| View previous topic :: View next topic |
| Author |
Message |
lurc Grandmaster Cheater Supreme
Reputation: 2
Joined: 13 Nov 2006 Posts: 1900
|
Posted: Mon Jan 14, 2008 4:01 pm Post subject: Calling a DialogBox from a DLL |
|
|
ok so i have a DLL that i made for Minesweeper, its only a small write 999 flags thing but anyways, it injects fine but once the dialog box opens up Minesweeper crashes.
help is appreciated.
| Code: | #include <windows.h>
#include "resource.h"
BOOL bWantsExit = FALSE;
void WriteFlags()
{
DWORD *pFlags = (DWORD*)0x1005194;
*pFlags = 999;
}
DWORD WINAPI MonitorHotKeys()
{
while ( !bWantsExit )
{
if ( GetAsyncKeyState( VK_F11 ) )
{
WriteFlags();
}
Sleep( 100 );
}
return 0;
}
BOOL CALLBACK DlgProc( HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam )
{
switch( uMsg )
{
case WM_INITDIALOG:
CreateThread( NULL, NULL, (LPTHREAD_START_ROUTINE)MonitorHotKeys, NULL, NULL, NULL );
return TRUE;
case WM_COMMAND:
switch( wParam )
{
case IDC_FLAGS:
WriteFlags();
return TRUE;
}
break;
case WM_CLOSE:
bWantsExit = TRUE;
EndDialog( hWnd, 0 );
return TRUE;
case WM_DESTROY:
bWantsExit = TRUE;
PostQuitMessage( 0 );
return TRUE;
}
return FALSE;
}
BOOL APIENTRY DllMain( HMODULE hModule, DWORD dwReason, LPVOID lpReserved )
{
switch( dwReason )
{
case DLL_PROCESS_ATTACH:
DisableThreadLibraryCalls( hModule );
MessageBox( NULL, TEXT("Minesweeper DLL has been Injected Succesfully"), TEXT("DLL Injected"), MB_OK );
DialogBox( hModule, MAKEINTRESOURCE( IDD_DIALOG1 ), NULL, (DLGPROC)DlgProc );
return TRUE;
case DLL_PROCESS_DETACH:
bWantsExit = TRUE;
return TRUE;
}
return TRUE;
} |
_________________
Last edited by lurc on Mon Jan 14, 2008 4:13 pm; edited 1 time in total |
|
| Back to top |
|
 |
appalsap Moderator
Reputation: 0
Joined: 27 Apr 2006 Posts: 6753 Location: Pakistan
|
Posted: Mon Jan 14, 2008 4:04 pm Post subject: |
|
|
You created a message loop in DllMain! LoadLibrary never returns! Don't use dangerous techniques like dll injection if you don't understand how they work!
_________________
|
|
| Back to top |
|
 |
lurc Grandmaster Cheater Supreme
Reputation: 2
Joined: 13 Nov 2006 Posts: 1900
|
Posted: Mon Jan 14, 2008 4:12 pm Post subject: |
|
|
lol oh >.< my bad i didnt know. no point in yelling, it was just a mistake.
so im sure its possible to call a dialogbox, id be neading a seperate thread my guess?
_________________
|
|
| Back to top |
|
 |
appalsap Moderator
Reputation: 0
Joined: 27 Apr 2006 Posts: 6753 Location: Pakistan
|
Posted: Mon Jan 14, 2008 4:18 pm Post subject: |
|
|
Not recommended, don't do anything OTHER than initialization in DllMain. The safest way would be to make a function the dll exports that does the dialogbox, and have the injector use CreateRemoteThread to start a new thread there (the same way the injector uses CreateRemoteThread to call LoadLibrary).
_________________
|
|
| Back to top |
|
 |
lurc Grandmaster Cheater Supreme
Reputation: 2
Joined: 13 Nov 2006 Posts: 1900
|
Posted: Mon Jan 14, 2008 4:33 pm Post subject: |
|
|
ok forget it, ill stick with making a dll with functions and just exporting them to a seperate executable.
_________________
|
|
| Back to top |
|
 |
|