Cheat Engine Forum Index Cheat Engine
The Official Site of Cheat Engine
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 


Dll Dialog Erro

 
Post new topic   Reply to topic    Cheat Engine Forum Index -> General programming
View previous topic :: View next topic  
Author Message
HomerSexual
Grandmaster Cheater Supreme
Reputation: 5

Joined: 03 Feb 2007
Posts: 1657

PostPosted: Tue May 20, 2008 7:07 pm    Post subject: Dll Dialog Erro Reply with quote

EDIT:

IT'S IN MY WHILE LOOP 100% SURE


Code:

#include <windows.h>
#include <commctrl.h>
#include <stdlib.h>
#define IDC_STATIC1 40000
#define IDC_STATIC2 40001
#define IDC_STATIC3 40002
#define IDC_STATIC4 40003
#define ReadPointer(base, offset) (*(ULONG_PTR*)((*(ULONG_PTR*)base)+offset))
bool fin = FALSE;
HINSTANCE hInst;

int CreateDialogB(){
hInst = GetModuleHandle(0);
WNDCLASSEX wcex;
ZeroMemory(&wcex, sizeof wcex);
wcex.cbSize         = sizeof wcex;
wcex.hbrBackground  = GetSysColorBrush(COLOR_3DFACE);
wcex.lpszMenuName   = 0;


wcex.style          = CS_HREDRAW | CS_VREDRAW;
wcex.lpfnWndProc    = DefWindowProc;
wcex.hInstance      = hInst;
wcex.hIcon          = LoadIcon(0, (LPCTSTR)IDI_APPLICATION);
wcex.hCursor        = LoadCursor(NULL, IDC_ARROW);
wcex.lpszClassName  = "SteveClass";
RegisterClassEx(&wcex);
InitCommonControls();
HFONT hfont0 = CreateFont(-11, 0, 0, 0, 400, FALSE, FALSE, FALSE, 1, 400, 0, 0, 0, TEXT("Ms Shell Dlg 2"));
HWND hwnd = CreateWindowEx(WS_EX_TOOLWINDOW, "SteveClass","Char X/Y", WS_VISIBLE | WS_BORDER | WS_CAPTION | WS_DLGFRAME | WS_POPUP | WS_SYSMENU, 900, 700, 116, 133, 0, 0, hInst, 0);

HWND hCtrl0_0 = CreateWindowEx(0, WC_STATIC, TEXT("Player X:"), WS_VISIBLE | WS_CHILD | WS_GROUP, 6, 36, 45, 13, hwnd, (HMENU)IDC_STATIC1, hInst, 0);
SendMessage(hCtrl0_0, WM_SETFONT, (WPARAM)hfont0, FALSE);
HWND hCtrl0_1 = CreateWindowEx(0, WC_STATIC, TEXT("Player Y:"), WS_VISIBLE | WS_CHILD | WS_GROUP, 6, 57, 45, 13, hwnd, (HMENU)IDC_STATIC2, hInst, 0);
SendMessage(hCtrl0_1, WM_SETFONT, (WPARAM)hfont0, FALSE);
HWND hCtrl0_2 = CreateWindowEx(0, WC_STATIC, TEXT("0"), WS_VISIBLE | WS_CHILD | WS_GROUP, 59, 36, 51, 18, hwnd, (HMENU)IDC_STATIC3, hInst, 0);
SendMessage(hCtrl0_2, WM_SETFONT, (WPARAM)hfont0, FALSE);
HWND hCtrl0_3 = CreateWindowEx(0, WC_STATIC, TEXT("0"), WS_VISIBLE | WS_CHILD | WS_GROUP, 59, 57, 29, 13, hwnd, (HMENU)IDC_STATIC4, hInst, 0);
SendMessage(hCtrl0_3, WM_SETFONT, (WPARAM)hfont0, FALSE);

return 0;

}

DWORD WINAPI main( LPVOID lpParam){
   long charx;
   long chary;
   HWND idcstatic3;
   char buf[33];

   if(CreateDialogB() != 0){
      MessageBox(0, "Window could not be made", "Error", MB_OK);
      return 1;
   }

   while(true){
      if(fin == TRUE)
         break;
      else{
      Sleep(250);
      }
   }
   FreeLibraryAndExitThread(hInst, 0);
   return 0;
}

