源代码
#include <iostream>
using namespace std;
class CMyString{
public:
CMyString(){
m_pString=NULL;
}
CMyString(CMyString&obj){
int nLen=strlen(obj.m_pString);
this->m_pString=new char[nLen+sizeof(char)];
strcpy(this->m_pString,obj.m_pString);
}
~CMyString(){
if(m_pString!=NULL)
{
delete[] m_pString;
m_pString=NULL;
}
}
void SetString(char* pString){
int nLen=strlen(pString);
if(m_pString!=NULL)
{
delete [] m_pString;
m_pString =NULL;
}
m_pString=new char[nLen+sizeof(char)];
strcpy(m_pString,pString);
}
char*m_pString;
};
void Show(CMyString MyString){
printf(MyString.m_pString);
}
int main(int argc,char*argv[]){
CMyString MyString;
MyString.SetString("Hello");
Show(MyString);
return 0;
}
37:
38: int main(int argc,char*argv[]){
00401120 push ebp
00401121 mov ebp,esp
00401123 push 0FFh
00401125 push offset __ehhandler$_main (0041f289)
0040112A mov eax,fs:[00000000]
00401130 push eax
00401131 mov dword ptr fs:[0],esp
00401138 sub esp,50h
0040113B push ebx
0040113C push esi
0040113D push edi
0040113E lea edi,[ebp-5Ch]
00401141 mov ecx,14h
00401146 mov eax,0CCCCCCCCh
0040114B rep stos dword ptr [edi]
39: CMyString MyString;
0040114D lea ecx,[ebp-10h]
00401150 call @ILT+5(CMyString::CMyString) (0040100a)
00401155 mov dword ptr [ebp-4],0
40: MyString.SetString("Hello");
0040115C push offset string "Hello" (0043101c)
00401161 lea ecx,[ebp-10h]
00401164 call @ILT+0(CMyString::SetString) (00401005)
41: Show(MyString);
00401169 push ecx
0040116A mov ecx,esp
0040116C mov dword ptr [ebp-14h],esp
0040116F lea eax,[ebp-10h]
00401172 push eax
00401173 call @ILT+10(CMyString::CMyString) (0040100f)
00401178 mov dword ptr [ebp-1Ch],eax
0040117B call @ILT+35(Show) (00401028)
00401180 add esp,4
42: return 0;
00401183 mov dword ptr [ebp-18h],0
0040118A mov dword ptr [ebp-4],0FFFFFFFFh
00401191 lea ecx,[ebp-10h]
00401194 call @ILT+30(CMyString::~CMyString) (00401023)
00401199 mov eax,dword ptr [ebp-18h]
43: }
0040119C mov ecx,dword ptr [ebp-0Ch]
0040119F mov dword ptr fs:[0],ecx
004011A6 pop edi
004011A7 pop esi
004011A8 pop ebx
004011A9 add esp,5Ch
004011AC cmp ebp,esp
004011AE call __chkesp (004084c0)
004011B3 mov esp,ebp
004011B5 pop ebp
004011B6 ret
反汇编中
0040116A mov ecx,esp
这一行的表示获取参数对象的地址,保存到ecx中。
那为什么用esp表示参数对象的地址,并把他放在[ebp-14h],第一个参数不是[ebp+8]吗
两个问题呀
[招生]科锐逆向工程师培训(2024年11月15日实地,远程教学同时开班, 第51期)