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 


Kill Proc

 
Post new topic   Reply to topic    Cheat Engine Forum Index -> Cheat Engine Lua Scripting
View previous topic :: View next topic  
Author Message
misha-cs
Newbie cheater
Reputation: 0

Joined: 02 Jul 2012
Posts: 12

PostPosted: Tue Mar 04, 2014 10:48 am    Post subject: Kill Proc Reply with quote

Hi!
How can I destroy a particular process, such as "Notepad"?
Reviewed all the features, but have not found an answer.
Back to top
View user's profile Send private message
Gniarf
Grandmaster Cheater Supreme
Reputation: 43

Joined: 12 Mar 2012
Posts: 1285

PostPosted: Thu Mar 06, 2014 1:30 am    Post subject: Reply with quote

In lua, a simple way would be:
Code:
os.execute("taskkill /im notepad.exe /f")

_________________
DO NOT PM me if you want help on making/fixing/using a hack.
Back to top
View user's profile Send private message
misha-cs
Newbie cheater
Reputation: 0

Joined: 02 Jul 2012
Posts: 12

PostPosted: Thu Mar 06, 2014 12:30 pm    Post subject: Reply with quote

Thanks.
And one question:
How I can find HANDLE of window programm not a CE ?
Back to top
View user's profile Send private message
Dark Byte
Site Admin
Reputation: 458

Joined: 09 May 2003
Posts: 25287
Location: The netherlands

PostPosted: Thu Mar 06, 2014 12:54 pm    Post subject: Reply with quote

execute this auto assemble script (e.g using autoAssemble() )
Code:

alloc(term,512)

term:
push 0
call ExitProcess

createthread(term)

_________________
Do not ask me about online cheats. I don't know any and wont help finding them.

Like my help? Join me on Patreon so i can keep helping
Back to top
View user's profile Send private message MSN Messenger
misha-cs
Newbie cheater
Reputation: 0

Joined: 02 Jul 2012
Posts: 12

PostPosted: Thu Mar 06, 2014 2:47 pm    Post subject: Reply with quote

How with HANDLE window ?
Thanks
Back to top
View user's profile Send private message
Gniarf
Grandmaster Cheater Supreme
Reputation: 43

Joined: 12 Mar 2012
Posts: 1285

PostPosted: Thu Mar 06, 2014 3:14 pm    Post subject: Reply with quote

misha-cs wrote:
How I can find HANDLE of window programm not a CE ?
If you meant "How to get the handle of a window that doesn't belong to CE", here's one way:
Code:
function CallFindWindowA(WindowName)
  --keep window names below 256 characters.
  --lpClassName is set to NULL
  local FindWindowAStub;

  --Looks like the [64-bit] and [32-bit] directives don't work in FindWindowAStub.
  if (cheatEngineIs64Bit()) then
    FindWindowAStub=[[
      globalalloc(FindWindowMemory,1024) //global alloc instead of alloc: see CleanupFindWindowAStub

      label(WindowName_)
      label(FindWindowAResult)
      label(FindWindowADone)
      registersymbol(WindowName_)
      registersymbol(FindWindowAResult)
      registersymbol(FindWindowADone)

      FindWindowMemory:
        mov rdx, WindowName_
        xor rcx,rcx  //LpClassName=NULL
        call FindWindowA
        mov qword [FindWindowAResult],rax
        mov dword [FindWindowADone],1
      retn
    FindWindowAResult:
    dq 0
    FindWindowADone:
    dd 0

    WindowName_:
    dq 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 //256 bytes
    ]];
  else
    FindWindowAStub=[[
      globalalloc(FindWindowMemory,1024) //global alloc instead of alloc: see CleanupFindWindowAStub

      label(WindowName_)
      label(FindWindowAResult)
      label(FindWindowADone)
      registersymbol(WindowName_)
      registersymbol(FindWindowAResult)
      registersymbol(FindWindowADone)

      FindWindowMemory:
        push, WindowName_
        push 0 //LpClassName=NULL
        call FindWindowA
        mov dword [FindWindowAResult],eax
        mov dword [FindWindowADone],1
      retn
    FindWindowAResult:
    dd 0
    FindWindowADone:
    dd 0

    WindowName_:
    dq 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 //256 bytes
    ]];
  end

  local RunFindWindowAStub = "createthread(FindWindowMemory)";
  local CleanupFindWindowAStub = [[
    dealloc(FindWindowMemory) //taskman inspection shows that dealloc (with a simple alloc) doens't seem to work on CE itself
    //unregistersymbol(FindWindowMemory)
    unregistersymbol(WindowName_)
    unregistersymbol(FindWindowAResult)
    unregistersymbol(FindWindowADone)]];

  --initialize the FindWindowA caller
  autoAssemble(FindWindowAStub,true);
  --give the parameter
  writeStringLocal("WindowName_",WindowName);
  --run the function
  autoAssemble(RunFindWindowAStub,true);
  --wait till done
  while(readIntegerLocal("FindWindowADone")==0) do
    sleep(10);
  end
  --fetch result
  local WindowHandle;
  if (cheatEngineIs64Bit()) then
    WindowHandle=readQwordLocal("FindWindowAResult");
  else
    WindowHandle=readIntegerLocal("FindWindowAResult");
  end
  --cleanup
  autoAssemble(CleanupFindWindowAStub,true);

  return WindowHandle;
end

print(string.format("%x",CallFindWindowA("Untitled - Notepad")));
Mind you, I really wonder what you want to do with that though.
_________________
DO NOT PM me if you want help on making/fixing/using a hack.
Back to top
View user's profile Send private message
bknight2602
Grandmaster Cheater
Reputation: 0

Joined: 08 Oct 2012
Posts: 577

PostPosted: Sun Mar 30, 2014 12:44 pm    Post subject: Reply with quote

On a similar vein, what would be the code to close CE if/when the process it is pointing toward is closed?
Back to top
View user's profile Send private message Yahoo Messenger
Keule
Cheater
Reputation: 0

Joined: 08 Aug 2012
Posts: 25

PostPosted: Mon Mar 31, 2014 5:40 am    Post subject: Reply with quote

bknight2602 wrote:
On a similar vein, what would be the code to close CE if/when the process it is pointing toward is closed?


use this:
Code:

GameExeFile = 'game.exe'
-- rename it with youe .exe file or something else

t = createTimer(nil, true)
t.Interval = 100
t.onTimer = _CheckGameStatus
function _CheckGameStatus() if readInteger(GameExeFile) == nil then closeCE() end end


-- edited t.Interval to 100


Last edited by Keule on Mon Mar 31, 2014 11:19 am; edited 1 time in total
Back to top
View user's profile Send private message
mgr.inz.Player
I post too much
Reputation: 218

Joined: 07 Nov 2008
Posts: 4438
Location: W kraju nad Wisla. UTC+01:00

PostPosted: Mon Mar 31, 2014 8:01 am    Post subject: Reply with quote

Agree. I also recommend bigger Interval, for example 100 or 500.
_________________
Back to top
View user's profile Send private message MSN Messenger
bknight2602
Grandmaster Cheater
Reputation: 0

Joined: 08 Oct 2012
Posts: 577

PostPosted: Mon Mar 31, 2014 4:24 pm    Post subject: Reply with quote

Thanks to both
Back to top
View user's profile Send private message Yahoo Messenger
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