- Joined
- Jan 18, 2010
- Messages
- 3,109
- Reaction score
- 1,139
**If you're trying to fix the "process hang" issue on higher version clients, read my below post.
As most if not all of you have already read my documentation thread regarding this problem, many weren't able to follow what I was doing and explaining. Thus, I've decided to quickly review what I was talking about and showing you how to fix it.
In the initial post, I was trying to fix the issue by bypassing the client's ZAPILoader checks that look if "dinput8.dll" is present and displays a korean error, and then placing a dinput8.dll into your MapleStory folder. The purpose of this was to "override" the dinput8 module that your operating system is loading from system32, and patch it by injecting the old windows 7 library that works for everyone. As a result, this fixed the problem for a lot of my friends who had tested it for me. Furthermore, for people whose clients were receiving the "CoInitialize failed" error (caused from the thread sleep workaround), this had fixed that problem because it wasn't delaying thread startup anymore.
However, after posting the thread, people were continuing to have problems even after patching dinput8 itself. So, if it wasn't from their OS's dinput8 library, then the exception itself is coming from outside the module itself. This is where a few posts later I tracked down after several AoB breakpoints, the function in dinput8 that was throwing the exception to the client. In order to confirm this was the true cause, I posted a modified dll that would throw a custom exception code instead of incorrect parameter.
Then, a day later, I had gotten a reply from PrinceReborn that had confirmed the location of the problem at hand was exactly what I had suggested -- the _hresValidInstanceVer_ function was throwing the exception. Thus, I had officially posted the source of the problem and continued digging deeper into WINAPI to figure out why this was happening with later operating systems. The issue at hand is because of the function GetModuleFileNameW in WINAPI failing. Therefore, if you were to figure out and fix the function that's failing, you would fix the incorrect parameter error.
My solution that I had done for Orion originally to fix not only the errors happening with this function in dinput8, but a handful of others as well, was to write a dinput8 wrapper (this way I didn't have to involve hooking). This had solved all the problems for me, and is the go-to method for fixing it on a lot of other games as well. While this way takes a lot more time and doesn't physically make any difference (the backend functions being fixed aren't all used by MapleStory in the first place), the alternative method was to hook the GetModuleFileNameW function and fix its return value. Since I never officially posted my wrapper fix, anhtanh95 had posted how he hooked GetModuleFileNameW in order to fix it.
So now that I've broken down how we got to the cause, how do we fix it?
Well, if you wish to hook GetModuleFileNameW to fix this problem, then I'll expect you to know what you're doing with detours enough to be able to implement the below function into your DLL.
Example Usage (DllMain):
Alright, so if you're not so advanced with C++ and detour hooking, then I advise you to use Orion's solution instead because no hooking is involved. First, you're going to need to jump the ZAPILoader checks in the client (time to get your OllyDbg game on!). Below are the client addresses for the common versions:
Once you've jumped the check, simply place
Hope this helps!
- Eric
As most if not all of you have already read my documentation thread regarding this problem, many weren't able to follow what I was doing and explaining. Thus, I've decided to quickly review what I was talking about and showing you how to fix it.
In the initial post, I was trying to fix the issue by bypassing the client's ZAPILoader checks that look if "dinput8.dll" is present and displays a korean error, and then placing a dinput8.dll into your MapleStory folder. The purpose of this was to "override" the dinput8 module that your operating system is loading from system32, and patch it by injecting the old windows 7 library that works for everyone. As a result, this fixed the problem for a lot of my friends who had tested it for me. Furthermore, for people whose clients were receiving the "CoInitialize failed" error (caused from the thread sleep workaround), this had fixed that problem because it wasn't delaying thread startup anymore.
However, after posting the thread, people were continuing to have problems even after patching dinput8 itself. So, if it wasn't from their OS's dinput8 library, then the exception itself is coming from outside the module itself. This is where a few posts later I tracked down after several AoB breakpoints, the function in dinput8 that was throwing the exception to the client. In order to confirm this was the true cause, I posted a modified dll that would throw a custom exception code instead of incorrect parameter.
Then, a day later, I had gotten a reply from PrinceReborn that had confirmed the location of the problem at hand was exactly what I had suggested -- the _hresValidInstanceVer_ function was throwing the exception. Thus, I had officially posted the source of the problem and continued digging deeper into WINAPI to figure out why this was happening with later operating systems. The issue at hand is because of the function GetModuleFileNameW in WINAPI failing. Therefore, if you were to figure out and fix the function that's failing, you would fix the incorrect parameter error.
My solution that I had done for Orion originally to fix not only the errors happening with this function in dinput8, but a handful of others as well, was to write a dinput8 wrapper (this way I didn't have to involve hooking). This had solved all the problems for me, and is the go-to method for fixing it on a lot of other games as well. While this way takes a lot more time and doesn't physically make any difference (the backend functions being fixed aren't all used by MapleStory in the first place), the alternative method was to hook the GetModuleFileNameW function and fix its return value. Since I never officially posted my wrapper fix, anhtanh95 had posted how he hooked GetModuleFileNameW in order to fix it.
So now that I've broken down how we got to the cause, how do we fix it?
Well, if you wish to hook GetModuleFileNameW to fix this problem, then I'll expect you to know what you're doing with detours enough to be able to implement the below function into your DLL.
Code:
/* GetModuleFileNameW hook used to fix the "Incorrect parameter" error within the DirectInput8 library */
bool Orion::Hook_GetModuleFileNameW(bool bEnable) {
static decltype(&GetModuleFileNameW) _GetModuleFileNameW = &GetModuleFileNameW;
decltype(&GetModuleFileNameW) GetModuleFileNameW_Hook = [](HMODULE hModule, LPWSTR lpFileName, DWORD dwSize) -> DWORD {
auto len = _GetModuleFileNameW(hModule, lpFileName, dwSize);
/* Check to see if the length is invalid (zero) */
if (!len) {
/* Try again without the provided module for a fixed result */
len = _GetModuleFileNameW(NULL, lpFileName, dwSize);
}
return len;
};
return SetHook(bEnable, reinterpret_cast<void**>(&_GetModuleFileNameW), GetModuleFileNameW_Hook);
}
Example Usage (DllMain):
Code:
/* Initiate the GetModuleFileNameW hook to fix DirectInput8 exceptions. */
if (!Orion::Hook_GetModuleFileNameW(true)) {
NotifyMessage("Failed to hook GetModuleFileNameW", Orion::NotifyType::Error);
return FALSE;
}
Alright, so if you're not so advanced with C++ and detour hooking, then I advise you to use Orion's solution instead because no hooking is involved. First, you're going to need to jump the ZAPILoader checks in the client (time to get your OllyDbg game on!). Below are the client addresses for the common versions:
Code:
v62 -> 00672F10 (JE to JMP)
v75 -> 006DF82D (JE to JMP)
v83 -> 00796357 (JE to JMP)
v90 -> 00864A34 (JMP 00864BCA)
v111 -> 0085EC08 (JMP 0085EE88)
Once you've jumped the check, simply place
You must be registered to see links
into your MapleStory folder. If done correctly (on either solution), you will no longer have any incorrect parameter problems. Hope this helps!
- Eric
Last edited: