ReactOS  r74244
env_spec_w32.h
Go to the documentation of this file.
1 // 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.
6 /*************************************************************************
7 *
8 * File: env_spec_w32.h
9 *
10 * Module: User-mode applications (User mode execution only)
11 *
12 * Description:
13 *
14 *
15 * Author: Alter
16 *
17 *************************************************************************/
18 
19 #ifndef __ENV_SPEC_W32__H_
20 #define __ENV_SPEC_W32__H_
21 
22 #ifdef NT_NATIVE_MODE
23 //#include "ntddk.h" // include this for its native functions and defn's
24 #include "nt_native.h"
25 #else //NT_NATIVE_MODE
26 #include <windows.h>
27 #endif //NT_NATIVE_MODE
28 #include "platform.h"
29 //#ifndef WITHOUT_FORMATTER
30 #include "udferr_usr.h"
31 //#endif WITHOUT_FORMATTER
32 
33 #ifndef NT_NATIVE_MODE
34 #ifdef ASSERT
35  #undef ASSERT
36  #define ASSERT(a) if(!(a)) {__asm int 3;}
37 #endif
38 #endif //NT_NATIVE_MODE
39 
40 #ifndef MAXIMUM_FILENAME_LENGTH
41 #define MAXIMUM_FILENAME_LENGTH MAX_PATH
42 #endif //MAXIMUM_FILENAME_LENGTH
43 
44 #ifndef PAGE_SHIFT
45 #define PAGE_SHIFT 12
46 #endif //PAGE_SHIFT
47 
48 #ifndef PAGE_SIZE
49 #define PAGE_SIZE (ULONG)0x1000
50 #endif //PAGE_SIZE
51 
52 #ifndef PHYSICAL_ADDRESS
53 #define PHYSICAL_ADDRESS LARGE_INTEGER
54 #endif //PHYSICAL_ADDRESS
55 
56 #define OS_SUCCESS(a) NT_SUCCESS(a)
57 #define OSSTATUS NTSTATUS
58 
59 #if defined UDF_DBG || defined DEBUG
60 #define DBG
61 #ifndef CDRW_W32
62 #define UDF_DBG
63 #endif //CDRW_W32
64 #endif
65 
66 #define ERESEOURCE ULONG
67 #define PERESEOURCE PULONG
68 
69 #define KEVENT ULONG
70 #define PKEVENT PULONG
71 
72 typedef ULONG KSPIN_LOCK; // winnt ntndis
74 
75 #ifndef NT_NATIVE_MODE
76 // Status ot
77 #define NTSTATUS LONG
78 
79 #define NT_SUCCESS(x) ( (NTSTATUS)(x)>=0 )
80 
81 #define PsGetCurrentThread() GetCurrentThreadId()
82 
83 #define PsGetVersion(a,b,c,d) { \
84  OSVERSIONINFO OsVer; \
85  OsVer.dwOSVersionInfoSize = sizeof(OsVer); \
86  GetVersionEx(&OsVer); \
87  if(a) (*(a)) = OsVer.dwMajorVersion; \
88  if(b) (*(b)) = OsVer.dwMinorVersion; \
89  if(c) (*(c)) = OsVer.dwBuildNumber; \
90  if(d) (d)->Buffer = L""; \
91  if(d) (d)->Length = 0; \
92  if(d) (d)->MaximumLength = 0; \
93 }
94 
95 extern "C"
96 VOID
98  PCHAR DebugMessage,
99  ...
100  );
101 
102 #else //NT_NATIVE_MODE
103 #define HINSTANCE HANDLE
104 #endif //NT_NATIVE_MODE
105 
106 typedef
108  HINSTANCE hInstance, // handle to current instance
109  HINSTANCE hPrevInstance, // handle to previous instance
110  int nCmdShow // show state
111  );
112 
113 typedef
115  const char* Message,
116  ...
117  );
118 
119 typedef
120 PWCHAR (__stdcall *PSKIN_GETCMDLINE) (
121  VOID
122  );
123 
124 typedef
125 ULONG (__stdcall *PSKIN_MSG) (
126  ULONG MsgId,
128  PVOID DataIn,
130  PVOID DataOut,
132  );
133 
134 typedef struct _SKIN_API {
137  PSKIN_GETCMDLINE GetCommandLine;
138  PSKIN_MSG Msg;
139 } SKIN_API, *PSKIN_API;
140 
141 #ifdef USE_SKIN_MODEL
142 
143 extern "C" PSKIN_API SkinAPI;
144 extern PSKIN_API SkinLoad(
145  PWCHAR path,
146  HINSTANCE hInstance, // handle to current instance
147  HINSTANCE hPrevInstance, // handle to previous instance
148  int nCmdShow // show state
149  );
150 
151 #define SkinPrintf SkinAPI->Printf
152 #define SkinGetCmdLine SkinAPI->GetCommandLine
153 #define SkinNotify(op, state, ctx, sz) SkinAPI->Msg(op, state, ctx, sz, NULL, 0)
154 #define SkinAsk(op, state, ctx, def) SkinAPI->Msg(op, state, ctx, sizeof(ctx), NULL, 0)
155 
156 #else
157 
158 #define SkinLoad(path) {;}
159 
160 #if defined(CDRW_W32) || defined(LIBUDFFMT) || defined(LIBUDF)
161  #define SkinPrintf(x) {;}
162 /*VOID
163 inline
164 SkinPrintf(
165  PCHAR Message,
166  ...
167  )
168 {
169  //do nothing
170  return;
171 }*/
172 #else // defined(CDRW_W32) || defined(LIBUDFFMT) || defined(LIBUDF)
173  #define SkinPrintf printf
174 #endif
175 
176 #define SkinGetCmdLine GetCommandLineW
177 #define SkinNotify(op, state, ctx) {;}
178 #define SkinAsk(op, state, ctx, def) (def)
179 
180 #endif // defined(CDRW_W32) || defined(LIBUDFFMT) || defined(LIBUDF)
181 
182 #if defined(CDRW_W32) || defined(LIBUDFFMT) || defined(LIBUDF)
183 
184  #if defined(PRINT_TO_DBG_LOG) || defined(PRINT_ALWAYS)
185  #define UserPrint(x) PrintDbgConsole x
186  #else
187  #define UserPrint(x) {;}
188  #endif // PRINT_TO_DBG_LOG
189 
190 #else // defined(CDRW_W32) || defined(LIBUDFFMT) || defined(LIBUDF)
191 
192  #if defined(PRINT_TO_DBG_LOG) || defined(PRINT_ALWAYS)
193 
194  #define UserPrint(x) \
195  { \
196  SkinPrintf x ; \
197  PrintDbgConsole x ; \
198  }
199 
200  #else // PRINT_TO_DBG_LOG
201 
202  #define UserPrint(x) \
203  { \
204  SkinPrintf x ; \
205  }
206 
207  #endif // PRINT_TO_DBG_LOG
208 
209 #endif // defined(CDRW_W32) || defined(LIBUDFFMT) || defined(LIBUDF)
210 
211 #if defined(DBG) || defined(PRINT_ALWAYS)
212 
213  #define DbgPrint SkinPrintf
214 
215  #ifdef KdPrint
216  #undef KdPrint
217  #endif
218 
219  #if defined(CDRW_W32) || defined(LIBUDFFMT) || defined(LIBUDF)
220  #ifdef PRINT_TO_DBG_LOG
221  #define KdPrint(x) PrintDbgConsole x;
222  #else
223  #define KdPrint(x) {;}
224  #endif
225  #else
226 
227  #if defined(PRINT_TO_DBG_LOG) || defined(PRINT_ALWAYS)
228  #define KdPrint(x) \
229  { \
230  SkinPrintf x ; \
231  PrintDbgConsole x ; \
232  }
233  #else
234  #define KdPrint(x) \
235  { \
236  SkinPrintf x ; \
237  }
238  #endif
239  #endif
240 
241  #ifdef USE_MM_PRINT
242  #define MmPrint(_x_) DbgPrint _x_
243  #else
244  #define MmPrint(_x_) {NOTHING;}
245  #endif //USE_MM_PRINT
246 
247  #ifdef USE_TIME_PRINT
248  extern ULONG UdfTimeStamp;
249  #define TmPrint(_x_) {UdfTimeStamp++;KdPrint(("TM:%d: ",UdfTimeStamp));KdPrint(_x_);}
250  #else
251  #define TmPrint KdPrint
252  #endif //USE_MM_PRINT
253 
254  #ifdef USE_PERF_PRINT
255  #define PerfPrint(_x_) DbgPrint _x_
256  #else
257  #define PerfPrint(_x_) {NOTHING;}
258  #endif //USE_MM_PRINT
259 
260 #if defined(CDRW_W32) || defined(LIBUDFFMT) || defined(LIBUDF)
261  #ifdef USE_AD_PRINT
262  #undef USE_AD_PRINT
263  #endif
264  #ifdef USE_TH_PRINT
265  #undef USE_TH_PRINT
266  #endif
267 #endif
268 
269  #ifdef USE_AD_PRINT
270  #define AdPrint(_x_) {DbgPrint("Thrd:%x:",PsGetCurrentThread());DbgPrint _x_;}
271  #else
272  #define AdPrint(_x_) {NOTHING;}
273  #endif
274 
275  #ifdef USE_TH_PRINT
276  #define ThPrint(_x_) {DbgPrint("Thrd:%x:",PsGetCurrentThread());DbgPrint _x_;}
277  #else
278  #define ThPrint(_x_) {NOTHING;}
279  #endif
280 
281  #ifdef USE_DUMP_EXT
282  #define ExtPrint(_x_) DbgPrint _x_
283  #else
284  #define ExtPrint(_x_) {NOTHING;}
285  #endif //USE_MM_PRINT
286 
287 #else
288  #define KdPrint(x) {NOTHING;}
289  #define MmPrint(_x_) {NOTHING;}
290  #define TmPrint(_x_) {NOTHING;}
291  #define PerfPrint(_x_) {NOTHING;}
292  #define AdPrint(_x_) {NOTHING;}
293  #define ThPrint(_x_) {NOTHING;}
294  #define ExtPrint(_x_) {NOTHING;}
295 #endif
296 
297 #define DbgTouch(a)
298 
299 #ifndef NT_NATIVE_MODE
300 #include "assert.h"
301 
302 #define ASSERT(_x_) assert(_x_)
303 #define UDFTouch(a)
304 
305 #endif //NT_NATIVE_MODE
306 
307 #define NonPagedPool 0
308 #define PagedPool 1
309 //#define NonPagedPoolMustSucceed 2
310 #define NonPagedPoolCacheAligned 4
311 
312 #define KdDump(a,b) \
313 if((a)!=NULL) { \
314  ULONG i; \
315  for(i=0; i<(b); i++) { \
316  ULONG c; \
317  c = (ULONG)(*(((PUCHAR)(a))+i)); \
318  KdPrint(("%2.2x ",c)); \
319  if ((i & 0x0f) == 0x0f) KdPrint(("\n")); \
320  } \
321  KdPrint(("\n")); \
322 }
323 
324 //mem ot
325 //#define ExAllocatePool(hernya,size) MyAllocatePool(size)
326 //#define ExFreePool(size) MyFreePool((PCHAR)(size))
327 //#define SystemAllocatePool(hernya,size) GlobalAlloc(GMEM_DISCARDABLE, size);
328 //#define SystemFreePool(addr) GlobalFree((PVOID)(addr))
329 #define DbgMoveMemory RtlMoveMemory
330 #define DbgCompareMemory RtlCompareMemory
331 #define DbgCopyMemory RtlCopyMemory
332 #define DbgAllocatePool ExAllocatePool
333 #define DbgAllocatePoolWithTag(a,b,c) ExAllocatePool(a,b)
334 #define DbgFreePool ExFreePool
335 
336 #ifdef NT_NATIVE_MODE
337 /*
338 #define GlobalAlloc(foo, size) MyGlobalAlloc( size );
339 #define GlobalFree(ptr) MyGlobalFree( ptr );
340 
341 extern "C"
342 PVOID MyGlobalAlloc(ULONG Size);
343 
344 extern "C"
345 VOID MyGlobalFree(PVOID Addr);
346 */
347 #endif
348 
349 #if !defined(KERNEL_MODE_MM_BEHAVIOR) && !defined(USE_THREAD_HEAPS)
350 #define ExAllocatePoolWithTag(hernya,size,tag) GlobalAlloc(GMEM_DISCARDABLE, (size))
351 #define ExAllocatePool(hernya,size) GlobalAlloc(GMEM_DISCARDABLE, (size))
352 #define ExFreePool(addr) GlobalFree((PVOID)(addr))
353 #endif
354 
355 #if defined(KERNEL_MODE_MM_BEHAVIOR) || defined(USE_THREAD_HEAPS)
356 #define ExAllocatePoolWithTag(MemoryType,size,tag) ExAllocatePool((MemoryType), (size))
357 
358 extern "C"
360 
361 extern "C"
362 VOID ExFreePool(PVOID Addr);
363 #endif //KERNEL_MODE_MM_BEHAVIOR || USE_THREAD_HEAPS
364 
365 #ifndef NT_NATIVE_MODE
366 
367 //string ot
368 typedef struct _UNICODE_STRING {
374 
375 typedef struct _ANSI_STRING {
379 } ANSI_STRING;
381 
382 #endif //NT_NATIVE_MODE
383 
384 #define PtrOffset(BASE,OFFSET) ((ULONG)((ULONG)(OFFSET) - (ULONG)(BASE)))
385 
386 // Device object ot
387 
388 #ifndef DO_UNLOAD_PENDING
389 // Define Device Object (DO) flags
390 //
391 
392 #define DO_UNLOAD_PENDING 0x00000001
393 #define DO_VERIFY_VOLUME 0x00000002
394 #define DO_BUFFERED_IO 0x00000004
395 #define DO_EXCLUSIVE 0x00000008
396 #define DO_DIRECT_IO 0x00000010
397 #define DO_MAP_IO_BUFFER 0x00000020
398 #define DO_DEVICE_HAS_NAME 0x00000040
399 #define DO_DEVICE_INITIALIZING 0x00000080
400 #define DO_SYSTEM_BOOT_PARTITION 0x00000100
401 #define DO_LONG_TERM_REQUESTS 0x00000200
402 #define DO_NEVER_LAST_DEVICE 0x00000400
403 #define DO_SHUTDOWN_REGISTERED 0x00000800
404 
405 #endif //DO_UNLOAD_PENDING
406 
407 #ifdef NT_NATIVE_MODE
408 #define _DEVICE_OBJECT _MY_DEVICE_OBJECT
409 #define DEVICE_OBJECT MY_DEVICE_OBJECT
410 #define PDEVICE_OBJECT PMY_DEVICE_OBJECT
411 #endif //NT_NATIVE_MODE
412 
413 typedef struct _DEVICE_OBJECT {
414 
415 #ifndef LIBUDF
416 
422 
423 #endif // LIBUDF
424 
425 
426 #ifdef LIBUDFFMT
427 
428  struct _UDF_FMT_PARAMETERS* cbio;
429  PVOID lpContext;
430 
431 #else
432 #ifdef LIBUDF
433  PVOID lpContext;
434 #endif // LIBUDF
435 #endif // LIBUDFFMT
436 
438 
439 #ifndef CDRW_W32
440 /*
441 typedef ULONG DEVICE_OBJECT;
442 typedef ULONG PDEVICE_OBJECT;
443 */
444 #define INVALID_PACKET 0x01
445 
446 typedef struct _PACKET {
447  // Node Identifier
448 // UDFIdentifier NodeIdentifier;
449  // Pointer to the buffer (in non-paged pool)
451  // Offset, from which this data was read
453  // Flags
455 } PACKET, *PPACKET;
456 
457 #define UDFInitPacket(x) STATUS_SUCCESS
458 #endif //CDRW_W32
459 
460 #define try_return(S) { S; goto try_exit; }
461 #define NOTHING
462 
463 #define FlagOn(x,f) ((x) & (f))
464 
465 #define RtlCompareMemory(s1,s2,l) MyRtlCompareMemory(s1,s2,l)
466 // Structure ot
467 extern "C"
468 ULONG
470  PVOID s1,
471  PVOID s2,
472  ULONG len
473  );
474 //#define RtlCompareMemory(d1,d2,l) (ULONG)(memcmp (d1,d2,l))
475 
476 #define KeSetEvent(pEvt, foo, foo2) {NOTHING;}
477 #define KeInitializeEvent(pEvt, foo, foo2) {NOTHING;}
478 #define KeWaitForSingleObject(pEvt, foo, a, b, c) {NOTHING;}
479 #define DbgWaitForSingleObject(o, to) KeWaitForSingleObject(o, Executive, KernelMode, FALSE, to);
480 //#define DbgWaitForSingleObject KeWaitForSingleObject
481 #ifdef NT_NATIVE_MODE
482 #define KeDelayExecutionThread(mode, foo, t) { NtDelayExecution(false, t); }
483 #else //NT_NATIVE_MODE
484 #define KeDelayExecutionThread(mode, foo, t) { Sleep( abs((LONG)(((t)->QuadPart)/10000)) ); }
485 #endif //NT_NATIVE_MODE
486 
487 /*#define RtlCompareUnicodeString(s1,s2,cs) \
488  (((s1)->Length == (s2)->Length) && \
489  (RtlCompareMemory(s1,s2,(s1)->Length)))
490 */
491 #ifndef CDRW_W32
492 #ifdef _X86_
493 
494 // This is an illegal use of INT3
495 #define UDFBreakPoint() __asm int 3
496 #else // _X86_
497 
498 #define UDFBreakPoint() DbgBreakPoint()
499 #endif // _X86_
500 
501 #ifdef BRUTE
502 #define BrutePoint() UDFBreakPoint()
503 #else
504 #define BrutePoint() {}
505 #endif // BRUTE
506 
507 #ifdef VALIDATE_STRUCTURES
508 #define ValidateFileInfo(fi) \
509 { /* validate FileInfo */ \
510  if((fi)->IntegrityTag) { \
511  KdPrint(("UDF: ERROR! Using deallocated structure !!!\n"));\
512  /*BrutePoint();*/ \
513  } \
514 }
515 #else
516 #define ValidateFileInfo(fi) {}
517 #endif
518 
519 #else //CDRW_W32
520 
521 #ifdef BRUTE
522 #ifdef _X86_
523 
524 // This is an illegal use of INT3
525 #define BrutePoint() __asm int 3
526 #else // _X86_
527 
528 #define BrutePoint() DbgBreakPoint()
529 #endif // _X86_
530 #else
531 #define BrutePoint() {}
532 #endif // BRUTE
533 
534 #endif //CDRW_W32
535 
536 #ifndef NT_NATIVE_MODE
537 
538 extern "C"
539 ULONG
543  BOOLEAN UpCase);
544 
545 extern "C"
546 NTSTATUS
550  BOOLEAN Alloc
551  );
552 
553 extern "C"
554 NTSTATUS
556  IN PUNICODE_STRING Str1,
557  IN PWSTR Str2
558  );
559 
560 #endif //NT_NATIVE_MODE
561 
562 extern "C"
563 NTSTATUS
565  IN PUNICODE_STRING Str1,
566  IN PCWSTR Str2
567  );
568 
569 #ifndef NT_NATIVE_MODE
570 #define KeQuerySystemTime(t) GetSystemTimeAsFileTime((LPFILETIME)(t));
571 
588 
589 #endif //NT_NATIVE_MODE
590 
591 typedef UCHAR KIRQL;
592 typedef KIRQL *PKIRQL;
593 
594 typedef ULONG ERESOURCE;
596 
597 #define KeRaiseIrql(irql, oldIrql) \
598 { \
599  *oldIrql = 0; \
600 }
601 
602 #define KeLowerIrql(oldIrql) {;}
603 
604 #define KeInitializeSpinLock(sl) \
605 { \
606  *(sl) = 0; \
607 }
608 
609 #define KeAcquireSpinLock(sl,irql) \
610 { \
611  ULONG isLocked = TRUE; \
612  while(isLocked) AcquireXLock(*(sl), isLocked, TRUE);\
613 }
614 
615 #define ExAcquireResourceExclusiveLite(res, wait) \
616 { \
617  ULONG isLocked = TRUE; \
618  while(isLocked) AcquireXLock(*(res), isLocked, TRUE);\
619 }
620 
621 #define ExAcquireResourceSharedLite(res, wait) \
622 { \
623  ULONG isLocked = TRUE; \
624  while(isLocked) AcquireXLock(*(res), isLocked, TRUE);\
625 }
626 
627 #define KeReleaseSpinLock(sl,irql) \
628 { \
629  ULONG isLocked; \
630  AcquireXLock(*(sl), isLocked, FALSE); \
631 }
632 
633 #define ExGetCurrentResourceThread() 0
634 
635 #define ExReleaseResourceForThreadLite(res, thrdID) \
636 { \
637  ULONG isLocked; \
638  AcquireXLock(*(res), isLocked, FALSE); \
639 }
640 
642 {
643  *(res) = 0;
644  return STATUS_SUCCESS;
645 }
646 
647 #define ExDeleteResourceLite(res) \
648 { \
649  *(res) = 0; \
650 }
651 
652 #define ExConvertExclusiveToSharedLite(res) {/* do nothing */}
653 
654 #ifndef CDRW_W32
655 
656 #define UDFAcquireResourceExclusive(Resource,CanWait) \
657  ExAcquireResourceExclusiveLite((Resource),(CanWait))
658 #define UDFAcquireResourceShared(Resource,CanWait) \
659  ExAcquireResourceSharedLite((Resource),(CanWait))
660 // a convenient macro (must be invoked in the context of the thread that acquired the resource)
661 #define UDFReleaseResource(Resource) \
662  ExReleaseResourceForThreadLite((Resource), ExGetCurrentResourceThread())
663 #define UDFDeleteResource(Resource) \
664  ExDeleteResourceLite((Resource))
665 #define UDFConvertExclusiveToSharedLite(Resource) \
666  ExConvertExclusiveToSharedLite((Resource))
667 #define UDFInitializeResourceLite(Resource) \
668  ExInitializeResourceLite((Resource))
669 #define UDFAcquireSharedStarveExclusive(Resource,CanWait) \
670  ExAcquireSharedStarveExclusive((Resource),(CanWait))
671 #define UDFAcquireSharedWaitForExclusive(Resource,CanWait) \
672  ExAcquireSharedWaitForExclusive((Resource),(CanWait))
673 //#define UDFDebugAcquireResourceExclusiveLite(a,b,c,d) ExAcquireResourceExclusiveLite(a,b)
674 
675 #define UDFInterlockedIncrement(addr) \
676  ((*addr)++)
677 #define UDFInterlockedDecrement(addr) \
678  ((*addr)--)
679 int
680 __inline
682  LONG Old = (*addr);
683  (*addr) += i;
684  return Old;
685 }
686 
687 #endif //CDRW_W32
688 
689 //
690 // Interrupt Request Level definitions
691 //
692 
693 #define PASSIVE_LEVEL 0 // Passive release level
694 #define LOW_LEVEL 0 // Lowest interrupt level
695 #define APC_LEVEL 1 // APC interrupt level
696 #define DISPATCH_LEVEL 2 // Dispatcher level
697 
698 #define PROFILE_LEVEL 27 // timer used for profiling.
699 #define CLOCK1_LEVEL 28 // Interval clock 1 level - Not used on x86
700 #define CLOCK2_LEVEL 28 // Interval clock 2 level
701 #define IPI_LEVEL 29 // Interprocessor interrupt level
702 #define POWER_LEVEL 30 // Power failure level
703 #define HIGH_LEVEL 31 // Highest interrupt level
704 #define SYNCH_LEVEL (IPI_LEVEL-1) // synchronization level
705 
706 #define KeGetCurrentIrql() PASSIVE_LEVEL
707 
708 #ifndef NT_NATIVE_MODE
709 
710 typedef struct _TIME_FIELDS {
711  USHORT Year; // range [1601...]
712  USHORT Month; // range [1..12]
713  USHORT Day; // range [1..31]
714  USHORT Hour; // range [0..23]
715  USHORT Minute; // range [0..59]
716  USHORT Second; // range [0..59]
717  USHORT Milliseconds;// range [0..999]
718  USHORT Weekday; // range [0..6] == [Sunday..Saturday]
719 } TIME_FIELDS;
721 
722 //#define RtlTimeFieldsToTime(a,b) TRUE
723 BOOLEAN
727  );
728 
729 #define ExSystemTimeToLocalTime(SysTime, LocTime) FileTimeToLocalFileTime((PFILETIME)(SysTime), (PFILETIME)(LocTime))
730 
731 //#define RtlTimeToTimeFields(a,b) {}
732 BOOLEAN
736  );
737 
738 #define ExLocalTimeToSystemTime(LocTime, SysTime) LocalFileTimeToFileTime((PFILETIME)(LocTime), (PFILETIME)(SysTime))
739 
740 #endif //NT_NATIVE_MODE
741 
742 #ifndef CDRW_W32
743 
744 typedef struct _FSRTL_COMMON_FCB_HEADER {
749 #if (_WIN32_WINNT >= 0x0400)
750  UCHAR Flags2;
751  UCHAR Reserved;
752 #endif // (_WIN32_WINNT >= 0x0400)
759 
760 typedef struct _SECTION_OBJECT_POINTERS {
766 
767 
769  PDEVICE_OBJECT DeviceObject,
770  PVOID Buffer,
771  ULONG Length,
774  ULONG Flags);
775 
777  PDEVICE_OBJECT DeviceObject, // the physical device object
778  PVOID Buffer,
779  ULONG Length,
781  PULONG WrittenBytes,
782  ULONG Flags);
783 
784 #if 0
785 extern NTSTATUS
787  PDEVICE_OBJECT DeviceObject, // the physical device object
788  PVOID Buffer,
789  ULONG Length,
791  PULONG WrittenBytes,
792  ULONG Flags
793  );
794 #endif
795 
796 #define UDFPhWriteVerifySynchronous UDFPhWriteSynchronous
797 
798 extern NTSTATUS UDFPhSendIOCTL(
800  IN PDEVICE_OBJECT DeviceObject,
805  IN BOOLEAN OverrideVerify,
807 
808 #endif //CDRW_W32
809 
811 // ULONG LBA);
812  int64 len);
813 
814 #ifdef UDF_FORMAT_MEDIA
816 #endif
817 
818 #ifndef UDF_FORMAT_MEDIA
819 ULONG write(
820  HANDLE h,
821  PCHAR buff,
822  ULONG len);
823 #endif
824 
825 extern "C"
826 HANDLE
827 my_open(
828 #ifndef CDRW_W32
829  struct _UDFVolumeControlBlock* Vcb,
830 #endif //CDRW_W32
831  PWCHAR fn);
832 
833 #ifdef UDF_FORMAT_MEDIA
834 struct _UDFFmtState;
835 #endif //UDF_FORMAT_MEDIA
836 
837 extern
838 void
839 my_exit(
840 #ifdef UDF_FORMAT_MEDIA
841  struct _UDFFmtState* fms,
842 #endif //UDF_FORMAT_MEDIA
843  int rc
844  );
845 
846 #ifndef CDRW_W32
847 uint64 udf_lseek64(HANDLE fd, uint64 offset, int whence);
848 #endif //CDRW_W32
849 
850 #ifdef LIBUDFFMT
851 BOOLEAN
852 udf_get_sizes(
853  IN PDEVICE_OBJECT DeviceObject,
854  IN ULONG* blocks
855  );
856 #endif //LIBUDFFMT
857 
858 int64
860  HANDLE h
861  );
862 
863 int64
865  HANDLE h,
866  int64 sz
867  );
868 
869 #ifndef NT_NATIVE_MODE
870 typedef struct _IO_STATUS_BLOCK {
874 #endif //NT_NATIVE_MODE
875 
876 
877 #ifndef UDF_FORMAT_MEDIA
878 extern ULONG LockMode;
879 extern BOOLEAN open_as_device;
881 #endif //UDF_FORMAT_MEDIA
882 
883 extern "C"
884 ULONG
886  HANDLE h,
887  ULONG* pLockMode // OUT
888  );
889 
890 extern "C"
891 ULONG
893  HANDLE h,
894  ULONG* pLockMode // IN
895  );
896 
897 #ifndef CDRW_W32
898 ULONG
899 UDFGetDevType(PDEVICE_OBJECT DeviceObject);
900 #endif //CDRW_W32
901 
902 #ifndef INVALID_HANDLE_VALUE
903 #define INVALID_HANDLE_VALUE ((HANDLE)(-1))
904 #endif
905 
906 #ifndef ANSI_DOS_STAR
907 
908 #define ANSI_DOS_STAR ('<')
909 #define ANSI_DOS_QM ('>')
910 #define ANSI_DOS_DOT ('"')
911 
912 #define DOS_STAR (L'<')
913 #define DOS_QM (L'>')
914 #define DOS_DOT (L'"')
915 
916 #endif //ANSI_DOS_STAR
917 
918 extern "C"
919 BOOLEAN
921  PVOID MemPtr,
922  ULONG Length,
923  BOOLEAN ForWrite
924  );
925 
926 #ifdef NT_NATIVE_MODE
927 #include "env_spec_nt.h"
928 #endif //NT_NATIVE_MODE
929 
930 #ifndef InitializeListHead
931 
932 //
933 // Doubly-linked list manipulation routines. Implemented as macros
934 // but logically these are procedures.
935 //
936 
937 //
938 // VOID
939 // InitializeListHead(
940 // PLIST_ENTRY ListHead
941 // );
942 //
943 
944 #define InitializeListHead(ListHead) (\
945  (ListHead)->Flink = (ListHead)->Blink = (ListHead))
946 
947 //
948 // BOOLEAN
949 // IsListEmpty(
950 // PLIST_ENTRY ListHead
951 // );
952 //
953 
954 #define IsListEmpty(ListHead) \
955  ((ListHead)->Flink == (ListHead))
956 
957 //
958 // PLIST_ENTRY
959 // RemoveHeadList(
960 // PLIST_ENTRY ListHead
961 // );
962 //
963 
964 #define RemoveHeadList(ListHead) \
965  (ListHead)->Flink;\
966  {RemoveEntryList((ListHead)->Flink)}
967 
968 //
969 // PLIST_ENTRY
970 // RemoveTailList(
971 // PLIST_ENTRY ListHead
972 // );
973 //
974 
975 #define RemoveTailList(ListHead) \
976  (ListHead)->Blink;\
977  {RemoveEntryList((ListHead)->Blink)}
978 
979 //
980 // VOID
981 // RemoveEntryList(
982 // PLIST_ENTRY Entry
983 // );
984 //
985 
986 #define RemoveEntryList(Entry) {\
987  PLIST_ENTRY _EX_Blink;\
988  PLIST_ENTRY _EX_Flink;\
989  _EX_Flink = (Entry)->Flink;\
990  _EX_Blink = (Entry)->Blink;\
991  _EX_Blink->Flink = _EX_Flink;\
992  _EX_Flink->Blink = _EX_Blink;\
993  }
994 
995 //
996 // VOID
997 // InsertTailList(
998 // PLIST_ENTRY ListHead,
999 // PLIST_ENTRY Entry
1000 // );
1001 //
1002 
1003 #define InsertTailList(ListHead,Entry) {\
1004  PLIST_ENTRY _EX_Blink;\
1005  PLIST_ENTRY _EX_ListHead;\
1006  _EX_ListHead = (ListHead);\
1007  _EX_Blink = _EX_ListHead->Blink;\
1008  (Entry)->Flink = _EX_ListHead;\
1009  (Entry)->Blink = _EX_Blink;\
1010  _EX_Blink->Flink = (Entry);\
1011  _EX_ListHead->Blink = (Entry);\
1012  }
1013 
1014 //
1015 // VOID
1016 // InsertHeadList(
1017 // PLIST_ENTRY ListHead,
1018 // PLIST_ENTRY Entry
1019 // );
1020 //
1021 
1022 #define InsertHeadList(ListHead,Entry) {\
1023  PLIST_ENTRY _EX_Flink;\
1024  PLIST_ENTRY _EX_ListHead;\
1025  _EX_ListHead = (ListHead);\
1026  _EX_Flink = _EX_ListHead->Flink;\
1027  (Entry)->Flink = _EX_Flink;\
1028  (Entry)->Blink = _EX_ListHead;\
1029  _EX_Flink->Blink = (Entry);\
1030  _EX_ListHead->Flink = (Entry);\
1031  }
1032 
1033 #endif //InitializeListHead
1034 
1035 #endif // __ENV_SPEC_W32__H_
unsigned long long uint64
Definition: platform.h:18
DWORD *typedef PVOID
Definition: winlogon.h:52
int __inline UDFInterlockedExchangeAdd(PLONG addr, LONG i)
Definition: env_spec_w32.h:681
USHORT Weekday
Definition: env_spec_w32.h:718
ACPI_EFI_MEMORY_TYPE
Definition: acefiex.h:128
#define STATUS_SUCCESS
Definition: contextmenu.cpp:55
VOID set_image_size(HANDLE h, int64 len)
const uint16_t * PCWSTR
Definition: typedefs.h:56
#define IN
Definition: typedefs.h:39
ULONG UDFGetDevType(PDEVICE_OBJECT DeviceObject)
struct S2 s2
NTSTATUS RtlUpcaseUnicodeString(PUNICODE_STRING dst, PUNICODE_STRING src, BOOLEAN Alloc)
Definition: string_lib.cpp:46
LARGE_INTEGER offset
Definition: env_spec_w32.h:452
_Must_inspect_result_ _In_ PFILE_OBJECT _In_ ULONG IoControlCode
Definition: fltkernel.h:1383
ULONG write(HANDLE h, PCHAR buff, ULONG len)
struct _SKIN_API SKIN_API
USHORT MaximumLength
Definition: env_spec_w32.h:370
static GLenum _GLUfuncptr fn
Definition: wgl_font.c:159
__wchar_t WCHAR
Definition: xmlstorage.h:180
struct _DEVICE_OBJECT * PDEVICE_OBJECT
TIME_FIELDS * PTIME_FIELDS
Definition: env_spec_w32.h:720
ULONG PVOID ULONG DataInLen
Definition: env_spec_w32.h:127
int64 set_file_pointer(HANDLE h, int64 sz)
ULONG MyUnlockVolume(HANDLE h, ULONG *pLockMode)
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)
PVOID *typedef PWSTR
Definition: winlogon.h:57
NTSTATUS ExInitializeResourceLite(PULONG res)
Definition: env_spec_w32.h:641
_Must_inspect_result_ _In_ PFILE_OBJECT _In_ ULONG _In_ ULONG _In_ ULONG OutputBufferLength
Definition: fltkernel.h:1374
KSPIN_LOCK * PKSPIN_LOCK
Definition: env_spec_w32.h:73
_In_ PLARGE_INTEGER _In_ ULONG _In_ BOOLEAN _In_ ULONG _Out_ PVOID _Out_ PIO_STATUS_BLOCK _In_ PDEVICE_OBJECT DeviceObject
Definition: npfs.h:636
uint16_t * PWCHAR
Definition: typedefs.h:55
long long int64
Definition: platform.h:13
int(* PSKIN_INIT)(HINSTANCE hInstance, HINSTANCE hPrevInstance, int nCmdShow)
Definition: env_spec_w32.h:107
CHAR InputBuffer[80]
Definition: conmgr.c:33
GLfloat GLfloat GLfloat GLfloat h
Definition: glext.h:7723
_Must_inspect_result_ _Out_ PIO_STATUS_BLOCK Iosb
Definition: fltkernel.h:1761
NTSTATUS MyInitUnicodeString(IN PUNICODE_STRING Str1, IN PCWSTR Str2)
UCHAR KIRQL
Definition: env_spec_w32.h:591
GLuint const GLubyte GLvoid * src
Definition: s_context.h:57
void my_exit(int rc)
_Must_inspect_result_ _In_ ULONG Flags
Definition: wsk.h:170
GLenum GLclampf GLint i
Definition: glfuncs.h:14
HINSTANCE hInstance
Definition: charmap.c:19
ERESOURCE * PERESOURCE
Definition: env_spec_w32.h:595
_In_ ULONG _In_ ULONG Offset
Definition: ntddpcm.h:101
long LONG
Definition: pedump.c:60
short SHORT
Definition: pedump.c:59
SECTION_OBJECT_POINTERS * PSECTION_OBJECT_POINTERS
Definition: env_spec_w32.h:765
ULONG UdfTimeStamp
Definition: udf_dbg.cpp:14
LARGE_INTEGER AllocationSize
Definition: env_spec_w32.h:580
PVOID DeviceExtension
Definition: env_spec_w32.h:418
#define UDFPhWriteVerifySynchronous
Definition: env_spec_w32.h:796
struct _SKIN_API * PSKIN_API
struct _PACKET PACKET
BOOLEAN RtlTimeToTimeFields(IN PLARGE_INTEGER Time, IN PTIME_FIELDS TimeFields)
Definition: bufpool.h:45
_Must_inspect_result_ __drv_aliasesMem _In_ PDEVICE_OBJECT _In_opt_ PVOID _In_ ULONG _Out_opt_ PVOID OutputBuffer
Definition: iofuncs.h:713
#define ExAllocatePool(hernya, size)
Definition: env_spec_w32.h:351
static int blocks
Definition: mkdosfs.c:527
USHORT Milliseconds
Definition: env_spec_w32.h:717
static NTSTATUS ReadBytes(IN PDEVICE_OBJECT LowerDevice, OUT PUCHAR Buffer, IN ULONG BufferSize, OUT PULONG_PTR FilledBytes)
Definition: detect.c:67
UINTN Size
Definition: acefiex.h:550
ULONG PVOID ULONG PVOID DataOut
Definition: env_spec_w32.h:127
NTSTATUS RtlAppendUnicodeToString(IN PUNICODE_STRING Str1, IN PWSTR Str2)
Definition: string_lib.cpp:62
USHORT MaximumLength
Definition: env_spec_w32.h:377
int64_t LONGLONG
Definition: typedefs.h:67
unsigned char BOOLEAN
PSKIN_PRINTF Printf
Definition: env_spec_w32.h:136
ULONG MyLockVolume(HANDLE h, ULONG *pLockMode)
int64 get_file_size(HANDLE h)
ULONG PVOID ULONG PVOID ULONG DataInOut
Definition: env_spec_w32.h:127
ULONG LockMode
Definition: env_spec_w32.cpp:8
char CCHAR
Definition: typedefs.h:51
struct S1 s1
ANSI_STRING * PANSI_STRING
Definition: env_spec_w32.h:380
PVOID Alloc(IN DWORD dwFlags, IN SIZE_T dwBytes)
Definition: main.c:63
#define fms
UCHAR flags
Definition: env_spec_w32.h:454
NTSTATUS UDFPhWriteSynchronous(PDEVICE_OBJECT DeviceObject, PVOID Buffer, ULONG Length, LONGLONG Offset, PULONG WrittenBytes, ULONG Flags)
Definition: env_spec.cpp:276
#define __stdcall
Definition: typedefs.h:26
struct _IO_STATUS_BLOCK * PIO_STATUS_BLOCK
Definition: change.c:34
BOOLEAN RtlTimeFieldsToTime(IN PTIME_FIELDS TimeFields, IN PLARGE_INTEGER Time)
ULONG PVOID DataIn
Definition: env_spec_w32.h:127
BOOLEAN open_as_device
#define SkinLoad(path)
Definition: env_spec_w32.h:158
int(* PSKIN_PRINTF)(const char *Message,...)
Definition: env_spec_w32.h:114
CHAR Message[80]
Definition: alive.c:5
HANDLE HINSTANCE
Definition: typedefs.h:76
unsigned char UCHAR
Definition: xmlstorage.h:181
struct _DEVICE_OBJECT DEVICE_OBJECT
struct _ANSI_STRING ANSI_STRING
GLenum const GLvoid * addr
Definition: glext.h:9621
ULONG RtlCompareUnicodeString(PUNICODE_STRING s1, PUNICODE_STRING s2, BOOLEAN UpCase)
Definition: string_lib.cpp:31
VOID UINTN Length
Definition: acefiex.h:718
#define VOID
Definition: acefi.h:69
KIRQL * PKIRQL
Definition: env_spec_w32.h:592
uint64 udf_lseek64(HANDLE fd, uint64 offset, int whence)
GLenum GLsizei len
Definition: glext.h:6722
LARGE_INTEGER AllocationSize
Definition: env_spec_w32.h:755
PCHAR buffer
Definition: env_spec_w32.h:450
struct _SECTION_OBJECT_POINTERS SECTION_OBJECT_POINTERS
ULONG AlignmentRequirement
Definition: env_spec_w32.h:420
ULONG PVOID Reserved
Definition: ntimage.h:533
struct _FSRTL_COMMON_FCB_HEADER FSRTL_COMMON_FCB_HEADER
_Must_inspect_result_ _In_ PFILE_OBJECT _In_ ULONG _In_ ULONG InputBufferLength
Definition: fltkernel.h:1372
typedef PWCHAR(__stdcall *PSKIN_GETCMDLINE)(VOID)
struct _TIME_FIELDS TIME_FIELDS
DWORD *typedef HANDLE
Definition: winlogon.h:52
static HANDLE fd
Definition: io.c:55
LONG NTSTATUS
Definition: DriverTester.h:11
ULONG MyRtlCompareMemory(PVOID s1, PVOID s2, ULONG len)
Definition: string_lib.cpp:9
unsigned short USHORT
Definition: pedump.c:61
ULONG KSPIN_LOCK
Definition: env_spec_w32.h:72
Definition: services.c:311
signed char * PSTR
Definition: retypes.h:7
HANDLE my_open(struct _UDFVolumeControlBlock *Vcb, PWCHAR fn)
unsigned int * PULONG
Definition: retypes.h:1
struct _PACKET * PPACKET
PSKIN_INIT Init
Definition: env_spec_w32.h:135
GLuint const GLubyte GLvoid const GLvoid * dst
Definition: s_context.h:57
UNICODE_STRING * PUNICODE_STRING
Definition: env_spec_w32.h:373
struct _UNICODE_STRING UNICODE_STRING
#define Vcb
typedef ULONG(__stdcall *PSKIN_MSG)(ULONG MsgId
signed char * PCHAR
Definition: retypes.h:7
#define OUT
Definition: typedefs.h:40
GLuint res
Definition: glext.h:9613
ULONG ERESOURCE
Definition: env_spec_w32.h:594
NTSTATUS UDFPhReadSynchronous(PDEVICE_OBJECT DeviceObject, PVOID Buffer, ULONG Length, LONGLONG Offset, PULONG ReadBytes, ULONG Flags)
Definition: env_spec.cpp:130
unsigned int ULONG
Definition: retypes.h:1
PSKIN_MSG Msg
Definition: env_spec_w32.h:138
LARGE_INTEGER LastAccessTime
Definition: env_spec_w32.h:576
ULONG MsgSubId
Definition: env_spec_w32.h:127
BOOLEAN opt_invalidate_volume
Definition: env_spec_w32.cpp:9
struct _FILE_BOTH_DIR_INFORMATION FILE_BOTH_DIR_INFORMATION
struct _FILE_BOTH_DIR_INFORMATION * PFILE_BOTH_DIR_INFORMATION
LARGE_INTEGER ValidDataLength
Definition: env_spec_w32.h:757
static PTIME_FIELDS TimeFields
Definition: time.c:27
localAdvHdr Flags2
Definition: fsrtlfuncs.h:1695
signed int * PLONG
Definition: retypes.h:5
static unsigned char buff[32768]
Definition: fatten.c:17
struct _IO_STATUS_BLOCK IO_STATUS_BLOCK
VOID PrintDbgConsole(PCHAR DebugMessage,...)
IN HDEVINFO IN PSP_DEVINFO_DATA DeviceInfoData OPTIONAL
Definition: devinst.c:44
static PLARGE_INTEGER Time
Definition: time.c:28
#define ExFreePool(addr)
Definition: env_spec_w32.h:352
struct _FSRTL_COMMON_FCB_HEADER * PFSRTL_COMMON_FCB_HEADER
BOOLEAN ProbeMemory(PVOID MemPtr, ULONG Length, BOOLEAN ForWrite)
PSKIN_GETCMDLINE GetCommandLine
Definition: env_spec_w32.h:137
GLintptr offset
Definition: glext.h:5920
unsigned int(__cdecl typeof(jpeg_read_scanlines))(struct jpeg_decompress_struct *
Definition: typeof.h:29