Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

dll exporting the same function it imports #50

Open
Trass3r opened this issue Jul 7, 2022 · 5 comments
Open

dll exporting the same function it imports #50

Trass3r opened this issue Jul 7, 2022 · 5 comments
Assignees
Labels
binary fails DDisasm fails to correctly disassemble a binary

Comments

@Trass3r
Copy link

Trass3r commented Jul 7, 2022

Did a quick test on a proxy dll, it struggled a bit with the import and export having the same name and produced:

EXTERN __imp__DirectDrawCreate_disambig_0_0:PROC
EXTERN _DirectDrawCreate_disambig_0_0:PROC
...
$L_100075d0:
DirectDrawCreate_disambig_0x100075d0_0 PROC EXPORT
DirectDrawCreate_disambig_0x100075d0_0 ENDP
            push EBP
            mov EBP,ESP
...
            jmp DWORD PTR __imp__DirectDrawCreate_disambig_0_0

So when rebuilding that into a dll it can't find the import nor is the export correct.
Removing the _disambig suffix everywhere fixes it (apart from a warning warning LNK4086: entrypoint '__EntryPoint' is not __stdcall with 12 bytes of arguments; image may not run).

ddisasm 1.5.4 (7026bf2 2022-07-07)
invoked like

ddisasm --asm d.asm --generate-import-libs ..\d.dll
ml /nologo /c /Zi d.asm
link /nologo /DLL /ENTRY:_EntryPoint /SUBSYSTEM:windows /DEBUG /OPT:REF /OPT:ICF d.obj
@Trass3r Trass3r added the binary fails DDisasm fails to correctly disassemble a binary label Jul 7, 2022
@aeflores
Copy link
Collaborator

Interesting, the _disambig_ is added by the pretty printer to avoid having multiple symbols with the same name. It sounds we should be making an exception for the case where one of the symbols is imported, and the other is locally defined.

We will address this ASAP.

@StarGazerM
Copy link

Hi, does this issue been solved now? I tried disassemble/reassemble Python windows today, seems when disasasembling python310.dll I saw similar probelm.

@aeflores
Copy link
Collaborator

aeflores commented Nov 4, 2022

It is not solved yet, but I am looking into it now.

@aeflores
Copy link
Collaborator

aeflores commented Nov 7, 2022

Hi @Trass3r would you have the example that you were trying available? That would help me figure out the best approach.

@StarGazerM I am not seeing this issue in python310.dll, which import/export symbol gets the _disambig_ suffix? Can you share the specific .dll where that happens?

@Trass3r
Copy link
Author

Trass3r commented Nov 7, 2022

I guess it can be replicated by something like https://godbolt.org/z/bzdrbvdra

extern "C"
{
__declspec(dllimport) int foo();
#pragma comment(linker, "/EXPORT:foo=_myfoo")
int myfoo() { return foo(); }
} 

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
binary fails DDisasm fails to correctly disassemble a binary
Projects
None yet
Development

No branches or pull requests

4 participants