473,322 Members | 1,401 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,322 software developers and data experts.

using c how to read the boot sctor of floppy disk

2
how to read the boot sector of a floppy disk
Dec 31 '18 #1
3 1882
Luuk
1,047 Expert 1GB
Untested code found by Googling for "c code read boot sector":

source: https://stackoverflow.com/questions/...-c-on-windows8
Expand|Select|Wrap|Line Numbers
  1. int lire_secteur(int num_sect,unsigned char* buf)
  2. {
  3. int retCode = 0;
  4. unsigned char secteur[512];
  5. char disque[10]   ;
  6. char partition ;
  7. FILE* device ;
  8. do
  9. {
  10.     disque[0]='\0'  ;       
  11.     scanf("%c",&partition) ;
  12.     if (partition=='0')
  13.     {
  14.         strcpy(disque,"\\\\.\\PHYSICALDRIVE0") ;
  15.     }
  16.     else
  17.     {
  18.         sprintf(disque,"\\\\.\\%c:",partition) ;
  19.     }
  20.     device = fopen(disque, "rb+");
  21. }
  22.  
  23. while (device == NULL) ;
  24. fseek( device,num_sect*512 , SEEK_SET );
  25. if (fread (secteur, 512,1, device) < 1)
  26. {
  27.     printf("erreur\n");
  28.     return 1 ;
  29. }
  30. else
  31. {
  32.     memcpy(buf,secteur, 512);
  33.     retCode=0;
  34. }
  35. return retCode;
  36. }
Dec 31 '18 #2
Luuk
1,047 Expert 1GB
But 'floppy disk', what's that? 😒😒
It's almost 2019 😊😊

And floppies are soo 1980's.... 😉
Dec 31 '18 #3
dks1
2
That's as maybe. But i find them very handy for storing specific data and programs. Also they are a totally secure way of passing information (by post) to like minded people.

Thank you for your solution - I look forward to trying it.

Best wihes, dks
Dec 31 '18 #4

Sign in to post your reply or Sign up for a free account.

Similar topics

1
by: geek589 | last post by:
i am writing an os with it's own file system, and i need some way to format my disks from windows. for this i need to write directly to the disk. i have tried may methods, but failed. please...
1
by: cfyam | last post by:
When my app copy some files to floppy disk, how can to determine the time to show the message to inform user to take the disk off?
1
by: temir_gal | last post by:
Good evening! I can't read the sector's from floppy in Win98 OS. My application is 32-capacity and that's why I can't use interrupts. At the same time HANDLE hFile1 = CreateFile( "\\\\.\\A:",...
3
by: morellik | last post by:
Dear all, I'm a newbie of JS. I'm starting to write a web application that has some fields where I want to put an help icon. When the user click on the icon, appears a new little browser with...
14
by: chance | last post by:
Hello, I have a file on disk called TEMP.ZIP and I would like to somehow get this into a memory stream so I can eventually do this: row = dataStream.ToArray() However, I am not sure of the...
2
by: OgaW | last post by:
Hi, Floppy Disk Drive Does Not Appear in the My Computer Folder? Under the device manager, the resources tab shows that no resources allocated cos it has a problem. This device cannot start....
15
by: CMOS | last post by:
one of the projects im working in currently requires use of ultra large sized maps, lists, vector, etc. (basically stl containers). Sizes might grow up to 1000 Million entries. since it is...
13
by: giannakis | last post by:
Hi, I want to read the whole hard disk by using c/c++. I don't want to access only the "visible" files, but also the deleted files (the survived files). Is it possible? How can I achieve it? I'm...
7
by: Sanchit | last post by:
My program is #include <fcntl.h> #include <unistd.h> int main(void) { int fd; ssize_t nread; char buf; /*open file for reading */
1
by: pmonte | last post by:
I have a service that can be configured using a simple xml file. When the service starts it reads this xml. I'd need to change the xml config file while the service is running (no probs so far) and...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.