当前位置:网站首页>函数调用方式_stdcall 、 _cdecl 、_thiscall
函数调用方式_stdcall 、 _cdecl 、_thiscall
2022-07-30 15:38:00 【陈子青 - See】
目录
前言
了解函数调用约定对逆向反汇编的分析会提供极大帮助。
__stdcall
__stdcall的全称是standard call。是C++的标准调用方式。
函数参数的入栈顺序为从右到左入栈。函数返回时使用retn x指令,其中x为调整堆栈的字节数。这种方式叫做自动清栈。即被调用的函数的参数个数是固定的,调用者必须严格按照定义传递参数,一个不多,一个不少。
堆栈平衡方式: __stdcall自动清栈
返回指令:_stdcall使用retn x
编译后函数的修饰名: 假设有函数int add(int a, int b), __stdcall编译后的函数名为[email protected]


__cdecl
__cdecl的全称是C Declaration,即C语言默认的函数调用方式。
函数参数的入栈顺序为从右到左入栈。函数返回时作用ret指令。由调用者手动清栈。被调用的函数支持可变参数。调用者根据调用时传入参数的个数,手动平衡堆栈。
堆栈平衡方式 __cdecl手动清栈。
返回指令:__cdecl使用ret
编译后函数的修饰名: 假设有函数int add(int a, int b), __cdecl编译后的函数名为_foo。

__thiscall
thiscall是调用类内部成员函数时传递的参数 . 其本质是类对象的第一个成员变量的地址.
this指针一般使用寄存器ECX传递
参数的传递方式:函数参数的入栈顺序为从右到左入栈
堆栈平衡:调用者平衡堆栈(外平栈)
【__thiscall只能够用在类的成员函数上,如果参数个数确定,this指针通过ecx传递给被调用者;如果参数不确定,this指针在所有参数被压栈后压入栈堆】
对参数个数不确定的,调用者清理堆栈,否则函数自己清理堆栈。


__fastcall
通过的ECX和EDX寄存器传参,其余参数从右向左入栈,由调用者清理堆栈。(很少见)

边栏推荐
猜你喜欢
![[HMS core] [FAQ] A collection of typical questions about push kit, analysis services, and video editing services 3](/img/7a/e7447b21421f3052c0b6c44d1c2817.png)
[HMS core] [FAQ] A collection of typical questions about push kit, analysis services, and video editing services 3

Flask之路由(app.route)详解

【AGC】质量服务1-崩溃服务示例
![[HMS core] [FAQ] Collection of typical problems of push kit, AR Engine, advertising service, scanning service 2](/img/08/9f2c7d1ea704f234c2a1882f85df24.png)
[HMS core] [FAQ] Collection of typical problems of push kit, AR Engine, advertising service, scanning service 2

应用OPC解决方案实现控制系统数据的安全交换

解析字符串拼接的两种情况

FME realizes the method of converting CAD with attribute to SHP data

【AGC】Open Test Example

动态规划 --- 状态压缩DP 详细解释

【HMS core】【Media】【Video Editing Service】 The online material cannot be displayed, it is always in the loading state or the network is abnormal
随机推荐
几种常见的存储器
开源WebGIS架构
【AGC】质量服务1-崩溃服务示例
数组元素逆置
TiDB tool download
rscsa笔记八
后浪来袭!阿里产出“第二代”容器技术手册及脑图,这也太香了吧
[AGC] Quality Service 2 - Performance Management Example
The Prospects of the Metaverse and the Four Tracks
Google engineer "code completion" tool; "Transformers NLP" accompanying book code; FastAPI development template; PyTorch model acceleration tool; cutting-edge papers | ShowMeAI News Daily
[HMS core] [FAQ] A collection of typical questions about push kit, analysis services, and video editing services 3
Overview of TiUP commands
近段时间的学习碎片整理(24)
nodejs环境变量设置
TiUP 命令概览
武汉星起航:海外仓基础建设成为跨境电商企业的一大出海利器
Database - SQL
Manage components using TiUP commands
RISC-V calling conventions
CAD几个优化设置