天天看點

WIN32程式對應彙編代碼

TITLE D:/vc6.0 project/WIN32MESSAGE/WIN32MESSAGE.cpp

.386P

include listing.inc

if @Version gt 510

.model FLAT

else

_TEXT SEGMENT PARA USE32 PUBLIC 'CODE'

_TEXT ENDS

_DATA SEGMENT DWORD USE32 PUBLIC 'DATA'

_DATA ENDS

CONST SEGMENT DWORD USE32 PUBLIC 'CONST'

CONST ENDS

_BSS SEGMENT DWORD USE32 PUBLIC 'BSS'

_BSS ENDS

$SYMBOLS SEGMENT BYTE USE32 'DEBSYM'

$SYMBOLS ENDS

$TYPES SEGMENT BYTE USE32 'DEBTYP'

$TYPES ENDS

_TLS SEGMENT DWORD USE32 PUBLIC 'TLS'

_TLS ENDS

; COMDAT _WinMain@16

_TEXT SEGMENT PARA USE32 PUBLIC 'CODE'

_TEXT ENDS

; COMDAT ?MyRegisterClass@@YAGPAUHINSTANCE__@@@Z

_TEXT SEGMENT PARA USE32 PUBLIC 'CODE'

_TEXT ENDS

; COMDAT ?InitInstance@@YAHPAUHINSTANCE__@@H@Z

_TEXT SEGMENT PARA USE32 PUBLIC 'CODE'

_TEXT ENDS

; COMDAT ?WndProc@@YGJPAUHWND__@@IIJ@Z

_TEXT SEGMENT PARA USE32 PUBLIC 'CODE'

_TEXT ENDS

; COMDAT ?About@@YGJPAUHWND__@@IIJ@Z

_TEXT SEGMENT PARA USE32 PUBLIC 'CODE'

_TEXT ENDS

FLAT GROUP _DATA, CONST, _BSS

ASSUME CS: FLAT, DS: FLAT, SS: FLAT

endif

PUBLIC ?hInst@@3PAUHINSTANCE__@@A ; hInst

PUBLIC ?szTitle@@3PADA ; szTitle

PUBLIC ?szWindowClass@@3PADA ; szWindowClass

_BSS SEGMENT

?hInst@@3PAUHINSTANCE__@@A DD 01H DUP (?) ; hInst

?szTitle@@3PADA DB 064H DUP (?) ; szTitle

?szWindowClass@@3PADA DB 064H DUP (?) ; szWindowClass

_BSS ENDS

PUBLIC ?MyRegisterClass@@YAGPAUHINSTANCE__@@@Z ; MyRegisterClass

PUBLIC ?InitInstance@@YAHPAUHINSTANCE__@@H@Z ; InitInstance

PUBLIC _WinMain@16

EXTRN __imp__LoadAcceleratorsA@8:NEAR

EXTRN __imp__TranslateAcceleratorA@12:NEAR

EXTRN __imp__LoadStringA@16:NEAR

EXTRN __chkesp:NEAR

EXTRN __imp__GetMessageA@16:NEAR

EXTRN __imp__TranslateMessage@4:NEAR

EXTRN __imp__DispatchMessageA@4:NEAR

; COMDAT _WinMain@16

_TEXT SEGMENT

_hInstance$ = 8

_nCmdShow$ = 20

_msg$ = -28

_hAccelTable$ = -32

_WinMain@16 PROC NEAR ; COMDAT

