GetModuleHandle on executable fails
I'm currently learning more about hooking and am interested in trying to make a few examples where I write a test program and then hook some function in it from my injected dll. However, when I try to get a handle to the program (using GetModuleHandle(NULL), which should return the exe module), it fails. I do not obtain any handle to it. Is it simply not possible to do it this way if you are injecting a dll, would it only work if my program loaded the dll?
Passing NULL should get the handle of your module, i.e. the one you injected. Sidenote, the exe is most likely loaded at 0x00400000..