From: Jacek Caban jacek@codeweavers.com
--- dlls/opengl32/make_opengl | 29 +++++++++++++++++++---------- dlls/opengl32/unix_private.h | 6 ++++++ dlls/opengl32/unix_thunks.c | 18 +++++++++++++++--- dlls/opengl32/unix_thunks.h | 3 +-- dlls/opengl32/unix_wgl.c | 23 +---------------------- 5 files changed, 42 insertions(+), 37 deletions(-)
diff --git a/dlls/opengl32/make_opengl b/dlls/opengl32/make_opengl index c8b1a865314..e54cd5dd783 100755 --- a/dlls/opengl32/make_opengl +++ b/dlls/opengl32/make_opengl @@ -218,7 +218,6 @@ my %manual_wow64_thunks = "glGetBufferPointervARB" => 1, "glGetNamedBufferPointerv" => 1, "glGetNamedBufferPointervEXT" => 1, - "glGetString" => 1, "glGetStringi" => 1, "glMapBuffer" => 1, "glMapBufferARB" => 1, @@ -370,9 +369,11 @@ sub generate_unix_thunk($$$$) my $need_wrap = $manual_wow64_wrapper || needs_wrapper( $name, $func ); my $need_lock = $func_ret =~ /HGLRC|HPBUFFERARB/; my $teb = $is_wow64 ? "teb" : "params->teb"; + my $ret_stat = "return STATUS_SUCCESS;"; my $input_conv = ""; my $output_conv = ""; my $call_args = ""; + my $ret_expr = ""; my $use_dc = 0; my $ret = "";
@@ -390,6 +391,7 @@ sub generate_unix_thunk($$$$) # special case for functions that take an HDC as first parameter $use_dc = @{$func->[1]} && get_arg_type( ${$func->[1]}[0] ) eq "HDC" && $name !~ /wglMake(Context)?Current/;
+ $ret_expr = "params->ret = " if !is_void_func( $func ); $call_args .= " $teb," if $need_wrap; if ($is_wow64) { @@ -443,11 +445,23 @@ sub generate_unix_thunk($$$$) } if (!is_void_func($func)) { + my $ret_type = get_arg_type( $func->[0] ); my $ptype = get_wow64_arg_type( $func->[0] ); $ret .= " $ptype ret;\n"; + if ($ret_type eq "const GLubyte *" || $ret_type eq "const char *" || $ret_type eq "const GLchar *") + { + $input_conv .= " " . $ret_type . "ret;\n"; + $ret_expr = "ret = "; + $ret_stat = "return return_wow64_string( ret, ¶ms->ret );"; + } + elsif ($ptype eq "PTR32") + { + $ret_expr .= "(UINT_PTR)"; + $need_manual_thunk = 1 if $ret_type =~ /(GLsync|PROC|GLintptr|*)/; + } } $ret .= " } *params = args;\n"; - if (!$need_wrap && ($need_manual_thunk || $func->[0]->textContent() =~ /(GLsync|PROC|GLintptr|*)/)) + if (!$need_wrap && $need_manual_thunk) { $ret .= " FIXME( "params %p stub!\n", params );\n"; $ret .= " return STATUS_NOT_IMPLEMENTED;\n"; @@ -486,12 +500,7 @@ sub generate_unix_thunk($$$$) $ret .= " const struct opengl_funcs *funcs = $teb->glTable;\n"; } $ret .= " pthread_mutex_lock( &wgl_lock );\n" if $need_lock; - $ret .= " "; - if (!is_void_func( $func )) - { - $ret .= "params->ret = "; - $ret .= "(UINT_PTR)" if $is_wow64 && get_wow64_arg_type( $func->[0] ) =~ /PTR32/; - } + $ret .= " $ret_expr"; $call_args =~ s/,$/ /; if ($manual_wow64_wrapper) { @@ -525,7 +534,7 @@ sub generate_unix_thunk($$$$) $ret .= " set_context_attribute( $teb, -1 /* unsupported */, NULL, 0 );\n"; } $ret .= $output_conv; - $ret .= " return STATUS_SUCCESS;\n"; + $ret .= " $ret_stat\n"; $ret .= "}\n\n";
return $ret; @@ -1309,6 +1318,7 @@ foreach (sort keys %ext_functions) }
print OUT "\n#ifdef _WIN64\n"; +print OUT "typedef ULONG PTR32;\n";
foreach (sort keys %wgl_functions) { @@ -1425,7 +1435,6 @@ print OUT "};\n\n"; print OUT "C_ASSERT(ARRAYSIZE(__wine_unix_call_funcs) == funcs_count);\n\n";
print OUT "#ifdef _WIN64\n\n"; -print OUT "typedef ULONG PTR32;\n\n"; print OUT "extern NTSTATUS wow64_thread_attach( void *args );\n"; print OUT "extern NTSTATUS wow64_process_detach( void *args );\n"; print OUT "extern NTSTATUS wow64_get_pixel_formats( void *args );\n\n"; diff --git a/dlls/opengl32/unix_private.h b/dlls/opengl32/unix_private.h index e83b7f35c02..26f21d6843a 100644 --- a/dlls/opengl32/unix_private.h +++ b/dlls/opengl32/unix_private.h @@ -53,6 +53,8 @@ static inline const struct opengl_funcs *get_dc_funcs( HDC hdc ) return funcs; }
+#ifdef _WIN64 + static inline void *copy_wow64_ptr32s( UINT_PTR address, ULONG count ) { ULONG *ptrs = (ULONG *)address; @@ -69,6 +71,10 @@ static inline TEB *get_teb64( ULONG teb32 ) return (TEB *)((char *)teb32_ptr + teb32_ptr->WowTebOffset); }
+extern NTSTATUS return_wow64_string( const void *str, PTR32 *wow64_str ); + +#endif + extern pthread_mutex_t wgl_lock;
extern NTSTATUS process_attach( void *args ); diff --git a/dlls/opengl32/unix_thunks.c b/dlls/opengl32/unix_thunks.c index 78bdf652b1e..0cb7ad4a11a 100644 --- a/dlls/opengl32/unix_thunks.c +++ b/dlls/opengl32/unix_thunks.c @@ -1133,7 +1133,7 @@ static NTSTATUS gl_glGetPolygonStipple( void *args ) return STATUS_SUCCESS; }
-NTSTATUS gl_glGetString( void *args ) +static NTSTATUS gl_glGetString( void *args ) { struct glGetString_params *params = args; params->ret = wrap_glGetString( params->teb, params->name ); @@ -29895,8 +29895,6 @@ C_ASSERT(ARRAYSIZE(__wine_unix_call_funcs) == funcs_count);
#ifdef _WIN64
-typedef ULONG PTR32; - extern NTSTATUS wow64_thread_attach( void *args ); extern NTSTATUS wow64_process_detach( void *args ); extern NTSTATUS wow64_get_pixel_formats( void *args ); @@ -31795,6 +31793,20 @@ static NTSTATUS wow64_gl_glGetPolygonStipple( void *args ) return STATUS_SUCCESS; }
+static NTSTATUS wow64_gl_glGetString( void *args ) +{ + struct + { + PTR32 teb; + GLenum name; + PTR32 ret; + } *params = args; + TEB *teb = get_teb64( params->teb ); + const GLubyte *ret; + ret = wrap_glGetString( teb, params->name ); + return return_wow64_string( ret, ¶ms->ret ); +} + static NTSTATUS wow64_gl_glGetTexEnvfv( void *args ) { struct diff --git a/dlls/opengl32/unix_thunks.h b/dlls/opengl32/unix_thunks.h index 76fcb67e689..0e887057a73 100644 --- a/dlls/opengl32/unix_thunks.h +++ b/dlls/opengl32/unix_thunks.h @@ -31,6 +31,7 @@ extern BOOL wrap_wglReleaseTexImageARB( TEB *teb , HPBUFFERARB hPbuffer, int iBu extern BOOL wrap_wglSetPbufferAttribARB( TEB *teb , HPBUFFERARB hPbuffer, const int *piAttribList );
#ifdef _WIN64 +typedef ULONG PTR32; extern GLenum wow64_glClientWaitSync( TEB *teb , GLsync sync, GLbitfield flags, GLuint64 timeout ); extern void wow64_glDeleteSync( TEB *teb , GLsync sync ); extern GLsync wow64_glFenceSync( TEB *teb , GLenum condition, GLbitfield flags ); @@ -41,8 +42,6 @@ extern void wow64_glWaitSync( TEB *teb , GLsync sync, GLbitfield flags, GLuint64
extern NTSTATUS wgl_wglGetProcAddress( void *args ); extern NTSTATUS wow64_wgl_wglGetProcAddress( void *args ); -extern NTSTATUS gl_glGetString( void *args ); -extern NTSTATUS wow64_gl_glGetString( void *args ); extern NTSTATUS ext_glGetBufferPointerv( void *args ); extern NTSTATUS wow64_ext_glGetBufferPointerv( void *args ); extern NTSTATUS ext_glGetBufferPointervARB( void *args ); diff --git a/dlls/opengl32/unix_wgl.c b/dlls/opengl32/unix_wgl.c index 3d9017ade3c..965fa488145 100644 --- a/dlls/opengl32/unix_wgl.c +++ b/dlls/opengl32/unix_wgl.c @@ -1401,8 +1401,6 @@ NTSTATUS get_pixel_formats( void *args )
#ifdef _WIN64
-typedef ULONG PTR32; - struct wow64_string_entry { const char *str; @@ -1411,7 +1409,7 @@ struct wow64_string_entry static struct wow64_string_entry *wow64_strings; static SIZE_T wow64_strings_count;
-static NTSTATUS return_wow64_string( const void *str, PTR32 *wow64_str ) +NTSTATUS return_wow64_string( const void *str, PTR32 *wow64_str ) { void *tmp; SIZE_T i; @@ -1513,25 +1511,6 @@ NTSTATUS wow64_wgl_wglGetProcAddress( void *args ) return STATUS_SUCCESS; }
-NTSTATUS wow64_gl_glGetString( void *args ) -{ - struct - { - PTR32 teb; - GLenum name; - PTR32 ret; - } *params32 = args; - struct glGetString_params params = - { - .teb = get_teb64(params32->teb), - .name = params32->name, - }; - NTSTATUS status; - - if ((status = gl_glGetString( ¶ms ))) return status; - return return_wow64_string( params.ret, ¶ms32->ret ); -} - NTSTATUS wow64_ext_glGetStringi( void *args ) { struct