1 ////////////////////////////////////////////////////////////////////
2 // Copyright (C) Alexander Telyatnikov, Ivan Keliukh, Yegor Anchishkin, SKIF Software, 1999-2013. Kiev, Ukraine
4 // This file was released under the GPLv2 on June 2015.
5 ////////////////////////////////////////////////////////////////////
7 #ifndef __UDF_PHYS_LIB__H__
8 #define __UDF_PHYS_LIB__H__
10 #ifndef UDF_FORMAT_MEDIA
11 extern BOOLEAN open_as_device
;
12 extern BOOLEAN opt_invalidate_volume
;
13 extern ULONG LockMode
;
14 #endif //UDF_FORMAT_MEDIA
16 extern NTSTATUS
UDFSyncCache(
24 IN
void* Buffer
, // Target buffer
34 IN
void* Buffer
, // Target buffer
37 OUT uint32
* WrittenBytes
,
44 IN
void* Buffer
, // Target buffer
47 OUT uint32
* ReadBytes
,
51 extern OSSTATUS
UDFTRead(PVOID _Vcb
,
52 PVOID Buffer
, // Target buffer
58 extern OSSTATUS
UDFTWrite(IN PVOID _Vcb
,
59 IN PVOID Buffer
, // Target buffer
62 OUT PULONG WrittenBytes
,
65 #define PH_TMP_BUFFER 1
66 #define PH_VCB_IN_RETLEN 2
67 #define PH_LOCK_CACHE 0x10000000
69 #define PH_EX_WRITE 0x80000000
70 #define PH_IO_LOCKED 0x20000000
79 extern OSSTATUS
UDFPrepareForWriteOperation(
84 extern OSSTATUS
UDFReadDiscTrackInfo(PDEVICE_OBJECT DeviceObject
, // the target device object
85 PVCB Vcb
); // Volume Control Block for ^ DevObj
87 extern OSSTATUS
UDFReadAndProcessFullToc(PDEVICE_OBJECT DeviceObject
, // the target device object
90 extern OSSTATUS
UDFUseStandard(PDEVICE_OBJECT DeviceObject
, // the target device object
91 PVCB Vcb
); // Volume control block fro this DevObj
93 extern OSSTATUS
UDFGetBlockSize(PDEVICE_OBJECT DeviceObject
, // the target device object
94 PVCB Vcb
); // Volume control block fro this DevObj
96 extern OSSTATUS
UDFGetDiskInfo(IN PDEVICE_OBJECT DeviceObject
, // the target device object
97 IN PVCB Vcb
); // Volume control block from this DevObj
99 extern VOID
UDFEjectReqWaiter(IN PVOID Context
);
101 extern VOID
UDFStopEjectWaiter(PVCB Vcb
);
103 extern OSSTATUS
UDFPrepareForReadOperation(IN PVCB Vcb
,
107 //#define UDFPrepareForReadOperation(a,b) (STATUS_SUCCESS)
109 extern VOID
UDFUpdateNWA(PVCB Vcb
,
114 extern OSSTATUS
UDFDoDismountSequence(IN PVCB Vcb
,
115 IN PPREVENT_MEDIA_REMOVAL_USER_IN Buf
,
118 // read physical sectors
119 /*OSSTATUS UDFReadSectors(IN PVCB Vcb,
120 IN BOOLEAN Translate,// Translate Logical to Physical
125 OUT PULONG ReadBytes);*/
126 #define UDFReadSectors(Vcb, Translate, Lba, BCount, Direct, Buffer, ReadBytes) \
127 (( WCacheIsInitialized__(&((Vcb)->FastCache)) && (KeGetCurrentIrql() < DISPATCH_LEVEL)) ? \
128 (WCacheReadBlocks__(&((Vcb)->FastCache), Vcb, Buffer, Lba, BCount, ReadBytes, Direct)) : \
129 (UDFTRead(Vcb, Buffer, (BCount)<<((Vcb)->BlockSizeBits), Lba, ReadBytes, 0)))
132 // read data inside physical sector
133 extern OSSTATUS
UDFReadInSector(IN PVCB Vcb
,
134 IN BOOLEAN Translate
, // Translate Logical to Physical
136 IN ULONG i
, // offset in sector
137 IN ULONG l
, // transfer length
140 OUT PULONG ReadBytes
);
141 // read unaligned data
142 extern OSSTATUS
UDFReadData(IN PVCB Vcb
,
143 IN BOOLEAN Translate
, // Translate Logical to Physical
148 OUT PULONG ReadBytes
);
150 #ifndef UDF_READ_ONLY_BUILD
151 // write physical sectors
152 OSSTATUS
UDFWriteSectors(IN PVCB Vcb
,
153 IN BOOLEAN Translate
, // Translate Logical to Physical
156 IN BOOLEAN Direct
, // setting this flag delays flushing of given
157 // data to indefinite term
159 OUT PULONG WrittenBytes
);
160 // write directly to cached sector
161 OSSTATUS
UDFWriteInSector(IN PVCB Vcb
,
162 IN BOOLEAN Translate
, // Translate Logical to Physical
164 IN ULONG i
, // offset in sector
165 IN ULONG l
, // transfer length
168 OUT PULONG WrittenBytes
);
169 // write data at unaligned offset & length
170 OSSTATUS
UDFWriteData(IN PVCB Vcb
,
171 IN BOOLEAN Translate
, // Translate Logical to Physical
174 IN BOOLEAN Direct
, // setting this flag delays flushing of given
175 // data to indefinite term
177 OUT PULONG WrittenBytes
);
178 #endif //UDF_READ_ONLY_BUILD
180 OSSTATUS
UDFResetDeviceDriver(IN PVCB Vcb
,
181 IN PDEVICE_OBJECT TargetDeviceObject
,
185 #endif //__UDF_PHYS_LIB__H__