crims
asked on
Stuck on ReadProcessMemory() for over a week, can someone please take a look
All the functions below main work fine, The SendMessage() work fine, Just the ReadProcessMemory. What I am trying to do is to copy a string from a listbox, to variable (with out looking at my code i think the variable is "testing". I have been programming 8 months, so i am not that experienced, my code might look like garbage in that ReadProcessMemory(), i have been trying differen't things.
Code is below
#include<iostream>
#include<windows.h>
using std::cin;
using std::cout;
using std::endl;
HWND AOL();
HWND MDI();
HWND ListBox();
HWND FindChat();
int main()
{
DWORD LBthread;
DWORD ProcessID;
char ScreenNames[17];
DWORD NumberOfPeopleInRoom;
unsigned long bytes;
LBthread = GetWindowThreadProcessId(L istBox(),& ProcessID) ;
HANDLE OpenProc;
OpenProc = OpenProcess(PROCESS_VM_REA D,FALSE,Pr ocessID);
if(OpenProc)
{
NumberOfPeopleInRoom = SendMessage(ListBox(), LB_GETCOUNT, 0, 0) - 1;
cout << NumberOfPeopleInRoom << endl;
DWORD itemData;
WORD length;
TCHAR *pszCmdLine = new TCHAR[length];
itemData = SendMessage(ListBox(), LB_GETITEMDATA,(WPARAM) 10,0);
ReadProcessMemory(OpenProc ,(LPVOID) itemData,pszCmdLine,length ,&bytes);
/*
struct __INFOBLOCK
{
DWORD dwFiller[16];
WORD wLength;
WORD wMaxLength;
DWORD dwCmdLineAddress;
} Block;
ReadProcessMemory(hProcess , (LPVOID) PEB.dwInfoBlockAddress,
&Block, sizeof(Block), &dwSize);
TCHAR *pszCmdLine = new TCHAR[Block.wMaxLength];
ReadProcessMemory(hProcess , (LPVOID) Block.dwCmdLineAddress,
pszCmdLine, Block.wMaxLength, &dwSize);
*/
char testing[17];
CopyMemory(&testing,&pszCm dLine,byte s);
cout << *testing << endl;
}
system("PAUSE");
return 0;
}
HWND AOL()
{
HWND AOLwindow;
AOLwindow = FindWindowEx(0,0,"AOL Frame25",0);
return AOLwindow;
}
HWND MDI()
{
HWND MDIwindow;
MDIwindow = FindWindowEx(AOL(),0,"MDIC lient",0);
return MDIwindow;
}
HWND FindChat()
{
HWND hwndChild = 0, hwndAOLChatForm = 0;
do
{
hwndAOLChatForm = FindWindowEx(hwndChild, 0, "_AOL_Static", "AOL_CHAT_FORM");
if (hwndAOLChatForm) break;
hwndChild = FindWindowEx(MDI(), hwndChild, "AOL Child", 0);
}
while (hwndChild);
return hwndChild;
}
HWND ListBox()
{
HWND listbox;
listbox = FindWindowEx(FindChat(),0, "_AOL_List box",0);
return listbox;
}
Code is below
#include<iostream>
#include<windows.h>
using std::cin;
using std::cout;
using std::endl;
HWND AOL();
HWND MDI();
HWND ListBox();
HWND FindChat();
int main()
{
DWORD LBthread;
DWORD ProcessID;
char ScreenNames[17];
DWORD NumberOfPeopleInRoom;
unsigned long bytes;
LBthread = GetWindowThreadProcessId(L
HANDLE OpenProc;
OpenProc = OpenProcess(PROCESS_VM_REA
if(OpenProc)
{
NumberOfPeopleInRoom = SendMessage(ListBox(), LB_GETCOUNT, 0, 0) - 1;
cout << NumberOfPeopleInRoom << endl;
DWORD itemData;
WORD length;
TCHAR *pszCmdLine = new TCHAR[length];
itemData = SendMessage(ListBox(), LB_GETITEMDATA,(WPARAM) 10,0);
ReadProcessMemory(OpenProc
/*
struct __INFOBLOCK
{
DWORD dwFiller[16];
WORD wLength;
WORD wMaxLength;
DWORD dwCmdLineAddress;
} Block;
ReadProcessMemory(hProcess
&Block, sizeof(Block), &dwSize);
TCHAR *pszCmdLine = new TCHAR[Block.wMaxLength];
ReadProcessMemory(hProcess
pszCmdLine, Block.wMaxLength, &dwSize);
*/
char testing[17];
CopyMemory(&testing,&pszCm
cout << *testing << endl;
}
system("PAUSE");
return 0;
}
HWND AOL()
{
HWND AOLwindow;
AOLwindow = FindWindowEx(0,0,"AOL Frame25",0);
return AOLwindow;
}
HWND MDI()
{
HWND MDIwindow;
MDIwindow = FindWindowEx(AOL(),0,"MDIC
return MDIwindow;
}
HWND FindChat()
{
HWND hwndChild = 0, hwndAOLChatForm = 0;
do
{
hwndAOLChatForm = FindWindowEx(hwndChild, 0, "_AOL_Static", "AOL_CHAT_FORM");
if (hwndAOLChatForm) break;
hwndChild = FindWindowEx(MDI(), hwndChild, "AOL Child", 0);
}
while (hwndChild);
return hwndChild;
}
HWND ListBox()
{
HWND listbox;
listbox = FindWindowEx(FindChat(),0,
return listbox;
}
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
thats correct:
HANDLE OpenProc;
OpenProc = OpenProcess(PROCESS_VM_REA D,FALSE,Pr ocessID);
HANDLE OpenProc;
OpenProc = OpenProcess(PROCESS_VM_REA
ASKER
I don't understand the second parameter, of this function, it says a "base address" a base address to the handle, to the item to what??????? i don't get it. I tried everything i can think of.
ASKER
hProcess
[in] A handle to the process with memory that is being read. The handle must have PROCESS_VM_READ access to the process.