ReactOS 0.4.15-dev-7693-gd0e2924
env_spec_w32.cpp File Reference
#include "string_lib.cpp"
Include dependency graph for env_spec_w32.cpp:

Go to the source code of this file.

Macros

#define MAX_INVALIDATE_VOLUME_RETRY   8
 

Functions

NTSTATUS UDFPhSendIOCTL (IN ULONG IoControlCode, IN PDEVICE_OBJECT DeviceObject, IN PVOID InputBuffer, IN ULONG InputBufferLength, OUT PVOID OutputBuffer, IN ULONG OutputBufferLength, IN BOOLEAN OverrideVerify, OUT PVOID Iosb OPTIONAL)
 
NTSTATUS UDFPhReadSynchronous (PDEVICE_OBJECT DeviceObject, PVOID Buffer, ULONG Length, LONGLONG Offset, PULONG ReadBytes, ULONG Flags)
 
NTSTATUS UDFPhWriteSynchronous (PDEVICE_OBJECT DeviceObject, PVOID Buffer, ULONG Length, LONGLONG Offset, PULONG WrittenBytes, ULONG Flags)
 
VOID set_image_size (HANDLE h, int64 len)
 
int64 get_file_size (HANDLE h)
 
int64 set_file_pointer (HANDLE h, int64 sz)
 
ULONG write (PVCB Vcb, HANDLE h, PCHAR buff, ULONG len)
 
ULONG MyLockVolume (HANDLE h, ULONG *pLockMode)
 
ULONG MyUnlockVolume (HANDLE h, ULONG *pLockMode)
 
void my_retrieve_vol_type (PVCB Vcb, PWCHAR fn)
 
HANDLE my_open (PVCB Vcb, PWCHAR fn)
 
uint64 udf_lseek64 (HANDLE fd, uint64 offset, int whence)
 
VOID PrintDbgConsole (PCHAR DebugMessage,...)
 
BOOLEAN RtlTimeFieldsToTime (IN PTIME_FIELDS TimeFields, IN PLARGE_INTEGER Time)
 
BOOLEAN RtlTimeToTimeFields (IN PLARGE_INTEGER Time, IN PTIME_FIELDS TimeFields)
 
BOOLEAN ProbeMemory (PVOID MemPtr, ULONG Length, BOOLEAN ForWrite)
 

Variables

ULONG LockMode = 0
 
BOOLEAN opt_invalidate_volume = FALSE
 
BOOLEAN open_as_device = FALSE
 

Macro Definition Documentation

◆ MAX_INVALIDATE_VOLUME_RETRY

#define MAX_INVALIDATE_VOLUME_RETRY   8

Definition at line 451 of file env_spec_w32.cpp.

Function Documentation

◆ get_file_size()

int64 get_file_size ( HANDLE  h)

Definition at line 262 of file env_spec_w32.cpp.

265{
266 LONG hsz = 0;
267 LONG lsz;
268
269 lsz = SetFilePointer(h, 0, &hsz, FILE_END);
270 return (((int64)hsz) << 32) | lsz;
271} // end get_file_size()
#define SetFilePointer
Definition: compat.h:743
long long int64
Definition: platform.h:13
GLfloat GLfloat GLfloat GLfloat h
Definition: glext.h:7723
long LONG
Definition: pedump.c:60
#define FILE_END
Definition: winbase.h:114

◆ my_open()

HANDLE my_open ( PVCB  Vcb,
PWCHAR  fn 
)

Definition at line 455 of file env_spec_w32.cpp.

