Retro video games delivered to your door every month!
Click above to get retro games delivered to your door ever month!
X-Hacker.org- Peter Norton Programmer's Guide - Norton Guide http://www.X-Hacker.org [<<Previous Entry] [^^Up^^] [Next Entry>>] [Menu] [About The Guide]

  The following sample routine reads the volume serial number from a DOS
  version 4 disk. It illustrates how to use the DOS version 4 extended
  interrupt 25H function, and shows how the additional information in the
  DOS version 4 boot sector is structured.

  main()
  {
          unsigned char   Buffer [512];
          unsigned long * LongPointer;

          int             DriveID = 2;            /* drive c */



          struct
          {
            \037H>Zned long SectorNumber;         /* 4 bytes */
            unsigned int  Count;                  /* 2 bytes */
            void far *    BufferPointer;          /* 4 bytes */
          }
                  ControlPacket;


          /* initialize control packet */
          ControlPacket.SectorNumber = 0;
          ControlPacket.Count = 1;
          ControlPacket.BufferPointer = (char far *)Buffer;

          /* read the DOS boot sector */
          ReadAbs( DriveID, &ControlPacket );


          /* display the volume serial number if it's there */
          if( Buffer[0x26] == 0x29 )              /* check the signature */
          {
            LongPointer = (long *) (Buffer+0x27);
            printf( "\nThe volume serial number is %081X", *LongPointer );
          }

          else
            printf( "\nNo volume serial number" );
  }




  _TEXT           SEGMENT byte public 'CODE'
                  ASSUME  cs:_TEXT


                  PUBLIC  _ReadAbs
  _ReadAbs        PROC    near

                  push    bp
                  mov     bp,sp
                  push    si
                  push    di

  ; (a call to int 21h func 47h will be inserted here)

                  mov     al,[bp+4]       ; AL = drive ID
                  mov     bx,[bp+6]       ; DS:BX -> control packet
                  mov     cx,-1
                  int     25h             ; absolute disk read

                  mov     ax,0            ; return AX = value of ...
                  adc     ax,0            ; ... carry flag


                  add     sp,2            ; discard flags pushed by DOS

                  pop     di
                  pop     si

                  pop     bp
                  ret

  _ReadAbs        ENDP

  _TEXT           ENDS

Online resources provided by: http://www.X-Hacker.org --- NG 2 HTML conversion by Dave Pearson