; 24 : {

push ebp

mov ebp, esp

sub esp, 96 ; 00000060H

push ebx

push esi

push edi

lea edi, DWORD PTR [ebp-96]

mov ecx, 24 ; 00000018H

mov eax, -858993460 ; ccccccccH

rep stosd

; 25 : // TODO: Place code here.

; 26 : MSG msg;

; 27 : HACCEL hAccelTable;

; 28 :

; 29 : // Initialize global strings

; 30 : LoadString(hInstance, IDS_APP_TITLE, szTitle, MAX_LOADSTRING);

mov esi, esp

push 100 ; 00000064H

push OFFSET FLAT:?szTitle@@3PADA ; szTitle

push 103 ; 00000067H

mov eax, DWORD PTR _hInstance$[ebp]

push eax

call DWORD PTR __imp__LoadStringA@16

cmp esi, esp

call __chkesp

; 31 : LoadString(hInstance, IDC_WIN32MESSAGE, szWindowClass, MAX_LOADSTRING);

mov esi, esp

push 100 ; 00000064H

push OFFSET FLAT:?szWindowClass@@3PADA ; szWindowClass

push 109 ; 0000006dH

mov ecx, DWORD PTR _hInstance$[ebp]

push ecx

call DWORD PTR __imp__LoadStringA@16

cmp esi, esp

call __chkesp

; 32 : MyRegisterClass(hInstance);

mov edx, DWORD PTR _hInstance$[ebp]

push edx

call ?MyRegisterClass@@YAGPAUHINSTANCE__@@@Z ; MyRegisterClass

add esp, 4

; 33 :

; 34 : // Perform application initialization:

; 35 : if (!InitInstance (hInstance, nCmdShow))

mov eax, DWORD PTR _nCmdShow$[ebp]

push eax

mov ecx, DWORD PTR _hInstance$[ebp]

push ecx

call ?InitInstance@@YAHPAUHINSTANCE__@@H@Z ; InitInstance

add esp, 8

test eax, eax

jne SHORT $L17608

; 37 : return FALSE;

xor eax, eax

jmp SHORT $L17605

$L17608:

; 39 :

; 40 : hAccelTable = LoadAccelerators(hInstance, (LPCTSTR)IDC_WIN32MESSAGE);

mov esi, esp

push 109 ; 0000006dH

mov edx, DWORD PTR _hInstance$[ebp]

push edx

call DWORD PTR __imp__LoadAcceleratorsA@8

cmp esi, esp

call __chkesp

mov DWORD PTR _hAccelTable$[ebp], eax

$L17611:

; 41 :

; 42 : // Main message loop:

; 43 : while (GetMessage(&msg, NULL, 0, 0))

mov esi, esp

push 0

push 0

push 0

lea eax, DWORD PTR _msg$[ebp]

push eax

call DWORD PTR __imp__GetMessageA@16

cmp esi, esp

call __chkesp

test eax, eax

je SHORT $L17612

; 45 : if (!TranslateAccelerator(msg.hwnd, hAccelTable, &msg))

mov esi, esp

lea ecx, DWORD PTR _msg$[ebp]

push ecx

mov edx, DWORD PTR _hAccelTable$[ebp]

push edx

mov eax, DWORD PTR _msg$[ebp]

push eax

call DWORD PTR __imp__TranslateAcceleratorA@12

cmp esi, esp

call __chkesp

test eax, eax

jne SHORT $L17613

; 47 : TranslateMessage(&msg);

mov esi, esp

lea ecx, DWORD PTR _msg$[ebp]

push ecx

call DWORD PTR __imp__TranslateMessage@4

cmp esi, esp

call __chkesp

; 48 : DispatchMessage(&msg);

mov esi, esp

lea edx, DWORD PTR _msg$[ebp]

push edx

call DWORD PTR __imp__DispatchMessageA@4

cmp esi, esp

call __chkesp

$L17613:

; 50 : }

jmp SHORT $L17611

$L17612:

; 51 :

; 52 : return msg.wParam;

mov eax, DWORD PTR _msg$[ebp+8]

$L17605:

; 53 : }

pop edi

pop esi

pop ebx

add esp, 96 ; 00000060H

cmp ebp, esp

call __chkesp

mov esp, ebp

pop ebp

ret 16 ; 00000010H

_WinMain@16 ENDP

_TEXT ENDS

PUBLIC ?WndProc@@YGJPAUHWND__@@IIJ@Z ; WndProc

EXTRN __imp__LoadCursorA@8:NEAR

EXTRN __imp__LoadIconA@8:NEAR

EXTRN __imp__RegisterClassExA@4:NEAR

; COMDAT ?MyRegisterClass@@YAGPAUHINSTANCE__@@@Z

_TEXT SEGMENT

_hInstance$ = 8

_wcex$ = -48

?MyRegisterClass@@YAGPAUHINSTANCE__@@@Z PROC NEAR ; MyRegisterClass, COMDAT

