1 //////////////////////////////////////////////////////////////////// 2 // Copyright (C) Alexander Telyatnikov, Ivan Keliukh, Yegor Anchishkin, SKIF Software, 1999-2013. Kiev, Ukraine 3 // All rights reserved 4 // This file was released under the GPLv2 on June 2015. 5 //////////////////////////////////////////////////////////////////// 6 7 #ifndef __UDF_PHYS_LIB__H__ 8 #define __UDF_PHYS_LIB__H__ 9 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 15 16 extern NTSTATUS UDFSyncCache( 17 IN PVCB Vcb 18 ); 19 20 OSSTATUS 21 __fastcall 22 UDFTIOVerify( 23 IN void* _Vcb, 24 IN void* Buffer, // Target buffer 25 IN SIZE_T Length, 26 IN uint32 LBA, 27 OUT PSIZE_T IOBytes, 28 IN uint32 Flags 29 ); 30 31 extern OSSTATUS 32 UDFTWriteVerify( 33 IN void* _Vcb, 34 IN void* Buffer, // Target buffer 35 IN SIZE_T Length, 36 IN uint32 LBA, 37 OUT PSIZE_T WrittenBytes, 38 IN uint32 Flags 39 ); 40 41 extern OSSTATUS 42 UDFTReadVerify( 43 IN void* _Vcb, 44 IN void* Buffer, // Target buffer 45 IN SIZE_T Length, 46 IN uint32 LBA, 47 OUT PSIZE_T ReadBytes, 48 IN uint32 Flags 49 ); 50 51 extern OSSTATUS UDFTRead(PVOID _Vcb, 52 PVOID Buffer, // Target buffer 53 SIZE_T Length, 54 ULONG LBA, 55 PSIZE_T ReadBytes, 56 ULONG Flags = 0); 57 58 extern OSSTATUS UDFTWrite(IN PVOID _Vcb, 59 IN PVOID Buffer, // Target buffer 60 IN SIZE_T Length, 61 IN ULONG LBA, 62 OUT PSIZE_T WrittenBytes, 63 IN ULONG Flags = 0); 64 65 #define PH_TMP_BUFFER 1 66 #define PH_VCB_IN_RETLEN 2 67 #define PH_LOCK_CACHE 0x10000000 68 69 #define PH_EX_WRITE 0x80000000 70 #define PH_IO_LOCKED 0x20000000 71 72 73 extern 74 OSSTATUS 75 UDFDoOPC( 76 IN PVCB Vcb 77 ); 78 79 extern OSSTATUS UDFPrepareForWriteOperation( 80 IN PVCB Vcb, 81 IN ULONG Lba, 82 IN ULONG BCount); 83 84 extern OSSTATUS UDFReadDiscTrackInfo(PDEVICE_OBJECT DeviceObject, // the target device object 85 PVCB Vcb); // Volume Control Block for ^ DevObj 86 87 extern OSSTATUS UDFReadAndProcessFullToc(PDEVICE_OBJECT DeviceObject, // the target device object 88 PVCB Vcb); 89 90 extern OSSTATUS UDFUseStandard(PDEVICE_OBJECT DeviceObject, // the target device object 91 PVCB Vcb); // Volume control block fro this DevObj 92 93 extern OSSTATUS UDFGetBlockSize(PDEVICE_OBJECT DeviceObject, // the target device object 94 PVCB Vcb); // Volume control block fro this DevObj 95 96 extern OSSTATUS UDFGetDiskInfo(IN PDEVICE_OBJECT DeviceObject, // the target device object 97 IN PVCB Vcb); // Volume control block from this DevObj 98 99 extern VOID NTAPI UDFEjectReqWaiter(IN PVOID Context); 100 101 extern VOID UDFStopEjectWaiter(PVCB Vcb); 102 103 extern OSSTATUS UDFPrepareForReadOperation(IN PVCB Vcb, 104 IN uint32 Lba, 105 IN uint32 BCount 106 ); 107 //#define UDFPrepareForReadOperation(a,b) (STATUS_SUCCESS) 108 109 extern VOID UDFUpdateNWA(PVCB Vcb, 110 ULONG LBA, 111 ULONG BCount, 112 OSSTATUS RC); 113 114 extern OSSTATUS UDFDoDismountSequence(IN PVCB Vcb, 115 IN PPREVENT_MEDIA_REMOVAL_USER_IN Buf, 116 IN BOOLEAN Eject); 117 118 // read physical sectors 119 /*OSSTATUS UDFReadSectors(IN PVCB Vcb, 120 IN BOOLEAN Translate,// Translate Logical to Physical 121 IN ULONG Lba, 122 IN ULONG BCount, 123 IN BOOLEAN Direct, 124 OUT PCHAR Buffer, 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, ((SIZE_T)(BCount))<<((Vcb)->BlockSizeBits), Lba, ReadBytes, 0))) 130 131 132 // read data inside physical sector 133 extern OSSTATUS UDFReadInSector(IN PVCB Vcb, 134 IN BOOLEAN Translate, // Translate Logical to Physical 135 IN ULONG Lba, 136 IN ULONG i, // offset in sector 137 IN ULONG l, // transfer length 138 IN BOOLEAN Direct, 139 OUT PCHAR Buffer, 140 OUT PSIZE_T ReadBytes); 141 // read unaligned data 142 extern OSSTATUS UDFReadData(IN PVCB Vcb, 143 IN BOOLEAN Translate, // Translate Logical to Physical 144 IN LONGLONG Offset, 145 IN ULONG Length, 146 IN BOOLEAN Direct, 147 OUT PCHAR Buffer, 148 OUT PSIZE_T ReadBytes); 149 150 #ifndef UDF_READ_ONLY_BUILD 151 // write physical sectors 152 OSSTATUS UDFWriteSectors(IN PVCB Vcb, 153 IN BOOLEAN Translate, // Translate Logical to Physical 154 IN ULONG Lba, 155 IN ULONG WBCount, 156 IN BOOLEAN Direct, // setting this flag delays flushing of given 157 // data to indefinite term 158 IN PCHAR Buffer, 159 OUT PSIZE_T WrittenBytes); 160 // write directly to cached sector 161 OSSTATUS UDFWriteInSector(IN PVCB Vcb, 162 IN BOOLEAN Translate, // Translate Logical to Physical 163 IN ULONG Lba, 164 IN ULONG i, // offset in sector 165 IN ULONG l, // transfer length 166 IN BOOLEAN Direct, 167 OUT PCHAR Buffer, 168 OUT PSIZE_T WrittenBytes); 169 // write data at unaligned offset & length 170 OSSTATUS UDFWriteData(IN PVCB Vcb, 171 IN BOOLEAN Translate, // Translate Logical to Physical 172 IN LONGLONG Offset, 173 IN SIZE_T Length, 174 IN BOOLEAN Direct, // setting this flag delays flushing of given 175 // data to indefinite term 176 IN PCHAR Buffer, 177 OUT PSIZE_T WrittenBytes); 178 #endif //UDF_READ_ONLY_BUILD 179 180 OSSTATUS UDFResetDeviceDriver(IN PVCB Vcb, 181 IN PDEVICE_OBJECT TargetDeviceObject, 182 IN BOOLEAN Unlock); 183 184 185 #endif //__UDF_PHYS_LIB__H__ 186