intstricmp_ascii_inline(constchar* a, constchar* b) { while (*a && *b) { char ca = toLowerAscii(*a++); char cb = toLowerAscii(*b++); if (ca != cb) return (ca < cb) ? -1 : 1; } if (*a == *b) return0; return *a ? 1 : -1; }
// ROR13-style ASCII (case-insensitive) hash for export names unsignedintror32(unsignedint v, unsignedint r) { return (v >> r) | (v << (32 - r)); }
unsignedinthash_accumulate_ascii_ci(unsignedint h, char c) { char u = c; if (u >= 'a' && u <= 'z') u = (char)(u - 32); return ror32(h, 13) + (unsignedchar)u; }
unsignedinthash_ascii_ci(constchar* s) { unsignedint h = 0; if (!s) return0; for (constchar* p = s; *p; ++p) { h = hash_accumulate_ascii_ci(h, *p); } return h; } unsignedinthash_literal_ci_runtime(constchar* s) { if (!s) return0; char tmp[64]; unsignedint i = 0; for (; i < sizeof(tmp) - 1 && s[i]; ++i) { tmp[i] = s[i]; } tmp[i] = '\0'; return hash_ascii_ci(tmp); } void* resolve_export_by_hash(HMODULE moduleBase, unsignedint targetHash) { if (!moduleBase) returnNULL; BYTE* base = (BYTE*)moduleBase; PIMAGE_DOS_HEADER dos = (PIMAGE_DOS_HEADER)base; if (!dos || dos->e_magic != IMAGE_DOS_SIGNATURE) returnNULL; PIMAGE_NT_HEADERS nt = (PIMAGE_NT_HEADERS)(base + dos->e_lfanew); if (!nt || nt->Signature != IMAGE_NT_SIGNATURE) returnNULL; IMAGE_DATA_DIRECTORY expDir = nt->OptionalHeader.DataDirectory[IMAGE_DIRECTORY_ENTRY_EXPORT]; if (!expDir.VirtualAddress || !expDir.Size) returnNULL; PIMAGE_EXPORT_DIRECTORY exp = (PIMAGE_EXPORT_DIRECTORY)(base + expDir.VirtualAddress); DWORD* nameRVAs = (DWORD*)(base + exp->AddressOfNames); WORD* ordinals = (WORD*)(base + exp->AddressOfNameOrdinals); DWORD* funcRVAs = (DWORD*)(base + exp->AddressOfFunctions);
for (DWORD i = 0; i < exp->NumberOfNames; ++i) { constchar* name = (constchar*)(base + nameRVAs[i]); if (!name) continue; unsignedint h = 0; for (constchar* p = name; *p; ++p) { h = hash_accumulate_ascii_ci(h, *p); } if (h == targetHash) { WORD ord = ordinals[i]; DWORD funcRva = funcRVAs[ord]; return (void*)(base + funcRva); } } returnNULL; }
unsignedint total = size + f->FileSize; unsignedint step = total / 10; unsignedint next = 0;
for (unsignedint i = 0; i < total; i++) { if (i >= next) { show_progress_bar(); next += step; } sprintf((char*)Cwrite, "0x%02x, ", (unsignedchar)array[i]); Wf->ThisWriteFile(Cwrite);