C#与C++的汇编

C#的一个简单函数。

 

 

using System;
using System.Collections.Generic;
using System.Text;
using System.Net.Sockets;


namespace Cross3389 {
    class Program {
        static void Main(string[] args) {
            Console.ReadKey();
        }
    }
}

 

汇编

--- D:\work_projects\Cross3389\Cross3389\Cross3389\Program.cs ------------------
using System;
using System.Collections.Generic;
using System.Text;
using System.Net.Sockets;


namespace Cross3389 {
    class Program {
        static void Main(string[] args) {
00000000  push        ebp 
00000001  mov         ebp,esp
00000003  push        edi 
00000004  push        esi 
00000005  push        ebx 
00000006  sub         esp,3Ch
00000009  xor         eax,eax
0000000b  mov         dword ptr [ebp-10h],eax
0000000e  xor         eax,eax
00000010  mov         dword ptr [ebp-1Ch],eax
00000013  mov         dword ptr [ebp-3Ch],ecx
00000016  cmp         dword ptr ds:[00988D90h],0
0000001d  je          00000024
0000001f  call        78EC8F39
00000024  nop             
            Console.ReadKey();
00000025  lea         ecx,[ebp-48h]
00000028  call        785922B4
0000002d  nop             
        }
0000002e  nop             
0000002f  lea         esp,[ebp-0Ch]
00000032  pop         ebx 
00000033  pop         esi 
00000034  pop         edi 
00000035  pop         ebp 
00000036  ret             

 

C++:

 

// Cross_3389.cpp : 定义控制台应用程序的入口点。
//

#include "stdafx.h"
#include "windows.h"
#include  <iostream>
using  namespace  std;

#include <conio.h>

int _tmain(int argc, _TCHAR* argv[])
{

 getch();
 return 0;
}

 

 

--- d:\work_projects\cross3389\cross3389\cross_3389\cross_3389.cpp -------------
// Cross_3389.cpp : 定义控制台应用程序的入口点。
//

#include "stdafx.h"
#include "windows.h"
#include  <iostream>
using  namespace  std;

#include <conio.h>

int _tmain(int argc, _TCHAR* argv[])
{
0042D6A0  push        ebp 
0042D6A1  mov         ebp,esp
0042D6A3  sub         esp,0C0h
0042D6A9  push        ebx 
0042D6AA  push        esi 
0042D6AB  push        edi 
0042D6AC  lea         edi,[ebp-0C0h]
0042D6B2  mov         ecx,30h
0042D6B7  mov         eax,0CCCCCCCCh
0042D6BC  rep stos    dword ptr es:[edi]

 getch();
0042D6BE  call        @ILT+1490(_getch) (42B5D7h)
 return 0;
0042D6C3  xor         eax,eax
}
0042D6C5  pop         edi 
0042D6C6  pop         esi 
0042D6C7  pop         ebx 
0042D6C8  add         esp,0C0h
0042D6CE  cmp         ebp,esp
0042D6D0  call        @ILT+3480(__RTC_CheckEsp) (42BD9Dh)
0042D6D5  mov         esp,ebp
0042D6D7  pop         ebp 
0042D6D8  ret             

posted on 2008-12-19 14:16 yurow 阅读(140) 评论(2) 编辑 收藏

评论

#1楼[楼主] 2008-12-19 14:24 yurow      

// Cross_3389.cpp : 定义控制台应用程序的入口点。
//

#include "stdafx.h"
#include "windows.h"
#include <iostream>
using namespace std;

int _tmain(int argc, _TCHAR* argv[])
{
char p[9];
cin >> p;
return 0;
}


--- d:\work_projects\cross3389\cross3389\cross_3389\cross_3389.cpp -------------
// Cross_3389.cpp : 定义控制台应用程序的入口点。
//

#include "stdafx.h"
#include "windows.h"
#include <iostream>
using namespace std;

int _tmain(int argc, _TCHAR* argv[])
{
004365F0 push ebp
004365F1 mov ebp,esp
004365F3 sub esp,0D8h
004365F9 push ebx
004365FA push esi
004365FB push edi
004365FC lea edi,[ebp-0D8h]
00436602 mov ecx,36h
00436607 mov eax,0CCCCCCCCh
0043660C rep stos dword ptr es:[edi]
0043660E mov eax,dword ptr [___security_cookie (4B3440h)]
00436613 xor eax,ebp
00436615 mov dword ptr [ebp-4],eax
char p[9];
cin >> p;
00436618 lea eax,[ebp-14h]
0043661B push eax
0043661C push offset std::cin (4B4A44h)
00436621 call std::operator>><char,std::char_traits<char> > (4335D2h) //等待输入
00436626 add esp,8
return 0;
00436629 xor eax,eax
}
0043662B push edx
0043662C mov ecx,ebp
0043662E push eax
0043662F lea edx,[ (43665Ch)]
00436635 call @ILT+2175(@_RTC_CheckStackVars@8) (433884h) //越界检查
0043663A pop eax
0043663B pop edx
0043663C pop edi
0043663D pop esi
0043663E pop ebx
0043663F mov ecx,dword ptr [ebp-4]
00436642 xor ecx,ebp
00436644 call @ILT+650(@__security_check_cookie@4) (43328Fh)
00436649 add esp,0D8h
0043664F cmp ebp,esp
00436651 call @ILT+4965(__RTC_CheckEsp) (43436Ah)
00436656 mov esp,ebp
00436658 pop ebp
00436659 ret
0043665A mov edi,edi
0043665C db 01h
0043665D db 00h
0043665E db 00h
0043665F db 00h
00436660 db 64h
00436661 db 66h
00436662 db 43h
00436663 db 00h
00436664 db ech
00436665 db ffh
00436666 db ffh
00436667 db ffh
00436668 db 09h
00436669 db 00h
0043666A db 00h
0043666B db 00h
0043666C db 70h
0043666D db 66h
0043666E db 43h
0043666F db 00h
00436670 db 70h
00436671 db 00h
 回复 引用 查看   

#2楼[楼主] 2008-12-19 16:07 yurow      

实际反汇编后

* Referenced by a (U)nconditional or (C)onditional Jump at Address:
|:004337D0(U)
|
:00444320 8BFF mov edi, edi
:00444322 55 push ebp
:00444323 8BEC mov ebp, esp
:00444325 E875F3FEFF call 0043369F
:0044432A E811000000 call 00444340 //等待输入
:0044432F 5D pop ebp
:00444330 C3 ret

这个可能是cin里的一个方法
 回复 引用 查看   

导航

公告

昵称:yurow
园龄:6年4个月
粉丝:0
关注:0
<2008年12月>
30123456
78910111213
14151617181920
21222324252627
28293031123
45678910

统计

搜索

 

常用链接

随笔分类(7)

文章分类(44)

我的其它博客

友情链接

积分与排名

最新评论

阅读排行榜

推荐排行榜