首页 > 解决方案 > 读取地址指向的数据

问题描述

在这里研究我的倒车技能,我发现了一些我认为我理解的东西,但我设法让自己感到困惑。

主要在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

标签: cmemoryreverse-engineering

解决方案


也许是这样的?

  #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;
    }

推荐阅读