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.

596 lines
13 KiB

  1. /******************************Module*Header*******************************\
  2. * Module Name: usersrv.c
  3. *
  4. * Copyright (c) 1996-1999 Microsoft Corporation
  5. *
  6. \**************************************************************************/
  7. #include "precomp.hxx"
  8. //
  9. // The following methods are thunks to support calls to user mode
  10. // font drivers
  11. //
  12. #define DEFINE_FUNCTION(x, y) \
  13. union { \
  14. PFN Generic; \
  15. PFN_Drv##x Kernel; \
  16. } y = { ppfn(INDEX_Drv##x) };
  17. class ATTACHOBJ {
  18. public:
  19. PDEVOBJ *pObject;
  20. ATTACHOBJ(PDEVOBJ *pObject_);
  21. ~ATTACHOBJ();
  22. };
  23. ATTACHOBJ::ATTACHOBJ(PDEVOBJ *pObject_)
  24. {
  25. if (pObject_->bFontDriver())
  26. {
  27. pObject = pObject_;
  28. KeAttachProcess(PsGetProcessPcb(gpepCSRSS));
  29. }
  30. else
  31. {
  32. pObject = 0;
  33. }
  34. }
  35. ATTACHOBJ::~ATTACHOBJ()
  36. {
  37. if (pObject)
  38. {
  39. KeDetachProcess();
  40. }
  41. }
  42. /******************************Public*Routine******************************\
  43. *
  44. * Routine Name:
  45. *
  46. * PDEVOBJ::EnablePDEV
  47. *
  48. \**************************************************************************/
  49. DHPDEV PDEVOBJ::EnablePDEV(
  50. DEVMODEW *pdm
  51. , LPWSTR pwszLogAddress
  52. , ULONG cPat
  53. , HSURF *phsurfPatterns
  54. , ULONG cjCaps
  55. , GDIINFO *pGdiInfo
  56. , ULONG cjDevInfo
  57. , DEVINFO *pdi
  58. , HDEV hdev
  59. , LPWSTR pwszDeviceName
  60. , HANDLE hDriver
  61. )
  62. {
  63. DHPDEV ReturnValue;
  64. DEFINE_FUNCTION(EnablePDEV, pfn);
  65. ReturnValue = (*pfn.Kernel)(pdm,
  66. pwszLogAddress,
  67. cPat,
  68. phsurfPatterns,
  69. cjCaps,
  70. pGdiInfo,
  71. cjDevInfo,
  72. pdi,
  73. hdev,
  74. pwszDeviceName,
  75. hDriver);
  76. return(ReturnValue);
  77. }
  78. /******************************Public*Routine******************************\
  79. *
  80. * Routine Name:
  81. *
  82. * PDEVOBJ::DisablePDEV
  83. *
  84. \**************************************************************************/
  85. VOID PDEVOBJ::DisablePDEV( DHPDEV dhpdev)
  86. {
  87. DEFINE_FUNCTION(DisablePDEV, pfn);
  88. (*pfn.Kernel)(dhpdev);
  89. }
  90. /******************************Public*Routine******************************\
  91. *
  92. * Routine Name:
  93. *
  94. * PDEVOBJ::CompletePDEV
  95. *
  96. \**************************************************************************/
  97. VOID PDEVOBJ::CompletePDEV( DHPDEV dhpdev, HDEV hdev)
  98. {
  99. DEFINE_FUNCTION(CompletePDEV, pfn);
  100. (*pfn.Kernel)(dhpdev, hdev);
  101. }
  102. /******************************Public*Routine******************************\
  103. *
  104. * Routine Name:
  105. *
  106. * PDEVOBJ::QueryFont
  107. *
  108. \**************************************************************************/
  109. IFIMETRICS* PDEVOBJ::QueryFont(
  110. DHPDEV dhpdev
  111. , ULONG_PTR iFile
  112. , ULONG iFace
  113. , ULONG_PTR *pid
  114. )
  115. {
  116. IFIMETRICS *ReturnValue = NULL;
  117. DEFINE_FUNCTION(QueryFont, pfn);
  118. if (gpepCSRSS)
  119. {
  120. ATTACHOBJ ato(this);
  121. ReturnValue = (*pfn.Kernel)(dhpdev, iFile, iFace, pid);
  122. }
  123. return(ReturnValue);
  124. }
  125. /******************************Public*Routine******************************\
  126. *
  127. * Routine Name:
  128. *
  129. * PDEVOBJ::QueryFontTree
  130. *
  131. \**************************************************************************/
  132. PVOID PDEVOBJ::QueryFontTree(
  133. DHPDEV dhpdev
  134. , ULONG_PTR iFile
  135. , ULONG iFace
  136. , ULONG iMode
  137. , ULONG_PTR *pid
  138. )
  139. {
  140. PVOID ReturnValue = NULL;
  141. DEFINE_FUNCTION(QueryFontTree, pfn);
  142. if (gpepCSRSS)
  143. {
  144. ATTACHOBJ ato(this);
  145. ReturnValue = (*pfn.Kernel)(dhpdev, iFile, iFace, iMode, pid);
  146. }
  147. return(ReturnValue);
  148. }
  149. /******************************Public*Routine******************************\
  150. *
  151. * Routine Name:
  152. *
  153. * PDEVOBJ::QueryFontData
  154. *
  155. \**************************************************************************/
  156. LONG PDEVOBJ::QueryFontData(
  157. DHPDEV dhpdev
  158. , FONTOBJ *pfo
  159. , ULONG iMode
  160. , HGLYPH hg
  161. , GLYPHDATA *pgd
  162. , PVOID pv
  163. , ULONG cjSize
  164. )
  165. {
  166. LONG ReturnValue = FD_ERROR;
  167. DEFINE_FUNCTION(QueryFontData, pfn);
  168. if (gpepCSRSS)
  169. {
  170. ATTACHOBJ ato(this);
  171. ReturnValue = (*pfn.Kernel)(dhpdev, pfo, iMode, hg, pgd, pv, cjSize);
  172. }
  173. return(ReturnValue);
  174. }
  175. /******************************Public*Routine******************************\
  176. *
  177. * Routine Name:
  178. *
  179. * PDEVOBJ::DestroyFont
  180. *
  181. \**************************************************************************/
  182. VOID PDEVOBJ::DestroyFont(FONTOBJ *pfo)
  183. {
  184. BOOL bUnmap = FALSE;
  185. RFONTTMPOBJ rfo(PFO_TO_PRF(pfo));
  186. // check ref count
  187. {
  188. SEMOBJ so(ghsemPublicPFT);
  189. if (rfo.pPFF()->cRFONT == 1)
  190. bUnmap = TRUE;
  191. }
  192. if (bUnmap)
  193. {
  194. UnmapPrintKView(rfo.pPFF()->hff);
  195. }
  196. DEFINE_FUNCTION(DestroyFont, pfn);
  197. if (gpepCSRSS)
  198. {
  199. ATTACHOBJ ato(this);
  200. (*pfn.Kernel)(pfo);
  201. }
  202. }
  203. /******************************Public*Routine******************************\
  204. *
  205. * Routine Name:
  206. *
  207. * PDEVOBJ::QueryFontCaps
  208. *
  209. \**************************************************************************/
  210. LONG PDEVOBJ::QueryFontCaps(
  211. ULONG culCaps
  212. , ULONG *pulCaps
  213. )
  214. {
  215. LONG ReturnValue;
  216. DEFINE_FUNCTION(QueryFontCaps, pfn);
  217. ReturnValue = (*pfn.Kernel)(culCaps, pulCaps);
  218. return(ReturnValue);
  219. }
  220. /******************************Public*Routine******************************\
  221. *
  222. * Routine Name:
  223. *
  224. * PDEVOBJ::LoadFontFile
  225. *
  226. \**************************************************************************/
  227. HFF PDEVOBJ::LoadFontFile(
  228. ULONG cFiles
  229. , ULONG_PTR *piFile
  230. , PVOID *ppvView
  231. , ULONG *pcjView
  232. , DESIGNVECTOR *pdv
  233. , ULONG ulLangID
  234. , ULONG ulFastCheckSum
  235. )
  236. {
  237. HFF ReturnValue = 0;
  238. DEFINE_FUNCTION(LoadFontFile, pfn);
  239. if (gpepCSRSS)
  240. {
  241. ATTACHOBJ ato(this);
  242. ReturnValue = (*pfn.Kernel)(cFiles, piFile, ppvView, pcjView, pdv, ulLangID, ulFastCheckSum);
  243. }
  244. return(ReturnValue);
  245. }
  246. /******************************Public*Routine******************************\
  247. *
  248. * Routine Name:
  249. *
  250. * PDEVOBJ::UnloadFontFile
  251. *
  252. \**************************************************************************/
  253. BOOL PDEVOBJ::UnloadFontFile(ULONG_PTR iFile)
  254. {
  255. BOOL ReturnValue = FALSE;
  256. DEFINE_FUNCTION(UnloadFontFile, pfn);
  257. if (gpepCSRSS)
  258. {
  259. ATTACHOBJ ato(this);
  260. ReturnValue = (*pfn.Kernel)(iFile);
  261. }
  262. else{
  263. return(-1);
  264. }
  265. return(ReturnValue);
  266. }
  267. /******************************Public*Routine******************************\
  268. *
  269. * Routine Name:
  270. *
  271. * PDEVOBJ::QueryFontFile
  272. *
  273. \**************************************************************************/
  274. LONG PDEVOBJ::QueryFontFile(
  275. ULONG_PTR iFile
  276. , ULONG ulMode
  277. , ULONG cjBuf
  278. , ULONG *pulBuf
  279. )
  280. {
  281. LONG ReturnValue = FD_ERROR;
  282. DEFINE_FUNCTION(QueryFontFile, pfn);
  283. if (gpepCSRSS)
  284. {
  285. ATTACHOBJ ato(this);
  286. ReturnValue = (*pfn.Kernel)(iFile, ulMode, cjBuf, pulBuf);
  287. }
  288. return(ReturnValue);
  289. }
  290. /******************************Public*Routine******************************\
  291. *
  292. * Routine Name:
  293. *
  294. * PDEVOBJ::QueryAdvanceWidths
  295. *
  296. \**************************************************************************/
  297. BOOL PDEVOBJ::QueryAdvanceWidths(
  298. DHPDEV dhpdev
  299. , FONTOBJ *pfo
  300. , ULONG iMode
  301. , HGLYPH *phg
  302. , PVOID pvWidths
  303. , ULONG cGlyphs
  304. )
  305. {
  306. BOOL ReturnValue = FALSE;
  307. DEFINE_FUNCTION(QueryAdvanceWidths, pfn);
  308. if (gpepCSRSS)
  309. {
  310. ATTACHOBJ ato(this);
  311. ReturnValue = (*pfn.Kernel)(dhpdev, pfo, iMode, phg, pvWidths, cGlyphs);
  312. }
  313. return(ReturnValue);
  314. }
  315. /******************************Public*Routine******************************\
  316. *
  317. * Routine Name:
  318. *
  319. * PDEVOBJ::Free
  320. *
  321. \**************************************************************************/
  322. VOID PDEVOBJ::Free(PVOID pv, ULONG_PTR id)
  323. {
  324. DEFINE_FUNCTION(Free, pfn);
  325. if (gpepCSRSS)
  326. {
  327. ATTACHOBJ ato(this);
  328. (*pfn.Kernel)(pv, id);
  329. }
  330. }
  331. /******************************Public*Routine******************************\
  332. *
  333. * Routine Name:
  334. *
  335. * PDEVOBJ::bQueryGlyphAttrs
  336. *
  337. \**************************************************************************/
  338. PFD_GLYPHATTR PDEVOBJ::QueryGlyphAttrs(
  339. FONTOBJ *pfo,
  340. ULONG iMode
  341. )
  342. {
  343. DEFINE_FUNCTION(QueryGlyphAttrs, pfn);
  344. if (gpepCSRSS)
  345. {
  346. ATTACHOBJ ato(this);
  347. if (pfn.Kernel)
  348. {
  349. return (*pfn.Kernel)(pfo, iMode);
  350. }
  351. }
  352. return NULL;
  353. }
  354. /******************************Public*Routine******************************\
  355. *
  356. * Routine Name:
  357. *
  358. * PDEVOBJ::QueryTrueTypeTable
  359. *
  360. \**************************************************************************/
  361. LONG PDEVOBJ::QueryTrueTypeTable(
  362. ULONG_PTR iFile
  363. , ULONG ulFont
  364. , ULONG ulTag
  365. , PTRDIFF dpStart
  366. , ULONG cjBuf
  367. , BYTE *pjBuf
  368. , BYTE **ppjTable
  369. , ULONG *pcjTable
  370. )
  371. {
  372. LONG ReturnValue = FD_ERROR;
  373. DEFINE_FUNCTION(QueryTrueTypeTable, pfn);
  374. if (gpepCSRSS)
  375. {
  376. ATTACHOBJ ato(this);
  377. if (pjBuf)
  378. {
  379. *pjBuf = 0;
  380. }
  381. if (pfn.Kernel)
  382. {
  383. ReturnValue = (*pfn.Kernel)(iFile,
  384. ulFont,
  385. ulTag,
  386. dpStart,
  387. cjBuf,
  388. pjBuf,
  389. ppjTable,
  390. pcjTable);
  391. }
  392. }
  393. return(ReturnValue);
  394. }
  395. /******************************Public*Routine******************************\
  396. *
  397. * Routine Name:
  398. *
  399. * PDEVOBJ::QueryTrueTypeOutline
  400. *
  401. \**************************************************************************/
  402. LONG PDEVOBJ::QueryTrueTypeOutline(
  403. DHPDEV dhpdev
  404. , FONTOBJ *pfo
  405. , HGLYPH hglyph
  406. , BOOL bMetricsOnly
  407. , GLYPHDATA *pgldt
  408. , ULONG cjBuf
  409. , TTPOLYGONHEADER *ppoly
  410. )
  411. {
  412. LONG ReturnValue = FD_ERROR;
  413. DEFINE_FUNCTION(QueryTrueTypeOutline, pfn);
  414. if (gpepCSRSS)
  415. {
  416. ATTACHOBJ ato(this);
  417. ReturnValue = (*pfn.Kernel)(dhpdev,
  418. pfo,
  419. hglyph,
  420. bMetricsOnly,
  421. pgldt,
  422. cjBuf,
  423. ppoly);
  424. }
  425. return(ReturnValue);
  426. }
  427. /******************************Public*Routine******************************\
  428. *
  429. * Routine Name:
  430. *
  431. * PDEVOBJ::GetTrueTypeFile
  432. *
  433. \**************************************************************************/
  434. PVOID PDEVOBJ::GetTrueTypeFile(ULONG_PTR iFile, ULONG *pcj)
  435. {
  436. PVOID ReturnValue = 0;
  437. DEFINE_FUNCTION(GetTrueTypeFile, pfn);
  438. if (gpepCSRSS)
  439. {
  440. ATTACHOBJ ato(this);
  441. *pcj = 0;
  442. if (pfn.Kernel)
  443. {
  444. ReturnValue = (*pfn.Kernel)(iFile, pcj);
  445. }
  446. }
  447. return(ReturnValue);
  448. }
  449. /******************************Public*Routine******************************\
  450. *
  451. * Routine Name:
  452. *
  453. * PDEVOBJ::FontManagement
  454. *
  455. \**************************************************************************/
  456. BOOL PDEVOBJ::FontManagement(
  457. SURFOBJ *pso,
  458. FONTOBJ *pfo,
  459. ULONG iEsc,
  460. ULONG cjIn,
  461. PVOID pvIn,
  462. ULONG cjOut,
  463. PVOID pvOut
  464. )
  465. {
  466. BOOL ReturnValue = FALSE;
  467. DEFINE_FUNCTION(FontManagement, pfn);
  468. if (gpepCSRSS)
  469. {
  470. ATTACHOBJ ato(this);
  471. if (pfn.Kernel)
  472. {
  473. ReturnValue = (*pfn.Kernel)(pso, pfo, iEsc, cjIn, pvIn, cjOut, pvOut);
  474. }
  475. }
  476. return(ReturnValue);
  477. }
  478. /******************************Public*Routine******************************\
  479. *
  480. * Routine Name:
  481. *
  482. * PDEVOBJ::Escape
  483. *
  484. \**************************************************************************/
  485. ULONG PDEVOBJ::Escape(
  486. SURFOBJ *pso
  487. , ULONG iEsc
  488. , ULONG cjIn
  489. , PVOID pvIn
  490. , ULONG cjOut
  491. , PVOID pvOut
  492. )
  493. {
  494. ULONG ReturnValue = 0;
  495. DEFINE_FUNCTION(Escape, pfn);
  496. if (gpepCSRSS)
  497. {
  498. ATTACHOBJ ato(this);
  499. ReturnValue = (*pfn.Kernel)(pso, iEsc, cjIn, pvIn, cjOut, pvOut);
  500. }
  501. return(ReturnValue);
  502. }