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.

961 lines
26 KiB

  1. /******************************Module*Header*******************************\
  2. * Module Name: init.cxx
  3. *
  4. * Engine initialization
  5. *
  6. * Copyright (c) 1990-1999 Microsoft Corporation
  7. \**************************************************************************/
  8. #include "precomp.hxx"
  9. #include "verifier.hxx"
  10. #include "winsta.h"
  11. extern "C" USHORT gProtocolType;
  12. BOOLEAN gIsTerminalServer;
  13. extern BOOL G_fConsole;
  14. extern BOOL G_fDoubleDpi;
  15. extern "C" BOOL bInitPALOBJ(); // palobj.cxx
  16. extern "C" VOID vInitXLATE(); // ylateobj.cxx
  17. extern "C" BOOL bInitBMOBJ(); // surfeng.cxx
  18. extern "C" BOOL InitializeScripts(); // fontsup.cxx
  19. extern "C" BOOL bInitICM(); // icmapi.cxx
  20. extern "C" BOOL bInitFontTables(); // pftobj.cxx
  21. extern "C" BOOL bInitStockFonts(VOID); // stockfnt.cxx
  22. extern "C" VOID vInitFontSubTable(); // fontsub.cxx
  23. extern "C" BOOL bInitBRUSHOBJ(); // brushobj.cxx
  24. extern "C" VOID vInitMapper(); // fontmap.cxx
  25. extern USHORT GetLanguageID();
  26. // Prototypes from font drivers.
  27. extern "C" BOOL BmfdEnableDriver(ULONG iEngineVersion,ULONG cj, PDRVENABLEDATA pded);
  28. extern "C" BOOL ttfdEnableDriver(ULONG iEngineVersion,ULONG cj, PDRVENABLEDATA pded);
  29. extern "C" BOOL vtfdEnableDriver(ULONG iEngineVersion,ULONG cj, PDRVENABLEDATA pded);
  30. extern "C" BOOL atmfdEnableDriver(ULONG iEngineVersion,ULONG cj, PDRVENABLEDATA pded);
  31. extern "C" NTSTATUS FontDriverQueryRoutine(
  32. IN PWSTR ValueName,
  33. IN ULONG ValueType,
  34. IN PVOID ValueData,
  35. IN ULONG ValueLength,
  36. IN PVOID Context,
  37. IN PVOID EntryContext
  38. );
  39. extern "C" BOOL bRegisterFontServer(VOID);
  40. extern "C" BOOL bUserModeFontDrivers(VOID);
  41. #ifdef LANGPACK
  42. extern "C" NTSTATUS LpkShapeQueryRoutine(
  43. IN PWSTR ValueName,
  44. IN ULONG ValueType,
  45. IN PVOID ValueData,
  46. IN ULONG ValueLength,
  47. IN PVOID Context,
  48. IN PVOID EntryContext
  49. );
  50. #endif
  51. //
  52. // Prototypes from halftone
  53. //
  54. extern "C" BOOL PASCAL EnableHalftone(VOID);
  55. extern "C" VOID PASCAL DisableHalftone(VOID);
  56. //
  57. // Hydra prototypes
  58. //
  59. extern "C" BOOL MultiUserGreCleanupInit();
  60. extern "C" BOOL GreEngLoadModuleTrackInit();
  61. //
  62. // Functions are located in INIT segment
  63. //
  64. #pragma alloc_text(INIT, InitializeGre)
  65. #pragma alloc_text(INIT, FontDriverQueryRoutine)
  66. #ifdef LANGPACK
  67. #pragma alloc_text(INIT, LpkShapeQueryRoutine)
  68. #endif
  69. #pragma alloc_text(INIT, bLoadProcessHandleQuota)
  70. #pragma alloc_text(INIT, bRegisterFontServer)
  71. /**************************************************************************\
  72. *
  73. \**************************************************************************/
  74. #if defined(i386) && !defined(_GDIPLUS_)
  75. extern "C" PVOID GDIpLockPrefixTable;
  76. extern "C" PVOID __safe_se_handler_table[]; /* base of safe handler entry table */
  77. extern "C" BYTE __safe_se_handler_count; /* absolute symbol whose address is
  78. the count of table entries */
  79. //
  80. // Specify address of kernel32 lock prefixes
  81. //
  82. extern "C" IMAGE_LOAD_CONFIG_DIRECTORY _load_config_used = {
  83. sizeof(_load_config_used), // Reserved
  84. 0, // Reserved
  85. 0, // Reserved
  86. 0, // Reserved
  87. 0, // GlobalFlagsClear
  88. 0, // GlobalFlagsSet
  89. 0, // CriticalSectionTimeout (milliseconds)
  90. 0, // DeCommitFreeBlockThreshold
  91. 0, // DeCommitTotalFreeThreshold
  92. (ULONG) &GDIpLockPrefixTable, // LockPrefixTable
  93. 0, 0, 0, 0, 0, 0, 0, // Reserved
  94. 0, // & security_cookie
  95. (ULONG)__safe_se_handler_table,
  96. (ULONG)&__safe_se_handler_count
  97. };
  98. #endif
  99. LONG gProcessHandleQuota;
  100. #if defined (_X86_)
  101. BOOL gbMMXProcessor = FALSE;
  102. #endif
  103. extern "C" VOID vConvertCodePageToCharSet(WORD src, DWORD *pfsRet, BYTE *pjRet);
  104. VOID vGetJpn98FixPitch();
  105. /******************************Public*Routine******************************\
  106. * bEnableFontDriver
  107. *
  108. * Enables an internal, statically-linked font driver.
  109. *
  110. \**************************************************************************/
  111. BOOL bEnableFontDriver(PFN pfnFdEnable, ULONG fl)
  112. {
  113. //
  114. // Load driver.
  115. //
  116. PLDEV pldev;
  117. pldev = ldevLoadInternal(pfnFdEnable, LDEV_FONT);
  118. //
  119. // Validate the new LDEV
  120. //
  121. if (pldev)
  122. {
  123. //
  124. // Create the PDEV for this (the PDEV won't have anything in it
  125. // except the dispatch table.
  126. //
  127. PDEVOBJ po(pldev,
  128. NULL, // PDEVMODEW pdriv,
  129. NULL, // PWSZ pwszLogAddr,
  130. NULL, // PWSZ pwszDataFile,
  131. NULL, // PWSZ pwszDeviceName,
  132. NULL, // HANDLE hSpool,
  133. NULL // PREMOTETYPEONENODE pRemoteTypeOne,
  134. );
  135. if (po.bValid())
  136. {
  137. //
  138. // Was it the TrueType driver? We need to keep a global handle to
  139. // it to support the Win 3.1 TrueType-specific calls.
  140. //
  141. if (fl & FNT_TT_DRV )
  142. {
  143. gppdevTrueType = (PPDEV) po.hdev();
  144. }
  145. if (fl & FNT_OT_DRV)
  146. {
  147. gppdevATMFD = (PPDEV) po.hdev();
  148. gufiLocalType1Rasterizer.CheckSum = TYPE1_RASTERIZER;
  149. gufiLocalType1Rasterizer.Index = 0x1;
  150. }
  151. FntCacheHDEV((PPDEV) po.hdev(), fl);
  152. po.ppdev->fl |= PDEV_FONTDRIVER;
  153. return(TRUE);
  154. }
  155. }
  156. WARNING("bLoadFontDriver failed\n");
  157. return(FALSE);
  158. }
  159. /******************************Public*Routine******************************\
  160. * bDoubleDpi
  161. *
  162. * Read the registry to determine if we should implement our double-the-DPI
  163. * hack. This functionality was intended as a simple mechanism for the
  164. * release of Windows 2000 for applications developers to test their
  165. * applications for conformance with upcoming high-DPI (200 DPI) displays.
  166. * The problem is that currently only 75 to 100 DPI displays are available,
  167. * but we know the high DPI displays are coming soon.
  168. *
  169. * So we implement this little hack that doubles the effective resolution
  170. * of the monitor, and down-samples to the display. So if your monitor does
  171. * 1024x768, we make the system think it's really 2048x1536.
  172. *
  173. * Hopefully, this hacky functionality can be removed for the release after
  174. * Windows 2000, as it's fairly unusable for anything other than simple
  175. * test purposes.
  176. *
  177. \**************************************************************************/
  178. BOOL bDoubleDpi(BOOL fConsole)
  179. {
  180. HANDLE hkRegistry;
  181. OBJECT_ATTRIBUTES ObjectAttributes;
  182. UNICODE_STRING UnicodeString;
  183. NTSTATUS status;
  184. DWORD Length;
  185. PKEY_VALUE_FULL_INFORMATION Information;
  186. DWORD dwDoubleDpi;
  187. dwDoubleDpi = 0;
  188. ///For this to success, it must be console session(session 0)
  189. ///Connected locally to physical console.
  190. if (fConsole && (gProtocolType == PROTOCOL_CONSOLE))
  191. {
  192. RtlInitUnicodeString(&UnicodeString,
  193. L"\\Registry\\Machine\\System\\CurrentControlSet\\"
  194. L"Control\\GraphicsDrivers");
  195. InitializeObjectAttributes(&ObjectAttributes,
  196. &UnicodeString,
  197. OBJ_CASE_INSENSITIVE,
  198. NULL,
  199. NULL);
  200. status = ZwOpenKey(&hkRegistry, GENERIC_READ, &ObjectAttributes);
  201. if (NT_SUCCESS(status))
  202. {
  203. RtlInitUnicodeString(&UnicodeString, L"DoubleDpi");
  204. Length = sizeof(KEY_VALUE_FULL_INFORMATION) + sizeof(L"DoubleDpi") +
  205. sizeof(DWORD);
  206. Information = (PKEY_VALUE_FULL_INFORMATION) PALLOCMEM(Length, ' ddG');
  207. if (Information)
  208. {
  209. status = ZwQueryValueKey(hkRegistry,
  210. &UnicodeString,
  211. KeyValueFullInformation,
  212. Information,
  213. Length,
  214. &Length);
  215. if (NT_SUCCESS(status))
  216. {
  217. dwDoubleDpi = *(LPDWORD) ((((PUCHAR)Information) +
  218. Information->DataOffset));
  219. }
  220. VFREEMEM(Information);
  221. }
  222. ZwCloseKey(hkRegistry);
  223. }
  224. }
  225. return(dwDoubleDpi == 1);
  226. }
  227. void vCheckTimeZoneBias()
  228. {
  229. HANDLE hkRegistry;
  230. OBJECT_ATTRIBUTES ObjectAttributes;
  231. UNICODE_STRING UnicodeString;
  232. NTSTATUS status;
  233. DWORD Length;
  234. PKEY_VALUE_FULL_INFORMATION Information;
  235. RtlInitUnicodeString(&UnicodeString,
  236. L"\\Registry\\Machine\\System\\CurrentControlSet\\"
  237. L"Control\\TimeZoneInformation");
  238. InitializeObjectAttributes(&ObjectAttributes,
  239. &UnicodeString,
  240. OBJ_CASE_INSENSITIVE,
  241. NULL,
  242. NULL);
  243. status = ZwOpenKey(&hkRegistry, GENERIC_READ, &ObjectAttributes);
  244. if (NT_SUCCESS(status))
  245. {
  246. RtlInitUnicodeString(&UnicodeString, L"ActiveTimeBias");
  247. Length = sizeof(KEY_VALUE_FULL_INFORMATION) + sizeof(L"ActiveTimeBias") +
  248. sizeof(DWORD);
  249. Information = (PKEY_VALUE_FULL_INFORMATION) PALLOCMEM(Length, 'pmtG');
  250. if (Information)
  251. {
  252. status = ZwQueryValueKey(hkRegistry,
  253. &UnicodeString,
  254. KeyValueFullInformation,
  255. Information,
  256. Length,
  257. &Length);
  258. if (!NT_SUCCESS(status))
  259. {
  260. gbGUISetup = TRUE;
  261. }
  262. VFREEMEM(Information);
  263. }
  264. ZwCloseKey(hkRegistry);
  265. }
  266. else
  267. {
  268. gbGUISetup = TRUE;
  269. }
  270. }
  271. /******************************Public*Routine******************************\
  272. * InitializeGreCSRSS
  273. *
  274. * Initialize the client-server subsystem portion of GDI.
  275. *
  276. \**************************************************************************/
  277. extern "C" BOOL InitializeGreCSRSS()
  278. {
  279. // Init DirectX graphics driver
  280. if (!NT_SUCCESS(DxDdStartupDxGraphics(0,NULL,0,NULL,NULL,gpepCSRSS)))
  281. {
  282. WARNING("GRE: could not enable DirectDraw\n");
  283. return(FALSE);
  284. }
  285. RTL_QUERY_REGISTRY_TABLE QueryTable[2];
  286. USHORT AnsiCodePage, OemCodePage;
  287. // Init the font drivers
  288. gppdevTrueType = NULL;
  289. gppdevATMFD = NULL;
  290. gcTrueTypeFonts = 0;
  291. gulFontInformation = 0;
  292. gusLanguageID = GetLanguageID();
  293. RtlGetDefaultCodePage(&AnsiCodePage,&OemCodePage);
  294. vConvertCodePageToCharSet(
  295. AnsiCodePage,
  296. &gfsCurSignature,
  297. &gjCurCharset);
  298. gbDBCSCodePage = (IS_ANY_DBCS_CODEPAGE(AnsiCodePage)) ? TRUE : FALSE;
  299. InitFNTCache();
  300. vCheckTimeZoneBias();
  301. //
  302. // NOTE: we are disabling ATM and vector font drivers for _GDIPLUS_ work
  303. //
  304. #ifndef _GDIPLUS_
  305. QueryTable[0].QueryRoutine = FontDriverQueryRoutine;
  306. QueryTable[0].Flags = 0; // RTL_QUERY_REGISTRY_REQUIRED;
  307. QueryTable[0].Name = (PWSTR)NULL;
  308. QueryTable[0].EntryContext = NULL;
  309. QueryTable[0].DefaultType = REG_NONE;
  310. QueryTable[0].DefaultData = NULL;
  311. QueryTable[0].DefaultLength = 0;
  312. QueryTable[1].QueryRoutine = NULL;
  313. QueryTable[1].Flags = 0;
  314. QueryTable[1].Name = NULL;
  315. // Enumerate and initialize all the font drivers.
  316. RtlQueryRegistryValues(RTL_REGISTRY_WINDOWS_NT | RTL_REGISTRY_OPTIONAL,
  317. (PWSTR)L"Font Drivers",
  318. &QueryTable[0],
  319. NULL,
  320. NULL);
  321. if (!bEnableFontDriver((PFN) atmfdEnableDriver, FNT_OT_DRV))
  322. {
  323. WARNING("GDISRV.DLL could not enable ATMFD stub\n");
  324. return(FALSE);
  325. }
  326. // also creates ghsemVTFD semaphore
  327. if (!bEnableFontDriver((PFN) vtfdEnableDriver, FNT_VT_DRV))
  328. {
  329. WARNING("GDISRV.DLL could not enable VTFD\n");
  330. return(FALSE);
  331. }
  332. #endif // !_GDIPLUS_
  333. // We need to get the fix pitch registry first
  334. // This is only JPN platform
  335. vGetJpn98FixPitch();
  336. // also creates ghsemBMFD semaphore
  337. if (!bEnableFontDriver((PFN) BmfdEnableDriver, FNT_BMP_DRV))
  338. {
  339. WARNING("GDISRV failed to enable BMFD\n");
  340. return(FALSE);
  341. }
  342. if (!bEnableFontDriver((PFN) ttfdEnableDriver, FNT_TT_DRV))
  343. {
  344. WARNING("GDISRV.DLL could not enable TTFD\n");
  345. return(FALSE);
  346. }
  347. //
  348. // Init global public PFT
  349. //
  350. if (!bInitFontTables())
  351. {
  352. WARNING("Could not start the global font tables\n");
  353. return(FALSE);
  354. }
  355. //
  356. // Initialize LFONT
  357. //
  358. TRACE_FONT(("GRE: Initializing Stock Fonts\n"));
  359. if (!bInitStockFonts())
  360. {
  361. WARNING("Stock font initialization failed\n");
  362. return(FALSE);
  363. }
  364. TRACE_FONT(("GRE: Initializing Font Substitution\n"));
  365. // Init font substitution table
  366. vInitFontSubTable();
  367. // Load default face names for the mapper from the registry
  368. vInitMapper();
  369. if (!bInitializeEUDC())
  370. {
  371. WARNING("EUDC initialization failed\n");
  372. return(FALSE);
  373. }
  374. return(TRUE);
  375. }
  376. /******************************Public*Routine******************************\
  377. * InitializeGre
  378. *
  379. * Initialize the Graphics Engine. This call is made once by USER.
  380. *
  381. * History:
  382. * Thu 29-Oct-1992 -by- Patrick Haluptzok [patrickh]
  383. * Remove wrappers, unnecesary semaphore use, bogus variables, cleanup.
  384. *
  385. * 10-Aug-1990 -by- Donald Sidoroff [donalds]
  386. * Wrote it.
  387. \**************************************************************************/
  388. LONG CountInit = 1;
  389. extern "C" BOOL gbRemoteSession; // as in ntuser\kernel\globals.c
  390. extern "C" BOOLEAN InitializeGre(
  391. VOID)
  392. {
  393. #ifdef LANGPACK
  394. RTL_QUERY_REGISTRY_TABLE QueryTable[2];
  395. #endif
  396. G_fConsole = (BOOL)!gbRemoteSession;
  397. G_fDoubleDpi = bDoubleDpi(G_fConsole);
  398. //
  399. // We only want to initialize once. We can detect transition to 0.
  400. //
  401. if (InterlockedDecrement(&CountInit) != 0)
  402. {
  403. return(TRUE);
  404. }
  405. #if defined(_GDIPLUS_)
  406. gIsTerminalServer = FALSE;
  407. #else
  408. gIsTerminalServer = !!(SharedUserData->SuiteMask & (1 << TerminalServer));
  409. #endif
  410. if (!MultiUserGreCleanupInit())
  411. {
  412. WARNING("InitializeGre: failed to initialize cleanup support\n");
  413. return(FALSE);
  414. }
  415. //
  416. // Initialize the GRE DriverVerifier support (see verifier.cxx).
  417. //
  418. VerifierInitialization();
  419. //
  420. // Note that GreEngLoadModuleTrackInit must be called AFTER gIsTerminalServer is set
  421. // (though it's called regardless of its value), so that the memory allocations will
  422. // be placed on the hydra tracking list if necessary.
  423. if (!GreEngLoadModuleTrackInit())
  424. {
  425. WARNING("InitializeGre: failed to initialize EngLoadModule tracking\n");
  426. return(FALSE);
  427. }
  428. #if TRACE_SURFACE_ALLOCS
  429. //
  430. // Initialize SURFACE tracing if requested in registry
  431. //
  432. TRACED_SURFACE::vInit();
  433. #endif
  434. //
  435. // load registry process quota information
  436. //
  437. bLoadProcessHandleQuota();
  438. //
  439. // Initialize lots of random stuff including the handle manager.
  440. //
  441. if (!HmgCreate())
  442. {
  443. WARNING("HMGR failed to initialize\n");
  444. return(FALSE);
  445. }
  446. //
  447. // Initialize REGION time stamp
  448. //
  449. REGION::ulUniqueREGION = 1;
  450. #if DBG_CORE
  451. if ((ghsemDEBUG = GreCreateSemaphore())==NULL)
  452. {
  453. WARNING("win32k: unable to initialize ghsemDEBUG\n");
  454. return(FALSE);
  455. }
  456. #endif
  457. #if defined(USE_NINEGRID_STATIC)
  458. if ((gNineGridSem = GreCreateSemaphore())==NULL)
  459. {
  460. WARNING("Win32k: unable to initialize gNineGridSem\n");
  461. return(FALSE);
  462. }
  463. #endif
  464. //
  465. // Create the LDEV\PDEV semaphore.
  466. //
  467. if ((ghsemDriverMgmt = GreCreateSemaphore()) == NULL)
  468. {
  469. WARNING("win32k: unable to create driver mgmt semaphore\n");
  470. return(FALSE);
  471. }
  472. //
  473. // Init the font drivers
  474. //
  475. if (!bInitPathAlloc())
  476. {
  477. WARNING("Pathalloc Initialization failed\n");
  478. return(FALSE);
  479. }
  480. // Create the RFONT list semaphore.
  481. ghsemRFONTList = GreCreateSemaphore();
  482. if (ghsemRFONTList == NULL)
  483. {
  484. WARNING("win32k: unable to create ghsemRFONTList\n");
  485. return FALSE;
  486. }
  487. ghsemCLISERV = GreCreateSemaphore();
  488. if (ghsemCLISERV == NULL)
  489. {
  490. WARNING("win32k: unabel to create ghsemCLISERV\n");
  491. return( FALSE );
  492. }
  493. if ((ghsemAtmfdInit = GreCreateSemaphore()) == NULL)
  494. {
  495. WARNING("win32k: unable to create driver mgmt semaphore\n");
  496. return(FALSE);
  497. }
  498. // Create the WNDOBJ semaphore.
  499. ghsemWndobj = GreCreateSemaphore();
  500. if (ghsemWndobj == NULL)
  501. {
  502. WARNING("win32k: unable to create ghsemWndobj\n");
  503. return FALSE;
  504. }
  505. // Create the RFONT list semaphore.
  506. ghsemGdiSpool = GreCreateSemaphore();
  507. if(ghsemGdiSpool == NULL)
  508. {
  509. WARNING("win32k: unable to create ghsemGdiSpool\n");
  510. return FALSE;
  511. }
  512. // Create the mode change semaphore.
  513. if ((ghsemShareDevLock = GreCreateSemaphore()) == NULL)
  514. {
  515. WARNING("win32k: unable to create mode change semaphore\n");
  516. return(FALSE);
  517. }
  518. // Create the association list mutex.
  519. if ((gAssociationListMutex = GreCreateFastMutex()) == NULL)
  520. {
  521. WARNING("win32k: unable to create association list mutex\n");
  522. return(FALSE);
  523. }
  524. // Create a null region as the default region
  525. hrgnDefault = GreCreateRectRgn(0, 0, 0, 0);
  526. if (hrgnDefault == (HRGN) 0)
  527. {
  528. WARNING("hrgnDefault failed to initialize\n");
  529. return(FALSE);
  530. }
  531. {
  532. RGNOBJAPI ro(hrgnDefault,TRUE);
  533. if(!ro.bValid()) {
  534. WARNING("invalid hrgnDefault\n");
  535. return FALSE;
  536. }
  537. prgnDefault = ro.prgnGet();
  538. }
  539. // Create a monochrome 1x1 bitmap as the default bitmap
  540. if (!bInitPALOBJ())
  541. {
  542. WARNING("bInitPALOBJ failed !\n");
  543. return(FALSE);
  544. }
  545. vInitXLATE();
  546. if (!bInitBMOBJ())
  547. {
  548. WARNING("bInitBMOBJ failed !\n");
  549. return(FALSE);
  550. }
  551. // initialize the script names
  552. if(!InitializeScripts())
  553. {
  554. WARNING("Could not initialize the script names\n");
  555. return(FALSE);
  556. }
  557. //
  558. // Start up the brush component
  559. //
  560. if (!bInitBRUSHOBJ())
  561. {
  562. WARNING("Could not init the brushes\n");
  563. return(FALSE);
  564. }
  565. if (!bInitICM())
  566. {
  567. WARNING("Could not init ICM\n");
  568. return(FALSE);
  569. }
  570. //
  571. // Enable statically linked halftone library
  572. //
  573. if (!EnableHalftone())
  574. {
  575. WARNING("GRE: could not enable halftone\n");
  576. return(FALSE);
  577. }
  578. //
  579. // determine if processor supports MMX
  580. //
  581. #if defined (_X86_)
  582. gbMMXProcessor = bIsMMXProcessor();
  583. #endif
  584. TRACE_INIT(("GRE: Completed Initialization\n"));
  585. #ifdef _GDIPLUS_
  586. gpepCSRSS = PsGetCurrentProcess();
  587. InitializeGreCSRSS();
  588. #endif
  589. #ifdef LANGPACK
  590. QueryTable[0].QueryRoutine = LpkShapeQueryRoutine;
  591. QueryTable[0].Flags = 0;
  592. QueryTable[0].Name = (PWSTR)NULL;
  593. QueryTable[0].EntryContext = NULL;
  594. QueryTable[0].DefaultType = REG_NONE;
  595. QueryTable[0].DefaultData = NULL;
  596. QueryTable[0].DefaultLength = 0;
  597. QueryTable[1].QueryRoutine = NULL;
  598. QueryTable[1].Flags = 0;
  599. QueryTable[1].Name = NULL;
  600. gpGdiSharedMemory->dwLpkShapingDLLs = 0;
  601. RtlQueryRegistryValues(RTL_REGISTRY_WINDOWS_NT | RTL_REGISTRY_OPTIONAL,
  602. (PWSTR)L"LanguagePack",
  603. &QueryTable[0],
  604. NULL,
  605. NULL);
  606. #endif
  607. gpGdiSharedMemory->timeStamp = 1;
  608. return(TRUE);
  609. }
  610. extern "C" BOOL TellGdiToGetReady()
  611. {
  612. ASSERTGDI(gpepCSRSS, "gpepCSRSS\n");
  613. return InitializeGreCSRSS();
  614. }
  615. #ifdef LANGPACK
  616. extern "C"
  617. NTSTATUS
  618. LpkShapeQueryRoutine
  619. (
  620. IN PWSTR ValueName,
  621. IN ULONG ValueType,
  622. IN PVOID ValueData,
  623. IN ULONG ValueLength,
  624. IN PVOID Context,
  625. IN PVOID EntryContext
  626. )
  627. {
  628. if( ValueType == REG_DWORD ) {
  629. gpGdiSharedMemory->dwLpkShapingDLLs |= (1<<(*((DWORD*)ValueData)));
  630. }
  631. return( STATUS_SUCCESS );
  632. }
  633. #endif
  634. extern "C"
  635. NTSTATUS
  636. FontDriverQueryRoutine
  637. (
  638. IN PWSTR ValueName,
  639. IN ULONG ValueType,
  640. IN PVOID ValueData,
  641. IN ULONG ValueLength,
  642. IN PVOID Context,
  643. IN PVOID EntryContext
  644. )
  645. {
  646. PLDEV pldev;
  647. WCHAR FontDriverPath[MAX_PATH+1];
  648. wcscpy(FontDriverPath, L"\\SystemRoot\\System32\\");
  649. // guard against some malicious person putting a huge value in here to hose us
  650. if((ValueLength / sizeof(WCHAR) <
  651. MAX_PATH - (sizeof(L"\\SystemRoot\\System32\\") / sizeof(WCHAR))) &&
  652. (ValueType == REG_SZ))
  653. {
  654. wcscat(FontDriverPath, (PWSTR) ValueData);
  655. if (_wcsicmp(L"\\SystemRoot\\System32\\atmdrvr.dll", FontDriverPath) == 0 ||
  656. _wcsicmp(L"\\SystemRoot\\System32\\atmfd.dll", FontDriverPath) == 0)
  657. {
  658. //skip old atm font driver (4.0) or (5.0) because it is loaded through stub
  659. //WARNING("FontDriverQueryRoutine: system has a old version of ATM driver\n");
  660. }
  661. else
  662. {
  663. pldev = ldevLoadDriver(FontDriverPath, LDEV_FONT);
  664. if (pldev)
  665. {
  666. // Create the PDEV for this (the PDEV won't have anything in it
  667. // except the dispatch table.
  668. PDEVOBJ po(pldev,
  669. NULL,
  670. NULL,
  671. NULL,
  672. NULL,
  673. NULL,
  674. NULL);
  675. if (po.bValid())
  676. {
  677. po.ppdev->fl |= PDEV_FONTDRIVER;
  678. FntCacheHDEV((PPDEV) po.hdev(), FNT_DUMMY_DRV);
  679. return(TRUE);
  680. }
  681. else
  682. {
  683. WARNING("win32k.sys could not initialize installable driver\n");
  684. }
  685. }
  686. else
  687. {
  688. WARNING("win32k.sys could not initialize installable driver\n");
  689. }
  690. }
  691. }
  692. return( STATUS_SUCCESS );
  693. }
  694. /******************************Public*Routine******************************\
  695. * Read process handle quota
  696. *
  697. * Arguments:
  698. *
  699. * None
  700. *
  701. * Return Value:
  702. *
  703. * Status
  704. *
  705. * History:
  706. *
  707. * 3-May-1996 -by- Mark Enstrom [marke]
  708. *
  709. \**************************************************************************/
  710. BOOL
  711. bLoadProcessHandleQuota()
  712. {
  713. OBJECT_ATTRIBUTES ObjectAttributes;
  714. UNICODE_STRING UnicodeString;
  715. NTSTATUS NtStatus;
  716. HANDLE hKey;
  717. BOOL bRet = FALSE;
  718. RtlInitUnicodeString(&UnicodeString,
  719. L"\\Registry\\Machine\\Software\\Microsoft\\Windows NT\\CurrentVersion\\Windows");
  720. //
  721. // Open a registry key
  722. //
  723. InitializeObjectAttributes(&ObjectAttributes,
  724. &UnicodeString,
  725. OBJ_CASE_INSENSITIVE,
  726. NULL,
  727. NULL);
  728. NtStatus = ZwOpenKey(&hKey,
  729. KEY_ALL_ACCESS,
  730. &ObjectAttributes);
  731. if (NT_SUCCESS(NtStatus))
  732. {
  733. UNICODE_STRING UnicodeValue;
  734. ULONG ReturnedLength;
  735. UCHAR DataArray[sizeof(KEY_VALUE_PARTIAL_INFORMATION) + sizeof(DWORD)];
  736. PKEY_VALUE_PARTIAL_INFORMATION pKeyInfo = (PKEY_VALUE_PARTIAL_INFORMATION)DataArray;
  737. RtlInitUnicodeString(&UnicodeValue,
  738. L"GDIProcessHandleQuota");
  739. NtStatus = ZwQueryValueKey(hKey,
  740. &UnicodeValue,
  741. KeyValuePartialInformation,
  742. pKeyInfo,
  743. sizeof(KEY_VALUE_PARTIAL_INFORMATION) + sizeof(DWORD),
  744. &ReturnedLength);
  745. if (NT_SUCCESS(NtStatus))
  746. {
  747. gProcessHandleQuota = *(PLONG)(&pKeyInfo->Data[0]);
  748. } else {
  749. gProcessHandleQuota = DEFAULT_HANDLE_QUOTA;
  750. }
  751. bRet = TRUE;
  752. ZwCloseKey(hKey);
  753. }
  754. return(bRet);
  755. }