[Assembly] How to create and open files

Discussion in 'Programmer's Corner' started by ahmedbj, Jan 16, 2010.

Thread Status:
Not open for further replies.
  1. ahmedbj

    Thread Starter New Member

    Jan 16, 2010
    5
    0
    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
     
  2. retched

    AAC Fanatic!

    Dec 5, 2009
    5,201
    312
    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:
     
  3. ahmedbj

    Thread Starter New Member

    Jan 16, 2010
    5
    0
    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
     
  4. retched

    AAC Fanatic!

    Dec 5, 2009
    5,201
    312
    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.
     
  5. retched

    AAC Fanatic!

    Dec 5, 2009
    5,201
    312
    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.
     
  6. retched

    AAC Fanatic!

    Dec 5, 2009
    5,201
    312
    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
     
  7. ahmedbj

    Thread Starter New Member

    Jan 16, 2010
    5
    0
    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
     
  8. ahmedbj

    Thread Starter New Member

    Jan 16, 2010
    5
    0
    and i'm not good with batch
     
  9. retched

    AAC Fanatic!

    Dec 5, 2009
    5,201
    312
    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:
    Code ( (Unknown Language)):
    1. cd\windows
    2. 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.
     
  10. beenthere

    Retired Moderator

    Apr 20, 2004
    15,815
    282
    As the OP seems interested mainly in porn, we will end this thread.
     
Loading...
Thread Status:
Not open for further replies.