1 | $COMPILE EXE
|
---|
2 |
|
---|
3 | Type LINUXIMG_13EXT_ControlType
|
---|
4 | SizePaket as WORD
|
---|
5 | NumBlocks as WORD
|
---|
6 | Transfer as DWORD
|
---|
7 | Absolut as DWORD
|
---|
8 | Absolut2 as DWORD
|
---|
9 | End Type
|
---|
10 |
|
---|
11 | Dim LINUXIMG_13EXT_Control as shared LINUXIMG_13EXT_ControlType
|
---|
12 | Dim LINUXIMG_13EXT_ControlPtr as shared DWORD
|
---|
13 | LINUXIMG_13EXT_ControlPtr = VarPtr32(LINUXIMG_13EXT_Control)
|
---|
14 | LINUXIMG_13EXT_Control.SizePaket = &h10
|
---|
15 |
|
---|
16 | ! mov ah, &h41
|
---|
17 | ! mov bx, &h55AA
|
---|
18 | ! mov dl, &h80
|
---|
19 | ! int &h13
|
---|
20 | ! cmp bx, &h0AA55
|
---|
21 | ! je LINUXIMG_13EXT_Found
|
---|
22 | LINUXIMG_13EXT_NotFound:
|
---|
23 | print "þ INT 13h Extensions not found, you won't need this tool"
|
---|
24 | end
|
---|
25 |
|
---|
26 | LINUXIMG_13EXT_Found:
|
---|
27 | ! and cx, 1
|
---|
28 | ! jz LINUXIMG_13EXT_NotFound
|
---|
29 | print "þ INT 13h Extensions found"
|
---|
30 |
|
---|
31 | AbsPartitionBegin??? = 2618595
|
---|
32 | 'AbsPartitionBegin??? = 16065+63
|
---|
33 | BootRecord$ = LINUXIMG_13EXT_ReadSector (&h80, AbsPartitionBegin???)
|
---|
34 | SectorsPerCluster? = CvByt(BootRecord$,14)
|
---|
35 | ReservedSectors?? = CvWrd(BootRecord$,15)
|
---|
36 | FATcopies? = CvByt(BootRecord$,17)
|
---|
37 | NumOfRootEntries?? = CvWrd(BootRecord$,18)
|
---|
38 | SectorsPerFAT?? = CvWrd(BootRecord$,23)
|
---|
39 | print ReservedSectors??, FATcopies?, NumOfRootEntries??, SectorsPerFAT??, SectorsPerCluster?
|
---|
40 |
|
---|
41 | FATstart??? = AbsPartitionBegin???+ReservedSectors??
|
---|
42 | RootStart??? = FATstart???+(FATcopies?*SectorsPerFAT??)
|
---|
43 | ClusterStart??? = RootStart???+NumOfRootEntries??/16
|
---|
44 |
|
---|
45 | CurEntry?? = 0: RootSector?? = 0
|
---|
46 | Do
|
---|
47 | RootTable$ = LINUXIMG_13EXT_ReadSector (&h80, RootStart???+RootSector??)
|
---|
48 | LocalEntry?? = 0
|
---|
49 | Do
|
---|
50 | If Mid$(RootTable$,LocalEntry??*32+1,11) = "KERNELS " Then
|
---|
51 | KernelDirFound% = -1
|
---|
52 | else
|
---|
53 | Incr LocalEntry??
|
---|
54 | End If
|
---|
55 | Loop Until KernelDirFound% or LocalEntry??=>16
|
---|
56 | Incr RootSector??: Incr CurEntry??, 16
|
---|
57 | if inkey$<>"" Then End
|
---|
58 | Loop Until KernelDirFound% or CurEntry??=NumOfRootEntries??
|
---|
59 |
|
---|
60 | If KernelDirFound% Then
|
---|
61 | DirFlags? = CvByt(RootTable$,LocalEntry??*32+12)
|
---|
62 | If DirFlags?=&h10 Then print "Valid Directory!"
|
---|
63 | ClusterStart?? = CvWrd(RootTable$,LocalEntry??*32+27)
|
---|
64 | print "Cluster start: ";ClusterStart??
|
---|
65 | print "Next Cluster: ";GetNextCluster(FATstart???, ClusterStart??)
|
---|
66 |
|
---|
67 | DirCluster$ = GetClusterData (ClusterStart???, SectorsPerCluster?, ClusterStart??)
|
---|
68 | ClusterStart?? = CvWrd(DirCluster$,2*32+27)
|
---|
69 | print GetClusterData (ClusterStart???, SectorsPerCluster?, ClusterStart??)
|
---|
70 | End If
|
---|
71 | end
|
---|
72 |
|
---|
73 | Function GetClusterData (byval ClusterStart???, byval SectorsPerCluster?, byval ClusterNo??) as STRING
|
---|
74 | ClusterPos??? = (ClusterNo??-2)*SectorsPerCluster?
|
---|
75 |
|
---|
76 | ClusterData$ = LINUXIMG_13EXT_ReadSector (&h80, ClusterStart???+ClusterPos???)
|
---|
77 | FUNCTION = ClusterData$
|
---|
78 | End Function
|
---|
79 |
|
---|
80 | Function GetNextCluster (byval FATstart???, byval CurCluster??) as WORD
|
---|
81 | FATpos?? = (CurCluster?? mod 256)
|
---|
82 | FATsector?? = (CurCluster??-FATpos??)/256
|
---|
83 | FATpos?? = FATpos??*2
|
---|
84 |
|
---|
85 | FATtable$ = LINUXIMG_13EXT_ReadSector (&h80, FATstart???+FATsector??)
|
---|
86 | NextCluster?? = CvWrd(FATtable$, FATpos??+1)
|
---|
87 |
|
---|
88 | FUNCTION = NextCluster??
|
---|
89 | End Function
|
---|
90 |
|
---|
91 | Function LINUXIMG_13EXT_ReadSector (byval Harddrive??, byval BlockNo???) as STRING
|
---|
92 | local MyBlock$
|
---|
93 | MyBlock$ = String$(512,0)
|
---|
94 | LINUXIMG_13EXT_Control.NumBlocks = 1
|
---|
95 | LINUXIMG_13EXT_Control.Transfer = StrPtr32(MyBlock$)
|
---|
96 | LINUXIMG_13EXT_Control.Absolut = BlockNo???
|
---|
97 | ! push ds
|
---|
98 | ! mov dl, Harddrive??
|
---|
99 | ! lds si, LINUXIMG_13EXT_ControlPtr
|
---|
100 | ! mov ah, &h42
|
---|
101 | ! int &h13
|
---|
102 | ! pop ds
|
---|
103 | ! jc LINUXIMG_13EXT_Error
|
---|
104 | FUNCTION = MyBlock$
|
---|
105 | Exit Function
|
---|
106 |
|
---|
107 | LINUXIMG_13EXT_Error:
|
---|
108 | print "Error in partition-table/Bad sector on harddisc."
|
---|
109 | end
|
---|
110 | End Function
|
---|
111 |
|
---|
112 | Sub LINUXIMG_13EXT_WriteSectors (byval Harddrive??, byval BlockNo???, byval DataBlock$)
|
---|
113 | local MyBlock$
|
---|
114 | If len(DataBlock$)<5120 Then
|
---|
115 | DataBlock$ = DataBlock$ + String$(5120-len(DataBlock$),0)
|
---|
116 | End If
|
---|
117 | LINUXIMG_13EXT_Control.NumBlocks = 10
|
---|
118 | LINUXIMG_13EXT_Control.Transfer = StrPtr32(DataBlock$)
|
---|
119 | LINUXIMG_13EXT_Control.Absolut = BlockNo???
|
---|
120 | ! push ds
|
---|
121 | ! mov dl, Harddrive??
|
---|
122 | ! lds si, LINUXIMG_13EXT_ControlPtr
|
---|
123 | ! mov ah, &h43 ; Write !
|
---|
124 | ! int &h13
|
---|
125 | ! pop ds
|
---|
126 | ! jc LINUXIMG_13EXT_ErrorWrite
|
---|
127 | Exit Sub
|
---|
128 |
|
---|
129 | LINUXIMG_13EXT_ErrorWrite:
|
---|
130 | print "Error, while writing to disc."
|
---|
131 | end
|
---|
132 | End Sub
|
---|