当前位置:网站首页>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);
边栏推荐
- 手写ABA遇到的坑
- GPS from getting started to giving up (XIII), receiver autonomous integrity monitoring (RAIM)
- The nearest common ancestor of binary (search) tree ●●
- lora同步字设置
- 解决项目跨域问题
- 2020 Bioinformatics | GraphDTA: predicting drug target binding affinity with graph neural networks
- Management background --2 Classification list
- Support multiple API versions in flask
- GNN, please deepen your network layer~
- Management background --3, modify classification
猜你喜欢
[Digital IC hand tearing code] Verilog burr free clock switching circuit | topic | principle | design | simulation
PVL EDI 项目案例
Leetcode question brushing (XI) -- sequential questions brushing 51 to 55
Powerful domestic API management tool
HDR image reconstruction from a single exposure using deep CNN reading notes
二叉(搜索)树的最近公共祖先 ●●
将MySQL的表数据纯净方式导出
Common sense: what is "preservation" in insurance?
BarcodeX(ActiveX打印控件) v5.3.0.80 免费版使用
硬件開發筆記(十): 硬件開發基本流程,制作一個USB轉RS232的模塊(九):創建CH340G/MAX232封裝庫sop-16並關聯原理圖元器件
随机推荐
网络基础入门理解
ResNet-RS:谷歌领衔调优ResNet,性能全面超越EfficientNet系列 | 2021 arxiv
Installation and use of labelimg
Oracle control file and log file management
【数字IC手撕代码】Verilog无毛刺时钟切换电路|题目|原理|设计|仿真
Management background --5, sub classification
[sdx62] wcn685x will bdwlan Bin and bdwlan Txt mutual conversion operation method
i. Mx6ull build boa server details and some of the problems encountered
Heavyweight news | softing fg-200 has obtained China 3C explosion-proof certification to provide safety assurance for customers' on-site testing
qt quick项目offscreen模式下崩溃的问题处理
Memorabilia of domestic database in June 2022 - ink Sky Wheel
Kohana database
Embedded common computing artifact excel, welcome to recommend skills to keep the document constantly updated and provide convenience for others
C#实现水晶报表绑定数据并实现打印4-条形码
Common sense: what is "preservation" in insurance?
Seata aggregates at, TCC, Saga and XA transaction modes to create a one-stop distributed transaction solution
Qt | UDP广播通信、简单使用案例
2022-07-05 使用tpcc对stonedb进行子查询测试
GPS from getting started to giving up (12), Doppler constant speed
GPS from getting started to giving up (XV), DCB differential code deviation