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 do i get the PID Process And thread id?

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

Joined: 29 May 2019
Posts: 36

PostPosted: Wed May 29, 2019 7:54 am    Post subject: How do i get the PID Process And thread id? Reply with quote

How do i get the
PID Process And thread id of my game "Game.exe"



please help me :/
Back to top
View user's profile Send private message
Corroder
Grandmaster Cheater Supreme
Reputation: 75

Joined: 10 Apr 2015
Posts: 1668

PostPosted: Wed May 29, 2019 8:26 pm    Post subject: Reply with quote

Code:
nowPID = getOpenedProcessID() -- a process already attached
print(nowPID)  -- 3504 on my case


Code:
whatID = getProcessIDFromProcessName('cheatengine-x86_64.exe')
print(whatID)  -- 3504

Code:
-- to attach a process
openProcess("cheatengine-x86_64.exe")
openProcess(3504)
openProcess(tonumber("3504"))


Code:
-- Make list for all PID and process name
TempTable = {}
function GetTheProcessList()
   local SL=createStringlist()
   getProcesslist(SL)
   for i=0,strings_getCount(SL)-1 do
     local entry = strings_getString(SL,i)
     local processname = entry:sub(10,255)
     local PID = tonumber('0x'..entry:sub(1,8))
     TempTable[i] = {PID, processname}
  end
  return TempTable
end

function AddTheProcessList()
   GetTheProcessList()
   index = 0
   for y in pairs (TempTable) do
      index = index+1
   end
   for i=0, index-1 do
      if TempTable[i]~='' and TempTable[i]~= nil then
         local TempText = TempTable[i][1].." - "..TempTable[i][2]
         print(TempText)
      end
   end
end

-- print out all process
AddTheProcessList()


Code:
-- or do with one line
getMainForm().sbOpenProcess.doClick()


Code:
-- get PID and process name from attached process
function getProcessNameFromID(processId)
 local processName = nil
 local list = createStringlist()
 getProcesslist(list)
  for i = 0, list.Count-1 do
    local id, name = list.String[i]:match("(.*)-(.*)")
    if processId == tonumber(id, 16) then
      processName = name
      break
    end
  end
  return processName
end

local id = getOpenedProcessID()
local name = getProcessNameFromID(id)
print(id..'-'..name)

_________________
Stealing Code From Stolen Code...
And Admit It.. Hmmm....Typically LOL
Back to top
View user's profile Send private message
gavrielsinvani
Cheater
Reputation: 0

Joined: 29 May 2019
Posts: 36

PostPosted: Fri May 31, 2019 6:20 am    Post subject: Reply with quote

Corroder wrote:
Code:
nowPID = getOpenedProcessID() -- a process already attached
print(nowPID)  -- 3504 on my case


Code:
whatID = getProcessIDFromProcessName('cheatengine-x86_64.exe')
print(whatID)  -- 3504

Code:
-- to attach a process
openProcess("cheatengine-x86_64.exe")
openProcess(3504)
openProcess(tonumber("3504"))


Code:
-- Make list for all PID and process name
TempTable = {}
function GetTheProcessList()
   local SL=createStringlist()
   getProcesslist(SL)
   for i=0,strings_getCount(SL)-1 do
     local entry = strings_getString(SL,i)
     local processname = entry:sub(10,255)
     local PID = tonumber('0x'..entry:sub(1,8))
     TempTable[i] = {PID, processname}
  end
  return TempTable
end

function AddTheProcessList()
   GetTheProcessList()
   index = 0
   for y in pairs (TempTable) do
      index = index+1
   end
   for i=0, index-1 do
      if TempTable[i]~='' and TempTable[i]~= nil then
         local TempText = TempTable[i][1].." - "..TempTable[i][2]
         print(TempText)
      end
   end
end

-- print out all process
AddTheProcessList()


Code:
-- or do with one line
getMainForm().sbOpenProcess.doClick()


