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 


Read/write Textfile?

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

Joined: 07 Oct 2015
Posts: 4

PostPosted: Wed Oct 07, 2015 6:00 pm    Post subject: Read/write Textfile? Reply with quote

I want to share my values from a file (written rapidly by Ahk) to CE.

Solution I thought of:
I need CE to get a new value for an address from a file or clipboard. I haven't used Auto Assemble once, and what could solve the problem is this loop:

Read file with value inside
If the value is new
1. Make it a value for named address
2. And maybe.. create text file with the value(That's not possible is it..?)

There could be easier ways that I cant come up with, if so, please tell.
I'm using an AutoHotkey to generate the specific values, and I just want the CE to get them and put them.
Back to top
View user's profile Send private message
Zanzer
I post too much
Reputation: 126

Joined: 09 Jun 2013
Posts: 3278

PostPosted: Wed Oct 07, 2015 6:22 pm    Post subject: Reply with quote

Use standard Lua to read and write files
Once you have the value, writeInteger("address", value)
Back to top
View user's profile Send private message
lussu
How do I cheat?
Reputation: 0

Joined: 07 Oct 2015
Posts: 4

PostPosted: Thu Oct 08, 2015 1:33 pm    Post subject: Reply with quote

Thank you for your help Zanzer!
However, I still cant figure out how to things, everything is so complicated!

This makes sense:
writeInteger(Address, Value)

I would appreciate someone posting a script doing this over and over:

"read Val from a Filename1"
writeInteger(Address, Val)
"write Val to a Filename2"

I'm just hopeless
Back to top
View user's profile Send private message
panraven
Grandmaster Cheater
Reputation: 62

Joined: 01 Oct 2008
Posts: 958

PostPosted: Thu Oct 08, 2015 2:34 pm    Post subject: Reply with quote

lussu wrote:
Thank you for your help Zanzer!
However, I still cant figure out how to things, everything is so complicated!

This makes sense:
writeInteger(Address, Value)

I would appreciate someone posting a script doing this over and over:

"read Val from a Filename1"
writeInteger(Address, Val)
"write Val to a Filename2"

I'm just hopeless



Since you mentioned the 'values' related to some "named address", I guess they are memory address things that derived from a common target process your ahk and ce both working with at the same time?

If so, why not just let ahk and ce communicate through a common memory region in the target process?

For example, this allocate a memory region in the Target Process by ce, and write the memory region address to a text file;
Code:

local aa = autoAssemble([[globalalloc(_ahkshared,2000)]])
local addy = getAddress("_ahkshared") -- type number
local f = io.open("shareaddr.txt","w")
f:write(addy) -- write the addy as string,ie. # 1111 is write as string "1111", not bytes (57) (04) (1111 = 0x457)
f:close()


Your ahk then can read this file and obtain the address value.

Now ahk and ce both know a common memory region, you can now divide some sub-region say to_ce and from_ce region,

When ahk want to send a value to ce, write it to memory of to_ce region, and ce should periodically check this region, and act accordingly if new data is input.

Hope you got the idea, bye~

ADDED:
A quick google search found this memory allocation from ahk side (not tested):
Code:
VarSetCapacity(buffer, bufSize)
pAddress = &buffer

... write pAddress to a file to be read by ce ...


ADDED:
oops~ above won't work as the memory is in ahk itself not the target process.
The idea is flaw if no ahk way to read/write memory on to the target process.

sorry for distraction~

ADDED:
ahk's writeProcessMemory (it's modified to use window id instead of process id)
http://www.autohotkey.com/board/topic/25517-writeprocessmemory-function/

_________________
- Retarded.
Back to top
View user's profile Send private message
lussu
How do I cheat?
Reputation: 0

Joined: 07 Oct 2015
Posts: 4

PostPosted: Thu Oct 08, 2015 4:25 pm    Post subject: Reply with quote

Thank you, panraven, for all the work you did for me! I truly appreciate it!

Behind the scenes:
I have a Ahk script that has nothing to do with memory.

DONE: generates certain values from certain custom files for a certain address.
PROBLEM: change that addresses value to the generated one(seems too much for me even after hours of googling)
DONE: value has changed, the Ahk script will do certain things in the certain process, and then generate a new value and so on.

So that function you found would allow me to do everything in Ahk! If I'm not too stupid to make it happen, I would be more than happy!

I'll work for it tomorrow ~
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