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.

341 lines
8.7 KiB

  1. #ifndef __LDMGR_HPP__
  2. #define __LDMGR_HPP__
  3. /*++
  4. Copyright (C) 2000 Microsoft Corporation
  5. All rights reserved.
  6. Module Name:
  7. ldmgr.hpp
  8. Abstract:
  9. This file contains the declararion of classes necessary to
  10. encapsulate the declarations and defintions and prototypes
  11. required for the RPC surrogate used to load 64 bit dlls from
  12. within 32 bit apps.
  13. Author:
  14. Khaled Sedky (khaleds) 18-Jan-2000
  15. Revision History:
  16. --*/
  17. #ifndef __LDERROR_HPP__
  18. #include "lderror.hpp"
  19. #endif
  20. #ifndef __BASECLS_HPP__
  21. #include "basecls.hpp"
  22. #endif
  23. #ifndef __PRTCFG_HPP__
  24. #include "prtcfg.hpp"
  25. #endif
  26. #ifndef __DRVEVNT_HPP__
  27. #include "drvevnt.hpp"
  28. #endif
  29. #ifndef __PRNTUIFN_HPP__
  30. #include "prntuifn.hpp"
  31. #endif
  32. #ifndef __LPCMGR_HPP__
  33. #include "lpcmgr.hpp"
  34. #endif
  35. #define MAX_CAPVAL DC_MEDIATYPES
  36. #define APPNAME L"splwow64"
  37. #define GDI_LPC_PORT_NAME L"\\RPC Control\\UmpdProxy"
  38. #define ACTIVATION_CONTEXT_RESOURCE_ID 123
  39. class TLoad64BitDllsMgr : public TClassID,
  40. public TRefCntMgr ,
  41. public TLd64BitDllsErrorHndlr,
  42. public TPrinterDriver
  43. {
  44. public:
  45. enum ELdMgrConstants
  46. {
  47. kMaxRPCPacketSize = 1024*1000
  48. };
  49. friend DWORD
  50. TLoad64BitDllsMgr::
  51. MonitorSrvrLifeExpiration(
  52. IN PVOID pData
  53. );
  54. TLoad64BitDllsMgr(
  55. OUT HRESULT *phRes = NULL
  56. );
  57. ~TLoad64BitDllsMgr(
  58. VOID
  59. );
  60. HRESULT
  61. QueryInterface(
  62. IN REFIID InterfaceID,
  63. OUT PVOID *ppInterface
  64. );
  65. DWORD
  66. Run();
  67. VOID
  68. RefreshLifeSpan(
  69. VOID
  70. );
  71. BOOL
  72. ExecuteMonitorOperation(
  73. IN ULONG_PTR hWnd,
  74. IN LPWSTR pszServerName,
  75. IN LPWSTR pszUIDllName,
  76. IN LPWSTR pszPortName,
  77. IN EPortOp Index,
  78. OUT PDWORD pErrorCode
  79. );
  80. int
  81. DeviceCapabilities(
  82. IN LPWSTR pszDeviceName,
  83. IN LPWSTR pszPortName,
  84. IN WORD Capabilites,
  85. IN DWORD DevModeSize,
  86. IN LPBYTE pDevMode,
  87. IN BOOL bClonedOutputFill,
  88. OUT PDWORD pClonedOutputSize,
  89. OUT LPBYTE *ppClonedOutput,
  90. OUT PDWORD pErrorCode
  91. );
  92. LONG
  93. DocumentProperties(
  94. IN ULONG_PTR hWnd,
  95. IN LPWSTR pszPrinterName,
  96. OUT PDWORD pTouchedDevModeSize,
  97. OUT PDWORD pClonedDevModeOutSize,
  98. OUT LPBYTE *ppClonedDevModeOut,
  99. IN DWORD DevModeSize,
  100. IN LPBYTE pDevMode,
  101. IN BOOL bClonedDevModeOutFill,
  102. IN DWORD fMode,
  103. OUT PDWORD pErrorCode
  104. );
  105. LONG
  106. PrintUIDocumentProperties(
  107. IN ULONG_PTR hWnd,
  108. IN LPWSTR pszPrinterName,
  109. OUT PDWORD pTouchedDevModeSize,
  110. OUT PDWORD pClonedDevModeOutSize,
  111. OUT LPBYTE *ppClonedDevModeOut,
  112. IN DWORD DevModeSize,
  113. IN LPBYTE pDevMode,
  114. IN BOOL bClonedDevModeOutFill,
  115. IN DWORD fMode,
  116. IN DWORD fExclusionFlags,
  117. OUT PDWORD pErrorCode
  118. );
  119. VOID
  120. IncUIRefCnt(
  121. VOID
  122. );
  123. VOID
  124. DecUIRefCnt(
  125. VOID
  126. );
  127. DWORD
  128. GetUIRefCnt(
  129. VOID
  130. )const;
  131. DWORD
  132. GetCurrSessionId(
  133. VOID
  134. ) const;
  135. struct SPORTADDTHREADDATA
  136. {
  137. PFNMONITORADD pMonFnAdd;
  138. PFNMONITORFNS pMonFns;
  139. HWND hWnd;
  140. PCWSTR pszServerName;
  141. PCWSTR pszMonitorName;
  142. PCWSTR pszPortName;
  143. PWSTR *ppszRetPortName;
  144. HMODULE hLib;
  145. HANDLE hActCtx;
  146. ULONG_PTR lActCtx;
  147. BOOL bActivated;
  148. };
  149. typedef struct SPORTADDTHREADDATA SPortAddThreadData;
  150. struct SDOCPROPSTHREADDATA
  151. {
  152. HWND hWnd;
  153. LPWSTR pszPrinterName;
  154. PDWORD pTouchedDevModeSize;
  155. PDWORD pClonedDevModeOutSize;
  156. LPBYTE *ppClonedDevModeOut;
  157. DWORD DevModeSize;
  158. LPBYTE pDevMode;
  159. TLoad64BitDllsMgr *pMgrInstance;
  160. DWORD fMode;
  161. DWORD fExclusionFlags;
  162. DWORD ErrorCode;
  163. LONG RetVal;
  164. BOOL bClonedDevModeOutFill;
  165. };
  166. typedef struct SDOCPROPSTHREADDATA SDocPropsThreadData;
  167. enum ETime
  168. {
  169. KOneMinute = 60000,
  170. KTwoMinutes = 120000
  171. };
  172. protected:
  173. DWORD
  174. StartLdrRPCServer(
  175. VOID
  176. );
  177. DWORD
  178. StopLdrRPCServer(
  179. VOID
  180. );
  181. static DWORD
  182. MonitorSrvrLifeExpiration(
  183. IN PVOID pData
  184. );
  185. static DWORD
  186. AddPortUI(
  187. IN PVOID pInThrdData
  188. );
  189. static DWORD
  190. DeletePortUI(
  191. IN PVOID pInThrdData
  192. );
  193. static DWORD
  194. ConfigurePortUI(
  195. IN PVOID pInThrdData
  196. );
  197. DWORD
  198. InternalDocumentProperties(
  199. IN PVOID pInThrdData
  200. );
  201. DWORD
  202. InternalPrintUIDocumentProperties(
  203. IN PVOID pInThrdData
  204. );
  205. BOOL
  206. DevCapFillsOutput(
  207. IN DWORD Capabilities
  208. ) const;
  209. DWORD
  210. CalcReqSizeForDevCaps(
  211. IN DWORD CapNum,
  212. IN DWORD Capabilites
  213. ) const;
  214. DWORD
  215. SpinPortOperationThread(
  216. IN HWND hWnd,
  217. IN LPWSTR pszServerName,
  218. IN LPWSTR pszName,
  219. IN PMONITORUI pMonitorUI,
  220. IN EPortOp Index,
  221. IN LPTHREAD_START_ROUTINE pThrdFn,
  222. IN HMODULE hLib,
  223. IN HANDLE hActCtx,
  224. IN ULONG_PTR lActCtx,
  225. IN BOOL bActivated
  226. ) const;
  227. DWORD
  228. GetMonitorUIActivationContext(
  229. IN LPWSTR pszUIDllName,
  230. IN OUT HANDLE *phActCtx,
  231. IN OUT ULONG_PTR *plActCtx,
  232. IN OUT BOOL *pActivated
  233. ) const;
  234. DWORD
  235. GetMonitorUIFullPath(
  236. IN LPWSTR pszUIDllName,
  237. IN OUT LPWSTR pszFullPath
  238. ) const;
  239. VOID
  240. ReleaseMonitorActivationContext(
  241. IN HINSTANCE hLib ,
  242. IN HANDLE hActCtx ,
  243. IN ULONG_PTR lActCtx,
  244. IN BOOL bActivated
  245. ) const;
  246. private:
  247. //
  248. // Some helper functions internal to the class
  249. //
  250. VOID
  251. LockSelf(
  252. VOID
  253. );
  254. VOID
  255. ReleaseSelf(
  256. VOID
  257. );
  258. BOOL
  259. StillAlive(
  260. VOID
  261. );
  262. //
  263. // The data encapsulated by the control.
  264. // This control has no data pertinent to itself. It only
  265. // encapsulates data pertinent to the synchronization of
  266. // of the requesting clients and timing out the whole
  267. // control . It also has a session ID which identifies its
  268. // instantion across different sessions for Terminal Server.
  269. // Added to it also is a Port connection handle for GDI UMPD
  270. // thunking
  271. //
  272. DWORD m_CurrSessionId;
  273. DWORD m_UIRefCnt;
  274. DWORD m_ExpirationTime;
  275. SYSTEMTIME m_LastTransactionTime;
  276. CRITICAL_SECTION m_LdMgrLock;
  277. };
  278. #endif //__LDMGR_HPP__