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.

222 lines
8.2 KiB

  1. /*++
  2. Copyright (c) 1990 Microsoft Corporation
  3. Module Name:
  4. srvvdm.h
  5. Abstract:
  6. Include file for VDM related functions
  7. Author:
  8. Sudeep Bharati (sudeepb) 03-Sep-1991
  9. Revision History:
  10. --*/
  11. // Shared wow vdm definition
  12. typedef struct tagSharedWowRecord *PSHAREDWOWRECORD;
  13. typedef struct _WOWRecord *PWOWRECORD;
  14. typedef struct tagSharedWowRecord {
  15. // all these structures are wired to the console list
  16. // so that each shared wow is identified in the console list by it's handle
  17. // the reason for this extra linkage is to speed up certain calls in which we
  18. // already know it's wow
  19. PSHAREDWOWRECORD pNextSharedWow; // points to the next shared vdm
  20. HANDLE hConsole; // hidden console of wow
  21. HANDLE hwndWowExec; // handle to a wow exec window
  22. DWORD dwWowExecProcessId; // process id of a wowexec
  23. DWORD dwWowExecThreadId; // thread id for wowexec
  24. // why sequence number:
  25. // Davehart explains that we could get in trouble if basesrv thinks
  26. // that wowexec could be identified uniquely by it's window handle, process id and thread id.
  27. // In reality, these values are recycled rather quickly which could lead us to [mistakenly]
  28. // accept hwndWowExec for a wowexec window when, in reality the relevant wowexec has long been
  29. // gone. This number reflects a sequential order in which processes are created.
  30. // And while it could still be recycled (when it overflows) this is a rather rare event.
  31. // all the sequence number info that we are in need of is located in the console
  32. // record itself
  33. // This is a unicode string representing windows station/desktop which is supported by this
  34. // particular ntvdm
  35. UNICODE_STRING WowExecDesktopName;
  36. ULONG VDMState; // the state of this shared wow
  37. // task queue
  38. PWOWRECORD pWOWRecord;
  39. // LUID - auth id for this wow
  40. LUID WowAuthId;
  41. // WOWUserToken - auth process token
  42. HANDLE WOWUserToken;
  43. // this is what is so interesting about this particular setting
  44. // special id that uniquely identifies this wow in the context of this machine
  45. // consists of [Time] + [SequenceNumber]
  46. // size of this structure is variable and depends on the length of the desktop name as
  47. // it is fitted together with this structure
  48. // sequence number
  49. ULONG SequenceNumber;
  50. ULONG ParentSequenceNumber;
  51. LPTHREAD_START_ROUTINE pfnW32HungAppNotifyThread; // For VDMTerminateTask
  52. } SHAREDWOWRECORD, *PSHAREDWOWRECORD;
  53. typedef struct _DOSRecord *PDOSRECORD;
  54. typedef struct _DOSRecord {
  55. PDOSRECORD DOSRecordNext; // Task record chain
  56. ULONG VDMState; // VDM State (bit flags)
  57. ULONG ErrorCode; // Error Code returned by DOS
  58. HANDLE hWaitForParent; // Handle to wait object for parent to wait on
  59. HANDLE hWaitForParentDup; // Dup of hWaitForParent
  60. PVDMINFO lpVDMInfo; // Pointer to VDM Information block
  61. ULONG iTask;
  62. DWORD dwThreadId;
  63. WORD hTask16;
  64. WORD hMod16;
  65. PCHAR pFilePath;
  66. CHAR szModName[9];
  67. } DOSRECORD, *PDOSRECORD;
  68. typedef struct _CONSOLERECORD *PCONSOLERECORD;
  69. typedef struct _CONSOLERECORD {
  70. PCONSOLERECORD Next;
  71. HANDLE hConsole; // Console Handle of the session
  72. HANDLE hVDM; // NTVDM process handle running in the console
  73. // these two members below are used only with dos vdm
  74. HANDLE hWaitForVDM; // Handle on which VDM will wait
  75. HANDLE hWaitForVDMDup; // Handle on which server will wake up the VDM (Its a dup of previous one)
  76. ULONG nReEntrancy; // Re-entrancy count
  77. ULONG SequenceNumber; // Sequencenumber from PCSR_PROCESS
  78. ULONG ParentSequenceNumber; // Sequencenumber of parent
  79. ULONG DosSesId; // Temp Session ID for no-console
  80. DWORD dwProcessId;
  81. // these two members below are used only with dos vdm
  82. ULONG cchCurDirs; // Length of NTVDM current directory in bytes
  83. PCHAR lpszzCurDirs; // NTVDM current directory accross VDMs
  84. PDOSRECORD DOSRecord; // Information for Tasks in this console
  85. // UserToken - auth process token
  86. HANDLE DosUserToken;
  87. LPTHREAD_START_ROUTINE pfnW32HungAppNotifyThread; // For VDMTerminateTask
  88. } CONSOLERECORD, *PCONSOLERECORD;
  89. typedef struct _WOWRecord {
  90. ULONG iTask;
  91. BOOL fDispatched; // Is Command Dispatched
  92. HANDLE hWaitForParent; // Parent Will wait on it
  93. HANDLE hWaitForParentServer; // Server will wake up the parent on it
  94. PVDMINFO lpVDMInfo; // Pointer to VDM Information block
  95. PWOWRECORD WOWRecordNext; // Task Record chain
  96. DWORD dwThreadId;
  97. WORD hTask16;
  98. WORD hMod16;
  99. PCHAR pFilePath;
  100. CHAR szModName[9];
  101. } WOWRECORD, *PWOWRECORD;
  102. typedef struct _INFORECORD {
  103. ULONG iTag;
  104. union {
  105. PWOWRECORD pWOWRecord;
  106. PDOSRECORD pDOSRecord;
  107. } pRecord;
  108. } INFORECORD, *PINFORECORD;
  109. typedef struct _BATRECORD {
  110. HANDLE hConsole;
  111. ULONG SequenceNumber;
  112. struct _BATRECORD *BatRecordNext;
  113. } BATRECORD, *PBATRECORD;
  114. #define WOWMINID 1
  115. #define WOWMAXID 0xfffffffe
  116. // VDMState Defines
  117. #define VDM_TO_TAKE_A_COMMAND 1
  118. #define VDM_BUSY 2
  119. #define VDM_HAS_RETURNED_ERROR_CODE 4
  120. #define VDM_READY 8
  121. VOID BaseSrvVDMInit(VOID);
  122. ULONG BaseSrvCheckVDM(PCSR_API_MSG, PCSR_REPLY_STATUS);
  123. ULONG BaseSrvUpdateVDMEntry(PCSR_API_MSG, PCSR_REPLY_STATUS);
  124. ULONG BaseSrvGetNextVDMCommand(PCSR_API_MSG, PCSR_REPLY_STATUS);
  125. ULONG BaseSrvExitVDM(PCSR_API_MSG, PCSR_REPLY_STATUS);
  126. ULONG BaseSrvIsFirstVDM(PCSR_API_MSG, PCSR_REPLY_STATUS);
  127. ULONG BaseSrvSetReenterCount (PCSR_API_MSG, PCSR_REPLY_STATUS);
  128. ULONG BaseSrvCheckWOW(PBASE_CHECKVDM_MSG, HANDLE);
  129. ULONG BaseSrvCheckDOS(PBASE_CHECKVDM_MSG, HANDLE);
  130. BOOL BaseSrvCopyCommand(PBASE_CHECKVDM_MSG,PINFORECORD);
  131. ULONG BaseSrvUpdateWOWEntry(PBASE_UPDATE_VDM_ENTRY_MSG,ULONG);
  132. ULONG BaseSrvUpdateDOSEntry(PBASE_UPDATE_VDM_ENTRY_MSG,ULONG);
  133. NTSTATUS BaseSrvExitWOWTask(PBASE_EXIT_VDM_MSG, ULONG);
  134. NTSTATUS BaseSrvExitDOSTask(PBASE_EXIT_VDM_MSG, ULONG);
  135. ULONG BaseSrvGetWOWRecord(ULONG,PWOWRECORD *);
  136. ULONG BaseSrvGetVDMExitCode(PCSR_API_MSG,PCSR_REPLY_STATUS);
  137. ULONG BaseSrvDupStandardHandles(HANDLE, PDOSRECORD);
  138. NTSTATUS BaseSrvGetConsoleRecord (HANDLE,PCONSOLERECORD*);
  139. VOID BaseSrvFreeWOWRecord (PWOWRECORD);
  140. PCONSOLERECORD BaseSrvAllocateConsoleRecord (VOID);
  141. VOID BaseSrvFreeConsoleRecord (PCONSOLERECORD);
  142. VOID BaseSrvRemoveConsoleRecord (PCONSOLERECORD);
  143. PDOSRECORD BaseSrvAllocateDOSRecord(VOID);
  144. VOID BaseSrvFreeDOSRecord (PDOSRECORD);
  145. VOID BaseSrvAddDOSRecord (PCONSOLERECORD,PDOSRECORD);
  146. VOID BaseSrvRemoveDOSRecord (PCONSOLERECORD,PDOSRECORD);
  147. VOID BaseSrvFreeVDMInfo(PVDMINFO);
  148. ULONG BaseSrvCreatePairWaitHandles (HANDLE *, HANDLE *);
  149. VOID BaseSrvAddConsoleRecord(PCONSOLERECORD);
  150. VOID BaseSrvCloseStandardHandles (HANDLE, PDOSRECORD);
  151. VOID BaseSrvClosePairWaitHandles (PDOSRECORD);
  152. VOID BaseSrvVDMTerminated (HANDLE, ULONG);
  153. NTSTATUS
  154. BaseSrvUpdateVDMSequenceNumber (
  155. IN ULONG VdmBinaryType, // binary type
  156. IN HANDLE hVDM, // console handle
  157. IN ULONG DosSesId, // session id
  158. IN HANDLE UniqueProcessClientID,
  159. IN HANDLE UniqueProcessParentID
  160. );
  161. VOID BaseSrvCleanupVDMResources (PCSR_PROCESS);
  162. VOID BaseSrvExitVDMWorker (PCONSOLERECORD);
  163. NTSTATUS BaseSrvFillPifInfo (PVDMINFO,PBASE_GET_NEXT_VDM_COMMAND_MSG);
  164. ULONG BaseSrvGetVDMCurDirs(PCSR_API_MSG, PCSR_REPLY_STATUS);
  165. ULONG BaseSrvSetVDMCurDirs(PCSR_API_MSG, PCSR_REPLY_STATUS);
  166. ULONG BaseSrvBatNotification(PCSR_API_MSG, PCSR_REPLY_STATUS);
  167. ULONG BaseSrvRegisterWowExec(PCSR_API_MSG, PCSR_REPLY_STATUS);
  168. PBATRECORD BaseSrvGetBatRecord(HANDLE);
  169. PBATRECORD BaseSrvAllocateAndAddBatRecord(HANDLE);
  170. VOID BaseSrvFreeAndRemoveBatRecord(PBATRECORD);
  171. BOOL BaseSrvIsVdmAllowed(VOID);
  172. NTSTATUS BaseSrvIsClientVdm(HANDLE UniqueProcessClientId);