当前位置:网站首页>函数调用方式_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寄存器传参,其余参数从右向左入栈,由调用者清理堆栈。(很少见)

边栏推荐
- C#西门子S7 协议通过偏移量的方式读写PLC DB块
- 科研中一些常用软件清单
- 【AGC】质量服务2-性能管理示例
- TiDB 工具适用场景
- [Developers must see] [push kit] Collection of typical problems of push service 2
- flask获取post请求参数
- 针对 MySQL/InnoDB 刷盘调优
- The Prospects of the Metaverse and the Four Tracks
- 【HMS core】【FAQ】push kit、WisePlay DRM、Location Kit、Health Kit、3D Modeling Kit、SignPal Kit典型问题合集4
- 华为ADS获取转化跟踪参数报错:getInstallReferrer IOException: getInstallReferrer not found installreferrer
猜你喜欢

【HMS core】【Media】【Video Editing Service】 The online material cannot be displayed, it is always in the loading state or the network is abnormal

rhce笔记2
![[Developers must see] [push kit] Collection of typical problems of push service 2](/img/70/d5127d57d2f3532deb7314d737820b.png)
[Developers must see] [push kit] Collection of typical problems of push service 2

C#西门子S7 协议通过偏移量的方式读写PLC DB块

配置Path环境变量
![[flutter]什么是MaterialApp和Material design](/img/72/d0845467b33b2291f47e7f54171088.jpg)
[flutter]什么是MaterialApp和Material design

FME读写cass数据的方案及操作流程

Image information extraction DEM

PCIE入门

70行代码撸一个桌面自动翻译神器
随机推荐
类和对象(下篇)
Changing SELECT...FROM to FROM...SELECT doesn't 'fix' SQL
Load Base Split 使用文档
TiUP 简介
应用OPC解决方案实现控制系统数据的安全交换
Image information extraction DEM
tiup completion
How to implement timing tasks for distributed applications in Golang
Array element inverse
rscsa笔记八
Recent learning defragmentation (24)
SMI 与 Gateway API 的 GAMMA 倡议意味着什么?
华为「天才少年」计划招募的博士们,迎来首秀!
rhce笔记1
How to intercept the first few digits of a string in php
Golang分布式应用定时任务如何实现
【HMS core】【FAQ】push kit、AR Engine、广告服务、扫描服务典型问题合集2
针对 MySQL/InnoDB 刷盘调优
tiup clean
Sparse-PointNet: See Further in Autonomous Vehicles 论文笔记