BOOL APIENTRY DllMain( HMODULE hModule,
                       DWORD  ul_reason_for_call,
                       LPVOID lpReserved
                )
{
   switch (ul_reason_for_call)
   {
   case DLL_PROCESS_ATTACH:
         CreateThread(NULL, 0, main, NULL, 0, NULL);
         break;
   case DLL_THREAD_ATTACH:
   case DLL_THREAD_DETACH:
   case DLL_PROCESS_DETACH:
         fin = FALSE;
         break;
   }
   return TRUE;
}




this is my source to a .dll program. The window is made but it will not totally load. I think it's the while loop. I have tried to comment alot out but no luck

_________________
Back to top
View user's profile Send private message
DoomsDay
Grandmaster Cheater
Reputation: 0

Joined: 06 Jan 2007
Posts: 768
Location: %HomePath%

PostPosted: Tue May 20, 2008 10:36 pm    Post subject: Reply with quote

Message loop?
Back to top
View user's profile Send private message
HalfPrime
Grandmaster Cheater
Reputation: 0

Joined: 12 Mar 2008
Posts: 532
Location: Right there...On your monitor

PostPosted: Tue May 20, 2008 11:09 pm    Post subject: Reply with quote

Code:
   while(true){
      if(fin == TRUE)
         break;
      else{
      Sleep(250);
      }

o.O?
either sleep forever or continue? you don't set fin to true anywhere.

EDIT:
whoa...you have 2 mains?

_________________
Back to top
View user's profile Send private message
Noz3001
I'm a spammer
Reputation: 26

Joined: 29 May 2006
Posts: 6220
Location: /dev/null

PostPosted: Wed May 21, 2008 1:35 am    Post subject: Reply with quote

Yeah, No WndProc either.
Back to top
View user's profile Send private message MSN Messenger
HomerSexual
Grandmaster Cheater Supreme
Reputation: 5

Joined: 03 Feb 2007
Posts: 1657

PostPosted: Wed May 21, 2008 5:22 am    Post subject: Reply with quote

If you didn't know, it has a WndProc, DefWndProc. It handles all the messages by default.

The main is DllMain() which calls CreateThread(NULL, 0, main, NULL, 0, NULL); on attachment

This runs my second main (it doesn't matter what you call them, my main could be Farfniggle) which runs my dialog creation and goes into an inf loop to keep it alive.

Since there are no buttons i don't have to handle commands or shit like that >.> I can just use SendMessage

_________________
Back to top
View user's profile Send private message
Symbol
I'm a spammer
Reputation: 0

Joined: 18 Apr 2007
Posts: 5094
Location: Israel.

PostPosted: Wed May 21, 2008 5:35 am    Post subject: Reply with quote

Why not just:

while (!fin){}?

And you do have to handle the messages, when you call SendMessage the message is waiting on the message queue, you need a message loop to process these messages.
Back to top
View user's profile Send private message
atom0s
Moderator
Reputation: 205

Joined: 25 Jan 2006
Posts: 8585
Location: 127.0.0.1

PostPosted: Wed May 21, 2008 6:18 am    Post subject: Reply with quote

Any reason why you want to use CreateWindowEx over a dialog for the window? Just wondering since you could do this via a dialog very very easily. I can make an example for you if you wish.
_________________
- Retired.
Back to top
View user's profile Send private message Visit poster's website
HomerSexual
Grandmaster Cheater Supreme
Reputation: 5

Joined: 03 Feb 2007
Posts: 1657

PostPosted: Wed May 21, 2008 2:08 pm    Post subject: Reply with quote

New Update:

My good friend cybar let me check out one of his dlls and i got this shit fixed but now I have a new problem. I can't close the form, move it, etc. IT's like the messages aren't being processes

Swithced to dialogs wiccan. I was using resedit so it made the code for me so i was like w/e

Code:

#include <windows.h>
#include <commctrl.h>
#include <stdlib.h>
#define IDC_STATIC1 40000
#define IDC_STATIC2 40001
#define IDC_STATIC3 40002
#define IDC_STATIC4 40003
#define IDD_DIALOG1 40004
#define ReadPointer(base, offset) (*(ULONG_PTR*)((*(ULONG_PTR*)base)+offset))
bool fin = FALSE;
HINSTANCE hInst;
HWND hDlgCtrl;
HWND thisHwnd;
HMODULE thisModule;

BOOL bExit = FALSE;
BOOL bExit2 = FALSE;

/*void DoStuff(){
   while (!bExit && !bExit2){
   Sleep(100);
   }
}*/

bool CALLBACK DlgProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
{
   UNREFERENCED_PARAMETER( lParam );

   thisHwnd = hWnd;

   switch( uMsg )
   {
   case WM_INITDIALOG:
      //CreateThread( NULL, 0, (LPTHREAD_START_ROUTINE)DoStuff, NULL, 0, 0 );
   return TRUE;

   case WM_CLOSE:
      bExit2 = TRUE;
      bExit = TRUE;
      EndDialog( hWnd, 0 );
      return TRUE;
   case WM_DESTROY:
      bExit2 = TRUE;
      bExit = TRUE;
      PostQuitMessage( 0 );
      return TRUE;
   }
   return FALSE;
}


DWORD WINAPI main( LPVOID lpParam){
   Sleep(500);
   DialogBox( thisModule, MAKEINTRESOURCE( IDD_DIALOG1 ), NULL, (DLGPROC)DlgProc );
   ExitThread(0);
   return 0;
}

BOOL APIENTRY DllMain( HMODULE hModule,
                       DWORD  ul_reason_for_call,
                       LPVOID lpReserved
                )
{
   switch (ul_reason_for_call)
   {
   case DLL_PROCESS_ATTACH:
         thisModule = hModule;
         CreateThread(NULL, 0, main, NULL, 0, NULL);
         break;
   case DLL_THREAD_ATTACH:
   case DLL_THREAD_DETACH:
   case DLL_PROCESS_DETACH:
         bExit2 = TRUE;
         bExit = TRUE;
         fin = FALSE;
         break;
   }
   return TRUE;
}

_________________
Back to top
View user's profile Send private message
DoomsDay
Grandmaster Cheater
Reputation: 0

Joined: 06 Jan 2007
Posts: 768
Location: %HomePath%

PostPosted: Wed May 21, 2008 2:25 pm    Post subject: Reply with quote

Code:
#define IDD_DLG1 1000

IDD_DLG1 DIALOGEX 0,0,200,150
CAPTION "Dialog"
FONT 8,"MS Sans Serif",400,0
STYLE WS_OVERLAPPEDWINDOW | WS_VISIBLE | DS_CENTER
EXSTYLE 0x00000000
BWGIN
END

//////////////////////////////////

bool CALLBACK DlgProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
{
   switch( uMsg )
   {
      case WM_CLOSE:
      EndDialog( hWnd,0);
      return TRUE
   case WM_DESTROY:
      PostQuitMessage(0);
      return TRUE;
   }
   return FALSE;
}

DWORD WINAPI main( LPVOID lpParam)
{
   InitCommonControls;
   DialogBoxParam(GetModuleHandle(NULL),IDD_DLG1,NULL,(DLGPROC)DlgProc,NULL)
   ExitThread(0);
}

BOOL APIENTRY DllMain( HMODULE hModule,DWORD  ul_reason_for_call,LPVOID lpReserved)
{
   switch (ul_reason_for_call)
   {
      case DLL_PROCESS_ATTACH:
         CreateThread(NULL, 0, main, NULL, 0, NULL);
         break;
      case DLL_THREAD_ATTACH:
      case DLL_THREAD_DETACH:
      case DLL_PROCESS_DETACH:
   }
   return TRUE;
}
Back to top
View user's profile Send private message
HomerSexual
Grandmaster Cheater Supreme
Reputation: 5

Joined: 03 Feb 2007
Posts: 1657

PostPosted: Wed May 21, 2008 2:43 pm    Post subject: Reply with quote

DialogBoxParam is incorrect and no difference really
_________________
Back to top
View user's profile Send private message
HalfPrime
Grandmaster Cheater
Reputation: 0

Joined: 12 Mar 2008
Posts: 532
Location: Right there...On your monitor

PostPosted: Wed May 21, 2008 6:55 pm    Post subject: Reply with quote

Are you sure you're sending messages to the dll and not the porogram you're injecting it into?
_________________
Back to top
View user's profile Send private message
HomerSexual
Grandmaster Cheater Supreme
Reputation: 5

Joined: 03 Feb 2007
Posts: 1657

PostPosted: Wed May 21, 2008 7:22 pm    Post subject: Reply with quote

the issue was in default

I needed

default:
return TRUE;

The messages were just sitting there

_________________
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    Cheat Engine Forum Index -> General programming All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


Powered by phpBB © 2001, 2005 phpBB Group

CE Wiki   IRC (#CEF)   Twitter
Third party websites