461{
462 HANDLE h/*, h2*/;
463 WCHAR deviceNameBuffer[0x200];
464 WCHAR FSNameBuffer[0x200];
465// CCHAR RealDeviceName[0x200];
466// WCHAR DeviceName[MAX_PATH+1];
467 ULONG RC;
468 ULONG retry;
469 ULONG i;
470 BOOLEAN CantLock = FALSE;
471 PULONG pLockMode;
472#ifdef NT_NATIVE_MODE
473 IO_STATUS_BLOCK ioStatus;
475 UNICODE_STRING uniFilename;
476#endif //NT_NATIVE_MODE
477 ULONG returned;
478
479#ifndef CDRW_W32
480#ifdef UDF_FORMAT_MEDIA
481 PUDFFmtState fms = Vcb->fms;
482 fms->
483#endif
485#endif //CDRW_W32
486
487 pLockMode = &
488#ifdef UDF_FORMAT_MEDIA
489 fms->
490#endif
491 LockMode;
492
493 // make several retries to workaround smart applications,
494 // those attempts to work with volume immediately after arrival
495 retry = 1 +
496#ifdef UDF_FORMAT_MEDIA
497 fms->
498#endif
500
501#ifndef NT_NATIVE_MODE
502 swprintf(deviceNameBuffer, L"%ws\\", fn);
503 UDFPrint(("my_open: %S\n", fn));
504 i = sizeof(FSNameBuffer)/sizeof(FSNameBuffer[0]);
505 if(GetVolumeInformationW(deviceNameBuffer, NULL, 0,
506 &returned, &returned, &returned, FSNameBuffer, i)) {
507 UDFPrint(("my_open: FS: %S\n", FSNameBuffer));
508 if(!wcscmp(FSNameBuffer, L"Unknown")) {
509 retry++;
510 }
511 } else {
512 UDFPrint(("my_open: FS: ???\n"));
513 }
514 UDFPrint(("my_open: retry %d times\n", retry));
515
516#endif //NT_NATIVE_MODE
517
518 do {
519 // open as device
520#ifndef NT_NATIVE_MODE
521 swprintf(deviceNameBuffer, L"\\\\.\\%ws", fn);
522 if(wcslen(fn) == 2 && fn[1] == ';') {
523 UserPrint(("Warrning: File name is similar to drive letter.\n"
524 " Don't you type semicolon ';' instead of colon ':' ?\n"));
525 }
526 h = (HANDLE)(-1);
527 for(i=0; i<4; i++) {
528 if(h == ((HANDLE)-1)) {
529 h = CreateFileW(deviceNameBuffer, GENERIC_READ | GENERIC_WRITE,
530 ((i & 1) ? 0 : FILE_SHARE_READ) | ((i & 2) ? 0 : FILE_SHARE_WRITE),
531 NULL,
534 if(h != ((HANDLE)-1)) {
535 UDFPrint((" opened i=%x\n", i));
536 }
537 }
538 }
539#else //NT_NATIVE_MODE
540 uniFilename.Length = swprintf(deviceNameBuffer, L"\\??\\%ws", fn);
541 uniFilename.Buffer = deviceNameBuffer;
542 uniFilename.Length *= sizeof(WCHAR);
543 uniFilename.MaximumLength = uniFilename.Length + sizeof(WCHAR);
544
545 h = (HANDLE)(-1);
546 for(i=0; i<4; i++) {
548 if(h == ((HANDLE)-1)) {
549 RC = NtCreateFile(&h,
552 &ioStatus,
553 NULL,
555 ((i & 1) ? 0 : FILE_SHARE_READ) | ((i & 2) ? 0 : FILE_SHARE_WRITE),
556 FILE_OPEN,
558 NULL,
559 0);
560 if(!NT_SUCCESS(RC)) {
561 UDFPrint((" opened i2=%x\n", i));
562 h = ((HANDLE)-1);
563 }
564 }
565 }
566#endif //NT_NATIVE_MODE
567 if(h != ((HANDLE)-1)) {
568#ifndef CDRW_W32
569#ifdef UDF_FORMAT_MEDIA
570 if(fms->opt_flush || fms->opt_probe) {
571 return h;
572 }
573#endif //UDF_FORMAT_MEDIA
575#else
577#endif //CDRW_W32
578 if(!NT_SUCCESS(MyLockVolume(h,pLockMode))) {
579#ifndef CDRW_W32
580 if(retry < MAX_INVALIDATE_VOLUME_RETRY) {
581 retry++;
582 if(!Privilege(SE_TCB_NAME, TRUE)) {
583 UDFPrint(("SE_TCB privilege not held\n"));
584 } else
585 if(DeviceIoControl(h,FSCTL_INVALIDATE_VOLUMES,&h,sizeof(h),NULL,0,&returned,NULL) ) {
586 UDFPrint((" FSCTL_INVALIDATE_VOLUMES ok, status %x\n", GetLastError()));
587 CloseHandle(h);
588 continue;
589 } else {
590//#ifndef CDRW_W32
591 UDFPrint((" FSCTL_INVALIDATE_VOLUMES failed, error %x\n", GetLastError()));
592 RC = GetLastError();
593 if(DeviceIoControl(h,IOCTL_UDF_INVALIDATE_VOLUMES,&h,sizeof(h),NULL,0,&returned,NULL) ) {
594 UDFPrint((" IOCTL_UDF_INVALIDATE_VOLUMES ok, status %x\n", GetLastError()));
595 CloseHandle(h);
596 continue;
597 }
598 UDFPrint((" IOCTL_UDF_INVALIDATE_VOLUMES, error %x\n", GetLastError()));
599//#endif //CDRW_W32
600 }
601 UserPrint(("can't lock volume, retry\n"));
602 CloseHandle(h);
603 continue;
604 }
605#endif //CDRW_W32
606 UserPrint(("can't lock volume\n"));
607#ifndef NT_NATIVE_MODE
608 // In native mode the volume can be not mounted yet !!!
609 CantLock = TRUE;
610 CloseHandle(h);
611 h = NULL;
612 goto try_as_file;
613#endif //NT_NATIVE_MODE
614 }
615//#ifndef CDRW_W32
617 UDFPrint(("Warning: can't allow extended DASD i/o\n"));
618 }
619//#endif //CDRW_W32
620
621 UDFPrint((" opened, h=%x\n", h));
622 return h;
623 }
624 RC = GetLastError();
625
626#ifndef NT_NATIVE_MODE
627 h = CreateFileW(deviceNameBuffer, GENERIC_READ,
629 NULL,
632#else //NT_NATIVE_MODE
633 RC = NtCreateFile(&h,
636 &ioStatus,
637 NULL,
640 FILE_OPEN,
642 NULL,
643 0);
644 if(!NT_SUCCESS(RC)) {
645 h = ((HANDLE)-1);
646 }
647#endif //NT_NATIVE_MODE
648 if(h != ((HANDLE)-1)) {
649
650 UDFPrint((" opened R/O, h=%x\n", h));
651#ifndef CDRW_W32
653#else
655#endif
656
657 UserPrint(("read-only open\n"));
658 if(!NT_SUCCESS(MyLockVolume(h,pLockMode))) {
659#ifndef CDRW_W32
660 if(retry < MAX_INVALIDATE_VOLUME_RETRY) {
661 retry++;
662 if(!Privilege(SE_TCB_NAME, TRUE)) {
663 UDFPrint(("SE_TCB privilege not held\n"));
664 } else
665 if(DeviceIoControl(h,FSCTL_INVALIDATE_VOLUMES,&h,sizeof(h),NULL,0,&returned,NULL) ) {
666 CloseHandle(h);
667 continue;
668 }
669 UserPrint(("can't lock read-only volumem retry"));
670 CloseHandle(h);
671 continue;
672 }
673#endif //CDRW_W32
674 UserPrint(("can't lock read-only volume"));
675#ifndef NT_NATIVE_MODE
676 CantLock = TRUE;
677 CloseHandle(h);
678 h = NULL;
679 goto try_as_file;
680#endif //NT_NATIVE_MODE
681 }
682// write_cdfs = TRUE;
683// DeviceIoControl(h,FSCTL_DISMOUNT_VOLUME,NULL,0,NULL,0,&returned,NULL);
684 return h;
685 }
686#ifndef NT_NATIVE_MODE
687try_as_file:
688#endif //NT_NATIVE_MODE
689
690#ifndef CDRW_W32
691#ifdef UDF_FORMAT_MEDIA
692 fms->
693#endif
695 // open as plain file
696 Vcb->PhDeviceType = FILE_DEVICE_DISK;
697#endif //CDRW_W32
698
699 UserPrint(("try image file\n"));
700#ifndef NT_NATIVE_MODE
703 NULL,
706#else //NT_NATIVE_MODE
707 RC = NtCreateFile(&h,
710 &ioStatus,
711 NULL,
714 FILE_OPEN,
716 NULL,
717 0);
718 if(!NT_SUCCESS(RC)) {
719 h = ((HANDLE)-1);
720 }
721#endif //NT_NATIVE_MODE
722 if(h == ((HANDLE)-1)) {
723
724 RC = GetLastError();
725 if(CantLock) {
726#ifndef CDRW_W32
727 my_exit(
728#ifdef UDF_FORMAT_MEDIA
729 fms,
730#endif
732#else
733 return NULL;
734#endif //CDRW_W32
735 }
736#ifndef CDRW_W32
737 UserPrint(("error opening device or image file"));
738 my_exit(
739#ifdef UDF_FORMAT_MEDIA
740 fms,
741#endif
743#else
744 return NULL;
745#endif //CDRW_W32
746 }
747 UDFPrint((" opened as file, h=%x\n", h));
748 break;
749
750 } while(TRUE);
751 return h;
752} // end my_open()
unsigned char BOOLEAN
#define FILE_COMPLETE_IF_OPLOCKED
Definition: constants.h:493
IN PUNICODE_STRING IN POBJECT_ATTRIBUTES ObjectAttributes
Definition: conport.c:36
BOOL WINAPI DeviceIoControl(IN HANDLE hDevice, IN DWORD dwIoControlCode, IN LPVOID lpInBuffer OPTIONAL, IN DWORD nInBufferSize OPTIONAL, OUT LPVOID lpOutBuffer OPTIONAL, IN DWORD nOutBufferSize OPTIONAL, OUT LPDWORD lpBytesReturned OPTIONAL, IN LPOVERLAPPED lpOverlapped OPTIONAL)
Definition: deviceio.c:136
#define NULL
Definition: types.h:112
#define TRUE
Definition: types.h:120
#define FALSE
Definition: types.h:117
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
#define CloseHandle
Definition: compat.h:739
#define OPEN_EXISTING
Definition: compat.h:775
#define GENERIC_READ
Definition: compat.h:135
#define CreateFileW
Definition: compat.h:741
#define FILE_ATTRIBUTE_NORMAL
Definition: compat.h:137
#define FILE_SHARE_READ
Definition: compat.h:136
BOOL WINAPI GetVolumeInformationW(IN LPCWSTR lpRootPathName, IN LPWSTR lpVolumeNameBuffer, IN DWORD nVolumeNameSize, OUT LPDWORD lpVolumeSerialNumber OPTIONAL, OUT LPDWORD lpMaximumComponentLength OPTIONAL, OUT LPDWORD lpFileSystemFlags OPTIONAL, OUT LPWSTR lpFileSystemNameBuffer OPTIONAL, IN DWORD nFileSystemNameSize)
Definition: volume.c:226
#define swprintf
Definition: precomp.h:40
ULONG MyLockVolume(HANDLE h, ULONG *pLockMode)
BOOLEAN open_as_device
BOOLEAN opt_invalidate_volume
Definition: env_spec_w32.cpp:9
#define MAX_INVALIDATE_VOLUME_RETRY
void my_retrieve_vol_type(PVCB Vcb, PWCHAR fn)
ULONG LockMode
Definition: env_spec_w32.cpp:8
#define UserPrint(x)
Definition: env_spec_w32.h:202
void my_exit(int rc)
#define FILE_OPEN
Definition: from_kernel.h:54
#define FILE_SYNCHRONOUS_IO_NONALERT
Definition: from_kernel.h:31
#define FILE_NO_INTERMEDIATE_BUFFERING
Definition: from_kernel.h:28
#define FILE_WRITE_THROUGH
Definition: from_kernel.h:26
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
_CRTIMP size_t __cdecl wcslen(_In_z_ const wchar_t *_Str)
#define OBJ_CASE_INSENSITIVE
Definition: winternl.h:228
#define CREATE_ALWAYS
Definition: disk.h:72
#define FILE_FLAG_NO_BUFFERING
Definition: disk.h:45
#define InitializeObjectAttributes(p, n, a, r, s)
Definition: reg.c:106
#define FILE_SHARE_WRITE
Definition: nt_native.h:681
#define SYNCHRONIZE
Definition: nt_native.h:61
#define FILE_READ_ATTRIBUTES
Definition: nt_native.h:647
#define FSCTL_INVALIDATE_VOLUMES
Definition: nt_native.h:847
NTSTATUS NTAPI NtCreateFile(OUT PHANDLE FileHandle, IN ACCESS_MASK DesiredAccess, IN POBJECT_ATTRIBUTES ObjectAttributes, OUT PIO_STATUS_BLOCK IoStatusBlock, IN PLARGE_INTEGER AllocationSize OPTIONAL, IN ULONG FileAttributes, IN ULONG ShareAccess, IN ULONG CreateDisposition, IN ULONG CreateOptions, IN PVOID EaBuffer OPTIONAL, IN ULONG EaLength)
#define GENERIC_WRITE
Definition: nt_native.h:90
#define L(x)
Definition: ntvdm.h:50
#define Vcb
Definition: cdprocs.h:1415
#define fms
#define FILE_DEVICE_DISK
Definition: winioctl.h:113
#define FSCTL_ALLOW_EXTENDED_DASD_IO
Definition: winioctl.h:124
_Check_return_ _CRTIMP int __cdecl wcscmp(_In_z_ const wchar_t *_Str1, _In_z_ const wchar_t *_Str2)
USHORT MaximumLength
Definition: env_spec_w32.h:370
uint32_t * PULONG
Definition: typedefs.h:59
PVOID HANDLE
Definition: typedefs.h:73
uint32_t ULONG
Definition: typedefs.h:59
#define MKUDF_CANT_OPEN_FILE
Definition: udferr_usr.h:38
#define MKUDF_CANT_LOCK_VOL
Definition: udferr_usr.h:48
#define UDFPrint(Args)
Definition: udffs.h:225
#define IOCTL_UDF_INVALIDATE_VOLUMES
Definition: udfpubl.h:38
BOOL Privilege(LPTSTR pszPrivilege, BOOL bEnable)
Definition: user_lib.cpp:531
static GLenum _GLUfuncptr fn
Definition: wgl_font.c:159
DWORD WINAPI GetLastError(void)
Definition: except.c:1042
#define SE_TCB_NAME
Definition: winnt_old.h:372
__wchar_t WCHAR
Definition: xmlstorage.h:180

◆ my_retrieve_vol_type()

void my_retrieve_vol_type ( PVCB  Vcb,
PWCHAR  fn 
)

Definition at line 419 of file env_spec_w32.cpp.

425{
426#ifndef CDRW_W32
427 if(wcslen(fn) == 2 && fn[1] == ':') {
428 ULONG DevType = GetDriveTypeW(fn);
429 UDFPrint((" DevType %x\n", DevType));
430 switch(DevType) {
431 case DRIVE_CDROM:
432 Vcb->PhDeviceType = FILE_DEVICE_CD_ROM;
433 break;
434 default:
435 Vcb->PhDeviceType = FILE_DEVICE_DISK;
436 break;
437 }
438 }
439 if(wcslen(fn) == 2 && fn[1] == ';') {
440 UserPrint(("Warrning: File name is similar to drive letter.\n"
441 " Don't you type semicolon ';' instead of colon ':' ?\n"));
442 }
443#endif //CDRW_W32
444} // end my_retrieve_vol_type()
UINT WINAPI GetDriveTypeW(IN LPCWSTR lpRootPathName)
Definition: disk.c:497
#define DRIVE_CDROM
Definition: machpc98.h:119
#define FILE_DEVICE_CD_ROM
Definition: winioctl.h:108

Referenced by my_open().

◆ MyLockVolume()

ULONG MyLockVolume ( HANDLE  h,
ULONG pLockMode 
)

Definition at line 374 of file env_spec_w32.cpp.

378{
379 ULONG RC;
380 ULONG returned;
381
382 (*pLockMode) = -1;
383#ifndef CDRW_W32
385 if(RC) {
386 (*pLockMode) = IOCTL_UDF_LOCK_VOLUME_BY_PID;
387 return STATUS_SUCCESS;
388 }
389#endif //CDRW_W32
390
391 RC = DeviceIoControl(h,FSCTL_LOCK_VOLUME,NULL,0,NULL,0,&returned,NULL);
392 if(RC) {
393 (*pLockMode) = FSCTL_LOCK_VOLUME;
394 return STATUS_SUCCESS;
395 }
396 return STATUS_UNSUCCESSFUL;
397} // MyLockVolume()
#define FSCTL_LOCK_VOLUME
Definition: nt_native.h:832
#define STATUS_SUCCESS
Definition: shellext.h:65
#define STATUS_UNSUCCESSFUL
Definition: udferr_usr.h:132
#define IOCTL_UDF_LOCK_VOLUME_BY_PID
Definition: udfpubl.h:42

Referenced by my_open().

◆ MyUnlockVolume()

ULONG MyUnlockVolume ( HANDLE  h,
ULONG pLockMode 
)

Definition at line 401 of file env_spec_w32.cpp.

405{
406 ULONG returned;
407
408#ifndef CDRW_W32
409 if((*pLockMode) == IOCTL_UDF_LOCK_VOLUME_BY_PID) {
411 }
412#endif //CDRW_W32
413
414 return DeviceIoControl(h,FSCTL_UNLOCK_VOLUME,NULL,0,NULL,0,&returned,NULL);
415
416} // MyUnlockVolume()
#define FSCTL_UNLOCK_VOLUME
Definition: nt_native.h:833
#define IOCTL_UDF_UNLOCK_VOLUME_BY_PID
Definition: udfpubl.h:43

◆ PrintDbgConsole()

VOID PrintDbgConsole ( PCHAR  DebugMessage,
  ... 
)

Definition at line 866 of file env_spec_w32.cpp.

870{
871} // end ClassDebugPrint()

◆ ProbeMemory()

BOOLEAN ProbeMemory ( PVOID  MemPtr,
ULONG  Length,
BOOLEAN  ForWrite 
)

Definition at line 1119 of file env_spec_w32.cpp.

1124{
1125 ULONG i;
1126 UCHAR a;
1127 if(!MemPtr && !Length)
1128 return TRUE;
1129 if(!MemPtr || !Length)
1130 return FALSE;
1131 _SEH2_TRY {
1132 a = ((PCHAR)MemPtr)[Length-1];
1133 if(ForWrite) {
1134 ((PCHAR)MemPtr)[Length-1] = a;
1135 }
1136 for(i=0; i<Length; i+=PAGE_SIZE) {
1137 a = ((PCHAR)MemPtr)[i];
1138 if(ForWrite) {
1139 ((PCHAR)MemPtr)[i] = a;
1140 }
1141 }
1143 return FALSE;
1144 } _SEH2_END;
1145 return TRUE;
1146} // end ProbeMemory()
#define PAGE_SIZE
Definition: env_spec_w32.h:49
#define _SEH2_END
Definition: filesup.c:22
#define _SEH2_TRY
Definition: filesup.c:19
GLboolean GLboolean GLboolean GLboolean a
Definition: glext.h:6204
#define EXCEPTION_EXECUTE_HANDLER
Definition: excpt.h:85
#define a
Definition: ke_i.h:78
#define PCHAR
Definition: match.c:90
_In_ ULONG _In_ ULONG _In_ ULONG Length
Definition: ntddpcm.h:102
#define _SEH2_EXCEPT(...)
Definition: pseh2_64.h:34
unsigned char UCHAR
Definition: xmlstorage.h:181

◆ RtlTimeFieldsToTime()

BOOLEAN RtlTimeFieldsToTime ( IN PTIME_FIELDS  TimeFields,
IN PLARGE_INTEGER  Time 
)

Definition at line 875 of file env_spec_w32.cpp.

879{
880 SYSTEMTIME st;
881
882 st.wYear = TimeFields->Year;
883 st.wMonth = TimeFields->Month;
884 st.wDayOfWeek = 0;
885 st.wDay = TimeFields->Day;
886 st.wHour = TimeFields->Hour;
890
891 return SystemTimeToFileTime(&st, (PFILETIME)Time);
892} // end RtlTimeFieldsToTime()
BOOL WINAPI SystemTimeToFileTime(IN CONST SYSTEMTIME *lpSystemTime, OUT LPFILETIME lpFileTime)
Definition: time.c:158
static PLARGE_INTEGER Time
Definition: time.c:105
static PTIME_FIELDS TimeFields
Definition: time.c:104
WORD wYear
Definition: winbase.h:905
WORD wMilliseconds
Definition: winbase.h:912
WORD wMonth
Definition: winbase.h:906
WORD wHour
Definition: winbase.h:909
WORD wSecond
Definition: winbase.h:911
WORD wMinute
Definition: winbase.h:910
WORD wDay
Definition: winbase.h:908
WORD wDayOfWeek
Definition: winbase.h:907
USHORT Milliseconds
Definition: env_spec_w32.h:717

Referenced by _Success_(), ConvertSystemTimeToFileTime(), DosDateTimeToFileTime(), DriverEntry(), ExpSetTimeZoneInformation(), FatFatDateToNtTime(), FatFatTimeToNtTime(), FsdDosDateTimeToSystemTime(), MSTASK_ITaskTrigger_SetTrigger(), Phase1InitializationDiscard(), RtlCutoverTimeToSystemTime(), SetLocalTime(), SetSystemTime(), SystemTimeToFileTime(), and UDFTimeToNT().

◆ RtlTimeToTimeFields()

◆ set_file_pointer()

int64 set_file_pointer ( HANDLE  h,
int64  sz 
)

Definition at line 274 of file env_spec_w32.cpp.

278{
279 ULONG hsz = (ULONG)(sz >> 32);
280 ULONG lsz = (ULONG)sz;
281
282 lsz = SetFilePointer(h, lsz, (PLONG)&hsz, FILE_BEGIN);
283 return (((int64)hsz) << 32) | lsz;
284} // end set_file_pointer()
#define FILE_BEGIN
Definition: compat.h:761
int32_t * PLONG
Definition: typedefs.h:58

◆ set_image_size()

VOID set_image_size ( HANDLE  h,
int64  len 
)

Definition at line 247 of file env_spec_w32.cpp.

251{
252 LONG offh = (ULONG)(len >> 32);
253 //( (LONGLONG)LBA >> (32-Vcb->BlockSizeBits) );
254
255 SetFilePointer((HANDLE)h, (ULONG)(len /*(LBA << Vcb->BlockSizeBits)*/ ), &offh, FILE_BEGIN);
257 offh = 0;
258 SetFilePointer((HANDLE)h, 0, &offh, FILE_BEGIN);
259} // end set_image_size()
BOOL WINAPI SetEndOfFile(HANDLE hFile)
Definition: fileinfo.c:1004
GLenum GLsizei len
Definition: glext.h:6722

◆ udf_lseek64()

uint64 udf_lseek64 ( HANDLE  fd,
uint64  offset,
int  whence 
)

Definition at line 759 of file env_spec_w32.cpp.

763{
764 LONG offh = (ULONG)(offset>>32);
765 LONG offl;
766 offl = SetFilePointer(fd, (ULONG)offset, &offh, whence);
767 if(offl == -1 && offh == -1) {
768 return -1;
769 }
770 return (((uint64)offh) << 32) | (uint64)offl;
771} // end udf_lseek64()
unsigned long long uint64
Definition: platform.h:18
GLintptr offset
Definition: glext.h:5920
static int fd
Definition: io.c:51

◆ UDFPhReadSynchronous()

NTSTATUS UDFPhReadSynchronous ( PDEVICE_OBJECT  DeviceObject,
PVOID  Buffer,
ULONG  Length,
LONGLONG  Offset,
PULONG  ReadBytes,
ULONG  Flags 
)

Definition at line 106 of file env_spec_w32.cpp.

114{
115
116#if !defined(LIBUDF) && !defined(LIBUDFFMT)
117
118 NTSTATUS RC;
119// UDFPrint(("UDFPhRead: Length: %x Lba: %lx\n",Length>>0xb,Offset>>0xb));
120 LONG HiOffs = (ULONG)(Offset >> 32);
121
123 if(RC == INVALID_SET_FILE_POINTER) {
124 if(GetLastError() != NO_ERROR) {
125 UDFPrint(("UDFPhReadSynchronous: error %x\n", GetLastError()));
126 return STATUS_END_OF_FILE;
127 }
128 }
130 if(NT_SUCCESS(RC) &&
131 (!(*ReadBytes))) {
132 RC = GetLastError();
133 return STATUS_END_OF_FILE;
134 }
135 return STATUS_SUCCESS;
136
137#else // LIBUDF
138
139 return _lphUdf->lpReadFunc(_lphUdf->lpParameter,
140 Buffer,
141 Length,
142 Offset,
143 ReadBytes);
144
145#endif //defined LIBUDF || defined LIBUDFFMT
146
147} // end UDFPhReadSynchronous()
LONG NTSTATUS
Definition: precomp.h:26
Definition: bufpool.h:45
#define NO_ERROR
Definition: dderror.h:5
#define INVALID_SET_FILE_POINTER
Definition: compat.h:732
#define ReadFile(a, b, c, d, e)
Definition: compat.h:742
static NTSTATUS ReadBytes(IN PDEVICE_OBJECT LowerDevice, OUT PUCHAR Buffer, IN ULONG BufferSize, OUT PULONG_PTR FilledBytes)
Definition: detect.c:67
_In_ ULONG _In_ ULONG Offset
Definition: ntddpcm.h:101
#define STATUS_END_OF_FILE
Definition: shellext.h:67
_In_ PDEVICE_OBJECT DeviceObject
Definition: wdfdevice.h:2055

◆ UDFPhSendIOCTL()

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

Definition at line 66 of file env_spec_w32.cpp.

76{
77 ULONG real_read;
78#if !defined(LIBUDF) && !defined(LIBUDFFMT)
79 ULONG ret;
80
84 &real_read,NULL);
85
86 if (!RC) {
87 ret = GetLastError();
88 }
89 return RC ? 1 : -1;
90
91#else // LIBUDF
92
93 ULONG RC = _lphUdf->lpIOCtlFunc(_lphUdf->lpParameter,IoControlCode,
96 &real_read);
97
98 return RC;
99
100#endif // LIBUDF
101
102} // end UDFPhSendIOCTL()
int ret
_In_ WDFREQUEST _In_ size_t _In_ size_t _In_ ULONG IoControlCode
Definition: wdfio.h:325
_In_ WDFREQUEST _In_ size_t OutputBufferLength
Definition: wdfio.h:320
_In_ WDFREQUEST _In_ size_t _In_ size_t InputBufferLength
Definition: wdfio.h:322
_Must_inspect_result_ _In_ WDFIOTARGET _In_opt_ WDFREQUEST _In_opt_ PWDF_MEMORY_DESCRIPTOR OutputBuffer
Definition: wdfiotarget.h:863
_Must_inspect_result_ _In_ WDFIOTARGET _In_opt_ WDFREQUEST _In_opt_ PWDF_MEMORY_DESCRIPTOR InputBuffer
Definition: wdfiotarget.h:953

◆ UDFPhWriteSynchronous()

NTSTATUS UDFPhWriteSynchronous ( PDEVICE_OBJECT  DeviceObject,
PVOID  Buffer,
ULONG  Length,
LONGLONG  Offset,
PULONG  WrittenBytes,
ULONG  Flags 
)

Definition at line 151 of file env_spec_w32.cpp.

159{
160#if !defined(LIBUDF) && !defined(LIBUDFFMT)
161
163 LONG HiOffs = (ULONG)(Offset >> 32);
164 PVOID Buffer2 = NULL;
165 PVOID Buffer3 = NULL;
166
168 if(RC == INVALID_SET_FILE_POINTER) {
169 if(GetLastError() != NO_ERROR) {
170 UDFPrint(("UDFPhWriteSynchronous: error %x\n", GetLastError()));
171 return STATUS_END_OF_FILE;
172 }
173 }
174
175 Buffer2 = ExAllocatePool(NonPagedPool, Length+0x10000);
176 Buffer3 = (PVOID)( ((ULONG)Buffer2 + 0xffff) & ~0xffff);
177 RtlCopyMemory(Buffer3, Buffer, Length);
178
179 RC = WriteFile(DeviceObject->h,Buffer3,Length,WrittenBytes,NULL);
180 if(!RC ||
181 !(*WrittenBytes)) {
182 RC = GetLastError();
183 UDFPrint(("UDFPhWriteSynchronous: EOF, error %x\n", RC));
185 } else {
186 RC = STATUS_SUCCESS;
187 }
188
189 if(Buffer2) ExFreePool(Buffer2);
190
191 return RC;
192
193#else // LIBUDF
194
195 return _lphUdf->lpWriteFunc(_lphUdf->lpParameter,
196 Buffer,
197 Length,
198 Offset,
199 WrittenBytes);
200
201#endif // LIBUDF
202
203} // end UDFPhWriteSynchronous()
BOOL WINAPI WriteFile(IN HANDLE hFile, IN LPCVOID lpBuffer, IN DWORD nNumberOfBytesToWrite OPTIONAL, OUT LPDWORD lpNumberOfBytesWritten, IN LPOVERLAPPED lpOverlapped OPTIONAL)
Definition: rw.c:24
#define ExFreePool(addr)
Definition: env_spec_w32.h:352
#define NonPagedPool
Definition: env_spec_w32.h:307
#define ExAllocatePool(type, size)
Definition: fbtusb.h:44
void * PVOID
Definition: typedefs.h:50
#define RtlCopyMemory(Destination, Source, Length)
Definition: typedefs.h:263

◆ write()

ULONG write ( PVCB  Vcb,
HANDLE  h,
PCHAR  buff,
ULONG  len 
)

Definition at line 293 of file env_spec_w32.cpp.

298{
299 ULONG written;
300 LONG offh = 0;
301 ULONG offl = SetFilePointer((HANDLE)h, 0, &offh, FILE_CURRENT);
302// ULONG Lba = (ULONG)((((LONGLONG)offh << 32) + offl) >> Vcb->BlockSizeBits);
303
304 UDFWriteData(Vcb, FALSE, (((LONGLONG)offh)<<32)+offl, len, FALSE, buff, &written);
305
306 SetFilePointer((HANDLE)h, offl, &offh, FILE_BEGIN);
307 offh = 0;
308 SetFilePointer((HANDLE)h, written, &offh, FILE_CURRENT);
309
310 return written;
311} // end write()
static unsigned char buff[32768]
Definition: fatten.c:17
OSSTATUS UDFWriteData(IN PVCB Vcb, IN BOOLEAN Translate, IN int64 Offset, IN SIZE_T Length, IN BOOLEAN Direct, IN int8 *Buffer, OUT PSIZE_T WrittenBytes)
Definition: phys_lib.cpp:4141
int64_t LONGLONG
Definition: typedefs.h:68
#define FILE_CURRENT
Definition: winbase.h:113

Variable Documentation

◆ LockMode

◆ open_as_device

BOOLEAN open_as_device = FALSE

Definition at line 14 of file env_spec_w32.cpp.

Referenced by my_open().

◆ opt_invalidate_volume

BOOLEAN opt_invalidate_volume = FALSE

Definition at line 9 of file env_spec_w32.cpp.

Referenced by my_open().