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.

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