ReactOS  0.4.15-dev-3456-g4a17d4b
forms.c File Reference
#include "precomp.h"
#include <marshalling/forms.h>
Include dependency graph for forms.c:

Go to the source code of this file.

Functions

DWORD _RpcAddForm (WINSPOOL_PRINTER_HANDLE hPrinter, WINSPOOL_FORM_CONTAINER *pFormInfoContainer)
 
DWORD _RpcDeleteForm (WINSPOOL_PRINTER_HANDLE hPrinter, WCHAR *pFormName)
 
DWORD _RpcEnumForms (WINSPOOL_PRINTER_HANDLE hPrinter, DWORD Level, BYTE *pForm, DWORD cbBuf, DWORD *pcbNeeded, DWORD *pcReturned)
 
DWORD _RpcGetForm (WINSPOOL_PRINTER_HANDLE hPrinter, WCHAR *pFormName, DWORD Level, BYTE *pForm, DWORD cbBuf, DWORD *pcbNeeded)
 
DWORD _RpcSetForm (WINSPOOL_PRINTER_HANDLE hPrinter, WCHAR *pFormName, WINSPOOL_FORM_CONTAINER *pFormInfoContainer)
 

Function Documentation

◆ _RpcAddForm()

DWORD _RpcAddForm ( WINSPOOL_PRINTER_HANDLE  hPrinter,
WINSPOOL_FORM_CONTAINER pFormInfoContainer 
)

Definition at line 12 of file forms.c.

13 {
14  DWORD dwErrorCode;
15 
16  dwErrorCode = RpcImpersonateClient(NULL);
17  if (dwErrorCode != ERROR_SUCCESS)
18  {
19  ERR("RpcImpersonateClient failed with error %lu!\n", dwErrorCode);
20  return dwErrorCode;
21  }
22 
23  if (!AddFormW(hPrinter, pFormInfoContainer->Level, (PBYTE)pFormInfoContainer->FormInfo.pFormInfo1))
24  dwErrorCode = GetLastError();
25 
27  return dwErrorCode;
28 }
#define ERROR_SUCCESS
Definition: deptool.c:10
WINSPOOL_FORM_INFO_1 * pFormInfo1
Definition: winspool.idl:620
DWORD WINAPI GetLastError(VOID)
Definition: except.c:1040
union _WINSPOOL_FORM_CONTAINER::@3353 FormInfo
BOOL WINAPI AddFormW(HANDLE hPrinter, DWORD Level, PBYTE pForm)
Definition: forms.c:11
RPC_STATUS WINAPI RpcRevertToSelf(void)
Definition: rpc_binding.c:1459
unsigned long DWORD
Definition: ntddk_ex.h:95
#define ERR(fmt,...)
Definition: debug.h:110
RPC_STATUS WINAPI RpcImpersonateClient(RPC_BINDING_HANDLE BindingHandle)
Definition: rpc_binding.c:1052
#define NULL
Definition: types.h:112
BYTE * PBYTE
Definition: pedump.c:66

Referenced by AddFormW(), and pointer_default().

◆ _RpcDeleteForm()

DWORD _RpcDeleteForm ( WINSPOOL_PRINTER_HANDLE  hPrinter,
WCHAR pFormName 
)

Definition at line 31 of file forms.c.

32 {
33  DWORD dwErrorCode;
34 
35  dwErrorCode = RpcImpersonateClient(NULL);
36  if (dwErrorCode != ERROR_SUCCESS)
37  {
38  ERR("RpcImpersonateClient failed with error %lu!\n", dwErrorCode);
39  return dwErrorCode;
40  }
41 
42  if (!DeleteFormW(hPrinter, pFormName))
43  dwErrorCode = GetLastError();
44 
46  return dwErrorCode;
47 }
#define ERROR_SUCCESS
Definition: deptool.c:10
DWORD WINAPI GetLastError(VOID)
Definition: except.c:1040
RPC_STATUS WINAPI RpcRevertToSelf(void)
Definition: rpc_binding.c:1459
BOOL WINAPI DeleteFormW(HANDLE hPrinter, PWSTR pFormName)
Definition: forms.c:26
unsigned long DWORD
Definition: ntddk_ex.h:95
#define ERR(fmt,...)
Definition: debug.h:110
RPC_STATUS WINAPI RpcImpersonateClient(RPC_BINDING_HANDLE BindingHandle)
Definition: rpc_binding.c:1052
#define NULL
Definition: types.h:112

