首页
社区
课程
招聘
一段汇编代码改写成c/c++的疑惑
发表于: 2011-10-13 19:08 4561

一段汇编代码改写成c/c++的疑惑

2011-10-13 19:08
4561
汇编代码:
void* pfn = GetProcAddress( GetModuleHandle(L"user32.dll"), (char*)1795 );

__asm
{
pushad
lea eax, d5
push eax
lea eax, d4
push eax
push pos
push 0
push hcur
call pfn
mov h, eax
popad
}

现在我修改的是:

#include <windows.h>

typedef   HICON ( WINAPI * fun_ptr)(  DWORD param_1,  DWORD  param_2,   DWORD  param_3,   DWORD  param_4,   void *  param_5);

#include <iostream>

void  main(void)
{
        fun_ptr   fun;

        //LoadLibraryW(L"user32.dll");
        fun = (fun_ptr) GetProcAddress( GetModuleHandleW(L"user32.dll"), (char*)1795 );
        //std::cout<<*fun;

        DWORD  d4 = 0,d5 = 0;
        if( (DWORD)fun == NULL )
                return ;

       

        HCURSOR  handl =  LoadCursorFromFileW( L"aero_pen_xl.cur" );

        HICON  hIcon;
        void * fun___ = (void *)fun;
        hIcon   =  fun( (DWORD)handl, 0, 0, d4, ( void *)d5);

}

但是总是错误, 用源汇编代码就能过,为什么呢?

[培训]科锐逆向工程师培训第53期2025年7月8日开班!

收藏
免费 0
支持
分享
最新回复 (8)
雪    币: 38
活跃值: (10)
能力值: ( LV2,RANK:10 )
在线值:
发帖
回帖
粉丝
2
大家帮个忙, 在线等, 谢谢了..
2011-10-13 19:09
0
雪    币: 38
活跃值: (10)
能力值: ( LV2,RANK:10 )
在线值:
发帖
回帖
粉丝
3
我现在想的是  这里的 lea和 mov的意思一样吗?
2011-10-13 19:10
0
雪    币: 38
活跃值: (10)
能力值: ( LV2,RANK:10 )
在线值:
发帖
回帖
粉丝
4
我的c++反汇编后是这样:

hIcon   =  fun( (DWORD)handl, 0, 0, d4, ( void *)d5);
00E6107D  mov         esi,esp  
00E6107F  mov         eax,dword ptr [d5]  
00E61082  push        eax  
00E61083  mov         ecx,dword ptr [d4]  
00E61086  push        ecx  
00E61087  push        0  
00E61089  push        0  
00E6108B  mov         edx,dword ptr [handl]  
00E6108E  push        edx  
00E6108F  call        dword ptr [fun]  
00E61092  cmp         esi,esp
2011-10-13 19:12
0
雪    币: 96
活跃值: (10)
能力值: ( LV2,RANK:10 )
在线值:
发帖
回帖
粉丝
5
不一样,lea是取地址的意思~~
2011-10-13 21:24
0
雪    币:
能力值: (RANK: )
在线值:
发帖
回帖
粉丝
6
hIcon   =  fun( (DWORD)handl, 0, 0, &d4, ( void *)&d5);
2011-10-13 21:47
0
雪    币: 93
活跃值: (41)
能力值: ( LV3,RANK:30 )
在线值:
发帖
回帖
粉丝
7
DWORD  d4 = 0,d5 = 0;
  if( (DWORD)fun == NULL )
    return ;

里面的返回应该return h;吧 你看你对应汇编后面的就是 mov h,eax
2011-10-13 23:05
0
雪    币: 7
活跃值: (55)
能力值: ( LV2,RANK:10 )
在线值:
发帖
回帖
粉丝
8
hIcon   =  fun( (DWORD)handl, 0, 0, d4, ( void *)d5);

应为
hIcon   =fun( (DWORD)handl, 0, 0, 0xd4, 0xd5);
2011-10-14 08:48
0
雪    币: 38
活跃值: (10)
能力值: ( LV2,RANK:10 )
在线值:
发帖
回帖
粉丝
9
谢谢各位,  之前就想到过lea指令,  但有点不清楚, 现在明白了。hIcon   =  fun( (DWORD)handl, 0, 0, &d4, ( void *)&d5);
2011-10-14 09:36
0
游客
登录 | 注册 方可回帖
返回