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.

509 lines
11 KiB

  1. #ifndef __REINTH
  2. #define __REINTH
  3. #define ERROR_SHADOW_OP_FAILED 3000L
  4. #define ERROR_REINT_FAILED 3001L
  5. #define ERROR_STALE 3002L
  6. #define ERROR_REMOTE_OP_FAILED 3003L
  7. #define ERROR_CONFLICT_FIRST 3100L
  8. #define ERROR_CREATE_CONFLICT 3100L // A locally created file already exists
  9. #define ERROR_DELETE_CONFLICT 3101L // A lcally modified shadow has been deleted from the remote
  10. #define ERROR_UPDATE_CONFLICT 3102L // Updated on remote while client changed it when disconnected
  11. #define ERROR_ATTRIBUTE_CONFLICT 3103L
  12. #define ERROR_NO_CONFLICT_DIR 3104L
  13. #define ERROR_CONFLICT_LAST 3104L
  14. // Force level fro refreshconnections
  15. #define REFRESH_FORCE_UNC_ONLY 0 // nuke UNC connections if no outstanding ops
  16. #define REFRESH_FORCE_GENTLE 1 // nuke all connections if no outstanding ops
  17. #define REFRESH_FORCE_SHADOW 2 // nuke all shadow connections
  18. #define REFRESH_FORCE_ALL 3 // nuke all connection
  19. // Verbose level while nuking connections
  20. #define REFRESH_SILENT 0
  21. #define REFRESH_NOISY 1
  22. #ifdef CSC_ON_NT
  23. #define FILL_BUF_SIZE_SLOWLINK 4096
  24. #define FILL_BUF_SIZE_LAN (FILL_BUF_SIZE_SLOWLINK * 4)
  25. #define MyStrChr wcschr
  26. #define MyPathIsUNC(lpT) ((*(lpT)==_T('\\')) && (*(lpT+1)==_T('\\')))
  27. #else
  28. #define FILL_BUF_SIZE_SLOWLINK 512
  29. #define FILL_BUF_SIZE_LAN (4096-1024)
  30. #define MyStrChr StrChr
  31. #define MyPathIsUNC(lpT) PathIsUNC(lpT)
  32. #endif
  33. #define PUBLIC FAR PASCAL
  34. #define PRIVATE NEAR PASCAL
  35. /******************* Macros *************************************************/
  36. #define mModifiedOffline(ulStatus) ((ulStatus) & (SHADOW_DIRTY|SHADOW_TIME_CHANGE|SHADOW_ATTRIB_CHANGE))
  37. /******************* Typedefs ***********************************************/
  38. typedef struct tagERRMSG
  39. {
  40. DWORD dwError;
  41. unsigned uMessageID;
  42. }
  43. ERRMSG;
  44. typedef struct tagFAILINFO
  45. {
  46. struct tagFAILINFO FAR *lpnextFI;
  47. HSHARE hShare;
  48. HSHADOW hDir;
  49. HSHADOW hShadow;
  50. unsigned short cntFail;
  51. unsigned short cntMaxFail;
  52. DWORD dwFailTime;
  53. #ifdef DEBUG
  54. _TCHAR rgchPath[MAX_PATH+1];
  55. #endif //DEBUG
  56. }
  57. FAILINFO, FAR *LPFAILINFO;
  58. typedef struct tagCONNECTINFO
  59. {
  60. struct tagCONNECTINFO *lpnextCI;
  61. unsigned uStatus;
  62. #ifdef _WIN64
  63. __declspec(align(8))
  64. #endif
  65. byte rgFill[];
  66. }
  67. CONNECTINFO, FAR *LPCONNECTINFO;
  68. typedef int (CALLBACK *LPFNREFRESHPROC)(LPCONNECTINFO, DWORD);
  69. typedef int (CALLBACK *LPFNREFRESHEXPROC)(int, DWORD);
  70. // In reint.c
  71. int PRIVATE PurgeSkipQueue(
  72. BOOL fAll,
  73. HSHARE hShare,
  74. HSHADOW hDir,
  75. HSHADOW hShadow
  76. );
  77. int PUBLIC ReintAllShares(HWND hwndParent);
  78. typedef struct tagUPDATEINFO
  79. {
  80. HSHARE hShare;
  81. HWND hwndParent;
  82. } UPDATEINFO, FAR * PUPDATEINFO;
  83. //
  84. // Pass in the Share to merge on
  85. // and the parent window.
  86. //
  87. int PUBLIC ReintOneShare(HSHARE hShare, HSHADOW hRoot, _TCHAR *, _TCHAR *, _TCHAR *, ULONG, LPCSCPROC lpfnMergeProgress, DWORD_PTR dwContext);
  88. BOOL FGetConnectionList(LPCONNECTINFO *, int *);
  89. BOOL FGetConnectionListEx(LPCONNECTINFO *lplpHead, LPCTSTR lptzShareName, BOOL fAllSharesOnServer, BOOL fForceOffline, int *lpcntDiscon);
  90. int DisconnectList(LPCONNECTINFO *, LPFNREFRESHPROC lpfn, DWORD dwCookie);
  91. int ReconnectList(LPCONNECTINFO *,HWND hwndParent);
  92. VOID ClearConnectionList(LPCONNECTINFO *);
  93. void DoFreeShadowSpace(void);
  94. void GetLogCopyStatus(void);
  95. _TCHAR * PRIVATE LpGetExclusionList( VOID );
  96. VOID PRIVATE ReleaseExclusionList( LPVOID lpBuff);
  97. DWORD
  98. PRIVATE
  99. DWConnectNet(
  100. _TCHAR *lpSharePath,
  101. _TCHAR *lpOutDrive,
  102. _TCHAR *lpDomainName,
  103. _TCHAR *lpUserName,
  104. _TCHAR *lpPassword,
  105. DWORD dwFlags,
  106. BOOL *lpfIsDfsConnect
  107. );
  108. DWORD DWDisconnectDriveMappedNet(
  109. LPTSTR lptzDrive,
  110. BOOL fForce
  111. );
  112. #ifdef DEBUG
  113. VOID EnterSkipQueue(
  114. HSHARE hShare,
  115. HSHADOW hDir,
  116. HSHADOW hShadow,
  117. _TCHAR * lpPath );
  118. #else
  119. VOID EnterSkipQueue(
  120. HSHARE hShare,
  121. HSHADOW hDir,
  122. HSHADOW hShadow);
  123. #endif //DEBUG
  124. BOOL GetWin32Info(
  125. _TCHAR * lpFile,
  126. LPWIN32_FIND_DATA lpFW32 );
  127. LPCOPYPARAMS LpAllocCopyParams(VOID);
  128. VOID FreeCopyParams( LPCOPYPARAMS lp );
  129. BOOL CALLBACK ShdLogonProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam);
  130. int BreakConnectionsInternal(
  131. int force,
  132. BOOL verbose
  133. );
  134. int RefreshConnectionsInternal(
  135. int force,
  136. BOOL verbose
  137. );
  138. int RefreshConnectionsEx(
  139. int force,
  140. BOOL verbose,
  141. LPFNREFRESHEXPROC lpfn,
  142. DWORD dwCookie
  143. );
  144. //Synchronization functions
  145. int PUBLIC
  146. EnterAgentCrit(
  147. VOID
  148. );
  149. VOID PUBLIC
  150. LeaveAgentCrit(
  151. VOID
  152. );
  153. int
  154. ExtractSpaceStats(
  155. IN GLOBALSTATUS *lpsGS,
  156. OUT unsigned long *lpulMaxSpace,
  157. OUT unsigned long *lpulCurSpace,
  158. OUT unsigned long *lpulFreeSpace
  159. );
  160. VOID
  161. ReInt_DoFreeShadowSpace(
  162. GLOBALSTATUS *lpsGS,
  163. int fForce
  164. );
  165. BOOL
  166. CALLBACK
  167. ShdLogonProc(
  168. HWND hwnd,
  169. UINT msg,
  170. WPARAM wParam,
  171. LPARAM lParam
  172. );
  173. BOOL
  174. TruncateAndMarkSparse(
  175. HANDLE,
  176. _TCHAR *,
  177. LPSHADOWINFO
  178. );
  179. DWORD
  180. DWConnectNetEx(
  181. _TCHAR * lpSharePath,
  182. _TCHAR * lpOutDrive,
  183. BOOL fInteractive
  184. );
  185. int
  186. AttemptCacheFill (
  187. HSHARE hShare,
  188. int type,
  189. BOOL fFullSync,
  190. ULONG ulPrincipalID,
  191. LPCSCPROC lpfnFillProgress,
  192. DWORD_PTR dwContext
  193. );
  194. DWORD
  195. DoSparseFill(
  196. HANDLE hShadowDB,
  197. _TCHAR *,
  198. _TCHAR *,
  199. LPSHADOWINFO,
  200. WIN32_FIND_DATA *,
  201. LPCOPYPARAMS lpCP,
  202. BOOL fStalenessCheck,
  203. ULONG ulPrincipalID,
  204. LPCSCPROC,
  205. DWORD_PTR
  206. );
  207. DWORD
  208. DoRefresh(
  209. HANDLE hShadowDB,
  210. LPCOPYPARAMS lpCP,
  211. _TCHAR *,
  212. LPSHADOWINFO,
  213. _TCHAR *
  214. );
  215. VOID
  216. ReportLastError(
  217. VOID
  218. );
  219. int
  220. CheckDirtyShares(
  221. VOID
  222. );
  223. // Shadow Cache Maintenance Functions
  224. int DoDBMaintenance(VOID);
  225. int ClearShadowCache(VOID);
  226. void CopyLogToShare(void);
  227. BOOL
  228. FStopAgent(
  229. VOID
  230. );
  231. BOOL
  232. UpdateExclusionList(
  233. VOID
  234. );
  235. BOOL
  236. UpdateBandwidthConservationList(
  237. VOID
  238. );
  239. BOOL
  240. SetAgentThreadImpersonation(
  241. HSHADOW hDir,
  242. HSHADOW hShadow,
  243. BOOL fWrite
  244. );
  245. BOOL
  246. ResetAgentThreadImpersonation(
  247. VOID
  248. );
  249. BOOL
  250. FAbortOperation(
  251. VOID
  252. );
  253. VOID
  254. SetAgentShutDownRequest(
  255. VOID
  256. );
  257. BOOL
  258. HasAgentShutDown(
  259. VOID
  260. );
  261. VOID
  262. CleanupReintState(
  263. VOID
  264. );
  265. BOOL
  266. InitCSCUI(
  267. HANDLE hToken
  268. );
  269. VOID
  270. TerminateCSCUI(
  271. VOID
  272. );
  273. BOOL
  274. GetWin32InfoForNT(
  275. _TCHAR * lpFile,
  276. LPWIN32_FIND_DATA lpFW32
  277. );
  278. DWORD
  279. DoNetUseAddForAgent(
  280. IN LPTSTR lptzShareName,
  281. IN LPTSTR lptzUseName,
  282. IN LPTSTR lptzDomainName,
  283. IN LPTSTR lptzUserName,
  284. IN LPTSTR lptzPassword,
  285. IN DWORD dwFlags,
  286. OUT BOOL *lpfIsDfsConnect
  287. );
  288. #define DO_ONE_OBJECT 1
  289. #define DO_ONE_SHARE 2
  290. #define DO_ALL 3
  291. #define TOD_CALLBACK_REASON_BEGIN 0
  292. #define TOD_CALLBACK_REASON_NEXT_ITEM 1
  293. #define TOD_CALLBACK_REASON_END 2
  294. #define TOD_CONTINUE 0
  295. #define TOD_ABORT 1
  296. #define TOD_SKIP_DIRECTORY 2
  297. typedef int (*TRAVERSEFUNC)(
  298. HANDLE,
  299. LPSECURITYINFO,
  300. _TCHAR *,
  301. DWORD,
  302. WIN32_FIND_DATA *,
  303. LPSHADOWINFO,
  304. LPVOID);
  305. int
  306. TraverseOneDirectory(
  307. HANDLE hShadowDB,
  308. LPSECURITYINFO pShareSecurityInfo,
  309. HSHADOW hParentDir,
  310. HSHADOW hDir,
  311. LPTSTR lptzInputPath,
  312. TRAVERSEFUNC lpfnTraverseDir,
  313. LPVOID lpContext
  314. );
  315. BOOL
  316. GetCSCPrincipalID(
  317. ULONG *lpPrincipalID
  318. );
  319. BOOL
  320. GetCSCAccessMaskForPrincipal(
  321. unsigned long ulPrincipalID,
  322. HSHADOW hDir,
  323. HSHADOW hShadow,
  324. unsigned long *pulAccessMask
  325. );
  326. BOOL
  327. GetCSCAccessMaskForPrincipalEx(
  328. unsigned long ulPrincipalID,
  329. HSHADOW hDir,
  330. HSHADOW hShadow,
  331. unsigned long *pulAccessMask,
  332. unsigned long *pulActualMaskForUser,
  333. unsigned long *pulActualMaskForGuest
  334. );
  335. BOOL
  336. GetConnectionInfoForDriveBasedName(
  337. _TCHAR * lpName,
  338. LPDWORD lpdwSpeed
  339. );
  340. BOOL
  341. ReportTransitionToDfs(
  342. _TCHAR *lptServerName,
  343. BOOL fOffline,
  344. DWORD cbLen
  345. );
  346. BOOL
  347. CSCEnumForStatsInternal(
  348. IN LPCTSTR lpszShareName,
  349. IN LPCSCPROC lpfnEnumProgress,
  350. IN BOOL fPeruserInfo,
  351. IN BOOL fUpdateShareReintBit,
  352. IN DWORD_PTR dwContext
  353. );
  354. // interval in milliseconds between two sparsefill attempts
  355. #define WAIT_INTERVAL_ATTEMPT_MS (1000*60) // 1 minute
  356. // interval in milliseconds between two polls for global status
  357. #define WAIT_INTERVAL_GLOBALSTATUS_MS (1000*60*10) // 10 minutes
  358. // duration in milliseconds after which an entry that is in the skip queue is nuked
  359. #define WAIT_INTERVAL_SKIP_MS (1000*60*10) // 10 minutes
  360. // duration in milliseconds between two stalenesscheck iterations
  361. #define WAIT_INTERVAL_BETWEEN_ITERATIONS_MS (1000*60*10)
  362. // interval in milliseconds between two staleness check attempts
  363. #define WAIT_INTERVAL_STALE_MS (1000*5) // 5 seconds
  364. #define WAIT_INTERVAL_CHECK_SERVER_ONLINE_MS (1000*60*8) // 8 minutes
  365. #define WAIT_INTERVAL_FILL_THROTTLE_MS (1000*60*2) // 2 minutes
  366. // delay to wait for PNP to settle down
  367. #define WAIT_INTERVAL_PNP (1000*15) // 15 seconds
  368. // for some Registry queries, this is the max len buffer that I want back
  369. #define MAX_NAME_LEN 100
  370. #define SZ_TRUE "true"
  371. #define SZ_FALSE "false"
  372. extern _TCHAR * vlpExclusionList;
  373. extern HANDLE vhMutex;
  374. extern BOOL vfLogCopying,vfCopying,allowAttempt;
  375. extern HCURSOR vhcursor;
  376. extern HWND vhdlgShdLogon;
  377. extern DWORD dwVxDEvent;
  378. extern HWND vhwndMain;
  379. extern HANDLE vhShadowDB;
  380. extern DWORD vdwAgentThreadId;
  381. extern DWORD vdwAgentSessionId;
  382. #ifdef CSC_ON_NT
  383. extern DWORD vdwCopyChunkThreadId;
  384. extern HDESK hdesktopUser;
  385. #endif
  386. extern BOOL fFillers;
  387. #define RWM_UPDATE (WM_USER+0x200)
  388. #define RWM_UPDATEALL (WM_USER+0x201)
  389. #ifdef DEBUG
  390. //dbgprint interface
  391. #define ReintKdPrint(__bit,__x) {\
  392. if (((REINT_KDP_##__bit)==0) || (ReintKdPrintVector & (REINT_KDP_##__bit))) {\
  393. DEBUG_PRINT(__x);\
  394. }\
  395. }
  396. #define REINT_KDP_ALWAYS 0x00000000
  397. #define REINT_KDP_BADERRORS 0x00000001
  398. #define REINT_KDP_INIT 0x00000002
  399. #define REINT_KDP_MAINLOOP 0x00000004
  400. #define REINT_KDP_FILL 0x00000008
  401. #define REINT_KDP_MERGE 0x00000010
  402. #define REINT_KDP_API 0x00000020
  403. #define REINT_KDP_SPACE 0x00000040
  404. #define REINT_KDP_STALENESS 0x00000080
  405. #define REINT_KDP_SKIPQUEUE 0x00000100
  406. #define REINT_KDP_SECURITY 0x00000200
  407. #define REINT_KDP_GOOD_DEFAULT (REINT_KDP_BADERRORS)
  408. extern ULONG ReintKdPrintVector;
  409. #else
  410. #define ReintKdPrint(__bit,__x) ;
  411. #endif
  412. #endif