Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
W
wine-winehq
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
wine
wine-winehq
Commits
607b5d77
Commit
607b5d77
authored
Apr 05, 2012
by
Huw Davies
Committed by
Alexandre Julliard
Apr 05, 2012
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
winspool: Add a helper to set devmode data in the registry.
parent
9166fcb7
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
72 additions
and
61 deletions
+72
-61
info.c
dlls/winspool.drv/info.c
+72
-61
No files found.
dlls/winspool.drv/info.c
View file @
607b5d77
...
...
@@ -349,6 +349,46 @@ static DEVMODEW *dup_devmode( const DEVMODEW *dm )
return
ret
;
}
/***********************************************************
* DEVMODEdupWtoA
* Creates an ansi copy of supplied devmode
*/
static
DEVMODEA
*
DEVMODEdupWtoA
(
const
DEVMODEW
*
dmW
)
{
LPDEVMODEA
dmA
;
DWORD
size
;
if
(
!
dmW
)
return
NULL
;
size
=
dmW
->
dmSize
-
CCHDEVICENAME
-
((
dmW
->
dmSize
>
FIELD_OFFSET
(
DEVMODEW
,
dmFormName
))
?
CCHFORMNAME
:
0
);
dmA
=
HeapAlloc
(
GetProcessHeap
(),
HEAP_ZERO_MEMORY
,
size
+
dmW
->
dmDriverExtra
);
if
(
!
dmA
)
return
NULL
;
WideCharToMultiByte
(
CP_ACP
,
0
,
dmW
->
dmDeviceName
,
-
1
,
(
LPSTR
)
dmA
->
dmDeviceName
,
CCHDEVICENAME
,
NULL
,
NULL
);
if
(
FIELD_OFFSET
(
DEVMODEW
,
dmFormName
)
>=
dmW
->
dmSize
)
{
memcpy
(
&
dmA
->
dmSpecVersion
,
&
dmW
->
dmSpecVersion
,
dmW
->
dmSize
-
FIELD_OFFSET
(
DEVMODEW
,
dmSpecVersion
)
);
}
else
{
memcpy
(
&
dmA
->
dmSpecVersion
,
&
dmW
->
dmSpecVersion
,
FIELD_OFFSET
(
DEVMODEW
,
dmFormName
)
-
FIELD_OFFSET
(
DEVMODEW
,
dmSpecVersion
)
);
WideCharToMultiByte
(
CP_ACP
,
0
,
dmW
->
dmFormName
,
-
1
,
(
LPSTR
)
dmA
->
dmFormName
,
CCHFORMNAME
,
NULL
,
NULL
);
memcpy
(
&
dmA
->
dmLogPixels
,
&
dmW
->
dmLogPixels
,
dmW
->
dmSize
-
FIELD_OFFSET
(
DEVMODEW
,
dmLogPixels
)
);
}
dmA
->
dmSize
=
size
;
memcpy
(
(
char
*
)
dmA
+
dmA
->
dmSize
,
(
const
char
*
)
dmW
+
dmW
->
dmSize
,
dmW
->
dmDriverExtra
);
return
dmA
;
}
/******************************************************************
* verify, that the filename is a local file
*
...
...
@@ -712,6 +752,26 @@ static inline DWORD set_reg_szW(HKEY hkey, const WCHAR *keyname, const WCHAR *va
return
ERROR_FILE_NOT_FOUND
;
}
static
inline
DWORD
set_reg_devmode
(
HKEY
key
,
const
WCHAR
*
name
,
const
DEVMODEW
*
dm
)
{
DEVMODEA
*
dmA
=
DEVMODEdupWtoA
(
dm
);
DWORD
ret
=
ERROR_FILE_NOT_FOUND
;
/* FIXME: Write DEVMODEA not DEVMODEW into reg. This is what win9x does
and we support these drivers. NT writes DEVMODEW so somehow
we'll need to distinguish between these when we support NT
drivers */
if
(
dmA
)
{
ret
=
RegSetValueExW
(
key
,
name
,
0
,
REG_BINARY
,
(
LPBYTE
)
dmA
,
dmA
->
dmSize
+
dmA
->
dmDriverExtra
);
HeapFree
(
GetProcessHeap
(),
0
,
dmA
);
}
return
ret
;
}
/******************************************************************
* get_servername_from_name (internal)
*
...
...
@@ -1102,44 +1162,6 @@ static LPDEVMODEW DEVMODEcpyAtoW(DEVMODEW *dmW, const DEVMODEA *dmA)
return
dmW
;
}
/***********************************************************
* DEVMODEdupWtoA
* Creates an ansi copy of supplied devmode
*/
static
LPDEVMODEA
DEVMODEdupWtoA
(
const
DEVMODEW
*
dmW
)
{
LPDEVMODEA
dmA
;
DWORD
size
;
if
(
!
dmW
)
return
NULL
;
size
=
dmW
->
dmSize
-
CCHDEVICENAME
-
((
dmW
->
dmSize
>
FIELD_OFFSET
(
DEVMODEW
,
dmFormName
))
?
CCHFORMNAME
:
0
);
dmA
=
HeapAlloc
(
GetProcessHeap
(),
HEAP_ZERO_MEMORY
,
size
+
dmW
->
dmDriverExtra
);
if
(
!
dmA
)
return
NULL
;
WideCharToMultiByte
(
CP_ACP
,
0
,
dmW
->
dmDeviceName
,
-
1
,
(
LPSTR
)
dmA
->
dmDeviceName
,
CCHDEVICENAME
,
NULL
,
NULL
);
if
(
FIELD_OFFSET
(
DEVMODEW
,
dmFormName
)
>=
dmW
->
dmSize
)
{
memcpy
(
&
dmA
->
dmSpecVersion
,
&
dmW
->
dmSpecVersion
,
dmW
->
dmSize
-
FIELD_OFFSET
(
DEVMODEW
,
dmSpecVersion
));
}
else
{
memcpy
(
&
dmA
->
dmSpecVersion
,
&
dmW
->
dmSpecVersion
,
FIELD_OFFSET
(
DEVMODEW
,
dmFormName
)
-
FIELD_OFFSET
(
DEVMODEW
,
dmSpecVersion
));
WideCharToMultiByte
(
CP_ACP
,
0
,
dmW
->
dmFormName
,
-
1
,
(
LPSTR
)
dmA
->
dmFormName
,
CCHFORMNAME
,
NULL
,
NULL
);
memcpy
(
&
dmA
->
dmLogPixels
,
&
dmW
->
dmLogPixels
,
dmW
->
dmSize
-
FIELD_OFFSET
(
DEVMODEW
,
dmLogPixels
));
}
dmA
->
dmSize
=
size
;
memcpy
((
char
*
)
dmA
+
dmA
->
dmSize
,
(
const
char
*
)
dmW
+
dmW
->
dmSize
,
dmW
->
dmDriverExtra
);
return
dmA
;
}
/******************************************************************
* convert_printerinfo_W_to_A [internal]
*
...
...
@@ -2560,8 +2582,7 @@ static void set_devices_and_printerports(PRINTER_INFO_2W *pi)
HANDLE
WINAPI
AddPrinterW
(
LPWSTR
pName
,
DWORD
Level
,
LPBYTE
pPrinter
)
{
PRINTER_INFO_2W
*
pi
=
(
PRINTER_INFO_2W
*
)
pPrinter
;
LPDEVMODEA
dmA
;
LPDEVMODEW
dmW
;
LPDEVMODEW
dm
;
HANDLE
retval
;
HKEY
hkeyPrinter
,
hkeyPrinters
,
hkeyDriver
,
hkeyDrivers
;
LONG
size
;
...
...
@@ -2643,7 +2664,7 @@ HANDLE WINAPI AddPrinterW(LPWSTR pName, DWORD Level, LPBYTE pPrinter)
*
* FIXME:
* Note that DocumentPropertiesW will briefly try to open the printer we
* just create to find a DEVMODE
A
struct (it will use the WINEPS default
* just create to find a DEVMODE struct (it will use the WINEPS default
* one in case it is not there, so we are ok).
*/
size
=
DocumentPropertiesW
(
0
,
0
,
pi
->
pPrinterName
,
NULL
,
NULL
,
0
);
...
...
@@ -2653,37 +2674,27 @@ HANDLE WINAPI AddPrinterW(LPWSTR pName, DWORD Level, LPBYTE pPrinter)
size
=
sizeof
(
DEVMODEW
);
}
if
(
pi
->
pDevMode
)
dm
W
=
pi
->
pDevMode
;
dm
=
pi
->
pDevMode
;
else
{
dm
W
=
HeapAlloc
(
GetProcessHeap
(),
HEAP_ZERO_MEMORY
,
size
);
dm
W
->
dmSize
=
size
;
if
(
0
>
DocumentPropertiesW
(
0
,
0
,
pi
->
pPrinterName
,
dmW
,
NULL
,
DM_OUT_BUFFER
)
)
dm
=
HeapAlloc
(
GetProcessHeap
(),
HEAP_ZERO_MEMORY
,
size
);
dm
->
dmSize
=
size
;
if
(
DocumentPropertiesW
(
0
,
0
,
pi
->
pPrinterName
,
dm
,
NULL
,
DM_OUT_BUFFER
)
<
0
)
{
WARN
(
"DocumentPropertiesW on printer %s failed!
\n
"
,
debugstr_w
(
pi
->
pPrinterName
));
HeapFree
(
GetProcessHeap
(),
0
,
dmW
);
dm
W
=
NULL
;
HeapFree
(
GetProcessHeap
(),
0
,
dm
);
dm
=
NULL
;
}
else
{
/* set devmode to printer name */
lstrcpynW
(
dmW
->
dmDeviceName
,
pi
->
pPrinterName
,
CCHDEVICENAME
);
lstrcpynW
(
dm
->
dmDeviceName
,
pi
->
pPrinterName
,
CCHDEVICENAME
);
}
}
/* Write DEVMODEA not DEVMODEW into reg. This is what win9x does
and we support these drivers. NT writes DEVMODEW so somehow
we'll need to distinguish between these when we support NT
drivers */
if
(
dmW
)
{
dmA
=
DEVMODEdupWtoA
(
dmW
);
RegSetValueExW
(
hkeyPrinter
,
default_devmodeW
,
0
,
REG_BINARY
,
(
LPBYTE
)
dmA
,
dmA
->
dmSize
+
dmA
->
dmDriverExtra
);
HeapFree
(
GetProcessHeap
(),
0
,
dmA
);
if
(
!
pi
->
pDevMode
)
HeapFree
(
GetProcessHeap
(),
0
,
dmW
);
}
set_reg_devmode
(
hkeyPrinter
,
default_devmodeW
,
dm
);
if
(
!
pi
->
pDevMode
)
HeapFree
(
GetProcessHeap
(),
0
,
dm
);
set_reg_szW
(
hkeyPrinter
,
DescriptionW
,
pi
->
pComment
);
set_reg_szW
(
hkeyPrinter
,
LocationW
,
pi
->
pLocation
);
set_reg_szW
(
hkeyPrinter
,
NameW
,
pi
->
pPrinterName
);
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment