ReactOS  0.4.15-dev-488-gc7a1924
precomp.h File Reference
#include <windef.h>
#include <winbase.h>
#include <winuser.h>
#include <wingdi.h>
#include <winreg.h>
#include <winspool.h>
#include <winspool_c.h>
#include <winsplp.h>
#include <winddiui.h>
#include <ndk/rtlfuncs.h>
#include <strsafe.h>
#include <spoolss.h>
#include <marshalling/marshalling.h>
#include "wspool.h"
#include <wine/debug.h>
Include dependency graph for precomp.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

struct  _SPOOLER_HANDLE
 
struct  _UNIVERSAL_FONT_ID
 

Macros

#define WIN32_NO_STATUS
 
#define SPOOLER_HANDLE_SIG   'gg'
 

Typedefs

typedef struct _SPOOLER_HANDLE SPOOLER_HANDLE
 
typedef struct _SPOOLER_HANDLEPSPOOLER_HANDLE
 
typedef struct _UNIVERSAL_FONT_ID UNIVERSAL_FONT_ID
 
typedef struct _UNIVERSAL_FONT_IDPUNIVERSAL_FONT_ID
 

Functions

 WINE_DEFAULT_DEBUG_CHANNEL (winspool)
 
DWORD UnicodeToAnsiInPlace (PWSTR pwszField)
 
DWORD UnicodeToAnsiZZInPlace (PWSTR pwszzField)
 
SECURITY_DESCRIPTORget_sd (SECURITY_DESCRIPTOR *sd, DWORD *size)
 
LONG WINAPI IntProtectHandle (HANDLE, BOOL)
 
BOOL WINAPI IntUnprotectHandle (HANDLE)
 
void RosConvertAnsiDevModeToUnicodeDevmode (PDEVMODEA pDevModeInput, PDEVMODEW *pDevModeOutput)
 
void RosConvertUnicodeDevModeToAnsiDevmode (PDEVMODEW pDevModeInput, PDEVMODEA pDevModeOutput)
 
BOOL WINAPI IsValidDevmodeNoSizeW (PDEVMODEW pDevmode)
 
static PWSTR AsciiToUnicode (UNICODE_STRING *usBufferPtr, LPCSTR src)
 

Variables

HANDLE hProcessHeap
 
CRITICAL_SECTION rtlCritSec
 

Macro Definition Documentation

◆ SPOOLER_HANDLE_SIG

#define SPOOLER_HANDLE_SIG   'gg'

Definition at line 32 of file precomp.h.

◆ WIN32_NO_STATUS

#define WIN32_NO_STATUS

Definition at line 11 of file precomp.h.

Typedef Documentation

◆ PSPOOLER_HANDLE

◆ PUNIVERSAL_FONT_ID

◆ SPOOLER_HANDLE

◆ UNIVERSAL_FONT_ID

Function Documentation

◆ AsciiToUnicode()

static PWSTR AsciiToUnicode ( UNICODE_STRING usBufferPtr,
LPCSTR  src 
)
inlinestatic

Definition at line 88 of file precomp.h.

89 {
90  if ( (src) )
91  {
93  return usBufferPtr->Buffer;
94  }
95  usBufferPtr->Buffer = NULL; /* so that RtlFreeUnicodeString won't barf */
96  return NULL;
97 }
smooth NULL
Definition: ftsmooth.c:416
NTSYSAPI BOOLEAN NTAPI RtlCreateUnicodeStringFromAsciiz(_Out_ PUNICODE_STRING Destination, _In_ PCSZ Source)
GLenum src
Definition: glext.h:6340

◆ get_sd()

SECURITY_DESCRIPTOR* get_sd ( SECURITY_DESCRIPTOR sd,
DWORD size 
)

Definition at line 275 of file utils.c.

