ULONG64 CTESTDlg::ReadMemoryLONG64(PREAD_MEMORY_LONG64 pReadMemoryLong64) {
ULONG64 pOutBuffer = 0;
ULONG returnLength = 0;
BOOL bDeviceIoControl = DeviceIoControl(hDevice, READ_MEMORY_CTL_CODE, pReadMemoryLong64, 16, &pOutBuffer ,8,&returnLength, NULL);
return pOutBuffer;
}
ReadProcessBaseAddr() {
ULONG64 pOutBuffer = 0;
ULONG returnLength = 0;
MYPROCESS_INFORMATION myProcessInfo;
myProcessInfo.PID = 12072;
__try {
BOOL bDeviceIoControl = DeviceIoControl(hDevice, GET_PROCESS_BASE_ADDRESS_CTL_CODE, &myProcessInfo, 16, &pOutBuffer, 8, &returnLength, NULL);
}
__except (1) {
TRACE("aaaa");
}
return pOutBuffer;
}
void CTESTDlg::OnBnClickedButton2()
{
// TODO: 在此添加控件通知处理程序代码
int a = 0;
HANDLE hThread = CreateThread(NULL, 0, ThreadProc, NULL, 0, NULL);//单线程久了,还是会蹦,
//尝试多线程
//CreateThread(NULL, 0, ThreadProc, NULL, 0, NULL);
//CreateThread(NULL, 0, ThreadProc, NULL, 0, NULL);
//CreateThread(NULL, 0, ThreadProc, NULL, 0, NULL);
//CreateThread(NULL, 0, ThreadProc, NULL, 0, NULL);
//CreateThread(NULL, 0, ThreadProc, NULL, 0, NULL);
CloseHandle(hThread);
}
DWORD WINAPI CTESTDlg::ThreadProc(LPVOID lpParameter) {
while (true)
{
//这里是测试代码,实际代码中,有上百条 读取地址。
ULONG64 BaseAddr = ReadProcessBaseAddr();
//TRACE("BaseAddr:%p \n", BaseAddr);
READ_MEMORY_LONG64 readMemoryLong64;
readMemoryLong64.PID = 12072;
readMemoryLong64.length = 8;
readMemoryLong64.address = BaseAddr + 25578244;
ULONG64 ArrayAddr = ReadMemoryLONG64(&readMemoryLong64);
//TRACE("ArrayAddr:%p \n", ArrayAddr);
}
return 0;
}