Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Write a file to "Sector 0" using C#? [duplicate]

Tags:

c#

bootloader

Possible Duplicate:
How can i put a compiled boot sector onto a USB stick or disk?

I'm busy creating a basic boot loader, it is for software that needs to run without an OS

I also want to write a small console app that moves the compiled bootloader to my SD card.

The problem I am running into is writing that specific boot loader to Sector0 on an SD card. The SD card is slotted into my SD Card slot on my laptop.

Can I accomplish this using a C# console app ? if not, what are my options on getting that boot loader on the SD card?

Update: The bootloader is written in C, I would like the console app that transfers the boot loader to be in C#

like image 925
stoic Avatar asked Jun 03 '12 20:06

stoic


2 Answers

You could use low level IO API to write a file to a specific sector. Have a look at WriteFile documentation for more info.

like image 173
GETah Avatar answered Nov 18 '22 07:11

GETah


A much easier idea would be to create an image file with your bootloader (and optionally, partition table and/or file systems) and use an external tool like dd or Image Writer to actually write the image to the SD card.

like image 1
Adam Maras Avatar answered Nov 18 '22 06:11

Adam Maras