ReactOS  0.4.13-dev-1148-g9b75b67
env_spec.cpp File Reference
#include "udffs.h"
Include dependency graph for env_spec.cpp:

Go to the source code of this file.

Macros

#define UDF_BUG_CHECK_ID   UDF_FILE_ENV_SPEC
 
#define MEASURE_IO_PERFORMANCE
 

Functions

NTSTATUS NTAPI UDFAsyncCompletionRoutine (IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp, IN PVOID Contxt)
 
NTSTATUS NTAPI UDFSyncCompletionRoutine (IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp, IN PVOID Contxt)
 
NTSTATUS NTAPI UDFPhReadSynchronous (PDEVICE_OBJECT DeviceObject, PVOID Buffer, SIZE_T Length, LONGLONG Offset, PSIZE_T ReadBytes, ULONG Flags)
 
NTSTATUS NTAPI UDFPhWriteSynchronous (PDEVICE_OBJECT DeviceObject, PVOID Buffer, SIZE_T Length, LONGLONG Offset, PSIZE_T WrittenBytes, ULONG Flags)
 
NTSTATUS NTAPI UDFTSendIOCTL (IN ULONG IoControlCode, IN PVCB Vcb, IN PVOID InputBuffer, IN ULONG InputBufferLength, OUT PVOID OutputBuffer, IN ULONG OutputBufferLength, IN BOOLEAN OverrideVerify, OUT PIO_STATUS_BLOCK Iosb OPTIONAL)
 
NTSTATUS NTAPI UDFPhSendIOCTL (IN ULONG IoControlCode, IN PDEVICE_OBJECT DeviceObject, IN PVOID InputBuffer, IN ULONG InputBufferLength, OUT PVOID OutputBuffer, IN ULONG OutputBufferLength, IN BOOLEAN OverrideVerify, OUT PIO_STATUS_BLOCK Iosb OPTIONAL)
 

Variables

LONGLONG IoReadTime =0
 
LONGLONG IoWriteTime =0
 
LONGLONG WrittenData =0
 
LONGLONG IoRelWriteTime =0
 

Macro Definition Documentation

◆ MEASURE_IO_PERFORMANCE

#define MEASURE_IO_PERFORMANCE

Definition at line 22 of file env_spec.cpp.

◆ UDF_BUG_CHECK_ID

#define UDF_BUG_CHECK_ID   UDF_FILE_ENV_SPEC

Definition at line 20 of file env_spec.cpp.

Function Documentation

◆ UDFAsyncCompletionRoutine()

NTSTATUS NTAPI UDFAsyncCompletionRoutine ( IN PDEVICE_OBJECT  DeviceObject,
IN PIRP  Irp,
IN PVOID  Contxt 
)

Definition at line 40 of file env_spec.cpp.

45 {
46  UDFPrint(("UDFAsyncCompletionRoutine ctx=%x\n", Contxt));
48  PMDL Mdl, NextMdl;
49 
50  Context->IosbToUse = Irp->IoStatus;
51 #if 1
52  // Unlock pages that are described by MDL (if any)...
53  Mdl = Irp->MdlAddress;
54  while(Mdl) {
55  MmPrint((" Unlock MDL=%x\n", Mdl));
56  MmUnlockPages(Mdl);
57  Mdl = Mdl->Next;
58  }
59  // ... and free MDL
60  Mdl = Irp->MdlAddress;
61  while(Mdl) {
62  MmPrint((" Free MDL=%x\n", Mdl));
63  NextMdl = Mdl->Next;
64  IoFreeMdl(Mdl);
65  Mdl = NextMdl;
66  }
67  Irp->MdlAddress = NULL;
68  IoFreeIrp(Irp);
69 
70  KeSetEvent( &(Context->event), 0, FALSE );
71 
73 #else
74  KeSetEvent( &(Context->event), 0, FALSE );
75 
76  return STATUS_SUCCESS;
77 #endif
78 } // end UDFAsyncCompletionRoutine()
#define UDFPrint(Args)
Definition: udffs.h:225
struct _UDF_PH_CALL_CONTEXT * PUDF_PH_CALL_CONTEXT
#define STATUS_MORE_PROCESSING_REQUIRED
Definition: shellext.h:63
_In_ PIRP Irp
Definition: csq.h:116
VOID NTAPI MmUnlockPages(IN PMDL Mdl)
Definition: mdlsup.c:1439
LONG NTAPI KeSetEvent(IN PKEVENT Event, IN KPRIORITY Increment, IN BOOLEAN Wait)
Definition: eventobj.c:159
smooth NULL
Definition: ftsmooth.c:416
#define MmPrint(_x_)
Definition: env_spec_w32.h:289
VOID NTAPI IoFreeMdl(PMDL Mdl)
Definition: iomdl.c:146
VOID NTAPI IoFreeIrp(IN PIRP Irp)
Definition: irp.c:1666
return STATUS_SUCCESS
Definition: btrfs.c:2966