Code:
-- get PID and process name from attached process
function getProcessNameFromID(processId)
 local processName = nil
 local list = createStringlist()
 getProcesslist(list)
  for i = 0, list.Count-1 do
    local id, name = list.String[i]:match("(.*)-(.*)")
    if processId == tonumber(id, 16) then
      processName = name
      break
    end
  end
  return processName
end

local id = getOpenedProcessID()
local name = getProcessNameFromID(id)
print(id..'-'..name)



thanks,

now i have it's code hack,

Code:

define(_GodmodeDelay, #%arg1) //Godmode on delay time. Change it to your precious time

[ENABLE]
label(Original)
label(Return)
alloc(Hook,100)
alloc(GodmodeTimer,4)
label(GodmodeOn)
GodmodeTimer:
dd 0

Hook:
inc [GodmodeTimer]
cmp [GodmodeTimer],_GodmodeDelay
je Original
db C2 30 00

GodmodeOn:
db C2 30 00 6A FF

Original:
db 55 8B EC 6A FF
mov [GodmodeTimer],0
jmp Return

02648640: //CUserLocal::SetDamaged
jmp Hook

Return:

[DISABLE]
02648640: //E8 ? ? ? ? 8D ? ? E8 ? ? ? ? 8B ? ? 64 ? ? ? ? ? ? 59 5E 8B ? 5D C2 1C 00 [follow call]
db 55 8B EC 6A FF

dealloc(Hook)
dealloc(GodmodeTimer)

Code:

you see it's line ?
define(_GodmodeDelay, #%arg1) //Godmode on delay time. Change it to


I want to create a textbox (in LUA CE) to edit this value, how do I do it?

u can help me please ?
Back to top
View user's profile Send private message
Corroder
Grandmaster Cheater Supreme
Reputation: 75

Joined: 10 Apr 2015
Posts: 1668

PostPosted: Fri May 31, 2019 9:40 am    Post subject: Reply with quote

Code:
-- Open game process first
local al = AddressList or getAddressList()
local mr1 = al.getMemoryRecordByDescription("God Timer")
local mr1Val = mr1.Value

form = createForm()
textBox = createEdit(form)
textBox.setSize(200,28)
textBox.Text = mr1Val
button = createButton(form)
button.setPosition(0,50)
button.Caption = 'Apply'

function changeValRec()
 mr1Val = textBox.Text
 if mr1Val == nil then
  return nil
 else
  mr1.Value = mr1Val ---use to number if integer
  -- or use writeBytes, writeInterger, depending address value type
 end
end
--textBox.onChange = changeValRec
button.onClick = changeValRec


And be patient, please. Peoples must read your post, so no need post same topic everywhere.
Do not spam the forum

_________________
Stealing Code From Stolen Code...
And Admit It.. Hmmm....Typically LOL
Back to top
View user's profile Send private message
gavrielsinvani
Cheater
Reputation: 0

Joined: 29 May 2019
Posts: 36

PostPosted: Fri May 31, 2019 11:12 am    Post subject: Reply with quote

Corroder wrote:
Code:
-- Open game process first
local al = AddressList or getAddressList()
local mr1 = al.getMemoryRecordByDescription("God Timer")
local mr1Val = mr1.Value

form = createForm()
textBox = createEdit(form)
textBox.setSize(200,28)
textBox.Text = mr1Val
button = createButton(form)
button.setPosition(0,50)
button.Caption = 'Apply'

function changeValRec()
 mr1Val = textBox.Text
 if mr1Val == nil then
  return nil
 else
  mr1.Value = mr1Val ---use to number if integer
  -- or use writeBytes, writeInterger, depending address value type
 end
end
--textBox.onChange = changeValRec
button.onClick = changeValRec


And be patient, please. Peoples must read your post, so no need post same topic everywhere.
Do not spam the forum

Can you link this to the above script?
It can only have a value of numbers

I just do not know how to link this to my script, please help me
Back to top
View user's profile Send private message
Corroder
Grandmaster Cheater Supreme
Reputation: 75

Joined: 10 Apr 2015
Posts: 1668

PostPosted: Fri May 31, 2019 1:11 pm    Post subject: Reply with quote

Maybe something like this, I am not too familiar with AA and I do not play GMS.

Code:
-- Open game process first
form = createForm()
textBox = createEdit(form)
textBox.setSize(200,28)
textBox.Text = mr1Val
button = createToggleBox(form)
button.setPosition(0,50)
button.setSize(140,30)
button.Caption = 'Enable GM Timed'

local mps2 = [[
label(Original)
label(Return)
alloc(Hook,100)
alloc(GodmodeTimer,4)
label(GodmodeOn)
GodmodeTimer:
dd 0

Hook:
inc [GodmodeTimer]
cmp [GodmodeTimer],_GodmodeDelay
je Original
db C2 30 00

GodmodeOn:
db C2 30 00 6A FF

Original:
db 55 8B EC 6A FF
mov [GodmodeTimer],0
jmp Return

02648640:
jmp Hook

Return:
]]


function scriptEnabled()
 local val = textBox.Text
 if tonumber(val) == nil then return nil end
 mps1 = 'define(_GodmodeDelay, #'..val..')'
 local mps = mps1..'\n'..mps2
 if syntaxcheck then return end
 autoAssemble(mps)
end

function scriptDisabled()
 writeBytes(02648640, 0x55, 0x8B, 0xEC, 0x6A, 0xFF)
 dealloc(Hook)
 dealloc(GodmodeTimer)
end

function godTimed()
 if (checkbox_getState(button) == 1) then
  scriptEnabled()
  button.Caption = 'Disable GM Timed'
 else
  scriptDisabled()
  button.Caption = 'Enable GM Timed'
 end
end

button.onClick = godTimed

_________________
Stealing Code From Stolen Code...
And Admit It.. Hmmm....Typically LOL
Back to top
View user's profile Send private message
gavrielsinvani
Cheater
Reputation: 0

Joined: 29 May 2019
Posts: 36

PostPosted: Sat Jun 01, 2019 9:03 am    Post subject: Reply with quote

Corroder wrote:
Maybe something like this, I am not too familiar with AA and I do not play GMS.

Code:
-- Open game process first
form = createForm()
textBox = createEdit(form)
textBox.setSize(200,28)
textBox.Text = mr1Val
button = createToggleBox(form)
button.setPosition(0,50)
button.setSize(140,30)
button.Caption = 'Enable GM Timed'

local mps2 = [[
label(Original)
label(Return)
alloc(Hook,100)
alloc(GodmodeTimer,4)
label(GodmodeOn)
GodmodeTimer:
dd 0

Hook:
inc [GodmodeTimer]
cmp [GodmodeTimer],_GodmodeDelay
je Original
db C2 30 00

GodmodeOn:
db C2 30 00 6A FF

Original:
db 55 8B EC 6A FF
mov [GodmodeTimer],0
jmp Return

02648640:
jmp Hook

Return:
]]


function scriptEnabled()
 local val = textBox.Text
 if tonumber(val) == nil then return nil end
 mps1 = 'define(_GodmodeDelay, #'..val..')'
 local mps = mps1..'\n'..mps2
 if syntaxcheck then return end
 autoAssemble(mps)
end

function scriptDisabled()
 writeBytes(02648640, 0x55, 0x8B, 0xEC, 0x6A, 0xFF)
 dealloc(Hook)
 dealloc(GodmodeTimer)
end

function godTimed()
 if (checkbox_getState(button) == 1) then
  scriptEnabled()
  button.Caption = 'Disable GM Timed'
 else
  scriptDisabled()
  button.Caption = 'Enable GM Timed'
 end
end

button.onClick = godTimed


I want to block the possibility of opening the program more than one window
and its not working, pls help me
Code:
 
 local GKTrainerON

if GKTrainerON == 1 then
    if messageDialog("GKTrainer Already Not Running!", mtError, mbOK) then end
end
GKTrainerON = 1


and umm how i hide process , i want hide game .


please help me thank you very much
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 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