Thread: Thread Issue

  1. #1
    Registered User
    Join Date
    Jul 2014
    Posts
    2

    Thread Issue

    Hello guys, I'm trying create a thread in a Win32 DLL (hooked with LoadLibraryA). But the thread doesn't work.


    For exemple:
    Code:
    void ThreadTest()
    {
    MessageBox(NULL,"Test","Test",0);
    }
    
    
    ...
    
    
    CreateThread(0,0,(LPTHREAD_START_ROUTINE)ThreadTest,NULL,0,0);

    I've tried various ways, with dword winapi, void parameter, with beginthread, with text log (on place of MessageBox).


    Someone help-me?


    Sorry my bad english.

  2. #2
    Registered User
    Join Date
    Jul 2014
    Posts
    2
    I found the problem but not found the solution.


    My application is some like:


    Code:
    BOOL APIENTRY DllMain(HANDLE hModule,DWORD ul_reason_for_call,LPVOID lpReserved) // OK
    {
    	switch(ul_reason_for_call)
    	{
    		case DLL_PROCESS_ATTACH:
                    EntryProc();
                    ...
            }
    }

    Code:
    void EntryProc()
    {
              CreateThread(...);
              while(true)
              {
               ...
              }
    }

    But my thread start only after while(), I need that he start before While().


    Someone can help me?

  3. #3
    Registered User Codeplug's Avatar
    Join Date
    Mar 2003
    Posts
    4,980
    Threads do not start running until after you return from DllMain. You have to be careful about what system calls you make from DllMain: Dynamic-Link Library Best Practices (Windows)

    gg

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Replies: 3
    Last Post: 11-20-2011, 12:01 AM
  2. C++ thread inside a class hang issue
    By diefast9 in forum C++ Programming
    Replies: 11
    Last Post: 10-21-2009, 07:18 AM
  3. Replies: 2
    Last Post: 07-01-2007, 07:11 AM
  4. Replies: 3
    Last Post: 11-16-2006, 04:23 AM
  5. Replies: 8
    Last Post: 01-17-2006, 05:39 PM