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 


custom file saving
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
oib111
I post too much
Reputation: 0

Joined: 02 Apr 2007
Posts: 2947
Location: you wanna know why?

PostPosted: Thu Jul 03, 2008 2:35 am    Post subject: custom file saving Reply with quote

I was wondering how I can do custom file saving? Good example is Cheat Engine and saving cheat tables or .ct files.
_________________


8D wrote:

cigs dont make people high, which weed does, which causes them to do bad stuff. like killing
Back to top
View user's profile Send private message AIM Address Yahoo Messenger MSN Messenger
Flyte
Peanuts!!!!
Reputation: 6

Joined: 19 Apr 2006
Posts: 1887
Location: Canada

PostPosted: Thu Jul 03, 2008 2:52 am    Post subject: Reply with quote

Just like any other file, except you have a premeditated way of scanning it for info, like a memory structure.
Back to top
View user's profile Send private message
DeletedUser14087
I post too much
Reputation: 2

Joined: 21 Jun 2006
Posts: 3069

PostPosted: Thu Jul 03, 2008 5:12 am    Post subject: Re: custom file saving Reply with quote

oib111 wrote:
I was wondering how I can do custom file saving? Good example is Cheat Engine and saving cheat tables or .ct files.


CE is Delphi, right ?

So, without looking at the source i bet DB did it like:

TListItem.Subitems.SaveToFile('MyFile.CT');

of if it's a TMemo

Memo1.lines.SaveToFile('MyFile.CT');

if you wanna make the user input the name for the file:

Memo1.lines.SaveToFile(Edit1.Text+'.ct');
Back to top
View user's profile Send private message
oib111
I post too much
Reputation: 0

Joined: 02 Apr 2007
Posts: 2947
Location: you wanna know why?

PostPosted: Thu Jul 03, 2008 12:54 pm    Post subject: Reply with quote

Well thanks for that delphi help, but C++ is a bit different. I'm assuming to do something like CE in C++ you would have to loop through each list item and append it to the .ct file. But like in Photoshop, they save the layers and what's on the layer.
_________________


8D wrote:

cigs dont make people high, which weed does, which causes them to do bad stuff. like killing
Back to top
View user's profile Send private message AIM Address Yahoo Messenger MSN Messenger
HomerSexual
Grandmaster Cheater Supreme
Reputation: 5

Joined: 03 Feb 2007
Posts: 1657

PostPosted: Thu Jul 03, 2008 9:16 pm    Post subject: Reply with quote

It's just an extension. You can make the extension anything you want with most of the win32 and C file apis
_________________
Back to top
View user's profile Send private message
oib111
I post too much
Reputation: 0

Joined: 02 Apr 2007
Posts: 2947
Location: you wanna know why?

PostPosted: Thu Jul 03, 2008 9:29 pm    Post subject: Reply with quote

Such as?
_________________


8D wrote:

cigs dont make people high, which weed does, which causes them to do bad stuff. like killing
Back to top
View user's profile Send private message AIM Address Yahoo Messenger MSN Messenger
HomerSexual
Grandmaster Cheater Supreme
Reputation: 5

Joined: 03 Feb 2007
Posts: 1657

PostPosted: Thu Jul 03, 2008 9:49 pm    Post subject: Reply with quote

