GrammaTech / ddisasm

A fast and accurate disassembler
https://grammatech.github.io/ddisasm/
GNU Affero General Public License v3.0
645 stars 60 forks source link

[BINARY] fails disassembly MSVC dll #55

Closed StarGazerM closed 1 year ago

StarGazerM commented 1 year ago

I am trying to reassemble windows dll using ddisasm. I am testing with a random repository on github https://github.com/RohitKumarPattanayak/Stack_CG_project

It's compiled with visual studio 2022. and binary is here (freeglut.dll) Debug.zip

Disassemble command:

ddisasm --asm=./freeglut_r.s --generate-import-libs --generate-resources ./freeglut.dll

Reassembled with:

ml /OUT:freeglut_r.dll .\freeglut_r.s /link /entry:_EntryPoint /DLL

but after I replaced original dll with the reassembled one, I got a prodcedure entry point __glutInitWithExit error when running original executable cg-final-stack.exe .

ddisasm version 1.5.5 (UNKNOWN 2022-10-29) ARM64+IA32+X64+ARM32+MIPS32

junghee commented 1 year ago

@StarGazerM I'm trying to reproduce the issue on my end. I'm having trouble with linking freeglut_r.s in my Visual Studio 2022:

Error   LNK2001 unresolved external symbol __imp__XcptFilter    
Error   LNK2001 unresolved external symbol _XcptFilter  
Error   LNK2001 unresolved external symbol __imp__amsg_exit 
Error   LNK2001 unresolved external symbol _amsg_exit   
Error   LNK2001 unresolved external symbol __imp__iob   
Error   LNK2001 unresolved external symbol _iob 
Error   LNK1120 6 unresolved externals  Project2

How did you make your ml command work?


Never mind, I was able to reproduce it on my end.

aeflores commented 1 year ago

This should be solved by https://github.com/GrammaTech/gtirb-pprinter/commit/babe432df2f9cf1e72a6ed1b5c6012d12fa02de4