可执行程序调用dll过程的反编译

来源:互联网 发布:淘宝刷钻石 编辑:程序博客网 时间:2024/05/29 04:46

我们先来一段C++的调用dll源代码

HINSTANCE hInstance=::LoadLibraryA("D:\\project\\dll\\Release\\dll.dll");typedef int(*fun)();fun hun=(fun)GetProcAddress(hInstance,"hehe");hun();int a=GetLastError();a++;

例子中的dll是我事先已经写好的,其反汇编代码是

.text:004017A0 ; void __thiscall CreverseDlg__OnBnClickedButton1(CreverseDlg *this).text:004017A0 ; void __thiscall CreverseDlg__OnBnClickedButton1(CreverseDlg *this).text:004017A0 ?OnBnClickedButton1@CreverseDlg@@QAEXXZ proc near.text:004017A0                                         ; DATA XREF: .rdata:00403774o.text:004017A0 this = ecx.text:004017A0                 push    offset LibFileName ; "D:\\project\\dll\\Release\\dll.dll".text:004017A5                 call    ds:__imp__LoadLibraryA@4 ; LoadLibraryA(x).text:004017AB                 push    offset ProcName ; "hehe".text:004017B0                 push    eax             ; hModule.text:004017B1                 call    ds:__imp__GetProcAddress@8 ; GetProcAddress(x,x).text:004017B7                 call    eax.text:004017B7                 jmp     ds:__imp__GetLastError@0 ; GetLastError().text:004017B7 ?OnBnClickedButton1@CreverseDlg@@QAEXXZ endp

这样我们就知道了,对于一些不太理解的ds:__imp_LoadLibrary过程实际上是在调用库函数,其中有一个我们需要注意的是call eax 可以看出,GetProcAddress的返回值是在eax

当中而call  eax则是执行了库中的函数,反汇编的结果是在执行我们自己写的函数时是跟调用在可执行程序当中定义的函数是相同的,所以,我们怎么自己写,才会有

ds:__imp_Loadlibrary有待于我进一步学习,看来自己知道的还是太少啊,继续学习ing。。。至于没有a++,应该是被编译器优化掉了...

原创粉丝点击