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 1, 2  Next
 
Post new topic   Reply to topic    Cheat Engine Forum Index -> General programming
View previous topic :: View next topic  
Author Message
DeletedUser14087
I post too much
Reputation: 2

Joined: 21 Jun 2006
Posts: 3069

PostPosted: Thu Oct 30, 2008 8:12 am    Post subject: [SOLVED]Empying A Binary File To Zero-Byte size. Reply with quote

Solved, thanks to nog_lorp (and Dark Byte for his tips too).

Last edited by DeletedUser14087 on Fri Oct 31, 2008 2:55 am; edited 2 times in total
Back to top
View user's profile Send private message
Dark Byte
Site Admin
Reputation: 475

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

PostPosted: Thu Oct 30, 2008 8:50 am    Post subject: Reply with quote

delete it and create a new file with the same name at that location without writing to it
_________________
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 8:54 am    Post subject: Reply with quote

Dark Byte wrote:
delete it and create a new file with the same name at that location without writing to it


that's the exact thing assaf84 told me, and i told him "i'm looking for a challenge, every baby can do that".

Isn't there a way to flush the file's buffer and re-write to it ?.

Edit:

CreateFile (OPEN_EXISTING) -> FlushFileBuffer(wtf) -> WriteFile -> CloseHandle.
Back to top
View user's profile Send private message
sphere90
Grandmaster Cheater
Reputation: 0

Joined: 24 Jun 2006
Posts: 912

PostPosted: Thu Oct 30, 2008 9:19 am    Post subject: Reply with quote

Rot1 wrote:
CreateFile (OPEN_EXISTING) -> FlushFileBuffer(wtf) -> WriteFile -> CloseHandle.


Seriously dude, check what a function does before using it. Do you know what FlushFileBuffers actually do? It "flushes the buffers of a specified file and causes all buffered data to be written to a file". It doesn't clear a file. Flushing a FILE and flushing the FILE BUFFER are totally different things.


Last edited by sphere90 on Thu Oct 30, 2008 9:23 am; edited 1 time in total
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 9:23 am    Post subject: Reply with quote

sphere90 wrote:
Rot1 wrote:
CreateFile (OPEN_EXISTING) -> FlushFileBuffer(wtf) -> WriteFile -> CloseHandle.


Seriously dude, check what a function does before using it. Do you know what FlushFileBuffers actually do? It "flushes the buffers of a specified file and causes all buffered data to be written to a file". Flushing a FILE and flushing the FILE BUFFER are totally different things.


It's alike CopyFile() i assume ? could be a 2nd use for WriteFile() too.
Back to top
View user's profile Send private message
sphere90
Grandmaster Cheater
Reputation: 0

Joined: 24 Jun 2006
Posts: 912

PostPosted: Thu Oct 30, 2008 9:27 am    Post subject: Reply with quote

Rot1 wrote:
sphere90 wrote:
Rot1 wrote:
CreateFile (OPEN_EXISTING) -> FlushFileBuffer(wtf) -> WriteFile -> CloseHandle.


Seriously dude, check what a function does before using it. Do you know what FlushFileBuffers actually do? It "flushes the buffers of a specified file and causes all buffered data to be written to a file". Flushing a FILE and flushing the FILE BUFFER are totally different things.


It's alike CopyFile() i assume ? could be a 2nd use for WriteFile() too.


Sometimes file operations are not synchronous. The bytes that you write to a file using WriteFile is written to a temporary buffer first. When you call FlushFileBuffers, the bytes that are stored in the buffer will be written to your file.
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 9:33 am    Post subject: Reply with quote

ok sphere90, i understand but lets not go off-topic, if there isn't a way to make a file empty then i guess i'll have to delete it.
Back to top
View user's profile Send private message
Jani
Grandmaster Cheater
Reputation: 2

Joined: 29 Dec 2006
Posts: 804

PostPosted: Thu Oct 30, 2008 10:51 am    Post subject: Reply with quote

Code:
FILE *f;
f = fopen("file.bin", "w");
fclose(f);
Back to top
View user's profile Send private message
SXGuy
I post too much
Reputation: 0

Joined: 19 Sep 2006
Posts: 3551

PostPosted: Thu Oct 30, 2008 11:30 am    Post subject: Reply with quote

Jani wrote:
Code:
FILE *f;
f = fopen("file.bin", "w");
fclose(f);


Doesnt that just open a file with write permissions and then closes it? how does that help?
Back to top
View user's profile Send private message
Dark Byte
Site Admin
Reputation: 475

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

PostPosted: Thu Oct 30, 2008 12:26 pm    Post subject: Reply with quote

no, that's w+
w is create/replace file with 0 size with write access

_________________
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
lurc
Grandmaster Cheater Supreme
Reputation: 2

Joined: 13 Nov 2006
Posts: 1900

PostPosted: Thu Oct 30, 2008 1:27 pm    Post subject: Reply with quote

Rot1 wrote:
that's the exact thing assaf84 told me, and i told him "i'm looking for a challenge, every baby can do that".


The point of program is not to make it fancy, but to make it efficient Rolling Eyes.

If the easiest and most efficient way is to just delete the file and recreate it, then use that instead of thinking of some dumb retarded way that you don't know how to do.

_________________
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 2:25 pm    Post subject: Reply with quote

lurc wrote:
Rot1 wrote:
that's the exact thing assaf84 told me, and i told him "i'm looking for a challenge, every baby can do that".


The point of program is not to make it fancy, but to make it efficient Rolling Eyes.

If the easiest and most efficient way is to just delete the file and recreate it, then use that instead of thinking of some dumb retarded way that you don't know how to do.


well, that's why i'm asking, and if you don't know how to do it then don't reply !.
Back to top
View user's profile Send private message
HomerSexual
Grandmaster Cheater Supreme
Reputation: 5

Joined: 03 Feb 2007
Posts: 1657

PostPosted: Thu Oct 30, 2008 2:31 pm    Post subject: Reply with quote

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!

_________________
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 2:39 pm    Post subject: Reply with quote

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.
Back to top
View user's profile Send private message
smartz993
I post too much
Reputation: 2

Joined: 20 Jun 2006
Posts: 2013
Location: USA

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

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.
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