Referenced by UDFPhReadSynchronous(), and UDFPhWriteSynchronous().

◆ UDFPhReadSynchronous()

NTSTATUS NTAPI UDFPhReadSynchronous ( PDEVICE_OBJECT  DeviceObject,
PVOID  Buffer,
SIZE_T  Length,
LONGLONG  Offset,
PSIZE_T  ReadBytes,
ULONG  Flags 
)

Definition at line 130 of file env_spec.cpp.

138 {
140  LARGE_INTEGER ROffset;
142  PIRP irp;
143  KIRQL CurIrql = KeGetCurrentIrql();
144  PVOID IoBuf = NULL;
145 // ULONG i;
146 #ifdef MEASURE_IO_PERFORMANCE
147  LONGLONG IoEnterTime;
148  LONGLONG IoExitTime;
149  ULONG dt;
150  ULONG dtm;
151 #endif //MEASURE_IO_PERFORMANCE
152 #ifdef _BROWSE_UDF_
153  PVCB Vcb = NULL;
154  if(Flags & PH_VCB_IN_RETLEN) {
155  Vcb = (PVCB)(*ReadBytes);
156  }
157 #endif //_BROWSE_UDF_
158 
159 #ifdef MEASURE_IO_PERFORMANCE
160  KeQuerySystemTime((PLARGE_INTEGER)&IoEnterTime);
161 #endif //MEASURE_IO_PERFORMANCE
162 
163  UDFPrint(("UDFPhRead: Length: %x Lba: %lx\n",Length>>0xb,Offset>>0xb));
164 // UDFPrint(("UDFPhRead: Length: %x Lba: %lx\n",Length>>0x9,Offset>>0x9));
165 
166  ROffset.QuadPart = Offset;
167  (*ReadBytes) = 0;
168 /*
169  // DEBUG !!!
170  Flags |= PH_TMP_BUFFER;
171 */
172  if(Flags & PH_TMP_BUFFER) {
173  IoBuf = Buffer;
174  } else {
175  IoBuf = DbgAllocatePoolWithTag(NonPagedPool, Length, 'bNWD');
176  }
177  if (!IoBuf) {
178  UDFPrint((" !IoBuf\n"));
180  }
182  if (!Context) {
183  UDFPrint((" !Context\n"));
185  }
186  // Create notification event object to be used to signal the request completion.
188 
189  if (CurIrql > PASSIVE_LEVEL) {
191  Length, &ROffset, &(Context->IosbToUse) );
192  if (!irp) {
193  UDFPrint((" !irp Async\n"));
195  }
196  MmPrint((" Alloc async Irp MDL=%x, ctx=%x\n", irp->MdlAddress, Context));
198  Context, TRUE, TRUE, TRUE );
199  } else {
201  Length, &ROffset, &(Context->event), &(Context->IosbToUse) );
202  if (!irp) {
203  UDFPrint((" !irp Sync\n"));
205  }
206  MmPrint((" Alloc Irp MDL=%x, ctx=%x\n", irp->MdlAddress, Context));
207  }
208 
210  RC = IoCallDriver(DeviceObject, irp);
211 
212  if (RC == STATUS_PENDING) {
213  DbgWaitForSingleObject(&(Context->event), NULL);
214  if ((RC = Context->IosbToUse.Status) == STATUS_DATA_OVERRUN) {
215  RC = STATUS_SUCCESS;
216  }
217 // *ReadBytes = Context->IosbToUse.Information;
218  } else {
219 // *ReadBytes = irp->IoStatus.Information;
220  }
221  if(NT_SUCCESS(RC)) {
222  (*ReadBytes) = Context->IosbToUse.Information;
223  }
224  if(!(Flags & PH_TMP_BUFFER)) {
225  RtlCopyMemory(Buffer, IoBuf, *ReadBytes);
226  }
227 
228  if(NT_SUCCESS(RC)) {
229 /*
230  for(i=0; i<(*ReadBytes); i+=2048) {
231  UDFPrint(("IOCRC %8.8x R %x\n", crc32((PUCHAR)Buffer+i, 2048), (ULONG)((Offset+i)/2048) ));
232  }
233 */
234 #ifdef _BROWSE_UDF_
235  if(Vcb) {
236  RC = UDFVRead(Vcb, IoBuf, Length >> Vcb->BlockSizeBits, (ULONG)(Offset >> Vcb->BlockSizeBits), Flags);
237  }
238 #endif //_BROWSE_UDF_
239  }
240 
241 try_exit: NOTHING;
242 
244  if(IoBuf && !(Flags & PH_TMP_BUFFER)) DbgFreePool(IoBuf);
245 
246 #ifdef MEASURE_IO_PERFORMANCE
247  KeQuerySystemTime((PLARGE_INTEGER)&IoExitTime);
248  IoReadTime += (IoExitTime-IoEnterTime);
249  dt = (ULONG)((IoExitTime-IoEnterTime)/10/1000);
250  dtm = (ULONG)(((IoExitTime-IoEnterTime)/10)%1000);
251  PerfPrint(("\nUDFPhReadSynchronous() exit: %08X, after %d.%4.4d msec.\n", RC, dt, dtm));
252 #else
253  UDFPrint(("UDFPhReadSynchronous() exit: %08X\n", RC));
254 #endif //MEASURE_IO_PERFORMANCE
255 
256  return(RC);
257 } // end UDFPhReadSynchronous()
#define KeQuerySystemTime(t)
Definition: env_spec_w32.h:570
#define KeGetCurrentIrql()
Definition: env_spec_w32.h:706
OSSTATUS UDFVRead(IN PVCB Vcb, IN void *Buffer, IN uint32 BCount, IN uint32 LBA, IN uint32 Flags)
Definition: remap.cpp:375
#define UDFPrint(Args)
Definition: udffs.h:225
struct _UDF_PH_CALL_CONTEXT * PUDF_PH_CALL_CONTEXT
#define TRUE
Definition: types.h:120
NTSYSAPI VOID NTAPI RtlCopyMemory(VOID UNALIGNED *Destination, CONST VOID UNALIGNED *Source, ULONG Length)
#define STATUS_INSUFFICIENT_RESOURCES
Definition: udferr_usr.h:158
#define STATUS_DATA_OVERRUN
Definition: udferr_usr.h:152
#define DbgAllocatePoolWithTag(a, b, c)
Definition: env_spec_w32.h:333
PIRP NTAPI IoBuildSynchronousFsdRequest(IN ULONG MajorFunction, IN PDEVICE_OBJECT DeviceObject, IN PVOID Buffer, IN ULONG Length, IN PLARGE_INTEGER StartingOffset, IN PKEVENT Event, IN PIO_STATUS_BLOCK IoStatusBlock)
Definition: irp.c:1069
LONG NTSTATUS
Definition: precomp.h:26
Definition: cdstruc.h:504
#define IoSetCompletionRoutine(_Irp, _CompletionRoutine, _Context, _InvokeOnSuccess, _InvokeOnError, _InvokeOnCancel)
Definition: irp.cpp:515
UCHAR KIRQL
Definition: env_spec_w32.h:591
_Must_inspect_result_ _In_ ULONG Flags
Definition: wsk.h:170
_In_ ULONG _In_ ULONG Offset
Definition: ntddpcm.h:101
NTSTATUS NTAPI UDFAsyncCompletionRoutine(IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp, IN PVOID Contxt)
Definition: env_spec.cpp:40
LONGLONG IoReadTime
Definition: env_spec.cpp:25
smooth NULL
Definition: ftsmooth.c:416
#define SL_OVERRIDE_VERIFY_VOLUME
Definition: iotypes.h:1780
Definition: bufpool.h:45
#define DbgWaitForSingleObject(o, to)
Definition: env_spec_w32.h:479
static NTSTATUS ReadBytes(IN PDEVICE_OBJECT LowerDevice, OUT PUCHAR Buffer, IN ULONG BufferSize, OUT PULONG_PTR FilledBytes)
Definition: detect.c:67
#define DbgFreePool
Definition: env_spec_w32.h:334
#define MyAllocatePool__(type, size)
Definition: mem_tools.h:149
int64_t LONGLONG
Definition: typedefs.h:66
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
#define STATUS_PENDING
Definition: ntstatus.h:82
#define try_return(S)
Definition: cdprocs.h:2189
#define Vcb
Definition: cdprocs.h:1425
#define MyFreePool__(addr)
Definition: mem_tools.h:152
PIRP NTAPI IoBuildAsynchronousFsdRequest(IN ULONG MajorFunction, IN PDEVICE_OBJECT DeviceObject, IN PVOID Buffer, IN ULONG Length, IN PLARGE_INTEGER StartingOffset, IN PIO_STATUS_BLOCK IoStatusBlock)
Definition: irp.c:750
#define PerfPrint(_x_)
Definition: env_spec_w32.h:291
#define MmPrint(_x_)
Definition: env_spec_w32.h:289
_In_ ULONG _In_ ULONG _In_ ULONG Length
Definition: ntddpcm.h:101
#define NOTHING
Definition: env_spec_w32.h:461
struct _VCB * PVCB
Definition: fatstruc.h:556
#define PASSIVE_LEVEL
Definition: env_spec_w32.h:693
__drv_aliasesMem FORCEINLINE PIO_STACK_LOCATION IoGetNextIrpStackLocation(_In_ PIRP Irp)
Definition: iofuncs.h:2647
#define PH_VCB_IN_RETLEN
Definition: phys_lib.h:66
IN PDEVICE_OBJECT DeviceObject
Definition: fatprocs.h:1560
#define KeInitializeEvent(pEvt, foo, foo2)
Definition: env_spec_w32.h:477
NTSTATUS NTAPI IoCallDriver(IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp)
Definition: irp.c:1218
#define PH_TMP_BUFFER
Definition: phys_lib.h:65
#define IRP_MJ_READ
Definition: rdpdr.c:46
struct tagContext Context
Definition: acpixf.h:1024
unsigned int ULONG
Definition: retypes.h:1
IN BOOLEAN OUT PSTR Buffer
Definition: progress.h:34
return STATUS_SUCCESS
Definition: btrfs.c:2966
LONGLONG QuadPart
Definition: typedefs.h:112

