https://git.reactos.org/?p=reactos.git;a=commitdiff;h=114bc2b96e48e991e5cff…
commit 114bc2b96e48e991e5cff01bee9c12f2f31f2dd5
Author: Oleg Dubinskiy <oleg.dubinskij30(a)gmail.com>
AuthorDate: Sat Jun 18 20:35:17 2022 +0200
Commit: Hermès Bélusca-Maïto <hermes.belusca-maito(a)reactos.org>
CommitDate: Sun Jun 11 13:44:56 2023 +0200
[NTGDI][NTUSER] Load DirectX graphics driver at system startup (#4551)
CORE-18221
Load the DirectX graphics kernel driver (dxg.sys) by win32k at WINSRV
initialization time, in NtUserInitialize(). Keep it always loaded in
memory, as on Windows, instead of loading it only by DirectX dlls.
This fixes the problem of acessing this driver: we need only to call
DxDdEnableDirectDraw() and do other stuff when DirectDraw/Direct3D is
required by anything. In other cases, it is called from win32k PDEV
functions when changing display mode (as in Windows). Since it's used
by other things too, it needs to be always loaded.
Otherwise, if it's not loaded, its APIs are not accessible when needed,
and execution fails.
For example, it fixes display mode change problem in VMWare, when a
new mode fails to be applied. Indeed, when it manages DirectDraw stuff,
it calls DXG routines, and therefore fails if dxg.sys isn't loaded
in memory at this moment.
- Implement InitializeGreCSRSS() initialization routine, that initializes
supplemental NTGDI/GRE data once CSRSS and WINSRV are loaded:
* Call DxDdStartupDxGraphics() inside it, which loads dxg.sys.
* Additionally, move fonts and language ID initialization there, from
win32k!DriverEntry. Confirmed by analysis on Windows.
- Call InitializeGreCSRSS() in NtUserInitialize() main initialization routine
(called by WINSRV initialization).
Moved to NTGDI from previously NTUSER place:
Co-authored-by: Hermès Bélusca-Maïto <hermes.belusca-maito(a)reactos.org>
---
win32ss/gdi/ntgdi/init.c | 28 +++++++++++++++++++++++++---
win32ss/gdi/ntgdi/misc.h | 2 ++
win32ss/user/ntuser/main.c | 10 ----------
win32ss/user/ntuser/ntuser.c | 9 +++------
4 files changed, 30 insertions(+), 19 deletions(-)
diff --git a/win32ss/gdi/ntgdi/init.c b/win32ss/gdi/ntgdi/init.c
index 35bab0f6029..44afa1219df 100644
--- a/win32ss/gdi/ntgdi/init.c
+++ b/win32ss/gdi/ntgdi/init.c
@@ -7,10 +7,9 @@
*/
#include <win32k.h>
+DBG_DEFAULT_CHANNEL(UserMisc);
-#define NDEBUG
-#include <debug.h>
-#include <kdros.h>
+USHORT gusLanguageID;
BOOL NTAPI GDI_CleanupForProcess(struct _EPROCESS *Process);
@@ -77,6 +76,29 @@ GdiThreadDestroy(PETHREAD Thread)
}
+BOOL
+InitializeGreCSRSS(VOID)
+{
+ /* Initialize DirectX graphics driver */
+ if (DxDdStartupDxGraphics(0, NULL, 0, NULL, NULL, gpepCSRSS) != STATUS_SUCCESS)
+ {
+ ERR("Unable to initialize DirectX graphics\n");
+ return FALSE;
+ }
+
+ /* Get global language ID */
+ gusLanguageID = UserGetLanguageID();
+
+ /* Initialize FreeType library */
+ if (!InitFontSupport())
+ {
+ ERR("Unable to initialize font support\n");
+ return FALSE;
+ }
+
+ return TRUE;
+}
+
/*
* @implemented
*/
diff --git a/win32ss/gdi/ntgdi/misc.h b/win32ss/gdi/ntgdi/misc.h
index 6757acce4c0..06fa17b8255 100644
--- a/win32ss/gdi/ntgdi/misc.h
+++ b/win32ss/gdi/ntgdi/misc.h
@@ -23,7 +23,9 @@ extern BOOL APIENTRY IntEngLeave(PINTENG_ENTER_LEAVE EnterLeave);
extern HGDIOBJ StockObjects[];
extern USHORT gusLanguageID;
+BOOL InitializeGreCSRSS(VOID);
USHORT FASTCALL UserGetLanguageID(VOID);
+
PVOID APIENTRY HackSecureVirtualMemory(IN PVOID,IN SIZE_T,IN ULONG,OUT PVOID *);
VOID APIENTRY HackUnsecureVirtualMemory(IN PVOID);
diff --git a/win32ss/user/ntuser/main.c b/win32ss/user/ntuser/main.c
index bdb36d45236..235e8aee696 100644
--- a/win32ss/user/ntuser/main.c
+++ b/win32ss/user/ntuser/main.c
@@ -26,7 +26,6 @@ NTSTATUS GdiThreadDestroy(PETHREAD Thread);
PSERVERINFO gpsi = NULL; // Global User Server Information.
-USHORT gusLanguageID;
PPROCESSINFO ppiScrnSaver;
PPROCESSINFO gppiList = NULL;
@@ -1051,15 +1050,6 @@ DriverEntry(
NT_ROF(InitTimerImpl());
NT_ROF(InitDCEImpl());
- gusLanguageID = UserGetLanguageID();
-
- /* Initialize FreeType library */
- if (!InitFontSupport())
- {
- DPRINT1("Unable to initialize font support\n");
- return Status;
- }
-
return STATUS_SUCCESS;
}
diff --git a/win32ss/user/ntuser/ntuser.c b/win32ss/user/ntuser/ntuser.c
index fd2f5f97e93..6643495606d 100644
--- a/win32ss/user/ntuser/ntuser.c
+++ b/win32ss/user/ntuser/ntuser.c
@@ -198,12 +198,9 @@ NtUserInitialize(
// Initialize Power Request List (use hPowerRequestEvent).
// Initialize Media Change (use hMediaRequestEvent).
-// InitializeGreCSRSS();
-// {
-// Startup DxGraphics.
-// calls ** UserGetLanguageID() and sets it **.
-// Enables Fonts drivers, Initialize Font table & Stock Fonts.
-// }
+ /* Initialize various GDI stuff (DirectX, fonts, language ID etc.) */
+ if (!InitializeGreCSRSS())
+ return STATUS_UNSUCCESSFUL;
/* Initialize USER */
Status = UserInitialize();