Jump to content

how to name a file

- - - - -

  • Please log in to reply
7 replies to this topic

#1
vampire

vampire

    Newbie

  • Members
  • Pip
  • 5 posts
wondering how to make a file in assembly language program, that will be kept in one of the file folders so you can click on it after or open it in a hex editor. And in the assembly language program get to name the file like for example asm.ple a ple file or whatever.

on a seperate note how does one find out where a certain file is stored in memory as far as what segment adresss and offset the code of the file starts at and is the names code stored right before that?

#2
RhetoricalRuvim

RhetoricalRuvim

    JavaScript Programmer

  • Members
  • PipPipPipPipPipPipPipPip
  • 1,252 posts
  • Location:C:\Countries\US
You're being too general. What is the execution environment and platform that your program is going to be running on? How much access do you want to the file?

#3
vampire

vampire

    Newbie

  • Members
  • Pip
  • 5 posts
well, the platform is windows xp, i want to be able to make a new file in the assebly program, it will write new data from old data, i want the new data to be contained within a file that i can click on like any other file in the computer. Like a .bmp file or an .exe all of those files have binary to them and i want to know how to make a new one of those in assembly language and decide witch extension it has and it's name then write it's data.

so then after i can use the file.

an example program i might write, analyses the code of a binary and dependant on what the codes patterns are mathmatically there is a perfect mathimatical pattern for a dll that goes with it naturally the best possible dll mathimaticall that matchs the patterns of the binary and then write the dll file for the program. aka it creates a new file , a dll something something dot dll and write the data, then i can find that file, the dll, in a folder. so as far as access i want normal access as much access as any other file on the computer.

i just find that when you program in assembly you can write to any segment and offset adress it's just i want what i ewrite to be in a file for what my purposes are and my assembly book doesn't explain how to do that.

---------- Post added at 07:20 PM ---------- Previous post was at 07:12 PM ----------

if you wanna know my big project, it is a pattern analyzer and auto completer, with auto make of extention files that are the matimatically best binarily pattern wise for the the pattern of the binary of the program, then you don't have to write the whole thing and get types off file with extentions you have never even heard of. anyways, i might not of explained it properly but it is the god of programs and it has yet to be wrtten and it is pretty easy, but will take me doing it on my own a bit of time. i personally know what binarys i want allready it is just putting down every code individually will take forever so if i make a code writing program that you put in the pattern of the cbainary you want the binary patterns you want it does all the code automatically. i believe this tool will evolve the market for those who know how to read binary directly like i do for you can think of 10000 pages of binary code you want in a momenrt and they have patterns so for us it will be just putting in the mathimatical patterns of the code we want to get those 10000 sheets of binary in a short time instead of typing each hex digit out one at a time till we forget the whole thing we were trying to type

#4
RhetoricalRuvim

RhetoricalRuvim

    JavaScript Programmer

  • Members
  • PipPipPipPipPipPipPipPip
  • 1,252 posts
  • Location:C:\Countries\US
Try the Win32 API file I/O functions.

I write an example program in my assembly tutorial about file I/O here:
http://forum.codecal...win32-nasm.html


By the way, you can also use C for file I/O and reading/writing from/to specific offsets, by using binary open mode along with the fseek () function.

Instead of this:
fopen ("myfile.bmp", "r"); 
, you would want to use this:
fopen ("myfile.bmp", "rb"); 
; the extra 'b' tells fopen () that you want to work with a binary file, rather than a text file. Also, you want to use fread () and fwrite (), instead of fgets (), etc., because fgets () and similar functions are mostly not binary-friendly. fclose () is the same.

fseek (file_handle, offset_to_go_to, FILE_SET /* beginning of the file */); 
is the syntax for jumping to a particular position in a file.


Just saying, you can use assembly language for this - I'm not saying anything against it - but if seeking inside the file and binary I/O is the thing that makes you use assembly, you can still use C for that stuff.

#5
vampire

vampire

    Newbie

  • Members
  • Pip
  • 5 posts