; 71 : {

push ebp

mov ebp, esp

sub esp, 112 ; 00000070H

push ebx

push esi

push edi

lea edi, DWORD PTR [ebp-112]

mov ecx, 28 ; 0000001cH

mov eax, -858993460 ; ccccccccH

rep stosd

; 72 : WNDCLASSEX wcex;

; 73 :

; 74 : wcex.cbSize = sizeof(WNDCLASSEX);

mov DWORD PTR _wcex$[ebp], 48 ; 00000030H

; 75 :

; 76 : wcex.style = CS_HREDRAW | CS_VREDRAW;

mov DWORD PTR _wcex$[ebp+4], 3

; 77 : wcex.lpfnWndProc = (WNDPROC)WndProc;

mov DWORD PTR _wcex$[ebp+8], OFFSET FLAT:?WndProc@@YGJPAUHWND__@@IIJ@Z ; WndProc

; 78 : wcex.cbClsExtra = 0;

mov DWORD PTR _wcex$[ebp+12], 0

; 79 : wcex.cbWndExtra = 0;

mov DWORD PTR _wcex$[ebp+16], 0

; 80 : wcex.hInstance = hInstance;

mov eax, DWORD PTR _hInstance$[ebp]

mov DWORD PTR _wcex$[ebp+20], eax

; 81 : wcex.hIcon = LoadIcon(hInstance, (LPCTSTR)IDI_WIN32MESSAGE);

mov esi, esp

push 107 ; 0000006bH

mov ecx, DWORD PTR _hInstance$[ebp]

push ecx

call DWORD PTR __imp__LoadIconA@8

cmp esi, esp

call __chkesp

mov DWORD PTR _wcex$[ebp+24], eax

; 82 : wcex.hCursor = LoadCursor(NULL, IDC_ARROW);

mov esi, esp

push 32512 ; 00007f00H

push 0

call DWORD PTR __imp__LoadCursorA@8

cmp esi, esp

call __chkesp

mov DWORD PTR _wcex$[ebp+28], eax

; 83 : wcex.hbrBackground = (HBRUSH)(COLOR_WINDOW+1);

mov DWORD PTR _wcex$[ebp+32], 6

; 84 : wcex.lpszMenuName = (LPCSTR)IDC_WIN32MESSAGE;

mov DWORD PTR _wcex$[ebp+36], 109 ; 0000006dH

; 85 : wcex.lpszClassName = szWindowClass;

mov DWORD PTR _wcex$[ebp+40], OFFSET FLAT:?szWindowClass@@3PADA ; szWindowClass

; 86 : wcex.hIconSm = LoadIcon(wcex.hInstance, (LPCTSTR)IDI_SMALL);

mov esi, esp

push 108 ; 0000006cH

mov edx, DWORD PTR _wcex$[ebp+20]

push edx

call DWORD PTR __imp__LoadIconA@8

cmp esi, esp

call __chkesp

mov DWORD PTR _wcex$[ebp+44], eax

; 87 :

; 88 : return RegisterClassEx(&wcex);

mov esi, esp

lea eax, DWORD PTR _wcex$[ebp]

push eax

call DWORD PTR __imp__RegisterClassExA@4

cmp esi, esp

call __chkesp

; 89 : }

pop edi

pop esi

pop ebx

add esp, 112 ; 00000070H

cmp ebp, esp

call __chkesp

mov esp, ebp

pop ebp

ret 0

?MyRegisterClass@@YAGPAUHINSTANCE__@@@Z ENDP ; MyRegisterClass

_TEXT ENDS

EXTRN __imp__UpdateWindow@4:NEAR

EXTRN __imp__CreateWindowExA@48:NEAR

EXTRN __imp__ShowWindow@8:NEAR

; COMDAT ?InitInstance@@YAHPAUHINSTANCE__@@H@Z

_TEXT SEGMENT

_hInstance$ = 8

_nCmdShow$ = 12

_hWnd$ = -4

?InitInstance@@YAHPAUHINSTANCE__@@H@Z PROC NEAR ; InitInstance, COMDAT

; 102 : {

push ebp

mov ebp, esp

sub esp, 68 ; 00000044H

push ebx

push esi

push edi

lea edi, DWORD PTR [ebp-68]

mov ecx, 17 ; 00000011H

mov eax, -858993460 ; ccccccccH

rep stosd

; 103 : HWND hWnd;

; 104 :

; 105 : hInst = hInstance; // Store instance handle in our global variable

mov eax, DWORD PTR _hInstance$[ebp]

mov DWORD PTR ?hInst@@3PAUHINSTANCE__@@A, eax ; hInst

; 106 :

; 107 : hWnd = CreateWindow(szWindowClass, szTitle, WS_OVERLAPPEDWINDOW,

; 108 : CW_USEDEFAULT, 0, CW_USEDEFAULT, 0, NULL, NULL, hInstance, NULL);

mov esi, esp

push 0

mov ecx, DWORD PTR _hInstance$[ebp]

push ecx

push 0

push 0

push 0

push -2147483648 ; 80000000H

push 0

push -2147483648 ; 80000000H

push 13565952 ; 00cf0000H

push OFFSET FLAT:?szTitle@@3PADA ; szTitle

push OFFSET FLAT:?szWindowClass@@3PADA ; szWindowClass

push 0

call DWORD PTR __imp__CreateWindowExA@48

cmp esi, esp

call __chkesp

mov DWORD PTR _hWnd$[ebp], eax

; 109 :

; 110 : if (!hWnd)

cmp DWORD PTR _hWnd$[ebp], 0

jne SHORT $L17634

; 112 : return FALSE;

xor eax, eax

jmp SHORT $L17630

$L17634:

; 114 :

; 115 : ShowWindow(hWnd, nCmdShow);

mov esi, esp

mov edx, DWORD PTR _nCmdShow$[ebp]

push edx

mov eax, DWORD PTR _hWnd$[ebp]

push eax

call DWORD PTR __imp__ShowWindow@8

cmp esi, esp

call __chkesp

; 116 : UpdateWindow(hWnd);

mov esi, esp

mov ecx, DWORD PTR _hWnd$[ebp]

push ecx

call DWORD PTR __imp__UpdateWindow@4

cmp esi, esp

call __chkesp

; 117 :

; 118 : return TRUE;

mov eax, 1

$L17630:

; 119 : }

pop edi

pop esi

pop ebx

add esp, 68 ; 00000044H

cmp ebp, esp

call __chkesp

mov esp, ebp

pop ebp

ret 0

?InitInstance@@YAHPAUHINSTANCE__@@H@Z ENDP ; InitInstance

_TEXT ENDS

PUBLIC ?About@@YGJPAUHWND__@@IIJ@Z ; About

EXTRN __imp__DrawTextA@20:NEAR

EXTRN __imp__DefWindowProcA@16:NEAR

EXTRN __imp__BeginPaint@8:NEAR

EXTRN __imp__EndPaint@8:NEAR

EXTRN __imp__PostQuitMessage@4:NEAR

EXTRN _strlen:NEAR

EXTRN __imp__DestroyWindow@4:NEAR

EXTRN __imp__GetClientRect@8:NEAR

EXTRN __imp__DialogBoxParamA@20:NEAR

; COMDAT ?WndProc@@YGJPAUHWND__@@IIJ@Z

_TEXT SEGMENT

_hWnd$ = 8

_message$ = 12

_wParam$ = 16

_lParam$ = 20

_wmId$ = -4

_wmEvent$ = -8

_ps$ = -72

_hdc$ = -76

_szHello$ = -176

_rt$17664 = -192

?WndProc@@YGJPAUHWND__@@IIJ@Z PROC NEAR ; WndProc, COMDAT

