c - 读取地址指向的数据
问题描述
在这里研究我的倒车技能,我发现了一些我认为我理解的东西,但我设法让自己感到困惑。
主要在C中工作
我的函数返回我想要访问的信息的地址。
LRESULT ret = SendMessage(hComboBox, CB_GETITEMDATA, (WPARAM)0 , (LPARAM) 0);
// the exact function doesn't really matter here.
printf("Address: %p\n", ret); // Output is 09437DF8
此地址的转储会导致
09437DF8 A0 55 E8 12
这是我真正想要读取的数据的地址(注意字节顺序)。12e855A0
12 E8 55 A0 - 30 00 3A 00 30 00 33 00 3A 00 32 00 32 00 00 00 - UNICODE "0:03:22"
现在我相当确定这只是基本的指针/引用/取消引用,但我无法理解我必须做什么才能务实地读取这个值。
wprintf(L"%s\n", <value at address pointed to by ret>);
// Yes its a null terminated string
// Im working via injected dll, so no access violations
// string is unicode
解决方案
也许是这样的?
#include <stdio.h>
#include <wchar.h>
int main()
{
wchar_t *name = L"UNICODE String";
void **ret = (void **)&name;
wprintf(L"%ls \n", *(wchar_t **)ret);
return 0;
}
推荐阅读
- azure-iot-hub - ESP32 上的 Azure IoT 中心 Python SDK
- debugging - 如何调试 vim indentexpr 脚本?
- xml - XPath/XQuery:计算节点元素并返回带有父 ID 的最小计数
- azure-active-directory - MS ADFS -ssolifetime 用于刷新令牌
- html - 是否有一个浏览器扩展可以记录对 HTML 的每一次更改?
- docusignapi - 是否可以在自定义顶点按钮中使用 Docusign Gen?
- javascript - 试图将值从 html 保存到 javascript 数组,但它不起作用
- javascript - 我无法更改 ListItem 组件内的开关状态
- python - 为什么python只打印一条错误消息?
- python - 断言可以与打印语句进行比较吗?