Referenced by DeleteFormW(), and pointer_default().

◆ _RpcEnumForms()

DWORD _RpcEnumForms ( WINSPOOL_PRINTER_HANDLE  hPrinter,
DWORD  Level,
BYTE pForm,
DWORD  cbBuf,
DWORD pcbNeeded,
DWORD pcReturned 
)

Definition at line 50 of file forms.c.

51 {
52  DWORD dwErrorCode;
53  PBYTE pFormsEnumAligned;
54 
55  dwErrorCode = RpcImpersonateClient(NULL);
56  if (dwErrorCode != ERROR_SUCCESS)
57  {
58  ERR("RpcImpersonateClient failed with error %lu!\n", dwErrorCode);
59  return dwErrorCode;
60  }
61 
62  pFormsEnumAligned = AlignRpcPtr(pForm, &cbBuf);
63 
64  if (EnumFormsW(hPrinter, Level, pFormsEnumAligned, cbBuf, pcbNeeded, pcReturned))
65  {
66  // Replace absolute pointer addresses in the output by relative offsets.
67  ASSERT(Level >= 1 && Level <= 2);
68  MarshallDownStructuresArray(pFormsEnumAligned, *pcReturned, pFormInfoMarshalling[Level]->pInfo, pFormInfoMarshalling[Level]->cbStructureSize, TRUE);
69  }
70  else
71  {
72  dwErrorCode = GetLastError();
73  }
74 
76  UndoAlignRpcPtr(pForm, pFormsEnumAligned, cbBuf, pcbNeeded);
77 
78  return dwErrorCode;
79 }
#define ERROR_SUCCESS
Definition: deptool.c:10
#define TRUE
Definition: types.h:120
DWORD WINAPI GetLastError(VOID)
Definition: except.c:1040
_IRQL_requires_same_ typedef _In_ ULONG _In_ UCHAR Level
Definition: wmitypes.h:55
RPC_STATUS WINAPI RpcRevertToSelf(void)
Definition: rpc_binding.c:1459
#define ASSERT(a)
Definition: mode.c:44
unsigned long DWORD
Definition: ntddk_ex.h:95
static const MARSHALLING * pFormInfoMarshalling[]
Definition: forms.h:36
#define ERR(fmt,...)
Definition: debug.h:110
PVOID WINAPI AlignRpcPtr(PVOID pBuffer, PDWORD pcbBuffer)
Definition: memory.c:29
_In_ DWORD _Out_ PDWORD pcbNeeded
Definition: winddi.h:3827
PDWORD WINAPI UndoAlignRpcPtr(PVOID pDestinationBuffer, PVOID pSourceBuffer, DWORD cbBuffer, PDWORD pcbNeeded)
Definition: memory.c:239
BOOL WINAPI EnumFormsW(HANDLE hPrinter, DWORD Level, PBYTE pForm, DWORD cbBuf, PDWORD pcbNeeded, PDWORD pcReturned)
Definition: forms.c:41
RPC_STATUS WINAPI RpcImpersonateClient(RPC_BINDING_HANDLE BindingHandle)
Definition: rpc_binding.c:1052
#define NULL
Definition: types.h:112
BYTE * PBYTE
Definition: pedump.c:66
BOOL WINAPI MarshallDownStructuresArray(PVOID pStructuresArray, DWORD cElements, const MARSHALLING_INFO *pInfo, DWORD cbStructureSize, BOOL bSomeBoolean)
Definition: marshalling.c:91

Referenced by EnumFormsW(), and pointer_default().

◆ _RpcGetForm()

DWORD _RpcGetForm ( WINSPOOL_PRINTER_HANDLE  hPrinter,
WCHAR pFormName,
DWORD  Level,
BYTE pForm,
DWORD  cbBuf,
DWORD pcbNeeded 
)

Definition at line 82 of file forms.c.

