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 


can I save register's values into a text file?
Goto page 1, 2  Next
 
Post new topic   Reply to topic    Cheat Engine Forum Index -> General programming
View previous topic :: View next topic  
Author Message
agoox
How do I cheat?
Reputation: 0

Joined: 04 May 2009
Posts: 7

PostPosted: Sat Jun 06, 2009 1:14 am    Post subject: can I save register's values into a text file? Reply with quote

Hi, can you tell me if is possible to save into a text file the values of a register. I can read the value manually the value but in my game this register is changing every second I for my statistics i should save the values into a text file. And if I can save those values in real time will be very good.
Thanks a lot for your time.
King regards, John.
Back to top
View user's profile Send private message
Jani
Grandmaster Cheater
Reputation: 2

Joined: 29 Dec 2006
Posts: 804

PostPosted: Sat Jun 06, 2009 3:48 am    Post subject: Reply with quote

This function is NOT thread safe:
Code:
void HookFunction()
{
  static FILE *f = NULL;
  static close = 0;
  unsigned int value = 0;

  if( !f ) {
    f = fopen("myfile.txt", 'w');
    if( !f )
      return;
  }

  __asm mov value, eax; // I can't recall if it's [value] or value, because this is inline asm.
 
  fprintf(f, %d\n, value);

  if( close )
    if( !fclose(f) )
      f = NULL;
}
Iono if it works, let's say it's pseudo code for yourself to implement :D
Back to top
View user's profile Send private message
dnsi0
I post too much
Reputation: 0

Joined: 04 Jan 2007
Posts: 2674

PostPosted: Sat Jun 06, 2009 8:07 am    Post subject: Reply with quote

TempNick wrote:
This function is NOT thread safe:
Code:
void HookFunction()
{
  static FILE *f = NULL;
  static close = 0;
  unsigned int value = 0;

  if( !f ) {
    f = fopen("myfile.txt", 'w');
    if( !f )
      return;
  }

  __asm mov value, eax; // I can't recall if it's [value] or value, because this is inline asm.
 
  fprintf(f, %d\n, value);

  if( close )
    if( !fclose(f) )
      f = NULL;
}
Iono if it works, let's say it's pseudo code for yourself to implement Very Happy


They both work. well... at least for delphi. If its a variable, it will automatically add the brackets to it.
Back to top
View user's profile Send private message
Slugsnack
Grandmaster Cheater Supreme
Reputation: 71

Joined: 24 Jan 2007
Posts: 1857

PostPosted: Sat Jun 06, 2009 8:48 am    Post subject: Reply with quote

getthreadcontext and then doing it in a function with pushad/popad is the best way but why would you want to save them constantly.. ?! there is a context change nearly every instruction..

@TempNick : thread-safe is very easy, just stick that code in a critical section or protect it with a semaphore/lock

still.. not quite sure what OP wants..
Back to top
View user's profile Send private message
agoox
How do I cheat?
Reputation: 0

Joined: 04 May 2009
Posts: 7

PostPosted: Sat Jun 06, 2009 10:05 am    Post subject: Reply with quote

I make a statistics for a friend and I have a "label" in a flash witch is loaded every 10 second with a random number and I should to display some graphics in real time after I perform those numbers. create graphics and work with those number it's not complicated because I work in C# but the problem was to read the number. thanks to you I think I will finish the job.
I don't want to change the context of flash, I need only to read this number and I sow that is a static register witch contain this number always even if I close and reopen the flash.
Thanks a lot.
Back to top
View user's profile Send private message
NINTENDO
Grandmaster Cheater Supreme
Reputation: 0

Joined: 02 Nov 2007
Posts: 1371

PostPosted: Sat Jun 06, 2009 3:09 pm    Post subject: Re: can I save register's values into a text file? Reply with quote

agoox wrote:
Hi, can you tell me if is possible to save into a text file the values of a register. I can read the value manually the value but in my game this register is changing every second I for my statistics i should save the values into a text file. And if I can save those values in real time will be very good.
Thanks a lot for your time.
King regards, John.

you know the value? you know how to write (to) files? What's the issue really?

_________________
Intel over amd yes.
Back to top
View user's profile Send private message Send e-mail AIM Address Yahoo Messenger MSN Messenger
Guy
Expert Cheater
Reputation: 0

Joined: 30 May 2009
Posts: 187

PostPosted: Sat Jun 06, 2009 5:20 pm    Post subject: Re: can I save register's values into a text file? Reply with quote

Den Söta Kaninen wrote:
agoox wrote:
Hi, can you tell me if is possible to save into a text file the values of a register. I can read the value manually the value but in my game this register is changing every second I for my statistics i should save the values into a text file. And if I can save those values in real time will be very good.
Thanks a lot for your time.
King regards, John.

you know the value? you know how to write (to) files? What's the issue really?


The issue is likely the OP's infamilarity with ASM and WinAPI functions for file I/O.
Back to top
View user's profile Send private message
agoox
How do I cheat?
Reputation: 0

