[教程]逆向反汇编第三课

说完利用堆栈传递参数了,下面该说说使用寄存器传递参数的话题了.寄存器传递传输的方式并没有一个标准,所有与平台相关的方法都是由IDE(也就是编译器)开发人员制定的.尽管没有统一的标准,但绝大多数编译器提供商都在不对兼容性声明的情况下,遵循相应的规范,吉fastcall规范._fastcall顾名思义,特点就是快,因为他是靠寄存器来传递参数的.
      不同编译器实现的fastcall稍有不同,如Microsoft Visual C++编译器采用fastcall规范传递参数时,最左边的两个不大于4个字节(DWORD)的参数分别放在ecx和edx寄存器.当寄存器用完后,就要使用堆栈,其余参数仍然按照从右到左的顺序压入堆栈,被调用的函数在返回前清理传送参数的堆栈.浮点值员指针和int64类型总是通过对战来传递的.而Borland Delphi/C++编译器总是通过将寄存器来传递参数的,其最左边的三个不大于4个字节(DWORD)的参数分别放在eax  edx  和 ecx寄存器,寄存器用完后,参数按照从左到右的PASCAL方式来压栈.另外一款编译器Watcom C总是通过寄存器来传递参数的,严格为每一个参数分配一个寄存器,默认时第一个参数用eax,第二个参数用edx,第三个参数用ebx,第四个参数用 ecx,如果寄存器用完了,就会用堆栈来传递参数.Watcom C可以由程序员指定任意一个寄存器传递参数,因此,其参数实际上可能通过任何寄存器进行传递.
        来看一个手动指定fastcall调用参数的实例:
C源码如下:

 

  1. int _fastcall Add(char,long,int,int);   
  2. main(void)   
  3. {   
  4.      Add(1,2,3,4);   
  5.      return 0;   
  6. }   
  7. int _fastcall Add(char</
  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
News 26.03.2015 Knowledge base file for Delphi XE3 freely available. 23.03.2015 Knowledge base file for Delphi XE and Delphi XE2 freely available. 16.03.2015 Latest version is available for download. What is IDR? IDR (Interactive Delphi Reconstructor) – a decompiler of executable files (EXE) and dynamic libraries (DLL), written in Delphi and executed in Windows32 environment. The program firstly is intended for the companies, engaged by development of anti-virus software. It can also help programmers to recover lost source code of programs appreciably. The current version of the program can process files (GUI and console applications), compiled by Delphi compilers of versions Delphi2 – Delphi XE3. Final project goal is development of the program capable to restore the most part of initial Delphi source codes from the compiled file but IDR, as well as others Delphi decompilers, cannot do it yet. Nevertheless, IDR is in a status considerably to facilitate such process. In comparison with other well known Delphi decompilers the result of IDR analysis has the greatest completeness and reliability. Moreover interactivity does work with the program comfortable and (we shall not be afraid of this word) pleasant. IDR make static analysis (analyzed file is not loaded to memory and executed) that allows to safely investigate viruses, trojans and other malware applications, those which executing is dangerous or is not desirable. The program does not require any installation activity and does not do any records in Windows registry. Below screenshot of IDR main window is shown. You can find examples of IDR working results on separate page. For detailed acquaintance with opportunities IDR there is a help file in format CHM which can be downloaded on page of download or directly from this link.
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值