| 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?
|
Posted: Thu Jul 03, 2008 2:35 am Post subject: custom file saving |
|
|
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 |
|
 |
Flyte Peanuts!!!!
Reputation: 6
Joined: 19 Apr 2006 Posts: 1887 Location: Canada
|
Posted: Thu Jul 03, 2008 2:52 am Post subject: |
|
|
| Just like any other file, except you have a premeditated way of scanning it for info, like a memory structure.
|
|
| Back to top |
|
 |
DeletedUser14087 I post too much
Reputation: 2
Joined: 21 Jun 2006 Posts: 3069
|
Posted: Thu Jul 03, 2008 5:12 am Post subject: Re: custom file saving |
|
|
| 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 |
|
 |
oib111 I post too much
Reputation: 0
Joined: 02 Apr 2007 Posts: 2947 Location: you wanna know why?
|
Posted: Thu Jul 03, 2008 12:54 pm Post subject: |
|
|
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 |
|
 |
HomerSexual Grandmaster Cheater Supreme
Reputation: 5
Joined: 03 Feb 2007 Posts: 1657
|
Posted: Thu Jul 03, 2008 9:16 pm Post subject: |
|
|
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 |
|
 |
oib111 I post too much
Reputation: 0
Joined: 02 Apr 2007 Posts: 2947 Location: you wanna know why?
|
Posted: Thu Jul 03, 2008 9:29 pm Post subject: |
|
|
Such as?
_________________
| 8D wrote: |
cigs dont make people high, which weed does, which causes them to do bad stuff. like killing |
|
|
| Back to top |
|
 |
HomerSexual Grandmaster Cheater Supreme
Reputation: 5
Joined: 03 Feb 2007 Posts: 1657
|
Posted: Thu Jul 03, 2008 9:49 pm Post subject: |
|
|
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 |
|
 |
ElectroFusion Grandmaster Cheater
Reputation: 0
Joined: 17 Dec 2006 Posts: 786
|
Posted: Thu Jul 03, 2008 9:57 pm Post subject: |
|
|
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 |
|
 |
oib111 I post too much
Reputation: 0
Joined: 02 Apr 2007 Posts: 2947 Location: you wanna know why?
|
Posted: Thu Jul 03, 2008 10:11 pm Post subject: |
|
|
| 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 |
|
 |
HomerSexual Grandmaster Cheater Supreme
Reputation: 5
Joined: 03 Feb 2007 Posts: 1657
|
Posted: Thu Jul 03, 2008 10:20 pm Post subject: |
|
|
| 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 |
|
 |
nwongfeiying Grandmaster Cheater
Reputation: 2
Joined: 25 Jun 2007 Posts: 695
|
Posted: Thu Jul 03, 2008 11:57 pm Post subject: |
|
|
| 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 |
|
 |
Dark Byte Site Admin
Reputation: 471
Joined: 09 May 2003 Posts: 25831 Location: The netherlands
|
Posted: Fri Jul 04, 2008 1:58 am Post subject: |
|
|
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 |
|
 |
oib111 I post too much
Reputation: 0
Joined: 02 Apr 2007 Posts: 2947 Location: you wanna know why?
|
Posted: Fri Jul 04, 2008 2:22 am Post subject: |
|
|
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 |
|
 |
Dark Byte Site Admin
Reputation: 471
Joined: 09 May 2003 Posts: 25831 Location: The netherlands
|
|
| Back to top |
|
 |
oib111 I post too much
Reputation: 0
Joined: 02 Apr 2007 Posts: 2947 Location: you wanna know why?
|
Posted: Fri Jul 04, 2008 11:27 am Post subject: |
|
|
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 |
|
 |
|