-
Автор темы
- #1
Обратите внимание, пользователь заблокирован на форуме. Не рекомендуется проводить сделки.
modules:
math:
string:
memory:
Код:
typedef struct _UNICODE_STRING {
USHORT Length;
USHORT MaximumLength;
PWCH Buffer;
} UNICODE_STRING, * PUNICODE_STRING;
typedef struct _PEB_LDR_DATA {
ULONG Length;
bool Initialized;
void* SsHandle;
LIST_ENTRY InLoadOrderModuleList;
LIST_ENTRY InMemoryOrderModuleList;
LIST_ENTRY InInitializationOrderModuleList;
} PEB_LDR_DATA, * PPEB_LDR_DATA;
typedef struct _LDR_DATA_TABLE_ENTRY
{
LIST_ENTRY InLoadOrderLinks;
LIST_ENTRY InMemoryOrderLinks;
LIST_ENTRY InInitializationOrderLinks;
ULONGLONG DllBase;
void* EntryPoint;
ULONG SizeOfImage;
UNICODE_STRING FullDllName;
UNICODE_STRING BaseDllName;
}LDR_DATA_TABLE_ENTRY, * PLDR_DATA_TABLE_ENTRY;
unsigned long long GetModuleBase(const wchar_t* moduleName)
{
PEB_LDR_DATA PebLdrData = *(PEB_LDR_DATA*)(*(uintptr_t *)(__readgsqword(0x60) + 0x18));
LDR_DATA_TABLE_ENTRY* LdrModule = (LDR_DATA_TABLE_ENTRY*)PebLdrData.InLoadOrderModuleList.Flink;
while (LdrModule->DllBase)
{
if (wstrcmpi(LdrModule->BaseDllName.Buffer, moduleName) == 0) return LdrModule->DllBase;
LdrModule = (LDR_DATA_TABLE_ENTRY*)LdrModule->InLoadOrderLinks.Flink;
}
return 0;
}
unsigned long long GetProcAddress(unsigned long long imageBase, const char* funcName)
{
PIMAGE_DOS_HEADER DosHeader = (PIMAGE_DOS_HEADER)imageBase;
PIMAGE_NT_HEADERS NtHeaders = (PIMAGE_NT_HEADERS)(imageBase + DosHeader->e_lfanew);
if (NtHeaders->OptionalHeader.DataDirectory[IMAGE_DIRECTORY_ENTRY_EXPORT].VirtualAddress != 0)
{
PIMAGE_EXPORT_DIRECTORY ExportDirectory = PIMAGE_EXPORT_DIRECTORY(imageBase + NtHeaders->OptionalHeader.DataDirectory[IMAGE_DIRECTORY_ENTRY_EXPORT].VirtualAddress);
if (ExportDirectory->NumberOfNames != 0)
{
PULONG NamePointerRVA = PULONG(imageBase + ExportDirectory->AddressOfNames);
PUSHORT NameOrdinals = PUSHORT(imageBase + ExportDirectory->AddressOfNameOrdinals);
PULONG FunctionsRVA = PULONG(imageBase + ExportDirectory->AddressOfFunctions);
if ((uintptr_t)funcName < 0xFFFF)
{
if ((uintptr_t)funcName - ExportDirectory->Base < ExportDirectory->NumberOfFunctions)
return imageBase + FunctionsRVA[(uintptr_t)funcName - ExportDirectory->Base];
}
else
{
for (ULONG i = 0; i < ExportDirectory->NumberOfNames; ++i)
if (strcmpi((char*)(imageBase + NamePointerRVA[i]), funcName) == 0)
return imageBase + FunctionsRVA[NameOrdinals[i]];
}
}
}
return 0;
}
Код:
float pow(float x, float y) {
return _mm_cvtss_f32(_mm_pow_ps(_mm_set_ss(x), _mm_set_ss(y)));
}
float sqrt(float x) {
return _mm_cvtss_f32(_mm_sqrt_ss(_mm_set_ss(x)));
}
float cos(float x) {
return _mm_cvtss_f32(_mm_cos_ps(_mm_set_ss(x)));
}
float exp(float x) {
return _mm_cvtss_f32(_mm_exp_ps(_mm_set_ss(x)));
}
float sin(float x) {
return _mm_cvtss_f32(_mm_sin_ps(_mm_set_ss(x)));
}
float logf(float x)
{
return _mm_cvtss_f32(_mm_log_ps(_mm_set_ss(x)));
}
float logf(float base, float x)
{
if (x <= 0 || base <= 0 || base == 1) return 0;
return logf(x) / logf(base);
}
int logi(int base, int x)
{
int result = 0;
if (x > 0 && base > 1) while (x /= base) ++result;
return result;
}
Код:
#define __ascii_tolower(c) ( (((c) >= 'A') && ((c) <= 'Z')) ? ((c) - 'A' + 'a') : (c) )
#define __ascii_toupper(c) ( (((c) >= 'a') && ((c) <= 'z')) ? ((c) - 'a' + 'A') : (c) )
#define __ascii_iswalpha(c) ( ('A' <= (c) && (c) <= 'Z') || ( 'a' <= (c) && (c) <= 'z'))
#define __ascii_iswdigit(c) ( '0' <= (c) && (c) <= '9')
#define __ascii_towlower(c) ( (((c) >= L'A') && ((c) <= L'Z')) ? ((c) - L'A' + L'a') : (c) )
#define __ascii_towupper(c) ( (((c) >= L'a') && ((c) <= L'z')) ? ((c) - L'a' + L'A') : (c) )
int atoi(const char* s)
{
int number = 0;
bool min = false;
if (*s == '-')
{
min = true;
*s++;
}
while ((*s >= '0') && (*s <= '9'))
{
number = 10 * number + *s - '0';
*s++;
}
return min ? -number : number;
}
char* itoa(int _Value, char* _Buffer)
{
PCHAR result = _Buffer;
if (_Value < 0)
{
_Value = -_Value;
*_Buffer = '-';
_Buffer++;
}
int count = logi(10, _Value);
if (count > 0)
{
_Buffer[count++] = 0;
while (count > 0)
{
_Buffer[--count] = _Value % 10 + '0';
_Value /= 10;
}
}
return result;
}
int wtoi(const wchar_t* s)
{
int number = 0;
bool min = false;
if (*s == '-')
{
min = true;
*s++;
}
while ((*s >= L'0') && (*s <= L'9'))
{
number = 10 * number + *s - L'0';
*s++;
}
return min ? -number : number;
}
wchar_t* itow(int _Value, wchar_t* _Buffer)
{
PWCHAR result = _Buffer;
if (_Value < 0)
{
_Value = -_Value;
*_Buffer = L'-';
_Buffer++;
}
int count = logi(10, _Value);
if (count > 0)
{
_Buffer[count++] = 0;
while (count > 0)
{
_Buffer[--count] = _Value % 10 + L'0';
_Value /= 10;
}
}
return result;
}
int tolower(int _C)
{
//en
if ((_C >= 'A') && (_C <= 'Z')) return _C - 'A' + 'a';
//ru
if ((_C >= 'А') && (_C <= 'Я')) return _C - 'А' + 'а';
if (_C == 'Ё') return 'ё';
return _C;
}
int towlower(int _C)
{
//en
if ((_C >= L'A') && (_C <= L'Z')) return _C - L'A' + L'a';
//ru
if ((_C >= L'А') && (_C <= L'Я')) return _C - L'А' + L'а';
if (_C == L'Ё') return L'ё';
return _C;
}
int toupper(int _C)
{
//en
if ((_C >= 'a') && (_C <= 'z')) return _C - 'a' + 'A';
//ru
if ((_C >= 'а') && (_C <= 'я')) return _C - 'а' + 'А';
if (_C == 'ё') return 'Ё';
return _C;
}
int towupper(int _C)
{
//en
if ((_C >= L'a') && (_C <= L'z')) return _C - L'a' + L'A';
//ru
if ((_C >= L'а') && (_C <= L'я')) return _C - L'а' + L'А';
if (_C == L'ё') return L'Ё';
return _C;
}
int isdigit(int _C)
{
return (_C >= '0') && (_C <= '9');
}
bool isalpha(int _C)
{
//en
if ((_C >= 'A' && _C <= 'Z') || (_C >= 'a' && _C <= 'z')) return true;
//ru
if ((_C >= 'А' && _C <= 'Я') || (_C >= 'а' && _C <= 'я') || (_C == 'Ё') || (_C == 'ё')) return true;
return false;
}
int iswalpha(int _C)
{
//en
if ((_C >= L'A' && _C <= L'Z') || (_C >= L'a' && _C <= L'z')) return true;
//ru
if ((_C >= L'А' && _C <= L'Я') || (_C >= L'а' && _C <= L'я') || (_C == L'Ё') || (_C == L'ё')) return true;
return _C;
}
bool isspace(int _C)
{
return _C == ' ';
}
UINT lstrlenA(LPCSTR text)
{
UINT value = 0;
while (*text++ != 0) value++;
return value;
}
UINT lstrlenA(LPCWSTR text)
{
UINT value = 0;
while (*text++ != 0) value++;
return value;
}
int lstrcmpA(LPCSTR lpString1, LPCSTR lpString2)
{
while (*lpString1 != 0 || *lpString2 != 0)
{
if (*lpString1 > *lpString2) return 1;
if (*lpString1 < *lpString2) return -1;
*lpString1++;
*lpString2++;
}
return 0;
}
int lstrcmpW(LPCWSTR lpString1, LPCWSTR lpString2)
{
while (*lpString1 != 0 || *lpString2 != 0)
{
if (*lpString1 > *lpString2) return 1;
if (*lpString1 < *lpString2) return -1;
*lpString1++;
*lpString2++;
}
return 0;
}
int lstrcmpiA(LPCSTR lpString1, LPCSTR lpString2)
{
while (*lpString1 != 0 || *lpString2 != 0)
{
if (tolower(*lpString1) > tolower(*lpString2)) return 1;
if (tolower(*lpString1) < tolower(*lpString2)) return -1;
*lpString1++;
*lpString2++;
}
return 0;
}
int lstrcmpiW(LPCWSTR lpString1, LPCWSTR lpString2)
{
while (*lpString1 != 0 || *lpString2 != 0)
{
if (tolower(*lpString1) > tolower(*lpString2)) return 1;
if (tolower(*lpString1) < tolower(*lpString2)) return -1;
*lpString1++;
*lpString2++;
}
return 0;
}
LPCSTR strstr(LPCSTR str1, LPCSTR str2)
{
LPSTR cp = (LPSTR)str1;
LPSTR s1, s2;
if (!*str2) return (LPSTR)str1;
while (*cp)
{
s1 = cp;
s2 = (LPSTR)str2;
while (*s2 && !(*s1 - *s2)) s1++, s2++;
if (!*s2) return cp;
cp++;
}
return 0;
}
LPCWSTR wcsstr(LPCWSTR wcs1, LPCWSTR wcs2)
{
LPWSTR cp = (LPWSTR)wcs1;
LPWSTR s1, s2;
if (!*wcs2) return (LPWSTR)wcs1;
while (*cp)
{
s1 = cp;
s2 = (LPWSTR)wcs2;
while (*s2 && !(*s1 - *s2)) s1++, s2++;
if (!*s2) return(cp);
cp++;
}
return 0;
}
LPCSTR strchr(LPCSTR string, CHAR ch)
{
while (*string && *string != (CHAR)ch) string++;
if (*string == (CHAR)ch) return (CHAR*)string;
return 0;
}
LPCWSTR wcschr(LPCWSTR string, WCHAR ch)
{
while (*string && *string != (WCHAR)ch) string++;
if (*string == (WCHAR)ch) return string;
return 0;
}
LPCSTR strrchr(LPCSTR string, CHAR ch)
{
PCHAR start = (PCHAR)string;
while (*string++) ;
while (--string != start && *string != ch) ;
if (*string == ch) return string;
return 0;
}
LPCWSTR wcsrchr(LPCWSTR string, WCHAR ch)
{
LPWSTR start = (LPWSTR)string;
while (*string++) ;
while (--string != start && *string != ch) ;
if (*string == ch) return string;
return 0;
}
LPCSTR lstrcatA(LPSTR str1, LPCSTR str2)
{
LPCSTR result = str1;
while (*str1 != 0 && *str2 != 0)
{
if (*str1 == 0)
{
*str1 = *str2;
*str2++;
}
*str1++;
}
*str1 = 0;
return result;
}
LPCWSTR lstrcatW(LPWSTR str1, LPCWSTR str2)
{
LPCWSTR result = str1;
while (*str1 != 0 && *str2 != 0)
{
if (*str1 == 0)
{
*str1 = *str2;
*str2++;
}
*str1++;
}
*str1 = 0;
return result;
}
LPCSTR lstrcpyA(LPSTR str1, LPCSTR str2)
{
LPCSTR result = str1;
while (*str2 != 0) *str1++ = *str2++;
*str1 = 0;
return result;
}
LPCWSTR lstrcpyW(LPWSTR str1, LPCWSTR str2)
{
LPCWSTR result = str1;
while (*str2 != 0) *str1++ = *str2++;
*str1 = 0;
return result;
}
Код:
void mbstowcs(wchar_t* _Dest, char const* _Source, int _MaxCount)
{
int Count = 0;
while (unsigned char c = *_Source)
{
if (Count >= _MaxCount) break;
switch (c)
{
case 168:
*_Dest = 1025;
break;
case 184:
*_Dest = 1105;
break;
default:
*_Dest = c + ((c >= 192 && c <= 255) ? 848 : 0);
break;
}
*_Source++;
*_Dest++;
}
}
void wcstombs(char* _Dest, wchar_t const* _Source, int _MaxCount)
{
int Count = 0;
while (unsigned short c = *_Source)
{
if (Count >= _MaxCount) break;
switch (c)
{
case 1025:
*_Dest = 168;
break;
case 1105:
*_Dest = 184;
break;
default:
*_Dest = c - ((c >= 1040 && c <= 1103) ? 848 : 0);
break;
}
*_Source++;
*_Dest++;
}
}
Код:
void* memchr(const void* buf, int chr, int cnt)
{
while (cnt && (*(unsigned char*)buf != (unsigned char)chr)) {
buf = (unsigned char*)buf + 1;
cnt--;
}
return(cnt ? (void*)buf : 0);
}
void* memset(void* _Dst, UCHAR _Val, SIZE_T _Size)
{
__stosb((PBYTE)_Dst, _Val, _Size);
}
void* memmove(void* dst, void* src, size_t count)
{
PUCHAR Dest = (PUCHAR)dst, Srv = (PUCHAR)src;
void* ret = dst;
if (Dest <= Srv || Dest >= (Srv + count))
{
while (count--) *Dest++ = *Srv++;
}
else
{
Dest += count - 1;
Srv += count - 1;
while (count--) *Dest-- = *Srv--;
}
return ret;
}
int memcmp(void const* _Buf1, void const* _Buf2, size_t _Size)
{
char* buf1 = (char*)_Buf1;
char* buf2 = (char*)_Buf2;
if (!_Size) return 0;
while (--_Size && *buf1 == *buf2)
{
buf1++;
buf2++;
}
return *buf1 - *buf2;
}