I believe you can use CreateFile(http://msdn.microsoft.com/en-us/library/aa363858.aspx)

followed by WriteFile with the hFile name of file.ext

Try it and get back to me

_________________
Back to top
View user's profile Send private message
ElectroFusion
Grandmaster Cheater
Reputation: 0

Joined: 17 Dec 2006
Posts: 786

PostPosted: Thu Jul 03, 2008 9:57 pm    Post subject: Reply with quote

Lets not forget some major encrypting.

Heres what I do:

Replace all a's with 5
Replace all b's with 19

and so on. Then when I read info.store it does this:

Replace all 5's with a
Replace all 19's with b

sometimes I use symbols, so nobody can decrypt it.

_________________
qwerty147 wrote:

ghostonline wrote:

what world are you in?

bera

but i live in NZ
Back to top
View user's profile Send private message
oib111
I post too much
Reputation: 0

Joined: 02 Apr 2007
Posts: 2947
Location: you wanna know why?

PostPosted: Thu Jul 03, 2008 10:11 pm    Post subject: Reply with quote

Code:

HANDLE hFile = CreateFile("file.ext", GENERIC_READ | GENERIC_WRITE, 0, NULL, OPEN_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL);


Btw, can I write anything to the file? Like Photoshop writes the layers. And how do you write numerous things at once? Or do you have to write one thing and then append another? If so, how do you set it to append, because it doesn't seem like you can.

_________________


8D wrote:

cigs dont make people high, which weed does, which causes them to do bad stuff. like killing
Back to top
View user's profile Send private message AIM Address Yahoo Messenger MSN Messenger
HomerSexual
Grandmaster Cheater Supreme
Reputation: 5

Joined: 03 Feb 2007
Posts: 1657

PostPosted: Thu Jul 03, 2008 10:20 pm    Post subject: Reply with quote

Quote:
Appending data automatically Joseph Galbraith ... RobbieCC | Edit | Show History
Please Wait Please Wait

You can use the data for this write to be written at the EOF (rather than the current file pointer) by using the OVERLAPPED structucture and specifying OVERLAPPED.Offset = FILE_WRITE_TO_END_OF_FILE and OVERLAPPED.OffsetHigh = -1

This behavior is documented in WDK / Installable Filesystems / Reference / IRP Function Codes / IRP_MJ_WRITE (currently http://msdn2.microsoft.com/en-us/library/ms795960.aspx)

Unfortunately, FILE_WRITE_TO_END_OF_FILE is not currently in the platform SDK headers, but it is in the WDK headers:

#define FILE_WRITE_TO_END_OF_FILE 0xffffffff


I believe this will be automatic with any other append operations to the file (regardless of whether such operations are on the same or a different file handle.) This is a much better solution than the classic seek-to-eof and write that I often see in code.

The following sample program demonstrates this behavior

Code:
#include <windows.h>
#include <tchar.h>

#define FILE_WRITE_TO_END_OF_FILE       0xffffffff


int
_tmain(int argc, _TCHAR* argv[])
{
 HANDLE hFile = ::CreateFile(L"Test.txt",
        GENERIC_WRITE,
        0,
        0,
        OPEN_EXISTING,
        FILE_ATTRIBUTE_NORMAL,
        0);
 if ( hFile == INVALID_HANDLE_VALUE )
  return ::GetLastError();


 OVERLAPPED o;
 ::memset(&o, 0, sizeof(o));

 o.Offset = FILE_WRITE_TO_END_OF_FILE;
 o.OffsetHigh = -1;


 DWORD dwBytesWritten;
 if ( ! ::WriteFile(hFile, "This is a test\r\n", 16, &dwBytesWritten, &o) )
  return ::GetLastError();


 return 0;
}



[/code]
_________________
Back to top
View user's profile Send private message
nwongfeiying
Grandmaster Cheater
Reputation: 2

Joined: 25 Jun 2007
Posts: 695

PostPosted: Thu Jul 03, 2008 11:57 pm    Post subject: Reply with quote

I just write and read files. It's unsecure since I do not encrypt the files, but it's all that is necessary so far.
Back to top
View user's profile Send private message
Dark Byte
Site Admin
Reputation: 471

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

PostPosted: Fri Jul 04, 2008 1:58 am    Post subject: Reply with quote

CE saves a CT like this:
write a 11 byte buffer containing the text "CHEATENGINE" to the file
write a 4 byte value indicating the current save version to the file
write a 4 byte value indicating how many addresses are in the list
then a block with information about each address is written to the file the same ammount of times there is an address

etc...

No real text is used, only pure data

_________________
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
oib111
I post too much
Reputation: 0

Joined: 02 Apr 2007
Posts: 2947
Location: you wanna know why?

PostPosted: Fri Jul 04, 2008 2:22 am    Post subject: Reply with quote

Can I see the code for that? I think it would help me understand how it works better if I saw it.
_________________


8D wrote:

cigs dont make people high, which weed does, which causes them to do bad stuff. like killing
Back to top
View user's profile Send private message AIM Address Yahoo Messenger MSN Messenger
Dark Byte
Site Admin
Reputation: 471

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

PostPosted: Fri Jul 04, 2008 2:48 am    Post subject: Reply with quote

save routine:
http://ce.colddot.nl/browser/Cheat%20Engine/OpenSave.pas#L5291

load routine:
http://ce.colddot.nl/browser/Cheat%20Engine/OpenSave.pas#L3363

_________________
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
oib111
I post too much
Reputation: 0

Joined: 02 Apr 2007
Posts: 2947
Location: you wanna know why?

PostPosted: Fri Jul 04, 2008 11:27 am    Post subject: Reply with quote

X_X There is over 5000 lines of code just to save?!?!
_________________


8D wrote:

cigs dont make people high, which weed does, which causes them to do bad stuff. like killing
Back to top
View user's profile Send private message AIM Address Yahoo Messenger MSN Messenger
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