home *** CD-ROM | disk | FTP | other *** search
/ Power-Programmierung / CD1.mdf / magazine / drdobbs / 1989 / 06 / doscal.asc < prev    next >
Text File  |  1989-05-27  |  4KB  |  147 lines

  1. _UNDOCUMENTED DOS_
  2. by Rahner James
  3.  
  4. [LISTING ONE]
  5.  
  6. ; *********************************************************************
  7.  
  8. ;            DATA STRUCTURES
  9.  
  10. ; *********************************************************************
  11.  
  12.  
  13. CALL52_2XX    struc
  14.  
  15. dpb_ptr    dd    ?        ; Far ptr to first disk parameter block
  16. open_file_ptr    dd    ?        ; Far ptr to Open File table
  17. clock_ptr    dd    ?        ; Far ptr to CLOCK$ device driver
  18. con_ptr    dd    ?        ; Far ptr to CON: device driver
  19.  
  20. num_drives_2xx    db    ?        ; Number of logical drives
  21. sector_sz_2xx    dw    ?        ; Maximum sector size
  22. buffer_ptr_2xx    dd    ?        ; Far pointer to next sector buffer
  23. NUL_driver_2xx    db    ?        ; Beginning of the NUL device driver
  24.  
  25. CALL52_2XX    ends
  26.  
  27.  
  28. CALL52_3XX    struc
  29.  
  30.         dd    4 dup(?)    ; This are defined in previous structure
  31.  
  32. sector_sz_3xx    dw    ?        ; Maximum sector size
  33. buffer_ptr_3xx    dd    ?        ; Far pointer to next sector buffer
  34. path_ptr_3xx    dd    ?        ; Far pointer to drive path table
  35. FCB_ptr_3xx    dd    ?        ; Far pointer to FCB table
  36. FCB_sz_3xx    dw    ?        ; Size of the FCB table
  37. num_drives_3xx    db    ?        ; Number of logical drives
  38. lastdrive    db    ?        ; LASTDRIVE number
  39. NUL_driver_3xx    db    ?        ; Beginning of the NUL device driver
  40.  
  41. CALL52_3XX    ends
  42.  
  43.  
  44. ; *********************************************************************
  45.  
  46. ; MODIFY_DOS
  47. ;
  48. ; Changes MS-DOS's internal maximum sector size and buffer linked list
  49. ; to allow MS-DOS to access partitions above 32-megabytes
  50. ;
  51. ; Given:
  52. ;    BIGGEST_SECTOR set to largest logical sector of all partitions
  53. ;    DOS_VERSION = major version of MS-DOS
  54. ;    OLD_FILE_END -> initial end of driver
  55. ;
  56. ; Returns:
  57. ;    TRASH_PTR set to new end of program
  58. ;    MS-DOS's internal maximum sector setting changed
  59. ;    MS-DOS's internal linked buffer list relocated
  60.  
  61. ; *********************************************************************
  62.  
  63.  
  64. modify_dos proc uses ax ds di si
  65. local    sect_para_size:word
  66. local    buffer_paragraph:word
  67.     mov    ax, offset old_file_end    ; Get pointer to old end of file
  68.     add    ax, 15            ; Change it to a segment number so we
  69.     mov    cl, 4            ; only have to deal with a 16-bit number
  70.     shr    ax, cl
  71.     mov    bx, cs
  72.     add    ax, bx            ; AX -> paragraph start
  73.     mov    buffer_paragraph, ax    ; Save it for later
  74.  
  75.     mov    ax, biggest_sector    ; AX = size of buffer we may need to
  76.                     ;      allocate
  77.     add    ax, 10h            ; The buffer header too
  78.     shr    ax, cl            ; Change bytes/sector to paras/sector
  79.     mov    sect_para_size, ax    ; Save for later
  80.  
  81.     mov    ah, 52h            ; Our undocumented system call
  82.     int    21h            ; Set ES:BX -> DOS list of lists
  83.     mov    di, buffer_paragraph    ; DI -> beg. of initialization trash
  84.  
  85.     mov    si, sector_sz_2xx    ; SI = offset to version 2.xx sector size
  86.     cmp    dos_version, 2        ; See if version 2.xx
  87.     je    @F            ; Skip if it is
  88.     mov    si, sector_sz_3xx    ; SI = offset to version 3.xx sector size
  89.  
  90. @@:    mov    cx, es:[bx+si]        ; CX = the largest block size supported
  91.  
  92.     cmp    cx, biggest_sector    ; See if we need to change anything
  93.     jnc    done            ; Jump if we don't need to
  94.  
  95.     mov    cx, biggest_sector    ; Update DOS with the new largest
  96.     add    bx, si            ; BX -> sector size variable
  97.     mov    es:[bx], cx        ; Update maximum sector size w/our sector
  98.     add    bx, 2            ; Buffer pointer is right after for
  99.                     ; both versions
  100.     mov    dx, cs
  101. @@:    mov    si, bx            ; DS:SI = ES:BX
  102.     mov    ax, es
  103.     mov    ds, ax
  104.  
  105.     les    bx, dword ptr es:[bx]    ; ES:BX -> next buffer in list
  106.     cmp    bx, -1            ; Are we at the end
  107.     je    done            ; Quit if we are
  108.     mov    byte ptr es:[bx+4], -1    ; Set the nasty buffer flag
  109.  
  110.     mov    ax, bx            ; Calculate absolute memory placement
  111.     mov    cl, 4
  112.     shr    ax, cl
  113.     mov    cx, es
  114.     add    ax, cx
  115.     cmp    ax, dx            ; See if we are above or below the line
  116.     ja    @B            ; Loop again if already done this buffer
  117.  
  118.     les    bx, dword ptr es:[bx]
  119.     xchg    si, bx            ; xchg es:bx, ds:si
  120.     push    es
  121.     mov    ax, ds
  122.     mov    es, ax
  123.     pop    ds
  124.  
  125.     mov    word ptr es:[bx], 0    ; Previous buffer -> this one
  126.     mov    es:[bx+2], di
  127.     push    es
  128.     mov    es, di
  129.     mov    es:[0], si        ; This one -> what previous did
  130.     mov    es:[2], ds
  131.     mov    byte ptr es:[4], -1    ; Tell DOS this hasn't been used yet
  132.     pop    es
  133.     add    di, sect_para_size    ; DI -> next buffer start
  134.  
  135.     cmp    si, -1            ; See if we are at end of list
  136.     je    done            ; Quit if we are
  137.     mov    bx, si            ; ES:BX -> next buffer in line
  138.     mov    ax, ds
  139.     mov    es, ax
  140.     jmp    @B
  141.  
  142. done:    mov    cs:trash_pointer, di    ; New end of program
  143.     ret
  144. modify_dos    endp
  145.  
  146.  
  147.