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.

755 lines
28 KiB

  1. #ifndef __SHDCOM_H__
  2. #define __SHDCOM_H__
  3. /* Common definitions, needed by Ring0 and Ring3 code */
  4. #define CSC_DATABASE_VERSION 0x00010005 // major # in higher WORD, minor # in lower word
  5. #define MIN_SPARSEFILL_PRI 1
  6. #define MAX_SERVER_SHARE_NAME_FOR_CSC 64
  7. #ifndef WM_USER
  8. #define WM_USER 0x400
  9. #endif
  10. #define WM_FILE_OPENS (WM_USER+1)
  11. #define WM_SHADOW_ADDED (WM_USER+2)
  12. #define WM_SHADOW_DELETED (WM_USER+3)
  13. #define WM_SHARE_DISCONNECTED (WM_USER+4)
  14. #define WM_DIRTY WM_USER+100
  15. #define WM_STALE WM_USER+101
  16. #define WM_SPARSE WM_USER+102
  17. #ifndef IOCTL_RDR_BASE
  18. #define IOCTL_RDR_BASE FILE_DEVICE_NETWORK_FILE_SYSTEM
  19. #endif //ifndef IOCTL_RDR_BASE
  20. #define SHADOW_IOCTL_ENUM_BASE 1000
  21. #define _SHADOW_IOCTL_CODE(__enum) \
  22. CTL_CODE(IOCTL_RDR_BASE,SHADOW_IOCTL_ENUM_BASE+__enum, METHOD_NEITHER, FILE_ANY_ACCESS)
  23. #define IOCTL_SHADOW_GETVERSION (_SHADOW_IOCTL_CODE(0))
  24. #define IOCTL_SHADOW_REGISTER_AGENT (_SHADOW_IOCTL_CODE(1))
  25. #define IOCTL_SHADOW_UNREGISTER_AGENT (_SHADOW_IOCTL_CODE(2))
  26. #define IOCTL_SHADOW_GET_UNC_PATH (_SHADOW_IOCTL_CODE(3))
  27. #define IOCTL_SHADOW_BEGIN_PQ_ENUM (_SHADOW_IOCTL_CODE(4))
  28. #define IOCTL_SHADOW_END_PQ_ENUM (_SHADOW_IOCTL_CODE(5))
  29. #define IOCTL_SHADOW_NEXT_PRI_SHADOW (_SHADOW_IOCTL_CODE(6))
  30. #define IOCTL_SHADOW_PREV_PRI_SHADOW (_SHADOW_IOCTL_CODE(7))
  31. #define IOCTL_SHADOW_GET_SHADOW_INFO (_SHADOW_IOCTL_CODE(8))
  32. #define IOCTL_SHADOW_SET_SHADOW_INFO (_SHADOW_IOCTL_CODE(9))
  33. #define IOCTL_SHADOW_CHK_UPDT_STATUS (_SHADOW_IOCTL_CODE(10))
  34. #define IOCTL_DO_SHADOW_MAINTENANCE (_SHADOW_IOCTL_CODE(11))
  35. #define IOCTL_SHADOW_COPYCHUNK (_SHADOW_IOCTL_CODE(12))
  36. #define IOCTL_SHADOW_BEGIN_REINT (_SHADOW_IOCTL_CODE(13))
  37. #define IOCTL_SHADOW_END_REINT (_SHADOW_IOCTL_CODE(14))
  38. #define IOCTL_SHADOW_CREATE (_SHADOW_IOCTL_CODE(15))
  39. #define IOCTL_SHADOW_DELETE (_SHADOW_IOCTL_CODE(16))
  40. #define IOCTL_GET_SHARE_STATUS (_SHADOW_IOCTL_CODE(17))
  41. #define IOCTL_SET_SHARE_STATUS (_SHADOW_IOCTL_CODE(18))
  42. #define IOCTL_ADDUSE (_SHADOW_IOCTL_CODE(19))
  43. #define IOCTL_DELUSE (_SHADOW_IOCTL_CODE(20))
  44. #define IOCTL_GETUSE (_SHADOW_IOCTL_CODE(21))
  45. #define IOCTL_SWITCHES (_SHADOW_IOCTL_CODE(22))
  46. #define IOCTL_GETSHADOW (_SHADOW_IOCTL_CODE(23))
  47. #define IOCTL_GETGLOBALSTATUS (_SHADOW_IOCTL_CODE(24))
  48. #define IOCTL_FINDOPEN_SHADOW (_SHADOW_IOCTL_CODE(25))
  49. #define IOCTL_FINDNEXT_SHADOW (_SHADOW_IOCTL_CODE(26))
  50. #define IOCTL_FINDCLOSE_SHADOW (_SHADOW_IOCTL_CODE(27))
  51. #define IOCTL_GETPRIORITY_SHADOW (_SHADOW_IOCTL_CODE(28))
  52. #define IOCTL_SETPRIORITY_SHADOW (_SHADOW_IOCTL_CODE(29))
  53. #define IOCTL_ADD_HINT (_SHADOW_IOCTL_CODE(30))
  54. #define IOCTL_DELETE_HINT (_SHADOW_IOCTL_CODE(31))
  55. #define IOCTL_FINDOPEN_HINT (_SHADOW_IOCTL_CODE(32))
  56. #define IOCTL_FINDNEXT_HINT (_SHADOW_IOCTL_CODE(33))
  57. #define IOCTL_FINDCLOSE_HINT (_SHADOW_IOCTL_CODE(34))
  58. #define IOCTL_GET_IH_PRIORITY (_SHADOW_IOCTL_CODE(35))
  59. #define IOCTL_GETALIAS_HSHADOW (_SHADOW_IOCTL_CODE(36))
  60. #define IOCTL_GET_DEBUG_INFO (_SHADOW_IOCTL_CODE(37))
  61. // the following are only used on NT but there's no harm in defining them for win9x as well
  62. #define IOCTL_OPENFORCOPYCHUNK (_SHADOW_IOCTL_CODE(40))
  63. #define IOCTL_CLOSEFORCOPYCHUNK (_SHADOW_IOCTL_CODE(41))
  64. #define IOCTL_IS_SERVER_OFFLINE (_SHADOW_IOCTL_CODE(42))
  65. #define IOCTL_TRANSITION_SERVER_TO_ONLINE (_SHADOW_IOCTL_CODE(43))
  66. #define IOCTL_TRANSITION_SERVER_TO_OFFLINE (_SHADOW_IOCTL_CODE(44))
  67. #define IOCTL_NAME_OF_SERVER_GOING_OFFLINE (_SHADOW_IOCTL_CODE(45))
  68. #define IOCTL_TAKE_SERVER_OFFLINE (_SHADOW_IOCTL_CODE(46))
  69. #define IOCTL_SHAREID_TO_SHARENAME (_SHADOW_IOCTL_CODE(47))
  70. #define CSC_IOCTL_MIN IOCTL_SHADOW_GETVERSION
  71. #define CSC_IOCTL_MAX_W9X IOCTL_GETALIAS_HSHADOW
  72. #define CSC_IOCTL_MAX_NT IOCTL_SHAREID_TO_SHARENAME
  73. // Sub operations for IOCTL_DO_SHADOW_MAINTENATCE
  74. #define SHADOW_MAKE_SPACE 1
  75. #define SHADOW_REDUCE_REFPRI 2
  76. #define SHADOW_ADD_SPACE 3
  77. #define SHADOW_FREE_SPACE 4
  78. #define SHADOW_GET_SPACE_STATS 5
  79. #define SHADOW_SET_MAX_SPACE 6
  80. #define SHADOW_PER_THREAD_DISABLE 7
  81. #define SHADOW_PER_THREAD_ENABLE 8
  82. #define SHADOW_REINIT_DATABASE 9
  83. #define SHADOW_ADDHINT_FROM_INODE 10
  84. #define SHADOW_DELETEHINT_FROM_INODE 11
  85. #define SHADOW_COPY_INODE_FILE 12
  86. #define SHADOW_BEGIN_INODE_TRANSACTION 13
  87. #define SHADOW_END_INODE_TRANSACTION 14
  88. #define SHADOW_FIND_CREATE_PRINCIPAL_ID 15
  89. #define SHADOW_GET_SECURITY_INFO 16
  90. #define SHADOW_SET_EXCLUSION_LIST 17
  91. #define SHADOW_SET_BW_CONSERVE_LIST 18
  92. #define SHADOW_TRANSITION_SERVER_TO_OFFLINE 19
  93. #define SHADOW_CHANGE_HANDLE_CACHING_STATE 20
  94. #define SHADOW_RECREATE 21
  95. #define SHADOW_RENAME 22
  96. #define SHADOW_SPARSE_STALE_DETECTION_COUNTER 23
  97. #define SHADOW_ENABLE_CSC_FOR_USER 24
  98. #define SHADOW_DISABLE_CSC_FOR_USER 25
  99. #define SHADOW_SET_DATABASE_STATUS 26
  100. #define SHADOW_PURGE_UNPINNED_FILES 27
  101. #define SHADOW_MANUAL_FILE_DETECTION_COUNTER 28
  102. // persistent status flags on files/directories in the CSC database
  103. #define SHADOW_DIRTY 0x0001 // Contents of file/dir modified while offline
  104. #define SHADOW_ATTRIB_CHANGE 0x0002 // attributes have been changed offline
  105. #define SHADOW_TIME_CHANGE 0x0004 // lastmodtime changed offline
  106. #define SHADOW_STALE 0x0008 // file/dir replic is not in sync with server copy
  107. #define SHADOW_DELETED 0x0010 // file/dir was deleted in an offline operation
  108. #define SHADOW_SPARSE 0x0020 // file/dir is not completely filled up
  109. #define SHADOW_BUSY 0x0040 //
  110. #define SHADOW_REUSED 0x0080 // A replica name has been reused during an offline
  111. // operation of delete follwed by a create
  112. #define SHADOW_ORPHAN 0x0100 // used to be a replica but the original has vanished
  113. // from the server
  114. #define SHADOW_SUSPECT 0x0200 // writes failed on this shadow
  115. #define SHADOW_LOCALLY_CREATED 0x0400 // File/directory created offline
  116. #define SHADOW_LOCAL_INODE 0x4000 // This has meaning only for an inode,
  117. // it means that the inode was created while offline
  118. #define SHADOW_NOT_FSOBJ 0x8000 // This is only a hint
  119. //not used...incorrect #define mShadowIsFsObj(uStatus) (((uStatus) & SHADOW_FILESYSTEM_OBJECT)==0)
  120. #define mShadowHintType(uStatus) ((uStatus) & SHADOW_HINT_MASK)
  121. #define mSetHintType(uStatus, type) ((uStatus) = ((uStatus) & ~SHADOW_HINT_MASK) | ((type) & SHADOW_HINT_MASK))
  122. #define SHADOW_IS_FILE 0x80000000 // flag ored at runtime for PQ enumeration
  123. #define SHADOW_FILE_IS_OPEN 0x40000000 // flag ored at runtime for dir enumeration
  124. #define SHADOW_MODFLAGS (SHADOW_DIRTY|SHADOW_TIME_CHANGE|SHADOW_ATTRIB_CHANGE|SHADOW_LOCALLY_CREATED|SHADOW_DELETED|SHADOW_REUSED)
  125. // Flags defined for a share entry in the CSC database
  126. #define SHARE_REINT 0x0001 // Needs reintegration (persistent)
  127. #define SHARE_CONFLICTS 0x0002 // Conflicts while merging (Persistent)
  128. #define SHARE_ERRORS 0x0004 // Database errors (Persistent)
  129. // 0x0008 // free
  130. #define SHARE_PRESERVES_CASE 0x0010 // (Persistent) may be expendable
  131. #define SHARE_SUPPORTS_LFN 0x0020 // (Persistent) may be expendable
  132. // share caching types (derived from the SMB spec).
  133. // These are set by the admin on the server side.
  134. #define SHARE_MANUAL_REINT 0x0000 // No automatic file by file reint (Persistent)
  135. #define SHARE_AUTO_REINT 0x0040 // File by file reint is OK (Persistent)
  136. #define SHARE_VDO 0x0080 // no need to flow opens (Persistent)
  137. #define SHARE_NO_CACHING 0x00c0 // client should not cache this share (Persistent)
  138. #define SHARE_CACHING_MASK 0x00c0 // type of caching
  139. // in memory flags
  140. #define SHARE_FINDS_IN_PROGRESS 0x0200 // has finds in progress
  141. #define SHARE_FILES_OPEN 0x0400 // has files open
  142. #define SHARE_CONNECTED 0x0800 // Share is connected right now
  143. #define SHARE_SHADOWNP 0x1000 // A shadow connection
  144. #define SHARE_PINNED_OFFLINE 0x2000 // Don't auto-reconnect
  145. #define SHARE_MERGING 0x4000 // free
  146. #define SHARE_DISCONNECTED_OP 0x8000 // Disconnected operation in progress
  147. // NB these are identical to
  148. #define mShadowLocallyCreated(uFlags) ((uFlags) & SHADOW_LOCALLY_CREATED)
  149. #define mShadowStale(uFlags) ((uFlags) & SHADOW_STALE)
  150. #define mShadowDirty(uFlags) ((uFlags) & SHADOW_DIRTY)
  151. #define mShadowTimeChange(uFlags) ((uFlags) & SHADOW_TIME_CHANGE)
  152. #define mShadowAttribChange(uFlags) ((uFlags) & SHADOW_ATTRIB_CHANGE)
  153. #define mShadowSparse(uFlags) ((uFlags) & SHADOW_SPARSE)
  154. #define mShadowBusy(uFlags) ((uFlags) & SHADOW_BUSY)
  155. #define mShadowSuspect(uFlags) ((uFlags) & SHADOW_SUSPECT)
  156. #define mShadowDeleted(uFlags) ((uFlags) & SHADOW_DELETED)
  157. #define mShadowReused(uFlags) ((uFlags) & SHADOW_REUSED)
  158. #define mShadowOrphan(uFlags) ((uFlags) & SHADOW_ORPHAN)
  159. #define mShadowNeedReint(uFlags) ((uFlags) & (SHADOW_MODFLAGS))
  160. #define mShadowConflict(uFlags) (((uFlags) & SHADOW_STALE) && ((uFlags) & SHADOW_MODFLAGS))
  161. #define mShadowUsable(uFlags) (!((uFlags) & (SHADOW_STALE|SHADOW_SUSPECT)))
  162. #define mShadowIsFile(uFlags) ((uFlags) & SHADOW_IS_FILE)
  163. #define SHADOW_FLAGS_BITOP_MASK 0xf
  164. #define SHADOW_FLAGS_ASSIGN 0
  165. #define SHADOW_FLAGS_AND 1
  166. #define SHADOW_FLAGS_OR 2
  167. #define SHADOW_OBJECT_FINDFIRST 3
  168. #define SHADOW_OBJECT_FINDNEXT 4
  169. #define SHADOW_OBJECT_FINDCLOSE 5
  170. #define SHADOW_HINT_FINDFIRST 6
  171. #define SHADOW_HINT_FINDNEXT 7
  172. #define SHADOW_HINT_FINDCLOSE 8
  173. #define SHADOW_HINT_ADD 9
  174. #define SHADOW_DELETE_HINT 10
  175. #define SHADOW_FLAGS_COMMAND_MASK 0xff00
  176. #define SHADOW_FLAGS_DONT_UPDATE_ORGTIME 0x1000
  177. #define SHADOW_FLAGS_TRUNCATE_DATA 0x2000
  178. #define SHADOW_FLAGS_FORCE_RELINK 0x4000 // forces the entry at the top of PQ even if
  179. // it's current priority is MAX_PRI and all
  180. // it's predecessors are MAX_PRI
  181. #define SHADOW_FLAGS_CHANGE_83NAME 0x8000 // applicable to setshadowinfo
  182. #define SHADOW_FLAGS_SET_REFRESH_TIME 0x0100 // setshadowinfo will update lastrefreshed time
  183. #define mBitOpShadowFlags(uOp) ((uOp) & SHADOW_FLAGS_BITOP_MASK)
  184. #define mOrShadowFlags(uOp) (((uOp) & SHADOW_FLAGS_BITOP_MASK)==SHADOW_FLAGS_OR)
  185. #define mAndShadowFlags(uOp) (((uOp) & SHADOW_FLAGS_BITOP_MASK)==SHADOW_FLAGS_AND)
  186. #define mAssignShadowFlags(uOp) (((uOp) & SHADOW_FLAGS_BITOP_MASK)==SHADOW_FLAGS_ASSIGN)
  187. #define mSetShadowFlagsOp(uVar, uOp) (((uVar) &= ~SHADOW_FLAGS_BITOP_MASK), (uVar) |= (uOp))
  188. #define mSetSetShadowCommand(uVar, uCommand) (((uVar) &= ~SHADOW_FLAGS_COMMAND_MASK), (uVar) |= uCommand)
  189. #define mDontUpdateOrgTime(uOp) ((uOp) & SHADOW_FLAGS_DONT_UPDATE_ORGTIME)
  190. #define mTruncateDataCommand(uOp) ((uOp) & SHADOW_FLAGS_TRUNCATE_DATA)
  191. #define mForceRelink(uOp) ((uOp) & SHADOW_FLAGS_FORCE_RELINK)
  192. #define mChange83Name(uOp) ((uOp) & SHADOW_FLAGS_CHANGE_83NAME)
  193. #define mSetLastRefreshTime(uOp) ((uOp) & SHADOW_FLAGS_SET_REFRESH_TIME)
  194. #define SHADOW_SWITCH_SHADOWING 0x0001
  195. #define SHADOW_SWITCH_LOGGING 0x0002
  196. #define SHADOW_SWITCH_SHADOWFIND 0x0004
  197. #define SHADOW_SWITCH_SPEAD_OPTIMIZE 0x0008
  198. #define SHADOW_SWITCH_REMOTE_BOOT 0x0010
  199. #define SHADOW_SWITCH_OFF 1
  200. #define SHADOW_SWITCH_ON 2
  201. #define SHADOW_SWITCH_GET_STATE 3
  202. #define mSetBits(uFlags, uBits) ((uFlags) |= (uBits))
  203. #define mClearBits(uFlags, uBits) ((uFlags) &= ~(uBits))
  204. #define mQueryBits(uFlags, uBits) ((uFlags) & (uBits))
  205. #ifndef CSC_ON_NT
  206. #define FlagOn(uFlags, uBit) (mQueryBits(uFlags, uBit) != 0)
  207. #endif
  208. #define RETAIN_VALUE 0xffffffff
  209. // pin flags
  210. // NTRAID#455275-shishirp-1/31/2000, we ended up replicating these in cscapi.h
  211. #define FLAG_CSC_HINT_PIN_USER 0x01
  212. #define FLAG_CSC_HINT_PIN_INHERIT_USER 0x02
  213. #define FLAG_CSC_HINT_PIN_INHERIT_SYSTEM 0x04
  214. #define FLAG_CSC_HINT_CONSERVE_BANDWIDTH 0x08
  215. #define FLAG_CSC_HINT_PIN_SYSTEM 0x10
  216. #define FLAG_CSC_HINT_COMMAND_ALTER_PIN_COUNT 0x80000000
  217. #define FLAG_CSC_HINT_COMMAND_MASK 0xf0000000
  218. #define FLAG_CSC_HINT_INHERIT_MASK (FLAG_CSC_HINT_PIN_INHERIT_USER|FLAG_CSC_HINT_PIN_INHERIT_SYSTEM)
  219. #define mPinFlags(ulHintFlags) ((ulHintFlags) & (FLAG_CSC_HINT_PIN_USER|FLAG_CSC_HINT_PIN_SYSTEM))
  220. #define mPinInheritFlags(ulHintFlags) ((ulHintFlags) & (FLAG_CSC_HINT_PIN_INHERIT_USER|FLAG_CSC_HINT_PIN_INHERIT_SYSTEM))
  221. #define mPinCommand(ulHintFlags) ((ulHintFlags) & FLAG_CSC_HINT_COMMAND_MASK)
  222. #define mPinAlterCount(ulHintFlags) ((ulHintFlags) & FLAG_CSC_HINT_COMMAND_ALTER_PIN_COUNT)
  223. // These defines are here for historical reasons, they are not used anymore
  224. // Hint, Hint
  225. #define HINT_FLAG_TYPE_MASK 0x03
  226. #define HINT_EXCLUSION 0x04
  227. #define HINT_WILDCARD 0x08
  228. #define HINT_TYPE_FILE 1
  229. #define HINT_TYPE_FOLDER 2
  230. #define HINT_TYPE_SUBTREE 3
  231. //
  232. #define mNotFsobj(uStatus) ((uStatus) & SHADOW_NOT_FSOBJ)
  233. #define mIsHint(uHF) ((uHF) & HINT_FLAG_TYPE_MASK)
  234. #define mHintSubtree(uHF) (((uHF) & HINT_FLAG_TYPE_MASK)==HINT_TYPE_SUBTREE)
  235. #define mHintExclude(uHF) ((uHF) & HINT_EXCLUSION)
  236. #define mHintWildcard(uHF) ((uHF) & HINT_WILDCARD)
  237. #ifdef VxD
  238. typedef _WIN32_FIND_DATA WIN32_FIND_DATA, *PFIND32, far *LPFIND32;
  239. typedef _FILETIME FILETIME;
  240. #else
  241. typedef LPWIN32_FIND_DATAW LPFIND32;
  242. #endif
  243. #ifdef CSC_RECORDMANAGER_WINNT
  244. typedef _FILETIME FILETIME;
  245. #endif
  246. typedef ULONG HSERVER;
  247. typedef ULONG HSHADOW;
  248. typedef ULONG HSHARE;
  249. typedef ULONG *PHSHARE;
  250. typedef ULONG *PHSERVER;
  251. typedef ULONG *PHSHADOW;
  252. #ifdef VxD
  253. typedef USHORT wchar_t;
  254. #endif
  255. typedef wchar_t *PWCHAR;
  256. typedef wchar_t *LPWCH, *PWCH;
  257. typedef CONST wchar_t *LPCWCH, *PCWCH;
  258. typedef wchar_t *NWPSTR;
  259. typedef wchar_t *LPWSTR, *PWSTR;
  260. typedef CONST wchar_t *LPCWSTR, *PCWSTR;
  261. //
  262. // ANSI (Multi-byte Character) types
  263. //
  264. typedef CHAR *PCHAR;
  265. typedef CHAR *LPCH, *PCH;
  266. typedef CONST CHAR *LPCCH, *PCCH;
  267. typedef CHAR *NPSTR;
  268. typedef CHAR *LPSTR, *PSTR;
  269. typedef CONST CHAR *LPCSTR, *PCSTR;
  270. typedef VOID *CSC_ENUMCOOKIE;
  271. typedef struct tagSTOREDATA
  272. {
  273. ULONG ulSize; // Max shadow data size
  274. ULONG ucntDirs; // Current count of dirs
  275. ULONG ucntFiles; // Current count of files
  276. }
  277. STOREDATA;
  278. #ifndef __COPYCHUNKCONTEXT__
  279. #define __COPYCHUNKCONTEXT__
  280. typedef struct tagCOPYCHUNKCONTEXT
  281. {
  282. DWORD dwFlags;
  283. ULONG LastAmountRead;
  284. ULONG TotalSizeBeforeThisRead;
  285. HANDLE handle;
  286. ULONG ChunkSize;
  287. ULONG Context[1];
  288. }
  289. COPYCHUNKCONTEXT;
  290. #endif
  291. #define COPYCHUNKCONTEXT_FLAG_IS_AGENT_OPEN 0x00000001
  292. typedef struct tagSHADOWSTORE
  293. {
  294. ULONG uFlags;
  295. STOREDATA sMax;
  296. STOREDATA sCur;
  297. }
  298. SHADOWSTORE;
  299. typedef struct tagCOPYPARAMSA
  300. {
  301. union
  302. {
  303. DWORD dwError;
  304. struct
  305. {
  306. ULONG uOp;
  307. HSHARE hShare;
  308. HSHADOW hDir;
  309. HSHADOW hShadow;
  310. LPSTR lpLocalPath;
  311. LPSTR lpRemotePath;
  312. LPSTR lpSharePath;
  313. };
  314. };
  315. }
  316. COPYPARAMSA;
  317. typedef struct tagCOPYPARAMSW
  318. {
  319. union
  320. {
  321. DWORD dwError;
  322. struct
  323. {
  324. ULONG uOp;
  325. HSHARE hShare;
  326. HSHADOW hDir;
  327. HSHADOW hShadow;
  328. LPWSTR lpLocalPath;
  329. LPWSTR lpRemotePath;
  330. LPWSTR lpSharePath;
  331. };
  332. };
  333. }
  334. COPYPARAMSW;
  335. typedef struct tagPQPARAMS
  336. {
  337. union
  338. {
  339. DWORD dwError;
  340. struct
  341. {
  342. HSHARE hShare;
  343. HSHADOW hDir;
  344. HSHADOW hShadow;
  345. ULONG ulStatus;
  346. ULONG ulRefPri;
  347. ULONG ulIHPri;
  348. ULONG ulHintFlags;
  349. ULONG ulHintPri;
  350. CSC_ENUMCOOKIE uEnumCookie;
  351. ULONG uPos;
  352. DWORD dwPQVersion;
  353. };
  354. };
  355. }
  356. PQPARAMS;
  357. typedef struct tagSHADOWINFO
  358. {
  359. union
  360. {
  361. DWORD dwError;
  362. struct
  363. {
  364. HSHARE hShare; // share ID
  365. HSHADOW hDir; // directory inode
  366. HSHADOW hShadow; // inode for the item
  367. union
  368. {
  369. HSHADOW hShadowOrg; // original inode, applies only to a replica
  370. HSHADOW hDirTo; // input for renaming hShadowFrom into hDirTo
  371. };
  372. FILETIME ftOrgTime; // the timestamp of a replica as obtained
  373. FILETIME ftLastRefreshTime; // last time a replica was refreshed
  374. union
  375. {
  376. LPFIND32 lpFind32;
  377. LPVOID lpBuffer;
  378. };
  379. ULONG uStatus; // status of the item in the database
  380. ULONG ulRefPri;
  381. union
  382. {
  383. ULONG ulPrincipalID;
  384. ULONG ulIHPri;
  385. ULONG uRootStatus;
  386. };
  387. ULONG ulHintFlags;
  388. ULONG ulHintPri;
  389. union
  390. {
  391. ULONG uOp;
  392. ULONG uSubOperation;
  393. };
  394. CSC_ENUMCOOKIE uEnumCookie;
  395. ULONG cbBufferSize;
  396. DWORD dwNameSpaceVersion;
  397. };
  398. };
  399. }
  400. SHADOWINFO;
  401. #define FINDOPEN_SHADOWINFO_NORMAL 0x1
  402. #define FINDOPEN_SHADOWINFO_SPARSE 0x2
  403. #define FINDOPEN_SHADOWINFO_DELETED 0x4
  404. #define FINDOPEN_SHADOWINFO_ALL 0x7
  405. typedef struct tagSHAREINFOW
  406. {
  407. union
  408. {
  409. DWORD dwError;
  410. struct
  411. {
  412. HSHARE hShare;
  413. USHORT usCaps; // Type of resource
  414. USHORT usState; // State of the resource (connected/paused etc.)
  415. unsigned short rgSharePath[MAX_SERVER_SHARE_NAME_FOR_CSC]; // name of the path
  416. unsigned short rgFileSystem[16]; // name of the file system
  417. };
  418. };
  419. }
  420. SHAREINFOW;
  421. typedef struct tagSHAREINFOA
  422. {
  423. union
  424. {
  425. DWORD dwError;
  426. struct
  427. {
  428. HSHARE hShare;
  429. USHORT usCaps; // Type of resource
  430. USHORT usState; // State of the resource (connected/paused etc.)
  431. char rgSharePath[MAX_SERVER_SHARE_NAME_FOR_CSC]; // name of the path
  432. char rgFileSystem[16]; // name of the file system
  433. };
  434. };
  435. }
  436. SHAREINFOA;
  437. typedef struct tagGLOBALSTATUS
  438. {
  439. union
  440. {
  441. DWORD dwError;
  442. struct
  443. {
  444. ULONG uFlagsEvents; // Reports the latest events noted
  445. ULONG uDatabaseErrorFlags;
  446. SHADOWSTORE sST;
  447. HSHADOW hShadowAdded;
  448. HSHADOW hDirAdded;
  449. HSHADOW hShadowDeleted;
  450. HSHADOW hDirDeleted;
  451. int cntFileOpen; // Count of file opens
  452. HSHARE hShareDisconnected;
  453. };
  454. };
  455. }
  456. GLOBALSTATUS, *LPGLOBALSTATUS;
  457. typedef struct tagSECURITYINFO
  458. {
  459. ULONG ulPrincipalID; // identifier of the principal
  460. ULONG ulPermissions; // permissions mask
  461. }
  462. SECURITYINFO, *LPSECURITYINFO;
  463. // achtung, these should match with those in the cscsec.h
  464. #define CSC_MAXIMUM_NUMBER_OF_CACHED_PRINCIPAL_IDS (0x4)
  465. #define CSC_GUEST_PRINCIPAL_ID (0xfffe)
  466. #define CSC_INVALID_PRINCIPAL_ID (0x0)
  467. #define FLAG_GLOBALSTATUS_SHADOW_ADDED 0x0001
  468. #define FLAG_GLOBALSTATUS_SHADOW_DELETED 0x0002
  469. #define FLAG_GLOBALSTATUS_FILE_OPENS 0x0004
  470. #define FLAG_GLOBALSTATUS_SHADOW_SPACE 0x0008
  471. #define FLAG_GLOBALSTATUS_SHARE_DISCONNECTED 0x0010
  472. #define FLAG_GLOBALSTATUS_STOP 0x0020
  473. #define FLAG_GLOBALSTATUS_START 0x0040
  474. #define FLAG_GLOBALSTATUS_NO_NET 0x0080
  475. #define FLAG_GLOBALSTATUS_GOT_NET 0x0100
  476. #define FLAG_GLOBALSTATUS_INVOKE_AUTODIAL 0x0200
  477. #define FLAG_GLOBALSTATUS_INVOKE_FREESPACE 0x0400
  478. #define FLAG_DATABASESTATUS_DIRTY 0x00000001
  479. #define FLAG_DATABASESTATUS_ENCRYPTION_MASK 0x00000006
  480. #define FLAG_DATABASESTATUS_UNENCRYPTED 0x00000000 // new inodes will NOT be encrypted
  481. #define FLAG_DATABASESTATUS_PARTIALLY_UNENCRYPTED 0x00000004
  482. #define FLAG_DATABASESTATUS_ENCRYPTED 0x00000002 // new fileinodes will be encrypted
  483. #define FLAG_DATABASESTATUS_PARTIALLY_ENCRYPTED 0x00000006
  484. #define mDatabaseEncryptionEnabled(ulGlobalStatus) ((ulGlobalStatus) & 0x00000002)
  485. #define mDatabasePartiallyEncrypted(ulGlobalStatus) (((ulGlobalStatus) & FLAG_DATABASESTATUS_ENCRYPTION_MASK)==FLAG_DATABASESTATUS_PARTIALLY_ENCRYPTED)
  486. #define mDatabasePartiallyUnencrypted(ulGlobalStatus) (((ulGlobalStatus) & FLAG_DATABASESTATUS_ENCRYPTION_MASK)==FLAG_DATABASESTATUS_PARTIALLY_UNENCRYPTED)
  487. //
  488. // Neutral ANSI/UNICODE types and macros
  489. //
  490. #ifndef _TCHAR_DEFINED
  491. #ifdef UNICODE // r_winnt
  492. typedef wchar_t TCHAR, *PTCHAR;
  493. typedef wchar_t TBYTE , *PTBYTE ;
  494. typedef LPWSTR LPTCH, PTCH;
  495. typedef LPWSTR PTSTR, LPTSTR;
  496. typedef LPCWSTR LPCTSTR;
  497. typedef LPWSTR LP;
  498. #define _TEXT(quote) L##quote // r_winnt
  499. #else /* UNICODE */ // r_winnt
  500. typedef char TCHAR, *PTCHAR;
  501. typedef unsigned char TBYTE , *PTBYTE ;
  502. typedef LPSTR LPTCH, PTCH;
  503. typedef LPSTR PTSTR, LPTSTR;
  504. typedef LPCSTR LPCTSTR;
  505. #define _TEXT(quote) quote // r_winnt
  506. #endif /* UNICODE */ // r_winnt
  507. #define _TCHAR_DEFINED
  508. #endif /* !_TCHAR_DEFINED */
  509. #ifdef VXD
  510. #define UNICODE
  511. #endif
  512. #ifdef UNICODE
  513. #define COPYPARAMS COPYPARAMSW
  514. #define SHAREINFO SHAREINFOW
  515. #define LPCOPYPARAMS LPCOPYPARAMSW
  516. #define LPSHAREINFO LPSHAREINFOW
  517. #else
  518. #define COPYPARAMS COPYPARAMSA
  519. #define SHAREINFO SHAREINFOA
  520. #define LPCOPYPARAMS LPCOPYPARAMSA
  521. #define LPSHAREINFO LPSHAREINFOA
  522. #endif
  523. #ifdef VxD
  524. typedef HSHARE *LPHSHARE;
  525. typedef HSHADOW *LPHSHADOW;
  526. typedef SHADOWSTORE *LPSHADOWSTORE;
  527. typedef SHADOWINFO *LPSHADOWINFO;
  528. typedef STOREDATA *LPSTOREDATA;
  529. typedef PQPARAMS *LPPQPARAMS;
  530. typedef COPYPARAMSA *LPCOPYPARAMSA;
  531. typedef SHAREINFOA *LPSHAREINFOA;
  532. typedef COPYPARAMSW *LPCOPYPARAMSW;
  533. typedef SHAREINFOW *LPSHAREINFOW;
  534. #else
  535. typedef HSHARE FAR *LPHSHARE;
  536. typedef HSHADOW FAR *LPHSHADOW;
  537. typedef SHADOWSTORE FAR *LPSHADOWSTORE;
  538. typedef SHADOWINFO FAR *LPSHADOWINFO;
  539. typedef STOREDATA FAR *LPSTOREDATA;
  540. typedef PQPARAMS FAR *LPPQPARAMS;
  541. typedef COPYPARAMS FAR *LPCOPYPARAMS;
  542. typedef COPYPARAMSA FAR *LPCOPYPARAMSA;
  543. typedef SHAREINFOA FAR *LPSHAREINFOA;
  544. typedef COPYPARAMSW FAR *LPCOPYPARAMSW;
  545. typedef SHAREINFOW FAR *LPSHAREINFOW;
  546. #endif
  547. // UNICODE versions of registry key/value names
  548. // kept for hist(y)rical reasons
  549. #define REG_KEY_IEXPLORER _TEXT("Software\\Microsoft\\Internet Explorer\\Main")
  550. #define REG_KEY_SHADOW _TEXT("System\\CurrentControlSet\\Services\\VxD\\Shadow")
  551. // settings exclusively used by cscdll.dll
  552. #define REG_KEY_CSC_SETTINGS _TEXT("Software\\Microsoft\\Windows\\CurrentVersion\\CSCSettings")
  553. #define REG_STRING_DATABASE_LOCATION _TEXT("DatabaseLocation")
  554. #define REG_VALUE_DATABASE_SIZE _TEXT("DatabaseSizePercent")
  555. #define REG_VALUE_ENABLED _TEXT("Enabled")
  556. // settings defined by UI and policy
  557. #define REG_STRING_POLICY_NETCACHE_KEY _TEXT("Software\\Policies\\Microsoft\\Windows\\NetCache")
  558. #define REG_STRING_NETCACHE_KEY _TEXT("Software\\Microsoft\\Windows\\CurrentVersion\\NetCache")
  559. #define REG_STRING_EXCLUSION_LIST _TEXT("ExcludeExtensions")
  560. #define REG_STRING_BANDWIDTH_CONSERVATION_LIST _TEXT("BandwidthConservationList")
  561. #define REG_VALUE_FORMAT_DATABASE _TEXT("FormatDatabase")
  562. // ANSI versions of registry key/value names
  563. // kept for hist(y)rical reasons
  564. #define REG_KEY_IEXPLORER_A "Software\\Microsoft\\Internet Explorer\\Main"
  565. #define REG_KEY_SHADOW_A "System\\CurrentControlSet\\Services\\VxD\\Shadow"
  566. // settings exclusively used by cscdll.dll
  567. #define REG_KEY_CSC_SETTINGS_A "Software\\Microsoft\\Windows\\CurrentVersion\\CSCSettings"
  568. #define REG_STRING_DATABASE_LOCATION_A "DatabaseLocation"
  569. #define REG_VALUE_DATABASE_SIZE_A "DatabaseSizePercent"
  570. #define REG_VALUE_ENABLED_A "Enabled"
  571. // settings defined by UI and policy
  572. #define REG_STRING_POLICY_NETCACHE_KEY_A "Software\\Policies\\Microsoft\\Windows\\NetCache"
  573. #define REG_STRING_NETCACHE_KEY_A "Software\\Microsoft\\Windows\\CurrentVersion\\NetCache"
  574. #define REG_STRING_EXCLUSION_LIST_A "ExcludeExtensions"
  575. #define REG_STRING_BANDWIDTH_CONSERVATION_LIST_A "BandwidthConservationList"
  576. #define REG_STRING_ENCRYPTED_A "Encrypted"
  577. #define REG_STRING_ENCRYPT_DECRYPT_A "EcDc"
  578. #define REG_VALUE_FORMAT_DATABASE_A "FormatDatabase"
  579. #define SESSION_EVENT_NAME_NT L"\\BaseNamedObjects\\jjCSCSessEvent_UM_KM"
  580. #define SHARED_FILL_EVENT_NAME_NT L"\\BaseNamedObjects\\jjCSCSharedFillEvent_UM_KM"
  581. #define IFNOT_CSC_RECORDMANAGER_WINNT if(FALSE)
  582. #define IF_CSC_RECORDMANAGER_WINNT if(TRUE)
  583. #define WINNT_DOIT(x__) x__
  584. int ShadowLog(
  585. LPSTR lpFmt,
  586. ...
  587. );
  588. #define DoCSCLog(__x) ShadowLog __x
  589. extern DWORD dwDebugLogVector;
  590. #define DEBUG_LOG(__bits, __x) {\
  591. if (((DEBUG_LOG_BIT_##__bits)==0) || FlagOn(dwDebugLogVector,(DEBUG_LOG_BIT_##__bits))){\
  592. DoCSCLog(__x); \
  593. }\
  594. }
  595. #define DEBUG_LOG_BIT_RECORD 0x00000001
  596. #define DEBUG_LOG_BIT_CSHADOW 0x00000002
  597. #endif //#ifndef __SHDCOM_H__