ReactOS  0.4.15-dev-509-g96a357b
jobs.c File Reference
#include "precomp.h"
#include <marshalling/jobs.h>
Include dependency graph for jobs.c:

Go to the source code of this file.

Functions

DWORD _RpcAddJob (WINSPOOL_PRINTER_HANDLE hPrinter, DWORD Level, BYTE *pAddJob, DWORD cbBuf, DWORD *pcbNeeded)
 
DWORD _RpcEnumJobs (WINSPOOL_PRINTER_HANDLE hPrinter, DWORD FirstJob, DWORD NoJobs, DWORD Level, BYTE *pJob, DWORD cbBuf, DWORD *pcbNeeded, DWORD *pcReturned)
 
DWORD _RpcGetJob (WINSPOOL_PRINTER_HANDLE hPrinter, DWORD JobId, DWORD Level, BYTE *pJob, DWORD cbBuf, DWORD *pcbNeeded)
 
DWORD _RpcScheduleJob (WINSPOOL_PRINTER_HANDLE hPrinter, DWORD JobId)
 
DWORD _RpcSetJob (WINSPOOL_PRINTER_HANDLE hPrinter, DWORD JobId, WINSPOOL_JOB_CONTAINER *pJobContainer, DWORD Command)
 

Function Documentation

◆ _RpcAddJob()

DWORD _RpcAddJob ( WINSPOOL_PRINTER_HANDLE  hPrinter,
DWORD  Level,
BYTE pAddJob,
DWORD  cbBuf,
DWORD pcbNeeded 
)

Definition at line 12 of file jobs.c.

13 {
14  DWORD dwErrorCode;
15  PBYTE pAddJobAligned;
16 
17  dwErrorCode = RpcImpersonateClient(NULL);
18  if (dwErrorCode != ERROR_SUCCESS)
19  {
20  ERR("RpcImpersonateClient failed with error %lu!\n", dwErrorCode);
21  return dwErrorCode;
22  }
23 
24  pAddJobAligned = AlignRpcPtr(pAddJob, &cbBuf);
25 
26  if (AddJobW(hPrinter, Level, pAddJobAligned, cbBuf, pcbNeeded))
27  {
28  // Replace absolute pointer addresses in the output by relative offsets.
30  }
31  else
32  {
33  dwErrorCode = GetLastError();
34  }
35 
37  UndoAlignRpcPtr(pAddJob, pAddJobAligned, cbBuf, pcbNeeded);
38 
39  return dwErrorCode;
40 }
DWORD cbStructureSize
Definition: marshalling.h:25
MARSHALLING_INFO pInfo[]
Definition: marshalling.h:26
#define TRUE
Definition: types.h:120
static const MARSHALLING AddJobInfo1Marshalling
Definition: jobs.h:8
#define ERROR_SUCCESS
Definition: deptool.c:10
DWORD WINAPI GetLastError(VOID)
Definition: except.c:1059
_IRQL_requires_same_ typedef _In_ ULONG _In_ UCHAR Level
Definition: wmitypes.h:55
smooth NULL
Definition: ftsmooth.c:416
BOOL WINAPI AddJobW(HANDLE hPrinter, DWORD Level, PBYTE pData, DWORD cbBuf, PDWORD pcbNeeded)
Definition: jobs.c:11
RPC_STATUS WINAPI RpcRevertToSelf(void)
Definition: rpc_binding.c:1459
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
#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
BYTE * PBYTE
Definition: pedump.c:66

Referenced by AddJobW(), and pointer_default().

◆ _RpcEnumJobs()

DWORD _RpcEnumJobs ( WINSPOOL_PRINTER_HANDLE  hPrinter,
DWORD  FirstJob,
DWORD  NoJobs,
DWORD  Level,
BYTE pJob,
DWORD  cbBuf,
DWORD pcbNeeded,
DWORD pcReturned 
)

Definition at line 43 of file jobs.c.

44 {
45  DWORD dwErrorCode;
46  PBYTE pJobAligned;
47 
48  dwErrorCode = RpcImpersonateClient(NULL);
49  if (dwErrorCode != ERROR_SUCCESS)
50  {
51  ERR("RpcImpersonateClient failed with error %lu!\n", dwErrorCode);
52  return dwErrorCode;
53  }
54 
55  pJobAligned = AlignRpcPtr(pJob, &cbBuf);
56 
57  if (EnumJobsW(hPrinter, FirstJob, NoJobs, Level, pJobAligned, cbBuf, pcbNeeded, pcReturned))
58  {
59  // Replace absolute pointer addresses in the output by relative offsets for JOB_INFO_1W and JOB_INFO_2W.
60  if (Level <= 2)
61  {
62  ASSERT(Level >= 1);
63  MarshallDownStructuresArray(pJobAligned, *pcReturned, pJobInfoMarshalling[Level]->pInfo, pJobInfoMarshalling[Level]->cbStructureSize, TRUE);
64  }
65  }
66  else
67  {
68  dwErrorCode = GetLastError();
69  }
70 
72  UndoAlignRpcPtr(pJob, pJobAligned, cbBuf, pcbNeeded);
73 
74  return dwErrorCode;
75 }
BOOL WINAPI EnumJobsW(HANDLE hPrinter, DWORD FirstJob, DWORD NoJobs, DWORD Level, PBYTE pJob, DWORD cbBuf, PDWORD pcbNeeded, PDWORD pcReturned)
Definition: jobs.c:26
#define TRUE
Definition: types.h:120
#define ERROR_SUCCESS
Definition: deptool.c:10
DWORD WINAPI GetLastError(VOID)
Definition: except.c:1059
_IRQL_requires_same_ typedef _In_ ULONG _In_ UCHAR Level
Definition: wmitypes.h:55
static const MARSHALLING * pJobInfoMarshalling[]
Definition: jobs.h:67
smooth NULL
Definition: ftsmooth.c:416
RPC_STATUS WINAPI RpcRevertToSelf(void)
Definition: rpc_binding.c:1459
unsigned long DWORD
Definition: ntddk_ex.h:95
ASSERT((InvokeOnSuccess||InvokeOnError||InvokeOnCancel) ?(CompletionRoutine !=NULL) :TRUE)
#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
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 EnumJobsW(), and pointer_default().

◆ _RpcGetJob()

DWORD _RpcGetJob ( WINSPOOL_PRINTER_HANDLE  hPrinter,
DWORD  JobId,
DWORD  Level,
BYTE pJob,
DWORD  cbBuf,
DWORD pcbNeeded 
)

Definition at line 78 of file jobs.c.

79 {
80  DWORD dwErrorCode;
81  PBYTE pJobAligned;
82 
83  dwErrorCode = RpcImpersonateClient(NULL);
84  if (dwErrorCode != ERROR_SUCCESS)
85  {
86  ERR("RpcImpersonateClient failed with error %lu!\n", dwErrorCode);
87  return dwErrorCode;
88  }
89 
90  pJobAligned = AlignRpcPtr(pJob, &cbBuf);
91 
92  if (GetJobW(hPrinter, JobId, Level, pJobAligned, cbBuf, pcbNeeded))
93  {
94  // Replace absolute pointer addresses in the output by relative offsets.
95  ASSERT(Level >= 1 && Level <= 2);
96  MarshallDownStructure(pJobAligned, pJobInfoMarshalling[Level]->pInfo, pJobInfoMarshalling[Level]->cbStructureSize, TRUE);
97  }
98  else
99  {
100  dwErrorCode = GetLastError();
101  }
102 
103  RpcRevertToSelf();
104  UndoAlignRpcPtr(pJob, pJobAligned, cbBuf, pcbNeeded);
105 
106  return dwErrorCode;
107 }
#define TRUE
Definition: types.h:120
#define ERROR_SUCCESS
Definition: deptool.c:10
DWORD WINAPI GetLastError(VOID)
Definition: except.c:1059
_IRQL_requires_same_ typedef _In_ ULONG _In_ UCHAR Level
Definition: wmitypes.h:55
static const MARSHALLING * pJobInfoMarshalling[]
Definition: jobs.h:67
smooth NULL
Definition: ftsmooth.c:416
RPC_STATUS WINAPI RpcRevertToSelf(void)
Definition: rpc_binding.c:1459
unsigned long DWORD
Definition: ntddk_ex.h:95
ASSERT((InvokeOnSuccess||InvokeOnError||InvokeOnCancel) ?(CompletionRoutine !=NULL) :TRUE)
BOOL WINAPI MarshallDownStructure(PVOID pStructure, const MARSHALLING_INFO *pInfo, DWORD cbStructureSize, BOOL bSomeBoolean)
Definition: marshalling.c:38
#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
BOOL WINAPI GetJobW(HANDLE hPrinter, DWORD JobId, DWORD Level, PBYTE pJob, DWORD cbBuf, PDWORD pcbNeeded)
Definition: jobs.c:41
BYTE * PBYTE
Definition: pedump.c:66

