Y
YuZi
Unregistered / Unconfirmed
GUEST, unregistred user!
麻烦将下面的代码翻译成Delphi语言,前次自己修改结果还是有问题,干脆请大侠帮忙完全转译一下,谢谢!会的人应该不难。
typedef struct tagDataList {
DWORD dwIndex;
union {
DATA_A DataA;
DATA_B DataB;
};
}DATALIST,*LPDATALIST;
typedef struct tagListHeader {
DWORD dwCount;
LPDATALIST* lpDataList;
}LISTHEADER,*LPLISTHEADER;
typedef struct tagMyData {
DWORD dwData1;
DWORD dwData2;
LPLISTHEADER lpListHeader;
} MYDATA,*LPMYDATA;
#include "tlhelp32.h"
LPMYDATA GetMyData()
{
HWND hWin = Wnd;//一个窗口句柄
LPMYDATA lpMyData=(LPMYDATA)VirtualAlloc(NULL,sizeof(MyData),MEM_COMMIT,PAGE_READWRITE);
if (lpMyData)
{
LPVOID lpData = (LPVOID)GetWindowLong(hWin,0);
if (lpData)
{
DWORD pid=0;
GetWindowThreadProcessId(hWin,&pid);
HANDLE hP = OpenProcess(PROCESS_VM_READ | PROCESS_VM_OPERATION,FALSE,pid);
if (hP)
{
if (ReadProcessMemory(hP,lpData,(LPVOID)lpMyData,sizeof(MyData),NULL))
{
lpData = (LPVOID)lpMyData->lpListHeader;
lpMyData->lpListHeader = (LPLISTHEADER)VirtualAlloc(NULL,sizeof(LISTHEADER),MEM_COMMIT,PAGE_READWRITE);
if (lpMyData->lpListHeader)
{
if (ReadProcessMemory(hP,lpData,(LPVOID)lpMyData->lpListHeader,sizeof(LISTHEADER),NULL))
{
ULONG dwCount =lpMyData->lpListHeader->dwCount;
lpData = (LPVOID)lpMyData->lpListHeader->lpDataList;
lpMyData->lpListHeader->lpDataList = (LPDATALIST*)VirtualAlloc(NULL,dwCount * sizeof(LPVOID),MEM_COMMIT,PAGE_READWRITE);
if (ReadProcessMemory(hP,lpData,(LPVOID)lpMyData->lpListHeader->lpDataList,dwCount * sizeof(LPVOID),NULL))
{
for (UINT x =0;
x < dwCount;x++)
{
if (IsWindowsNT())
{
if (((lpMyData->lpListHeader->lpDataList))[x] = (LPDATALIST)VirtualAlloc(NULL,sizeof(DATA_W)+4,MEM_COMMIT,PAGE_READWRITE))
ReadProcessMemory(hP,(LPVOID)(((LPDATALIST*)lpData)[x]),(LPVOID)((lpMyData->lpListHeader->lpDataList))[x],sizeof(DATA_W)+4,NULL);
}
else
{
if (((lpMyData->lpListHeader->lpDataList))[x] = (LPDATALIST)VirtualAlloc(NULL,sizeof(DATA_A)+4,MEM_COMMIT,PAGE_READWRITE))
ReadProcessMemory(hP,(LPVOID)(((LPDATALIST*)lpData)[x]),(LPVOID)((lpMyData->lpListHeader->lpDataList))[x],sizeof(DATA_A)+4,NULL);
}
}
}
}
}
}
CloseHandle(hP);
}
}
}
return lpMyData;
}
typedef struct tagDataList {
DWORD dwIndex;
union {
DATA_A DataA;
DATA_B DataB;
};
}DATALIST,*LPDATALIST;
typedef struct tagListHeader {
DWORD dwCount;
LPDATALIST* lpDataList;
}LISTHEADER,*LPLISTHEADER;
typedef struct tagMyData {
DWORD dwData1;
DWORD dwData2;
LPLISTHEADER lpListHeader;
} MYDATA,*LPMYDATA;
#include "tlhelp32.h"
LPMYDATA GetMyData()
{
HWND hWin = Wnd;//一个窗口句柄
LPMYDATA lpMyData=(LPMYDATA)VirtualAlloc(NULL,sizeof(MyData),MEM_COMMIT,PAGE_READWRITE);
if (lpMyData)
{
LPVOID lpData = (LPVOID)GetWindowLong(hWin,0);
if (lpData)
{
DWORD pid=0;
GetWindowThreadProcessId(hWin,&pid);
HANDLE hP = OpenProcess(PROCESS_VM_READ | PROCESS_VM_OPERATION,FALSE,pid);
if (hP)
{
if (ReadProcessMemory(hP,lpData,(LPVOID)lpMyData,sizeof(MyData),NULL))
{
lpData = (LPVOID)lpMyData->lpListHeader;
lpMyData->lpListHeader = (LPLISTHEADER)VirtualAlloc(NULL,sizeof(LISTHEADER),MEM_COMMIT,PAGE_READWRITE);
if (lpMyData->lpListHeader)
{
if (ReadProcessMemory(hP,lpData,(LPVOID)lpMyData->lpListHeader,sizeof(LISTHEADER),NULL))
{
ULONG dwCount =lpMyData->lpListHeader->dwCount;
lpData = (LPVOID)lpMyData->lpListHeader->lpDataList;
lpMyData->lpListHeader->lpDataList = (LPDATALIST*)VirtualAlloc(NULL,dwCount * sizeof(LPVOID),MEM_COMMIT,PAGE_READWRITE);
if (ReadProcessMemory(hP,lpData,(LPVOID)lpMyData->lpListHeader->lpDataList,dwCount * sizeof(LPVOID),NULL))
{
for (UINT x =0;
x < dwCount;x++)
{
if (IsWindowsNT())
{
if (((lpMyData->lpListHeader->lpDataList))[x] = (LPDATALIST)VirtualAlloc(NULL,sizeof(DATA_W)+4,MEM_COMMIT,PAGE_READWRITE))
ReadProcessMemory(hP,(LPVOID)(((LPDATALIST*)lpData)[x]),(LPVOID)((lpMyData->lpListHeader->lpDataList))[x],sizeof(DATA_W)+4,NULL);
}
else
{
if (((lpMyData->lpListHeader->lpDataList))[x] = (LPDATALIST)VirtualAlloc(NULL,sizeof(DATA_A)+4,MEM_COMMIT,PAGE_READWRITE))
ReadProcessMemory(hP,(LPVOID)(((LPDATALIST*)lpData)[x]),(LPVOID)((lpMyData->lpListHeader->lpDataList))[x],sizeof(DATA_A)+4,NULL);
}
}
}
}
}
}
CloseHandle(hP);
}
}
}
return lpMyData;
}