Source code of Windows XP (NT5)
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.

201 lines
7.3 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. // this is what is so interesting about this particular setting
  42. // special id that uniquely identifies this wow in the context of this machine
  43. // consists of [Time] + [SequenceNumber]
  44. // size of this structure is variable and depends on the length of the desktop name as
  45. // it is fitted together with this structure
  46. // sequence number
  47. ULONG SequenceNumber;
  48. ULONG ParentSequenceNumber;
  49. } SHAREDWOWRECORD, *PSHAREDWOWRECORD;
  50. typedef struct _DOSRecord *PDOSRECORD;
  51. typedef struct _DOSRecord {
  52. PDOSRECORD DOSRecordNext; // Task record chain
  53. ULONG VDMState; // VDM State (bit flags)
  54. ULONG ErrorCode; // Error Code returned by DOS
  55. HANDLE hWaitForParent; // Handle to wait object for parent to wait on
  56. HANDLE hWaitForParentDup; // Dup of hWaitForParent
  57. PVDMINFO lpVDMInfo; // Pointer to VDM Information block
  58. } DOSRECORD, *PDOSRECORD;
  59. typedef struct _CONSOLERECORD *PCONSOLERECORD;
  60. typedef struct _CONSOLERECORD {
  61. PCONSOLERECORD Next;
  62. HANDLE hConsole; // Console Handle of the session
  63. HANDLE hVDM; // NTVDM process handle running in the console
  64. // these two members below are used only with dos vdm
  65. HANDLE hWaitForVDM; // Handle on which VDM will wait
  66. HANDLE hWaitForVDMDup; // Handle on which server will wake up the VDM (Its a dup of previous one)
  67. ULONG nReEntrancy; // Re-entrancy count
  68. ULONG SequenceNumber; // Sequencenumber from PCSR_PROCESS
  69. ULONG ParentSequenceNumber; // Sequencenumber of parent
  70. ULONG DosSesId; // Temp Session ID for no-console
  71. // these two members below are used only with dos vdm
  72. ULONG cchCurDirs; // Length of NTVDM current directory in bytes
  73. PCHAR lpszzCurDirs; // NTVDM current directory accross VDMs
  74. PDOSRECORD DOSRecord; // Information for Tasks in this console
  75. } CONSOLERECORD, *PCONSOLERECORD;
  76. typedef struct _WOWRecord {
  77. ULONG iTask;
  78. BOOL fDispatched; // Is Command Dispatched
  79. HANDLE hWaitForParent; // Parent Will wait on it
  80. HANDLE hWaitForParentServer; // Server will wake up the parent on it
  81. PVDMINFO lpVDMInfo; // Pointer to VDM Information block
  82. PWOWRECORD WOWRecordNext; // Task Record chain
  83. } WOWRECORD, *PWOWRECORD;
  84. typedef struct _INFORECORD {
  85. ULONG iTag;
  86. union {
  87. PWOWRECORD pWOWRecord;
  88. PDOSRECORD pDOSRecord;
  89. } pRecord;
  90. } INFORECORD, *PINFORECORD;
  91. typedef struct _BATRECORD {
  92. HANDLE hConsole;
  93. ULONG SequenceNumber;
  94. struct _BATRECORD *BatRecordNext;
  95. } BATRECORD, *PBATRECORD;
  96. #define WOWMINID 1
  97. #define WOWMAXID 0xfffffffe
  98. // VDMState Defines
  99. #define VDM_TO_TAKE_A_COMMAND 1
  100. #define VDM_BUSY 2
  101. #define VDM_HAS_RETURNED_ERROR_CODE 4
  102. #define VDM_READY 8
  103. VOID BaseSrvVDMInit(VOID);
  104. ULONG BaseSrvCheckVDM(PCSR_API_MSG, PCSR_REPLY_STATUS);
  105. ULONG BaseSrvUpdateVDMEntry(PCSR_API_MSG, PCSR_REPLY_STATUS);
  106. ULONG BaseSrvGetNextVDMCommand(PCSR_API_MSG, PCSR_REPLY_STATUS);
  107. ULONG BaseSrvExitVDM(PCSR_API_MSG, PCSR_REPLY_STATUS);
  108. ULONG BaseSrvIsFirstVDM(PCSR_API_MSG, PCSR_REPLY_STATUS);
  109. ULONG BaseSrvSetReenterCount (PCSR_API_MSG, PCSR_REPLY_STATUS);
  110. ULONG BaseSrvCheckWOW(PBASE_CHECKVDM_MSG, HANDLE);
  111. ULONG BaseSrvCheckDOS(PBASE_CHECKVDM_MSG, HANDLE);
  112. BOOL BaseSrvCopyCommand(PBASE_CHECKVDM_MSG,PINFORECORD);
  113. ULONG BaseSrvUpdateWOWEntry(PBASE_UPDATE_VDM_ENTRY_MSG);
  114. ULONG BaseSrvUpdateDOSEntry(PBASE_UPDATE_VDM_ENTRY_MSG);
  115. NTSTATUS BaseSrvExitWOWTask(PBASE_EXIT_VDM_MSG, HANDLE);
  116. NTSTATUS BaseSrvExitDOSTask(PBASE_EXIT_VDM_MSG);
  117. ULONG BaseSrvGetWOWRecord(ULONG,PWOWRECORD *);
  118. ULONG BaseSrvGetVDMExitCode(PCSR_API_MSG,PCSR_REPLY_STATUS);
  119. ULONG BaseSrvDupStandardHandles(HANDLE, PDOSRECORD);
  120. NTSTATUS BaseSrvGetConsoleRecord (HANDLE,PCONSOLERECORD *);
  121. VOID BaseSrvFreeWOWRecord (PWOWRECORD);
  122. PCONSOLERECORD BaseSrvAllocateConsoleRecord (VOID);
  123. VOID BaseSrvFreeConsoleRecord (PCONSOLERECORD);
  124. VOID BaseSrvRemoveConsoleRecord (PCONSOLERECORD);
  125. PDOSRECORD BaseSrvAllocateDOSRecord(VOID);
  126. VOID BaseSrvFreeDOSRecord (PDOSRECORD);
  127. VOID BaseSrvAddDOSRecord (PCONSOLERECORD,PDOSRECORD);
  128. VOID BaseSrvRemoveDOSRecord (PCONSOLERECORD,PDOSRECORD);
  129. VOID BaseSrvFreeVDMInfo(PVDMINFO);
  130. ULONG BaseSrvCreatePairWaitHandles (HANDLE *, HANDLE *);
  131. VOID BaseSrvAddConsoleRecord(PCONSOLERECORD);
  132. VOID BaseSrvCloseStandardHandles (HANDLE, PDOSRECORD);
  133. VOID BaseSrvClosePairWaitHandles (PDOSRECORD);
  134. VOID BaseSrvVDMTerminated (HANDLE, ULONG);
  135. NTSTATUS
  136. BaseSrvUpdateVDMSequenceNumber (
  137. IN ULONG VdmBinaryType, // binary type
  138. IN HANDLE hVDM, // console handle
  139. IN ULONG DosSesId, // session id
  140. IN HANDLE UniqueProcessClientID
  141. );
  142. VOID BaseSrvCleanupVDMResources (PCSR_PROCESS);
  143. VOID BaseSrvExitVDMWorker (PCONSOLERECORD);
  144. NTSTATUS BaseSrvFillPifInfo (PVDMINFO,PBASE_GET_NEXT_VDM_COMMAND_MSG);
  145. ULONG BaseSrvGetVDMCurDirs(PCSR_API_MSG, PCSR_REPLY_STATUS);
  146. ULONG BaseSrvSetVDMCurDirs(PCSR_API_MSG, PCSR_REPLY_STATUS);
  147. ULONG BaseSrvBatNotification(PCSR_API_MSG, PCSR_REPLY_STATUS);
  148. ULONG BaseSrvRegisterWowExec(PCSR_API_MSG, PCSR_REPLY_STATUS);
  149. PBATRECORD BaseSrvGetBatRecord(HANDLE);
  150. PBATRECORD BaseSrvAllocateAndAddBatRecord(HANDLE);
  151. VOID BaseSrvFreeAndRemoveBatRecord(PBATRECORD);