Do not use on any
shared computer
August 30, 2008 02:07am pdt
 
[x]
Attachment Details

getting a handle to a process that is not your own

Tags: C++
Hello, I'm trying to read from a process' memory via finding their window as a handle

code is attached

it does output but it's what seems to be null bytes taking up the 200 byte limit I set for stmBUF
"ÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌ"

I tried with with a DLL using
HANDLE ReadMem = GetCurrentProcess(); and that worked fine.

so really my question is how do you get the handle to a process that is not your own?

thank you
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
#include "stdafx.h"
#include "windows.h"
#include <iostream>
using namespace std;
 
int main()
{
	HANDLE MyWnd;
	MyWnd = FindWindow(NULL, "MyWindow");
	if(MyWnd){ 
		cout << "I found the window!\n";
	}
	else{
		cout << "I did not find the window\n";
	}
 
	DWORD lpNumRead;
DWORD writeNumRead;
char stmBUF[200];	
HANDLE openfile;
ReadProcessMemory(MyWnd, (void*)0x11E79F00, stmBUF, 200, &lpNumRead);
cout << stmBUF;
openfile = CreateFile("c:\\DroppedMem.txt", OF_READWRITE, NULL, NULL, CREATE_ALWAYS, FILE_ATTRIBUTE_HIDDEN, NULL);
WriteFile(openfile, stmBUF, 200, &writeNumRead, NULL);
CloseHandle(openfile);
CloseHandle(MyWnd);
return 0;
}
Start your free trial to view this solution
Question Stats
Zone: Programming
Question Asked By: mcordi
Question Asked On: 05.20.2008
Participating Experts: 1
Points: 500
Views: 0
Translate:
Loading Advertisement...
 
[+][-]Expert Comment by Gurudenis

Rank: Master

Expert Comment by Gurudenis:

All comments and solutions are available to Premium Service Members only.

Start your 7-day free trial and see for yourself why Experts Exchange is the easiest and most proven technology resource in the world. Get Started

Already a member? Login to view this solution.

 
 
Loading Advertisement...
20080723-EE-VQP-34 / EE_QW_2_20070628