Skip to content
qiannian edited this page Jul 1, 2026 · 3 revisions

memory

内存操作

接口目录

接口方法

内存接口通过窗口句柄找到目标进程。address 使用十六进制字符串,也支持简单表达式,比如 "140001000""140001000+20"

整数类型的 type 取值如下:

类型 字节数
0 int32 4
1 int16 2
2 int8 1
3 int64 8
4 uint32 4
5 uint16 2
6 uint8 1

字符串类型的 type 取值如下:

编码
0 ACP/GBK
1 UTF-16
2 UTF-8

WriteData

向某进程写入数据

long WriteData(hwnd,address,data,size)
参数 类型 描述
hwnd int 窗口句柄,用于指定要在哪个窗口内写入数据
address string 写入数据的地址
data string 写入的数据,使用十六进制字符串
size int 写入的数据的大小

返回值

类型:int

  • 0: 失败
  • 1: 成功

示例

op.WriteData(hwnd,"140001000","01020304",4)

ReadData

读取数据

string ReadData(hwnd,address,size)
参数 类型 描述
hwnd int 窗口句柄,用于指定要从哪个窗口内读取数据
address string 表示要读取数据的地址
size int 要读取的数据的大小

返回值

类型:string

读取到的数值

示例

data = op.ReadData(hwnd,"140001000",4)

ReadInt

读取整数

long ReadInt(hwnd,address,type)
参数 类型 描述
hwnd int 窗口句柄
address string 读取数据的地址
type int 整数类型,见上表

返回值

类型:int64

读取到的整数,失败返回 0

示例

value = op.ReadInt(hwnd,"140001000",0)

WriteInt

写入整数

long WriteInt(hwnd,address,type,value)
参数 类型 描述
hwnd int 窗口句柄
address string 写入数据的地址
type int 整数类型,见上表
value int64 要写入的整数

返回值

类型:int

  • 0: 失败
  • 1: 成功

示例

op.WriteInt(hwnd,"140001000",0,100)

ReadFloat

读取单精度浮点数

double ReadFloat(hwnd,address)
参数 类型 描述
hwnd int 窗口句柄
address string 读取数据的地址

返回值

类型:double

读取到的单精度浮点数,失败返回 0

示例

value = op.ReadFloat(hwnd,"140001000")

WriteFloat

写入单精度浮点数

long WriteFloat(hwnd,address,value)
参数 类型 描述
hwnd int 窗口句柄
address string 写入数据的地址
value double 要写入的数值

返回值

类型:int

  • 0: 失败
  • 1: 成功

示例

op.WriteFloat(hwnd,"140001000",1.5)

ReadDouble

读取双精度浮点数

double ReadDouble(hwnd,address)
参数 类型 描述
hwnd int 窗口句柄
address string 读取数据的地址

返回值

类型:double

读取到的双精度浮点数,失败返回 0

示例

value = op.ReadDouble(hwnd,"140001000")

WriteDouble

写入双精度浮点数

long WriteDouble(hwnd,address,value)
参数 类型 描述
hwnd int 窗口句柄
address string 写入数据的地址
value double 要写入的数值

返回值

类型:int

  • 0: 失败
  • 1: 成功

示例

op.WriteDouble(hwnd,"140001000",1.5)

ReadString

读取字符串

string ReadString(hwnd,address,type,len)
参数 类型 描述
hwnd int 窗口句柄
address string 读取数据的地址
type int 字符串编码,见上表
len int 读取字节数,0 表示自动到结尾

返回值

类型:string

读取到的字符串,失败返回空字符串

示例

text = op.ReadString(hwnd,"140001000",2,0)

WriteString

写入字符串

long WriteString(hwnd,address,type,value)
参数 类型 描述
hwnd int 窗口句柄
address string 写入数据的地址
type int 字符串编码,见上表
value string 要写入的字符串

返回值

类型:int

  • 0: 失败
  • 1: 成功

示例

op.WriteString(hwnd,"140001000",2,"hello")

Clone this wiki locally