hasherezade / masm_shc

A helper utility for creating shellcodes. Cleans MASM file generated by MSVC, gives refactoring hints.
MIT License
156 stars 30 forks source link

Infinite loop in get_module_by_name #3

Closed davemcincork closed 2 years ago

davemcincork commented 2 years ago

https://github.com/hasherezade/masm_shc/blob/05c71497225d132cbfa17a6f80ca61a711b8bf67/demos/peb_lookup.h#L83

if curr_module->BaseAddress is non-null and curr_module->BaseDllName.Buffer is null, the while loop goes infinite. Reason is that the advance to the next list item is skipped on continue. Suggest turning the while loop into a for loop, i.e.

for (
    PLDR_DATA_TABLE_ENTRY curr_module = Flink;
    curr_module && curr_module->BaseAddress;
    curr_module = (PLDR_DATA_TABLE_ENTRY)curr_module->InLoadOrderModuleList.Flink) {
hasherezade commented 2 years ago

Thank you, fixed!