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.

548 lines
16 KiB

  1. // Copyright (c) 1996-1999 Microsoft Corporation
  2. //+-------------------------------------------------------------------------
  3. //
  4. // Microsoft Windows
  5. //
  6. // File: stubs.cxx
  7. //
  8. // Contents: RPC stub routines that call CTrkWksSvc
  9. //
  10. // Classes:
  11. //
  12. // Functions:
  13. //
  14. //
  15. //
  16. // History: 18-Nov-96 BillMo Created.
  17. //
  18. // Notes:
  19. //
  20. //--------------------------------------------------------------------------
  21. #include "pch.cxx"
  22. #pragma hdrstop
  23. #include "trkwks.hxx"
  24. #define THIS_FILE_NUMBER STUBS_CXX_FILE_NO
  25. //+----------------------------------------------------------------------------
  26. //
  27. // StubLnkCallSvrMessage
  28. //
  29. // Calls CTrkWksSvc::CallSvrMessage.
  30. //
  31. //+----------------------------------------------------------------------------
  32. HRESULT StubLnkCallSvrMessage(
  33. /* [in] */ handle_t IDL_handle,
  34. /* [switch_is][out][in] */ TRKSVR_MESSAGE_UNION __RPC_FAR *pMsg)
  35. {
  36. HRESULT hr;
  37. SThreadFromPoolState state;
  38. #if DBG
  39. InterlockedIncrement( &g_cTrkWksRpcThreads );
  40. TrkAssert( NULL != g_ptrkwks && CTRKWKSSVC_SIG == g_ptrkwks->GetSignature() );
  41. #endif
  42. __try
  43. {
  44. state = InitializeThreadFromPool();
  45. CVerifyAuthentication::VerifyAuthentication( IDL_handle );
  46. hr = g_ptrkwks->CallSvrMessage( IDL_handle, pMsg );
  47. }
  48. __except (BreakOnDebuggableException())
  49. {
  50. hr = GetExceptionCode();
  51. }
  52. UnInitializeThreadFromPool( state );
  53. #if DBG
  54. InterlockedDecrement( &g_cTrkWksRpcThreads );
  55. TrkAssert( 0 <= g_cTrkWksRpcThreads );
  56. #endif
  57. return(hr);
  58. }
  59. //+----------------------------------------------------------------------------
  60. //
  61. // Stubold_LnkCallSvrMessage
  62. //
  63. // Backward compatibility, calls StubLnkCallSvrMessage with new msg
  64. // structure.
  65. //
  66. //+----------------------------------------------------------------------------
  67. HRESULT Stubold_LnkCallSvrMessage(
  68. /* [in] */ handle_t IDL_handle,
  69. /* [out][in] */ TRKSVR_MESSAGE_UNION_OLD __RPC_FAR *pMsg)
  70. {
  71. TRKSVR_MESSAGE_UNION Msg2;
  72. #if DBG
  73. InterlockedIncrement( &g_cTrkWksRpcThreads );
  74. TrkAssert( NULL != g_ptrkwks && CTRKWKSSVC_SIG == g_ptrkwks->GetSignature() );
  75. #endif
  76. Msg2.MessageType = pMsg->MessageType;
  77. Msg2.Priority = PRI_5;
  78. switch (Msg2.MessageType)
  79. {
  80. case (SEARCH):
  81. Msg2.Search = pMsg->Search;
  82. break;
  83. case (MOVE_NOTIFICATION):
  84. Msg2.MoveNotification = pMsg->MoveNotification;
  85. break;
  86. case (REFRESH):
  87. Msg2.Refresh = pMsg->Refresh;
  88. break;
  89. case (SYNC_VOLUMES):
  90. Msg2.SyncVolumes = pMsg->SyncVolumes;
  91. break;
  92. case (DELETE_NOTIFY):
  93. Msg2.Delete = pMsg->Delete;
  94. break;
  95. }
  96. Msg2.ptszMachineID = pMsg->ptszMachineID;
  97. #if DBG
  98. InterlockedDecrement( &g_cTrkWksRpcThreads );
  99. TrkAssert( 0 <= g_cTrkWksRpcThreads );
  100. #endif
  101. return StubLnkCallSvrMessage( IDL_handle, &Msg2 );
  102. }
  103. //+----------------------------------------------------------------------------
  104. //
  105. // StubLnkMendLink
  106. //
  107. // Calls CTrkWksSvc::MendLink. This stub is caled from within the local machine.
  108. //
  109. //+----------------------------------------------------------------------------
  110. /*
  111. // Version 1.2 (added pdroidBirthCurrent)
  112. HRESULT
  113. StubLnkMendLink(RPC_BINDING_HANDLE IDL_handle,
  114. FILETIME ftLimit,
  115. DWORD RestrictionsIn,
  116. const CDomainRelativeObjId *pdroidBirthLast,
  117. const CDomainRelativeObjId *pdroidLast,
  118. const CMachineId *pmcidLast,
  119. CDomainRelativeObjId *pdroidBirthCurrent,
  120. CDomainRelativeObjId *pdroidCurrent,
  121. CMachineId *pmcidCurrent,
  122. ULONG *pcbPath,
  123. WCHAR *pwsz )
  124. {
  125. HRESULT hr = g_ptrkwks->MendLink( IDL_handle, static_cast<CFILETIME>(ftLimit), RestrictionsIn,
  126. *pdroidBirthLast, *pdroidLast, *pmcidLast,
  127. pdroidBirthCurrent, pdroidCurrent, pmcidCurrent,
  128. pcbPath, pwsz );
  129. TrkAssert( TRK_E_POTENTIAL_FILE_FOUND != hr
  130. ||
  131. *pdroidBirthLast != *pdroidBirthCurrent );
  132. TrkAssert( FAILED(hr) || *pdroidBirthLast == *pdroidBirthCurrent
  133. || *pdroidBirthLast == CDomainRelativeObjId() );
  134. return( MapTR2HR(hr) );
  135. }
  136. */
  137. // Version 1.1 (added pmcidLast and pmcidCurrent)
  138. void
  139. StubLnkMendLink(PRPC_ASYNC_STATE pAsync_handle,
  140. RPC_BINDING_HANDLE IDL_handle,
  141. FILETIME ftLimit,
  142. DWORD RestrictionsIn,
  143. const CDomainRelativeObjId *pdroidBirth,
  144. const CDomainRelativeObjId *pdroidLast,
  145. const CMachineId * pmcidLast,
  146. CDomainRelativeObjId * pdroidCurrent,
  147. CMachineId * pmcidCurrent,
  148. ULONG * pcbPath,
  149. WCHAR * wsz)
  150. {
  151. #if DBG
  152. InterlockedIncrement( &g_cTrkWksRpcThreads );
  153. TrkAssert( NULL != g_ptrkwks && CTRKWKSSVC_SIG == g_ptrkwks->GetSignature() );
  154. #endif
  155. CDomainRelativeObjId droidBirthCurrent;
  156. HRESULT hr = S_OK;
  157. SThreadFromPoolState state;
  158. __try
  159. {
  160. state = InitializeThreadFromPool();
  161. CVerifyAuthentication::VerifyAuthentication( IDL_handle );
  162. // Convert the time limit into a tick-count limit, so that we're reslient
  163. // to clock updates. Perf: Since this is always a intra-machine call,
  164. // the interface really ought to be changed so that it just passes
  165. // in a tick count, but it's not worth changing the interface just
  166. // for that.
  167. CFILETIME cftNow, cftLimit(ftLimit);
  168. DWORD dwTickCountDeadline = GetTickCount();
  169. if( cftLimit > cftNow )
  170. dwTickCountDeadline += (DWORD) ( (cftLimit - cftNow)/10000 );
  171. hr = g_ptrkwks->MendLink( IDL_handle, dwTickCountDeadline, RestrictionsIn,
  172. *pdroidBirth, *pdroidLast, *pmcidLast,
  173. &droidBirthCurrent, pdroidCurrent, pmcidCurrent,
  174. pcbPath, wsz );
  175. TrkAssert( FAILED(hr)
  176. ||
  177. *pdroidBirth == droidBirthCurrent );
  178. #if DBG
  179. InterlockedDecrement( &g_cTrkWksRpcThreads );
  180. TrkAssert( 0 <= g_cTrkWksRpcThreads );
  181. #endif
  182. }
  183. __except( EXCEPTION_EXECUTE_HANDLER )
  184. {
  185. hr = GetExceptionCode();
  186. }
  187. UnInitializeThreadFromPool( state );
  188. hr = MapTR2HR(hr);
  189. // If this request came in on Async RPC, complete the call and
  190. // pass back the return code.
  191. if( NULL != pAsync_handle )
  192. {
  193. HRESULT hrT = RpcAsyncCompleteCall( pAsync_handle, &hr );
  194. #if DBG
  195. if( ERROR_SUCCESS != hrT )
  196. TrkLog(( TRKDBG_ERROR, TEXT("Failed RpcAsyncCompleteCall (%lu)"), hrT ));
  197. #endif
  198. }
  199. }
  200. // Version 1.0
  201. HRESULT Stubold_LnkMendLink(
  202. /* [in] */ handle_t IDL_handle,
  203. /* [in] */ FILETIME ftLimit,
  204. /* [in] */ ULONG Restrictions,
  205. /* [in] */ const CDomainRelativeObjId __RPC_FAR *pdroidBirth,
  206. /* [in] */ const CDomainRelativeObjId __RPC_FAR *pdroidLast,
  207. /* [out] */ CDomainRelativeObjId __RPC_FAR *pdroidCurrent,
  208. /* [string][out] */ WCHAR __RPC_FAR wsz[ MAX_PATH + 1 ] )
  209. {
  210. TrkLog(( TRKDBG_ERROR, TEXT("Stubold_LnkMendLink was called") ));
  211. return( E_FAIL );
  212. }
  213. //+----------------------------------------------------------------------------
  214. //
  215. // StubLnkSearchMachine
  216. //
  217. // Calls CTrkWksSvc::SearchMachine. This is called from the trkwks service
  218. // on another machine, or directly (i.e. not by RPC) from within this
  219. // service.
  220. //
  221. //+----------------------------------------------------------------------------
  222. // Version 1.2 (added pdroidBirthLast, pdroidBirthNext)
  223. // S_OK || TRK_E_REFERRAL || TRK_E_NOT_FOUND || TRK_E_POTENTIAL_FILE_FOUND
  224. HRESULT StubLnkSearchMachine(RPC_BINDING_HANDLE IDL_handle,
  225. ULONG RestrictionsIn,
  226. const CDomainRelativeObjId *pdroidBirthLast,
  227. const CDomainRelativeObjId *pdroidLast,
  228. CDomainRelativeObjId *pdroidBirthNext,
  229. CDomainRelativeObjId *pdroidNext,
  230. CMachineId *pmcidNext,
  231. TCHAR *ptsz )
  232. {
  233. HRESULT hr;
  234. SThreadFromPoolState state;
  235. #if DBG
  236. InterlockedIncrement( &g_cTrkWksRpcThreads );
  237. TrkAssert( NULL != g_ptrkwks && CTRKWKSSVC_SIG == g_ptrkwks->GetSignature() );
  238. #endif
  239. __try
  240. {
  241. state = InitializeThreadFromPool();
  242. CVerifyAuthentication::VerifyAuthentication( IDL_handle );
  243. hr = g_ptrkwks->SearchMachine(
  244. IDL_handle,
  245. RestrictionsIn,
  246. *pdroidBirthLast, *pdroidLast,
  247. pdroidBirthNext, pdroidNext, pmcidNext, ptsz
  248. );
  249. }
  250. __except( BreakOnDebuggableException() )
  251. {
  252. hr = GetExceptionCode();
  253. }
  254. UnInitializeThreadFromPool( state );
  255. #if DBG
  256. InterlockedDecrement( &g_cTrkWksRpcThreads );
  257. TrkAssert( 0 <= g_cTrkWksRpcThreads );
  258. #endif
  259. return( hr );
  260. }
  261. // Version 1.1 (added pmcidNext)
  262. HRESULT Stubold2_LnkSearchMachine( RPC_BINDING_HANDLE IDL_handle,
  263. ULONG RestrictionsIn,
  264. const CDomainRelativeObjId *pdroidLast,
  265. CDomainRelativeObjId *pdroidNext,
  266. CMachineId *pmcidNext,
  267. TCHAR *tsz )
  268. {
  269. CDomainRelativeObjId droidBirthLast, droidBirthNext;
  270. return( StubLnkSearchMachine( IDL_handle, RestrictionsIn,
  271. &droidBirthLast, pdroidLast,
  272. &droidBirthNext, pdroidNext, pmcidNext,
  273. tsz ));
  274. }
  275. // Version 1.0
  276. HRESULT Stubold_LnkSearchMachine(
  277. /* [in] */ handle_t IDL_handle,
  278. /* [in] */ ULONG Restrictions,
  279. /* [in] */ const CDomainRelativeObjId __RPC_FAR *pdroidLast,
  280. /* [out] */ CDomainRelativeObjId __RPC_FAR *pdroidReferral,
  281. /* [string][out] */ TCHAR __RPC_FAR tsz[ MAX_PATH + 1 ])
  282. {
  283. CMachineId mcidNext;
  284. return Stubold2_LnkSearchMachine( IDL_handle, Restrictions, pdroidLast, pdroidReferral, &mcidNext, tsz );
  285. }
  286. HRESULT
  287. StubLnkGetBackup(
  288. /* [in] */ handle_t IDL_handle,
  289. /* [out][in] */ DWORD __RPC_FAR *pcVolumes,
  290. /* [size_is][size_is][out] */ VolumeMapEntry __RPC_FAR *__RPC_FAR *ppVolumeChanges,
  291. /* [out] */ FILETIME __RPC_FAR *pft)
  292. {
  293. return(E_NOTIMPL);
  294. }
  295. HRESULT
  296. StubGetFileTrackingInformation( RPC_BINDING_HANDLE IDL_handle,
  297. /*[in]*/ CDomainRelativeObjId droidCurrent,
  298. /*[in]*/ TrkInfoScope scope,
  299. /*[out]*/ TRK_FILE_TRACKING_INFORMATION_PIPE pipeFileInfo )
  300. {
  301. HRESULT hr = E_FAIL;
  302. SThreadFromPoolState state;
  303. #if DBG
  304. InterlockedIncrement( &g_cTrkWksRpcThreads );
  305. TrkAssert( NULL != g_ptrkwks && CTRKWKSSVC_SIG == g_ptrkwks->GetSignature() );
  306. #endif
  307. __try
  308. {
  309. TCHAR tszUncPath[ MAX_PATH + 1 ];
  310. ULONG cbPath = sizeof(tszUncPath);
  311. state = InitializeThreadFromPool();
  312. CVerifyAuthentication::VerifyAuthentication( IDL_handle );
  313. hr = g_ptrkwks->GetFileTrackingInformation( droidCurrent, scope, pipeFileInfo );
  314. }
  315. __except( BreakOnDebuggableException() )
  316. {
  317. hr = GetExceptionCode();
  318. }
  319. UnInitializeThreadFromPool( state );
  320. #if DBG
  321. InterlockedDecrement( &g_cTrkWksRpcThreads );
  322. TrkAssert( 0 <= g_cTrkWksRpcThreads );
  323. #endif
  324. return( hr );
  325. } // StubGetFileTrackingInformation()
  326. HRESULT
  327. StubGetVolumeTrackingInformation( RPC_BINDING_HANDLE IDL_handle,
  328. /*[in]*/ CVolumeId volid,
  329. /*[in]*/ TrkInfoScope scope,
  330. /*[out]*/ TRK_VOLUME_TRACKING_INFORMATION_PIPE pipeVolInfo )
  331. {
  332. HRESULT hr = E_FAIL;
  333. SThreadFromPoolState state;
  334. #if DBG
  335. InterlockedIncrement( &g_cTrkWksRpcThreads );
  336. TrkAssert( NULL != g_ptrkwks && CTRKWKSSVC_SIG == g_ptrkwks->GetSignature() );
  337. #endif
  338. __try
  339. {
  340. state = InitializeThreadFromPool();
  341. CVerifyAuthentication::VerifyAuthentication( IDL_handle );
  342. hr = g_ptrkwks->GetVolumeTrackingInformation( volid, scope, pipeVolInfo );
  343. }
  344. __except( BreakOnDebuggableException() )
  345. {
  346. hr = GetExceptionCode();
  347. }
  348. UnInitializeThreadFromPool( state );
  349. #if DBG
  350. InterlockedDecrement( &g_cTrkWksRpcThreads );
  351. TrkAssert( 0 <= g_cTrkWksRpcThreads );
  352. #endif
  353. return( hr );
  354. } // StubGetVolumes()
  355. HRESULT StubLnkOnRestore(/*[in]*/ RPC_BINDING_HANDLE IDL_handle)
  356. {
  357. HRESULT hr;
  358. SThreadFromPoolState state;
  359. #if DBG
  360. InterlockedIncrement( &g_cTrkWksRpcThreads );
  361. TrkAssert( NULL != g_ptrkwks && CTRKWKSSVC_SIG == g_ptrkwks->GetSignature() );
  362. #endif
  363. __try
  364. {
  365. state = InitializeThreadFromPool();
  366. CVerifyAuthentication::VerifyAuthentication( IDL_handle );
  367. hr = g_ptrkwks->OnRestore();
  368. }
  369. __except( BreakOnDebuggableException() )
  370. {
  371. hr = GetExceptionCode();
  372. }
  373. UnInitializeThreadFromPool( state );
  374. #if DBG
  375. InterlockedDecrement( &g_cTrkWksRpcThreads );
  376. TrkAssert( 0 <= g_cTrkWksRpcThreads );
  377. #endif
  378. return hr;
  379. }
  380. HRESULT StubLnkRestartDcSynchronization(
  381. RPC_BINDING_HANDLE IDL_handle
  382. )
  383. {
  384. return(E_NOTIMPL);
  385. }
  386. HRESULT StubLnkSetVolumeId(
  387. handle_t IDL_handle,
  388. ULONG iVolume,
  389. const CVolumeId VolId)
  390. {
  391. HRESULT hr;
  392. SThreadFromPoolState state;
  393. #if DBG
  394. InterlockedIncrement( &g_cTrkWksRpcThreads );
  395. TrkAssert( NULL != g_ptrkwks && CTRKWKSSVC_SIG == g_ptrkwks->GetSignature() );
  396. #endif
  397. __try
  398. {
  399. state = InitializeThreadFromPool();
  400. CVerifyAuthentication::VerifyAuthentication( IDL_handle );
  401. hr = g_ptrkwks->SetVolumeId( iVolume, VolId );
  402. }
  403. __except (BreakOnDebuggableException())
  404. {
  405. hr = GetExceptionCode();
  406. }
  407. UnInitializeThreadFromPool( state );
  408. #if DBG
  409. InterlockedDecrement( &g_cTrkWksRpcThreads );
  410. TrkAssert( 0 <= g_cTrkWksRpcThreads );
  411. #endif
  412. return(hr);
  413. }
  414. HRESULT
  415. StubTriggerVolumeClaims( RPC_BINDING_HANDLE IDL_handle,
  416. /*[in]*/ ULONG cVolumes,
  417. /*[in]*/ const CVolumeId *rgvolid )
  418. {
  419. HRESULT hr = E_FAIL;
  420. SThreadFromPoolState state;
  421. #if DBG
  422. InterlockedIncrement( &g_cTrkWksRpcThreads );
  423. TrkAssert( NULL != g_ptrkwks && CTRKWKSSVC_SIG == g_ptrkwks->GetSignature() );
  424. #endif
  425. __try
  426. {
  427. state = InitializeThreadFromPool();
  428. CVerifyAuthentication::VerifyAuthentication( IDL_handle );
  429. hr = g_ptrkwks->TriggerVolumeClaims( cVolumes, rgvolid );
  430. }
  431. __except( BreakOnDebuggableException() )
  432. {
  433. hr = GetExceptionCode();
  434. }
  435. UnInitializeThreadFromPool( state );
  436. #if DBG
  437. InterlockedDecrement( &g_cTrkWksRpcThreads );
  438. TrkAssert( 0 <= g_cTrkWksRpcThreads );
  439. #endif
  440. return( hr );
  441. } // StubTriggerVolumeClaims