Thread: Two Step DLL Inection (How to get thread handle?)

  1. #1
    Registered User
    Join Date
    Jan 2009
    Posts
    3

    Two Step DLL Inection (How to get thread handle?)

    So I want two create a 2 step DLL injection process, the first level is a very unobtrusive global DLL:

    SetWindowsHookEx -> parameter 4 = 0 -> Global injection.

    this dll then observes which process it attaches to:

    Code:
    BOOL APIENTRY DllMain( HMODULE hModule,
                           DWORD  ul_reason_for_call,
                           LPVOID lpReserved	 )
    {
    
    
    	switch (ul_reason_for_call)
    	{
    	case DLL_PROCESS_ATTACH:
            if ( GetModuleHandle( _T("Process.exe") ) != NULL )
                    // inject 2nd dll ONLY into this thread
    
    :
    so basically after I verify that the object currently being attached is of a specific type I want to attach my 2nd hook, but only into this process. Using SetWindowsHookEx(), i need the DWORD threadID for this process, but I'm not sure how to get it from the HMODULE given in the DLLMain, any suggestions?

  2. #2
    Ex scientia vera
    Join Date
    Sep 2007
    Posts
    477
    "What's up, Doc?"
    "'Up' is a relative concept. It has no intrinsic value."

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Terminating secondary thread from another thread
    By wssoh85 in forum C++ Programming
    Replies: 13
    Last Post: 12-19-2008, 05:14 AM
  2. Direct3D problem
    By cboard_member in forum Game Programming
    Replies: 10
    Last Post: 04-09-2006, 03:36 AM
  3. Button handler
    By Nephiroth in forum Windows Programming
    Replies: 8
    Last Post: 03-12-2006, 06:23 AM
  4. Thread from Dll
    By knutso in forum C++ Programming
    Replies: 4
    Last Post: 10-07-2002, 05:36 AM
  5. Multi-Thread Programming
    By drdroid in forum C++ Programming
    Replies: 6
    Last Post: 04-04-2002, 02:53 PM