Skip to content

Instantly share code, notes, and snippets.

@Konctantin
Created April 28, 2016 14:14
Show Gist options
  • Select an option

  • Save Konctantin/124bdda46e1a9fa86c1830467dee08d6 to your computer and use it in GitHub Desktop.

Select an option

Save Konctantin/124bdda46e1a9fa86c1830467dee08d6 to your computer and use it in GitHub Desktop.
opcode_dumper.c
void DumpHandlers(DWORD_PTR baseAddr)
{
int getPtrOffset = 0x257D58; // x86 21463
typedef DWORD*(*GetPtr)();
typedef BOOL(__cdecl *CheckOpcode)(WORD);
DWORD* ptrTable = GetPtr(baseAddr + getPtrOffset)();
DWORD v7 = *ptrTable;
for (const auto& element : opcodeList)
{
int opcode = element.first;
char* name = element.second;
while (1)
{
if (CheckOpcode(*(DWORD *)v7 + 4)(opcode))
{
DWORD handler = (*(DWORD*)v7 + 20) - baseAddr;
printf("Opcode: 0x%04X Handler: 0x%08X %s\n", opcode, handler, name);
break;
}
// todo: need validate this check
if (v7 == (*(DWORD*)(ptrTable + 4) * *(ptrTable+4)))
break;
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment