Source code of Windows XP (NT5)
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

26 lines
565 B

  1. #include "stdinc.h"
  2. HRESULT SxApwHmoduleFromAddress(void* p, HMODULE* phModule)
  3. {
  4. HRESULT hr = S_OK;
  5. MEMORY_BASIC_INFORMATION mbi;
  6. SIZE_T size;
  7. size = VirtualQuery(p, &mbi, sizeof(mbi));
  8. if (size < sizeof(mbi))
  9. {
  10. hr = HRESULT_FROM_WIN32(GetLastError());
  11. goto Exit;
  12. }
  13. *phModule = (HMODULE)mbi.AllocationBase;
  14. Exit:
  15. return hr;
  16. }
  17. HRESULT SxApwHmoduleFromObject(IUnknown* punk, HMODULE* phModule)
  18. /*
  19. This assumes no marshaling!
  20. */
  21. {
  22. return SxApwHmoduleFromAddress(*reinterpret_cast<void**>(punk), phModule);
  23. }