Click here to Skip to main content
16,015,072 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
Generalprocesses Pin
mpapeo21-Feb-05 14:06
mpapeo21-Feb-05 14:06 
GeneralRe: processes Pin
Aamir Butt22-Feb-05 0:17
Aamir Butt22-Feb-05 0:17 
GeneralRe: processes Pin
mpapeo28-Feb-05 16:31
mpapeo28-Feb-05 16:31 
GeneralDialog Bars in Dialog Based applications Pin
Will115721-Feb-05 12:49
sussWill115721-Feb-05 12:49 
GeneralRe: Dialog Bars in Dialog Based applications Pin
Will115721-Feb-05 13:13
sussWill115721-Feb-05 13:13 
GeneralRe: Dialog Bars in Dialog Based applications Pin
JohnCz21-Feb-05 13:50
JohnCz21-Feb-05 13:50 
GeneralRe: Dialog Bars in Dialog Based applications Pin
Mohammad Tarik22-Feb-05 1:23
Mohammad Tarik22-Feb-05 1:23 
GeneralProblem With Dll Injection Pin
gamitech21-Feb-05 10:37
gamitech21-Feb-05 10:37 
Hello everybody
I am trying to inject a dll in a certain process but everytime I do It the injected process does not respond.
I have debuged the program step by step and I don't get any invalid handles or leaks of memoriy.
The funny thing is that when I enumerate all the modules from a process and I create a remote thread to free a library from a process it works just fine.
Also when I try to inject a certain library in my own process it works just fine
Here Is the code I use:


<br />
int WINAPI InjectLib(DWORD process_id, char *lib_name)<br />
{<br />
<br />
	PTHREAD_START_ROUTINE pfnRemote =(PTHREAD_START_ROUTINE)<br />
			GetProcAddress(GetModuleHandle("Kernel32"), "LoadLibraryA");<br />
	if(pfnRemote ==NULL)<br />
		return -1;<br />
	HANDLE hProcess =OpenProcess(PROCESS_ALL_ACCESS, FALSE, process_id);<br />
	if(hProcess ==NULL)<br />
	{<br />
<br />
		return -1;<br />
	}<br />
<br />
	int mem_size =strlen(lib_name)+1;<br />
	void *premote_mem =VirtualAllocEx(hProcess, NULL, mem_size, MEM_COMMIT, PAGE_READWRITE);<br />
	if(premote_mem ==NULL)<br />
	{<br />
		CloseHandle(hProcess);<br />
		return -1;<br />
	}<br />
<br />
	int ret =WriteProcessMemory(hProcess, premote_mem, lib_name, mem_size,NULL);<br />
	if(ret ==STATUS_ACCESS_VIOLATION || ret ==false)<br />
	{<br />
<br />
		VirtualFreeEx(hProcess, premote_mem, 0, MEM_RELEASE);<br />
		CloseHandle(hProcess); <br />
		return -1;<br />
	}<br />
<br />
<br />
	HANDLE hThread =CreateRemoteThread(hProcess, NULL, 0, <br />
			pfnRemote, premote_mem, 0, NULL);<br />
<br />
	if(hThread ==NULL)<br />
	{<br />
		VirtualFreeEx(hProcess, premote_mem, 0, MEM_RELEASE);<br />
		CloseHandle(hProcess);<br />
		return -1;<br />
	}<br />
	<br />
<br />
	WaitForSingleObject(hThread, INFINITE);<br />
<br />
	VirtualFreeEx(hProcess, premote_mem, 0, MEM_RELEASE);<br />
	CloseHandle(hProcess);<br />
	CloseHandle(hThread);<br />
<br />
	return 0;<br />
}


Can someone tell me what am I missing.


gabby
Generalstart when cd is in Pin
jonavon blakly21-Feb-05 7:40
jonavon blakly21-Feb-05 7:40 
GeneralRe: start when cd is in Pin
Ravi Bhavnani21-Feb-05 7:44
professionalRavi Bhavnani21-Feb-05 7:44 
GeneralSafe Exit Pin
DanYELL21-Feb-05 6:36
DanYELL21-Feb-05 6:36 
GeneralRe: Safe Exit Pin
Michael Dunn21-Feb-05 6:53
sitebuilderMichael Dunn21-Feb-05 6:53 
GeneralStatic map Pin
ralfeus21-Feb-05 4:57
ralfeus21-Feb-05 4:57 
GeneralRe: Static map Pin
HalfWayMan21-Feb-05 5:15
HalfWayMan21-Feb-05 5:15 
GeneralRe: Static map Pin
ralfeus21-Feb-05 6:02
ralfeus21-Feb-05 6:02 
GeneralRe: Static map Pin
ThatsAlok21-Feb-05 5:16
ThatsAlok21-Feb-05 5:16 
QuestionHow to change color of button text ? Pin
scanf21-Feb-05 4:06
scanf21-Feb-05 4:06 
AnswerRe: How to change color of button text ? Pin
ThatsAlok21-Feb-05 4:56
ThatsAlok21-Feb-05 4:56 
GeneralRe: How to change color of button text ? Pin
scanf21-Feb-05 6:34
scanf21-Feb-05 6:34 
AnswerRe: How to change color of button text ? Pin
Ravi Bhavnani21-Feb-05 7:41
professionalRavi Bhavnani21-Feb-05 7:41 
AnswerRe: How to change color of button text ? Pin
eli1502197922-Feb-05 3:22
eli1502197922-Feb-05 3:22 
GeneralMeasuring Internet Activity Pin
Anorexic Tribble21-Feb-05 3:44
Anorexic Tribble21-Feb-05 3:44 
GeneralRe: Measuring Internet Activity Pin
ThatsAlok21-Feb-05 5:33
ThatsAlok21-Feb-05 5:33 
GeneralRe: Measuring Internet Activity Pin
Anorexic Tribble21-Feb-05 6:48
Anorexic Tribble21-Feb-05 6:48 
GeneralRe: Measuring Internet Activity Pin
ThatsAlok23-Feb-05 18:46
ThatsAlok23-Feb-05 18:46 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.