Referenced by GetJobW(), and pointer_default().

◆ _RpcScheduleJob()

DWORD _RpcScheduleJob ( WINSPOOL_PRINTER_HANDLE  hPrinter,
DWORD  JobId 
)

Definition at line 110 of file jobs.c.

111 {
112  DWORD dwErrorCode;
113 
114  dwErrorCode = RpcImpersonateClient(NULL);
115  if (dwErrorCode != ERROR_SUCCESS)
116  {
117  ERR("RpcImpersonateClient failed with error %lu!\n", dwErrorCode);
118  return dwErrorCode;
119  }
120 
121  if (!ScheduleJob(hPrinter, JobId))
122  dwErrorCode = GetLastError();
123 
124  RpcRevertToSelf();
125  return dwErrorCode;
126 }
#define ERROR_SUCCESS
Definition: deptool.c:10
DWORD WINAPI GetLastError(VOID)
Definition: except.c:1059
smooth NULL
Definition: ftsmooth.c:416
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
BOOL WINAPI ScheduleJob(HANDLE hPrinter, DWORD dwJobID)
Definition: jobs.c:56

Referenced by EndDocPrinter(), pointer_default(), and ScheduleJob().

◆ _RpcSetJob()

DWORD _RpcSetJob ( WINSPOOL_PRINTER_HANDLE  hPrinter,
DWORD  JobId,
WINSPOOL_JOB_CONTAINER pJobContainer,
DWORD  Command 
)

Definition at line 129 of file jobs.c.

130 {
131  DWORD dwErrorCode;
132 
133  dwErrorCode = RpcImpersonateClient(NULL);
134  if (dwErrorCode != ERROR_SUCCESS)
135  {
136  ERR("RpcImpersonateClient failed with error %lu!\n", dwErrorCode);
137  return dwErrorCode;
138  }
139 
140  // pJobContainer->JobInfo is a union of pointers, so we can just convert any element to our BYTE pointer.
141  if (!SetJobW(hPrinter, JobId, pJobContainer->Level, (PBYTE)pJobContainer->JobInfo.Level1, Command))
142  dwErrorCode = GetLastError();
143 
144  RpcRevertToSelf();
145  return dwErrorCode;
146 }
#define ERROR_SUCCESS
Definition: deptool.c:10
BOOL WINAPI SetJobW(HANDLE hPrinter, DWORD JobId, DWORD Level, PBYTE pJobInfo, DWORD Command)
Definition: jobs.c:71
DWORD WINAPI GetLastError(VOID)
Definition: except.c:1059
Definition: shell.h:41
union _WINSPOOL_JOB_CONTAINER::@3361 JobInfo
smooth NULL
Definition: ftsmooth.c:416
WINSPOOL_JOB_INFO_1 * Level1
Definition: winspool.idl:635
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
BYTE * PBYTE
Definition: pedump.c:66

Referenced by pointer_default(), and SetJobW().