Microsoft’s Macro Assembler and DumpBin are great tools, but you can’t feed DumpBin’s results into MASM — it lacks some info (like exception handling directives) which are necessary for correct assembly, and the syntax also seems to have issues.
Is there any x86/64 disassembler that can produce disassembled code which can be assembled without modification back into exactly the original executable?
Unless we’re talking about very simple, flat executables like .COM in DOS, I doubt it. These days executables contain a lot of stuff besides raw code and its data and fully extracting all the components and putting them back together isn’t something very straightforward or universally supported.
And then, don’t forget that many instructions can be encoded in several different ways (e.g.
mov ax, 0). To cope with the encoding ambiguity you should explicitly assembledb 0b8h, 0, 0ordb 0c7h, 0c0h, 0, 0instead ofmov ax, 0. db’s you can assemble without a loss.