当前位置:网站首页>Aardio - 不声明直接传float数值的方法
Aardio - 不声明直接传float数值的方法
2022-07-06 14:39:00 【卢光庆】
本文内容已整理到:
Aardio - API调用分析_卢光庆的博客-CSDN博客_aardio
因为个人觉得相关资料较少,特在此另发一文,以作参考。
因为aardio在不声明直接调用dll的时候,对于数值型参数是这样处理的:
数值参数一律处理为32位int整型。(小于32位的整数、枚举类型、8位或32位bool值都跟int 32位数值兼容)
所以,如果要传递float数据类型,如何传递呢?
这里写了两个dll函数进行测试:

aardio调用代码如下(测试过程就不详细解释了,直接说结果吧):
import console;
var dll=..raw.loadDll("\show.dll")
//传值测试:
//数值型数据结构
dll.show_byvalue(123.456)
//错误(float传递时被自动处理为整数类型,值已发生改变)
dll.show_byvalue(..raw.float(123.456))
//正确(构造为小数类型,aardio自动识别并在调用时自动调整参数类型为float)
//传址型数据结构
dll.show_byvalue({float v=123.456})
//错误(传的是“地址”,不是“数值”,值不一样)
dll.show_byvalue(..raw.float(123.456,true))
//错误(传的是“地址”,不是“数值”,值不一样)
//数值型,数据类型转换,将float数值转为int数值,再进行传递
dll.show_byvalue(raw.convert({ float f = 123.456 },{int i}).i)
//正确(用int数值,伪造float类型的内存数据,能被dll正确解析为float数值。原理同union)
//总之,就是必须将正确的“值”传递过去。
//传址测试:
//数值型数据结构
dll.show_byaddr(123.456)
//错误,地址非法,保护异常,程序退出
dll.show_byaddr(..raw.float(123.456))
//错误,地址非法,保护异常,程序退出
//传址型数据结构
dll.show_byaddr({float v=123.456})
//正确
dll.show_byaddr(..raw.float(123.456,true))
//正确
//传址相对比较简单,其他方法不一一测试了。
console.pause(true);
边栏推荐
- qt quick项目offscreen模式下崩溃的问题处理
- Crawler obtains real estate data
- 微信红包封面小程序源码-后台独立版-带测评积分功能源码
- Set status bar style demo
- ResNet-RS:谷歌领衔调优ResNet,性能全面超越EfficientNet系列 | 2021 arxiv
- 2020 Bioinformatics | GraphDTA: predicting drug target binding affinity with graph neural networks
- LeetCode刷题(十一)——顺序刷题51至55
- Barcodex (ActiveX print control) v5.3.0.80 free version
- How does the uni admin basic framework close the creation of super administrator entries?
- 基于 QEMUv8 搭建 OP-TEE 开发环境
猜你喜欢

ZABBIX proxy server and ZABBIX SNMP monitoring

基于 QEMUv8 搭建 OP-TEE 开发环境

Seata aggregates at, TCC, Saga and XA transaction modes to create a one-stop distributed transaction solution

GPS du début à l'abandon (XIII), surveillance autonome de l'intégrité du récepteur (raim)

Management background --3, modify classification

手写ABA遇到的坑

每日一题:力扣:225:用队列实现栈

GPS from getting started to giving up (19), precise ephemeris (SP3 format)

Adjustable DC power supply based on LM317

Leetcode question brushing (XI) -- sequential questions brushing 51 to 55
随机推荐
[linear algebra] determinant of order 1.3 n
ResNet-RS:谷歌领衔调优ResNet,性能全面超越EfficientNet系列 | 2021 arxiv
Daily question 1: force deduction: 225: realize stack with queue
AI enterprise multi cloud storage architecture practice | Shenzhen potential technology sharing
Xiaoman network model & http1-http2 & browser cache
Lora sync word settings
C # realizes crystal report binding data and printing 4-bar code
解决项目跨域问题
小程序系统更新提示,并强制小程序重启并使用新版本
Embedded common computing artifact excel, welcome to recommend skills to keep the document constantly updated and provide convenience for others
CCNA Cisco network EIGRP protocol
插入排序与希尔排序
What is the difference between animators and animators- What is the difference between an Animator and an Animation?
GD32F4XX串口接收中断和闲时中断配置
3DMax指定面贴图
[sdx62] wcn685x will bdwlan Bin and bdwlan Txt mutual conversion operation method
Management background --2 Classification list
12、 Start process
Heavyweight news | softing fg-200 has obtained China 3C explosion-proof certification to provide safety assurance for customers' on-site testing
VIP case introduction and in-depth analysis of brokerage XX system node exceptions