Skip to content

Instantly share code, notes, and snippets.

@BillyONeal
Created September 28, 2017 22:48
Show Gist options
  • Save BillyONeal/f7cc0417195e025f67edba822365069a to your computer and use it in GitHub Desktop.
Save BillyONeal/f7cc0417195e025f67edba822365069a to your computer and use it in GitHub Desktop.
String Things
; Function compile flags: /Ogtpy
; COMDAT _append_char
_TEXT SEGMENT
tv636 = -4 ; size = 4
__New_ptr$1$ = 8 ; size = 4
_x$ = 8 ; size = 4
_append_char PROC ; COMDAT
; File c:\users\bion\desktop\test.cpp
; Line 3
00000 51 push ecx
00001 55 push ebp
00002 56 push esi
; Line 4
00003 8b 74 24 10 mov esi, DWORD PTR _x$[esp+8]
00007 57 push edi
00008 8b 7e 10 mov edi, DWORD PTR [esi+16]
0000b 8b 6e 14 mov ebp, DWORD PTR [esi+20]
0000e 3b fd cmp edi, ebp
00010 73 18 jae SHORT $LN6@append_cha
00012 8d 47 01 lea eax, DWORD PTR [edi+1]
00015 89 46 10 mov DWORD PTR [esi+16], eax
00018 83 fd 10 cmp ebp, 16 ; 00000010H
0001b 72 02 jb SHORT $LN15@append_cha
0001d 8b 36 mov esi, DWORD PTR [esi]
$LN15@append_cha:
0001f 66 c7 04 3e 63
00 mov WORD PTR [esi+edi], 99 ; 00000063H
00025 5f pop edi
; Line 5
00026 5e pop esi
00027 5d pop ebp
00028 59 pop ecx
00029 c3 ret 0
; Line 4
$LN6@append_cha:
0002a b9 ff ff ff 7f mov ecx, 2147483647 ; 7fffffffH
0002f 8b c1 mov eax, ecx
00031 2b c7 sub eax, edi
00033 83 f8 01 cmp eax, 1
00036 0f 82 b8 00 00
00 jb $LN163@append_cha
0003c 53 push ebx
0003d 8d 5f 01 lea ebx, DWORD PTR [edi+1]
00040 83 cb 0f or ebx, 15 ; 0000000fH
00043 3b d9 cmp ebx, ecx
00045 76 04 jbe SHORT $LN60@append_cha
00047 8b d9 mov ebx, ecx
00049 eb 18 jmp SHORT $LN59@append_cha
$LN60@append_cha:
0004b 8b c5 mov eax, ebp
0004d d1 e8 shr eax, 1
0004f 2b c8 sub ecx, eax
00051 3b e9 cmp ebp, ecx
00053 76 07 jbe SHORT $LN61@append_cha
00055 bb ff ff ff 7f mov ebx, 2147483647 ; 7fffffffH
0005a eb 07 jmp SHORT $LN59@append_cha
$LN61@append_cha:
0005c 03 c5 add eax, ebp
0005e 3b d8 cmp ebx, eax
00060 0f 42 d8 cmovb ebx, eax
$LN59@append_cha:
00063 8d 43 01 lea eax, DWORD PTR [ebx+1]
00066 6a 01 push 1
00068 50 push eax
00069 e8 00 00 00 00 call ??$_Allocate@U?$_Default_allocate_traits@$00@std@@@std@@YAPAXII@Z ; std::_Allocate<std::_Default_allocate_traits<1> >
0006e 83 c4 08 add esp, 8
00071 89 5e 14 mov DWORD PTR [esi+20], ebx
00074 89 44 24 18 mov DWORD PTR __New_ptr$1$[esp+16], eax
00078 8d 4f 01 lea ecx, DWORD PTR [edi+1]
0007b 89 4e 10 mov DWORD PTR [esi+16], ecx
0007e 8d 1c 38 lea ebx, DWORD PTR [eax+edi]
00081 89 5c 24 10 mov DWORD PTR tv636[esp+20], ebx
00085 57 push edi
00086 83 fd 10 cmp ebp, 16 ; 00000010H
00089 72 4e jb SHORT $LN29@append_cha
0008b 8b 1e mov ebx, DWORD PTR [esi]
0008d 53 push ebx
0008e 50 push eax
0008f e8 00 00 00 00 call _memcpy
00094 8b 44 24 1c mov eax, DWORD PTR tv636[esp+32]
00098 83 c4 0c add esp, 12 ; 0000000cH
0009b 66 c7 00 63 00 mov WORD PTR [eax], 99 ; 00000063H
000a0 8d 45 01 lea eax, DWORD PTR [ebp+1]
000a3 3d 00 10 00 00 cmp eax, 4096 ; 00001000H
000a8 72 1a jb SHORT $LN124@append_cha
000aa f6 c3 1f test bl, 31 ; 0000001fH
000ad 75 4a jne SHORT $_Invalid_parameter$167
000af 8b 43 fc mov eax, DWORD PTR [ebx-4]
000b2 3b c3 cmp eax, ebx
000b4 73 43 jae SHORT $_Invalid_parameter$167
000b6 2b d8 sub ebx, eax
000b8 83 fb 04 cmp ebx, 4
000bb 72 3c jb SHORT $_Invalid_parameter$167
000bd 83 fb 23 cmp ebx, 35 ; 00000023H
000c0 77 37 ja SHORT $_Invalid_parameter$167
000c2 8b d8 mov ebx, eax
$LN124@append_cha:
000c4 53 push ebx
000c5 e8 00 00 00 00 call ??3@YAXPAX@Z ; operator delete
000ca 8b 44 24 1c mov eax, DWORD PTR __New_ptr$1$[esp+20]
000ce 83 c4 04 add esp, 4
000d1 89 06 mov DWORD PTR [esi], eax
000d3 5b pop ebx
000d4 5f pop edi
; Line 5
000d5 5e pop esi
000d6 5d pop ebp
000d7 59 pop ecx
000d8 c3 ret 0
; Line 4
$LN29@append_cha:
000d9 56 push esi
000da 50 push eax
000db e8 00 00 00 00 call _memcpy
000e0 8b 44 24 24 mov eax, DWORD PTR __New_ptr$1$[esp+28]
000e4 83 c4 0c add esp, 12 ; 0000000cH
000e7 66 c7 03 63 00 mov WORD PTR [ebx], 99 ; 00000063H
000ec 89 06 mov DWORD PTR [esi], eax
000ee 5b pop ebx
000ef 5f pop edi
; Line 5
000f0 5e pop esi
000f1 5d pop ebp
000f2 59 pop ecx
000f3 c3 ret 0
$LN163@append_cha:
; Line 4
000f4 e8 00 00 00 00 call ?_Xlen@?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@SAXXZ ; std::basic_string<char,std::char_traits<char>,std::allocator<char> >::_Xlen
$LN165@append_cha:
$_Invalid_parameter$167:
000f9 e8 00 00 00 00 call __invalid_parameter_noinfo_noreturn
$LN166@append_cha:
$LN161@append_cha:
000fe cc int 3
_append_char ENDP
_TEXT ENDS
; Function compile flags: /Ogtpy
; COMDAT _append_str
_TEXT SEGMENT
_x$ = 8 ; size = 4
_append_str PROC ; COMDAT
; File c:\users\bion\desktop\test.cpp
; Line 8
00000 8b 4c 24 04 mov ecx, DWORD PTR _x$[esp-4]
00004 6a 01 push 1
00006 68 00 00 00 00 push OFFSET ??_C@_01PAPGNFGE@c?$AA@
0000b e8 00 00 00 00 call ?append@?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@QAEAAV12@QBDI@Z ; std::basic_string<char,std::char_traits<char>,std::allocator<char> >::append
; Line 9
00010 c3 ret 0
_append_str ENDP
_TEXT ENDS
; Function compile flags: /Ogtpy
; COMDAT ?append@?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@QAEAAV12@QBDI@Z
_TEXT SEGMENT
__Old$1$ = -12 ; size = 4
tv624 = -8 ; size = 4
tv623 = -4 ; size = 4
__Ptr$ = 8 ; size = 4
__New_ptr$1$ = 12 ; size = 4
__Count$ = 12 ; size = 4
?append@?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@QAEAAV12@QBDI@Z PROC ; std::basic_string<char,std::char_traits<char>,std::allocator<char> >::append, COMDAT
; _this$ = ecx
; File c:\dev\msvc\binaries\x86ret\inc\xstring
; Line 2333
00000 83 ec 0c sub esp, 12 ; 0000000cH
00003 55 push ebp
; Line 2336
00004 8b 6c 24 18 mov ebp, DWORD PTR __Count$[esp+12]
00008 56 push esi
00009 57 push edi
0000a 8b f9 mov edi, ecx
0000c 8b 4f 14 mov ecx, DWORD PTR [edi+20]
0000f 8b c1 mov eax, ecx
00011 8b 77 10 mov esi, DWORD PTR [edi+16]
00014 2b c6 sub eax, esi
00016 89 4c 24 0c mov DWORD PTR __Old$1$[esp+24], ecx
0001a 3b e8 cmp ebp, eax
0001c 77 2e ja SHORT $LN2@append
; Line 2338
0001e 8d 04 2e lea eax, DWORD PTR [esi+ebp]
00021 89 47 10 mov DWORD PTR [edi+16], eax
; Line 2339
00024 8b c7 mov eax, edi
00026 83 f9 10 cmp ecx, 16 ; 00000010H
00029 72 02 jb SHORT $LN11@append
0002b 8b 07 mov eax, DWORD PTR [edi]
$LN11@append:
; Line 2340
0002d 55 push ebp
0002e ff 74 24 20 push DWORD PTR __Ptr$[esp+24]
00032 03 f0 add esi, eax
00034 56 push esi
00035 e8 00 00 00 00 call _memmove
0003a 83 c4 0c add esp, 12 ; 0000000cH
; Line 2341
0003d c6 04 2e 00 mov BYTE PTR [esi+ebp], 0
; Line 2345
00041 8b c7 mov eax, edi
00043 5f pop edi
; Line 2352
00044 5e pop esi
00045 5d pop ebp
00046 83 c4 0c add esp, 12 ; 0000000cH
00049 c2 08 00 ret 8
$LN2@append:
; Line 2345
0004c ba ff ff ff 7f mov edx, 2147483647 ; 7fffffffH
00051 8b c2 mov eax, edx
00053 2b c6 sub eax, esi
00055 3b c5 cmp eax, ebp
00057 0f 82 e8 00 00
00 jb $LN158@append
0005d 53 push ebx
0005e 8d 1c 2e lea ebx, DWORD PTR [esi+ebp]
00061 83 cb 0f or ebx, 15 ; 0000000fH
00064 3b da cmp ebx, edx
00066 76 04 jbe SHORT $LN56@append
00068 8b da mov ebx, edx
0006a eb 18 jmp SHORT $LN55@append
$LN56@append:
0006c 8b c1 mov eax, ecx
0006e d1 e8 shr eax, 1
00070 2b d0 sub edx, eax
00072 3b ca cmp ecx, edx
00074 76 07 jbe SHORT $LN57@append
00076 bb ff ff ff 7f mov ebx, 2147483647 ; 7fffffffH
0007b eb 07 jmp SHORT $LN55@append
$LN57@append:
0007d 03 c1 add eax, ecx
0007f 3b d8 cmp ebx, eax
00081 0f 42 d8 cmovb ebx, eax
$LN55@append:
00084 8d 43 01 lea eax, DWORD PTR [ebx+1]
00087 6a 01 push 1
00089 50 push eax
0008a e8 00 00 00 00 call ??$_Allocate@U?$_Default_allocate_traits@$00@std@@@std@@YAPAXII@Z ; std::_Allocate<std::_Default_allocate_traits<1> >
0008f 83 c4 08 add esp, 8
00092 89 5f 14 mov DWORD PTR [edi+20], ebx
00095 83 7c 24 10 10 cmp DWORD PTR __Old$1$[esp+28], 16 ; 00000010H
0009a 8d 0c 2e lea ecx, DWORD PTR [esi+ebp]
0009d 89 4f 10 mov DWORD PTR [edi+16], ecx
000a0 8d 1c 30 lea ebx, DWORD PTR [eax+esi]
000a3 89 44 24 24 mov DWORD PTR __New_ptr$1$[esp+24], eax
000a7 8d 0c 2b lea ecx, DWORD PTR [ebx+ebp]
000aa 89 5c 24 14 mov DWORD PTR tv624[esp+28], ebx
000ae 89 4c 24 18 mov DWORD PTR tv623[esp+28], ecx
000b2 56 push esi
000b3 72 62 jb SHORT $LN25@append
000b5 8b 1f mov ebx, DWORD PTR [edi]
000b7 53 push ebx
000b8 50 push eax
000b9 e8 00 00 00 00 call _memcpy
000be 55 push ebp
000bf ff 74 24 30 push DWORD PTR __Ptr$[esp+40]
000c3 ff 74 24 28 push DWORD PTR tv624[esp+48]
000c7 e8 00 00 00 00 call _memcpy
000cc 8b 44 24 30 mov eax, DWORD PTR tv623[esp+52]
000d0 83 c4 18 add esp, 24 ; 00000018H
000d3 c6 00 00 mov BYTE PTR [eax], 0
000d6 8b 44 24 10 mov eax, DWORD PTR __Old$1$[esp+28]
000da 40 inc eax
000db 3d 00 10 00 00 cmp eax, 4096 ; 00001000H
000e0 72 1a jb SHORT $LN120@append
000e2 f6 c3 1f test bl, 31 ; 0000001fH
000e5 75 63 jne SHORT $_Invalid_parameter$162
000e7 8b 43 fc mov eax, DWORD PTR [ebx-4]
000ea 3b c3 cmp eax, ebx
000ec 73 5c jae SHORT $_Invalid_parameter$162
000ee 2b d8 sub ebx, eax
000f0 83 fb 04 cmp ebx, 4
000f3 72 55 jb SHORT $_Invalid_parameter$162
000f5 83 fb 23 cmp ebx, 35 ; 00000023H
000f8 77 50 ja SHORT $_Invalid_parameter$162
000fa 8b d8 mov ebx, eax
$LN120@append:
000fc 53 push ebx
000fd e8 00 00 00 00 call ??3@YAXPAX@Z ; operator delete
00102 8b 44 24 28 mov eax, DWORD PTR __New_ptr$1$[esp+28]
00106 83 c4 04 add esp, 4
00109 89 07 mov DWORD PTR [edi], eax
0010b 8b c7 mov eax, edi
0010d 5b pop ebx
0010e 5f pop edi
; Line 2352
0010f 5e pop esi
00110 5d pop ebp
00111 83 c4 0c add esp, 12 ; 0000000cH
00114 c2 08 00 ret 8
; Line 2345
$LN25@append:
00117 57 push edi
00118 50 push eax
00119 e8 00 00 00 00 call _memcpy
0011e 55 push ebp
0011f ff 74 24 30 push DWORD PTR __Ptr$[esp+40]
00123 53 push ebx
00124 e8 00 00 00 00 call _memcpy
00129 83 c4 18 add esp, 24 ; 00000018H
0012c c6 04 2b 00 mov BYTE PTR [ebx+ebp], 0
00130 8d 04 2b lea eax, DWORD PTR [ebx+ebp]
00133 8b 44 24 24 mov eax, DWORD PTR __New_ptr$1$[esp+24]
00137 89 07 mov DWORD PTR [edi], eax
00139 8b c7 mov eax, edi
0013b 5b pop ebx
0013c 5f pop edi
; Line 2352
0013d 5e pop esi
0013e 5d pop ebp
0013f 83 c4 0c add esp, 12 ; 0000000cH
00142 c2 08 00 ret 8
$LN158@append:
; Line 2345
00145 e8 00 00 00 00 call ?_Xlen@?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@SAXXZ ; std::basic_string<char,std::char_traits<char>,std::allocator<char> >::_Xlen
$LN160@append:
$_Invalid_parameter$162:
0014a e8 00 00 00 00 call __invalid_parameter_noinfo_noreturn
$LN161@append:
$LN155@append:
0014f cc int 3
?append@?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@QAEAAV12@QBDI@Z ENDP ; std::basic_string<char,std::char_traits<char>,std::allocator<char> >::append
_TEXT ENDS
#include <string>
extern "C" void append_char(std::string& x) {
x += 'c';
}
extern "C" void append_str(std::string& x) {
x += "c";
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment