This is my code, you can try it, I have run it without problems:
#include <stdio.h>
#include <conio.h>
#include <process.h>
#include <bios.h>
#include <dos.h>
#include <math.h>
#include <dir.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include <sys/stat.h>
#include <sys/movedata.h>
#include <go32.h>
#include <dpmi.h>
#define HANDLE_PRAGMA_PACK_PUSH_POP 1
#pragma pack(push,1)
typedef struct
{
unsigned char PacketSize; /* Packet size (16 bytes) */
unsigned char Reserved1; /* Set to 0 */
unsigned char BlockCount; /* Number of data blocks to transfer (in sectors) */
unsigned char Reserved2; /* Set to 0 */
unsigned short BufferAddrOFF; /* Buffer offset address */
unsigned short BufferAddrSEG; /* Buffer segment address */
unsigned long long LBA; /* Absolute block address on disk start */
}
DiskAddressPacket;
#pragma pack(pop)
/* Use extended 13 interrupt to read and write large hard drives */
int ExInt13(char cmd, char driveNum, unsigned long startSector, int sectorNum, char buf[])
{
__dpmi_regs reg;
DiskAddressPacket DAP_package;
memset(&DAP_package, 0, sizeof(DiskAddressPacket));
DAP_package.PacketSize = sizeof(DiskAddressPacket);
DAP_package.BlockCount = sectorNum;
DAP_package.BufferAddrOFF = __tb & 0x0F;
DAP_package.BufferAddrSEG = __tb >> 4;
DAP_package.LBA = startSector;
dosmemput(&DAP_package, sizeof(DiskAddressPacket), __tb + 512 * sectorNum);
reg.h.ah = cmd;
reg.h.dl = driveNum;
reg.h.al = 0; /* 0 for no write check, 1 for with */
reg.x.ds = (__tb + 512 * sectorNum) >> 4;
reg.x.si = (__tb + 512 * sectorNum) & 0x0F;
__dpmi_int(0x13, ®);
if((reg.x.flags & 0x0001) == 0)
{
dosmemget(__tb, 512 * sectorNum, buf);
return 0;
}
else
return(reg.h.ah);
}
int main(void)
{
int i, result, temp;
unsigned long log_sector;
char buf[512];
char s[5];
scanf("%lu", &log_sector); /* Enter sector number */
result = ExInt13(0x42, 0x80, log_sector, 1, buf); /* Read disk sector */
if (result!= 0) /* Determine if operation is successful */
{
perror("Read Disk Error"); /* If not successful, display error */
exit(1);
}
printf("Read OK\n"); /* If successful, display "ok" */
for (i=446; i<512; i++) /* Loop to read partition table */
{
if(buf[i] < 0) /* Convert negative ASCII values to positive */
temp = buf[i] + 256;
else
temp = buf[i];
sprintf(s, "%x", temp); /* Convert partition table content to hexadecimal format */
if(temp < 16)
printf("0%s", s); /* Output display */
else
printf("%s", s);
printf(" ");
if((i==461)||(i==477)||(i==493)||(i==509))
printf("\n");
}
getch();
return(0);
}