CS609 Assignment 3 Solution Spring 2017

The objective of this assignment is to provide hands-on experience of:

§ Understanding system programming concepts including accessing hard disk and reading its contents using BIOS

§ Hands on experience of using Virtual Box and working with DOS environment


As in the case with previous two assignments, you should use Virtual Box and run Windows 98 on it to solve this assignment. Instructions of how to install Virtual Box and Windows 98 are given in Announcement page and Downloads section of this course.

For any query about the assignment, contact at CS609@vu.edu.pk

Problem Statement:
Write a C program that will access your hard disk, read its contents, and then write these contents in a file.

1) In this program, you will use biosdisk() function to access and read hard disk. It accepts a total of 7 parameters; their details are given below:
2) command parameter should be 2, which indicates that you want to read from the hard disk
3) Drive number will be fixed to 0x80 which indicate that you want to access first fixed hard disk
4) Head number, Track number and Sector number will be provided at runtime by the user. The program should prompt the user to enter these values. During execution of the program, give following values to these parameters:
 Head Number = 1
 Track Number = 1
 Sector Number = 1
5) Buffer size should be fixed to 512 bytes
6) The name of the file on which data from hard disk will be written, should also be provided at run time by the user. During execution, you must give your VUID as file name. Also, open the file in write binary mode.
7) After invoking biosdisk() function, you have to check high byte of its return code to see if reading the specified hard disk area was successful or not. If high byte contains 0, it means function was successful. Only then you should write data on the file
8) In either case, (successful or unsuccessful) print a message accordingly: e.g. “Data is successfully written” or “Error in reading disk” etc.
9) After execution, navigate to the Bin folder and highlight newly created file (single click on the file) by your name and take screenshot. There’s no need to open the file. As we’re using Virtual Box and Windows 98, this file’s location will be C:\CS609\BorlandC\Bin
10) Your solution file will be a single Word file containing 3 things:
I. Complete code written in Word
II. Screenshot of the program after complete execution (use getchar() function to temporarily halt the screen)
III. Screenshot of generated file as described in instruction number 9