276 {
277  PSID sid_group, sid_owner;
278  ACL *sacl, *dacl;
279  BOOL bSet = FALSE, bSetd = FALSE, bSets = FALSE;
280  PSECURITY_DESCRIPTOR absolute_sd, retsd;
281 
282  if ( !IsValidSecurityDescriptor( sd ) )
283  {
284  return NULL;
285  }
286 
288 
289  if ( !GetSecurityDescriptorOwner( sd, &sid_owner, &bSet ) )
290  {
291  return NULL;
292  }
293 
294  SetSecurityDescriptorOwner( &absolute_sd, sid_owner, bSet );
295 
296  if ( !GetSecurityDescriptorGroup( sd, &sid_group, &bSet ) )
297  {
298  return NULL;
299  }
300 
301  SetSecurityDescriptorGroup( &absolute_sd, sid_group, bSet );
302 
303  if ( !GetSecurityDescriptorDacl( sd, &bSetd, &dacl, &bSet ) )
304  {
305  return NULL;
306  }
307 
308  SetSecurityDescriptorDacl( &absolute_sd, bSetd, dacl, bSet );
309 
310  if ( !GetSecurityDescriptorSacl( sd, &bSets, &sacl, &bSet ) )
311  {
312  return(NULL);
313  }
314 
315  SetSecurityDescriptorSacl( &absolute_sd, bSets, sacl, bSet );
316 
317  *size = GetSecurityDescriptorLength( &absolute_sd );
318 
319  retsd = HeapAlloc( GetProcessHeap(), 0, *size );
320 
321  if ( retsd )
322  {
323  if ( !MakeSelfRelativeSD( &absolute_sd, retsd, size ) )
324  {
325  HeapFree( GetProcessHeap(), 0, retsd );
326  retsd = NULL;
327  }
328  }
329 
330  return retsd;
331 }
BOOL WINAPI IsValidSecurityDescriptor(PSECURITY_DESCRIPTOR pSecurityDescriptor)
Definition: sec.c:176
BOOL WINAPI GetSecurityDescriptorDacl(PSECURITY_DESCRIPTOR pSecurityDescriptor, LPBOOL lpbDaclPresent, PACL *pDacl, LPBOOL lpbDaclDefaulted)
Definition: sec.c:45
BOOL WINAPI InitializeSecurityDescriptor(PSECURITY_DESCRIPTOR pSecurityDescriptor, DWORD dwRevision)
Definition: security.c:808
BOOL WINAPI GetSecurityDescriptorGroup(PSECURITY_DESCRIPTOR pSecurityDescriptor, PSID *pGroup, LPBOOL lpbGroupDefaulted)
Definition: sec.c:76
#define SECURITY_DESCRIPTOR_REVISION
Definition: setypes.h:58
BOOL WINAPI GetSecurityDescriptorOwner(PSECURITY_DESCRIPTOR pSecurityDescriptor, PSID *pOwner, LPBOOL lpbOwnerDefaulted)
Definition: sec.c:103
unsigned int BOOL
Definition: ntddk_ex.h:94
smooth NULL
Definition: ftsmooth.c:416
GLsizeiptr size
Definition: glext.h:5919
#define GetProcessHeap()
Definition: compat.h:404
PVOID WINAPI HeapAlloc(HANDLE, DWORD, SIZE_T)
Definition: security.c:35
static const WCHAR sd[]
Definition: suminfo.c:287
DWORD WINAPI GetSecurityDescriptorLength(PSECURITY_DESCRIPTOR)
BOOL WINAPI GetSecurityDescriptorSacl(PSECURITY_DESCRIPTOR pSecurityDescriptor, LPBOOL lpbSaclPresent, PACL *pSacl, LPBOOL lpbSaclDefaulted)
Definition: sec.c:146
BOOL WINAPI SetSecurityDescriptorDacl(PSECURITY_DESCRIPTOR pSecurityDescriptor, BOOL bDaclPresent, PACL pDacl, BOOL bDaclDefaulted)
Definition: sec.c:262
BOOL WINAPI MakeSelfRelativeSD(PSECURITY_DESCRIPTOR pAbsoluteSecurityDescriptor, PSECURITY_DESCRIPTOR pSelfRelativeSecurityDescriptor, LPDWORD lpdwBufferLength)
Definition: sec.c:214
BOOL WINAPI SetSecurityDescriptorGroup(PSECURITY_DESCRIPTOR pSecurityDescriptor, PSID pGroup, BOOL bGroupDefaulted)
Definition: sec.c:288
#define HeapFree(x, y, z)
Definition: compat.h:403
BOOL WINAPI SetSecurityDescriptorOwner(PSECURITY_DESCRIPTOR pSecurityDescriptor, PSID pOwner, BOOL bOwnerDefaulted)
Definition: sec.c:312
BOOL WINAPI SetSecurityDescriptorSacl(PSECURITY_DESCRIPTOR pSecurityDescriptor, BOOL bSaclPresent, PACL pSacl, BOOL bSaclDefaulted)
Definition: sec.c:351

◆ IntProtectHandle()

LONG WINAPI IntProtectHandle ( HANDLE  ,
BOOL   
)

Definition at line 97 of file utils.c.

98 {
99  BOOL Bad = TRUE;
100  LONG Ret;
101  PSPOOLER_HANDLE pHandle;
102 
104 
105  _SEH2_TRY
106  {
107  pHandle = (PSPOOLER_HANDLE)hSpooler;
108  if ( pHandle && pHandle->Sig == SPOOLER_HANDLE_SIG )
109  {
110  Bad = FALSE; // Not bad.
111  }
112  }
114  {
115  }
116  _SEH2_END;
117 
118  Ret = Bad; // Set return Level to 1 if we are BAD.
119 
120  if ( Bad )
121  {
123  ERR("IPH : Printer Handle failed!\n");
124  }
125  else
126  {
127  if ( Close )
128  {
129  if ( pHandle->bShared || pHandle->cCount != 0 )
130  {
131  pHandle->bShared = TRUE;
132  Ret = 2; // Return a high level and we are shared.
133  FIXME("IPH Close : We are shared\n");
134  }
135  else
136  {
137  pHandle->bClosed = TRUE;
138  FIXME("IPH Close : closing.\n");
139  }
140  }
141  }
142 
143  if ( !Ret ) // Need to be Level 0.
144  {
145  pHandle->cCount++;
146  FIXME("IPH : Count %d\n",pHandle->cCount);
147  }
148 
150 
151  // Return Level:
152  // 2 : Close and/or shared
153  // 1 : Failed Handle
154  // 0 : In use.
155  return Ret;
156 }
#define TRUE
Definition: types.h:120
#define ERROR_INVALID_HANDLE
Definition: compat.h:88
BOOL bShared
Definition: precomp.h:47
void WINAPI EnterCriticalSection(LPCRITICAL_SECTION)
_SEH2_TRY
Definition: create.c:4226
#define SPOOLER_HANDLE_SIG
Definition: precomp.h:32
DWORD cCount
Definition: precomp.h:52
unsigned int BOOL
Definition: ntddk_ex.h:94
long LONG
Definition: pedump.c:60
#define FIXME(fmt,...)
Definition: debug.h:111
#define EXCEPTION_EXECUTE_HANDLER
Definition: excpt.h:85
DWORD_PTR Sig
Definition: precomp.h:40
#define SetLastError(x)
Definition: compat.h:418
BOOL bClosed
Definition: precomp.h:48
#define ERR(fmt,...)
Definition: debug.h:110
_SEH2_END
Definition: create.c:4400
CRITICAL_SECTION rtlCritSec
Definition: main.c:13
Definition: sacdrv.h:267
#define _SEH2_EXCEPT(...)
Definition: pseh2_64.h:6
void WINAPI LeaveCriticalSection(LPCRITICAL_SECTION)
struct _SPOOLER_HANDLE * PSPOOLER_HANDLE

Referenced by ClosePrinter(), CloseSpoolFileHandle(), CommitSpoolData(), and GetSpoolFileHandle().

◆ IntUnprotectHandle()

BOOL WINAPI IntUnprotectHandle ( HANDLE  )

Definition at line 161 of file utils.c.

162 {
163  BOOL Ret = FALSE;
164  PSPOOLER_HANDLE pHandle = (PSPOOLER_HANDLE)hSpooler;
166  if ( pHandle->bShared && --pHandle->cCount == 0 )
167  {
168  pHandle->bClosed = TRUE;
169  pHandle->bShared = FALSE;
170  Ret = TRUE;
171  }
173  FIXME("IUH : Count %d\n",pHandle->cCount);
174  if ( Ret )
175  {
176 // ClosePrinterWorker( pHandle );
177  }
178  return Ret;
179 }
#define TRUE
Definition: types.h:120
BOOL bShared
Definition: precomp.h:47
void WINAPI EnterCriticalSection(LPCRITICAL_SECTION)
DWORD cCount
Definition: precomp.h:52
unsigned int BOOL
Definition: ntddk_ex.h:94
#define FIXME(fmt,...)
Definition: debug.h:111
BOOL bClosed
Definition: precomp.h:48
CRITICAL_SECTION rtlCritSec
Definition: main.c:13
void WINAPI LeaveCriticalSection(LPCRITICAL_SECTION)
struct _SPOOLER_HANDLE * PSPOOLER_HANDLE

Referenced by CloseSpoolFileHandle(), CommitSpoolData(), and GetSpoolFileHandle().

◆ IsValidDevmodeNoSizeW()

BOOL WINAPI IsValidDevmodeNoSizeW ( PDEVMODEW  pDevmode)

Definition at line 238 of file devmode.c.

239 {
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:
282  return FALSE;
283 }
#define RTL_FIELD_SIZE(type, field)
Definition: kdb_expr.c:84
#define TRUE
Definition: types.h:120
static MINIMUM_SIZE_TABLE MinimumSizeW[]
Definition: devmode.c:57
DWORD dmFields
Definition: wingdi.h:1621
WORD dmDriverExtra
Definition: wingdi.h:1620
WCHAR dmFormName[CCHFORMNAME]
Definition: wingdi.h:1644
#define DM_FORMNAME
Definition: wingdi.h:1265
#define TRACE(s)
Definition: solgame.cpp:4
WORD dmSize
Definition: wingdi.h:1619
unsigned short WORD
Definition: ntddk_ex.h:93
static __inline void _FixStringW(PWSTR String, DWORD cbString)
Definition: devmode.c:116
#define SetLastError(x)
Definition: compat.h:418
WCHAR dmDeviceName[CCHDEVICENAME]
Definition: wingdi.h:1616
#define ERROR_INVALID_DATA
Definition: winerror.h:116
#define FIELD_OFFSET(t, f)
Definition: typedefs.h:254
static const EHCI_PERIOD pTable[]
Definition: usbehci.c:29

Referenced by AddPrinterW(), DeviceCapabilitiesW(), DocumentPropertiesW(), QueryColorProfile(), and SetPrinterW().

◆ RosConvertAnsiDevModeToUnicodeDevmode()

void RosConvertAnsiDevModeToUnicodeDevmode ( PDEVMODEA  pDevModeInput,
PDEVMODEW pDevModeOutput 
)

Definition at line 285 of file devmode.c.

286 {
287  // FIXME: This function should become ConvertAnsiDevModeToUnicodeDevmode when its parameters are known!
288 
289  // Check if a pDevModeInput and pDevModeOutput are both not NULL.
290  if (!pDevModeInput || !pDevModeOutput)
291  return;
292 
293  *pDevModeOutput = GdiConvertToDevmodeW(pDevModeInput);
294 }
DEVMODEW *WINAPI GdiConvertToDevmodeW(const DEVMODEA *)
Definition: misc.c:969

Referenced by AddPrinterA(), DeviceCapabilitiesA(), DocumentPropertiesA(), ResetPrinterA(), and SetPrinterA().

◆ RosConvertUnicodeDevModeToAnsiDevmode()

void RosConvertUnicodeDevModeToAnsiDevmode ( PDEVMODEW  pDevModeInput,
PDEVMODEA  pDevModeOutput 
)

Definition at line 353 of file devmode.c.

354 {
355  PDEVMODEA pTmp;
356 
357  // FIXME: This function should become ConvertUnicodeDevModeToAnsiDevmode when its parameters are known!
358 
359  // Check if a pDevModeInput and pDevModeOutput are both not NULL.
360  if (!pDevModeInput || !pDevModeOutput)
361  return;
362 
363  pTmp = _ConvertToDevmodeA(pDevModeInput);
364  memcpy( pDevModeOutput, pTmp, pTmp->dmSize + pTmp->dmDriverExtra); // Copy into a Wide char (Larger) buffer.
365  HeapFree(hProcessHeap, 0, pTmp);
366 }
WORD dmSize
Definition: wingdi.h:1567
WORD dmDriverExtra
Definition: wingdi.h:1568
static __inline DEVMODEA * _ConvertToDevmodeA(const DEVMODEW *dmW)
Definition: devmode.c:298
#define memcpy(s1, s2, n)
Definition: mkisofs.h:878
#define HeapFree(x, y, z)
Definition: compat.h:403
HANDLE hProcessHeap
Definition: kbswitch.c:25

Referenced by DocumentPropertiesA(), EnumJobsA(), EnumPrintersA(), GetJobA(), and GetPrinterA().

◆ UnicodeToAnsiInPlace()

DWORD UnicodeToAnsiInPlace ( PWSTR  pwszField)

Definition at line 18 of file utils.c.

19 {
20  PSTR pszTemp;
21  DWORD cch;
22 
23  /*
24  * Map the incoming Unicode pwszField string to an ANSI one here so that we can do
25  * in-place conversion. We read the Unicode input and then we write back the ANSI
26  * conversion into the same buffer for use with our GetPrinterDriverA function
27  */
28  PSTR pszField = (PSTR)pwszField;
29 
30  if (!pwszField)
31  {
32  return ERROR_SUCCESS;
33  }
34 
35  cch = wcslen(pwszField);
36  if (cch == 0)
37  {
38  return ERROR_SUCCESS;
39  }
40 
41  pszTemp = HeapAlloc(hProcessHeap, 0, (cch + 1) * sizeof(CHAR));
42  if (!pszTemp)
43  {
44  ERR("HeapAlloc failed!\n");
46  }
47 
48  WideCharToMultiByte(CP_ACP, 0, pwszField, -1, pszTemp, cch + 1, NULL, NULL);
49  StringCchCopyA(pszField, cch + 1, pszTemp);
50 
51  HeapFree(hProcessHeap, 0, pszTemp);
52 
53  return ERROR_SUCCESS;
54 }
#define ERROR_SUCCESS
Definition: deptool.c:10
#define WideCharToMultiByte
Definition: compat.h:101
#define CP_ACP
Definition: compat.h:99
char CHAR
Definition: xmlstorage.h:175
#define ERROR_NOT_ENOUGH_MEMORY
Definition: dderror.h:7
static DWORD DWORD void LPSTR DWORD cch
Definition: str.c:201
smooth NULL
Definition: ftsmooth.c:416
PVOID WINAPI HeapAlloc(HANDLE, DWORD, SIZE_T)
unsigned long DWORD
Definition: ntddk_ex.h:95
#define ERR(fmt,...)
Definition: debug.h:110
STRSAFEAPI StringCchCopyA(STRSAFE_LPSTR pszDest, size_t cchDest, STRSAFE_LPCSTR pszSrc)
Definition: strsafe.h:145
signed char * PSTR
Definition: retypes.h:7
size_t __cdecl wcslen(_In_z_ const wchar_t *_Str)
#define HeapFree(x, y, z)
Definition: compat.h:403
HANDLE hProcessHeap
Definition: kbswitch.c:25

Referenced by AddJobA(), EnumFormsA(), EnumJobsA(), EnumPrinterDriversA(), GetFormA(), GetJobA(), and GetPrinterDriverA().

◆ UnicodeToAnsiZZInPlace()

DWORD UnicodeToAnsiZZInPlace ( PWSTR  pwszzField)

Definition at line 68 of file utils.c.

69 {
70  PSTR pszTemp;
71  INT len, lenW;
72  PSTR pszField = (PSTR)pwszzField;
73 
74  lenW = multi_sz_lenW(pwszzField);
75  if (lenW == 0)
76  {
77  return ERROR_SUCCESS;
78  }
79 
80  len = WideCharToMultiByte(CP_ACP, 0, pwszzField, lenW, NULL, 0, NULL, NULL);
81 
82  pszTemp = HeapAlloc(GetProcessHeap(), 0, len * sizeof(WCHAR));
83 
84  WideCharToMultiByte(CP_ACP, 0, pwszzField, lenW, pszTemp, len, NULL, NULL);
85 
86  StringCchCopyA(pszField, len, pszTemp);
87 
88  HeapFree(hProcessHeap, 0, pszTemp);
89 
90  return ERROR_SUCCESS;
91 }
#define ERROR_SUCCESS
Definition: deptool.c:10
#define WideCharToMultiByte
Definition: compat.h:101
#define CP_ACP
Definition: compat.h:99
int32_t INT
Definition: typedefs.h:57
smooth NULL
Definition: ftsmooth.c:416
#define GetProcessHeap()
Definition: compat.h:404
PVOID WINAPI HeapAlloc(HANDLE, DWORD, SIZE_T)
__wchar_t WCHAR
Definition: xmlstorage.h:180
GLenum GLsizei len
Definition: glext.h:6722
STRSAFEAPI StringCchCopyA(STRSAFE_LPSTR pszDest, size_t cchDest, STRSAFE_LPCSTR pszSrc)
Definition: strsafe.h:145
signed char * PSTR
Definition: retypes.h:7
static int multi_sz_lenW(const WCHAR *str)
Definition: utils.c:56
#define HeapFree(x, y, z)
Definition: compat.h:403
HANDLE hProcessHeap
Definition: kbswitch.c:25

Referenced by EnumPrinterDriversA(), and GetPrinterDriverA().

◆ WINE_DEFAULT_DEBUG_CHANNEL()

WINE_DEFAULT_DEBUG_CHANNEL ( winspool  )

Variable Documentation

◆ hProcessHeap

◆ rtlCritSec

CRITICAL_SECTION rtlCritSec

Definition at line 13 of file main.c.

Referenced by DllMain(), IntProtectHandle(), and IntUnprotectHandle().