Please enable JavaScript to view this site.

Thread 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 svlTVAPI.c/h files you can use GetProcAddress to find the interface functions in the Thread 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 tv with api. For example tvSetThreadNameW() becomes apiSetThreadNameW();



Example usage


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


HMODULE getValidatorModule()
   HMODULE   hModule;
   hModule = GetModuleHandle(_T("svlThreadValidatorStub6432.dll"));                // 32 bit DLL with 64 bit Thread Validator GUI
   if (hModule == NULL)
      hModule = GetModuleHandle(_T("svlThreadValidatorStub_x64.dll"));        // 64 bit DLL with 64 bit Thread Validator GUI
   if (hModule == NULL)
      hModule = GetModuleHandle(_T("svlThreadValidatorStub.dll"));                // 32 bit DLL with 32 bit Thread Validator GUI
   return hModule;

// get module, will only succeed if Thread 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
    tvSetThreadNameW_FUNC   pFunc;
    // "apiSetThreadNameW" is equivalent to linking against "tvSetThreadNameW"
    pFunc = (tvSetThreadNameW_FUNC)GetProcAddress(hMod, "apiSetThreadNameW");
    if (pFunc != NULL)



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 svlThreadValidatorStub.dll(_x64).dll.


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