From: Piotr Caban piotr@codeweavers.com
Doing it this way avoids passing Unix library pointers throught PE. --- dlls/gdi32/dc.c | 13 ++++++++---- dlls/win32u/dc.c | 9 ++++----- dlls/wineps.drv/init.c | 35 ++++++++++++++++++--------------- dlls/wineps.drv/unixlib.c | 25 +++++++++++++++-------- dlls/wineps.drv/unixlib.h | 14 +++++++------ dlls/wineps.drv/wineps.drv.spec | 2 +- 6 files changed, 58 insertions(+), 40 deletions(-)
diff --git a/dlls/gdi32/dc.c b/dlls/gdi32/dc.c index 91ab6c43bde..e7f2d8526d1 100644 --- a/dlls/gdi32/dc.c +++ b/dlls/gdi32/dc.c @@ -42,7 +42,8 @@ static CRITICAL_SECTION_DEBUG critsect_debug = }; static CRITICAL_SECTION driver_section = { &critsect_debug, -1, 0, 0, 0, 0 };
-typedef const void * (CDECL *driver_entry_point)( unsigned int version, const WCHAR *device ); +typedef HDC (CDECL *driver_entry_point)( const WCHAR *device, + const DEVMODEW *devmode, const WCHAR *output );
struct graphics_driver { @@ -138,7 +139,7 @@ static struct graphics_driver *create_driver( HMODULE module ) driver->module = module;
if (module) - driver->entry_point = (void *)GetProcAddress( module, "wine_get_gdi_driver" ); + driver->entry_point = (void *)GetProcAddress( module, "wine_driver_open_dc" ); else driver->entry_point = NULL;
@@ -312,8 +313,12 @@ HDC WINAPI CreateDCW( LPCWSTR driver, LPCWSTR device, LPCWSTR output, device_str.Buffer = (WCHAR *)device; }
- ret = NtGdiOpenDCW( device || display ? &device_str : NULL, devmode, output ? &output_str : NULL, - 0, is_display, entry_point, NULL, NULL ); + if (entry_point) + ret = entry_point( device, devmode, output ); + else + ret = NtGdiOpenDCW( device || display ? &device_str : NULL, devmode, + output ? &output_str : NULL, + 0, is_display, entry_point, NULL, NULL );
if (ret && hspool && (dc_attr = get_dc_attr( ret ))) { diff --git a/dlls/win32u/dc.c b/dlls/win32u/dc.c index bcfbed29426..9e8e2f65212 100644 --- a/dlls/win32u/dc.c +++ b/dlls/win32u/dc.c @@ -717,11 +717,10 @@ HDC WINAPI NtGdiOpenDCW( UNICODE_STRING *device, const DEVMODEW *devmode, UNICOD /* gdi_lock should not be locked */ if (is_display) funcs = get_display_driver(); - else if (hspool) - { - const struct gdi_dc_funcs * (CDECL *wine_get_gdi_driver)( unsigned int, const WCHAR * ) = hspool; - funcs = wine_get_gdi_driver( WINE_GDI_DRIVER_VERSION, device ? device->Buffer : NULL ); - } + else if (type != WINE_GDI_DRIVER_VERSION) + ERR( "version mismatch: %u\n", (unsigned int)type ); + else + funcs = hspool; if (!funcs) { ERR( "no driver found\n" ); diff --git a/dlls/wineps.drv/init.c b/dlls/wineps.drv/init.c index 136856d5dc0..ec015e1c871 100644 --- a/dlls/wineps.drv/init.c +++ b/dlls/wineps.drv/init.c @@ -897,24 +897,27 @@ fail: }
/****************************************************************************** - * PSDRV_get_gdi_driver + * PSDRV_open_printer_dc */ -const struct gdi_dc_funcs * CDECL PSDRV_get_gdi_driver( unsigned int version, const WCHAR *name ) +HDC CDECL PSDRV_open_printer_dc( const WCHAR *device, + const DEVMODEW *devmode, const WCHAR *output ) { - PRINTERINFO *pi = PSDRV_FindPrinterInfo( name ); - struct init_dc_params params; + struct open_dc_params params; + PRINTERINFO *pi; + + if (!device) + return 0;
+ pi = PSDRV_FindPrinterInfo( device ); if (!pi) - return NULL; - if (version != WINE_GDI_DRIVER_VERSION) - { - ERR( "version mismatch, gdi32 wants %u but wineps has %u\n", version, WINE_GDI_DRIVER_VERSION ); - return NULL; - } - params.name = pi->friendly_name; - params.devmode = pi->Devmode; - params.funcs = NULL; - if (!WINE_UNIX_CALL( unix_init_dc, ¶ms )) - return FALSE; - return params.funcs; + return 0; + + params.device = pi->friendly_name; + params.devmode = devmode; + params.output = output; + params.def_devmode = pi->Devmode; + params.hdc = 0; + if (!WINE_UNIX_CALL( unix_open_dc, ¶ms )) + return 0; + return params.hdc; } diff --git a/dlls/wineps.drv/unixlib.c b/dlls/wineps.drv/unixlib.c index 68509025eac..80331372572 100644 --- a/dlls/wineps.drv/unixlib.c +++ b/dlls/wineps.drv/unixlib.c @@ -1688,23 +1688,32 @@ static NTSTATUS import_ntf(void *arg) return add_ntf_fonts(params->data, params->size); }
-static NTSTATUS init_dc(void *arg) +static NTSTATUS open_dc(void *arg) { - struct init_dc_params *params = arg; + UNICODE_STRING device_str, output_str; + struct open_dc_params *params = arg; struct printer_info *pi;
- pi = find_printer_info(params->name); + pi = find_printer_info(params->device); if (!pi) { pi = malloc(sizeof(*pi)); if (!pi) return FALSE;
- pi->name = params->name; - pi->devmode = params->devmode; + pi->name = params->device; + pi->devmode = params->def_devmode; list_add_head(&printer_info_list, &pi->entry); }
- params->funcs = &psdrv_funcs; + device_str.Length = device_str.MaximumLength = lstrlenW(params->device) + 1; + device_str.Buffer = (WCHAR *)params->device; + if (params->output) + { + output_str.Length = output_str.MaximumLength = lstrlenW(params->output) + 1; + output_str.Buffer = (WCHAR *)params->output; + } + params->hdc = NtGdiOpenDCW(&device_str, params->devmode, params->output ? &output_str : NULL, + WINE_GDI_DRIVER_VERSION, 0, (HANDLE)&psdrv_funcs, NULL, NULL); return TRUE; }
@@ -1727,9 +1736,9 @@ static NTSTATUS free_printer_info(void *arg)
const unixlib_entry_t __wine_unix_call_funcs[] = { - import_ntf, - init_dc, free_printer_info, + import_ntf, + open_dc, };
C_ASSERT(ARRAYSIZE(__wine_unix_call_funcs) == unix_funcs_count); diff --git a/dlls/wineps.drv/unixlib.h b/dlls/wineps.drv/unixlib.h index 03459590dc6..e28a4416d09 100644 --- a/dlls/wineps.drv/unixlib.h +++ b/dlls/wineps.drv/unixlib.h @@ -74,9 +74,9 @@ struct installed_font /* Unix calls */ enum wineps_funcs { - unix_import_ntf, - unix_init_dc, unix_free_printer_info, + unix_import_ntf, + unix_open_dc, unix_funcs_count, };
@@ -86,9 +86,11 @@ struct import_ntf_params int size; };
-struct init_dc_params +struct open_dc_params { - const WCHAR *name; - PSDRV_DEVMODE *devmode; - const struct gdi_dc_funcs *funcs; + const WCHAR *device; + const DEVMODEW *devmode; + const WCHAR *output; + PSDRV_DEVMODE *def_devmode; + HDC hdc; }; diff --git a/dlls/wineps.drv/wineps.drv.spec b/dlls/wineps.drv/wineps.drv.spec index aca8ed2d10f..f193930a9fe 100644 --- a/dlls/wineps.drv/wineps.drv.spec +++ b/dlls/wineps.drv/wineps.drv.spec @@ -1,4 +1,4 @@ -@ cdecl wine_get_gdi_driver(long str) PSDRV_get_gdi_driver +@ cdecl wine_driver_open_dc(wstr ptr wstr) PSDRV_open_printer_dc @ stdcall -private DllRegisterServer()
# Printer driver config exports
From: Piotr Caban piotr@codeweavers.com
--- dlls/wineps.drv/unixlib.c | 52 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 52 insertions(+)
diff --git a/dlls/wineps.drv/unixlib.c b/dlls/wineps.drv/unixlib.c index 80331372572..e90d3c31531 100644 --- a/dlls/wineps.drv/unixlib.c +++ b/dlls/wineps.drv/unixlib.c @@ -1742,3 +1742,55 @@ const unixlib_entry_t __wine_unix_call_funcs[] = };
C_ASSERT(ARRAYSIZE(__wine_unix_call_funcs) == unix_funcs_count); + +#ifdef _WIN64 + +typedef ULONG PTR32; + +static NTSTATUS wow64_import_ntf(void *args) +{ + struct + { + PTR32 data; + int size; + } const *params32 = args; + struct import_ntf_params params = { ULongToPtr(params32->data), params32->size }; + + return import_ntf(¶ms); +} + +static NTSTATUS wow64_open_dc(void *args) +{ + struct + { + PTR32 device; + PTR32 devmode; + PTR32 output; + PTR32 def_devmode; + PTR32 hdc; + } *params32 = args; + struct open_dc_params params = + { + ULongToPtr(params32->device), + ULongToPtr(params32->devmode), + ULongToPtr(params32->output), + ULongToPtr(params32->def_devmode), + 0 + }; + NTSTATUS ret; + + ret = open_dc(¶ms); + params32->hdc = PtrToUlong(params.hdc); + return ret; +} + +const unixlib_entry_t __wine_unix_call_wow64_funcs[] = +{ + free_printer_info, + wow64_import_ntf, + wow64_open_dc, +}; + +C_ASSERT(ARRAYSIZE(__wine_unix_call_wow64_funcs) == unix_funcs_count); + +#endif /* _WIN64 */
From: Piotr Caban piotr@codeweavers.com
Fixes regression caused by aa3699dd59c9. --- dlls/wineps.drv/init.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-)
diff --git a/dlls/wineps.drv/init.c b/dlls/wineps.drv/init.c index ec015e1c871..78a72303708 100644 --- a/dlls/wineps.drv/init.c +++ b/dlls/wineps.drv/init.c @@ -644,14 +644,16 @@ static PSDRV_DEVMODE *get_devmode( HANDLE printer, const WCHAR *name, BOOL *is_d
*is_default = FALSE;
- if (dm) + if (dm && (dm->dmPublic.dmFields & DefaultDevmode.dmPublic.dmFields) == + DefaultDevmode.dmPublic.dmFields) { TRACE( "Retrieved devmode from winspool\n" ); return dm; }
TRACE( "Using default devmode\n" ); - dm = HeapAlloc( PSDRV_Heap, 0, size ); + if (!dm) + dm = HeapAlloc( PSDRV_Heap, 0, size ); if (dm) { memcpy( dm, &DefaultDevmode, min(sizeof(DefaultDevmode), size) );
From: Piotr Caban piotr@codeweavers.com
--- dlls/winspool.drv/info.c | 2 ++ 1 file changed, 2 insertions(+)
diff --git a/dlls/winspool.drv/info.c b/dlls/winspool.drv/info.c index 2f2529ea01b..3c513f1c0e8 100644 --- a/dlls/winspool.drv/info.c +++ b/dlls/winspool.drv/info.c @@ -649,6 +649,8 @@ static BOOL add_printer_driver( const WCHAR *name, const WCHAR *ppd_dir ) res = !UNIX_CALL( get_ppd, &ppd_params ) || get_internal_fallback_ppd( ppd ); if (!res) goto end;
+ AddPrintProcessorW(NULL, NULL, driver_nt, (WCHAR *)L"wineps"); + memset( &di3, 0, sizeof(DRIVER_INFO_3W) ); di3.cVersion = 3; di3.pName = (WCHAR *)name;
Hi,
It looks like your patch introduced the new failures shown below. Please investigate and fix them before resubmitting your patch. If they are not new, fixing them anyway would help a lot. Otherwise please ask for the known failures list to be updated.
The tests also ran into some preexisting test failures. If you know how to fix them that would be helpful. See the TestBot job for the details:
The full results can be found at: https://testbot.winehq.org/JobDetails.pl?Key=132762
Your paranoid android.
=== debian11b (64 bit WoW report) ===
win32u: win32u.c:1046: Test failed: buf = d
winspool.drv: win32u.c:1059: Test failed: res = 0
Report validation errors: win32u:win32u has unaccounted for failure messages win32u:win32u has unaccounted for todo messages win32u:win32u returned success despite having failures winspool.drv:info contains a misplaced failure line for win32u
This merge request was approved by Huw Davies.