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.

379 lines
12 KiB

  1. title "Dynamic Linkages to RPCRT4.DLL"
  2. ;++
  3. ;
  4. ; Copyright (c) 1989 Microsoft Corporation
  5. ;
  6. ; Module Name:
  7. ;
  8. ; rpccall.asm
  9. ;
  10. ; Abstract:
  11. ;
  12. ; This module implements functions that dynamically link to
  13. ; RPCRT4.DLL.
  14. ;
  15. ; Author:
  16. ;
  17. ; Murthy Srinivas 7-Nov-1995
  18. ;
  19. ; Environment:
  20. ;
  21. ; Any mode.
  22. ;
  23. ; Revision History:
  24. ;
  25. ; Notes:
  26. ;
  27. ; This module is dependent on the internal structure of the
  28. ; COleStaticMutexSem object (g_Rpcrt4Sem). It invokes the
  29. ; COleCommonMutexSem::Request method, as well as invokes
  30. ; COleStaticMutexSem::ReleaseFn. Any changes to this object
  31. ; may impact this code -- BEWARE!
  32. ;
  33. ;--
  34. .386p
  35. .xlist
  36. include callconv.inc
  37. .list
  38. extrn _GetLastError@0:proc
  39. extrn _GetProcAddress@8:proc
  40. extrn _LoadLibraryA@4:proc
  41. extrn _FreeLibrary@4:proc
  42. extrn ?Request@COleStaticMutexSem@@QAEXXZ:proc ; COleStaticMutexSem::Request
  43. extrn ?g_Rpcrt4Sem@@3VCOleStaticMutexSem@@A:DWORD ; COleStaticMutexSem g_Rpcrt4Sem
  44. extrn ?ReleaseFn@COleStaticMutexSem@@QAEXXZ:proc ; COleStaticMutexSem::ReleaseFn
  45. _BSS SEGMENT DWORD PUBLIC 'BSS'
  46. _BSS ENDS
  47. CONST SEGMENT DWORD PUBLIC 'CONST'
  48. CONST ENDS
  49. _TEXT SEGMENT DWORD PUBLIC 'CODE'
  50. ASSUME DS:FLAT, ES:NOTHING, SS:NOTHING, FS:NOTHING, GS:NOTHING
  51. _TEXT ENDS
  52. _DATA SEGMENT DWORD PUBLIC 'DATA'
  53. ASSUME DS:FLAT, ES:NOTHING, SS:NOTHING, FS:NOTHING, GS:NOTHING
  54. _DATA ENDS
  55. EPBlock STRUC
  56. EPAddr DD ?
  57. Nameptr DD ?
  58. ErrRtn DD ?
  59. EPBlock ENDS
  60. ;
  61. ; Macro to define an RPC entry point that is to be dynamically
  62. ; linked-to
  63. ;
  64. RPC_ENTRY macro EntryPoint,N
  65. _DATA SEGMENT
  66. EntryPoint&Block EPBlock {LoadAndGo,EntryPoint&Name,EntryPoint&Err}
  67. _DATA ENDS
  68. CONST SEGMENT
  69. EntryPoint&Name DB '&EntryPoint',0
  70. CONST ENDS
  71. _TEXT SEGMENT
  72. align dword ;;
  73. ifb <N>
  74. PUBLICP <_&EntryPoint>
  75. stdProc <_&EntryPoint>,0,<> ;;
  76. else
  77. PUBLICP <_&EntryPoint>,N
  78. stdProc <_&EntryPoint>,N,<> ;;
  79. endif
  80. lea eax,EntryPoint&Block ;; ptr to block for EP
  81. jmp DWORD PTR [eax].EPBlock.EPAddr ;; first time will jump to
  82. ;; LoadAndGo. Subsequently
  83. ;; will jump to EP in RPCRT4
  84. EntryPoint&Err: ;;
  85. stdRET <_&EntryPoint> ;;
  86. stdENDP <_&EntryPoint> ;;
  87. _TEXT ENDS
  88. endm
  89. RPC_VAR_ENTRY macro EntryPoint
  90. _DATA SEGMENT
  91. EntryPoint&Block EPBlock {LoadAndGo,EntryPoint&Name,EntryPoint&Err}
  92. _DATA ENDS
  93. CONST SEGMENT
  94. EntryPoint&Name DB '&EntryPoint',0
  95. CONST ENDS
  96. _TEXT SEGMENT
  97. align dword ;;
  98. public _&EntryPoint ;;
  99. _&EntryPoint proc ;;
  100. lea eax,EntryPoint&Block ;; ptr to block for EP
  101. jmp DWORD PTR [eax].EPBlock.EPAddr ;; first time will jump to
  102. ;; LoadAndGo. Subsequently
  103. ;; will jump to EP in RPCRT4
  104. EntryPoint&Err: ;;
  105. ret ;;
  106. _&EntryPoint endp ;;
  107. _TEXT ENDS
  108. endm
  109. page
  110. subttl "Load RPCRT4 Entry Point And Jump"
  111. ;++
  112. ;
  113. ; VOID
  114. ; LoadAndGo ()
  115. ;
  116. ; Routine Description:
  117. ;
  118. ; This function dynamically loads and saves the entry point address
  119. ; from RPCRT4.DLL and then jumps to the routine.
  120. ;
  121. ; Arguments:
  122. ;
  123. ; AX - ptr to EPBlock structure
  124. ;
  125. ; Return Value:
  126. ;
  127. ; Whatever the designated routine returns.
  128. ;
  129. ;--
  130. _BSS SEGMENT
  131. hLibrary DD 1
  132. _BSS ENDS
  133. _DATA SEGMENT
  134. LoadOrGet DD LoadLib
  135. _DATA ENDS
  136. CONST SEGMENT
  137. RPCRT4 DB 'RPCRT4.DLL',0
  138. CONST ENDS
  139. _TEXT SEGMENT
  140. LoadAndGo:
  141. push ebx ; save ebx, ecx, edx
  142. push ecx ;
  143. push edx ;
  144. push eax ; save EPBlock address
  145. mov ecx, OFFSET FLAT:?g_Rpcrt4Sem@@3VCOleStaticMutexSem@@A ; g_Rpcrt4Sem
  146. call ?Request@COleStaticMutexSem@@QAEXXZ ; COleStaticMutexSem::Request
  147. jmp DWORD PTR LoadOrGet ; LoadLib or GetProc
  148. LoadLib:
  149. lea eax,RPCRT4 ; load rpcrt4.dll
  150. push eax
  151. call _LoadLibraryA@4
  152. or eax,eax ; successful?
  153. jnz LoadLibOK ;
  154. mov ecx, OFFSET FLAT:?g_Rpcrt4Sem@@3VCOleStaticMutexSem@@A ; g_Rpcrt4Sem
  155. call ?ReleaseFn@COleStaticMutexSem@@QAEXXZ ; COleStaticMutexSem::ReleaseFn
  156. jmp GotError ;
  157. LoadLibOK:
  158. mov hLibrary,eax ; save its module handle
  159. lea eax,GetProc ; next time we won't LoadLib
  160. mov LoadOrGet,eax ;
  161. GetProc:
  162. mov ecx, OFFSET FLAT:?g_Rpcrt4Sem@@3VCOleStaticMutexSem@@A ; g_Rpcrt4Sem
  163. call ?ReleaseFn@COleStaticMutexSem@@QAEXXZ ; COleStaticMutexSem::ReleaseFn
  164. pop eax ; restore EPBlock address
  165. push eax ; save EPBlock address
  166. push [eax].EPBlock.NamePtr ; routine name
  167. push hLibrary ;
  168. call _GetProcAddress@8 ; load routine address
  169. or eax,eax ; successful?
  170. jz GotError ;
  171. pop ebx ; restore EPBlock Address
  172. mov [ebx].EPBlock.EPAddr,eax ; save routine address in designated location
  173. pop edx ; restore EDX, ECX, EBX
  174. pop ecx ;
  175. pop ebx ;
  176. jmp eax ; and jump to the routine in rpcrt4.dll
  177. GotError:
  178. call _GetLastError@0 ; for debugging only
  179. pop eax ; restore EPBlock address
  180. pop edx ;
  181. pop ecx ;
  182. pop ebx ;
  183. push [eax].EPBlock.ErrRtn ; set up error return
  184. mov eax,8 ; error return ERROR_NOT_ENOUGH_MEMORY
  185. ret ;
  186. _TEXT ENDS
  187. _TEXT SEGMENT
  188. align dword
  189. PUBLICP _FreeRPCRT4 ;
  190. stdProc _FreeRPCRT4,0,<> ;
  191. mov ecx, OFFSET FLAT:?g_Rpcrt4Sem@@3VCOleStaticMutexSem@@A ; g_Rpcrt4Sem
  192. call ?Request@COleStaticMutexSem@@QAEXXZ ; COleStaticMutexSem::Request
  193. push hLibrary ; FreeLibrary
  194. call _FreeLibrary@4 ;
  195. lea eax,GotError ; Always return error
  196. mov LoadOrGet,eax ;
  197. mov ecx, OFFSET FLAT:?g_Rpcrt4Sem@@3VCOleStaticMutexSem@@A ; g_Rpcrt4Sem
  198. call ?ReleaseFn@COleStaticMutexSem@@QAEXXZ ; COleStaticMutexSem::ReleaseFn
  199. stdRET _FreeRPCRT4 ;
  200. stdENDP _FreeRPCRT4 ;
  201. _TEXT ENDS
  202. ;
  203. ; Intercepted Entry points
  204. ;
  205. RPC_ENTRY CStdStubBuffer_AddRef,1
  206. RPC_ENTRY CStdStubBuffer_Connect,2
  207. RPC_ENTRY CStdStubBuffer_CountRefs,1
  208. RPC_ENTRY CStdStubBuffer_DebugServerQueryInterface,2
  209. RPC_ENTRY CStdStubBuffer_DebugServerRelease,2
  210. RPC_ENTRY CStdStubBuffer_Disconnect,1
  211. RPC_ENTRY CStdStubBuffer_Invoke,3
  212. RPC_ENTRY CStdStubBuffer_IsIIDSupported,2
  213. RPC_ENTRY CStdStubBuffer_QueryInterface,3
  214. RPC_ENTRY IUnknown_AddRef_Proxy,1
  215. RPC_ENTRY IUnknown_QueryInterface_Proxy,3
  216. RPC_ENTRY IUnknown_Release_Proxy,1
  217. RPC_ENTRY I_RpcAllocate,1
  218. RPC_ENTRY I_RpcBindingInqTransportType,2
  219. RPC_ENTRY I_RpcBindingSetAsync,3
  220. RPC_ENTRY I_RpcFree,1
  221. RPC_ENTRY I_RpcFreeBuffer,1
  222. RPC_ENTRY I_RpcGetBuffer,1
  223. RPC_ENTRY I_RpcGetThreadWindowHandle,1
  224. RPC_ENTRY I_RpcSendReceive,1
  225. RPC_ENTRY I_RpcServerRegisterForwardFunction,1
  226. RPC_ENTRY I_RpcServerStartListening,1
  227. RPC_ENTRY I_RpcServerStopListening,0
  228. RPC_ENTRY I_RpcServerUnregisterEndpointW,2
  229. RPC_ENTRY I_RpcSetThreadParams,3
  230. RPC_ENTRY I_RpcSsDontSerializeContext
  231. RPC_ENTRY I_RpcWindowProc,4
  232. RPC_ENTRY NdrAllocate,2
  233. RPC_ENTRY NDRCContextBinding,1
  234. RPC_ENTRY NDRSContextUnmarshall,2
  235. RPC_ENTRY NdrClearOutParameters,3
  236. RPC_ENTRY NdrCStdStubBuffer_Release,2
  237. RPC_VAR_ENTRY NdrClientCall2
  238. RPC_ENTRY NdrClientContextMarshall,3
  239. RPC_ENTRY NdrClientContextUnmarshall,3
  240. RPC_ENTRY NdrClientInitializeNew,4
  241. RPC_ENTRY NdrComplexArrayBufferSize,3
  242. RPC_ENTRY NdrComplexArrayFree,3
  243. RPC_ENTRY NdrComplexArrayMarshall,3
  244. RPC_ENTRY NdrComplexArrayUnmarshall,4
  245. RPC_ENTRY NdrConformantStringBufferSize,3
  246. RPC_ENTRY NdrConformantStringMarshall,3
  247. RPC_ENTRY NdrConformantStringUnmarshall,4
  248. RPC_ENTRY NdrConformantStructBufferSize,3
  249. RPC_ENTRY NdrConformantStructMarshall,3
  250. RPC_ENTRY NdrConformantStructUnmarshall,4
  251. RPC_ENTRY NdrConformantVaryingArrayBufferSize,3
  252. RPC_ENTRY NdrConformantVaryingArrayMarshall,3
  253. RPC_ENTRY NdrConvert,2
  254. RPC_ENTRY NdrConvert2,3
  255. RPC_ENTRY NdrCStdStubBuffer2_Release,2
  256. RPC_ENTRY NdrDllCanUnloadNow,1
  257. RPC_ENTRY NdrDllGetClassObject,6
  258. RPC_ENTRY NdrDllRegisterProxy,3
  259. RPC_ENTRY NdrDllUnregisterProxy,3
  260. RPC_ENTRY NdrFreeBuffer,1
  261. RPC_ENTRY NdrFullPointerXlatFree,1
  262. RPC_ENTRY NdrFullPointerXlatInit,2
  263. RPC_ENTRY NdrGetBuffer,3
  264. RPC_ENTRY NdrMapCommAndFaultStatus,4
  265. RPC_ENTRY NdrOleAllocate,1
  266. RPC_ENTRY NdrOleFree,1
  267. RPC_ENTRY NdrPointerBufferSize,3
  268. RPC_ENTRY NdrPointerFree,3
  269. RPC_ENTRY NdrPointerMarshall,3
  270. RPC_ENTRY NdrPointerUnmarshall,4
  271. RPC_ENTRY NdrProxyErrorHandler,1
  272. RPC_ENTRY NdrProxyFreeBuffer,2
  273. RPC_ENTRY NdrProxyGetBuffer,2
  274. RPC_ENTRY NdrProxyInitialize,5
  275. RPC_ENTRY NdrProxySendReceive,2
  276. RPC_ENTRY NdrSendReceive,2
  277. RPC_ENTRY NdrServerCall2,1
  278. RPC_ENTRY NdrServerContextMarshall,3
  279. RPC_ENTRY NdrServerContextUnmarshall,1
  280. RPC_ENTRY NdrServerInitializeNew,3
  281. RPC_ENTRY NdrSimpleStructBufferSize,3
  282. RPC_ENTRY NdrSimpleStructMarshall,3
  283. RPC_ENTRY NdrSimpleStructUnmarshall,4
  284. RPC_ENTRY NdrStubCall2,4
  285. RPC_ENTRY NdrStubGetBuffer,3
  286. RPC_ENTRY NdrStubInitialize,4
  287. RPC_ENTRY RpcBindingCopy,2
  288. RPC_ENTRY RpcBindingFree,1
  289. RPC_ENTRY RpcBindingFromStringBindingA,2
  290. RPC_ENTRY RpcBindingFromStringBindingW,2
  291. RPC_ENTRY RpcBindingInqAuthClientA,6
  292. RPC_ENTRY RpcBindingInqAuthClientW,6
  293. RPC_ENTRY RpcBindingInqAuthInfoExW,8
  294. RPC_ENTRY RpcBindingInqAuthInfoW,6
  295. RPC_ENTRY RpcBindingInqObject,2
  296. RPC_ENTRY RpcBindingReset,1
  297. RPC_ENTRY RpcBindingSetAuthInfoA,6
  298. RPC_ENTRY RpcBindingSetAuthInfoExW,7
  299. RPC_ENTRY RpcBindingSetAuthInfoW,6
  300. RPC_ENTRY RpcBindingSetObject,2
  301. RPC_ENTRY RpcBindingToStringBindingW,2
  302. RPC_ENTRY RpcBindingVectorFree,1
  303. RPC_ENTRY RpcImpersonateClient,1
  304. RPC_ENTRY RpcMgmtInqComTimeout,2
  305. RPC_ENTRY RpcMgmtIsServerListening,1
  306. RPC_ENTRY RpcMgmtStopServerListening,1
  307. RPC_ENTRY RpcMgmtWaitServerListen
  308. RPC_ENTRY RpcNetworkIsProtseqValidW,1
  309. RPC_ENTRY RpcRaiseException,1
  310. RPC_ENTRY RpcRevertToSelf
  311. RPC_ENTRY RpcServerInqBindings,1
  312. RPC_ENTRY RpcServerInqDefaultPrincNameA,2
  313. RPC_ENTRY RpcServerInqDefaultPrincNameW,2
  314. RPC_ENTRY RpcServerListen,3
  315. RPC_ENTRY RpcServerRegisterAuthInfoW,4
  316. RPC_ENTRY RpcServerRegisterAuthInfoA,4
  317. RPC_ENTRY RpcServerRegisterIf,3
  318. RPC_ENTRY RpcServerRegisterIfEx,6
  319. RPC_ENTRY RpcServerUnregisterIf,3
  320. RPC_ENTRY RpcServerUseProtseqEpW,4
  321. RPC_ENTRY RpcServerUseProtseqW,3
  322. RPC_ENTRY RpcSmDestroyClientContext,1
  323. RPC_ENTRY RpcStringBindingComposeW,6
  324. RPC_ENTRY RpcStringBindingParseW,6
  325. RPC_ENTRY RpcStringFreeW,1
  326. RPC_ENTRY RpcStringFreeA,1
  327. RPC_ENTRY TowerExplode,6
  328. RPC_ENTRY UuidCreate,1
  329. RPC_ENTRY MesHandleFree,1
  330. RPC_ENTRY MesEncodeFixedBufferHandleCreate,4
  331. RPC_ENTRY MesBufferHandleReset,6
  332. RPC_ENTRY MesDecodeBufferHandleCreate,3
  333. RPC_ENTRY NdrMesTypeAlignSize,4
  334. RPC_ENTRY NdrMesTypeEncode,4
  335. RPC_ENTRY NdrMesTypeDecode,4
  336. end