[Assembly] How to create and open files

Status
Not open for further replies.

Thread Starter

ahmedbj

Joined Jan 16, 2010
5
Hello everyone
I'm a begginer in assembly langage, and i'm trying to make a programme that can open, and write on a file.
All is working, i can create and open the file and writte on it. But i noticed that the fil isn't created in the place that i have marked (dir1 db "d:\test.txt") the file is not created in d:\ i tried to change it to "d:\dir\test.txt" but it still not working :(
But i noticed that there is a folder, in the emulator installation folder c:\emu8086, called vdrive (c:\emu8086\vdrive) that contain other folder called C and another one Called D and my fil is created there in folder c:\emu8086\vdrive\D
I changer the directory to c:\test.txt and my fil was created in c:\emu8086\vdrive\C
So can someone help me ? i wanna open files that are in C:\WINDOWS\ODBC.INI for exemple so i can writte on it....
Sorry for my bad english
and Thank you for taking time to read my post :)
Another question i wanna know how to change registry values with assembly, because i want that my programme be executed automatically when a user start a session in Windows
thank you
 

retched

Joined Dec 5, 2009
5,207
Some emulators can only write to the VIRTUAL drive. It uses the hard drive like on-board memory in a microcontroller. In order to write to the "physical" drive, you would need to write a IO driver to talk the language of the storage device. Not very easy. It has to be able to read the file allocation table and set aside bits for the writing.. a whole lot more.

[ed]
From the emu8086.com website:
emu8086 can create a tiny operating system and write its binary code to a bootable floppy disk. This software package includes several virtual external devices: robot, stepper motor, led display, and traffic lights intersection. Virtually anyone with any programming experience can design animated virtual devices in assembly language or in any other programming language. All devices are open for modifications and cloning (source code is available). All communications between the microprocessor and devices is coming through this file: c:\emu8086.io, to emulate in/out instructions it's just required to change corresponding bytes in this binary file.
 

Thread Starter

ahmedbj

Joined Jan 16, 2010
5
so my aim is that i want to open this file C:\WINDOWS\system32\drivers\etc\hosts
and modify it with assembly, so is there any way to do it or if you have an exemple for code or source code that can do the same, and i can do somechange to modify it for my own aim ?
thank you
 

retched

Joined Dec 5, 2009
5,207
ah, you want to EDIT, not just write. That would require a bit of code.

You will need to pull the file into memory, locate the insertion point, remove the old lines (if it was a change) and replace it with new, then write the changed file back.
 

retched

Joined Dec 5, 2009
5,207
do you want this to stay a PC program, or do you want to put this on a prototype?

are you writing a virus or malware?

It seems to me you want to open and edit hosts file at startup, without any input from the user. I don't think I want to go there.
 

retched

Joined Dec 5, 2009
5,207
Ok, so you do want to edit the hosts file at every startup with a remote host list.
To keep your brother from seeing nudie and other such sites.

is there a reason you are using assembly language over another?

You can use a batch file to add whatever sites you want added to hosts file from a file you make. You could continually update the file with more sites as your brother finds out about them.

Here is a way to do it with batch files with minor adjustment:
http://www.novell.com/coolsolutions/trench/3036.html
 

Thread Starter

ahmedbj

Joined Jan 16, 2010
5
yes i know, but i'm using assembly because we learn it at university and i want to know more.
if you want i can give you my email adress so you can help me?
because i need to know how things works
i'm not a virus programmer be sur of that.
Because if i did it with assembly i can learne more and do well in TP in class
so please help i really need it
 

retched

Joined Dec 5, 2009
5,207
Ok, assembler it is. You can use batch files as a flow chart. Batch files are not written in a batch language. They are a batch of command line commands.

so if you got tired of typing:
C:\>cd\windows
C:\>dir /p
you could make a batch file to do it for you.

d.bat:
Rich (BB code):
cd\windows
dir /p
so when you want to change directories to 'windows' and see a directory listing of with page breaks, you can just type 'd'

But I digress, here is some info to help:

After you compile you program, it wont keep putting files in c:\emu8086\vdrive\. It only does that in the emulator.

So write the file file how you WANT it to work and it will when compiled.

For instance. You want to write to C:\windows\ect\hello.txt.

While usind the emulator it will write to c:\emu8086\vdrive\c\windows\ect\hello.txt. Just so you dont screw anything up.

If you don't understand, post your code, and ill try to help more.
 
Status
Not open for further replies.
Top