如何根据指针地址获取指针内容

How to get the pointer content based on the pointer address

本文关键字:指针 获取 地址 何根      更新时间:2023-10-16

我使用 ctypes 调用 dll 来读取存储区域的内容。但它返回一个无符号的字符指针,我想获取指针的内容。我该怎么做?

from ctypes import *
c = WinDLL("FT_ET99_API.dll")
hwnd = c_void_p()
c.et_OpenToken(byref(hwnd), c_char_p('53E00FD8'), c_int(1))
c.et_Verify(hwnd, c_int(0), c_char_p('35316D69696C616E'))
f = c.et_Read
f.argtypes = c_void_p, c_int, c_int, POINTER(c_char_p)
f.restype = None
txt = c_char_p()
f(hwnd, 1, 34, byref(txt))
(What should I do next?)
et_Read( 
ET_HANDLE hHandle(in),
WORD offset(in), 
int Len(in), 
unsigned char* pucReadBuf(out) 
) 

我尝试了另一种方法,它成功了。我获取原始缓冲区的内容。

from ctypes import *
c = WinDLL("FT_ET99_API.dll")
hwnd = c_void_p()
c.et_OpenToken(byref(hwnd), c_char_p('53E00FD8'), c_int(1))
c.et_Verify(hwnd, c_int(0), c_char_p('35316D69696C616E'))
outData = create_string_buffer(34)
c.et_Read(hwnd, 1, 34, outData)
print outData.value(my aim)