Referenced by UDFPrepareForReadOperation(), UDFTRead(), and UDFUseStandard().

◆ UDFPhSendIOCTL()

NTSTATUS NTAPI UDFPhSendIOCTL ( IN ULONG  IoControlCode,
IN PDEVICE_OBJECT  DeviceObject,
IN PVOID  InputBuffer,
IN ULONG  InputBufferLength,
OUT PVOID  OutputBuffer,
IN ULONG  OutputBufferLength,
IN BOOLEAN  OverrideVerify,
OUT PIO_STATUS_BLOCK Iosb  OPTIONAL 
)

Definition at line 511 of file env_spec.cpp.

521 {
523  PIRP irp;
526 
527  UDFPrint(("UDFPhDevIOCTL: Code %8x \n",IoControlCode));
528 
531  // Check if the user gave us an Iosb.
532 
533  // Create notification event object to be used to signal the request completion.
535 
538 
539  if (!irp) try_return (RC = STATUS_INSUFFICIENT_RESOURCES);
540  MmPrint((" Alloc Irp MDL=%x, ctx=%x\n", irp->MdlAddress, Context));
541 /*
542  if (KeGetCurrentIrql() > PASSIVE_LEVEL) {
543  UDFPrint(("Setting completion routine\n"));
544  IoSetCompletionRoutine( irp, &UDFSyncCompletionRoutine,
545  Context, TRUE, TRUE, TRUE );
546  }
547 */
548  if(OverrideVerify) {
550  }
551 
552  RC = IoCallDriver(DeviceObject, irp);
553 
554  if (RC == STATUS_PENDING) {
556  UDFPrint(("Enter wait state on evt %x\n", Context));
557 
559  timeout.QuadPart = -1000;
560  UDFPrint(("waiting, TO=%I64d\n", timeout.QuadPart));
561  RC = DbgWaitForSingleObject(&(Context->event), &timeout);
562  while(RC == STATUS_TIMEOUT) {
563  timeout.QuadPart *= 2;
564  UDFPrint(("waiting, TO=%I64d\n", timeout.QuadPart));
565  RC = DbgWaitForSingleObject(&(Context->event), &timeout);
566  }
567 
568  } else {
569  DbgWaitForSingleObject(&(Context->event), NULL);
570  }
571  if ((RC = Context->IosbToUse.Status) == STATUS_DATA_OVERRUN) {
572  RC = STATUS_SUCCESS;
573  }
574  UDFPrint(("Exit wait state on evt %x, status %8.8x\n", Context, RC));
575 /* if(Iosb) {
576  (*Iosb) = Context->IosbToUse;
577  }*/
578  } else {
579  UDFPrint(("No wait completion on evt %x\n", Context));
580 /* if(Iosb) {
581  (*Iosb) = irp->IoStatus;
582  }*/
583  }
584 
585  if(Iosb) {
586  (*Iosb) = Context->IosbToUse;
587  }
588 
589 try_exit: NOTHING;
590 
592  return(RC);
593 } // end UDFPhSendIOCTL()
#define KeGetCurrentIrql()
Definition: env_spec_w32.h:706
#define UDFPrint(Args)
Definition: udffs.h:225
struct _UDF_PH_CALL_CONTEXT * PUDF_PH_CALL_CONTEXT
#define STATUS_INSUFFICIENT_RESOURCES
Definition: udferr_usr.h:158
_Must_inspect_result_ _In_ PFILE_OBJECT _In_ ULONG IoControlCode
Definition: fltkernel.h:1383
#define STATUS_DATA_OVERRUN
Definition: udferr_usr.h:152
LONG NTSTATUS
Definition: precomp.h:26
_Must_inspect_result_ _In_ PFILE_OBJECT _In_ ULONG _In_ ULONG _In_ ULONG OutputBufferLength
Definition: fltkernel.h:1374
Definition: dhcpd.h:245
GLbitfield GLuint64 timeout
Definition: glext.h:7164
CHAR InputBuffer[80]
Definition: conmgr.c:33
#define STATUS_TIMEOUT
Definition: ntstatus.h:81
_Must_inspect_result_ _In_ ULONG Flags
Definition: wsk.h:170
smooth NULL
Definition: ftsmooth.c:416
#define SL_OVERRIDE_VERIFY_VOLUME
Definition: iotypes.h:1780
_Must_inspect_result_ __drv_aliasesMem _In_ PDEVICE_OBJECT _In_opt_ PVOID _In_ ULONG _Out_opt_ PVOID OutputBuffer
Definition: iofuncs.h:713
#define DbgWaitForSingleObject(o, to)
Definition: env_spec_w32.h:479
#define MyAllocatePool__(type, size)
Definition: mem_tools.h:149
return Iosb
Definition: create.c:4426
#define STATUS_PENDING
Definition: ntstatus.h:82
#define try_return(S)
Definition: cdprocs.h:2189
#define MyFreePool__(addr)
Definition: mem_tools.h:152
#define MmPrint(_x_)
Definition: env_spec_w32.h:289
ASSERT((InvokeOnSuccess||InvokeOnError||InvokeOnCancel) ?(CompletionRoutine !=NULL) :TRUE)
#define NOTHING
Definition: env_spec_w32.h:461
#define PASSIVE_LEVEL
Definition: env_spec_w32.h:693
__drv_aliasesMem FORCEINLINE PIO_STACK_LOCATION IoGetNextIrpStackLocation(_In_ PIRP Irp)
Definition: iofuncs.h:2647
_Must_inspect_result_ _In_ PFILE_OBJECT _In_ ULONG _In_ ULONG InputBufferLength
Definition: fltkernel.h:1372
#define DISPATCH_LEVEL
Definition: env_spec_w32.h:696
IN PDEVICE_OBJECT DeviceObject
Definition: fatprocs.h:1560
#define KeInitializeEvent(pEvt, foo, foo2)
Definition: env_spec_w32.h:477
NTSTATUS NTAPI IoCallDriver(IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp)
Definition: irp.c:1218
PIRP NTAPI IoBuildDeviceIoControlRequest(IN ULONG IoControlCode, IN PDEVICE_OBJECT DeviceObject, IN PVOID InputBuffer, IN ULONG InputBufferLength, IN PVOID OutputBuffer, IN ULONG OutputBufferLength, IN BOOLEAN InternalDeviceIoControl, IN PKEVENT Event, IN PIO_STATUS_BLOCK IoStatusBlock)
Definition: irp.c:881
struct tagContext Context
Definition: acpixf.h:1024
return STATUS_SUCCESS
Definition: btrfs.c:2966

Referenced by CheckCDType(), UDFCommonClose(), UDFDoDismountSequence(), UDFDoOPC(), UDFEjectReqWaiter(), UDFGetBlockSize(), UDFGetDiskInfo(), UDFInitializeVCB(), UDFMountVolume(), UDFPrepareForReadOperation(), UDFPrepareForWriteOperation(), UDFReadAndProcessFullToc(), UDFReadDiscTrackInfo(), UDFRecoverFromError(), UDFResetDeviceDriver(), UDFSetCaching(), UDFSetMRWMode(), UDFSetSpeeds(), UDFSyncCache(), UDFTSendIOCTL(), UDFUseStandard(), and UDFVerifyVolume().

◆ UDFPhWriteSynchronous()

NTSTATUS NTAPI UDFPhWriteSynchronous ( PDEVICE_OBJECT  DeviceObject,
PVOID  Buffer,
SIZE_T  Length,
LONGLONG  Offset,
PSIZE_T  WrittenBytes,
ULONG  Flags 
)

Definition at line 276 of file env_spec.cpp.

284 {
286  LARGE_INTEGER ROffset;
288  PIRP irp;
289 // LARGE_INTEGER timeout;
290  KIRQL CurIrql = KeGetCurrentIrql();
291  PVOID IoBuf = NULL;
292 // ULONG i;
293 #ifdef MEASURE_IO_PERFORMANCE
294  LONGLONG IoEnterTime;
295  LONGLONG IoExitTime;
296  ULONG dt;
297  ULONG dtm;
298 #endif //MEASURE_IO_PERFORMANCE
299 #ifdef _BROWSE_UDF_
300  PVCB Vcb = NULL;
301  if(Flags & PH_VCB_IN_RETLEN) {
302  Vcb = (PVCB)(*WrittenBytes);
303  }
304 #endif //_BROWSE_UDF_
305 
306 #ifdef MEASURE_IO_PERFORMANCE
307  KeQuerySystemTime((PLARGE_INTEGER)&IoEnterTime);
308 #endif //MEASURE_IO_PERFORMANCE
309 
310 #if defined UDF_DBG || defined USE_PERF_PRINT
311  ULONG Lba = (ULONG)(Offset>>0xb);
312 // ASSERT(!(Lba & (32-1)));
313  PerfPrint(("UDFPhWrite: Length: %x Lba: %lx\n",Length>>0xb,Lba));
314 // UDFPrint(("UDFPhWrite: Length: %x Lba: %lx\n",Length>>0x9,Offset>>0x9));
315 #endif //DBG
316 
317 #ifdef DBG
318  if(UDF_SIMULATE_WRITES) {
319 /* FIXME ReactOS
320  If this function is to force a read from the bufffer to simulate any segfaults, then it makes sense.
321  Else, this forloop is useless.
322  UCHAR a;
323  for(ULONG i=0; i<Length; i++) {
324  a = ((PUCHAR)Buffer)[i];
325  }
326 */
327  *WrittenBytes = Length;
328  return STATUS_SUCCESS;
329  }
330 #endif //DBG
331 
332  ROffset.QuadPart = Offset;
333  (*WrittenBytes) = 0;
334 
335 /* IoBuf = ExAllocatePool(NonPagedPool, Length);
336  if (!IoBuf) return STATUS_INSUFFICIENT_RESOURCES;
337  RtlCopyMemory(IoBuf, Buffer, Length);*/
338  IoBuf = Buffer;
339 
340 /* if(Flags & PH_TMP_BUFFER) {
341  IoBuf = Buffer;
342  } else {
343  IoBuf = DbgAllocatePool(NonPagedPool, Length);
344  RtlCopyMemory(IoBuf, Buffer, Length);
345  }*/
346 
349  // Create notification event object to be used to signal the request completion.
351 
352  if (CurIrql > PASSIVE_LEVEL) {
354  Length, &ROffset, &(Context->IosbToUse) );
356  MmPrint((" Alloc async Irp MDL=%x, ctx=%x\n", irp->MdlAddress, Context));
358  Context, TRUE, TRUE, TRUE );
359  } else {
361  Length, &ROffset, &(Context->event), &(Context->IosbToUse) );
363  MmPrint((" Alloc Irp MDL=%x\n, ctx=%x", irp->MdlAddress, Context));
364  }
365 
367  RC = IoCallDriver(DeviceObject, irp);
368 /*
369  for(i=0; i<Length; i+=2048) {
370  UDFPrint(("IOCRC %8.8x W %x\n", crc32((PUCHAR)Buffer+i, 2048), (ULONG)((Offset+i)/2048) ));
371  }
372 */
373 #ifdef _BROWSE_UDF_
374  if(Vcb) {
375  UDFVWrite(Vcb, IoBuf, Length >> Vcb->BlockSizeBits, (ULONG)(Offset >> Vcb->BlockSizeBits), Flags);
376  }
377 #endif //_BROWSE_UDF_
378 
379  if (RC == STATUS_PENDING) {
380  DbgWaitForSingleObject(&(Context->event), NULL);
381  if ((RC = Context->IosbToUse.Status) == STATUS_DATA_OVERRUN) {
382  RC = STATUS_SUCCESS;
383  }
384 // *WrittenBytes = Context->IosbToUse.Information;
385  } else {
386 // *WrittenBytes = irp->IoStatus.Information;
387  }
388  if(NT_SUCCESS(RC)) {
389  (*WrittenBytes) = Context->IosbToUse.Information;
390  }
391 
392 try_exit: NOTHING;
393 
395 // if(IoBuf) ExFreePool(IoBuf);
396 // if(IoBuf && !(Flags & PH_TMP_BUFFER)) DbgFreePool(IoBuf);
397  if(!NT_SUCCESS(RC)) {
398  UDFPrint(("WriteError\n"));
399  }
400 
401 #ifdef MEASURE_IO_PERFORMANCE
402  KeQuerySystemTime((PLARGE_INTEGER)&IoExitTime);
403  IoWriteTime += (IoExitTime-IoEnterTime);
404  if (WrittenData > 1024*1024*8) {
405  PerfPrint(("\nUDFPhWriteSynchronous() Relative size=%I64d, time=%I64d.\n", WrittenData, IoRelWriteTime));
407  }
408  WrittenData += Length;
409  IoRelWriteTime += (IoExitTime-IoEnterTime);
410  dt = (ULONG)((IoExitTime-IoEnterTime)/10/1000);
411  dtm = (ULONG)(((IoExitTime-IoEnterTime)/10)%1000);
412  PerfPrint(("\nUDFPhWriteSynchronous() exit: %08X, after %d.%4.4d msec.\n", RC, dt, dtm));
413 #else
414  UDFPrint(("nUDFPhWriteSynchronous() exit: %08X\n", RC));
415 #endif //MEASURE_IO_PERFORMANCE
416 
417  return(RC);
418 } // end UDFPhWriteSynchronous()
#define KeQuerySystemTime(t)
Definition: env_spec_w32.h:570
#define KeGetCurrentIrql()
Definition: env_spec_w32.h:706
#define UDFPrint(Args)
Definition: udffs.h:225
struct _UDF_PH_CALL_CONTEXT * PUDF_PH_CALL_CONTEXT
#define TRUE
Definition: types.h:120
#define STATUS_INSUFFICIENT_RESOURCES
Definition: udferr_usr.h:158
#define STATUS_DATA_OVERRUN
Definition: udferr_usr.h:152
PIRP NTAPI IoBuildSynchronousFsdRequest(IN ULONG MajorFunction, IN PDEVICE_OBJECT DeviceObject, IN PVOID Buffer, IN ULONG Length, IN PLARGE_INTEGER StartingOffset, IN PKEVENT Event, IN PIO_STATUS_BLOCK IoStatusBlock)
Definition: irp.c:1069
LONGLONG IoWriteTime
Definition: env_spec.cpp:26
LONG NTSTATUS
Definition: precomp.h:26
Definition: cdstruc.h:504
#define IoSetCompletionRoutine(_Irp, _CompletionRoutine, _Context, _InvokeOnSuccess, _InvokeOnError, _InvokeOnCancel)
Definition: irp.cpp:515
UCHAR KIRQL
Definition: env_spec_w32.h:591
LONGLONG IoRelWriteTime
Definition: env_spec.cpp:28
_Must_inspect_result_ _In_ ULONG Flags
Definition: wsk.h:170
_In_ ULONG _In_ ULONG Offset
Definition: ntddpcm.h:101
NTSTATUS NTAPI UDFAsyncCompletionRoutine(IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp, IN PVOID Contxt)
Definition: env_spec.cpp:40
smooth NULL
Definition: ftsmooth.c:416
#define SL_OVERRIDE_VERIFY_VOLUME
Definition: iotypes.h:1780
#define DbgWaitForSingleObject(o, to)
Definition: env_spec_w32.h:479
#define MyAllocatePool__(type, size)
Definition: mem_tools.h:149
int64_t LONGLONG
Definition: typedefs.h:66
LONGLONG WrittenData
Definition: env_spec.cpp:27
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
#define STATUS_PENDING
Definition: ntstatus.h:82
#define try_return(S)
Definition: cdprocs.h:2189
#define Vcb
Definition: cdprocs.h:1425
#define MyFreePool__(addr)
Definition: mem_tools.h:152
PIRP NTAPI IoBuildAsynchronousFsdRequest(IN ULONG MajorFunction, IN PDEVICE_OBJECT DeviceObject, IN PVOID Buffer, IN ULONG Length, IN PLARGE_INTEGER StartingOffset, IN PIO_STATUS_BLOCK IoStatusBlock)
Definition: irp.c:750
#define PerfPrint(_x_)
Definition: env_spec_w32.h:291
#define MmPrint(_x_)
Definition: env_spec_w32.h:289
_In_ ULONG _In_ ULONG _In_ ULONG Length
Definition: ntddpcm.h:101
#define NOTHING
Definition: env_spec_w32.h:461
struct _VCB * PVCB
Definition: fatstruc.h:556
#define PASSIVE_LEVEL
Definition: env_spec_w32.h:693
__drv_aliasesMem FORCEINLINE PIO_STACK_LOCATION IoGetNextIrpStackLocation(_In_ PIRP Irp)
Definition: iofuncs.h:2647
#define PH_VCB_IN_RETLEN
Definition: phys_lib.h:66
IN PDEVICE_OBJECT DeviceObject
Definition: fatprocs.h:1560
#define KeInitializeEvent(pEvt, foo, foo2)
Definition: env_spec_w32.h:477
NTSTATUS NTAPI IoCallDriver(IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp)
Definition: irp.c:1218
struct tagContext Context
Definition: acpixf.h:1024
unsigned int ULONG
Definition: retypes.h:1
OSSTATUS UDFVWrite(IN PVCB Vcb, IN void *Buffer, IN uint32 BCount, IN uint32 LBA, IN uint32 Flags)
Definition: remap.cpp:225
#define IRP_MJ_WRITE
Definition: rdpdr.c:47
IN BOOLEAN OUT PSTR Buffer
Definition: progress.h:34
return STATUS_SUCCESS
Definition: btrfs.c:2966
LONGLONG QuadPart
Definition: typedefs.h:112

