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 


How can I use createthread on this? (Creating a window)

 
Post new topic   Reply to topic    Cheat Engine Forum Index -> Cheat Engine
View previous topic :: View next topic  
Author Message
Stacktrace
Expert Cheater
Reputation: 1

Joined: 04 Jul 2015
Posts: 105

PostPosted: Mon Nov 16, 2020 1:42 am    Post subject: How can I use createthread on this? (Creating a window) Reply with quote

I finally at least seem to have gotten the parameters right so there is no crash but not sure how to use all of this to make a functional window that remains

(This example code does nothing at all, but I tried some other parameters and noticed a large window flashing for one second and then no longer existing at all nor able to re create a thread that shows the flash for some reason / sometimes worked again other times not but in the end I just want it to stay)

If someone can fill in those parameters and from there I can learn it would be much appreciated

createthread(mywindow)
alloc(mywindow,1000)
registersymbol(mywindow)
mywindow:
push 00
push 00
push 00
push 00
push 00
push 00
push 00
push 00
push 00
push 00
push 00
push 00
call USER32.CreateWindowExW
ret
Back to top
View user's profile Send private message
OldCheatEngineUser
Whateven rank
Reputation: 20

Joined: 01 Feb 2016
Posts: 1587

PostPosted: Mon Nov 16, 2020 2:36 pm    Post subject: Reply with quote

the arguments passed here are invalid, the code is missing a lot of requirements in term of window creation setup.

- create window class structure and fill the requirements
- call RegisterClass / Ex A/W
- call CreateWindowEx A/W and save the returned window handle
- call ShowWindow and UpdateWindow
- create a message loop
- create window procedure (callback)

refer to msdn/docs for proper arguments and function calls.

_________________
About Me;
I Use CE Since Version 1.X, And Still Learning How To Use It Well!
Jul 26, 2020
STN wrote:
i am a sweetheart.
Back to top
View user's profile Send private message Visit poster's website
DaSpamer
Grandmaster Cheater Supreme
Reputation: 52

Joined: 13 Sep 2011
Posts: 1578

PostPosted: Fri Nov 20, 2020 11:09 am    Post subject: Reply with quote

Here's an 32bit example, adapted from Corroder response (Don't know who the author).
in my opinion it does not worth it.
Code:
globalalloc(createWindow,4096)

label(windowHwnd)
label(hInstance)
label(ClassName)
label(AppName)
label(hCursor)
registersymbol(hInstance)
registersymbol(windowHwnd)

label(_messageDialog)
label(_closeWindow)

registersymbol(_messageDialog)
registersymbol(_closeWindow)

label(destroyCallback)

label(_getModuleHandle)
label(_registerClassEx)
label(_loadCursor)
label(_createWindowEx)
label(_wndProc)

define(COLOR_WINDOW,6)
define(IDC_CURSOR, 0x7F00)

define(WM_DESTROY,2)

define(CS_HREDRAW,1)
define(CS_VREDRAW,2)
define(CS_HREDRAW_VREDRAW,CS_HREDRAW|CS_VREDRAW)
define(CW_USEDEFAULT,0x80000000)

define(WS_OVERLAPPED,0x0)
define(WS_CAPTION,0x00C00000)
define(WS_SYSMENU,0x00080000)
define(WS_THICKFRAME,0x00040000)
define(WS_MINIMIZEBOX,0x00020000)
define(WS_MAXIMIZEBOX,0x00010000)
define(WS_VISIBLE,0x10000000)

define(WS_OVERLAPPEDWINDOW_WS_VISIBLE,WS_OVERLAPPED|WS_CAPTION|WS_SYSMENU|WS_THICKFRAME|WS_MINIMIZEBOX|WS_MAXIMIZEBOX|WS_VISIBLE)


STRUCT POINT
   x: dd ?
   y: dd ?
ENDSTRUCT

STRUCT MSG
   hwnd:       dd ?
   msg:       dd ?
   wParam:    dd ?
   lParam:    dd ? // mouse position relative to window ?
   time:       dd ?
   pt:         dd ? // POINT; mouse cordinates
   lprivate:    dd ?
ENDSTRUCT

