Closed 2vg closed 3 years ago
hi I didn't know that the resolve_rva option could be set to false. I used it, but I get another error.
code changed to this:
while !(*module_list).DllBase.is_null() {
let dll_base = (*module_list).DllBase;
let size = (*module_list).SizeOfImage as usize;
module_list = (*module_list).InLoadOrderLinks.Flink as *mut LDR_DATA_TABLE_ENTRY;
let buffer = std::slice::from_raw_parts::<u8>(dll_base as _, size);
let opts = goblin::pe::options::ParseOptions{ resolve_rva: false };
let res = goblin::pe::PE::parse_with_opts(buffer, &opts);
if res.is_err() { continue }
let parsed = res?;
println!("{}", parsed.name.unwrap());
println!("parsed!");
}
Error: bad input invalid utf8 (56906)
Caused by:
bad input invalid utf8 (56906)
Only some loaded images fail, but others parsed correctly. (For example, ntdll, kernel32, etc)
By ignoring the error, I was able to achieve what I wanted to do, but I'm not sure if this is a problem to be resolved in the future, so I'll leave an issue. If you're willing to close it, you can close it!
I thought goblin was the only library that could parse PE correctly, but unfortunately after getting the list of modules loaded from PEB, trying to parse from the DllBase address seems to fail halfway. (fyi, pelite succeeded in parsing this, but failed to parse the system DLL. Goblin is perfect for parsing from disc dll.) Here is the procedure for reproducing the error.
put this in
Cargo.toml
then, code like a this:
example output (got this error on my env):
I don't know if this only happens in my environment. Or is this not a problem and my code is wrong?
thanks in advance!