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 


[SOLVED]Empying A Binary File To Zero-Byte size.
Goto page Previous  1, 2
 
Post new topic   Reply to topic    Cheat Engine Forum Index -> General programming
View previous topic :: View next topic  
Author Message
Dark Byte
Site Admin
Reputation: 475

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

PostPosted: Thu Oct 30, 2008 3:21 pm    Post subject: Reply with quote

well, if you want to do a 'more complicated' way:
First detect what kind of filesystem is used. fat,ntfs, other
then find out where the filesystem stores the size value AND the the links to the used sectors/clusters
Set the size to zero and mark the used clusters as free.

You will probably need to get into kernelmode

_________________
Tools give you results. Knowledge gives you control.

Like my help? Join me on Patreon so i can keep helping
Back to top
View user's profile Send private message MSN Messenger
DeletedUser14087
I post too much
Reputation: 2

Joined: 21 Jun 2006
Posts: 3069

PostPosted: Thu Oct 30, 2008 3:22 pm    Post subject: Reply with quote

smartz993 wrote:
Rot1 wrote:
blankrider wrote:
He already told you how to do it. Stop being stubborn and trying to make shit complicated.

Lesson learned: Not everything has to be complicated to be the correct and efficient way!


I'm not!, i'm asking for a method OTHER THAN deleting a file, then he comes saying "stop trying doing stuff you don't know", how does it help me ? jesus am i the only one who get fucking pissed @ fucktards.


Why are you looking for a method other than this one? It's the most simplistic.


i'm not looking for something simple and like "hehe, that was easy, now bye bye", it's not a clever way to act. (for me).

Dark Byte wrote:
well, if you want to do a 'more complicated' way:
First detect what kind of filesystem is used. fat,ntfs, other
then find out where the filesystem stores the size value AND the the links to the used sectors/clusters
Set the size to zero and mark the used clusters as free.

You will probably need to get into kernelmode


will GetBinaryType do it ?

edit: shit, let me re-read your reply 500 times until i get it ;D.
Back to top
View user's profile Send private message
nog_lorp
Grandmaster Cheater
Reputation: 0

Joined: 26 Feb 2006
Posts: 743

PostPosted: Thu Oct 30, 2008 4:55 pm    Post subject: Reply with quote

The win32 way of doing fopen with "w" is calling CreateFile with CREATE_ALWAYS.
The "clever" (read: stupid) way of doing it would be
CreateFile with OPEN_ALWAYS
//SetFilePointer(hFile, 0, 0, FILE_BEGIN) if you want to read from the sile before you 0 it.
SetEndOfFile(hFile);

This might be marginally faster then deleting the file and recreating it, and might be marginally advantageous in stopping fragmentation. It is probably only worth while in cases where you have a file that is regularly growed, read, and then zoroed.

_________________
Mutilated lips give a kiss on the wrist of the worm-like tips of tentacles expanding in my mind
I'm fine accepting only fresh brine you can get another drop of this yeah you wish
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 Oct 30, 2008 5:23 pm    Post subject: Reply with quote

nog_lorp wrote:
The win32 way of doing fopen with "w" is calling CreateFile with CREATE_ALWAYS.
The "clever" (read: stupid) way of doing it would be
CreateFile with OPEN_ALWAYS
//SetFilePointer(hFile, 0, 0, FILE_BEGIN) if you want to read from the sile before you 0 it.
SetEndOfFile(hFile);

This might be marginally faster then deleting the file and recreating it, and might be marginally advantageous in stopping fragmentation. It is probably only worth while in cases where you have a file that is regularly growed, read, and then zoroed.


nice!, thanks man. i will try this.

Edit: It fucking works, thank you Very Happy !!!
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 Previous  1, 2
Page 2 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