From GetProcAddress() reference page, for lpProcName
:
The function or variable name, or the function's ordinal value. If this parameter is an ordinal value, it must be in the low-order word; the high-order word must be zero.
This means it might not be a pointer to string but the replacement function always treats it at such. This is a possible cause of the access violation as it will be using an integer value (182
for example) as the starting memory address of a null terminated string.
Use HIWORD()
to correct:
if (HIWORD(lpProcName))
{
prclist << "name: " << lpProcName << std::endl;
}
else
{
prclist << "ordinal: " << reinterpret_cast<DWORD>(lpProcName) << std::endl;
}