Last active
March 30, 2020 04:53
-
-
Save Nukem9/51fcb405ba189e9135e4c143493246d7 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <idc.idc> | |
static get_str_length(ea) | |
{ | |
auto startEA = ea; | |
while (Byte(ea) != 0) | |
ea = ea + 1; | |
return ea - startEA; | |
} | |
static extract_string_at(ea) | |
{ | |
if (ea == 0) | |
return ""; | |
return get_bytes(ea, get_str_length(ea), 0); | |
} | |
static extract_struct_members(f, ea) | |
{ | |
auto memberArrayPtr = get_qword(ea + 0x20); | |
if (memberArrayPtr == 0 || get_qword(memberArrayPtr) == -1) | |
return 0; | |
while (1) | |
{ | |
if (get_qword(memberArrayPtr) == 0) | |
break; | |
fprintf(f, "\t%s %s%s;// 0x%X %s\n", | |
extract_string_at(get_qword(memberArrayPtr)), | |
extract_string_at(get_qword(memberArrayPtr + 0x8)), | |
extract_string_at(get_qword(memberArrayPtr + 0x10)), | |
get_dword(memberArrayPtr + 0x18), | |
extract_string_at(get_qword(memberArrayPtr + 0x28)) | |
); | |
memberArrayPtr = memberArrayPtr + 0x48; | |
} | |
return 1; | |
} | |
static extract_enum_members(f, ea) | |
{ | |
auto valueEntryPtr = get_qword(ea + 0x18); | |
if (valueEntryPtr == 0 || get_qword(valueEntryPtr) == -1) | |
return 0; | |
while (1) | |
{ | |
if (get_qword(valueEntryPtr) == 0) | |
break; | |
fprintf(f, "\t%s = 0x%lX,// %ld\n", | |
extract_string_at(get_qword(valueEntryPtr)), | |
get_qword(valueEntryPtr + 0x8), | |
get_qword(valueEntryPtr + 0x8) | |
); | |
valueEntryPtr = valueEntryPtr + 0x10; | |
} | |
return 1; | |
} | |
static main() | |
{ | |
auto x; | |
auto f = fopen("C:\\idtech.h", "w"); | |
for (x = 0x1434915C0; x < 0x1434C1B78; x = x + 0x48) | |
{ | |
// Message("pulling struct 0x%lX\n", x); | |
fprintf(f, "// sizeof() = 0x%X\n", get_dword(x + 0x10)); | |
fprintf(f, "struct %s : public %s\n{\n", extract_string_at(get_qword(x)), extract_string_at(get_qword(x + 8))); | |
extract_struct_members(f, x); | |
fprintf(f, "};\n\n"); | |
} | |
fprintf(f, "\n/* ENUMS */\n\n"); | |
for (x = 0x1434884E0; x < 0x14348E298; x = x + 0x28) | |
{ | |
// Message("pulling enum 0x%lX\n", x); | |
fprintf(f, "enum %s\n{\n", extract_string_at(get_qword(x))); | |
extract_enum_members(f, x); | |
fprintf(f, "};\n\n"); | |
} | |
fclose(f); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment