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 


Advice on Automation

 
Post new topic   Reply to topic    Cheat Engine Forum Index -> General Discussions
View previous topic :: View next topic  
Author Message
artymate
How do I cheat?
Reputation: 0

Joined: 02 Apr 2020
Posts: 2

PostPosted: Thu Apr 02, 2020 1:08 am    Post subject: Advice on Automation Reply with quote

Hi,

My first post here and new user of CE. I've spent some hours with moderate success on CE over the past few days, but seem to have found a few hiccups on my path.

Let me explain what my goal is and how I planned to use CE in accomplishing that goal, what I've done since starting with CE and the limitations I am now assuming.

I have written a bot for a flash based game using image scanning which was more to learn about that technology than anything else. The bot has since evolved quite nicely but is having real performance and reliability issues now requiring constant babysitting. Fetching trivial information like hp and food levels is a massive chore.

I want to use CE (or similar mechanic, ie. memory address reading) to fetch information from memory so I can reduce image scanning and improve reliability.

So what seems to be a known limitation due to flash/java is that I can not find any green pointers for the values that I need, even in read-only mode, which is obviously not sustainable for me, as I require my bot to query CE or similar engine for specific data readable from memory, without having to figure out each time what memory address its at. I would have thought finding the starting address for the flash dll + additional address from pointer scanning might work, but that does not.

Given that I am new in this arena, is what I mention above worth pursuing and reasonably possible. I've looked threads relating to flash games, and have found little light at the end of that tunnel.

Any feedback or advice on the above would be greatly appreciated.
Back to top
View user's profile Send private message
ParkourPenguin
I post too much
Reputation: 152

Joined: 06 Jul 2014
Posts: 4696

PostPosted: Thu Apr 02, 2020 9:49 am    Post subject: Reply with quote

Search for "injection copy" or "injection copies" for tutorials on an alternative method to get the address of the value you want.
_________________
I don't know where I'm going, but I'll figure it out when I get there.
Back to top
View user's profile Send private message
artymate
How do I cheat?
Reputation: 0

Joined: 02 Apr 2020
Posts: 2

PostPosted: Fri Apr 03, 2020 1:30 am    Post subject: Reply with quote

Thanks for the response. I did make some progress on this and found a working solution with AoB scanning as well as started familiarizing myself with the LUA Engine.

Given that my bot runs in it's own application, I am looking for a way for CE to make available the values it finds.

Something like this.

Start Game - get pid and attach to CE
Load and Activate cheat table and AoB Scan scripts
-- At this point I have the addresses and values needed by my bot
However, as my bot runs, these values are changing, and my bot needs to know what the values are at any given time

Using the LUA engine to write these values to a file every second is not viable.

It would be great to just have something that updates a file or database on change for each address, but I'm not sure if that is out of the scope of what CE offers.

Some questions I'm looking into which could lead to the desired result:
Would that be a plugin I'd need to write?
Make use of a 3rd byte scanner library?
Can I call CE from my bot to execute a LUA script to update a database?
Can I use an external LUA script with CE libraries to get address values from my AoB scan and related addresses.
Back to top
View user's profile Send private message
ParkourPenguin
I post too much
Reputation: 152

Joined: 06 Jul 2014
Posts: 4696

PostPosted: Fri Apr 03, 2020 11:34 am    Post subject: Reply with quote

This might be easier:
https://docs.microsoft.com/en-us/windows/win32/memory/creating-named-shared-memory

CE's implementation is in Cheat Engine/sharedMemory.pas. The Lua API can access "allocateSharedMemory(name: string; size: integer): THandle" (pascal function) as "allocateSharedMemoryLocal(name, size)" (Lua function).

DB recently posted an example of what this looks like between two CE processes here.

Have CE give the address of the values to watch and call ReadProcessMemory yourself. e.g.:
Code:
{$lua}
if syntaxcheck then return end

-- only holds a pointer; 64 is plenty, but 1 page will be allocated regardless
h_shared_mem = h_shared_mem or allocateSharedMemoryLocal('MySpecialValuesPtr',64)

if memrec then
  memrec.OnActivate = memrec.OnActivate or function(memoryrecord,before,currentstate)
    if not before then
      writeQwordLocal(h_shared_mem, getAddressSafe('mydata') or 0)
    end
    return true
  end
  memrec.OnDeactivate = memrec.OnDeactivate or function(memoryrecord,before,currentstate)
    if before then
      writeQwordLocal(h_shared_mem, 0)
    end
    return true
  end
end
{$asm}

[ENABLE]
alloc(mycode,1024)
alloc(mydata,1024)
label(ImportantAddress1)
...
registersymbol(mydata)
registersymbol(ImportantAddress1)
...
mycode:
  mov [ImportantAddress1],rax
  ...
mydata:
ImportantAddress1:
  dq 0
...
(you can also put the Lua code in the main Lua script window and get the memory record via AddressList.getMemoryRecordByDescription; do this if assigning memrec.OnActivate in the script itself doesn't work)
  1. CE makes shared memory via allocateSharedMemoryLocal
  2. CE allocates memory "mydata" in the target process for it to copy important data into
  3. CE exposes the address of "mydata" in shared memory
  4. Target process writes important data into "mydata" via a code injection
  5. You copy the address of "mydata" from shared memory
  6. You call ReadProcessMemory on the target process to read the important values from "mydata"
You should also take into account the possibility that ReadProcessMemory fails if the script is deactivated and memory is deallocated... or just use globalalloc and account for RIP-relative addressing if it's a 64-bit target.

_________________
I don't know where I'm going, but I'll figure it out when I get there.
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    Cheat Engine Forum Index -> General Discussions 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