Through all the reasearch of @
Eric at
#21. Yep, the root cause is from
WINAPI GetModuleFileNameW , i dont know why it happened, but i have found the way to fix it. It failed randomly when dinput8 call
GetModuleFileNameW(0x400000, L"", 260) at 2 address for example: "0x538F2D02" and "0x5390AD14"..
As the document on MSDN:
PHP:
DWORD WINAPI GetModuleFileName(
_In_opt_ HMODULE hModule,
_Out_ LPTSTR lpFilename,
_In_ DWORD nSize
);
Here is the result return when it failed.
PHP:
ReturnAddr(538F2D02)
The module file name is: "". Result returned: 0
ReturnAddr(5390AD14)
The module file name is: "". Result returned: 0
[BUG] DInput8Create return failed.
Here is the result return when it success.
PHP:
ReturnAddr(5DA02D02)
The module file name is: "C:\Users\Public\MapleV62\localhost.exe" . Result returned: 38
ReturnAddr(5DA1AD14)
The module file name is: "C:". Result returned: 3
As you can see,
GetModuleFileNameW(0x400000, L"", 260) cannot return the path file name (the
lpFilename = "" in this case) and
return 0, so it made failed for DInput8Create. (Still don't know why it failed). After run client for 10+ time, i have realized that the first 4 bytes is change everytime you run the game, but the 4 last bytes never change. It is
0x2D02 and
0xAD14. So i have do more research with the result above:
1. I tried to modify and hardcode it to make
lpFilename="C:\Users\Public\MapleV62\localhost.exe" and the
return value is the length of
lpFilename....and hell yeah.... it work perfectly every single time
.
2.. As some research on the internet, it tried to make dinput8 to call
GetModuleFileNameW(NULL, L"", 260); and it work perfectly too.
So, after
1. and
2., i has detouring the
WINAPI GetModuleFileNameW to made it call this function:
You must be registered to see links
Here is the final result :laugh:
You must be registered to see links