Open hahaleyile opened 3 months ago
The code above return
MH_ERROR_MEMORY_ALLOC
, but the hook is working
That doesn't make sense, I believe there's some misunderstanding on your side. Perhaps it failed in a specific process, and the hook worked in another process?
In any case, similar code is used as the core of Windhawk, which is used by many users and was proven to be working and stable, so I believe the problems you see are as a result of your code changes.
MH_ERROR_MEMORY_ALLOC
can also be caused by the following, although it's not a common scenario:
https://github.com/TsudaKageyu/minhook/issues/107
Thanks for the reply! After your tip, I found out that there was a global variable defined in the namespace, and moving it out fix the problem. Also, there are indeed some special high-privileged processes that can't be injected.
In my project, I defined slot handle in namespace before, this caused problem. May I ask why?
https://github.com/m417z/global-inject-demo/blob/608f007e9e0566b340ac2e6684bf2001106cca57/global-inject-lib/customization_session.cpp#L30-L33
The code above return
MH_ERROR_MEMORY_ALLOC
, but the hook is working. What's even stranger is that when I add a new hook toGetComputerNameW
, all hooks fail.