help-gplusplus
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

writing on boot sector


From: zak100
Subject: writing on boot sector
Date: Fri, 26 Jun 2009 23:16:04 -0700 (PDT)

Hi,
I have got a 'C' laguage to write on boot sector. When I excute it, nothing
happens and the disk data remains the same. On the other hand assembly
language version is wroking fine. Can somebody help me plz:


#include  /* unistd.h needs this */
#include     /* contains read/write */
#include 

int main()
{
        char boot_buf[512];
        int floppy_desc, file_desc;
 
        
        file_desc = open("./boot", O_RDONLY);
        read(file_desc, boot_buf, 510);
        close(file_desc);
        
        boot_buf[510] = 0x55;
        boot_buf[511] = 0xaa;

        floppy_desc = open("/dev/fd0", O_RDWR);
        lseek(floppy_desc, 0, SEEK_CUR);
        write(floppy_desc, boot_buf, 512);
        close(floppy_desc);
}

I am working on windows XP and I am using gcc compiler:MinGW-5.1.4
Zulfi.
-- 
View this message in context: 
http://www.nabble.com/writing-on-boot-sector-tp24230734p24230734.html
Sent from the gcc - Gnu Help List mailing list archive at Nabble.com.





reply via email to

[Prev in Thread] Current Thread [Next in Thread]