通过DMA写入指定地址的单精度浮点数 - DmaWriteFloat
函数简介
通过 DMA 写入指定地址的单精度浮点数。支持 CE 地址格式。(高级版功能,普通版无法使用)
接口名称
DmaWriteFloat
DLL调用
int32_t OLA_CALL_TYPE DmaWriteFloat(int64_t instance, int64_t deviceId, int32_t pid, OLA_STRING_INPUT addr, float float_value);
参数定义:
instance(长整型数): OLAPlug对象的指针,由 CreateCOLAPlugInterFace 接口生成。deviceId(长整型数): 设备IDpid(整型数): 进程 PIDaddr(字符串): 地址,支持 CE 数据格式float_value(单精度浮点数): 要写入的浮点数值
示例:
// 写入单精度浮点数
int32_t result = DmaWriteFloat(instance, deviceId, 1234, "0x400000", 3.14f);
if (result == 1) {
printf("浮点数写入成功\n");
}
// 写入坐标
int32_t result2 = DmaWriteFloat(instance, deviceId, 1234, "0x400000", 100.5f);
int32_t result3 = DmaWriteFloat(instance, deviceId, 1234, "0x400004", 200.5f);
int32_t result4 = DmaWriteFloat(instance, deviceId, 1234, "0x400008", 50.0f);
if (result2 == 1 && result3 == 1 && result4 == 1) {
printf("坐标写入成功\n");
}
// 使用 CE 格式地址写入
int32_t result5 = DmaWriteFloat(instance, deviceId, 1234, "[<Game.exe>+1234]+8+4", 999.99f);
if (result5 == 1) {
printf("CE格式地址写入成功\n");
}
返回值
整型数:
- 1: 成功
- 0: 失败
参数说明
float_value(浮点数值):
- 要写入的单精度浮点数
- 范围:±3.4e±38
addr(地址):
- 支持十六进制格式:
0x400000 - 支持 CE 格式:
[[[<module>+offset1]+offset2]+offset3] - 支持模块相对地址:
<Game.exe>+1234+8+4
应用场景
- 修改游戏中的浮点数据(坐标、血量等)
- 内存修改
- 参数调整
相关接口
- DmaWriteFloatAddr - 直接地址写入
- DmaWriteDouble - 写入双精度浮点数
- DmaWriteInt - 写入整数
