Problem with a injection MFC Dll

c++ / delphi package - dll injection and api hooking

Postby Layane » Thu May 06, 2004 5:45 pm

After a week i resolve the problem with MFC Dlls. The source code that fix the problem is:

Code: Select all
CMyApplication theApp;

DWORD WINAPI ThreadStart (LPVOID dwThreadId) {

   //Change the module state

   ModStat = AfxGetStaticModuleState();
   ModStat->m_pCurrentWinApp = &theApp;
   ModStat->m_hCurrentInstanceHandle = ::GetModuleHandle(NULL);


   //put the new params for us application
   theApp.m_hThread = ::GetCurrentThread();
   theApp.m_nThreadID = m_nThreadID;
   theApp.m_hInstance = ::GetModuleHandle(NULL);
   //We create the windows
   CFrameWnd *MainWin = new CFrameWnd();


   theApp.m_pMainWnd = MainWin;

   //Run the message loop

   return TRUE;

BOOL CMyApplication::InitInstance()
   DWORD dwThreadId;

   return CWinApp::InitInstance();

- Madshi thks for the support and ideas to solve this problem :lol: :wink:

- The bug:;EN-US;142243
- MFC Source Code
Posts: 20
Joined: Sat May 01, 2004 11:03 am


Return to madCodeHook

Who is online

Users browsing this forum: No registered users and 2 guests