Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
W
wine-cw
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-cw
Commits
3a8b51d6
Commit
3a8b51d6
authored
Nov 16, 2022
by
Piotr Caban
Committed by
Alexandre Julliard
Nov 16, 2022
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
winspool: Allow specifying out buffer in DEVMODEdupWtoA.
parent
a3fe33f6
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
49 additions
and
53 deletions
+49
-53
info.c
dlls/winspool.drv/info.c
+49
-53
No files found.
dlls/winspool.drv/info.c
View file @
3a8b51d6
...
...
@@ -250,58 +250,62 @@ static DEVMODEW *dup_devmode( const DEVMODEW *dm )
return
ret
;
}
/* stringWtoA
* Converts Unicode string to Ansi (possibly in place).
*/
static
void
stringWtoA
(
const
WCHAR
*
strW
,
char
*
strA
,
size_t
size
)
{
DWORD
ret
;
char
*
str
;
str
=
(
char
*
)
strW
==
strA
?
malloc
(
size
)
:
strA
;
ret
=
WideCharToMultiByte
(
CP_ACP
,
0
,
strW
,
-
1
,
str
,
size
,
NULL
,
NULL
);
if
(
str
!=
strA
)
{
memcpy
(
strA
,
str
,
ret
);
free
(
str
);
}
memset
(
strA
+
ret
,
0
,
size
-
ret
);
}
/***********************************************************
* DEVMODEdupWtoA
* Creates an ansi copy of supplied devmode
* DEVMODEWtoA
* Converts DEVMODEW to DEVMODEA (possibly in place).
* Allocates DEVMODEA if needed.
*/
static
DEVMODEA
*
DEVMODE
dupWtoA
(
const
DEVMODEW
*
dmW
)
static
DEVMODEA
*
DEVMODE
WtoA
(
const
DEVMODEW
*
dmW
,
DEVMODEA
*
dmA
)
{
LPDEVMODEA
dmA
;
DWORD
size
;
DWORD
size
,
sizeW
;
if
(
!
dmW
)
return
NULL
;
size
=
dmW
->
dmSize
-
CCHDEVICENAME
-
((
dmW
->
dmSize
>
FIELD_OFFSET
(
DEVMODEW
,
dmFormName
))
?
CCHFORMNAME
:
0
);
sizeW
=
dmW
->
dmSize
;
size
=
sizeW
-
CCHDEVICENAME
-
((
sizeW
>
FIELD_OFFSET
(
DEVMODEW
,
dmFormName
))
?
CCHFORMNAME
:
0
);
dmA
=
calloc
(
1
,
size
+
dmW
->
dmDriverExtra
);
if
(
!
dmA
)
dmA
=
calloc
(
1
,
size
+
dmW
->
dmDriverExtra
);
if
(
!
dmA
)
return
NULL
;
WideCharToMultiByte
(
CP_ACP
,
0
,
dmW
->
dmDeviceName
,
-
1
,
(
LPSTR
)
dmA
->
dmDeviceName
,
CCHDEVICENAME
,
NULL
,
NULL
);
stringWtoA
(
dmW
->
dmDeviceName
,
(
char
*
)
dmA
->
dmDeviceName
,
CCHDEVICENAME
);
if
(
FIELD_OFFSET
(
DEVMODEW
,
dmFormName
)
>=
dmW
->
dmSize
)
if
(
FIELD_OFFSET
(
DEVMODEW
,
dmFormName
)
>=
sizeW
)
{
mem
cpy
(
&
dmA
->
dmSpecVersion
,
&
dmW
->
dmSpecVersion
,
dmW
->
dmSize
-
FIELD_OFFSET
(
DEVMODEW
,
dmSpecVersion
)
);
mem
move
(
&
dmA
->
dmSpecVersion
,
&
dmW
->
dmSpecVersion
,
sizeW
-
FIELD_OFFSET
(
DEVMODEW
,
dmSpecVersion
)
);
}
else
{
mem
cpy
(
&
dmA
->
dmSpecVersion
,
&
dmW
->
dmSpecVersion
,
mem
move
(
&
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
)
);
stringWtoA
(
dmW
->
dmFormName
,
(
char
*
)
dmA
->
dmFormName
,
CCHFORMNAME
);
memmove
(
&
dmA
->
dmLogPixels
,
&
dmW
->
dmLogPixels
,
sizeW
-
FIELD_OFFSET
(
DEVMODEW
,
dmLogPixels
)
);
}
dmA
->
dmSize
=
size
;
mem
cpy
(
(
char
*
)
dmA
+
dmA
->
dmSize
,
(
const
char
*
)
dmW
+
dmW
->
dmSize
,
dmW
->
dmDriverExtra
);
mem
move
(
(
char
*
)
dmA
+
dmA
->
dmSize
,
(
const
char
*
)
dmW
+
sizeW
,
dmW
->
dmDriverExtra
);
return
dmA
;
}
static
void
packed_string_WtoA
(
WCHAR
*
strW
)
{
DWORD
len
=
wcslen
(
strW
),
size
=
(
len
+
1
)
*
sizeof
(
WCHAR
),
ret
;
char
*
str
;
if
(
!
len
)
return
;
str
=
malloc
(
size
);
ret
=
WideCharToMultiByte
(
CP_ACP
,
0
,
strW
,
len
,
str
,
size
-
1
,
NULL
,
NULL
);
memcpy
(
strW
,
str
,
ret
);
memset
(
(
BYTE
*
)
strW
+
ret
,
0
,
size
-
ret
);
free
(
str
);
}
/*********************************************************************
* packed_struct_WtoA
*
...
...
@@ -316,7 +320,7 @@ static void packed_struct_WtoA( BYTE *data, const DWORD *string_info )
while
(
*
string_info
!=
~
0u
)
{
strW
=
*
(
WCHAR
**
)(
data
+
*
string_info
);
if
(
strW
)
packed_string_WtoA
(
strW
);
if
(
strW
)
stringWtoA
(
strW
,
(
char
*
)
strW
,
(
wcslen
(
strW
)
+
1
)
*
sizeof
(
WCHAR
)
);
string_info
++
;
}
}
...
...
@@ -894,7 +898,7 @@ static inline DWORD set_reg_szW(HKEY hkey, const WCHAR *keyname, const WCHAR *va
static
inline
DWORD
set_reg_devmode
(
HKEY
key
,
const
WCHAR
*
name
,
const
DEVMODEW
*
dm
)
{
DEVMODEA
*
dmA
=
DEVMODE
dupWtoA
(
dm
);
DEVMODEA
*
dmA
=
DEVMODE
WtoA
(
dm
,
NULL
);
DWORD
ret
=
ERROR_FILE_NOT_FOUND
;
/* FIXME: Write DEVMODEA not DEVMODEW into reg. This is what win9x does
...
...
@@ -1282,7 +1286,6 @@ static void convert_printerinfo_W_to_A(LPBYTE out, LPBYTE pPrintersW,
{
PRINTER_INFO_2W
*
piW
=
(
PRINTER_INFO_2W
*
)
pPrintersW
;
PRINTER_INFO_2A
*
piA
=
(
PRINTER_INFO_2A
*
)
out
;
LPDEVMODEA
dmA
;
TRACE
(
"(%lu) #%lu: %s
\n
"
,
level
,
id
,
debugstr_w
(
piW
->
pPrinterName
));
if
(
piW
->
pServerName
)
{
...
...
@@ -1335,17 +1338,16 @@ static void convert_printerinfo_W_to_A(LPBYTE out, LPBYTE pPrintersW,
outlen
-=
len
;
}
dmA
=
DEVMODEdupWtoA
(
piW
->
pDevMode
);
if
(
dmA
)
{
if
(
piW
->
pDevMode
)
{
/* align DEVMODEA to a DWORD boundary */
len
=
(
4
-
(
(
DWORD_PTR
)
ptr
&
3
))
&
3
;
ptr
+=
len
;
outlen
-=
len
;
piA
->
pDevMode
=
(
LPDEVMODEA
)
ptr
;
len
=
dmA
->
dmSize
+
dmA
->
dmDriverExtra
;
memcpy
(
ptr
,
dmA
,
len
);
free
(
dmA
);
DEVMODEWtoA
(
piW
->
pDevMode
,
piA
->
pDevMode
);
len
=
piA
->
pDevMode
->
dmSize
+
piA
->
pDevMode
->
dmDriverExtra
;
ptr
+=
len
;
outlen
-=
len
;
...
...
@@ -1458,25 +1460,22 @@ static void convert_printerinfo_W_to_A(LPBYTE out, LPBYTE pPrintersW,
{
PRINTER_INFO_9W
*
piW
=
(
PRINTER_INFO_9W
*
)
pPrintersW
;
PRINTER_INFO_9A
*
piA
=
(
PRINTER_INFO_9A
*
)
out
;
LPDEVMODEA
dmA
;
TRACE
(
"(%lu) #%lu
\n
"
,
level
,
id
);
dmA
=
DEVMODEdupWtoA
(
piW
->
pDevMode
);
if
(
dmA
)
{
if
(
piW
->
pDevMode
)
{
/* align DEVMODEA to a DWORD boundary */
len
=
(
4
-
(
(
DWORD_PTR
)
ptr
&
3
))
&
3
;
ptr
+=
len
;
outlen
-=
len
;
piA
->
pDevMode
=
(
LPDEVMODEA
)
ptr
;
len
=
dmA
->
dmSize
+
dmA
->
dmDriverExtra
;
memcpy
(
ptr
,
dmA
,
len
);
free
(
dmA
);
DEVMODEWtoA
(
piW
->
pDevMode
,
piA
->
pDevMode
);
len
=
piA
->
pDevMode
->
dmSize
+
piA
->
pDevMode
->
dmDriverExtra
;
ptr
+=
len
;
outlen
-=
len
;
}
break
;
}
...
...
@@ -1890,11 +1889,8 @@ LONG WINAPI DocumentPropertiesA(HWND hwnd, HANDLE printer, char *device_name, DE
ret
=
DocumentPropertiesW
(
hwnd
,
printer
,
device
,
outputW
,
inputW
,
mode
);
if
(
ret
>=
0
&&
outputW
&&
(
mode
&
(
DM_COPY
|
DM_UPDATE
)))
{
DEVMODEA
*
dmA
=
DEVMODEdupWtoA
(
outputW
);
if
(
dmA
)
memcpy
(
output
,
dmA
,
dmA
->
dmSize
+
dmA
->
dmDriverExtra
);
free
(
dmA
);
}
if
(
ret
>=
0
&&
outputW
&&
(
mode
&
(
DM_COPY
|
DM_UPDATE
)))
DEVMODEWtoA
(
outputW
,
output
);
free
(
device
);
free
(
inputW
);
...
...
@@ -7621,7 +7617,7 @@ static BOOL get_job_info_2(job_t *job, JOB_INFO_2W *ji2, LPBYTE buf, DWORD cbBuf
{
if
(
!
unicode
)
{
dmA
=
DEVMODE
dupWtoA
(
job
->
devmode
);
dmA
=
DEVMODE
WtoA
(
job
->
devmode
,
NULL
);
devmode
=
(
LPDEVMODEW
)
dmA
;
if
(
dmA
)
size
=
dmA
->
dmSize
+
dmA
->
dmDriverExtra
;
}
...
...
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