From: Rémi Bernon rbernon@codeweavers.com
Keeping the 32bit TEB context and private data in sync. --- dlls/opengl32/make_opengl | 4 ++ dlls/opengl32/unix_thunks.c | 76 ++------------------------------ dlls/opengl32/unix_wgl.c | 87 +++++++++++++++++++++++++++++++++++++ 3 files changed, 95 insertions(+), 72 deletions(-)
diff --git a/dlls/opengl32/make_opengl b/dlls/opengl32/make_opengl index 312e7acc964..7803dd21287 100755 --- a/dlls/opengl32/make_opengl +++ b/dlls/opengl32/make_opengl @@ -170,7 +170,11 @@ my %manual_win_thunks = my %manual_wow64_thunks = ( "glPathGlyphIndexRangeNV" => 1, + "wglCreateContext" => 1, + "wglDeleteContext" => 1, "wglGetProcAddress" => 1, + "wglMakeContextCurrentARB" => 1, + "wglMakeCurrent" => 1, );
# diff --git a/dlls/opengl32/unix_thunks.c b/dlls/opengl32/unix_thunks.c index c710d2141ec..5accad6fc0b 100644 --- a/dlls/opengl32/unix_thunks.c +++ b/dlls/opengl32/unix_thunks.c @@ -27222,38 +27222,6 @@ static NTSTATUS wow64_wgl_wglCopyContext( void *args ) return status; }
-static NTSTATUS wow64_wgl_wglCreateContext( void *args ) -{ - struct - { - PTR32 hDc; - PTR32 ret; - } *params32 = args; - struct wglCreateContext_params params = - { - .hDc = ULongToPtr(params32->hDc), - }; - FIXME( "params32 %p, params %p stub!\n", params32, ¶ms ); - return STATUS_NOT_IMPLEMENTED; -} - -static NTSTATUS wow64_wgl_wglDeleteContext( void *args ) -{ - struct - { - PTR32 oldContext; - BOOL ret; - } *params32 = args; - struct wglDeleteContext_params params = - { - .oldContext = ULongToPtr(params32->oldContext), - }; - NTSTATUS status; - status = wgl_wglDeleteContext( ¶ms ); - params32->ret = params.ret; - return status; -} - static NTSTATUS wow64_wgl_wglDescribePixelFormat( void *args ) { struct @@ -27294,25 +27262,6 @@ static NTSTATUS wow64_wgl_wglGetPixelFormat( void *args ) return status; }
-static NTSTATUS wow64_wgl_wglMakeCurrent( void *args ) -{ - struct - { - PTR32 hDc; - PTR32 newContext; - BOOL ret; - } *params32 = args; - struct wglMakeCurrent_params params = - { - .hDc = ULongToPtr(params32->hDc), - .newContext = ULongToPtr(params32->newContext), - }; - NTSTATUS status; - status = wgl_wglMakeCurrent( ¶ms ); - params32->ret = params.ret; - return status; -} - static NTSTATUS wow64_wgl_wglSetPixelFormat( void *args ) { struct @@ -60879,27 +60828,6 @@ static NTSTATUS wow64_ext_wglGetPixelFormatAttribivARB( void *args ) return status; }
-static NTSTATUS wow64_ext_wglMakeContextCurrentARB( void *args ) -{ - struct - { - PTR32 hDrawDC; - PTR32 hReadDC; - PTR32 hglrc; - BOOL ret; - } *params32 = args; - struct wglMakeContextCurrentARB_params params = - { - .hDrawDC = ULongToPtr(params32->hDrawDC), - .hReadDC = ULongToPtr(params32->hReadDC), - .hglrc = ULongToPtr(params32->hglrc), - }; - NTSTATUS status; - status = ext_wglMakeContextCurrentARB( ¶ms ); - params32->ret = params.ret; - return status; -} - static NTSTATUS wow64_ext_wglQueryCurrentRendererIntegerWINE( void *args ) { struct @@ -61073,8 +61001,12 @@ static NTSTATUS wow64_ext_wglSetPixelFormatWINE( void *args ) return status; }
+extern NTSTATUS wow64_wgl_wglCreateContext( void *args ) DECLSPEC_HIDDEN; +extern NTSTATUS wow64_wgl_wglDeleteContext( void *args ) DECLSPEC_HIDDEN; extern NTSTATUS wow64_wgl_wglGetProcAddress( void *args ) DECLSPEC_HIDDEN; +extern NTSTATUS wow64_wgl_wglMakeCurrent( void *args ) DECLSPEC_HIDDEN; extern NTSTATUS wow64_ext_glPathGlyphIndexRangeNV( void *args ) DECLSPEC_HIDDEN; +extern NTSTATUS wow64_ext_wglMakeContextCurrentARB( void *args ) DECLSPEC_HIDDEN;
const unixlib_entry_t __wine_unix_call_wow64_funcs[] = { diff --git a/dlls/opengl32/unix_wgl.c b/dlls/opengl32/unix_wgl.c index 7fd044182d7..7ba2045e384 100644 --- a/dlls/opengl32/unix_wgl.c +++ b/dlls/opengl32/unix_wgl.c @@ -1060,6 +1060,93 @@ typedef ULONG PTR32;
extern NTSTATUS ext_glPathGlyphIndexRangeNV( void *args ) DECLSPEC_HIDDEN;
+static inline void update_teb32_context(void) +{ + TEB *teb = NtCurrentTeb(); + void *teb32; + + if (!teb->WowTebOffset) return; + teb32 = (char *)teb + teb->WowTebOffset; + + ((TEB32 *)teb32)->glCurrentRC = (UINT_PTR)teb->glCurrentRC; + ((TEB32 *)teb32)->glReserved1[0] = (UINT_PTR)teb->glReserved1[0]; + ((TEB32 *)teb32)->glReserved1[1] = (UINT_PTR)teb->glReserved1[1]; +} + +NTSTATUS wow64_wgl_wglCreateContext( void *args ) +{ + struct + { + PTR32 hDc; + PTR32 ret; + } *params32 = args; + struct wglCreateContext_params params = + { + .hDc = ULongToPtr(params32->hDc), + }; + NTSTATUS status; + if ((status = wgl_wglCreateContext( ¶ms ))) return status; + params32->ret = (UINT_PTR)params.ret; + return STATUS_SUCCESS; +} + +NTSTATUS wow64_wgl_wglDeleteContext( void *args ) +{ + struct + { + PTR32 oldContext; + BOOL ret; + } *params32 = args; + struct wglDeleteContext_params params = + { + .oldContext = ULongToPtr(params32->oldContext), + }; + NTSTATUS status; + if (!(status = wgl_wglDeleteContext( ¶ms ))) update_teb32_context(); + params32->ret = params.ret; + return status; +} + +NTSTATUS wow64_wgl_wglMakeCurrent( void *args ) +{ + struct + { + PTR32 hDc; + PTR32 newContext; + BOOL ret; + } *params32 = args; + struct wglMakeCurrent_params params = + { + .hDc = ULongToPtr(params32->hDc), + .newContext = ULongToPtr(params32->newContext), + }; + NTSTATUS status; + if (!(status = wgl_wglMakeCurrent( ¶ms ))) update_teb32_context(); + params32->ret = params.ret; + return status; +} + +NTSTATUS wow64_ext_wglMakeContextCurrentARB( void *args ) +{ + struct + { + PTR32 hDrawDC; + PTR32 hReadDC; + PTR32 hglrc; + BOOL ret; + } *params32 = args; + struct wglMakeContextCurrentARB_params params = + { + .hDrawDC = ULongToPtr(params32->hDrawDC), + .hReadDC = ULongToPtr(params32->hReadDC), + .hglrc = ULongToPtr(params32->hglrc), + }; + NTSTATUS status; + if (!(status = ext_wglMakeContextCurrentARB( ¶ms ))) update_teb32_context(); + params32->ret = params.ret; + return status; +} + NTSTATUS wow64_wgl_wglGetProcAddress( void *args ) { struct