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 


customer function setwindowontop,crash

 
Post new topic   Reply to topic    Cheat Engine Forum Index -> Cheat Engine Lua Scripting
View previous topic :: View next topic  
Author Message
movss
Cheater
Reputation: 0

Joined: 10 Feb 2018
Posts: 38

PostPosted: Fri Apr 06, 2018 11:01 am    Post subject: customer function setwindowontop,crash Reply with quote

SetWindowPos (hwnd, -1, 0, 0, 0, 0, 3)

Code:

function SetWindowTop(form)
  if cheatEngineIs64Bit() then
    handle = readQwordLocal(userDataToInteger(form)+0x538)
    script = [[
    alloc(thread,128)
    createthread(thread)
    thread:
    lea rsp,[rsp-40]
   mov rcx,handle
    mov edx,-1 
    mov r8d,0
    mov r9d,0
   push 0
   push 0
   push 3
    call user32.SetWindowPos
    lea rsp,[rsp+40]
    ret
    ]]
    script=script:gsub('handle', string.format('%X',handle))
    autoAssemble(script,true)
  else
    handle = bAnd( readQwordLocal(userDataToInteger(form)+0x330) , 0xFFFFFFFF)
    script = [[
    alloc(thread,128)
    createthread(thread)
    thread:
    push 3
    push 0
    push 0
   push 0
   push 0
   push -1
    push handle
    call user32.SetWindowPos
    ret
    ]]
    script=script:gsub('handle', string.format('%X',handle))
    autoAssemble(script,true)
  end
end

when i run this function ,it crash, WTF
help,me
Crying or Very sad

_________________
A wild programmer
Back to top
View user's profile Send private message
TheyCallMeTim13
Wiki Contributor
Reputation: 50

Joined: 24 Feb 2017
Posts: 976
Location: Pluto

PostPosted: Fri Apr 06, 2018 11:19 am    Post subject: Reply with quote

If your passing a form object to the function any way, then why not just us "form.bringToFront()". That and the WinControl class has a "Handle" property, and the control class has a "setPosition" function.

EDIT:
But I think the crash is because the thread is created with not instructions:
Code:

    alloc(thread,128)
    createthread(thread) //// you create a thread with no instructions, just nulls.
    thread: //// Then you add the instructions, after the thread has already been ran.
    // ...
    ret


Code:

    alloc(thread,128)
    thread: //// Add the instructions first.
    // ...
    ret
createthread(thread) //// Then create a thread.


But I'm not actually real sure how CE would handle this, it may correct this for you; but I don't think you should count on that even if it is.

_________________
Back to top
View user's profile Send private message Visit poster's website
Display posts from previous:   
Post new topic   Reply to topic    Cheat Engine Forum Index -> Cheat Engine Lua Scripting 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