https://git.reactos.org/?p=reactos.git;a=commitdiff;h=75f4be53dfb168981ff25…
commit 75f4be53dfb168981ff25a090aac8396d8b4fa23
Author: Hervé Poussineau <hpoussin(a)reactos.org>
AuthorDate: Sun Jan 9 11:02:27 2022 +0100
Commit: hpoussin <32227662+hpoussin(a)users.noreply.github.com>
CommitDate: Fri Apr 15 23:09:16 2022 +0200
[WIN32SS] Preparation to load internal drivers (ie entry point in win32k)
- Change LDEVOBJ_bEnableDriver to directly take the entry point
(pGdiDriverInfo not required anymore)
- Add LDEVOBJ_pLoadInternal to load and start an internal driver
---
win32ss/gdi/eng/ldevobj.c | 53 +++++++++++++++++++++++++++++++++++++++++------
win32ss/gdi/eng/ldevobj.h | 5 +++++
2 files changed, 52 insertions(+), 6 deletions(-)
diff --git a/win32ss/gdi/eng/ldevobj.c b/win32ss/gdi/eng/ldevobj.c
index db46a0dfbb6..6321c8ad88d 100644
--- a/win32ss/gdi/eng/ldevobj.c
+++ b/win32ss/gdi/eng/ldevobj.c
@@ -194,18 +194,16 @@ LDEVOBJ_vUnloadImage(
static
BOOL
LDEVOBJ_bEnableDriver(
- _Inout_ PLDEVOBJ pldev)
+ _Inout_ PLDEVOBJ pldev,
+ _In_ PFN_DrvEnableDriver pfnEnableDriver)
{
- PFN_DrvEnableDriver pfnEnableDriver;
DRVENABLEDATA ded;
ULONG i;
- /* Make sure we have a driver info */
- ASSERT(pldev && pldev->pGdiDriverInfo != NULL);
+ ASSERT(pldev);
/* Call the drivers DrvEnableDriver function */
RtlZeroMemory(&ded, sizeof(ded));
- pfnEnableDriver = pldev->pGdiDriverInfo->EntryPoint;
if (!pfnEnableDriver(GDI_ENGINE_VERSION, sizeof(ded), &ded))
{
ERR("DrvEnableDriver failed\n");
@@ -325,6 +323,49 @@ LDEVOBJ_pvFindImageProcAddress(
return pvProcAdress;
}
+PLDEVOBJ
+LDEVOBJ_pLoadInternal(
+ _In_ PFN_DrvEnableDriver pfnEnableDriver,
+ _In_ ULONG ldevtype)
+{
+ PLDEVOBJ pldev;
+
+ TRACE("LDEVOBJ_pLoadInternal(%lu)\n", ldevtype);
+
+ /* Lock loader */
+ EngAcquireSemaphore(ghsemLDEVList);
+
+ /* Allocate a new LDEVOBJ */
+ pldev = LDEVOBJ_AllocLDEV(ldevtype);
+ if (!pldev)
+ {
+ ERR("Could not allocate LDEV\n");
+ goto leave;
+ }
+
+ /* Load the driver */
+ if (!LDEVOBJ_bEnableDriver(pldev, pfnEnableDriver))
+ {
+ ERR("LDEVOBJ_bEnableDriver failed\n");
+ LDEVOBJ_vFreeLDEV(pldev);
+ pldev = NULL;
+ goto leave;
+ }
+
+ /* Insert the LDEV into the global list */
+ InsertHeadList(&gleLdevListHead, &pldev->leLink);
+
+ /* Increase ref count */
+ pldev->cRefs++;
+
+leave:
+ /* Unlock loader */
+ EngReleaseSemaphore(ghsemLDEVList);
+
+ TRACE("LDEVOBJ_pLoadInternal returning %p\n", pldev);
+ return pldev;
+}
+
PLDEVOBJ
NTAPI
LDEVOBJ_pLoadDriver(
@@ -423,7 +464,7 @@ LDEVOBJ_pLoadDriver(
if (ldevtype != LDEV_IMAGE)
{
/* Load the driver */
- if (!LDEVOBJ_bEnableDriver(pldev))
+ if (!LDEVOBJ_bEnableDriver(pldev, pldev->pGdiDriverInfo->EntryPoint))
{
ERR("LDEVOBJ_bEnableDriver failed\n");
diff --git a/win32ss/gdi/eng/ldevobj.h b/win32ss/gdi/eng/ldevobj.h
index f1fc624950d..c603847cecc 100644
--- a/win32ss/gdi/eng/ldevobj.h
+++ b/win32ss/gdi/eng/ldevobj.h
@@ -46,6 +46,11 @@ LDEVOBJ_ulGetDriverModes(
_In_ HANDLE hDriver,
_Out_ PDEVMODEW *ppdm);
+PLDEVOBJ
+LDEVOBJ_pLoadInternal(
+ _In_ PFN_DrvEnableDriver pfnEnableDriver,
+ _In_ ULONG ldevtype);
+
PLDEVOBJ
APIENTRY
LDEVOBJ_pLoadDriver(