Skip to content

Commit

Permalink
add 64-bit mangled names of new and delete
Browse files Browse the repository at this point in the history
  • Loading branch information
weidai11 committed Apr 16, 2007
1 parent 3344b3e commit 32b47f1
Showing 1 changed file with 13 additions and 3 deletions.
16 changes: 13 additions & 3 deletions dll.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -96,14 +96,24 @@ 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
return;
// 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;
}

OutputDebugString("Crypto++ was not able to obtain new and delete function pointers.\n");
Expand Down

0 comments on commit 32b47f1

Please sign in to comment.