ReactOS 0.4.15-dev-7693-gd0e2924
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}
#define ERR(fmt,...)
Definition: debug.h:110
#define ERROR_SUCCESS
Definition: deptool.c:10
#define NULL
Definition: types.h:112
#define TRUE
Definition: types.h:120
unsigned long DWORD
Definition: ntddk_ex.h:95
static const MARSHALLING AddJobInfo1Marshalling
Definition: jobs.h:8
BOOL WINAPI MarshallDownStructure(PVOID pStructure, const MARSHALLING_INFO *pInfo, DWORD cbStructureSize, BOOL bSomeBoolean)
Definition: marshalling.c:38
BYTE * PBYTE
Definition: pedump.c:66
RPC_STATUS WINAPI RpcRevertToSelf(void)
Definition: rpc_binding.c:1463
RPC_STATUS WINAPI RpcImpersonateClient(RPC_BINDING_HANDLE BindingHandle)
Definition: rpc_binding.c:1056
MARSHALLING_INFO pInfo[]
Definition: marshalling.h:26
DWORD cbStructureSize
Definition: marshalling.h:25
PVOID WINAPI AlignRpcPtr(PVOID pBuffer, PDWORD pcbBuffer)
Definition: memory.c:29
PDWORD WINAPI UndoAlignRpcPtr(PVOID pDestinationBuffer, PVOID pSourceBuffer, DWORD cbBuffer, PDWORD pcbNeeded)
Definition: memory.c:239
DWORD WINAPI GetLastError(void)
Definition: except.c:1042
_In_ DWORD _Out_ PDWORD pcbNeeded
Definition: winddi.h:3828
WINBOOL WINAPI AddJobW(HANDLE hPrinter, DWORD Level, LPBYTE pData, DWORD cbBuf, LPDWORD pcbNeeded)
_IRQL_requires_same_ typedef _In_ ULONG _In_ UCHAR Level
Definition: wmitypes.h:56

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}
static const MARSHALLING * pJobInfoMarshalling[]
Definition: jobs.h:67
BOOL WINAPI MarshallDownStructuresArray(PVOID pStructuresArray, DWORD cElements, const MARSHALLING_INFO *pInfo, DWORD cbStructureSize, BOOL bSomeBoolean)
Definition: marshalling.c:91
#define ASSERT(a)
Definition: mode.c:44
WINBOOL WINAPI EnumJobsW(HANDLE hPrinter, DWORD FirstJob, DWORD NoJobs, DWORD Level, LPBYTE pJob, DWORD cbBuf, LPDWORD pcbNeeded, LPDWORD pcReturned)

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
104 UndoAlignRpcPtr(pJob, pJobAligned, cbBuf, pcbNeeded);
105
106 return dwErrorCode;
107}
WINBOOL WINAPI GetJobW(HANDLE hPrinter, DWORD JobId, DWORD Level, LPBYTE pJob, DWORD cbBuf, LPDWORD pcbNeeded)

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
125 return dwErrorCode;
126}
WINBOOL WINAPI ScheduleJob(HANDLE hPrinter, DWORD JobId)
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
145 return dwErrorCode;
146}
Definition: shell.h:41
union _WINSPOOL_JOB_CONTAINER::@3439 JobInfo
WINSPOOL_JOB_INFO_1 * Level1
Definition: winspool.idl:635
WINBOOL WINAPI SetJobW(HANDLE hPrinter, DWORD JobId, DWORD Level, LPBYTE pJob, DWORD Command)

Referenced by pointer_default(), and SetJobW().