; 132 : {

push ebp

mov ebp, esp

sub esp, 264 ; 00000108H

push ebx

push esi

push edi

lea edi, DWORD PTR [ebp-264]

mov ecx, 66 ; 00000042H

mov eax, -858993460 ; ccccccccH

rep stosd

; 133 : int wmId, wmEvent;

; 134 : PAINTSTRUCT ps;

; 135 : HDC hdc;

; 136 : TCHAR szHello[MAX_LOADSTRING];

; 137 : LoadString(hInst, IDS_HELLO, szHello, MAX_LOADSTRING);

mov esi, esp

push 100 ; 00000064H

lea eax, DWORD PTR _szHello$[ebp]

push eax

push 106 ; 0000006aH

mov ecx, DWORD PTR ?hInst@@3PAUHINSTANCE__@@A ; hInst

push ecx

call DWORD PTR __imp__LoadStringA@16

cmp esi, esp

call __chkesp

; 140 : {

mov edx, DWORD PTR _message$[ebp]

mov DWORD PTR -196+[ebp], edx

cmp DWORD PTR -196+[ebp], 2

je $L17665

cmp DWORD PTR -196+[ebp], 15 ; 0000000fH

je $L17663

cmp DWORD PTR -196+[ebp], 273 ; 00000111H

je SHORT $L17650

jmp $L17666

$L17650:

; 141 : case WM_COMMAND:

; 142 : wmId = LOWORD(wParam);

mov eax, DWORD PTR _wParam$[ebp]

and eax, 65535 ; 0000ffffH

mov DWORD PTR _wmId$[ebp], eax

; 143 : wmEvent = HIWORD(wParam);

mov ecx, DWORD PTR _wParam$[ebp]

shr ecx, 16 ; 00000010H

and ecx, 65535 ; 0000ffffH

and ecx, 65535 ; 0000ffffH

mov DWORD PTR _wmEvent$[ebp], ecx

; 146 : {

mov edx, DWORD PTR _wmId$[ebp]

mov DWORD PTR -200+[ebp], edx

cmp DWORD PTR -200+[ebp], 104 ; 00000068H

je SHORT $L17658

cmp DWORD PTR -200+[ebp], 105 ; 00000069H

je SHORT $L17661

jmp SHORT $L17662

$L17658:

; 147 : case IDM_ABOUT:

; 148 : DialogBox(hInst, (LPCTSTR)IDD_ABOUTBOX, hWnd, (DLGPROC)About);

mov esi, esp

push 0

push OFFSET FLAT:?About@@YGJPAUHWND__@@IIJ@Z ; About

mov eax, DWORD PTR _hWnd$[ebp]

push eax

push 103 ; 00000067H

mov ecx, DWORD PTR ?hInst@@3PAUHINSTANCE__@@A ; hInst

push ecx

call DWORD PTR __imp__DialogBoxParamA@20

cmp esi, esp

call __chkesp

; 149 : break;

jmp SHORT $L17655

$L17661:

; 150 : case IDM_EXIT:

; 151 : DestroyWindow(hWnd);

mov esi, esp

mov edx, DWORD PTR _hWnd$[ebp]

push edx

call DWORD PTR __imp__DestroyWindow@4

cmp esi, esp

call __chkesp

; 152 : break;

jmp SHORT $L17655

$L17662:

; 153 : default:

; 154 : return DefWindowProc(hWnd, message, wParam, lParam);

mov esi, esp

mov eax, DWORD PTR _lParam$[ebp]

push eax

mov ecx, DWORD PTR _wParam$[ebp]

push ecx

mov edx, DWORD PTR _message$[ebp]

push edx

mov eax, DWORD PTR _hWnd$[ebp]

push eax

call DWORD PTR __imp__DefWindowProcA@16

cmp esi, esp

call __chkesp

jmp $L17640

$L17655:

; 156 : break;

jmp $L17647

$L17663:

; 157 : case WM_PAINT:

; 158 : hdc = BeginPaint(hWnd, &ps);

mov esi, esp

lea ecx, DWORD PTR _ps$[ebp]

push ecx

mov edx, DWORD PTR _hWnd$[ebp]

push edx

call DWORD PTR __imp__BeginPaint@8

cmp esi, esp

call __chkesp

mov DWORD PTR _hdc$[ebp], eax

; 159 : // TODO: Add any drawing code here...

; 160 : RECT rt;

; 161 : GetClientRect(hWnd, &rt);

mov esi, esp

lea eax, DWORD PTR _rt$17664[ebp]

push eax

mov ecx, DWORD PTR _hWnd$[ebp]

push ecx

call DWORD PTR __imp__GetClientRect@8

cmp esi, esp

call __chkesp

; 162 : DrawText(hdc, szHello, strlen(szHello), &rt, DT_CENTER);

mov esi, esp

push 1

lea edx, DWORD PTR _rt$17664[ebp]

push edx

lea eax, DWORD PTR _szHello$[ebp]

push eax

call _strlen

add esp, 4

push eax

lea ecx, DWORD PTR _szHello$[ebp]

push ecx

mov edx, DWORD PTR _hdc$[ebp]

push edx

call DWORD PTR __imp__DrawTextA@20

cmp esi, esp

call __chkesp

; 163 : EndPaint(hWnd, &ps);

mov esi, esp

lea eax, DWORD PTR _ps$[ebp]

push eax

mov ecx, DWORD PTR _hWnd$[ebp]

push ecx

call DWORD PTR __imp__EndPaint@8

cmp esi, esp

call __chkesp

; 164 : break;

jmp SHORT $L17647

$L17665:

; 165 : case WM_DESTROY:

; 166 : PostQuitMessage(0);

mov esi, esp

push 0

call DWORD PTR __imp__PostQuitMessage@4

cmp esi, esp

call __chkesp

; 167 : break;

jmp SHORT $L17647

$L17666:

; 168 : default:

; 169 : return DefWindowProc(hWnd, message, wParam, lParam);

mov esi, esp

mov edx, DWORD PTR _lParam$[ebp]

push edx

mov eax, DWORD PTR _wParam$[ebp]

push eax

mov ecx, DWORD PTR _message$[ebp]

push ecx

mov edx, DWORD PTR _hWnd$[ebp]

push edx

call DWORD PTR __imp__DefWindowProcA@16

cmp esi, esp

call __chkesp

jmp SHORT $L17640

$L17647:

; 171 : return 0;

xor eax, eax

$L17640:

; 172 : }

pop edi

pop esi

pop ebx

add esp, 264 ; 00000108H

cmp ebp, esp

call __chkesp

mov esp, ebp

pop ebp

ret 16 ; 00000010H

?WndProc@@YGJPAUHWND__@@IIJ@Z ENDP ; WndProc

_TEXT ENDS

EXTRN __imp__EndDialog@8:NEAR

; COMDAT ?About@@YGJPAUHWND__@@IIJ@Z

_TEXT SEGMENT

_hDlg$ = 8

_message$ = 12

_wParam$ = 16

?About@@YGJPAUHWND__@@IIJ@Z PROC NEAR ; About, COMDAT

; 176 : {

push ebp

mov ebp, esp

sub esp, 68 ; 00000044H

push ebx

push esi

push edi

lea edi, DWORD PTR [ebp-68]

mov ecx, 17 ; 00000011H

mov eax, -858993460 ; ccccccccH

rep stosd

; 178 : {

mov eax, DWORD PTR _message$[ebp]

mov DWORD PTR -4+[ebp], eax

cmp DWORD PTR -4+[ebp], 272 ; 00000110H

je SHORT $L17677

cmp DWORD PTR -4+[ebp], 273 ; 00000111H

je SHORT $L17678

jmp SHORT $L17674

$L17677:

; 179 : case WM_INITDIALOG:

; 180 : return TRUE;

mov eax, 1

jmp SHORT $L17672

$L17678:

; 181 :

; 182 : case WM_COMMAND:

; 183 : if (LOWORD(wParam) == IDOK || LOWORD(wParam) == IDCANCEL)

mov ecx, DWORD PTR _wParam$[ebp]

and ecx, 65535 ; 0000ffffH

cmp ecx, 1

je SHORT $L17682

mov edx, DWORD PTR _wParam$[ebp]

and edx, 65535 ; 0000ffffH

cmp edx, 2

jne SHORT $L17681

$L17682:

; 185 : EndDialog(hDlg, LOWORD(wParam));

mov eax, DWORD PTR _wParam$[ebp]

and eax, 65535 ; 0000ffffH

mov esi, esp

push eax

mov ecx, DWORD PTR _hDlg$[ebp]

push ecx

call DWORD PTR __imp__EndDialog@8

cmp esi, esp

call __chkesp

; 186 : return TRUE;

mov eax, 1

jmp SHORT $L17672

$L17681:

$L17674:

; 190 : return FALSE;

xor eax, eax

$L17672:

; 191 : }

pop edi

pop esi

pop ebx

add esp, 68 ; 00000044H

cmp ebp, esp

call __chkesp

mov esp, ebp

pop ebp

ret 16 ; 00000010H

?About@@YGJPAUHWND__@@IIJ@Z ENDP ; About

_TEXT ENDS

END

繼續閱讀