Skip to content

add new stuff to obfus.h#23

Open
BJNFNE wants to merge 1 commit intoDosX-dev:mainfrom
BJNFNE:new-packer
Open

add new stuff to obfus.h#23
BJNFNE wants to merge 1 commit intoDosX-dev:mainfrom
BJNFNE:new-packer

Conversation

@BJNFNE
Copy link
Contributor

@BJNFNE BJNFNE commented Feb 14, 2026

No description provided.

@BJNFNE BJNFNE marked this pull request as draft February 15, 2026 07:54
@BJNFNE BJNFNE force-pushed the new-packer branch 6 times, most recently from adbab03 to fc8144b Compare February 15, 2026 08:15
@BJNFNE BJNFNE changed the title add new packers to obfus.h add new stuff to obfus.h Feb 15, 2026
@BJNFNE BJNFNE marked this pull request as ready for review February 15, 2026 08:40
@BJNFNE BJNFNE force-pushed the new-packer branch 3 times, most recently from 35ced69 to df65deb Compare February 15, 2026 15:38
@DosX-dev DosX-dev requested a review from Copilot February 15, 2026 16:04
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds additional obfuscation “fake section” data and expands the set of proxied/wrapped APIs in obfus.h.

Changes:

  • Add a new fake section marker (MacroMix).
  • Add a new CRT proxy wrapper for fflush.
  • Add additional WinAPI wrapper macros (CopyFile, CriticalSection APIs, and registry key APIs).

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +1371 to +1380
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))
Copy link

Copilot AI Feb 15, 2026

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.

Suggested change
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 uses AI. Check for mistakes.
Comment on lines +1383 to +1389
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))
Copy link

Copilot AI Feb 15, 2026

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).

Suggested change
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)

Copilot uses AI. Check for mistakes.
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__)
Copy link

Copilot AI Feb 15, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The fflush proxy macro casts GetProcAddress to size_t(*)() and returns a size_t, but the C runtime fflush signature is int 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 match int (*)(FILE*) (and include the parameter list) so calls are type-correct.

Suggested change
#define fflush(...) ((size_t(*)())GetProcAddress(LoadLibraryA_proxy(getStdLibName_proxy()), getFflushName_proxy()))(__VA_ARGS__)
#define fflush(stream) ((int (*)(FILE *))GetProcAddress(LoadLibraryA_proxy(getStdLibName_proxy()), getFflushName_proxy()))(stream)

Copilot uses AI. Check for mistakes.
Comment on lines +1308 to +1309
#define CopyFile(lpExistingFileName, lpNewFileName) \
CopyFile(obfh_int_proxy(lpExistingFileName), obfh_int_proxy(lpNewFileName))
Copy link

Copilot AI Feb 15, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

CopyFile on Windows takes 3 parameters (lpExistingFileName, lpNewFileName, bFailIfExists) and is commonly a macro mapping to CopyFileA/W. This new 2-argument macro will break callers that pass the third parameter and may also interfere with the CopyFile macro from Windows headers. Consider wrapping CopyFileA (or CopyFileW) with the correct 3-arg signature, or expose a separate CopyFile_proxy name to avoid colliding with the Windows macro.

Suggested change
#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 uses AI. Check for mistakes.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants