[WINSPOOL]
[reactos.git] / reactos / win32ss / printing / base / winspool / devmode.c
1 /*
2 * PROJECT: ReactOS Spooler API
3 * LICENSE: GNU LGPL v2.1 or any later version as published by the Free Software Foundation
4 * PURPOSE: Functions giving information about DEVMODE structures
5 * COPYRIGHT: Copyright 2016 Colin Finck <colin@reactos.org>
6 */
7
8 #include "precomp.h"
9
10 BOOL WINAPI
11 IsValidDevmodeA(PDEVMODEA pDevmode, size_t DevmodeSize)
12 {
13 // Check if a Devmode was given, its dmSize member is at least as big as the DEVMODEA structure
14 // and DevmodeSize is large enough for the public and private members of the structure.
15 if (!pDevmode ||
16 pDevmode->dmSize < sizeof(DEVMODEA) ||
17 DevmodeSize < pDevmode->dmSize + pDevmode->dmDriverExtra)
18 {
19 SetLastError(ERROR_INVALID_DATA);
20 return FALSE;
21 }
22
23 // Return success without setting the error code.
24 return TRUE;
25 }
26
27 BOOL WINAPI
28 IsValidDevmodeW(PDEVMODEW pDevmode, size_t DevmodeSize)
29 {
30 // Check if a Devmode was given, its dmSize member is at least as big as the DEVMODEW structure
31 // and DevmodeSize is large enough for the public and private members of the structure.
32 if (!pDevmode ||
33 pDevmode->dmSize < sizeof(DEVMODEW) ||
34 DevmodeSize < pDevmode->dmSize + pDevmode->dmDriverExtra)
35 {
36 SetLastError(ERROR_INVALID_DATA);
37 return FALSE;
38 }
39
40 // Return success without setting the error code.
41 return TRUE;
42 }