add 64-bit mangled names of new and delete

pull/2/head
weidai 2007-04-16 00:40:48 +00:00
parent 3344b3eef1
commit 32b47f1a66
1 changed files with 13 additions and 3 deletions

14
dll.cpp
View File

@ -96,13 +96,23 @@ static void SetNewAndDeleteFunctionPointers()
}
}
// try getting these directly using mangled names of new and delete operators
hModule = GetModuleHandle("msvcrtd");
if (!hModule)
hModule = GetModuleHandle("msvcrt");
if (hModule)
{
s_pNew = (PNew)GetProcAddress(hModule, "??2@YAPAXI@Z"); // operator new
s_pDelete = (PDelete)GetProcAddress(hModule, "??3@YAXPAX@Z"); // operator delete
// 32-bit versions
s_pNew = (PNew)GetProcAddress(hModule, "??2@YAPAXI@Z");
s_pDelete = (PDelete)GetProcAddress(hModule, "??3@YAXPAX@Z");
if (s_pNew && s_pDelete)
return;
// 64-bit versions
s_pNew = (PNew)GetProcAddress(hModule, "??2@YAPEAX_K@Z");
s_pDelete = (PDelete)GetProcAddress(hModule, "??3@YAXPEAX@Z");
if (s_pNew && s_pDelete)
return;
}