home *** CD-ROM | disk | FTP | other *** search
/ Tricks of the Windows Gam…ming Gurus (2nd Edition) / Disc2.iso / msdn_vcb / samples / vc98 / sdk / sdktools / winnt / remote / remote.h < prev    next >
C/C++ Source or Header  |  1997-10-12  |  4KB  |  196 lines

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