Cheat Engine Forum Index Cheat Engine
The Official Site of Cheat Engine
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 


[Q] CreateRemoteThread

 
Post new topic   Reply to topic    Cheat Engine Forum Index -> General programming
View previous topic :: View next topic  
Author Message
*CandyShop*
Grandmaster Cheater
Reputation: 0

Joined: 03 Apr 2007
Posts: 865
Location: Israel

PostPosted: Wed Apr 09, 2008 2:01 pm    Post subject: [Q] CreateRemoteThread Reply with quote

Hi,
I want to CreatRemoteThread to a process and actually run my function in the process(thread...)
Anyway, I want something like this:
Code:
//Thread function
int __stdcall threadProc(LPVOID lpParameter){
        MessageBox(0, _T("Hello world"), _T("Caption"), MB_OK);
}

//...
//...CreateRemoteThread with threadProc so when it will executed
//(when thread will be created, it will do a messagebox with the threadProc code).


Thanks for helpers Smile
Back to top
View user's profile Send private message
samuri25404
Grandmaster Cheater
Reputation: 7

Joined: 04 May 2007
Posts: 955
Location: Why do you care?

PostPosted: Wed Apr 09, 2008 2:18 pm    Post subject: Reply with quote

Decl:

Code:

HANDLE WINAPI CreateRemoteThread(
  __in   HANDLE hProcess,
  __in   LPSECURITY_ATTRIBUTES lpThreadAttributes,
  __in   SIZE_T dwStackSize,
  __in   LPTHREAD_START_ROUTINE lpStartAddress,
  __in   LPVOID lpParameter,
  __in   DWORD dwCreationFlags,
  __out  LPDWORD lpThreadId
);


Figure it out yourself.

_________________
Wiccaan wrote:

Oh jeez, watchout I'm a bias person! Locked.


Auto Assembly Tuts:
In Depth Tutorial on AA
Extended
Back to top
View user's profile Send private message
atom0s
Moderator
Reputation: 205

Joined: 25 Jan 2006
Posts: 8587
Location: 127.0.0.1

PostPosted: Thu Apr 10, 2008 12:02 am    Post subject: Reply with quote

Code:
__in   LPTHREAD_START_ROUTINE lpStartAddress


lpStartAddress param is the function address that holds the thread routine, pass it the address to your function you listed above, other params can just be NULL.

CreateRemoteThread( hProcess, NULL, NULL, (LPTHREAD_START_ROUTINE)&threadProc, NULL, NULL, NULL );

You can obtain the thread handle and ID if you wish, most of the time you don't really need it unless you wish to terminate the thread manually before closing the full program.

(Although you should always clean up the memory you create.)

_________________
- Retired.
Back to top
View user's profile Send private message Visit poster's website
*CandyShop*
Grandmaster Cheater
Reputation: 0

Joined: 03 Apr 2007
Posts: 865
Location: Israel

PostPosted: Thu Apr 10, 2008 7:28 am    Post subject: Reply with quote

I know all these...
Wiccan, is that CreateRemoteThread example works? Or do I need to VirtualAllocEx for my thread before?
Back to top
View user's profile Send private message
atom0s
Moderator
Reputation: 205

Joined: 25 Jan 2006
Posts: 8587
Location: 127.0.0.1

PostPosted: Thu Apr 10, 2008 7:56 pm    Post subject: Reply with quote

*CandyShop* wrote:
I know all these...
Wiccan, is that CreateRemoteThread example works? Or do I need to VirtualAllocEx for my thread before?


You would need to allocate memory and write your thread function into the processes memory space. So yes, you would need to use VirtualAllocEx(), then WriteProcessMemory to write the function to the programs memory, then create the remote thread to call that function.

_________________
- Retired.
Back to top
View user's profile Send private message Visit poster's website
*CandyShop*
Grandmaster Cheater
Reputation: 0

Joined: 03 Apr 2007
Posts: 865
Location: Israel

PostPosted: Fri Apr 11, 2008 10:46 am    Post subject: Reply with quote

Wiccaan wrote:
*CandyShop* wrote:
I know all these...
Wiccan, is that CreateRemoteThread example works? Or do I need to VirtualAllocEx for my thread before?


You would need to allocate memory and write your thread function into the processes memory space. So yes, you would need to use VirtualAllocEx(), then WriteProcessMemory to write the function to the programs memory, then create the remote thread to call that function.
Thanks Smile
Do I need to write my function as an aobs? Is there any other method?
Ty
Back to top
View user's profile Send private message
rapion124
Grandmaster Cheater Supreme
Reputation: 0

Joined: 25 Mar 2007
Posts: 1095

PostPosted: Fri Apr 11, 2008 8:53 pm    Post subject: Reply with quote

Write the function in your own program and then use WriteProcessMemory to write it to the process you want to invoke CreateRemoteThread in.
Back to top
View user's profile Send private message
*CandyShop*
Grandmaster Cheater
Reputation: 0

Joined: 03 Apr 2007
Posts: 865
Location: Israel

PostPosted: Mon Apr 14, 2008 2:33 pm    Post subject: Reply with quote

rapion124 wrote:
Write the function in your own program and then use WriteProcessMemory to write it to the process you want to invoke CreateRemoteThread in.


Code:
//Thread function
int __stdcall threadProc(LPVOID lpParameter){
        MessageBox(0, _T("Hello world"), _T("Caption"), MB_OK);
}
//Writing the function?:
WriteProcessMemory(hProcess,VirtualAllocEx(hProcess,...),(LPVOID)threadProc, ..., NULL);

I know that VirtualAllocEx isn't completed but the thing is...
Code:
(LPVOID)threadProc
will work? I think it won't...
Do I need to make my own array of byte to do it? Is there any other method?

ty
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    Cheat Engine Forum Index -> General programming All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


Powered by phpBB © 2001, 2005 phpBB Group

CE Wiki   IRC (#CEF)   Twitter
Third party websites