能力值:
( LV13,RANK:970 )
|
-
-
2 楼
这是编译器的处理方式。历史遗留问题 :D :D
|
能力值:
( LV2,RANK:10 )
|
-
-
3 楼
能说的详细些吗?
|
能力值:
( LV12,RANK:650 )
|
-
-
4 楼
保留当前的堆栈指针,在后面用[ebp+xx][ebp-xx]来定位变量和参数
如果你自己写汇编完全不用这样
VC编译的WinMain没有吗,我记得也有啊
|
能力值:
( LV2,RANK:10 )
|
-
-
5 楼
直接用ESP不行吗? WinMain()的反汇编里就是这么做的. 虽然用EBP确实方便易懂一些. 不过为什么WinMain()的反汇编不是这样的呢? 不信你写个HelloWin试试然后反汇编试试?
|
能力值:
( LV4,RANK:50 )
|
-
-
6 楼
int WINAPI WinMain(HINSTANCE hInstance,HINSTANCE hPrevInstance,
12: PSTR szCmdLine,int iCmdShow)
13: {[COLOR=red]
00401030 push ebp ---------------
00401031 mov ebp,esp ---------------[/COLOR]
00401033 sub esp,88h
00401039 push ebx
0040103A push esi
0040103B push edi
0040103C lea edi,[ebp-88h]
00401042 mov ecx,22h
00401047 mov eax,0CCCCCCCCh
0040104C rep stos dword ptr [edi]
14: static TCHAR szAppName[]=TEXT("About3") ;
15: HWND hwnd ;
16: MSG msg ;
17: WNDCLASS wndclass ;
18:
19: wndclass.style = CS_HREDRAW | CS_VREDRAW ;
0040104E mov dword ptr [ebp-48h],3
20: wndclass.lpfnWndProc = WndProc ;
00401055 mov dword ptr [ebp-44h],offset @ILT+5(_WndProc@16) (0040100a)
21: wndclass.cbClsExtra = 0 ;
0040105C mov dword ptr [ebp-40h],0
22: wndclass.cbWndExtra = 0 ;
00401063 mov dword ptr [ebp-3Ch],0
23: wndclass.hInstance = hInstance ;
0040106A mov eax,dword ptr [ebp+8]
0040106D mov dword ptr [ebp-38h],eax
24: wndclass.hIcon = LoadIcon(hInstance,szAppName) ;
00401070 mov esi,esp
00401072 push offset szAppName (00422a30)
00401077 mov ecx,dword ptr [ebp+8]
0040107A push ecx
0040107B call dword ptr [__imp__LoadIconA@8 (004253dc)]
00401081 cmp esi,esp
00401083 call __chkesp (00401820)
00401088 mov dword ptr [ebp-34h],eax
25: wndclass.hCursor = LoadCursor(NULL,IDC_ARROW) ;
0040108B mov esi,esp
0040108D push 7F00h
00401092 push 0
00401094 call dword ptr [__imp__LoadCursorA@8 (004253e0)]
0040109A cmp esi,esp
0040109C call __chkesp (00401820)
004010A1 mov dword ptr [ebp-30h],eax
26: wndclass.hbrBackground = (HBRUSH)GetStockObject(WHITE_BRUSH) ;
004010A4 mov esi,esp
004010A6 push 0
004010A8 call dword ptr [__imp__GetStockObject@4 (0042525c)]
004010AE cmp esi,esp
004010B0 call __chkesp (00401820)
004010B5 mov dword ptr [ebp-2Ch],eax
27: wndclass.lpszMenuName = szAppName ;
004010B8 mov dword ptr [ebp-28h],offset szAppName (00422a30)
28: wndclass.lpszClassName = szAppName ;
004010BF mov dword ptr [ebp-24h],offset szAppName (00422a30)
29:
30: if(!RegisterClass(&wndclass))
004010C6 mov esi,esp
004010C8 lea edx,[ebp-48h]
004010CB push edx
004010CC call dword ptr [__imp__RegisterClassA@4 (004253e4)]
004010D2 cmp esi,esp
004010D4 call __chkesp (00401820)
004010D9 and eax,0FFFFh
004010DE test eax,eax
004010E0 jne WinMain+0D6h (00401106)
|
能力值:
( LV2,RANK:10 )
|
-
-
7 楼
用新版本的编译器一般用ebp架构,如果嵌入汇编的话,最好不要用
ebp,很容易出错
老版本的或者优化过的代码,可能就不这么用了
不过我比较喜欢ebp的,不用跟踪什么push/pop。。
|
|
|