Programming Forums
User Name Password Register
 

RSS Feed
FORUM INDEX | TODAY'S POSTS | UNANSWERED THREADS | ADVANCED SEARCH

Reply
 
Thread Tools Display Modes
Old Mar 16th, 2005, 5:27 AM   #1
lepricaun
Hobbyist Programmer
 
lepricaun's Avatar
 
Join Date: Aug 2004
Location: The Netherlands
Posts: 111
Rep Power: 5 lepricaun is on a distinguished road
CreateRemoteThread interest

Hi all,

i was writing a program which needed a thread so i went to msdn to read up on CreateThread. Well program works fine, problem solved.
But i saw CreateRemoteThread there and it made me curious, it has exactly the same parameters except for an extra handle to the target process.

So i decided to try it out using a simple function like the one here:
ThreadProc(LPARAM lpara)
{
      MessageBox(NULL,"I'm inside another process.","lepricaun",MB_OK);
     return 0;
}

this function works fine in
CreateThread(NULL,0,ThreadProc,0,0,NULL);

But as you can guess it gives an error if trying to create a remote thread in another process (although it does return a handle to the thread).

What am i missing here? i can imagin i need to copy the code to the memory of the target process first, but how do i retrieve the starting address of the procedure once in memory?

Thanks in advance!
__________________
http://www.white-scorpion.nl
lepricaun is offline   Reply With Quote
Old Mar 16th, 2005, 9:47 AM   #2
Ooble
I eat cake for breakfast.
 
Ooble's Avatar
 
Join Date: Jul 2004
Location: In my box.
Posts: 4,434
Rep Power: 9 Ooble is on a distinguished road
IIRC, you want the address of the function:
CreateThread(NULL, 0, &ThreadProc, 0, 0, NULL);
__________________
Me :: You :: Them
Ooble is offline   Reply With Quote
Old Mar 17th, 2005, 3:15 AM   #3
lepricaun
Hobbyist Programmer
 
lepricaun's Avatar
 
Join Date: Aug 2004
Location: The Netherlands
Posts: 111
Rep Power: 5 lepricaun is on a distinguished road
thanks for your response Ooble.

But i do need to write the procedure to the processes memory first don't i?
__________________
http://www.white-scorpion.nl
lepricaun is offline   Reply With Quote
Old Mar 17th, 2005, 10:38 AM   #4
Ooble
I eat cake for breakfast.
 
Ooble's Avatar
 
Join Date: Jul 2004
Location: In my box.
Posts: 4,434
Rep Power: 9 Ooble is on a distinguished road
Try it - I think that was how I did it when I was playing with threads.
__________________
Me :: You :: Them
Ooble is offline   Reply With Quote
Old Mar 17th, 2005, 4:08 PM   #5
lepricaun
Hobbyist Programmer
 
lepricaun's Avatar
 
Join Date: Aug 2004
Location: The Netherlands
Posts: 111
Rep Power: 5 lepricaun is on a distinguished road
unfortunately that didn't work i even tried rewriting it in masm using the same API's and then:
offset ThreadProc
addr ThreadProc
ThreadProc

all of the above give the same error as well, so there must be something else wrong, but what?
__________________
http://www.white-scorpion.nl
lepricaun is offline   Reply With Quote
Reply

Bookmarks

« Previous Thread in Forum | Next Thread in Forum »

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump




DaniWeb IT Discussion Community
All times are GMT -5. The time now is 5:54 AM.

Powered by vBulletin® Version 3.7.0, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Copyright ©2007 DaniWeb® LLC