mirror of
git://source.winehq.org/git/wine.git
synced 2024-10-06 08:39:34 +00:00
wineps: Introduce wine_driver_open_dc wine specific export used to create printer DC.
Doing it this way avoids passing Unix library pointers throught PE.
This commit is contained in:
parent
a894528071
commit
ec6062c572
|
@ -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 )))
|
||||
{
|
||||
|
|
|
@ -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" );
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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;
|
||||
};
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in a new issue