News:

MASM32 SDK Description, downloads and other helpful links
MASM32.com New Forum Link
masmforum WebSite

Append existing file

Started by unknown, August 24, 2009, 11:11:11 AM

Previous topic - Next topic

unknown

Hi everyone,

I want to add text to a existing file  ::)
And the point of view is:
1) Get the file.
2) Seek the end of the file.
3) Add text at end.

The file which I wanna append is existing already and the file is not with any extension.
The file can be opened with notepad.

dedndave

nice name you picked - lol
took all day to think of it, eh ?
now - your file
so, you want us to guess the filename ?
my guess is.....
hosts
tell us what you want to stick in there
be specific - as in, tell us the url

unknown

Precious mind......
Well its some thing I want to avoid server check.  :wink

I never thought you can think of it lol

127.0.0.1 www.xxxx.com

----------------
Do you know me, off course not - so I am unknown
Moreover Its better than some numeric name lol

dedndave

xxx.com ?
lol
your originality is gonna kill me
Quotebe specific - as in, tell us the url

unknown

opps.....I did not write xxx, I wrote xxxx lol

Anyway,

127.0.0.1 client.msnslide.com

I hope we can move on solving the problem  :wink

dedndave

well, first, let me tell you that the forum has rather strict rules about cracking, etc
second, most of us won't write a program for you
you have to learn assembly language and write it yourself
if you are new to programming, i would suggest you pick a simpler language to start with

sinsi

Light travels faster than sound, that's why some people seem bright until you hear them.

unknown

Quote from: dedndave on August 24, 2009, 11:48:21 AM
well, first, let me tell you that the forum has rather strict rules about cracking, etc
second, most of us won't write a program for you
you have to learn assembly language and write it yourself
if you are new to programming, i would suggest you pick a simpler language to start with

Where do I mention its for cracking.
I am a asm coder but not so good...
I coded the solution but it not seem to be working...

Well forget everything, delete this post admins...or the last reply for help!  :8)

sinsi

1. CreateFile
HANDLE WINAPI CreateFile(
  __in      LPCTSTR lpFileName,
  __in      DWORD dwDesiredAccess,
  __in      DWORD dwShareMode,
  __in_opt  LPSECURITY_ATTRIBUTES lpSecurityAttributes,
  __in      DWORD dwCreationDisposition,
  __in      DWORD dwFlagsAndAttributes,
  __in_opt  HANDLE hTemplateFile

2. SetFilePointer to FILE_END
DWORD WINAPI SetFilePointer(
  __in         HANDLE hFile,
  __in         LONG lDistanceToMove,
  __inout_opt  PLONG lpDistanceToMoveHigh,
  __in         DWORD dwMoveMethod

3. WriteFile
BOOL WINAPI WriteFile(
  __in         HANDLE hFile,
  __in         LPCVOID lpBuffer,
  __in         DWORD nNumberOfBytesToWrite,
  __out_opt    LPDWORD lpNumberOfBytesWritten,
  __inout_opt  LPOVERLAPPED lpOverlapped

4. CloseHandle
BOOL WINAPI CloseHandle(
  __in  HANDLE hObject



Quote
What a mentality you have, So you think I am crazy writing just for fun right here, I can modify but its not for me
For others I cant tell every newbie individual to add it!

I decided to come here on this forum because I hoped for any help, and not this kind of help....

I told every thing what 'dedndave'  wanted.

I want to append host file with specified text, now what you want out of me ?! 



Charmed, I'm sure.
Light travels faster than sound, that's why some people seem bright until you hear them.

unknown

Thanks for the hints...

dedndave, learn from it, not everything can be solved with your way....Aquire the reason and follow and it seem you were the first to think about stupid idea of cracking here ...and I really don't believe you can be...  :wink

And where did I mention to code for me, did I, just want hints!
Just like this:
http://www.masm32.com/board/index.php?topic=9209.msg91889#msg91889

sinsi

Just remember, the hosts file is one of the things that antivirus and antispyware programs keep tabs on.

There are a few available on the internet, they just give you the whole hosts file.
I've also seen that it's not much use anyway, so who knows?
Light travels faster than sound, that's why some people seem bright until you hear them.

dedndave

i know what a hosts file is
and i know that if XYZ software wants to put ABC software out of business, adding www.XYZ.com to the hosts file will help
and, Sinsi - i have used the hosts file - and i know it helps
i also use it to get rid of advertisements
mine is currently about 600 kb
there are other ways to use the file, as well - i won't go into it here

unknown - if you have some code that isn't working - post it

unknown

Quote from: dedndave on August 24, 2009, 01:35:02 PM
i know what a hosts file is
and i know that if XYZ software wants to put ABC software out of business, adding www.XYZ.com to the hosts file will help
and, Sinsi - i have used the hosts file - and i know it helps
i also use it to get rid of advertisements
mine is currently about 600 kb
there are other ways to use the file, as well - i won't go into it here

unknown - if you have some code that isn't working - post it
Better I think better reply this time lol, Well I already coded!

I used GetSystemDirectory > copied to buffer and combining the text '\drivers\etc\Hosts' > Seeked the end of file by using FILE_END > Input the text by WriteFile > and then
closed file!
Thanks to sinsi and
Quoteyou have to learn assembly language and write it yourself
if you are new to programming, i would suggest you pick a simpler language to start with
your attitude made me do it  :lol

dedndave

normally, i would use FindFile to get the size, then set the pointer using SetFilePointer to the desired position
seeing as you are going straight to the end, you don't even need to use FindFile
one of the SetFilePointer options is to set it to the current end of file

1) use CreateFile to open it
2) use SetFilePointer to point to end of file
3) use WriteFile to write
4) use CloseHandle to close the file

MichaelW

Or for easy you could use the MASM32 fopen, fseek, fprint, and fclose macros.
eschew obfuscation