我还在一条一条的琢磨呢。
; Listing generated by Microsoft (R) Optimizing Compiler Version 16.00.40219.01 TITLE e:\My_Documents\Projects\C_Test\test2\test2.cpp .686P .XMM include listing.inc .model flat INCLUDELIB MSVCRTD INCLUDELIB OLDNAMES PUBLIC ??_C@_08GAIPLOLA@c?J?G?$KD?$LK?$CFs?6?$AA@ ; `string' PUBLIC ??_C@_0CL@LCHNGBJP@?U?b?$MA?o?T?Y?S?P?R?$LL?$LI?v?W?V?$LH?$PL?$LE?$KO?S?$KG?$LI?C?J?G?$LC?$LL?T?v?$LM?S?$LG?Q@ ; `string' PUBLIC ??_C@_08HHPEKKPD@b?J?G?$KD?$LK?$CFs?6?$AA@ ; `string' PUBLIC ??_C@_08EOHJJGDG@a?J?G?$KD?$LK?$CFs?6?$AA@ ; `string' PUBLIC ??_C@_0BJ@PJBNBAIL@?N?R?S?C?U?b?$LI?v?J?$PN?W?i?$LH?E?R?$LL?$LI?v?W?V?$LH?$PL?$LE?$KO?$AA@ ; `string' PUBLIC __$ArrayPad$ PUBLIC _main EXTRN __imp__printf:PROC EXTRN _strcpy:PROC EXTRN ___security_cookie:DWORD EXTRN @__security_check_cookie@4:PROC EXTRN @_RTC_CheckStackVars@8:PROC EXTRN __RTC_CheckEsp:PROC EXTRN _memset:PROC EXTRN __RTC_Shutdown:PROC EXTRN __RTC_InitBase:PROC ; COMDAT ??_C@_08GAIPLOLA@c?J?G?$KD?$LK?$CFs?6?$AA@ ; File e:\my_documents\projects\c_test\test2\test2.cpp CONST SEGMENT ??_C@_08GAIPLOLA@c?J?G?$KD?$LK?$CFs?6?$AA@ DB 'c', 0caH, 0c7H, 0a3H, 0baH DB '%s', 0aH, 00H ; `string' CONST ENDS ; COMDAT ??_C@_0CL@LCHNGBJP@?U?b?$MA?o?T?Y?S?P?R?$LL?$LI?v?W?V?$LH?$PL?$LE?$KO?S?$KG?$LI?C?J?G?$LC?$LL?T?v?$LM?S?$LG?Q@ CONST SEGMENT ??_C@_0CL@LCHNGB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H ; `string' CONST ENDS ; COMDAT rtc$TMZ rtc$TMZ SEGMENT __RTC_Shutdown.rtc$TMZ DD FLAT:__RTC_Shutdown rtc$TMZ ENDS ; COMDAT rtc$IMZ rtc$IMZ SEGMENT __RTC_InitBase.rtc$IMZ DD FLAT:__RTC_InitBase ; Function compile flags: /Odtp /RTCsu /ZI rtc$IMZ ENDS ; COMDAT _main _TEXT SEGMENT _c$ = -216 ; size = 64 _b$4520 = -144 ; size = 64 _a$ = -72 ; size = 64 __$ArrayPad$ = -4 ; size = 4 _main PROC ; COMDAT ; 5 : { push ebp mov ebp, esp sub esp, 412 ; 0000019cH push ebx push esi push edi lea edi, DWORD PTR [ebp-412] mov ecx, 103 ; 00000067H mov eax, -858993460 ; ccccccccH rep stosd mov eax, DWORD PTR ___security_cookie xor eax, ebp mov DWORD PTR __$ArrayPad$[ebp], eax ; 6 : char a[64] = {0}; mov BYTE PTR _a$[ebp], 0 push 63 ; 0000003fH push 0 lea eax, DWORD PTR _a$[ebp+1] push eax call _memset add esp, 12 ; 0000000cH ; 7 : strcpy(a, "我用这个数组放一个字符串"); push OFFSET ??_C@_0BJ@PJBNBAIL@?N?R?S?C?U?b?$LI?v?J?$PN?W?i?$LH?E?R?$LL?$LI?v?W?V?$LH?$PL?$LE?$KO?$AA@ lea eax, DWORD PTR _a$[ebp] push eax call _strcpy add esp, 8 ; 8 : printf("a是:%s\n", a); mov esi, esp lea eax, DWORD PTR _a$[ebp] push eax push OFFSET ??_C@_08EOHJJGDG@a?J?G?$KD?$LK?$CFs?6?$AA@ call DWORD PTR __imp__printf add esp, 8 cmp esi, esp call __RTC_CheckEsp ; 9 : ; 10 : { ; 11 : //这是个大括号里面 ; 12 : char b[64] = {0}; mov BYTE PTR _b$4520[ebp], 0 push 63 ; 0000003fH push 0 lea eax, DWORD PTR _b$4520[ebp+1] push eax call _memset add esp, 12 ; 0000000cH ; 13 : strcpy(b, a); lea eax, DWORD PTR _a$[ebp] push eax lea ecx, DWORD PTR _b$4520[ebp] push ecx call _strcpy add esp, 8 ; 14 : printf("b是:%s\n", b); mov esi, esp lea eax, DWORD PTR _b$4520[ebp] push eax push OFFSET ??_C@_08HHPEKKPD@b?J?G?$KD?$LK?$CFs?6?$AA@ call DWORD PTR __imp__printf add esp, 8 cmp esi, esp call __RTC_CheckEsp ; 15 : } ; 16 : //理论上到这里b就释放了 ; 17 : ; 18 : char c[64] = "这里再有一个字符串应该是不增加堆栈大小才对"; mov ecx, 10 ; 0000000aH mov esi, OFFSET ??_C@_0CL@LCHNGBJP@?U?b?$MA?o?T?Y?S?P?R?$LL?$LI?v?W?V?$LH?$PL?$LE?$KO?S?$KG?$LI?C?J?G?$LC?$LL?T?v?$LM?S?$LG?Q@ lea edi, DWORD PTR _c$[ebp] rep movsd movsw movsb xor eax, eax mov DWORD PTR _c$[ebp+43], eax mov DWORD PTR _c$[ebp+47], eax mov DWORD PTR _c$[ebp+51], eax mov DWORD PTR _c$[ebp+55], eax mov DWORD PTR _c$[ebp+59], eax mov BYTE PTR _c$[ebp+63], al ; 19 : printf("c是:%s\n", c); mov esi, esp lea eax, DWORD PTR _c$[ebp] push eax push OFFSET ??_C@_08GAIPLOLA@c?J?G?$KD?$LK?$CFs?6?$AA@ call DWORD PTR __imp__printf add esp, 8 cmp esi, esp call __RTC_CheckEsp ; 20 : ; 21 : return 0; xor eax, eax ; 22 : } push edx mov ecx, ebp push eax lea edx, DWORD PTR $LN7@main call @_RTC_CheckStackVars@8 pop eax pop edx pop edi pop esi pop ebx mov ecx, DWORD PTR __$ArrayPad$[ebp] xor ecx, ebp call @__security_check_cookie@4 add esp, 412 ; 0000019cH cmp ebp, esp call __RTC_CheckEsp mov esp, ebp pop ebp ret 0 npad 3 $LN7@main: DD 3 DD $LN6@main $LN6@main: DD -72 ; ffffffb8H DD 64 ; 00000040H DD $LN3@main DD -144 ; ffffff70H DD 64 ; 00000040H DD $LN4@main DD -216 ; ffffff28H DD 64 ; 00000040H DD $LN5@main $LN5@main: DB 99 ; 00000063H DB 0 $LN4@main: DB 98 ; 00000062H DB 0 $LN3@main: DB 97 ; 00000061H DB 0 _main ENDP _TEXT ENDS END
.text:004013B7 ; Attributes: bp-based frame .text:004013B7 .text:004013B7 sub_4013B7 proc near ; CODE XREF: sub_401000+B4p .text:004013B7 .text:004013B7 var_DC = dword ptr -0DCh .text:004013B7 var_D8 = dword ptr -0D8h .text:004013B7 var_CC = byte ptr -0CCh .text:004013B7 var_8C = byte ptr -8Ch .text:004013B7 var_61 = byte ptr -61h .text:004013B7 var_4C = byte ptr -4Ch .text:004013B7 .text:004013B7 push ebp .text:004013B8 mov ebp, esp .text:004013BA push edi .text:004013BB push esi .text:004013BC push ebx .text:004013BD and esp, 0FFFFFFF0h .text:004013C0 sub esp, 0D0h .text:004013C6 call sub_4019B4 .text:004013CB lea ebx, [esp+0DCh+var_4C] .text:004013D2 mov al, 0 .text:004013D4 mov edx, 40h .text:004013D9 mov edi, ebx .text:004013DB mov ecx, edx .text:004013DD rep stosb .text:004013DF lea eax, [esp+0DCh+var_4C] .text:004013E6 mov edx, eax .text:004013E8 mov ebx, offset aTSO ; "我用这个数组放一个字符串" .text:004013ED mov eax, 19h .text:004013F2 mov edi, edx .text:004013F4 mov esi, ebx .text:004013F6 mov ecx, eax .text:004013F8 rep movsb .text:004013FA lea eax, [esp+0DCh+var_4C] .text:00401401 mov [esp+0DCh+var_D8], eax .text:00401405 mov [esp+0DCh+var_DC], offset aAGS ; "a是:%s\n" .text:0040140C call sub_40138C .text:00401411 lea ebx, [esp+0DCh+var_CC] .text:00401415 mov al, 0 .text:00401417 mov edx, 40h .text:0040141C mov edi, ebx .text:0040141E mov ecx, edx .text:00401420 rep stosb .text:00401422 lea eax, [esp+0DCh+var_4C] .text:00401429 mov [esp+0DCh+var_D8], eax .text:0040142D lea eax, [esp+0DCh+var_CC] .text:00401431 mov [esp+0DCh+var_DC], eax .text:00401434 call strcpy .text:00401439 lea eax, [esp+0DCh+var_CC] .text:0040143D mov [esp+0DCh+var_D8], eax .text:00401441 mov [esp+0DCh+var_DC], offset aBGS ; "b是:%s\n" .text:00401448 call sub_40138C .text:0040144D lea edx, [esp+0DCh+var_8C] .text:00401451 mov ebx, offset aTQOJB ; "这里再有一个字符串应该是不增加堆栈大小?... .text:00401456 mov eax, 2Bh .text:0040145B mov edi, edx .text:0040145D mov esi, ebx .text:0040145F mov ecx, eax .text:00401461 rep movsb .text:00401463 lea ebx, [esp+0DCh+var_61] .text:00401467 mov al, 0 .text:00401469 mov edx, 15h .text:0040146E mov edi, ebx .text:00401470 mov ecx, edx .text:00401472 rep stosb .text:00401474 lea eax, [esp+0DCh+var_8C] .text:00401478 mov [esp+0DCh+var_D8], eax .text:0040147C mov [esp+0DCh+var_DC], offset aCGS ; "c是:%s\n" .text:00401483 call sub_40138C .text:00401488 mov eax, 0 .text:0040148D lea esp, [ebp-0Ch] .text:00401490 pop ebx .text:00401491 pop esi .text:00401492 pop edi .text:00401493 pop ebp .text:00401494 retn .text:00401494 sub_4013B7 endp .text:00401494