Leaked source code of windows server 2003
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

243 lines
7.5 KiB

  1. /******************************Module*Header*******************************\
  2. * Module Name: usermode.h
  3. *
  4. * This file contains all the system abstraction definitions required to allow
  5. * GDI to run as a stand-alone graphics library in user-mode.
  6. *
  7. * Copyright (c) 1998-1999 Microsoft Corporation
  8. \**************************************************************************/
  9. #include <nturtl.h>
  10. #include <winbase.h>
  11. #include <winnls.h>
  12. // Prototype for GDI+ virtual screen driver entry point:
  13. BOOL GpsEnableDriver(ULONG, ULONG, DRVENABLEDATA*);
  14. // User-mode GDI doesn't require any security probing:
  15. #undef ProbeForRead
  16. #undef ProbeForWrite
  17. #undef ProbeAndReadStructure
  18. #undef ProbeAndWriteStructure
  19. #undef ProbeAndReadUlong
  20. #undef ProbeAndWriteUlong
  21. #define ProbeForRead(a, b, c) 0
  22. #define ProbeForWrite(a, b, c) 0
  23. #define ProbeAndReadStructure(a, b) (*(b *)(a))
  24. #define ProbeAndWriteStructure(a, b, c) (*(a) = (b))
  25. #define ProbeAndReadUlong(a) (*(ULONG *)(a))
  26. #define ProbeAndWriteUlong(a, b) (*(a) = (b))
  27. #undef IS_SYSTEM_ADDRESS
  28. #undef MM_LOWEST_USER_ADDRESS
  29. #undef MM_HIGHEST_USER_ADDRESS
  30. #undef MM_USER_PROBE_ADDRESS
  31. #define MM_LOWEST_USER_ADDRESS NULL
  32. #define MM_HIGHEST_USER_ADDRESS ((VOID*) 0xffffffff)
  33. #define MM_USER_PROBE_ADDRESS 0xffffffff
  34. #define ExSystemExceptionFilter() EXCEPTION_EXECUTE_HANDLER
  35. // The following are not needed for user-mode GDI:
  36. #define KeSaveFloatingPointState(a) STATUS_SUCCESS
  37. #define KeRestoreFloatingPointState(a) STATUS_SUCCESS
  38. #define UserScreenAccessCheck() TRUE
  39. #define UserGetHwnd(a, b, c, d) 0
  40. #define UserAssertUserCritSecOut()
  41. #define UserEnterUserCritSec()
  42. #define UserLeaveUserCritSec()
  43. #define UserIsUserCritSecIn() 0
  44. #define UserAssertUserCritSecIn()
  45. #define UserRedrawDesktop()
  46. #define UserReleaseDC(a)
  47. #define UserGetClientRgn(a, b, c) 0
  48. #define UserAssociateHwnd(a, b)
  49. #define UserSetTimer(a,b) 1
  50. #define UserKillTimer(a)
  51. #define ClientPrinterThunk(a, b, c, d) 0xffffffff
  52. #define AlignRects(a, b, c, d) 0
  53. #define IofCallDriver(a, b) STATUS_UNSUCCESSFUL
  54. #define IoBuildSynchronousFsdRequest(a, b, c, d, e, f, g) 0
  55. #define IoInitializeIrp(a, b, c)
  56. #define IoBuildDeviceIoControlRequest(a, b, c, d, e, f, g, h, i) 0
  57. #define IoBuildAsynchronousFsdRequest(a, b, c, d, e, f) 0
  58. #define IoGetRelatedDeviceObject(a) 0
  59. #define IoReadOperationCount 0
  60. #define IoWriteOperationCount 0
  61. #define IoQueueThreadIrp(a)
  62. #define IoFreeIrp(a)
  63. #define IoAllocateMdl(a, b, c, d, e) 0
  64. #define IoFreeMdl(a)
  65. #define IoAllocateIrp(a, b) 0
  66. #define IoGetDeviceObjectPointer(a, b, c, d) STATUS_UNSUCCESSFUL
  67. #define IoOpenDeviceRegistryKey(a, b, c, d) STATUS_UNSUCCESSFUL
  68. #define IoGetRelatedDeviceObject(a) 0
  69. #define ObOpenObjectByPointer(a, b, c, d, e, f, g) STATUS_UNSUCCESSFUL
  70. #define ObReferenceObjectByHandle(a, b, c, d, e, f) STATUS_UNSUCCESSFUL
  71. #define ObfDereferenceObject(a) STATUS_UNSUCCESSFUL
  72. #define MmResetDriverPaging(a)
  73. #define MmGrowKernelStack(a) STATUS_SUCCESS
  74. #define MmQuerySystemSize() MmMediumSystem
  75. #undef KeEnterCriticalRegion
  76. #undef KeLeaveCriticalRegion
  77. #define KeEnterCriticalRegion()
  78. #define KeLeaveCriticalRegion()
  79. #define KeInitializeSpinLock(a)
  80. #define KeInitializeDpc(a, b, c)
  81. #define KeGetCurrentIrql() PASSIVE_LEVEL
  82. #define KeSetKernelStackSwapEnable(a) 0
  83. #define KeResetEvent(a)
  84. #undef SeStopImpersonatingClient
  85. #undef SeDeleteClientSecurity
  86. #define SeStopImpersonatingClient()
  87. #define SeDeleteClientSecurity(a)
  88. #define SeImpersonateClientEx(a, b) STATUS_UNSUCCESSFUL
  89. #define SeCreateClientSecurity(a, b, c, d) STATUS_UNSUCCESSFUL
  90. #define Win32UserProbeAddress 0
  91. #define HalRequestSoftwareInterrupt(x) 0
  92. #undef W32GetCurrentPID
  93. #define W32GetCurrentPID() ((W32PID) NtCurrentTeb()->ClientId.UniqueProcess)
  94. #undef W32GetCurrentProcess
  95. __inline PW32PROCESS W32GetCurrentProcess() { return(NULL); }
  96. #undef PsGetCurrentProcess
  97. __inline PEPROCESS PsGetCurrentProcess() { return(NULL); }
  98. // Re-route all the memory allocations:
  99. #define ExAllocatePoolWithTag(type, size, tag) \
  100. RtlAllocateHeap(RtlProcessHeap(), 0, (size))
  101. #define ExFreePool(p) RtlFreeHeap(RtlProcessHeap(), 0, (p))
  102. #define ExDeletePagedLookasideList(a)
  103. // Give up our time-slice when KeDelayExecutionThread called:
  104. #define KeDelayExecutionThread(a, b, c) Sleep(0)
  105. // @@@ The following are temporary (I hope!)
  106. #undef W32GetCurrentTID
  107. #undef W32GetCurrentThread
  108. __inline PW32THREAD W32GetCurrentThread() { return(NULL); } // @@@
  109. #define W32GetCurrentTID (W32PID) 0 // @@@
  110. #define ExIsProcessorFeaturePresent(a) 0
  111. /*
  112. comma expressions don't work in free builds since
  113. WARNING(x) and RIP(x) expand to nothing.
  114. */
  115. #if DBG
  116. #define IS_SYSTEM_ADDRESS(a) (RIP("IS_SYTEM_ADDRESS"), 0)
  117. #define MmSecureVirtualMemory(x, y, z) \
  118. (WARNING("@@@ MmSecureVirtualMemory"), (HANDLE) 1)
  119. #define MmUnsecureVirtualMemory(x)
  120. #define KeAttachProcess(x) \
  121. (WARNING("@@@ KeAttachProcess"), STATUS_UNSUCCESSFUL)
  122. #define KeDetachProcess() STATUS_UNSUCCESSFUL
  123. #undef KeInitializeEvent
  124. #define KeInitializeEvent(a, b, c) \
  125. (WARNING("@@@ KeInitializeEvent"), STATUS_UNSUCCESSFUL)
  126. #define KeSetEvent(a, b, c) \
  127. (RIP("KeSetEvent"), STATUS_UNSUCCESSFUL)
  128. #define KeWaitForSingleObject(a, b, c, d, e) \
  129. (RIP("KeWaitForSingleObject"), STATUS_UNSUCCESSFUL)
  130. #define KeWaitForMultipleObjects(a, b, c, d, e, f, g, h) \
  131. (RIP("KeWaitForMultipleObjects"), STATUS_UNSUCCESSFUL)
  132. #define MmMapViewOfSection(a, b, c, d, e, f, g, h, i, j) \
  133. (RIP("MmMapViewOfSection"), STATUS_UNSUCCESSFUL)
  134. #define MmUnmapViewOfSection(a, b) STATUS_UNSUCCESSFUL
  135. #define MmMapViewInSessionSpace(a, b, c) \
  136. (RIP("MmMapViewInSessionSpace"), STATUS_UNSUCCESSFUL)
  137. #define MmUnmapViewInSessionSpace(a) STATUS_UNSUCCESSFUL
  138. #define MmCreateSection(a, b, c, d, e, f, g, h) \
  139. (RIP("MmCreateSection"), STATUS_UNSUCCESSFUL)
  140. #else // !DBG
  141. #define IS_SYSTEM_ADDRESS(a) 0
  142. #define MmSecureVirtualMemory(x, y, z) ((HANDLE) 1)
  143. #define MmUnsecureVirtualMemory(x)
  144. #define KeAttachProcess(x) STATUS_UNSUCCESSFUL
  145. #define KeDetachProcess() STATUS_UNSUCCESSFUL
  146. #undef KeInitializeEvent
  147. #define KeInitializeEvent(a, b, c) STATUS_UNSUCCESSFUL
  148. #define KeSetEvent(a, b, c) STATUS_UNSUCCESSFUL
  149. #define KeWaitForSingleObject(a, b, c, d, e) STATUS_UNSUCCESSFUL
  150. #define KeWaitForMultipleObjects(a, b, c, d, e, f, g, h) STATUS_UNSUCCESSFUL
  151. #define MmMapViewOfSection(a, b, c, d, e, f, g, h, i, j) STATUS_UNSUCCESSFUL
  152. #define MmUnmapViewOfSection(a, b) STATUS_UNSUCCESSFUL
  153. #define MmMapViewInSessionSpace(a, b, c) STATUS_UNSUCCESSFUL
  154. #define MmUnmapViewInSessionSpace(a) STATUS_UNSUCCESSFUL
  155. #define MmCreateSection(a, b, c, d, e, f, g, h) STATUS_UNSUCCESSFUL
  156. #endif // !DBG
  157. __inline LARGE_INTEGER KeQueryPerformanceCounter(
  158. PLARGE_INTEGER PerformanceFrequency)
  159. {
  160. LARGE_INTEGER li = { 0, 0 };
  161. return(li);
  162. }
  163. #define RtlGetDefaultCodePage(a, b) \
  164. { \
  165. *(a) = (USHORT) GetACP(); \
  166. *(b) = (USHORT) GetOEMCP(); \
  167. }
  168. typedef struct _MEMORY_MAPPED_FILE
  169. {
  170. HANDLE fileMap;
  171. DWORD fileSize;
  172. BOOL readOnly;
  173. } MEMORY_MAPPED_FILE;
  174. NTSTATUS MapViewInProcessSpace(PVOID, PVOID*, ULONG*);
  175. NTSTATUS UnmapViewInProcessSpace(PVOID);
  176. BOOL CreateMemoryMappedSection(PWSTR, FILEVIEW*, INT);
  177. VOID DeleteMemoryMappedSection(PVOID);
  178. NTSYSAPI
  179. NTSTATUS
  180. NTAPI
  181. ZwCloseKey(
  182. HANDLE Handle
  183. );