Created
May 30, 2023 16:38
-
-
Save Unam3dd/801be6a05ba9027403564dc581160a7c to your computer and use it in GitHub Desktop.
Backup of vostrok API like ifunc function
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include "vs_std.h" | |
#include "_vs_std.h" | |
#include <cpuid.h> | |
///////////////////////////// | |
// | |
// INCLUDES | |
// | |
///////////////////////////// | |
#include "vs_types.h" | |
void *__vs_memmove_slow(void *dst, const void *src, vs_size_t size) | |
{ | |
if (!dst || !src || !size) | |
return (dst); | |
vs_uint8_t *tdst = (vs_uint8_t *)dst; | |
vs_uint8_t *tsrc = (vs_uint8_t *)src; | |
for (vs_size_t i = 0; i < size; i++) | |
*tdst++ = *tsrc++; | |
return (dst); | |
} | |
void *vs_memmove(void *dst, const void *src, vs_size_t size) __attribute__ ((ifunc ("__vs_memmove_ifunc"))); | |
static void *(*__vs_memmove_ifunc (void))(void *dst, const void *src, vs_size_t size) | |
{ | |
unsigned int eax, ebx, ecx, edx; | |
__get_cpuid(0x7, &eax, &ebx, &ecx, &edx); | |
if ((ebx & 0x100)) | |
return (__vs_memmove_erms); | |
return (__vs_memmove_slow); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment