Skip to content

Commit 7bffb70

Browse files
committed
[Printing] Fix ups and Implementations.
WinSpool : Implement missing API. Sync/Port from wine. Setting it to fast track for needed testing of the later GDI code. Leaving Fix-me debug prints on. Local tree has WinSpool_winetest turned on. So no debug noise during normal ReactOS operation. SpoolSS : Reordered header types. Have more Spl function to be added while SpoolSV is being coded to forward to LocalSpl. Based on wine and old research from the GDI code.
1 parent 89e716a commit 7bffb70

26 files changed

+5442
-704
lines changed

win32ss/printing/base/printui/printui.spec

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
@ stub ConnectToPrinterDlg
22
@ stub ConnectToPrinterPropertyPage
3-
@ stub ConstructPrinterFriendlyName
3+
@ stdcall -stub ConstructPrinterFriendlyName(wstr wstr ptr)
44
@ stub -private DllCanUnloadNow
55
@ stub -private DllGetClassObject
66
@ stub DocumentPropertiesWrap

win32ss/printing/base/spoolss/memory.c

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,7 @@ DllAllocSplMem(DWORD dwBytes)
111111
BOOL WINAPI
112112
DllFreeSplMem(PVOID pMem)
113113
{
114+
if ( !pMem ) return TRUE;
114115
return HeapFree(hProcessHeap, 0, pMem);
115116
}
116117

@@ -128,7 +129,9 @@ DllFreeSplMem(PVOID pMem)
128129
BOOL WINAPI
129130
DllFreeSplStr(PWSTR pwszString)
130131
{
131-
return HeapFree(hProcessHeap, 0, pwszString);
132+
if ( pwszString )
133+
return HeapFree(hProcessHeap, 0, pwszString);
134+
return FALSE;
132135
}
133136

134137
/**

win32ss/printing/base/spoolss/precomp.h

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -52,12 +52,4 @@ SPOOLSS_PRINTER_HANDLE, *PSPOOLSS_PRINTER_HANDLE;
5252
extern HANDLE hProcessHeap;
5353
extern LIST_ENTRY PrintProviderList;
5454

55-
// spoolfile.c
56-
typedef struct _FILE_INFO_1
57-
{
58-
BOOL bInheritHandle;
59-
HANDLE hSpoolFileHandle;
60-
DWORD dwOptions;
61-
} FILE_INFO_1, *PFILE_INFO_1;
62-
6355
#endif

win32ss/printing/base/spoolsv/precomp.h

Lines changed: 0 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -28,27 +28,4 @@ WINE_DEFAULT_DEBUG_CHANNEL(spoolsv);
2828
// rpcserver.c
2929
DWORD WINAPI LrpcThreadProc(LPVOID lpParameter);
3030

31-
// spoolfile.c
32-
BOOL WINAPI
33-
SplGetSpoolFileInfo(
34-
HANDLE hPrinter,
35-
HANDLE hProcessHandle,
36-
DWORD Level,
37-
WINSPOOL_FILE_INFO_1 *pFileInfo,
38-
DWORD dwSize,
39-
DWORD* dwNeeded );
40-
41-
BOOL WINAPI
42-
SplCommitSpoolData(
43-
HANDLE hPrinter,
44-
HANDLE hProcessHandle,
45-
DWORD cbCommit,
46-
DWORD Level,
47-
WINSPOOL_FILE_INFO_1 *pFileInfo,
48-
DWORD dwSize,
49-
DWORD* dwNeeded );
50-
51-
BOOL WINAPI
52-
SplCloseSpoolFileHandle( HANDLE hPrinter );
53-
5431
#endif

win32ss/printing/base/spoolsv/spoolfile.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ _RpcGetSpoolFileInfo( WINSPOOL_PRINTER_HANDLE hPrinter, WINSPOOL_HANDLE hProcess
1919
return dwErrorCode;
2020
}
2121

22-
if (!SplGetSpoolFileInfo( hPrinter, hProcessHandle, Level, pFileInfo, dwSize, dwNeeded ) )
22+
if (!SplGetSpoolFileInfo( hPrinter, hProcessHandle, Level, (FILE_INFO_1*)pFileInfo, dwSize, dwNeeded ) )
2323
dwErrorCode = GetLastError();
2424

2525
RpcRevertToSelf();
@@ -38,7 +38,7 @@ _RpcCommitSpoolData( WINSPOOL_PRINTER_HANDLE hPrinter, WINSPOOL_HANDLE hProcessH
3838
return dwErrorCode;
3939
}
4040

41-
if (!SplCommitSpoolData( hPrinter, hProcessHandle, cbCommit, Level, pFileInfo, dwSize, dwNeeded ) )
41+
if (!SplCommitSpoolData( hPrinter, hProcessHandle, cbCommit, Level, (FILE_INFO_1*)pFileInfo, dwSize, dwNeeded ) )
4242
dwErrorCode = GetLastError();
4343

4444
RpcRevertToSelf();
@@ -61,7 +61,7 @@ _RpcGetSpoolFileInfo2( WINSPOOL_PRINTER_HANDLE hPrinter, DWORD dwProcessId, DWOR
6161
hProcessHandle = OpenProcess( PROCESS_DUP_HANDLE, FALSE, dwProcessId );
6262

6363

64-
if (!SplGetSpoolFileInfo( hPrinter, hProcessHandle, Level, pFileInfoContainer->FileInfo.pFileInfo1, sizeof(WINSPOOL_FILE_INFO_1), &dwNeeded ) )
64+
if (!SplGetSpoolFileInfo( hPrinter, hProcessHandle, Level, (FILE_INFO_1*)pFileInfoContainer->FileInfo.pFileInfo1, sizeof(FILE_INFO_1), &dwNeeded ) )
6565
dwErrorCode = GetLastError();
6666

6767
if ( hProcessHandle )
@@ -88,7 +88,7 @@ _RpcCommitSpoolData2( WINSPOOL_PRINTER_HANDLE hPrinter, DWORD dwProcessId, DWORD
8888

8989
hProcessHandle = OpenProcess( PROCESS_DUP_HANDLE, FALSE, dwProcessId );
9090

91-
if (!SplCommitSpoolData( hPrinter, hProcessHandle, cbCommit, Level, pFileInfoContainer->FileInfo.pFileInfo1, sizeof(WINSPOOL_FILE_INFO_1), &dwNeeded ) )
91+
if (!SplCommitSpoolData( hPrinter, hProcessHandle, cbCommit, Level, (FILE_INFO_1*)pFileInfoContainer->FileInfo.pFileInfo1, sizeof(FILE_INFO_1), &dwNeeded ) )
9292
dwErrorCode = GetLastError();
9393

9494
if ( hProcessHandle )

win32ss/printing/base/winspool/CMakeLists.txt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ list(APPEND SOURCE
1616
printers.c
1717
printprocessors.c
1818
printproviders.c
19+
spoolfile.c
1920
utils.c
2021
${CMAKE_CURRENT_BINARY_DIR}/winspool_c.c)
2122

@@ -31,6 +32,6 @@ add_library(winspool MODULE
3132
set_target_properties(winspool PROPERTIES SUFFIX ".drv")
3233
set_module_type(winspool win32dll UNICODE)
3334
target_link_libraries(winspool wine ${PSEH_LIB})
34-
add_importlibs(winspool advapi32 gdi32 rpcrt4 msvcrt kernel32 ntdll)
35+
add_importlibs(winspool advapi32 gdi32 user32 rpcrt4 msvcrt kernel32 ntdll)
3536
add_pch(winspool precomp.h "${PCH_SKIP_SOURCE}")
3637
add_cd_file(TARGET winspool DESTINATION reactos/system32 FOR all)

win32ss/printing/base/winspool/devmode.c

Lines changed: 55 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -234,15 +234,63 @@ IsValidDevmodeW(PDEVMODEW pDevmode, size_t DevmodeSize)
234234
return FALSE;
235235
}
236236

237-
void RosConvertAnsiDevModeToUnicodeDevmode(PDEVMODEA pDevModeInput, PDEVMODEW pDevModeOutput)
237+
BOOL WINAPI
238+
IsValidDevmodeNoSizeW(PDEVMODEW pDevmode)
239+
{
240+
PMINIMUM_SIZE_TABLE pTable = MinimumSizeW;
241+
WORD wRequiredSize;
242+
243+
TRACE("IsValidDevmodeNoSizeW(%p)\n", pDevmode);
244+
245+
// Check if a Devmode was given at all.
246+
if (!pDevmode)
247+
goto Failure;
248+
249+
// If the structure has private members, the public structure must be 32-bit packed.
250+
if (pDevmode->dmDriverExtra && pDevmode->dmSize % 4)
251+
goto Failure;
252+
253+
// Now determine the minimum possible dmSize based on the given fields in dmFields.
254+
wRequiredSize = FIELD_OFFSET(DEVMODEW, dmFields) + RTL_FIELD_SIZE(DEVMODEW, dmFields);
255+
256+
while (pTable->dwField)
257+
{
258+
if (pDevmode->dmFields & pTable->dwField)
259+
{
260+
wRequiredSize = pTable->wSize;
261+
break;
262+
}
263+
264+
pTable++;
265+
}
266+
267+
// Verify that the value in dmSize is big enough for the used fields.
268+
if (pDevmode->dmSize < wRequiredSize)
269+
goto Failure;
270+
271+
// Check if dmDeviceName and (if used) dmFormName are null-terminated.
272+
// Fix this if they aren't.
273+
_FixStringW(pDevmode->dmDeviceName, sizeof(pDevmode->dmDeviceName));
274+
if (pDevmode->dmFields & DM_FORMNAME)
275+
_FixStringW(pDevmode->dmFormName, sizeof(pDevmode->dmFormName));
276+
277+
// Return success without setting the error code.
278+
return TRUE;
279+
280+
Failure:
281+
SetLastError(ERROR_INVALID_DATA);
282+
return FALSE;
283+
}
284+
285+
void RosConvertAnsiDevModeToUnicodeDevmode(PDEVMODEA pDevModeInput, PDEVMODEW *pDevModeOutput)
238286
{
239287
// FIXME: This function should become ConvertAnsiDevModeToUnicodeDevmode when its parameters are known!
240288

241289
// Check if a pDevModeInput and pDevModeOutput are both not NULL.
242290
if (!pDevModeInput || !pDevModeOutput)
243291
return;
244292

245-
pDevModeOutput = GdiConvertToDevmodeW(pDevModeInput);
293+
*pDevModeOutput = GdiConvertToDevmodeW(pDevModeInput);
246294
}
247295

248296
// Internal counterpart to GdiConvertToDevmodeW from gdi32
@@ -304,11 +352,15 @@ _ConvertToDevmodeA(const DEVMODEW *dmW)
304352

305353
void RosConvertUnicodeDevModeToAnsiDevmode(PDEVMODEW pDevModeInput, PDEVMODEA pDevModeOutput)
306354
{
355+
PDEVMODEA pTmp;
356+
307357
// FIXME: This function should become ConvertUnicodeDevModeToAnsiDevmode when its parameters are known!
308358

309359
// Check if a pDevModeInput and pDevModeOutput are both not NULL.
310360
if (!pDevModeInput || !pDevModeOutput)
311361
return;
312362

313-
pDevModeOutput = _ConvertToDevmodeA(pDevModeInput);
363+
pTmp = _ConvertToDevmodeA(pDevModeInput);
364+
memcpy( pDevModeOutput, pTmp, pTmp->dmSize + pTmp->dmDriverExtra); // Copy into a Wide char (Larger) buffer.
365+
HeapFree(hProcessHeap, 0, pTmp);
314366
}

0 commit comments

Comments
 (0)