-
-
Notifications
You must be signed in to change notification settings - Fork 100
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
Problem in 64-bit environment #22
Comments
Not sure I'm following, the api docs of GetExitCodeThread say nothing about different behaviour on different architectures? |
The What does change between 32-bit and 64-bit systems is the size of certain types, such as pointers and thus
The difference here is not in how This is why, in a 64-bit environment, you typically can't use a thread's exit code to pass back an However, I am afraid that shellcode need be written in this manner. |
Ah, because the HMODULE of LoadLibraryW gets cast into a 32bit DWORD behind the scenes, now I get it. I doubt this error has ever popped up before so IDK how big of a deal it is... |
as x64 and Arm64 (in windows) are little-endian, it's non-zero high bits that mess this up: #include <iostream>
#include <Windows.h>
int main() {
HMODULE handle {reinterpret_cast<HMODULE>(1)};
HMODULE handle2 {reinterpret_cast<HMODULE>(1 << 32)};
DWORD value { };
DWORD value2 { };
value = *reinterpret_cast<DWORD*>(&handle);
std::cout << sizeof(handle) << std::endl << value << std::endl << value2 << std::endl;
return 0;
}
|
Ah, sorry, you're right, I need a coffee and to wake up >_< non-zero high bits are what's needed for an incorrect complete HMODULE, but zero low bits are what's needed for a bad bool conversion in this logic. |
Doesn't fundamentally change the issue, but just for some context, there are some constraints on these values - they are literally pointers to the DLL's address space, not an arbitrary 64-bit value: https://learn.microsoft.com/en-us/windows/win32/dlls/dllmain
|
In a 64-bit environment (Win64), DWORD is a 32-bit unsigned integer type, while HMODULE, which is essentially a pointer, is 64 bits long.
Injector/Injector/Injector.cpp
Lines 97 to 98 in 4e0e14a
For instance, when a Dll is loaded with low double-word of base address being zero, false runtime error is thrown.
The text was updated successfully, but these errors were encountered: