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.

410 lines
11 KiB

  1. /*
  2. Copyright (c) 1992 Microsoft Corporation
  3. Module Name:
  4. server.h
  5. Abstract:
  6. This module contains server definition and data structures relating to
  7. server class APIs.
  8. Author:
  9. Jameel Hyder (microsoft!jameelh)
  10. Revision History:
  11. 25 Apr 1992 Initial Version
  12. Notes: Tab stop: 4
  13. --*/
  14. #ifndef _SERVER_
  15. #define _SERVER_
  16. // AfpGetSrvrMsg values
  17. #define SRVRMSG_LOGIN 0
  18. #define SRVRMSG_SERVER 1
  19. #define SRVRMSG_BITMAP_MESSAGE 1
  20. // Attention word definitions. These are the only one's used.
  21. #define ATTN_SERVER_SHUTDOWN 0x8000
  22. #define ATTN_USER_DISCONNECT 0x9000
  23. #define ATTN_SERVER_MESSAGE 0x2000
  24. #define ATTN_SERVER_NOTIFY 0x3001
  25. #define ATTN_TIME_MASK 0x0FFF
  26. // AfpGetUserInfo values
  27. #define USERINFO_BITMAP_USERID 1
  28. #define USERINFO_BITMAP_PRIGID 2
  29. #define USERINFO_THISUSER 1
  30. // AfpMapId subfunction values
  31. #define MAP_USER_ID 1
  32. #define MAP_GROUP_ID 2
  33. #define MAP_USER_NAME 3
  34. #define MAP_GROUP_NAME 4
  35. #define SRVRPARMS_VOLUMEHASPASS 0x80
  36. // AfpGetSrvrInfo values
  37. #define SRVRINFO_SUPPORTS_COPYFILE 0x0001
  38. #define SRVRINFO_SUPPORTS_CHGPASSWD 0x0002
  39. #define SRVRINFO_DISALLOW_SAVEPASS 0x0004
  40. #define SRVRINFO_SUPPORTS_SERVERMSG 0x0008
  41. #define SRVRINFO_SUPPORTS_SRVSIGN 0x0010
  42. #define SRVRINFO_SUPPORTS_TCPIP 0x0020
  43. #define SRVRINFO_SUPPORTS_SRVNOTIFY 0x0040
  44. #define SRVRINFO_SUPPORTS_MGETREQS 0x8000
  45. #define SRVRINFO_MASK 0x800F
  46. // in hopes that we will save some network traffic, we delay server notification for
  47. // some time, so if too many changes are happening (e.g. xcopy on that dir) then
  48. // we send just one notification for several of the changes combined...
  49. #define AFP_MIN_SRVR_NOTIF_INTERVAL 3
  50. // at the same time, we don't want to not send a notification for too long
  51. #define AFP_MAX_SRVR_NOTIF_INTERVAL 15
  52. // Server State values.
  53. #define AFP_STATE_IDLE 0xFF
  54. #define AFP_STATE_STOPPED 0x00
  55. #define AFP_STATE_STOP_PENDING 0x01
  56. #define AFP_STATE_START_PENDING 0x02
  57. #define AFP_STATE_RUNNING 0x04
  58. #define AFP_STATE_PAUSE_PENDING 0x08
  59. #define AFP_STATE_PAUSED 0x10
  60. #define AFP_STATE_CONTINUE_PENDING 0x20
  61. #define AFP_STATE_SHUTTINGDOWN 0x40
  62. #define AFP_STATE_PENDING_ANY (AFP_STATE_STOP_PENDING | \
  63. AFP_STATE_START_PENDING | \
  64. AFP_STATE_PAUSE_PENDING | \
  65. AFP_STATE_CONTINUE_PENDING)
  66. #define AFP_XLAT_TABLE_SIZE 128
  67. #define AFP_REV_XLAT_TABLE_SIZE 256 - (0x80 - 0x20)
  68. // all server global data must be non-pagable if it is protected by
  69. // an executive spin-lock (i.e. accessed at IRQL DISPATCH_LEVEL)
  70. GLOBAL AFP_SPIN_LOCK AfpServerGlobalLock EQU {0};
  71. GLOBAL AFP_SPIN_LOCK AfpSwmrLock EQU {0};
  72. GLOBAL PBYTE AfpServerIcon EQU NULL;
  73. GLOBAL PANSI_STRING AfpServerMsg EQU NULL;
  74. GLOBAL ANSI_STRING AfpServerName EQU { 0, 0 , NULL};
  75. GLOBAL ANSI_STRING AfpLoginMsg EQU { 0, 0 , NULL};
  76. GLOBAL UNICODE_STRING AfpLoginMsgU EQU { 0, 0 , NULL};
  77. // There is no lock protecting the following codepage related variables
  78. GLOBAL PBYTE AfpTranslationTable EQU NULL;
  79. GLOBAL PBYTE AfpRevTranslationTable EQU NULL;
  80. GLOBAL PBYTE AfpCasePreserveTranslationTable EQU NULL;
  81. GLOBAL PUSHORT AfpMacCPBaseAddress EQU NULL;
  82. GLOBAL CPTABLEINFO AfpMacCPTableInfo EQU { 0 };
  83. GLOBAL DWORD AfpServerState EQU AFP_STATE_IDLE;
  84. GLOBAL DWORD AfpServerMaxSessions EQU AFP_MAXSESSIONS;
  85. GLOBAL KEVENT AfpStopConfirmEvent EQU { 0 };
  86. GLOBAL KMUTEX AfpPgLkMutex EQU { 0 };
  87. GLOBAL DWORD AfpServerOptions EQU AFP_SRVROPT_NONE;
  88. GLOBAL PDEVICE_OBJECT AfpDeviceObject EQU NULL;
  89. GLOBAL BOOLEAN AfpServerIsStandalone EQU { 0 };
  90. GLOBAL LONG AfpEtcMapCount EQU 0; // # valid entries
  91. GLOBAL LONG AfpEtcMapsSize EQU 0; // # entries allocated
  92. GLOBAL struct _EtcMapInfo * AfpEtcMaps EQU NULL; // array of entries
  93. GLOBAL struct _EtcMapInfo AfpDefaultEtcMap EQU { 0 };
  94. GLOBAL SWMR AfpEtcMapLock EQU { 0 };
  95. GLOBAL DWORD AfpSecondsSinceEpoch EQU 0;
  96. #ifdef USE_OBSOLETE_LSA_API
  97. GLOBAL HANDLE AfpLsaHandle EQU NULL;
  98. #endif
  99. GLOBAL CredHandle AfpSecHandle EQU {0, 0};
  100. GLOBAL HANDLE AfpFspToken EQU NULL;
  101. #ifdef OPTIMIZE_GUEST_LOGONS
  102. GLOBAL HANDLE AfpGuestToken EQU NULL;
  103. #endif
  104. GLOBAL ULONG EncryptionKeyCount EQU 0;
  105. GLOBAL PEPROCESS AfpProcessObject EQU NULL;
  106. GLOBAL DWORD AfpAuthenticationPackage EQU 0;
  107. GLOBAL PETHREAD AfpThread EQU NULL;
  108. GLOBAL AFP_SPIN_LOCK AfpStatisticsLock EQU {0};
  109. GLOBAL AFP_STATISTICS_INFO_EX AfpServerStatistics EQU { 0 };
  110. GLOBAL DWORD AfpSrvrNotifSentTime EQU 0;
  111. GLOBAL BOOLEAN fAfpServerShutdownEvent EQU FALSE;
  112. GLOBAL BOOLEAN fAfpAdminStop EQU FALSE;
  113. #ifdef PROFILING
  114. GLOBAL PAFP_PROFILE_INFO AfpServerProfile EQU NULL;
  115. #endif
  116. GLOBAL DWORD AfpPagedPoolLimit EQU AFP_DEF_MAXPAGEDMEM * 1024;
  117. GLOBAL DWORD AfpNonPagedPoolLimit EQU AFP_DEF_MAXNONPAGEDMEM * 1024;
  118. GLOBAL SECURITY_QUALITY_OF_SERVICE AfpSecurityQOS EQU { 0 };
  119. GLOBAL ANSI_STRING AfpVersions[AFP_NUM_VERSIONS] EQU { 0 };
  120. #define AfpVersion20 AfpVersions[AFP_VER_20]
  121. #define AfpVersion21 AfpVersions[AFP_VER_21]
  122. #define AfpVersion22 AfpVersions[AFP_VER_22]
  123. GLOBAL ANSI_STRING AfpUamStrings[AFP_NUM_UAMS] EQU { 0 };
  124. #define AfpUamGuest AfpUamStrings[NO_USER_AUTHENT]
  125. #define AfpUamClearText AfpUamStrings[CLEAR_TEXT_AUTHENT]
  126. #define AfpUamCustomV1 AfpUamStrings[CUSTOM_UAM_V1]
  127. #define AfpUamCustomV2 AfpUamStrings[CUSTOM_UAM_V2]
  128. #define AfpUamApple AfpUamStrings[RANDNUM_EXCHANGE]
  129. #define AfpUamApple2Way AfpUamStrings[TWOWAY_EXCHANGE]
  130. GLOBAL LARGE_INTEGER FiveSecTimeOut EQU {0, 0};
  131. GLOBAL LARGE_INTEGER ThreeSecTimeOut EQU {0, 0};
  132. GLOBAL LARGE_INTEGER TwoSecTimeOut EQU {0, 0};
  133. GLOBAL LARGE_INTEGER OneSecTimeOut EQU {0, 0};
  134. GLOBAL LARGE_INTEGER LIZero EQU {0, 0};
  135. GLOBAL UNICODE_STRING UNullString EQU {0, 0, NULL};
  136. GLOBAL BYTE AfpServerSignature[16] EQU {0};
  137. #define THREAD_BASE_PRIORITY_MAX 2 // maximum thread base priority boost
  138. // To manage our own threads
  139. #define AFP_MIN_THREADS 3 // Independent of processors
  140. #define AFP_MAX_THREADS 200 // Independent of processors
  141. #define NUM_NOTIFY_QUEUES 2 // # of change notify threads
  142. #define AFP_THREAD_THRESHOLD_REQS 2
  143. #define AFP_THREAD_THRESHOLD_IDLE 8
  144. typedef BYTE THREAD_STATE, *PTHREAD_STATE;
  145. typedef LONG (FASTCALL *WORKER)(IN PVOID);
  146. #define AFP_THREAD_DEAD 0
  147. #define AFP_THREAD_STARTED 1
  148. #define AFP_THREAD_WAITING 2
  149. #define AFP_THREAD_BUSY 3
  150. typedef struct
  151. {
  152. LIST_ENTRY wi_List;
  153. WORKER wi_Worker;
  154. PVOID wi_Context;
  155. } WORK_ITEM, *PWORK_ITEM;
  156. GLOBAL WORK_ITEM AfpTerminateThreadWI EQU { 0 };
  157. #define AfpInitializeWorkItem(pWI, Worker, Context) \
  158. { \
  159. InitializeListHead(&(pWI)->wi_List); \
  160. (pWI)->wi_Worker = (WORKER)(Worker); \
  161. (pWI)->wi_Context = (Context); \
  162. }
  163. GLOBAL THREAD_STATE AfpThreadState[AFP_MAX_THREADS] EQU { AFP_THREAD_DEAD };
  164. GLOBAL PETHREAD AfpThreadPtrsW[AFP_MAX_THREADS] EQU { NULL };
  165. GLOBAL PETHREAD AfpThreadPtrsN[NUM_NOTIFY_QUEUES] EQU { NULL };
  166. #if DBG
  167. GLOBAL LONG AfpThreadDispCount[AFP_MAX_THREADS] EQU { 0 };
  168. GLOBAL AFP_SPIN_LOCK AfpDebugSpinLock EQU {0};
  169. GLOBAL LIST_ENTRY AfpDebugDelAllocHead;
  170. GLOBAL DWORD AfpReadCMAlloced EQU {0};
  171. GLOBAL DWORD AfpWriteCMAlloced EQU {0};
  172. GLOBAL DWORD AfpDbgMdlsAlloced EQU 0;
  173. GLOBAL DWORD AfpDbgIrpsAlloced EQU 0;
  174. #define AFP_DBG_INC_COUNT(_Val) \
  175. { \
  176. KIRQL _OldIrql; \
  177. ACQUIRE_SPIN_LOCK(&AfpDebugSpinLock, &_OldIrql); \
  178. _Val++; \
  179. RELEASE_SPIN_LOCK(&AfpDebugSpinLock, _OldIrql); \
  180. }
  181. #define AFP_DBG_DEC_COUNT(_Val) \
  182. { \
  183. KIRQL _OldIrql; \
  184. ACQUIRE_SPIN_LOCK(&AfpDebugSpinLock, &_OldIrql); \
  185. if (_Val == 0) \
  186. { \
  187. DbgPrint("How come this is 0!!\n"); \
  188. DbgBreakPoint(); \
  189. } \
  190. _Val--; \
  191. RELEASE_SPIN_LOCK(&AfpDebugSpinLock, _OldIrql); \
  192. }
  193. #else
  194. #define AFP_DBG_INC_COUNT(_Val)
  195. #define AFP_DBG_DEC_COUNT(_Val)
  196. #endif
  197. GLOBAL LONG AfpLockCount EQU 0;
  198. GLOBAL PVOID AfpLockHandle EQU NULL;
  199. GLOBAL LONG AfpWorkerRequests EQU 0;
  200. GLOBAL LONG AfpNumThreads EQU 0;
  201. GLOBAL LONG AfpNumNotifyThreads EQU 0;
  202. GLOBAL LONG AfpNumAdminThreads EQU 0;
  203. GLOBAL KQUEUE AfpWorkerQueue EQU { 0 };
  204. GLOBAL KQUEUE AfpDelAllocQueue EQU { 0 };
  205. GLOBAL KQUEUE AfpAdminQueue EQU { 0 };
  206. GLOBAL BOOLEAN AfpIsMachineLittleEndian EQU True;
  207. GLOBAL HANDLE AfpTdiNotificationHandle EQU NULL;
  208. GLOBAL BOOLEAN AfpServerBoundToAsp EQU FALSE;
  209. GLOBAL BOOLEAN AfpServerBoundToTcp EQU FALSE;
  210. typedef AFPSTATUS (FASTCALL *AFPAPIWORKER) (IN struct _SessDataArea *);
  211. typedef AFPSTATUS (*ADMINAPIWORKER)(IN PVOID, IN LONG, OUT PVOID);
  212. typedef NTSTATUS (*AFPINITSUBS) (VOID);
  213. typedef VOID (*AFPDEINITSUBS)(VOID);
  214. #define AFPAttachProcess(_CurrProc) \
  215. { \
  216. if ((_CurrProc) != AfpProcessObject) \
  217. { \
  218. KeAttachProcess( (PRKPROCESS)AfpProcessObject );\
  219. } \
  220. }
  221. #define AFPDetachProcess(_CurrProc) \
  222. { \
  223. if ((_CurrProc) != AfpProcessObject) \
  224. { \
  225. KeDetachProcess(); \
  226. } \
  227. }
  228. extern
  229. NTSTATUS
  230. AfpInitializeDataAndSubsystems(
  231. VOID
  232. );
  233. extern
  234. VOID
  235. AfpDeinitializeSubsystems(
  236. VOID
  237. );
  238. extern
  239. VOID FASTCALL
  240. AfpUnmarshallReq(
  241. IN struct _SessDataArea * pSda
  242. );
  243. extern
  244. VOID FASTCALL
  245. AfpDisposeRequest(
  246. IN struct _SessDataArea * pSda,
  247. IN AFPSTATUS RetCode
  248. );
  249. extern
  250. VOID FASTCALL
  251. AfpStartApiProcessing(
  252. IN struct _SessDataArea * pSda
  253. );
  254. extern
  255. VOID FASTCALL
  256. AfpCompleteApiProcessing(
  257. IN struct _SessDataArea * pSda,
  258. IN AFPSTATUS RetCode
  259. );
  260. extern
  261. NTSTATUS FASTCALL
  262. AfpGetWriteBuffer(
  263. IN struct _SessDataArea * pSda,
  264. IN PREQUEST pRequest
  265. );
  266. extern
  267. NTSTATUS
  268. AfpSetServerStatus(
  269. IN VOID
  270. );
  271. extern
  272. AFPSTATUS
  273. AfpAdmWServerSetInfo(
  274. IN OUT PVOID Inbuf OPTIONAL,
  275. IN LONG OutBufLen OPTIONAL,
  276. OUT PVOID Outbuf OPTIONAL
  277. );
  278. extern
  279. NTSTATUS FASTCALL
  280. AfpCreateNewThread(
  281. IN VOID (*ThreadFunc)(IN PVOID pContext),
  282. IN LONG ThreadNum
  283. );
  284. extern
  285. VOID FASTCALL
  286. AfpInitStrings(
  287. IN VOID
  288. );
  289. extern
  290. VOID
  291. AfpWorkerThread(
  292. IN PVOID pContext
  293. );
  294. extern
  295. VOID FASTCALL
  296. AfpQueueWorkItem(
  297. IN PWORK_ITEM pWI
  298. );
  299. extern
  300. VOID
  301. AfpSleepAWhile(
  302. IN DWORD SleepDuration
  303. );
  304. #ifdef SERVER_LOCALS
  305. #define NUM_INIT_SYSTEMS 11
  306. typedef struct _AfpInitSystems
  307. {
  308. AFPINITSUBS InitRoutine;
  309. AFPDEINITSUBS DeInitRoutine;
  310. #if DBG
  311. BOOLEAN Initialized;
  312. BOOLEAN Deinitialized;
  313. PCHAR InitRoutineName;
  314. PCHAR DeInitRoutineName;
  315. #endif
  316. } INIT_SYSTEMS, *PINIT_SYSTEMS;
  317. extern INIT_SYSTEMS AfpInitSubSystems[];
  318. extern
  319. VOID FASTCALL
  320. afpQueueDeferredRequest(
  321. IN struct _SessDataArea * pSda,
  322. IN PREQUEST pRequest
  323. );
  324. #endif // SERVER_LOCALS
  325. #endif // _SERVER_
  326.