◆ UDFSyncCompletionRoutine()

NTSTATUS NTAPI UDFSyncCompletionRoutine ( IN PDEVICE_OBJECT  DeviceObject,
IN PIRP  Irp,
IN PVOID  Contxt 
)

Definition at line 82 of file env_spec.cpp.

87 {
88  UDFPrint(("UDFSyncCompletionRoutine ctx=%x\n", Contxt));
90 
91  Context->IosbToUse = Irp->IoStatus;
92  //KeSetEvent( &(Context->event), 0, FALSE );
93 
94  return STATUS_SUCCESS;
95 } // end UDFSyncCompletionRoutine()
#define UDFPrint(Args)
Definition: udffs.h:225
struct _UDF_PH_CALL_CONTEXT * PUDF_PH_CALL_CONTEXT
_In_ PIRP Irp
Definition: csq.h:116
return STATUS_SUCCESS
Definition: btrfs.c:2966

◆ UDFTSendIOCTL()

NTSTATUS NTAPI UDFTSendIOCTL ( IN ULONG  IoControlCode,
IN PVCB  Vcb,
IN PVOID  InputBuffer,
IN ULONG  InputBufferLength,
OUT PVOID  OutputBuffer,
IN ULONG  OutputBufferLength,
IN BOOLEAN  OverrideVerify,
OUT PIO_STATUS_BLOCK Iosb  OPTIONAL 
)