83 {
84  DWORD dwErrorCode;
85  PBYTE pFormAligned;
86 
87  dwErrorCode = RpcImpersonateClient(NULL);
88  if (dwErrorCode != ERROR_SUCCESS)
89  {
90  ERR("RpcImpersonateClient failed with error %lu!\n", dwErrorCode);
91  return dwErrorCode;
92  }
93 
94  pFormAligned = AlignRpcPtr(pForm, &cbBuf);
95 
96  if (GetFormW(hPrinter, pFormName, Level, pFormAligned, cbBuf, pcbNeeded))
97  {
98  // Replace absolute pointer addresses in the output by relative offsets.
99  ASSERT(Level >= 1 && Level <= 2);
100  MarshallDownStructure(pFormAligned, pFormInfoMarshalling[Level]->pInfo, pFormInfoMarshalling[Level]->cbStructureSize, TRUE);
101  }
102  else
103  {
104  dwErrorCode = GetLastError();
105  }
106 
107  RpcRevertToSelf();
108  UndoAlignRpcPtr(pForm, pFormAligned, cbBuf, pcbNeeded);
109 
110  return dwErrorCode;
111 }
#define ERROR_SUCCESS
Definition: deptool.c:10
#define TRUE
Definition: types.h:120
DWORD WINAPI GetLastError(VOID)
Definition: except.c:1040
_IRQL_requires_same_ typedef _In_ ULONG _In_ UCHAR Level
Definition: wmitypes.h:55
RPC_STATUS WINAPI RpcRevertToSelf(void)
Definition: rpc_binding.c:1459
#define ASSERT(a)
Definition: mode.c:44
unsigned long DWORD
Definition: ntddk_ex.h:95
BOOL WINAPI MarshallDownStructure(PVOID pStructure, const MARSHALLING_INFO *pInfo, DWORD cbStructureSize, BOOL bSomeBoolean)
Definition: marshalling.c:38
static const MARSHALLING * pFormInfoMarshalling[]
Definition: forms.h:36
#define ERR(fmt,...)
Definition: debug.h:110
PVOID WINAPI AlignRpcPtr(PVOID pBuffer, PDWORD pcbBuffer)
Definition: memory.c:29
_In_ DWORD _Out_ PDWORD pcbNeeded
Definition: winddi.h:3827
PDWORD WINAPI UndoAlignRpcPtr(PVOID pDestinationBuffer, PVOID pSourceBuffer, DWORD cbBuffer, PDWORD pcbNeeded)
Definition: memory.c:239
RPC_STATUS WINAPI RpcImpersonateClient(RPC_BINDING_HANDLE BindingHandle)
Definition: rpc_binding.c:1052
#define NULL
Definition: types.h:112
BYTE * PBYTE
Definition: pedump.c:66
BOOL WINAPI GetFormW(HANDLE hPrinter, PWSTR pFormName, DWORD Level, PBYTE pForm, DWORD cbBuf, PDWORD pcbNeeded)
Definition: forms.c:62

Referenced by GetFormW(), and pointer_default().

◆ _RpcSetForm()

DWORD _RpcSetForm ( WINSPOOL_PRINTER_HANDLE  hPrinter,
WCHAR pFormName,
WINSPOOL_FORM_CONTAINER pFormInfoContainer 
)

Definition at line 114 of file forms.c.

115 {
116  DWORD dwErrorCode;
117 
118  dwErrorCode = RpcImpersonateClient(NULL);
119  if (dwErrorCode != ERROR_SUCCESS)
120  {
121  ERR("RpcImpersonateClient failed with error %lu!\n", dwErrorCode);
122  return dwErrorCode;
123  }
124 
125  if (!SetFormW(hPrinter, pFormName, pFormInfoContainer->Level, (PBYTE)pFormInfoContainer->FormInfo.pFormInfo1))
126  dwErrorCode = GetLastError();
127 
128  RpcRevertToSelf();
129  return dwErrorCode;
130 }
#define ERROR_SUCCESS
Definition: deptool.c:10
WINSPOOL_FORM_INFO_1 * pFormInfo1
Definition: winspool.idl:620
DWORD WINAPI GetLastError(VOID)
Definition: except.c:1040
BOOL WINAPI SetFormW(HANDLE hPrinter, PWSTR pFormName, DWORD Level, PBYTE pForm)
Definition: forms.c:83
union _WINSPOOL_FORM_CONTAINER::@3353 FormInfo
RPC_STATUS WINAPI RpcRevertToSelf(void)
Definition: rpc_binding.c:1459
unsigned long DWORD
Definition: ntddk_ex.h:95
#define ERR(fmt,...)
Definition: debug.h:110
RPC_STATUS WINAPI RpcImpersonateClient(RPC_BINDING_HANDLE BindingHandle)
Definition: rpc_binding.c:1052
#define NULL
Definition: types.h:112
BYTE * PBYTE
Definition: pedump.c:66

Referenced by pointer_default(), and SetFormW().