From 50d99bf9745591afc3320fa6ebd65c07e3cb463c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Adam=20S=C5=82abo=C5=84?= Date: Sat, 7 Feb 2026 01:36:47 +0100 Subject: [PATCH] [OPENGL32] Misc refactoring and a bugfix for Nvidia OpenGL ICD (#8656) * [OPENGL32] Use NDK definitions for list functions * [OPENGL32] wglCreateLayerContext: Insert an entry into context list Fixes a crash when wglDeleteContext is called on layer context. --- dll/opengl/opengl32/opengl32.h | 44 +++------------------------------- dll/opengl/opengl32/wgl.c | 6 +++-- 2 files changed, 7 insertions(+), 43 deletions(-) diff --git a/dll/opengl/opengl32/opengl32.h b/dll/opengl/opengl32/opengl32.h index 0395fe00a66..ac5cb88ef83 100644 --- a/dll/opengl/opengl32/opengl32.h +++ b/dll/opengl/opengl32/opengl32.h @@ -21,51 +21,13 @@ #include #endif +#define NTOS_MODE_USER +#include + #include #include "icd.h" -/* *$%$£^§! headers inclusion */ -static __inline -BOOLEAN -RemoveEntryList( - _In_ PLIST_ENTRY Entry) -{ - PLIST_ENTRY OldFlink; - PLIST_ENTRY OldBlink; - - OldFlink = Entry->Flink; - OldBlink = Entry->Blink; - OldFlink->Blink = OldBlink; - OldBlink->Flink = OldFlink; - return (OldFlink == OldBlink); -} - -static __inline -VOID -InsertTailList( - _In_ PLIST_ENTRY ListHead, - _In_ PLIST_ENTRY Entry -) -{ - PLIST_ENTRY OldBlink; - OldBlink = ListHead->Blink; - Entry->Flink = ListHead; - Entry->Blink = OldBlink; - OldBlink->Flink = Entry; - ListHead->Blink = Entry; -} - - -static __inline -VOID -InitializeListHead( - _Inout_ PLIST_ENTRY ListHead -) -{ - ListHead->Flink = ListHead->Blink = ListHead; -} - extern LIST_ENTRY ContextListHead; struct wgl_context diff --git a/dll/opengl/opengl32/wgl.c b/dll/opengl/opengl32/wgl.c index 2beee39c263..b495b354deb 100644 --- a/dll/opengl/opengl32/wgl.c +++ b/dll/opengl/opengl32/wgl.c @@ -437,11 +437,11 @@ HGLRC WINAPI wglCreateContext(HDC hdc) context->icd_data = dc_data->icd_data; context->pixelformat = dc_data->pixelformat; context->thread_id = 0; + context->magic = 'GLRC'; /* Insert into the list */ InsertTailList(&ContextListHead, &context->ListEntry); - context->magic = 'GLRC'; TRACE("Success!\n"); return (HGLRC)context; } @@ -504,9 +504,11 @@ HGLRC WINAPI wglCreateLayerContext(HDC hdc, int iLayerPlane) context->icd_data = dc_data->icd_data; context->pixelformat = dc_data->pixelformat; context->thread_id = 0; - context->magic = 'GLRC'; + /* Insert into the list */ + InsertTailList(&ContextListHead, &context->ListEntry); + release_dc_data(dc_data); return (HGLRC)context; }