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 


Multiple Processnames and individual AAScripts

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

Joined: 15 Jun 2017
Posts: 22

PostPosted: Sat Jan 20, 2018 4:08 pm    Post subject: Multiple Processnames and individual AAScripts Reply with quote

Hey there,

im stuck at my actual project :/
I want to use my own trainer at a Game, which i run more than once at the same time.
So i decided to rename the Game.exe to like:
Game_1.exe
Game_2.exe
...
But when i want to use my AAScripts they wont work because of:
Code:
[enable]
"Game_1.exe"+27728:
db EB 08
[disable]
"Game_1.exe"+27728:
db 76 08


So i created something like that:
Code:
PID = getOpenedProcessID()
name=getProcessList()[PID]

local MyProcessName=name
--Game_1.exe
--Game_2.exe

function CECheckbox1Click(sender)
  addresslist=getAddressList()
  if sender.state == 1 then
    CheatEntry=addresslist_getMemoryRecordByDescription(addresslist,[[Function1]])
    memoryrecord_freeze(CheatEntry)
  elseif sender.state == 0 then
    CheatEntry=addresslist_getMemoryRecordByDescription(addresslist,[[Function1]])
    memoryrecord_unfreeze(CheatEntry)
  end
end


So my Question is. How can i create the AA directly at my "Cheat Table Lua Script". Or how could i call these "local MyProcessName=name " in all of my CheatEntry's ?
Is this possible or am i crazy ?

Edit: And once more. Is it possible to define pointers via Lua Script ?

Please help me Sad
Back to top
View user's profile Send private message
TheyCallMeTim13
Wiki Contributor
Reputation: 50

Joined: 24 Feb 2017
Posts: 976
Location: Pluto

PostPosted: Sat Jan 20, 2018 4:35 pm    Post subject: Reply with quote

Have you tried using AOB scans instead of addresses.

But in Lua:
You can use Lua in AA scripts, and if it returns a string then Cheat Engine will put that in the AA script.

Code:

{$lua}
[enable]
return '"' .. PROCESS_NAME .. '"+27728:\r\ndb EB 08'
[disable]
return '"' .. PROCESS_NAME .. '"+27728:\r\ndb 76 08'


Code:
registerSymbol('ptrMrPointer', 0x123ABC00)
registerSymbol('ptrMrPointer2', getAddress('Game.exe+123ABC'))

_________________
Back to top
View user's profile Send private message Visit poster's website
Dark Byte
Site Admin
Reputation: 457

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

PostPosted: Sat Jan 20, 2018 4:38 pm    Post subject: Reply with quote

you can use the lua variable "process" for this, and use AA's lua var access method ($) to access it

e.g:
Code:

aobscanmodule(aobresult,$process,10 20 30)


or in your case
Code:

$process+27728:
db EB 08



(alternatively you could do:
Code:

[enable]
{$lua}
return getProcessList()[PID] ..'+27728:'
{$asm}
db EB 08

[disable]
{$lua}
return getProcessList()[PID] ..'+27728:'
{$asm}
db 76 08

)

as for pointers:
Code:

local mr=AddressList.createMemoryRecord()

mr.Address='tutorial-i386.exe+1234';
mr.OffsetCount=2
mr.Offset[0]=0x10
mr.Offset[1]=0x20
mr.Description="My pointer"

_________________
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


Last edited by Dark Byte on Sat Jan 20, 2018 4:44 pm; edited 1 time in total
Back to top
View user's profile Send private message MSN Messenger
FreeER
Grandmaster Cheater Supreme
Reputation: 53

Joined: 09 Aug 2013
Posts: 1091

PostPosted: Sat Jan 20, 2018 4:40 pm    Post subject: Reply with quote

You can use lua variables in AA scripts by prefixing the name with $ and CE has a lua variable named process that is set to the exe's name (with .exe)

for example Step 2 of the x86 tutorial can be done like this:
Code:
//based on "full injection" template
//define(address,$process+23B80) // not using define just to show that you don't need it
// define does also work however
define(bytes,89 83 80 04 00 00)
[ENABLE]
assert($process+23B80,bytes)
alloc(newmem,$1000)

label(return)

newmem:
  mov eax, #1000
  mov [ebx+00000480], eax
  jmp return

$process+23B80:
  jmp newmem
  nop
return:

[DISABLE]
$process+23B80:
  db bytes
  // mov [ebx+00000480],eax
dealloc(newmem)


you can even use it in aobscanmodule(INJECT,$process,89 83 80 04 00 00 8D 55 D4 E8 12).

I haven't played with this too much so there's probably some caveats to it (like only getting the value on enable making it impractical for a pointer, or something) but it seems perfect for this.

to answer the original question, you'd use
Code:

-- create the sript
local mr = AddressList.createMemoryRecord()
mr.Description = 'some description' -- defaults to "Plugin Address" if not set
mr.type = vtAutoAssembler
mr.Script = [=[
/*your script here, it's just a string so
you can use any concatenation methods you like
to build up the string out of variables or whatever,
the double square brackets [[like this]]
are multiline strings in lua and as you
can see here you can actually put characters
inbetween the brackets so that you can use
double brackets inside of the multiline string
*/
]=]
mr.Active = true -- enable it


as for pointers... 3 ways, the easy ways:

Code:
local pointerAddress = '[Tutorial-i386.exe+1FD5D0]+480'
local step2Value = readInteger(pointerAddress)


yeah, lua will just parse the string properly.

Code:
local mr = AddressList.getMemoryRecordByDescription('record with pointer set')
--local address = mr.Address
local step2Value = toNumber(mr.value, mr.ShowAsHex and 16 or 10)


yep, you can get the value from the memory record, though it'll be a string value, you can write to it through the memory record as well.

the hard way:

Code:

local step8Address = getAddress('[[[["Tutorial-i386.exe"+1FD660]+C]+14]+0]+18')
local offsets = {0xC, 0x14, 0x0, 0x18}
local base = '"Tutorial-i386.exe"+1FD660'
local address = base
for i,offset in ipairs(offsets) do
  address = readPointer(address)+offset
end
local step8Value = readInteger(address)
print(('%x == %x: %s'):format(step8Address, address, step8Address == address))


once you have the address you can pass it to registerSymbol to use it in an AA script
Back to top
View user's profile Send private message
scarface010305
Newbie cheater
Reputation: 0

Joined: 15 Jun 2017
Posts: 22

PostPosted: Sun Jan 21, 2018 3:32 am    Post subject: Reply with quote

Very nice.
Thank you to all of you Smile
Very fast and helpful Very Happy Very Happy
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