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 


writing a memory address's value to file

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

Joined: 03 Sep 2014
Posts: 112

PostPosted: Mon Mar 09, 2020 8:20 am    Post subject: writing a memory address's value to file Reply with quote

theres a loop

x= 0
Y = read fileA.exe+X
encrypt Y and write it to [XXXXX]
now i want to inline the writing code so that i write those encrypted bytes to a file. i.e. write [XXXXX]'s values to file every time it is caculated
Back to top
View user's profile Send private message
daspamer
Grandmaster Cheater Supreme
Reputation: 54

Joined: 13 Sep 2011
Posts: 1588

PostPosted: Mon Mar 09, 2020 9:32 am    Post subject: Reply with quote

Code:
function writeFile(filePath,data)
   if (type(data)=='string') then
      local file = assert(io.open(filePath,'a'),'io.open failed!'); -- create files if does not exists and appends to it;
      file:write(data);
      file:close();
      return true
   end
   return false
end

function logXXXX()
   local log_file_path = 'C:\\Path\\To\\File.log';
   local value = readInteger('address_XXXX');
   local fmt = ('%s -\t\tvalue - %d',tostring(os.date(),value))
   return writeFile(log_file_path,fmt)
end


function recalculate()
   -- your calculation code...
   logXXXX();
   -- contiune and such
end

_________________
I'm rusty and getting older, help me re-learn lua.
Back to top
View user's profile Send private message Visit poster's website
reverser69
Expert Cheater
Reputation: 0

Joined: 03 Sep 2014
Posts: 112

PostPosted: Mon Mar 09, 2020 3:35 pm    Post subject: Reply with quote

hi & thx for reply
this is my code:
Code:
[ENABLE]

{$lua}

function writeFile(filePath,data)
   if (type(data)=='string') then
      local file = assert(io.open(filePath,'a'),'io.open failed!');
      file:write(data);
      file:close();
      return true
   end
   return false
end

function logXXXX()
   local log_file_path = 'C:\\Users\\shetal\\Desktop\\1.txt';
   local value = readInteger(ecx+0x3c);
   local fmt = ('%s -\t\tvalue - %d',tostring(os.date(),value))
   return writeFile(log_file_path,fmt)
end


{$asm}

"Operators.exe"+4C0D:
mov [ecx+3C],al
mov [ebp-04],00000009
luacall(logXXXX())

 
 
[DISABLE]

dealloc(newmem)
"Operators.exe"+4C0D:
mov [ecx+3C],al
mov [ebp-04],00000009
//Alt: db 88 41 3C C7 45 FC 09 00 00 00


but i receive error :
lua error in line 3 : string "local syntaxcheck...... ')' expected near ','

whats wrong?
Back to top
View user's profile Send private message
Corroder
Grandmaster Cheater Supreme
Reputation: 75

Joined: 10 Apr 2015
Posts: 1668

PostPosted: Mon Mar 09, 2020 10:47 pm    Post subject: Reply with quote

Look at your code, line 3, there is something typo there. At least you need to post your complete code before asking something you don't know.
_________________
Stealing Code From Stolen Code...
And Admit It.. Hmmm....Typically LOL
Back to top
View user's profile Send private message
reverser69
Expert Cheater
Reputation: 0

Joined: 03 Sep 2014
Posts: 112

PostPosted: Tue Mar 10, 2020 6:42 am    Post subject: Reply with quote

i don't know Lua so i cant recognize that typo. why don't you point it out?!
Back to top
View user's profile Send private message
Corroder
Grandmaster Cheater Supreme
Reputation: 75

Joined: 10 Apr 2015
Posts: 1668

PostPosted: Tue Mar 10, 2020 9:10 am    Post subject: Reply with quote

reverser69 wrote:
i don't know Lua so i cant recognize that typo. why don't you point it out?!


Because you are not posting your Lua script at least lines 1 to 10 or more.
The error you got shown that error on line 3 in your Lua script. So, what is the code written on line 3 ?.

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

Joined: 13 Sep 2011
Posts: 1588

PostPosted: Wed Mar 11, 2020 8:51 am    Post subject: Reply with quote

Yes sorry, had a typo
Code:
[ENABLE]

{$lua}

function writeFile(filePath,data)
   if (type(data)=='string') then
      local file = assert(io.open(filePath,'a'),'io.open failed!');
      file:write(data);
      file:close();
      return true
   end
   return false
end

function logXXXX()
   local log_file_path = 'C:\\Users\\shetal\\Desktop\\1.txt';
   local value = readInteger(ecx+0x3c);
   local fmt = ('%s -\t\tvalue - %d'):format(os.date(),tostring(value))
   return writeFile(log_file_path,fmt)
end


{$asm}

"Operators.exe"+4C0D:
mov [ecx+3C],al
mov [ebp-04],00000009
luacall(logXXXX())

 
 
[DISABLE]

dealloc(newmem)
"Operators.exe"+4C0D:
mov [ecx+3C],al
mov [ebp-04],00000009
//Alt: db 88 41 3C C7 45 FC 09 00 00 00

_________________
I'm rusty and getting older, help me re-learn lua.
Back to top
View user's profile Send private message Visit poster's website
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