How do you get HINSTANCE the code module?



  • Like MS Visual C+ get HINSTANCE (exe or dll) where the current function is present?



  • I agree that option with __ImageBase In some cases, two other standard methods could be used.

    Most often needed HINSTANCE Major Programme (EXE). It's easier to use. https://msdn.microsoft.com/ru-RU/library/windows/desktop/ms683199(v=vs.85).aspx ♪

    Another typical situation that we wrote DLL callingback function and someone calling her. In this case, we usually have the paramenals transferred to our vain module. With help GetModuleHandleEx with parameter GET_MODULE_HANDLE_EX_FLAG_FROM_ADDRESS I'll get it. HMODULE Ades of variable, a HINSTANCE DLL is what it is. HMODULE

    There are many other ways. But decisive is in what context we are.

    I personally, in my time, gave a lot to do with the general memorial of the program I put on. https://stackoverflow.com/a/3010909/315935 ♪ It shows that the vast virtual space of the process is blocked and each block belongs to its module. With the start of the module, all information about it can be found. I believe that GetModuleHandleEx It works like that.




Suggested Topics

  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2