Homemade tool to write data from file to disk image
Homemade tool to write data from file to disk image
Hi,
As I didn't find any simple tool to write a bootloader or some other data to disk images for Bochs or something, I made my own. Comes in handy while I don't have file system and user space properly implemented. It just takes a file and writes it (fully or not) to an image made by bximage from Bochs, etc at a given offset.
I just put it here in case anyone finds it useful and to get some feedfack because I didn't test it extensively so please report bugs.
Windows x64 cmd app
Cheers,
Luís
As I didn't find any simple tool to write a bootloader or some other data to disk images for Bochs or something, I made my own. Comes in handy while I don't have file system and user space properly implemented. It just takes a file and writes it (fully or not) to an image made by bximage from Bochs, etc at a given offset.
I just put it here in case anyone finds it useful and to get some feedfack because I didn't test it extensively so please report bugs.
Windows x64 cmd app
Cheers,
Luís
- Attachments
-
- diskwrite.zip
- (4.35 KiB) Downloaded 117 times
Last edited by Luis on Fri Mar 29, 2013 5:00 pm, edited 1 time in total.
- Combuster
- Member
- Posts: 9301
- Joined: Wed Oct 18, 2006 3:45 am
- Libera.chat IRC: [com]buster
- Location: On the balcony, where I can actually keep 1½m distance
- Contact:
Re: Homemade tool to write data from file to disk image
There's this stock tool that many people here use for that purpose. Comes with both msys and cygwin for windows users, and has the additional feature that it's not strictly limited to disk images.
Re: Homemade tool to write data from file to disk image
I've seen it but I can't use it because I don't have disk space for cygwin and besides I never liked to use cygwin, I prefer the real Linux which I can't have at the moment. Thanks anyway
Re: Homemade tool to write data from file to disk image
When I had a 85Mb IBM hard drive in my PS/1 machine there was just enough space for the stripped-down copy of Windows 95, Borland C++ 3.1 compiler and IDE and a few small-ish DOS games.Luis wrote:because I don't have disk space for cygwin
Learn to read.
Re: Homemade tool to write data from file to disk image
I also wrote a simple tool that does everything I need. Currently I use it to make disk images with proper file systems. It can combine files and make modifications at any offsets. The tool takes input line by line and it can be used directly by typing "commands" or redirecting commands from so called script files.
Example script file (script.txt):
Usage:
Of course there are drawbacks and I do not claim it is a perfect tool. However, I really like it.
Source Code for Collector
Script for creating an ISO 9660 El Torito CD
Example script file (script.txt):
Code: Select all
# Comments are allowed
. = 16 # Offset is zero by default but can be changed
=some/path/file.bin # Include this file here (offset is incremented accordingly)
# Edit the beginning of the file
. = 16 # Set offset again
S$ "ABCD" # S$ is for strings
4$ 0x10 # Little endian 4byte
4$ 0x10, 4, 0x2 # Three little endian 4bytes
4$B 0x10 # Big endiand 4byte
4$L 0x10 # Explicit little endian 4byte (same as without 'L')
1.5$ 1,2,3,4 # Four 1.5 bytes (used for FAT 12, always little endian)
D$ SOME_DEFINE # Use builtin define ("SOME_DEFINE" is not available)
. = 0x1000 # Set offset again
=some/path/another.bin # Include this file here (offset is incremented accordingly)
Code: Select all
Usage: ./Collector <file size>
Example: ./Collector 0x8000 < script.txt > final.img
Source Code for Collector
Script for creating an ISO 9660 El Torito CD
Re: Homemade tool to write data from file to disk image
looks like a cross between assembly and a linker scriptAntti wrote:Code: Select all
# Comments are allowed . = 16 # Offset is zero by default but can be changed =some/path/file.bin # Include this file here (offset is incremented accordingly) # Edit the beginning of the file . = 16 # Set offset again S$ "ABCD" # S$ is for strings 4$ 0x10 # Little endian 4byte 4$ 0x10, 4, 0x2 # Three little endian 4bytes 4$B 0x10 # Big endiand 4byte 4$L 0x10 # Explicit little endian 4byte (same as without 'L') 1.5$ 1,2,3,4 # Four 1.5 bytes (used for FAT 12, always little endian) D$ SOME_DEFINE # Use builtin define ("SOME_DEFINE" is not available) . = 0x1000 # Set offset again =some/path/another.bin # Include this file here (offset is incremented accordingly)
Programming is 80% Math, 20% Grammar, and 10% Creativity <--- Do not make fun of my joke!
If you're new, check this out.
If you're new, check this out.
Re: Homemade tool to write data from file to disk image
partcopy.exe is quite common amongst os-developers on windows.
Re: Homemade tool to write data from file to disk image
I just use flat images.
Programming is 80% Math, 20% Grammar, and 10% Creativity <--- Do not make fun of my joke!
If you're new, check this out.
If you're new, check this out.
- Love4Boobies
- Member
- Posts: 2111
- Joined: Fri Mar 07, 2008 5:36 pm
- Location: Bucharest, Romania
Re: Homemade tool to write data from file to disk image
Is it? I don't know anyone to actually use it, only that it came up a few years ago on #osdev due to some tutorial. I remember that the problem (s)he encountered turned out to be a limitation in the utility---it choked on files exceeding some rather small size. That means it is only useful for floppy disk images (which no one seriously uses anymore) and toy images.bubach wrote:partcopy.exe is quite common amongst os-developers on windows.
Most developers under Windows use Cygwin, which provides a dd implementation---the standard and more powerful tool for the job.
"Computers in the future may weigh no more than 1.5 tons.", Popular Mechanics (1949)
[ Project UDI ]
[ Project UDI ]