Thanks, i am trying to avoid api's or already programmed routine and program it right from scratch so that i have every operation in my control, i am pretty sure there is a way without using ank you for giving me the way you know how, maybe i can find the source code for the api and it will tell the api, for api's are just premade code. For some api's are great for otheres they like to make their own code, i understand you are an api guy, one sticks to what one knows, , I appriciate your help and the time you invested in giving me a response, I will use the api's if i can't find the way to code it myself.

---------- Post added at 07:35 AM ---------- Previous post was at 07:29 AM ----------

if anyone else knows how to do it without api's or whatever, please post answer here. it should be somthing simple just like setting a destination for storage of data byte anywhere you set the segment and offset to. since you can just find out where a file is stored and write directly over it's data or read it's data. shpould be simple i think, instead of having to rely on api's.

#6
RhetoricalRuvim

RhetoricalRuvim

    JavaScript Programmer

  • Members
  • PipPipPipPipPipPipPipPip
  • 1,252 posts
  • Location:C:\Countries\US
I think you're getting it wrong: Win32 API is not a high-level optional type of thing; it's required for any program that wants to be Win32-friendly. So using the Win32 API is the lowest level you can get to.

One thing you could try is using direct access to the drive, but you'll still have to use Win32 API even for that. Here's a link if you want to try that:
this (use the first search result (the one that says "INFO: Direct Drive Access Under Win32"))
or this:
INFO: Direct Drive Access Under Win32

I don't know if it'll let you access the main hard drive, though, because it wouldn't make sense for it to.

If you want total control/access, including the "talking to the hardware" part, you'll probably need to write an executive, save it on a flash drive or floppy disk or compact disk, and boot it rather than the normal Windows XP operating system you use.

But note, though, that for these 2 latter methods, you'll need to learn how to handle the filesystem, and also, you'd want to test everything in a virtual machine, and make sure it works, before actually doing it on the actual computer; I don't want to be liable if your computer's filesystem goes corrupt and you have to re-install the operating system (I think this happened to my math teacher's computer, some time ago, when he was trying to program in assembly language and made a mistake).

#7
Alexander

Alexander

    It's Science!

  • Moderators
  • 4,118 posts
  • Location:Vancouver, Eh! Cleverness: 200

vampire said:



if anyone else knows how to do it without api's or whatever, please post answer here. it should be somthing simple just like setting a destination for storage of data byte anywhere you set the segment and offset to. since you can just find out where a file is stored and write directly over it's data or read it's data. shpould be simple i think, instead of having to rely on api's.

Think: Why would the processor have the ability to access the harddisk and write files? Those instructions would complicate the design so much, especially due to the fact there are many file systems.

Unless you have direct hardware access (maybe not possible in XP) then you likely cannot do it without the operating system's help. If that control was there, then viruses would have a fun time ruining your day be being able to access everything and anything it wants.
Be sure to read the updated FAQ! || Health is achieved through the same 10,000 steps.
If a suggested code/method fails, informing us is less important than telling us why or what errors occurred.

#8
RhetoricalRuvim

RhetoricalRuvim

    JavaScript Programmer

  • Members
  • PipPipPipPipPipPipPipPip
  • 1,252 posts
  • Location:C:\Countries\US
That's probably at least one of the reasons why boot viruses are dangerous. I wonder if there are any ones that pretend that they load the operating system, but whatever.

In case you would like to write your own operating system or executive, supernovah.com and wiki.osdev.org are good resources, especially the latter.

Here's a link to a page with links to how to access the hardware directly (from a processor input/output privilege level of 0, I think; or was it 3?):
Category:ATA - OSDev Wiki

The ATA PIO mode is probably the easiest to start off with, but it's also probably the worst method for a multi-tasking operating system.


Here's a link to a page with links to information about different filesystems:
Category:Filesystems - OSDev Wiki

Edited by dargueta, 19 December 2011 - 11:44 PM.
Double-posted





1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users