https://git.reactos.org/?p=reactos.git;a=commitdiff;h=b3cdb7e713da0801b6af5…
commit b3cdb7e713da0801b6af5c6ddafcdfc1fb3aac8e
Author: Hervé Poussineau <hpoussin(a)reactos.org>
AuthorDate: Thu Nov 10 22:11:22 2022 +0100
Commit: Hervé Poussineau <hpoussin(a)reactos.org>
CommitDate: Tue Nov 15 23:16:10 2022 +0100
[WIN32SS:ENG] Add EngpLinkGraphicsDevice, to add a device to gpGraphicsDeviceFirst
list
---
win32ss/gdi/eng/device.c | 37 +++++++++++++++++++++++++++++++------
1 file changed, 31 insertions(+), 6 deletions(-)
diff --git a/win32ss/gdi/eng/device.c b/win32ss/gdi/eng/device.c
index 8a0d686d2ea..1e2a46a0a17 100644
--- a/win32ss/gdi/eng/device.c
+++ b/win32ss/gdi/eng/device.c
@@ -98,6 +98,36 @@ EngpHasVgaDriver(
return (_wcsnicmp(awcServiceName, L"VGA", 3) == 0);
}
+/*
+ * Add a device to gpGraphicsDeviceFirst/gpGraphicsDeviceLast list (if not already
present).
+ */
+_Requires_lock_held_(ghsemGraphicsDeviceList)
+static
+VOID
+EngpLinkGraphicsDevice(
+ _In_ PGRAPHICS_DEVICE pToAdd)
+{
+ PGRAPHICS_DEVICE pGraphicsDevice;
+
+ TRACE("EngLinkGraphicsDevice(%p)\n", pToAdd);
+
+ /* Search if device is not already linked */
+ for (pGraphicsDevice = gpGraphicsDeviceFirst;
+ pGraphicsDevice;
+ pGraphicsDevice = pGraphicsDevice->pNextGraphicsDevice)
+ {
+ if (pGraphicsDevice == pToAdd)
+ return;
+ }
+
+ pToAdd->pNextGraphicsDevice = NULL;
+ if (gpGraphicsDeviceLast)
+ gpGraphicsDeviceLast->pNextGraphicsDevice = pToAdd;
+ gpGraphicsDeviceLast = pToAdd;
+ if (!gpGraphicsDeviceFirst)
+ gpGraphicsDeviceFirst = pToAdd;
+}
+
/*
* Remove a device from gpGraphicsDeviceFirst/gpGraphicsDeviceLast list.
*/
@@ -567,12 +597,7 @@ EngpRegisterGraphicsDevice(
EngAcquireSemaphore(ghsemGraphicsDeviceList);
/* Insert the device into the global list */
- pGraphicsDevice->pNextGraphicsDevice = NULL;
- if (gpGraphicsDeviceLast)
- gpGraphicsDeviceLast->pNextGraphicsDevice = pGraphicsDevice;
- gpGraphicsDeviceLast = pGraphicsDevice;
- if (!gpGraphicsDeviceFirst)
- gpGraphicsDeviceFirst = pGraphicsDevice;
+ EngpLinkGraphicsDevice(pGraphicsDevice);
/* Increment the device number */
giDevNum++;