forked from redcode/SpecEmu
-
Notifications
You must be signed in to change notification settings - Fork 0
/
atapi.asm
118 lines (97 loc) · 4.43 KB
/
atapi.asm
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
include atapi.inc
.data?
align 4
atapi_dllmodule dd ?
atapi_available db ?
atapiprocscount db ?
atapiprocsfound db ?
.code
Atapi_LoadDLL PROTO
Atapi_UnloadDLL PROTO
GetAtapiProcAddress PROTO lpFncName: DWORD
Atapi_RemoveUnit PROTO :BYTE
Atapi_IsAttached PROTO :BYTE
GetDLLProc macro fncname:REQ
.data?
align 4
f&fncname& dd ?
.code
mov f&fncname&, $fnc (DLLPROC, SADD("&fncname&"))
endm
Atapi_LoadDLL proc
mov atapi_available, FALSE
mov atapi_dllmodule, $fnc (LoadLibrary, SADD("atapi.dll"))
.if eax != NULL
mov atapiprocscount, 0
mov atapiprocsfound, 0
DLLPROC equ <GetAtapiProcAddress>
GetDLLProc IDE_Initialise
GetDLLProc IDE_ShutDown
GetDLLProc IDE_HardwareReset
GetDLLProc IDE_SelectHDF
GetDLLProc IDE_CloseHDFFiles
GetDLLProc IDE_CloseHDFFile
GetDLLProc IDE_WriteData
GetDLLProc IDE_WriteFeature
GetDLLProc IDE_WriteSectorCount
GetDLLProc IDE_WriteSectorNumber
GetDLLProc IDE_WriteCylinderLow
GetDLLProc IDE_WriteCylinderHigh
GetDLLProc IDE_WriteDrive_Head
GetDLLProc IDE_WriteCommand
GetDLLProc IDE_ReadData
GetDLLProc IDE_ReadError
GetDLLProc IDE_ReadSectorCount
GetDLLProc IDE_ReadSectorNumber
GetDLLProc IDE_ReadCylinderLow
GetDLLProc IDE_ReadCylinderHigh
GetDLLProc IDE_ReadDrive_Head
GetDLLProc IDE_ReadStatus
GetDLLProc IDE_GetHDFSectorSize
GetDLLProc IDE_SetHDFAccessSize
; set 'atapi_available' to True if all atapi.dll functions located
mov al, atapiprocscount
.if al == atapiprocsfound
mov atapi_available, TRUE
.endif
.endif
return atapi_available
Atapi_LoadDLL endp
GetAtapiProcAddress proc lpFncName: DWORD
inc atapiprocscount ; increment procs searched counter
invoke GetProcAddress, atapi_dllmodule, lpFncName
.if eax != NULL
inc atapiprocsfound ; increment procs found counter
.endif
ret
GetAtapiProcAddress endp
Atapi_UnloadDLL proc
.if atapi_dllmodule != NULL
invoke FreeLibrary, atapi_dllmodule
.endif
ret
Atapi_UnloadDLL endp
Atapi_RemoveUnit proc Unit: BYTE
switch Unit
case 0
IDE_CloseHDFFile IDEHandle, 0
case 1
IDE_CloseHDFFile IDEHandle, 1
endsw
ret
Atapi_RemoveUnit endp
Atapi_IsAttached proc Unit: BYTE
switch Unit
case 0
IDE_GetHDFSectorSize IDEHandle, 0
.if eax != 0
return TRUE
.endif
case 1
IDE_GetHDFSectorSize IDEHandle, 1
.if eax != 0
return TRUE
.endif
endsw
return FALSE
Atapi_IsAttached endp