Leaked source code of windows server 2003
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.

414 lines
14 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 PUSHORT AfpMacCPBaseAddress EQU NULL;
  81. GLOBAL CPTABLEINFO AfpMacCPTableInfo EQU { 0 };
  82. GLOBAL DWORD AfpServerState EQU AFP_STATE_IDLE;
  83. GLOBAL DWORD AfpServerMaxSessions EQU AFP_MAXSESSIONS;
  84. GLOBAL KEVENT AfpStopConfirmEvent EQU { 0 };
  85. GLOBAL KMUTEX AfpPgLkMutex EQU { 0 };
  86. GLOBAL DWORD AfpServerOptions EQU AFP_SRVROPT_NONE;
  87. GLOBAL PDEVICE_OBJECT AfpDeviceObject EQU NULL;
  88. GLOBAL BOOLEAN AfpServerIsStandalone EQU { 0 };
  89. GLOBAL BOOLEAN AfpServerIsGreek 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 AfpUamCustomV3 AfpUamStrings[CUSTOM_UAM_V3]
  129. #define AfpUamApple AfpUamStrings[RANDNUM_EXCHANGE]
  130. #define AfpUamApple2Way AfpUamStrings[TWOWAY_EXCHANGE]
  131. GLOBAL LARGE_INTEGER FiveSecTimeOut EQU {0, 0};
  132. GLOBAL LARGE_INTEGER ThreeSecTimeOut EQU {0, 0};
  133. GLOBAL LARGE_INTEGER TwoSecTimeOut EQU {0, 0};
  134. GLOBAL LARGE_INTEGER OneSecTimeOut EQU {0, 0};
  135. GLOBAL LARGE_INTEGER LIZero EQU {0, 0};
  136. GLOBAL UNICODE_STRING UNullString EQU {0, 0, NULL};
  137. GLOBAL BYTE AfpServerSignature[16] EQU {0};
  138. #define THREAD_BASE_PRIORITY_MAX 2 // maximum thread base priority boost
  139. // To manage our own threads
  140. #define AFP_MIN_THREADS 3 // Independent of processors
  141. #define AFP_MAX_THREADS 200 // Independent of processors
  142. #define NUM_NOTIFY_QUEUES 2 // # of change notify threads
  143. #define AFP_THREAD_THRESHOLD_REQS 2
  144. #define AFP_THREAD_THRESHOLD_IDLE 8
  145. typedef BYTE THREAD_STATE, *PTHREAD_STATE;
  146. typedef LONG (FASTCALL *WORKER)(IN PVOID);
  147. #define AFP_THREAD_DEAD 0
  148. #define AFP_THREAD_STARTED 1
  149. #define AFP_THREAD_WAITING 2
  150. #define AFP_THREAD_BUSY 3
  151. typedef struct
  152. {
  153. LIST_ENTRY wi_List;
  154. WORKER wi_Worker;
  155. PVOID wi_Context;
  156. } WORK_ITEM, *PWORK_ITEM;
  157. GLOBAL WORK_ITEM AfpTerminateThreadWI EQU { 0 };
  158. #define AfpInitializeWorkItem(pWI, Worker, Context) \
  159. { \
  160. InitializeListHead(&(pWI)->wi_List); \
  161. (pWI)->wi_Worker = (WORKER)(Worker); \
  162. (pWI)->wi_Context = (Context); \
  163. }
  164. GLOBAL THREAD_STATE AfpThreadState[AFP_MAX_THREADS] EQU { AFP_THREAD_DEAD };
  165. GLOBAL PETHREAD AfpThreadPtrsW[AFP_MAX_THREADS] EQU { NULL };
  166. GLOBAL PETHREAD AfpThreadPtrsN[NUM_NOTIFY_QUEUES] EQU { NULL };
  167. #if DBG
  168. GLOBAL LONG AfpThreadDispCount[AFP_MAX_THREADS] EQU { 0 };
  169. GLOBAL AFP_SPIN_LOCK AfpDebugSpinLock EQU {0};
  170. GLOBAL LIST_ENTRY AfpDebugDelAllocHead;
  171. GLOBAL DWORD AfpReadCMAlloced EQU {0};
  172. GLOBAL DWORD AfpWriteCMAlloced EQU {0};
  173. GLOBAL DWORD AfpDbgMdlsAlloced EQU 0;
  174. GLOBAL DWORD AfpDbgIrpsAlloced EQU 0;
  175. #define AFP_DBG_INC_COUNT(_Val) \
  176. { \
  177. KIRQL _OldIrql; \
  178. ACQUIRE_SPIN_LOCK(&AfpDebugSpinLock, &_OldIrql); \
  179. _Val++; \
  180. RELEASE_SPIN_LOCK(&AfpDebugSpinLock, _OldIrql); \
  181. }
  182. #define AFP_DBG_DEC_COUNT(_Val) \
  183. { \
  184. KIRQL _OldIrql; \
  185. ACQUIRE_SPIN_LOCK(&AfpDebugSpinLock, &_OldIrql); \
  186. if (_Val == 0) \
  187. { \
  188. DbgPrint("How come this is 0!!\n"); \
  189. DbgBreakPoint(); \
  190. } \
  191. _Val--; \
  192. RELEASE_SPIN_LOCK(&AfpDebugSpinLock, _OldIrql); \
  193. }
  194. #else
  195. #define AFP_DBG_INC_COUNT(_Val)
  196. #define AFP_DBG_DEC_COUNT(_Val)
  197. #endif
  198. GLOBAL LONG AfpLockCount EQU 0;
  199. GLOBAL PVOID AfpLockHandle EQU NULL;
  200. GLOBAL LONG AfpWorkerRequests EQU 0;
  201. GLOBAL LONG AfpNumThreads EQU 0;
  202. GLOBAL LONG AfpNumNotifyThreads EQU 0;
  203. GLOBAL LONG AfpNumAdminThreads EQU 0;
  204. GLOBAL KQUEUE AfpWorkerQueue EQU { 0 };
  205. GLOBAL KQUEUE AfpDelAllocQueue EQU { 0 };
  206. GLOBAL KQUEUE AfpAdminQueue EQU { 0 };
  207. GLOBAL BOOLEAN AfpIsMachineLittleEndian EQU True;
  208. GLOBAL HANDLE AfpTdiNotificationHandle EQU NULL;
  209. GLOBAL BOOLEAN AfpServerBoundToAsp EQU FALSE;
  210. GLOBAL BOOLEAN AfpServerBoundToTcp EQU FALSE;
  211. typedef AFPSTATUS (FASTCALL *AFPAPIWORKER) (IN struct _SessDataArea *);
  212. typedef AFPSTATUS (*ADMINAPIWORKER)(IN PVOID, IN LONG, OUT PVOID);
  213. typedef NTSTATUS (*AFPINITSUBS) (VOID);
  214. typedef VOID (*AFPDEINITSUBS)(VOID);
  215. #define AFPAttachProcess(_CurrProc) \
  216. { \
  217. if ((_CurrProc) != AfpProcessObject) \
  218. { \
  219. KeAttachProcess( (PRKPROCESS)AfpProcessObject );\
  220. } \
  221. }
  222. #define AFPDetachProcess(_CurrProc) \
  223. { \
  224. if ((_CurrProc) != AfpProcessObject) \
  225. { \
  226. KeDetachProcess(); \
  227. } \
  228. }
  229. #define AFP_KEYPATH_SERVER_PARAMS_GREEK \
  230. TEXT("\\REGISTRY\\MACHINE\\SYSTEM\\CurrentControlSet\\Services\\MacFile\\Parameters")
  231. #define AFPREG_VALNAME_GreekServer TEXT("GreekServer")
  232. extern
  233. NTSTATUS
  234. AfpInitializeDataAndSubsystems(
  235. VOID
  236. );
  237. extern
  238. VOID
  239. AfpDeinitializeSubsystems(
  240. VOID
  241. );
  242. extern
  243. VOID FASTCALL
  244. AfpUnmarshallReq(
  245. IN struct _SessDataArea * pSda
  246. );
  247. extern
  248. VOID FASTCALL
  249. AfpDisposeRequest(
  250. IN struct _SessDataArea * pSda,
  251. IN AFPSTATUS RetCode
  252. );
  253. extern
  254. VOID FASTCALL
  255. AfpStartApiProcessing(
  256. IN struct _SessDataArea * pSda
  257. );
  258. extern
  259. VOID FASTCALL
  260. AfpCompleteApiProcessing(
  261. IN struct _SessDataArea * pSda,
  262. IN AFPSTATUS RetCode
  263. );
  264. extern
  265. NTSTATUS FASTCALL
  266. AfpGetWriteBuffer(
  267. IN struct _SessDataArea * pSda,
  268. IN PREQUEST pRequest
  269. );
  270. extern
  271. NTSTATUS
  272. AfpSetServerStatus(
  273. IN VOID
  274. );
  275. extern
  276. AFPSTATUS
  277. AfpAdmWServerSetInfo(
  278. IN OUT PVOID Inbuf OPTIONAL,
  279. IN LONG OutBufLen OPTIONAL,
  280. OUT PVOID Outbuf OPTIONAL
  281. );
  282. extern
  283. NTSTATUS FASTCALL
  284. AfpCreateNewThread(
  285. IN VOID (*ThreadFunc)(IN PVOID pContext),
  286. IN LONG ThreadNum
  287. );
  288. extern
  289. VOID FASTCALL
  290. AfpInitStrings(
  291. IN VOID
  292. );
  293. extern
  294. VOID
  295. AfpWorkerThread(
  296. IN PVOID pContext
  297. );
  298. extern
  299. VOID FASTCALL
  300. AfpQueueWorkItem(
  301. IN PWORK_ITEM pWI
  302. );
  303. extern
  304. VOID
  305. AfpSleepAWhile(
  306. IN DWORD SleepDuration
  307. );
  308. #ifdef SERVER_LOCALS
  309. #define NUM_INIT_SYSTEMS 11
  310. typedef struct _AfpInitSystems
  311. {
  312. AFPINITSUBS InitRoutine;
  313. AFPDEINITSUBS DeInitRoutine;
  314. #if DBG
  315. BOOLEAN Initialized;
  316. BOOLEAN Deinitialized;
  317. PCHAR InitRoutineName;
  318. PCHAR DeInitRoutineName;
  319. #endif
  320. } INIT_SYSTEMS, *PINIT_SYSTEMS;
  321. extern INIT_SYSTEMS AfpInitSubSystems[];
  322. extern
  323. VOID FASTCALL
  324. afpQueueDeferredRequest(
  325. IN struct _SessDataArea * pSda,
  326. IN PREQUEST pRequest
  327. );
  328. #endif // SERVER_LOCALS
  329. #endif // _SERVER_