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.

226 lines
4.4 KiB

  1. /******************************************************************************\
  2. * This is a part of the Microsoft Source Code Samples.
  3. * Copyright 1993 - 1997 Microsoft Corporation.
  4. * All rights reserved.
  5. * This source code is only intended as a supplement to
  6. * Microsoft Development Tools and/or WinHelp documentation.
  7. * See these sources for detailed information regarding the
  8. * Microsoft samples programs.
  9. \******************************************************************************/
  10. /*++
  11. Copyright 1993 - 1997 Microsoft Corporation
  12. Module Name:
  13. Remote.h
  14. Abstract:
  15. This module contains the main() entry point for Remote.
  16. Calls the Server or the Client depending on the first parameter.
  17. Author:
  18. Rajivendra Nath 2-Jan-1993
  19. Environment:
  20. Console App. User mode.
  21. Revision History:
  22. --*/
  23. #if !defined(FASTCALL)
  24. #if defined(_M_IX86)
  25. #define FASTCALL _fastcall
  26. #else
  27. #define FASTCALL
  28. #endif
  29. #endif
  30. #define VERSION 4
  31. #define REMOTE_SERVER 1
  32. #define RUNTYPE_CLIENT 2
  33. #define SERVER_READ_PIPE "\\\\%s\\PIPE\\%sIN" //Client Writes and Server Reads
  34. #define SERVER_WRITE_PIPE "\\\\%s\\PIPE\\%sOUT" //Server Writes and Client Reads
  35. #define QUERY_DEBUGGERS_PIPE "\\\\%s\\PIPE\\QueryDebuggerPipe"
  36. // PRIVACY_DEFAULT: this session will be listed only if it looks like a debugging one
  37. // PRIVACY_NON_VISIBLE: whatever the name of command, it will not show up with remote /q
  38. // PRIVACY_VISIBLE: this session will be visible for querying
  39. #define PRIVACY_DEFAULT 1
  40. #define PRIVACY_VISIBLE 2
  41. #define PRIVACY_NOT_VISIBLE 3
  42. #define COMMANDCHAR '@' //Commands intended for remote begins with this
  43. #define CTRLC 3
  44. #define CLIENT_ATTR FOREGROUND_INTENSITY|FOREGROUND_GREEN|FOREGROUND_RED|BACKGROUND_BLUE
  45. #define SERVER_ATTR FOREGROUND_INTENSITY|FOREGROUND_GREEN|FOREGROUND_BLUE|BACKGROUND_RED
  46. //
  47. //Some General purpose Macros
  48. //
  49. #define MINIMUM(x,y) ((x)>(y)?(y):(x))
  50. #define MAXIMUM(x,y) ((x)>(y)?(x):(y))
  51. #define HOSTNAMELEN MAX_COMPUTERNAME_LENGTH+1
  52. #define CHARS_PER_LINE 45
  53. #define MAGICNUMBER 0x31109000
  54. #define BEGINMARK '\xfe'
  55. #define ENDMARK '\xff'
  56. #define LINESTOSEND 200
  57. #define MAX_DACL_NAMES 64
  58. typedef struct
  59. {
  60. DWORD Size;
  61. DWORD Version;
  62. char ClientName[HOSTNAMELEN];
  63. DWORD LinesToSend;
  64. DWORD Flag;
  65. } SESSION_STARTUPINFO;
  66. typedef struct
  67. {
  68. DWORD MagicNumber; //New Remote
  69. DWORD Size; //Size of structure
  70. DWORD FileSize; //Num bytes sent
  71. } SESSION_STARTREPLY;
  72. typedef struct
  73. {
  74. char* out; // message
  75. int size; // message length
  76. int allocated; // length of allocated memory
  77. } QUERY_MESSAGE;
  78. typedef struct
  79. {
  80. char *sLine;
  81. BOOL bLineContinues;
  82. BOOL bLineTooLarge;
  83. DWORD cbLine;
  84. DWORD cbCurPos;
  85. COORD cLineBegin;
  86. } CWCDATA;
  87. VOID
  88. QueryRemotePipes(
  89. char* serverName
  90. );
  91. int
  92. OverlappedServer(
  93. char* ChildCmd,
  94. char* PipeName
  95. );
  96. VOID
  97. Client(
  98. char* ServerName,
  99. char* PipeName
  100. );
  101. VOID
  102. ErrorExit(
  103. char* str
  104. );
  105. VOID
  106. DisplayClientHlp(
  107. );
  108. VOID
  109. DisplayServerHlp(
  110. );
  111. VOID
  112. Errormsg(
  113. char* str
  114. );
  115. BOOL
  116. IsKdString(
  117. char* string
  118. );
  119. BOOL
  120. pWantColorLines(
  121. VOID
  122. );
  123. BOOL
  124. FASTCALL
  125. WriteFileSynch(
  126. HANDLE hFile,
  127. LPVOID lpBuffer,
  128. DWORD cbWrite,
  129. LPDWORD lpNumberOfBytesWritten,
  130. DWORD dwFileOffset,
  131. LPOVERLAPPED lpO
  132. );
  133. BOOL
  134. FASTCALL
  135. ReadFileSynch(
  136. HANDLE hFile,
  137. LPVOID lpBuffer,
  138. DWORD cbRead,
  139. LPDWORD lpNumberOfBytesRead,
  140. DWORD dwFileOffset,
  141. LPOVERLAPPED lpO
  142. );
  143. BOOL
  144. FASTCALL
  145. WriteConsoleWithColor(
  146. HANDLE MyStdOut,
  147. char *buffer,
  148. DWORD cbBuffer,
  149. CWCDATA *persist
  150. );
  151. VOID
  152. CloseClientPipes(
  153. VOID
  154. );
  155. BOOL
  156. pColorLine(
  157. char *sLine,
  158. int cbLine,
  159. WORD wDefaultColor,
  160. WORD *color );
  161. extern char HostName[HOSTNAMELEN];
  162. extern char* ChildCmd;
  163. extern char* PipeName;
  164. extern char* ServerName;
  165. extern HANDLE MyOutHandle;
  166. extern DWORD LinesToSend;
  167. extern BOOL IsAdvertise;
  168. extern DWORD ClientToServerFlag;
  169. extern char * DaclNames[];
  170. extern DWORD DaclNameCount;
  171. extern char * DaclDenyNames[];
  172. extern DWORD DaclDenyNameCount;
  173. extern BOOL fAsyncPipe;
  174. extern HANDLE hAttachedProcess;
  175. extern HANDLE hAttachedWriteChildStdIn;
  176. extern HANDLE hAttachedReadChildStdOut;