Joined: 04 May 2009
Posts: 7

PostPosted: Mon Jun 29, 2009 4:47 am    Post subject: Reply with quote

I don't know almost anything about ASM and I know so much about C++ so I have some difficulties to do this. I
first I found the register with I need, after this I pressed the Memory View button -> Tools-> script engine and I copy the script below:
Code:
void HookFunction()
{
  static FILE *f = NULL; //this is a parse error. Cannot find 'FILE'
  static close = 0;
  unsigned int value = 0;

  if( !f ) {
    f = fopen("D:\\test.txt", 'w'); //
    if( !f )
      return;
  }

  __asm mov value, eax; // I can't recall if it's [value] or value, because this is inline asm.
 
  fprintf(f, %d\n, value);

  if( close )
    if( !fclose(f) )
      f = NULL;
}

should I use some reference for 'FILE' or I don't insert the script where must be inserted?
king regards, John.
Back to top
View user's profile Send private message
Dark Byte
Site Admin
Reputation: 471

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

PostPosted: Mon Jun 29, 2009 5:19 am    Post subject: Reply with quote

hasn't anyone noticed that this script is pretty much useless ?
Let's just say that fopen already destroys the original value of EAX, and the other code in front might just as well do the same

anyhow, in your code injection, the first thing you do, save EAX to a static address (mov [staticaddress],eax ), and if you then want you can jump to some c code that saves that static address to a file (or you could just do the saving using assembler as well)

_________________
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
Back to top
View user's profile Send private message MSN Messenger
agoox
How do I cheat?
Reputation: 0

Joined: 04 May 2009
Posts: 7

PostPosted: Mon Jun 29, 2009 6:25 am    Post subject: Reply with quote

Quote:
(or you could just do the saving using assembler as well)

how this is possible?
Back to top
View user's profile Send private message
Jani
Grandmaster Cheater
Reputation: 2

Joined: 29 Dec 2006
Posts: 804

PostPosted: Mon Jun 29, 2009 6:50 am    Post subject: Reply with quote

Dark Byte wrote:
Let's just say that fopen already destroys the original value of EAX, and the other code in front might just as well do the same
Oops, my bad :P
Code:
// v2.0
void HookFunction()
{
  static FILE *f = NULL;
  static close = 0;
  static unsigned int value = 0;

  __asm mov value, eax; // I can't recall if it's [value] or value, because this is inline asm.

  if( !f ) {
    f = fopen("myfile.txt", 'w');
    if( !f )
      return;
  }
 
  fprintf(f, "%d\n", value);

  if( close )
    if( !fclose(f) )
      f = NULL;
}
Fix'd? I left out __declspec(naked) on purpose, earlier too.. Also it seems I missed some quotation marks..
Back to top
View user's profile Send private message
Zerith
Master Cheater
Reputation: 1

Joined: 07 Oct 2007
Posts: 468

PostPosted: Mon Jun 29, 2009 9:03 am    Post subject: Reply with quote

by the way, you can write either mov value ,eax or mov [value], eax
the compiler translates it anyway into:
Code:

MOV DWORD PTR [VALUE], eax
Back to top
View user's profile Send private message MSN Messenger
agoox
How do I cheat?
Reputation: 0

Joined: 04 May 2009
Posts: 7

PostPosted: Mon Jun 29, 2009 9:40 am    Post subject: Reply with quote

now this is a stupid question, but I don't understand something. where should I insert the script? to insert the script I follow this steps:
find register -> click Memory View button -> Tools -> Script Engine
and in this window I insert your function but on execution I receive an error(Error interpreting script: parse error Cannot find 'FILE'). I thick this error is because my script is not parse with C debugger and this is a problem. can you help me with this pl?
also I tired with 'ofstream' instead of 'FILE' and I receive the same error.

please see the attached picture



ScreenShot001.jpg
 Description:
 Filesize:  102.8 KB
 Viewed:  12793 Time(s)

ScreenShot001.jpg


Back to top
View user's profile Send private message
&Vage
Grandmaster Cheater Supreme
Reputation: 0

Joined: 25 Jul 2008
Posts: 1053

PostPosted: Mon Jun 29, 2009 9:53 am    Post subject: Reply with quote

This thread made me lol'd. Jani posted a C script not an AA script Neutral
Back to top
View user's profile Send private message
agoox
How do I cheat?
Reputation: 0

Joined: 04 May 2009
Posts: 7

PostPosted: Mon Jun 29, 2009 10:32 am    Post subject: Reply with quote

I've done all tutorials and read a lot of topics but I didn't find anything where I can understand where should I insert C script, and I didn't find anything about AA script or how should I convert C scripts in AA scripts, anybody can tell me about this ? or give me a link to read about inserting script in Cheat engine.
Thanks a lot.
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 programming All times are GMT - 6 Hours
Goto page 1, 2  Next
Page 1 of 2

 
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