本帖最后由 jtwc 于 2022-4-24 19:40 编辑
各位老师,C++中如下情况:void* ncdz = (void*)str2;输出结果错误为0,改为void* ncdz = (void*)0x15166AAC;输出结果正确,该如何处理void* ncdz = (void*)str2;才能输出正确呢?谢谢了
源码如下:
[C++] 纯文本查看 复制代码
#include<Windows.h>
#include<iostream>
#include<vector>
int main()
{
double dwsunshineAddressValue = 0;
HWND hWnd;
hWnd = FindWindow(NULL, "窗口");
GetWindowThreadProcessId(hWnd, &pid);
//通过进程ID获取进程句柄
HANDLE hProcess = OpenProcess(PROCESS_ALL_ACCESS, false, pid);
char* str = "15166AAC";
char* str1 = "0x";
char str2[12];
sprintf(str2, "%s%s", str1, str);
cout << str2 << endl;
void* ncdz = (void*)str2;
//void* ncdz = (void*)0x15166AAC;
if (FALSE == ReadProcessMemory(hProcess, ncdz, &dwsunshineAddressValue, sizeof(double), NULL))
{
//printf("读取静态地址.\n");
}
double a = dwsunshineAddressValue;
printf("%.2f\n", a);
} |