对__stdcall命名规则怀疑
源代码:
#include <stdio.h>
extern "C"
{
void __stdcall Print(void)
{
printf("how are you");
}
}
void __stdcall Show(void)
{
printf("Fine Thank you");
}
int main()
{
int num = 5;
printf("This is %d\n", num);
Print();
Show();
getchar();
return 0;
}
自动生成代码//////////////////////////////////////////////////////////////////////////////////
TITLE G:\Documents and Settings\xkx\桌面\Try.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 ??_C@_0M@GIIH@how?5are?5you?$AA@
CONST SEGMENT DWORD USE32 PUBLIC 'CONST'
CONST ENDS
; COMDAT ??_C@_0P@MFFM@Fine?5Thank?5you?$AA@
CONST SEGMENT DWORD USE32 PUBLIC 'CONST'
CONST ENDS
; COMDAT ??_C@_0M@IHNM@This?5is?5?$CFd?6?$AA@
CONST SEGMENT DWORD USE32 PUBLIC 'CONST'
CONST ENDS
; COMDAT _Print@0
_TEXT SEGMENT PARA USE32 PUBLIC 'CODE'
_TEXT ENDS
; COMDAT ?Show@@YGXXZ
_TEXT SEGMENT PARA USE32 PUBLIC 'CODE'
_TEXT ENDS
; COMDAT _main
_TEXT SEGMENT PARA USE32 PUBLIC 'CODE'
_TEXT ENDS
FLAT GROUP _DATA, CONST, _BSS
ASSUME CS: FLAT, DS: FLAT, SS: FLAT
endif
PUBLIC _Print@0
PUBLIC ??_C@_0M@GIIH@how?5are?5you?$AA@ ; `string'
EXTRN _printf:NEAR
EXTRN __chkesp:NEAR
; COMDAT ??_C@_0M@GIIH@how?5are?5you?$AA@
; File G:\Documents and Settings\xkx\桌面\Try.cpp
CONST SEGMENT
??_C@_0M@GIIH@how?5are?5you?$AA@ DB 'how are you', 00H ; `string'
CONST ENDS
; COMDAT _Print@0
_TEXT SEGMENT
_Print@0 PROC NEAR ; COMDAT
; 8 : {
00000 55 push ebp
00001 8b ec mov ebp, esp
00003 83 ec 40 sub esp, 64 ; 00000040H
00006 53 push ebx
00007 56 push esi
00008 57 push edi
00009 8d 7d c0 lea edi, DWORD PTR [ebp-64]
0000c b9 10 00 00 00 mov ecx, 16 ; 00000010H
00011 b8 cc cc cc cc mov eax, -858993460 ; ccccccccH
00016 f3 ab rep stosd
; 9 : printf("how are you");
00018 68 00 00 00 00 push OFFSET FLAT:??_C@_0M@GIIH@how?5are?5you?$AA@ ; `string'
0001d e8 00 00 00 00 call _printf
00022 83 c4 04 add esp, 4
; 10 : }
00025 5f pop edi
00026 5e pop esi
00027 5b pop ebx
00028 83 c4 40 add esp, 64 ; 00000040H
0002b 3b ec cmp ebp, esp
0002d e8 00 00 00 00 call __chkesp
00032 8b e5 mov esp, ebp
00034 5d pop ebp
00035 c3 ret 0
_Print@0 ENDP
_TEXT ENDS
PUBLIC ?Show@@YGXXZ ; Show
PUBLIC ??_C@_0P@MFFM@Fine?5Thank?5you?$AA@ ; `string'
; COMDAT ??_C@_0P@MFFM@Fine?5Thank?5you?$AA@
; File G:\Documents and Settings\xkx\桌面\Try.cpp
CONST SEGMENT
??_C@_0P@MFFM@Fine?5Thank?5you?$AA@ DB 'Fine Thank you', 00H ; `string'
CONST ENDS
; COMDAT ?Show@@YGXXZ
_TEXT SEGMENT
?Show@@YGXXZ PROC NEAR ; Show, COMDAT
; 15 : {
00000 55 push ebp
00001 8b ec mov ebp, esp
00003 83 ec 40 sub esp, 64 ; 00000040H
00006 53 push ebx
00007 56 push esi
00008 57 push edi
00009 8d 7d c0 lea edi, DWORD PTR [ebp-64]
0000c b9 10 00 00 00 mov ecx, 16 ; 00000010H
00011 b8 cc cc cc cc mov eax, -858993460 ; ccccccccH
00016 f3 ab rep stosd
; 16 : printf("Fine Thank you");
00018 68 00 00 00 00 push OFFSET FLAT:??_C@_0P@MFFM@Fine?5Thank?5you?$AA@ ; `string'
0001d e8 00 00 00 00 call _printf
00022 83 c4 04 add esp, 4
; 17 : }
00025 5f pop edi
00026 5e pop esi
00027 5b pop ebx
00028 83 c4 40 add esp, 64 ; 00000040H
0002b 3b ec cmp ebp, esp
0002d e8 00 00 00 00 call __chkesp
00032 8b e5 mov esp, ebp
00034 5d pop ebp
00035 c3 ret 0
?Show@@YGXXZ ENDP ; Show
_TEXT ENDS
PUBLIC _main
PUBLIC ??_C@_0M@IHNM@This?5is?5?$CFd?6?$AA@ ; `string'
EXTRN __iob:BYTE
EXTRN __filbuf:NEAR
; COMDAT ??_C@_0M@IHNM@This?5is?5?$CFd?6?$AA@
; File G:\Documents and Settings\xkx\桌面\Try.cpp
CONST SEGMENT
??_C@_0M@IHNM@This?5is?5?$CFd?6?$AA@ DB 'This is %d', 0aH, 00H ; `string'
CONST ENDS
; COMDAT _main
_TEXT SEGMENT
_num$ = -4
_main PROC NEAR ; COMDAT
; 20 : {
00000 55 push ebp
00001 8b ec mov ebp, esp
00003 83 ec 48 sub esp, 72 ; 00000048H
00006 53 push ebx
00007 56 push esi
00008 57 push edi
00009 8d 7d b8 lea edi, DWORD PTR [ebp-72]
0000c b9 12 00 00 00 mov ecx, 18 ; 00000012H
00011 b8 cc cc cc cc mov eax, -858993460 ; ccccccccH
00016 f3 ab rep stosd
; 21 : int num = 5;
00018 c7 45 fc 05 00
00 00 mov DWORD PTR _num$[ebp], 5
; 22 : printf("This is %d\n", num);
0001f 8b 45 fc mov eax, DWORD PTR _num$[ebp]
00022 50 push eax
00023 68 00 00 00 00 push OFFSET FLAT:??_C@_0M@IHNM@This?5is?5?$CFd?6?$AA@ ; `string'
00028 e8 00 00 00 00 call _printf
0002d 83 c4 08 add esp, 8
; 23 : Print();
00030 e8 00 00 00 00 call _Print@0
; 24 : Show();
00035 e8 00 00 00 00 call ?Show@@YGXXZ ; Show
; 25 : getchar();
0003a 8b 0d 04 00 00
00 mov ecx, DWORD PTR __iob+4
00040 83 e9 01 sub ecx, 1
00043 89 0d 04 00 00
00 mov DWORD PTR __iob+4, ecx
00049 83 3d 04 00 00
00 00 cmp DWORD PTR __iob+4, 0
00050 7c 22 jl SHORT $L551
00052 8b 15 00 00 00
00 mov edx, DWORD PTR __iob
00058 0f be 02 movsx eax, BYTE PTR [edx]
0005b 25 ff 00 00 00 and eax, 255 ; 000000ffH
00060 89 45 f8 mov DWORD PTR -8+[ebp], eax
00063 8b 0d 00 00 00
00 mov ecx, DWORD PTR __iob
00069 83 c1 01 add ecx, 1
0006c 89 0d 00 00 00
00 mov DWORD PTR __iob, ecx
00072 eb 10 jmp SHORT $L552
$L551:
00074 68 00 00 00 00 push OFFSET FLAT:__iob
00079 e8 00 00 00 00 call __filbuf
0007e 83 c4 04 add esp, 4
00081 89 45 f8 mov DWORD PTR -8+[ebp], eax
$L552:
; 26 : return 0;
00084 33 c0 xor eax, eax
; 27 : }
00086 5f pop edi
00087 5e pop esi
00088 5b pop ebx
00089 83 c4 48 add esp, 72 ; 00000048H
0008c 3b ec cmp ebp, esp
0008e e8 00 00 00 00 call __chkesp
00093 8b e5 mov esp, ebp
00095 5d pop ebp
00096 c3 ret 0
_main ENDP
_TEXT ENDS
END
///////////////////////////////////////////////////////////////////////////////////
Print()和Show()的命名规则不一样了