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.

231 lines
6.3 KiB

  1. //+-------------------------------------------------------------------------
  2. //
  3. // Microsoft Windows
  4. //
  5. // Copyright (C) Microsoft Corporation, 1994 - 1999
  6. //
  7. // File: rawcom.h
  8. //
  9. //--------------------------------------------------------------------------
  10. /************************************************************************/
  11. // Include Files
  12. /************************************************************************/
  13. // #include <nt.h>
  14. // #include <ntrtl.h>
  15. // #include <nturtl.h>
  16. // #include <ntcsrdll.h>
  17. #include <windef.h>
  18. #include <windows.h>
  19. #include <nb30.h>
  20. #include <winsock.h>
  21. #include "rpc.h"
  22. #include "rpcndr.h"
  23. #include <ctype.h>
  24. #include <stdio.h>
  25. #include <stdlib.h>
  26. #include <string.h>
  27. // #include "np.h"
  28. // #include "nb.h"
  29. // #include "sct.h"
  30. // #include "scx.h"
  31. #define DEBUG 0
  32. /************************************************************************/
  33. // Typedef for NTSTATUS and NT_SUCCESS macro
  34. /************************************************************************/
  35. typedef LONG NTSTATUS;
  36. typedef NTSTATUS *PNTSTATUS;
  37. #define NT_SUCCESS(status) ((NTSTATUS)(status) >= 0)
  38. #define STATUS_UNSUCCESSFUL ((NTSTATUS)0xC0000001L)
  39. #define OBJ_CASE_INSENSITIVE 0x00000040L
  40. #define FSCTL_PIPE_LISTEN CTL_CODE(FILE_DEVICE_NAMED_PIPE, 2, METHOD_BUFFERED, FILE_ANY_ACCESS)
  41. #define STATUS_PIPE_BROKEN ((NTSTATUS)0xC000014BL)
  42. #define STATUS_INVALID_PIPE_STATE ((NTSTATUS)0xC00000ADL)
  43. typedef struct _CLIENT_ID {
  44. HANDLE UniqueProcess;
  45. HANDLE UniqueThread;
  46. }CLIENT_ID, *PCLIENT_ID;
  47. /************************************************************************/
  48. // Constants etc.
  49. /************************************************************************/
  50. #define MAXBUFSIZE 65000
  51. #define TRUE 1
  52. #define FALSE 0
  53. #define STACK_SIZE 1024
  54. #define MAXCLIENTS 32
  55. #define SRV 1
  56. #define CLI 0
  57. #define BASEIPC 0
  58. #define NP BASEIPC+0
  59. #define NB BASEIPC+1
  60. #define SCTCP BASEIPC+2
  61. #define SCSPX BASEIPC+3
  62. #define SCXNS BASEIPC+3
  63. #define SCUDP BASEIPC+4
  64. #define SCIPX BASEIPC+5
  65. #define DGNB BASEIPC+6
  66. #define NamePipe "Nmp"
  67. #define NetBIOS "NetB"
  68. #define SocketTCP "SockTCP"
  69. #define SocketXNS "SockXNS"
  70. #define UDP "UDP"
  71. #define IPX "IPX"
  72. #define DGNetBIOS "DGNetB"
  73. #define PERFSRV "IPCSRV"
  74. #define PERFCLI "IPCCLI"
  75. // Memory allocation mechanisms
  76. #define AllocType MEM_COMMIT
  77. #define DeallocType MEM_DECOMMIT
  78. /*
  79. #define FAIL_CHECK(x,y,z) if (!NT_SUCCESS(z)) { \
  80. DbgPrint("%s:Error in %s: status:%lx\n", x,y,z); \
  81. Failure = TRUE; \
  82. break; \
  83. }
  84. */
  85. #define FAIL_CHECK(x,y,z) if (!NT_SUCCESS(z)) { \
  86. char outputDebugBuffer[100]; \
  87. _snprintf(outputDebugBuffer, 100, "%s:Error in %s: status:%lx\n", x, y, z); \
  88. OutputDebugString(outputDebugBuffer); \
  89. Failure = TRUE; \
  90. break; \
  91. }
  92. /*
  93. #define FAIL_CHECK_EXIT(x,y,z) if (!NT_SUCCESS(z)) { \
  94. DbgPrint("%s:Error in %s: status:%lx\n", x,y,z); \
  95. Failure = TRUE; \
  96. return; \
  97. }
  98. */
  99. #define FAIL_CHECK_EXIT(x,y,z) if (!NT_SUCCESS(z)) { \
  100. char outputDebugBuffer[100]; \
  101. _snprintf(outputDebugBuffer, 100, "%s:Error in %s: status:%lx\n", x, y, z); \
  102. OutputDebugString(outputDebugBuffer); \
  103. Failure = TRUE; \
  104. return; \
  105. }
  106. #define MyDbgPrint(x) if (DEBUG) { \
  107. char outputDebugBuffer[100]; \
  108. _snprintf(outputDebugBuffer, 100, (x)); \
  109. OutputDebugString(outputDebugBuffer); \
  110. }
  111. #define STATUS_SUCCESS ((NTSTATUS)0x00000000L)
  112. #ifndef _DBGNT_
  113. ULONG
  114. DbgPrint(
  115. PCH Format,
  116. ...
  117. );
  118. #endif // _DBGNT_
  119. /************************************************************************/
  120. // Local Structures
  121. /************************************************************************/
  122. struct reqbuf {
  123. ULONG Iterations;
  124. ULONG SendSize;
  125. ULONG NumSends;
  126. ULONG RecvSize;
  127. ULONG NumRecvs;
  128. USHORT ClientNumber;
  129. UCHAR TestCmd; // only for 'E' and transact NamedPipe U/T
  130. UCHAR RSVD[9];
  131. };
  132. // Client structure is organized into IPC independent fields followed by IPC
  133. // dependent part.
  134. // NamedPipe info structure
  135. struct NmpInfo {
  136. HANDLE c_PipeHandle;
  137. BOOLEAN c_DoTransact;
  138. };
  139. // NetBIOS info structure
  140. struct NetBInfo {
  141. UCHAR c_LSN;
  142. UCHAR c_NameNum;
  143. PUCHAR c_pRecvBufG; // global buffer for double receives
  144. USHORT c_LanaNumber; // lana number for a client
  145. HANDLE c_SendEvent;
  146. HANDLE c_RecvEvent;
  147. HANDLE c_RecvEventG;
  148. BOOLEAN c_RecvPosted; // while doing RecvSend
  149. };
  150. // Socket info structure
  151. struct SockInfo {
  152. SOCKET c_Sockid;
  153. SOCKET c_Listenid;
  154. };
  155. struct client {
  156. USHORT c_client_num; // This client number
  157. HANDLE c_hThHandle; // Thread handle
  158. CLIENT_ID c_ThClientID; // Thread client Id.
  159. struct reqbuf c_reqbuf; // Request buffer
  160. PCHAR c_pSendBuf; // Ptr. to the send buffer
  161. PCHAR c_pRecvBuf; // Ptr. to the Recv buffer
  162. DWORD c_Duration; // Total time in msecs.
  163. union IPCinfo {
  164. struct NmpInfo c_Nmp; // NamedPipe specific info
  165. struct NetBInfo c_NetB; // NetBIOS info.
  166. struct SockInfo c_Sock; // Socket Info.
  167. };
  168. };
  169. typedef struct _THREADPARAMS {
  170. PHANDLE phThHandle;
  171. PCLIENT_ID pThClientID;
  172. } THREADPARAMS;
  173. /************************************************************************/
  174. // Local function prototypes
  175. /************************************************************************/
  176. VOID
  177. Usage(
  178. IN PSZ PrgName
  179. );
  180. NTSTATUS
  181. Parse_Cmd_Line(
  182. IN USHORT argc,
  183. IN PSZ argv[]
  184. );
  185. VOID
  186. SrvService(
  187. IN PUSHORT pTindex
  188. );
  189. VOID
  190. Cleanup(
  191. );
  192. /************************************************************************/
  193. // External function prototypes
  194. /************************************************************************/
  195.