Please enable JavaScript to view this site.

Memory Validator Help

Navigation: Native API

Calling the API via GetProcAddress

Scroll Prev Top Next More

 

Calling API functions using GetProcAddress

 

If you don't want to use the svlMVAPI.c/h files you can use GetProcAddress() to find the interface functions in the Memory Validator DLL.

 

The interface functions have different names and do not use C++ name mangling, but have identical parameters to the API functions.

 

To determine the function name take any native API name, replace the leading mv with api. For example mvSetWatermarkEx() becomes apiSetWatermarkEx();

 

 

Example usage

 

typedef void (*mvSetWatermark_FUNC)(const TCHAR   *name);

 

HMODULE getValidatorModule()
{
   HMODULE   hModule;
 
   hModule = GetModuleHandle(_T("svlMemoryValidatorStub6432.dll"));                // 32 bit DLL with 64 bit Memory Validator GUI
   if (hModule == NULL)
      hModule = GetModuleHandle(_T("svlMemoryValidatorStub_x64.dll"));        // 64 bit DLL with 64 bit Memory Validator GUI
   if (hModule == NULL)
      hModule = GetModuleHandle(_T("svlMemoryValidatorStub.dll"));                // 32 bit DLL with 32 bit Memory Validator GUI
 
   return hModule;
}
 

HMODULE   hMod;
 
// get module, will only succeed if Memory Validator launched this app or is injected into this app
 
hMod = getValidatorModule();
if (hMod != NULL)
{
    // MV is present, lookup the function and call it to set a watermark for this location in the code
 
    mvSetWatermark_FUNC   pFunc;
 
    // "apiSetWatermark" is equivalent to linking against "mvSetWatermark"
 
    pFunc = (mvSetWatermark_FUNC)GetProcAddress(hMod, "apiSetWatermark");
    if (pFunc != NULL)
    {
        (*pFunc)(watermarkName);
    }
}

 

 

API functions and their GetProcAddress names

 

For any API functions not listed, try looking up the name in svlMemoryValidatorStub.dll using depends.exe or PE File Browser.

 

 

 

Other exported functions

 

You may see some other functions exported from svlMemoryValidatorStub.dll(_x64).dll.

 

warningnote These other functions are for Memory Validator's use. Using them may damage memory locations and/or crash your code. Best not to use them!