windows-nt/Source/XPSP1/NT/base/win32/fusion/appweek/common/context.cpp

27 lines
565 B
C++
Raw Permalink Normal View History

2020-09-26 03:20:57 -05:00
#include "stdinc.h"
HRESULT SxApwHmoduleFromAddress(void* p, HMODULE* phModule)
{
HRESULT hr = S_OK;
MEMORY_BASIC_INFORMATION mbi;
SIZE_T size;
size = VirtualQuery(p, &mbi, sizeof(mbi));
if (size < sizeof(mbi))
{
hr = HRESULT_FROM_WIN32(GetLastError());
goto Exit;
}
*phModule = (HMODULE)mbi.AllocationBase;
Exit:
return hr;
}
HRESULT SxApwHmoduleFromObject(IUnknown* punk, HMODULE* phModule)
/*
This assumes no marshaling!
*/
{
return SxApwHmoduleFromAddress(*reinterpret_cast<void**>(punk), phModule);
}