Definition at line 462 of file env_spec.cpp.

472 {
474  BOOLEAN Acquired;
475 
476  Acquired = UDFAcquireResourceExclusiveWithCheck(&(Vcb->IoResource));
477 
478  _SEH2_TRY {
479 
481  Vcb->TargetDeviceObject,
482  InputBuffer ,
484  OutputBuffer ,
486  OverrideVerify,
487  Iosb
488  );
489 
490  } _SEH2_FINALLY {
491  if(Acquired)
492  UDFReleaseResource(&(Vcb->IoResource));
493  } _SEH2_END;
494 
495  return RC;
496 } // end UDFTSendIOCTL()
NTSTATUS NTAPI UDFPhSendIOCTL(IN ULONG IoControlCode, IN PDEVICE_OBJECT DeviceObject, IN PVOID InputBuffer, IN ULONG InputBufferLength, OUT PVOID OutputBuffer, IN ULONG OutputBufferLength, IN BOOLEAN OverrideVerify, OUT PIO_STATUS_BLOCK Iosb OPTIONAL)
Definition: env_spec.cpp:511
_Must_inspect_result_ _In_ PFILE_OBJECT _In_ ULONG IoControlCode
Definition: fltkernel.h:1383
#define UDFReleaseResource(Resource)
Definition: env_spec_w32.h:661
LONG NTSTATUS
Definition: precomp.h:26
_Must_inspect_result_ _In_ PFILE_OBJECT _In_ ULONG _In_ ULONG _In_ ULONG OutputBufferLength
Definition: fltkernel.h:1374
CHAR InputBuffer[80]
Definition: conmgr.c:33
_SEH2_TRY
Definition: create.c:4250
unsigned char BOOLEAN
_Must_inspect_result_ __drv_aliasesMem _In_ PDEVICE_OBJECT _In_opt_ PVOID _In_ ULONG _Out_opt_ PVOID OutputBuffer
Definition: iofuncs.h:713
return Iosb
Definition: create.c:4426
#define Vcb
Definition: cdprocs.h:1425
_Must_inspect_result_ _In_ PFILE_OBJECT _In_ ULONG _In_ ULONG InputBufferLength
Definition: fltkernel.h:1372
_SEH2_END
Definition: create.c:4424
_SEH2_FINALLY
Definition: create.c:4395
BOOLEAN UDFAcquireResourceExclusiveWithCheck(IN PERESOURCE Resource)
Definition: misc.cpp:2529
return STATUS_SUCCESS
Definition: btrfs.c:2966

Referenced by UDFEjectReqWaiter(), UDFStartEjectWaiter(), and UDFVerifyVcb().

Variable Documentation

◆ IoReadTime

LONGLONG IoReadTime =0

Definition at line 25 of file env_spec.cpp.

Referenced by UDFPhReadSynchronous().

◆ IoRelWriteTime

LONGLONG IoRelWriteTime =0

Definition at line 28 of file env_spec.cpp.

Referenced by UDFPhWriteSynchronous().

◆ IoWriteTime

LONGLONG IoWriteTime =0

Definition at line 26 of file env_spec.cpp.

Referenced by UDFPhWriteSynchronous().

◆ WrittenData

LONGLONG WrittenData =0

Definition at line 27 of file env_spec.cpp.

Referenced by UDFPhWriteSynchronous().