createWindow:
push ebp
   sub esp,20
   mov ebp,esp
   
      call _getModuleHandle
      call _loadCursor
      call _registerClassEx
      call _createWindowEx
      
      @_while:
         push 0
         push 0
         push 0
         push ebp   //MSG Struct
         call GetMessageA
         
         test eax,eax
               //je @createWindow_end //WM_EXIT
               jne @F
            call destroyCallback
            jmp @createWindow_end
         @@:
         cmp eax,-1
               jne @F
            
            mov eax,[ebp+MSG.wParam]
            push eax
            
            push 0
            push _Error
            push _Error
            push 0
            call MessageBoxA
            
            call ExitProcess
            jmp @createWindow_end
         @@:
         push ebp
         call TranslateMessage
         push ebp
         call DispatchMessageA
      jmp @_while
      
      @createWindow_end:
      
      mov eax,[ebp+MSG.wParam]
      
   add esp,20
pop ebp
ret


_createWindowEx:
push ebp
   sub esp,30
   mov ebp,esp
   
   xor eax,eax
   
   mov [ebp],eax
   mov [ebp+4],ClassName
   mov [ebp+8],AppName
   mov [ebp+c],WS_OVERLAPPEDWINDOW_WS_VISIBLE
   mov [ebp+10],CW_USEDEFAULT
   mov [ebp+14],CW_USEDEFAULT
   mov [ebp+18],CW_USEDEFAULT
   mov [ebp+1c],CW_USEDEFAULT
   mov [ebp+20],eax
   mov [ebp+24],eax
   mov [ebp+28],hInstance
   mov [ebp+2c],eax
   
   call CreateWindowExA
   
   mov [windowHwnd],eax
pop ebp
ret
_registerClassEx:
push ebp
   sub esp,30
   mov ebp,esp
   
   mov [ebp],30                   //cbSize - 48 bytes
   mov [ebp+4],CS_HREDRAW_VREDRAW       //style
   mov [ebp+8],_wndProc             //lpfn wndProc
   mov [ebp+C],0                  //cbClsExtra
   mov [ebp+10],0                  //cbWndExtra
   mov [ebp+14],hInstance            //hInstance - _getModuleHandle procedure
   mov [ebp+18],0                  //hIcon
   mov [ebp+1C],hCursor            //HCURSOR   - loadCursor procedure
   mov [ebp+20],COLOR_WINDOW         //hbrBackground
   mov [ebp+24],0                  //lpszMenuName
   mov [ebp+28],ClassName            //lpszClassName
   mov [ebp+2C],0                  //hIconSm
   
   mov eax,ebp
   push eax
   call RegisterClassExA

   add esp,30
pop ebp
ret

_loadCursor:
   push IDC_CURSOR
   push 0
   call LoadCursorA //ECX,EDX are being modified
   mov [hCursor],eax
ret

_getModuleHandle:
   push 0
   call GetModuleHandleA
   mov [hInstance],eax
ret

_wndProc:
push ebp
   mov ebp,esp
   
   mov eax,[ebp+C]
   cmp eax,WM_DESTROY
   jne @F
      push 0
      call PostQuitMessage
      
      xor eax,eax
   jmp @wndProc_end
   @@:
      push [ebp+14]
      push [ebp+10]
      push [ebp+C]
      push [ebp+8]
      call user32.DefWindowProcA
   
   @wndProc_end:
pop ebp
retn

_messageDialog:
push ebp
   mov ebp,esp
   push 0
   push [ebp+C]
   push [ebp+8]
   push 0
   call MessageBoxA
pop ebp
ret 8

_closeWindow:
   push [windowHwnd]
   call closeWindow
ret

destroyCallback:
push ebp
   sub esp,34
   mov ebp,esp
   mov [ebp],"Clos"   // title
   mov [ebp+4],"ed m"
   mov [ebp+8],"sg!"
   
   mov [ebp+C],"Wind"   // body
   mov [ebp+10],"ow c"
   mov [ebp+14],"lose"
   mov [ebp+18]," cal"
   mov [ebp+1C],"lbac"
   mov [ebp+20],"k be"
   mov [ebp+24],"en e"
   mov [ebp+28],"xecu"
   mov [ebp+2C],"ted!"
   xor eax,eax
   mov [ebp+30],eax
   
   lea eax,[ebp+C]
   push ebp
   push eax
   call _messageDialog
   
   add esp,34
pop ebp
ret

ClassName:
db 'WinClass',0
AppName:
db 'Example Form',0
_Error:
db 'Error',0


hInstance:
dd 0
hCursor:
dd 0
windowHwnd:
dd 0

_________________
HEY Hitler
Do you get lazy when making trainers?
Well no more!
My CETrainer will generate it for you in seconds, so you won't get lazy! Very Happy

http://forum.cheatengine.org/viewtopic.php?t=564919
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    Cheat Engine Forum Index -> Cheat Engine 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