1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

How to Use CreateRemoteThread

Discussion in 'C++' started by felix1432, Jul 6, 2010.

  1. felix1432

    felix1432 New Member

    Joined:
    Jul 6, 2010
    Messages:
    1
    Likes Received:
    0
    Trophy Points:
    0
    Hi,


    I can create Threads in my own process using the CreateThread API easily.
    Now i wanted to create a remote thread, but fail to supply a handle to the desire process:

    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
    );

    I tried to get a handle using OpenProcess:

    HANDLE WINAPI OpenProcess(
    __in DWORD dwDesiredAccess,
    __in BOOL bInheritHandle,
    __in DWORD dwProcessId <==
    );


    but i need a process id (PID) here.
    Now, how do i get that PID?

    I thought of the GetProcessId API:

    DWORD WINAPI GetProcessId(
    __in HANDLE Process
    );


    which requires a handle to the process...Do you see the vicious circle here? :/
     

Share This Page