-
Notifications
You must be signed in to change notification settings - Fork 148
add new stuff to obfus.h #23
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -1092,6 +1092,15 @@ char *getFwriteName_proxy() { | |||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||
| #define fwrite(...) ((size_t(*)())GetProcAddress(LoadLibraryA_proxy(getStdLibName_proxy()), getFwriteName_proxy()))(__VA_ARGS__) | ||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||
| // fflush | ||||||||||||||||||||||||||||||||||||||||||
| char *getFflushName_proxy() { | ||||||||||||||||||||||||||||||||||||||||||
| BREAK_STACK_1; | ||||||||||||||||||||||||||||||||||||||||||
| FAKE_CPUID; | ||||||||||||||||||||||||||||||||||||||||||
| return "fflush"; | ||||||||||||||||||||||||||||||||||||||||||
| // return ({ char result[32]; sprintf(result, getCharMask(_6), _f, _f, _l, _u, _s, _h); result; }); | ||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||
| #define fflush(...) ((size_t(*)())GetProcAddress(LoadLibraryA_proxy(getStdLibName_proxy()), getFflushName_proxy()))(__VA_ARGS__) | ||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||
| // exit | ||||||||||||||||||||||||||||||||||||||||||
| char *getExitName_proxy() { | ||||||||||||||||||||||||||||||||||||||||||
| BREAK_STACK_1; | ||||||||||||||||||||||||||||||||||||||||||
|
|
@@ -1295,6 +1304,9 @@ int toupper_proxy(int c) OBFH_SECTION_ATTRIBUTE { | |||||||||||||||||||||||||||||||||||||||||
| #define ReadFile(hFile, lpBuffer, nNumberOfBytesToRead, lpNumberOfBytesRead, lpOverlapped) \ | ||||||||||||||||||||||||||||||||||||||||||
| ReadFile(obfh_int_proxy(hFile), obfh_int_proxy(lpBuffer), obfh_int_proxy(nNumberOfBytesToRead), obfh_int_proxy(lpNumberOfBytesRead), obfh_int_proxy(lpOverlapped)) | ||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||
| #define CopyFile(lpExistingFileName, lpNewFileName) \ | ||||||||||||||||||||||||||||||||||||||||||
| CopyFile(obfh_int_proxy(lpExistingFileName), obfh_int_proxy(lpNewFileName)) | ||||||||||||||||||||||||||||||||||||||||||
|
Comment on lines
+1307
to
+1308
|
||||||||||||||||||||||||||||||||||||||||||
| #define CopyFile(lpExistingFileName, lpNewFileName) \ | |
| CopyFile(obfh_int_proxy(lpExistingFileName), obfh_int_proxy(lpNewFileName)) | |
| #undef CopyFile | |
| #define CopyFile(lpExistingFileName, lpNewFileName, bFailIfExists) \ | |
| CopyFileA(obfh_int_proxy(lpExistingFileName), obfh_int_proxy(lpNewFileName), obfh_int_proxy(bFailIfExists)) |
Copilot
AI
Feb 15, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These CriticalSection wrappers pass LPCRITICAL_SECTION through obfh_int_proxy, which is int obfh_int_proxy(int value). That forces pointer→int→pointer conversions (and truncation on 64-bit), risking crashes/UB. Introduce a pointer-sized proxy (e.g., using uintptr_t/intptr_t) or at least cast via uintptr_t so pointer arguments are preserved on x86_64.
| InitializeCriticalSection(obfh_int_proxy(lpCriticalSection)) | |
| #define EnterCriticalSection(lpCriticalSection) \ | |
| EnterCriticalSection(obfh_int_proxy(lpCriticalSection)) | |
| #define LeaveCriticalSection(lpCriticalSection) \ | |
| LeaveCriticalSection(obfh_int_proxy(lpCriticalSection)) | |
| #define DeleteCriticalSection(lpCriticalSection) \ | |
| DeleteCriticalSection(obfh_int_proxy(lpCriticalSection)) | |
| InitializeCriticalSection(lpCriticalSection) | |
| #define EnterCriticalSection(lpCriticalSection) \ | |
| EnterCriticalSection(lpCriticalSection) | |
| #define LeaveCriticalSection(lpCriticalSection) \ | |
| LeaveCriticalSection(lpCriticalSection) | |
| #define DeleteCriticalSection(lpCriticalSection) \ | |
| DeleteCriticalSection(lpCriticalSection) |
Copilot
AI
Feb 15, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The registry wrappers (RegCloseKey / RegOpenKeyA / RegCreateKeyA) also route handle/pointer parameters through obfh_int_proxy (an int), which can truncate HKEY/pointer values on 64-bit and yields incorrect argument types. Use a pointer-sized proxy type (e.g., uintptr_t) for these parameters (and/or avoid proxying pointer/handle values through an int helper).
| RegCloseKey(obfh_int_proxy(hKey)) | |
| #define RegOpenKeyA(hKey, lpSubKey, phkResult) \ | |
| RegOpenKeyA(obfh_int_proxy(hKey), obfh_int_proxy(lpSubKey), obfh_int_proxy(phkResult)) | |
| #define RegCreateKeyA(hKey, lpSubKey, phkResult) \ | |
| RegCreateKeyA(obfh_int_proxy(hKey), obfh_int_proxy(lpSubKey), obfh_int_proxy(phkResult)) | |
| RegCloseKey(hKey) | |
| #define RegOpenKeyA(hKey, lpSubKey, phkResult) \ | |
| RegOpenKeyA(hKey, lpSubKey, phkResult) | |
| #define RegCreateKeyA(hKey, lpSubKey, phkResult) \ | |
| RegCreateKeyA(hKey, lpSubKey, phkResult) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The
fflushproxy macro castsGetProcAddresstosize_t(*)()and returns asize_t, but the C runtimefflushsignature isint fflush(FILE*). This mismatch can lead to incorrect return values and, on some ABIs, undefined behavior from calling a function through an incompatible function-pointer type. Update the cast/typedef to matchint (*)(FILE*)(and include the parameter list) so calls are type-correct.