mbr

Modifying the MBR of Windows

I need to modify the MBR of Windows, and I would really like to do this from Windows. Here are my questions. I know that I can get a handle on a physical device with a call to CreateFile. Will the MBR always be on \\.\PHYSICALDRIVE0? Also, I'm still learning the Windows API to read directly from the disk. Is readabsolutesectors and writ...

How to tell which disk Windows Used to Boot

Hi, I'm need to find a method to programmatically determine which disk drive Windows is using to boot. In other words, I need a way from Windows to determine which drive the BIOS is using to boot the whole system. Does Windows expose an interface to discover this? With how big the Windows API is, I'm hoping there is something buried i...

Convert a GTP disk to MBR from XP

So I took some files with me on my external HDD while going on vacation. Through a series of events, I ended up storing the data in a NTFS formatted partition defined in a GUID Partition Table. The only computer I have is a Windows XP home box, which does not have native support for reading GPT's. So far everything I have read online ...

How to create file with help of P/Invoke to read boot sector and display .MBR?

I've browsed through the CreateFile documentation... still wondering how should I use P/Invoke to call CreateFile and to read the boot sector, to display out the .MBR? Any reference code for this portion? Thank you in advance! ...

Write MBR Code

I am an electrical engineer who has recently discovered the need to modify the code in the MBR. Basically I need the ability to execute code on the HDD before, the OS starts up and takes over. I fully understand that this will need to be written in Assembly and given the 446 bytes or so of code space in the MBR I just expect to call ot...

Dual booting Windows 2k3 Server and Linux MBR

I have Windows Server 2003 and Linux installed on one hard drive [on separate partitions]. My first partition is the linux boot partition, and maintains Grub. When I boot the Windows partition and shutdown W2k3 keeps modifying the MBR to boot directly, and only to the Windows partition. How do I prevent this behavior? I rather like using...

What information does BIOS load into RAM?

I know that, on booting, BIOS loads the first sector (512 bytes) of a pre-defined device drive on memory 0x7c00 and then jump to that address. So, memory from 0x7c00 to 0x7dff is occupied. Is there any other section of RAM that is occupied? If I'm programming an Operating System, could I use all the RAM except 0x7c00 to ox7dff for my o...

winapi c - read/write mbr of system drive

Does anyone have any example code that shows how to identify the system boot harddisk, and read/write the mbr from the harddisk in windows xp and vista? I know createfile can be used. But I do not know how to properly identify which device is the boot device. Like how do you find out which ones you are meant to use? \.\Volume{GUID}\...

Where to find the source code for a PC MBR Bootloader?

Preferably well comment and with some associated docmentation and a Makefile. Just for clearity, that's the less than 512 bytes (512 bytes - partition table) of machine code that gets loaded by the Bios and is responsible for chaining to the secondary bootloader in your boot partition. Edit: Both David's and bdonlan's answers look prom...

How do I disassemble raw x86 code?

I'd like to disassemble the MBR (first 512 bytes) of a bootable x86 disk that I have. I have copied the MBR to a file using dd if=/dev/my-device of=mbr bs=512 count=1 Any suggestions for a Linux utility that can disassemble the file mbr? ...

MBR says Invalid partition table - But system works! WHY?

I have been given an end of term project to write an assembly code to read the MBR and save it to floppy. I think I managed to read it with INT 13h in DOS in a virtualBox machine. The machine has only one hard disk with one partition with XP installed. When I read the MBR and print it, it gives me a whole lot of junk and amongst the jun...

What Assembly Instructions Live In the Master Boot Record?

Curious about what explicit assembly instructions actually make up the Master Boot Record on an X86 architecture. Thanks for any insights. Other architectures welcome, but this is primarily for X86. ...

FASM vc MASM trasnlation problem in mov si, offset msg

hi folks, just did my first test with MASM and FASM with the same code (almos) and I falled in trouble. The only difference is that to produce just the 104 bytes I need to write to MBR in FASM I put org 7c00h and in MASM 0h. The problem is on the mov si, offset msg that in the first case transletes it to 44 7C (7c44h) and with masm ...

Problem with stack based implementation of function 0x42 of int 0x13

I'm trying a new approach to int 0x13 (just to learn more about the way the system works): using stack to create a DAP.. Assuming that DL contains the disk number, AX contains the address of the bootable entry in PT, DS is updated to the right segment and the stack is correctly set, this is the code: push DWORD 0x00000000 add ax, 0x00...

Change the mbr signature with dd

Hi, I use the linux kernel module CONFIG_EDD. I would change the mbr_signature, I can do that with the tool hexedit but I have to integrate in a script. I use this command: dd if=/dev/mydev bs=4 count=1 skip=110 | hexdump -e '"0x%08x\n"' to recover it without using the file (/sys/firmware/edd/...) created by EDD. I wonder how ...

USB programming as MBR Program

Hi I was wondering if it's possible for the MBR to read data from the USB port? I'm wanting it to load windows or linux depending on the value it's read from the usb port ...

Partitioning the filesystem on Android

I'm trying to re-partition an SDCard on Android, with root access. I have the 512 byte MBR file, and it shows up as this: Pos MBRndx Type/Name Size Active Hide Start Sector Sectors --- ------ ---------- ---- ------ ---- ------------ ------------ 0 0 0C-FAT32X 5.9G No No 64 12,124,096 1 1 0C-FAT3...