Closed enusbaum closed 4 years ago
Iced assumes you only feed it code, but the code at 2332h looks like a word table, so it's data.
Adding read-only data inside the code segment is pretty common. The only way to not disassemble it as code, but as data, is to figure out what is code and what isn't. A recursive traversal algorithm is often used by higher level disassemblers such as IDA.
Some links:
Every Instruction
has a FlowControl
property you can use to figure out if it's a branch instruction etc. You can then mark known branch targets as code and continue disassembling there later. Whatever is left is data or code that you didn't detect.
Thanks -- I'm going to close this as it's just the nature of the beast if I feed all the code into the disassembler as a single string.
Also, thanks for the feedback! I went ahead and just wrote a routine that manually does a .Create() on the byte at the given location if an instruction wasn't decoded successfully at that offset. Works well enough, might not be 100% but suits my needs.
Cheers!
I have code where the int16 offset for the jump target is stored within the same code segment.
but when I feed the code segment in for disassembly, it decodes this dataset as if it were opcodes:
The issue I'm running into is that there's a routine entry point actually at the address 0002:2394 that isn't being decoded properly because of this switch jump.
You can see it there, the ENTER 0x2, 0 being
Thoughts on how I can work around this? I could probably just manually write a routine that if Iced doesn't have a decoded instruction at that specific IP16 to grab the instruction before and after that address and try and manually reconstruct the missing instructions.
This is a bit of an edge case and weirdness with the compiler. I get the same issue on entry point in SEG1 of an NE DLL