flat assembler
Message board for the users of flat assembler.

Index > OS Construction > How do I make a USB bootloader?

Author
Thread Post new topic Reply to topic
Coddy41



Joined: 18 Jan 2009
Posts: 384
Location: Ohio, USA
Coddy41 09 Feb 2009, 21:50
I want to make a FAT USB boot loader to load my kernel.com only because I am tired of
making a program on my laptop putting in on a USB, going to my HP putting in on a floppy,
taking it to my old pc (that I don't care about) and testing my kernel.

ps I will use it only to test my kernel and to learn from.

_________________
Want hosting for free for your asm project? You can PM me. (*.fasm4u.net)
Post 09 Feb 2009, 21:50
View user's profile Send private message Visit poster's website Reply with quote
revolution
When all else fails, read the source


Joined: 24 Aug 2004
Posts: 20451
Location: In your JS exploiting you and your system
revolution 10 Feb 2009, 02:22
Use a VM for rapid testing.
Post 10 Feb 2009, 02:22
View user's profile Send private message Visit poster's website Reply with quote
Coddy41



Joined: 18 Jan 2009
Posts: 384
Location: Ohio, USA
Coddy41 10 Feb 2009, 16:38
But, I have Linux, And i like to test under real term conditions
Post 10 Feb 2009, 16:38
View user's profile Send private message Visit poster's website Reply with quote
revolution
When all else fails, read the source


Joined: 24 Aug 2004
Posts: 20451
Location: In your JS exploiting you and your system
revolution 11 Feb 2009, 00:32
You don't have to test it live every time, right? Just once every few iterations should be appropriate.
Post 11 Feb 2009, 00:32
View user's profile Send private message Visit poster's website Reply with quote
bitRAKE



Joined: 21 Jul 2003
Posts: 4073
Location: vpcmpistri
bitRAKE 12 Feb 2009, 05:13
It is possible to write directly to USB drive sectors:
http://shounen.ru/soft/flashnul/
(includes source code in C++, easy to convert to FASM - something like:
Code:
drv_name TCHAR '\\.\PhysicalDrive6',0 ; G:\

nStart = 0
pData file "floppy.img"
nData = $ - pData

    align 16
hDevice rq 1
lpBytesReturned rq 1


    invoke CreateFile,drv_name,GENERIC_READ|GENERIC_WRITE,\
            FILE_SHARE_READ|FILE_SHARE_WRITE,NULL,OPEN_EXISTING,0,NULL
  cmp rax,INVALID_HANDLE_VALUE
        je .cannot_open_drive
       mov [hDevice],rax

       invoke DeviceIoControl,[hDevice],FSCTL_ALLOW_EXTENDED_DASD_IO,\
            NULL,0,NULL,0,lpBytesReturned,NULL
  test eax,eax ; BOOL
 je .no_extended

 invoke SetFilePointerEx,[hDevice],nStart,NULL,FILE_BEGIN
    test eax,eax ; BOOL
 je .no_seek

     invoke WriteFile,[hDevice],pData,nData,lpBytesReturned,NULL
 test eax,eax ; BOOL
 je .no_write

    invoke CloseHandle,[hDevice]
        retn


.no_write:
.no_seek:
.no_extended:
        invoke CloseHandle,[hDevice]
.no_open_drive:
        ; print error message
        retn    
Code untested.)

Be careful though: some BIOS' only support floppy or hard disk emulation of USB devices.
Hard disks need a partition table with an active partition (which are emulated on some USB sticks?).
Post 12 Feb 2009, 05:13
View user's profile Send private message Visit poster's website Reply with quote
bitRAKE



Joined: 21 Jul 2003
Posts: 4073
Location: vpcmpistri
bitRAKE 12 Feb 2009, 06:19
Under Linux I hear it's even easier to write sectors to a USB stick.
Sorry, just noticed you were not working with Windows.
Post 12 Feb 2009, 06:19
View user's profile Send private message Visit poster's website Reply with quote
Coddy41



Joined: 18 Jan 2009
Posts: 384
Location: Ohio, USA
Coddy41 12 Feb 2009, 16:17
That ok I have XP on my old desktop but I have Ubuntu on my used to be vista laptop Smile

ha ha, the web site is in Russian, I was going to try to learn Germen but know most things I
need seem to be in Russian...
Post 12 Feb 2009, 16:17
View user's profile Send private message Visit poster's website Reply with quote
egos



Joined: 10 Feb 2009
Posts: 144
egos 13 Feb 2009, 12:41
This program is first of all intended for testing of the USB flashes, not for editing. I like HxD for this purpose: HxD web site.
USB flush has same structure as a hard drive, including MBR with partition table. You can use same MBR and FAT16/32 partition boot loaders if they implement work with EDD service.
Post 13 Feb 2009, 12:41
View user's profile Send private message Reply with quote
Coddy41



Joined: 18 Jan 2009
Posts: 384
Location: Ohio, USA
Coddy41 14 Feb 2009, 22:15
I'll just use this http://home.gna.org/bless/
Post 14 Feb 2009, 22:15
View user's profile Send private message Visit poster's website Reply with quote
Display posts from previous:
Post new topic Reply to topic

Jump to:  


< Last Thread | Next Thread >
Forum Rules:
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


Copyright © 1999-2025, Tomasz Grysztar. Also on GitHub, YouTube.

Website powered by rwasa.