The problem is that the functions which are hooked by VLD are not properly unhooked at VLD shutdown.
That means the hooked functions are called even though VLD is destroyed already and this leads to the crash.
In RestoreImport the hooked function GetProcAddress is used instead of the real GetProcAddress (_RGetProcAddress) function, so the replaced function pointers
are taken and not the original function pointers.
Comments: Are you saying LPCVOID original = VisualLeakDetector::_RGetProcAddress(exportmodule, importname); instead of LPCVOID original = GetProcAddress(exportmodule, importname); ?
That means the hooked functions are called even though VLD is destroyed already and this leads to the crash.
In RestoreImport the hooked function GetProcAddress is used instead of the real GetProcAddress (_RGetProcAddress) function, so the replaced function pointers
are taken and not the original function pointers.
Comments: Are you saying LPCVOID original = VisualLeakDetector::_RGetProcAddress(exportmodule, importname); instead of LPCVOID original = GetProcAddress(exportmodule, importname); ?