ReactOS  0.4.14-dev-358-gbef841c
main.c
Go to the documentation of this file.
1 /*
2  * PROJECT: ReactOS Spooler API
3  * LICENSE: GPL-2.0+ (https://spdx.org/licenses/GPL-2.0+)
4  * PURPOSE: Main functions
5  * COPYRIGHT: Copyright 2015-2017 Colin Finck (colin@reactos.org)
6  */
7 
8 #include "precomp.h"
9 
10 // Global Variables
12 
13 
16 {
18  PWSTR wszStringBinding;
20 
21  // Get us a string binding handle from the supplied connection information
22  Status = RpcStringBindingComposeW(NULL, L"ncalrpc", NULL, L"spoolss", NULL, &wszStringBinding);
23  if (Status != RPC_S_OK)
24  {
25  ERR("RpcStringBindingComposeW failed with status %ld!\n", Status);
26  return NULL;
27  }
28 
29  // Get a handle_t binding handle from the string binding handle
30  Status = RpcBindingFromStringBindingW(wszStringBinding, &hBinding);
31  if (Status != RPC_S_OK)
32  {
33  ERR("RpcBindingFromStringBindingW failed with status %ld!\n", Status);
34  return NULL;
35  }
36 
37  // Free the string binding handle
38  Status = RpcStringFreeW(&wszStringBinding);
39  if (Status != RPC_S_OK)
40  {
41  ERR("RpcStringFreeW failed with status %ld!\n", Status);
42  return NULL;
43  }
44 
45  return hBinding;
46 }
47 
48 void __RPC_USER
50 {
52 
54  if (Status != RPC_S_OK)
55  {
56  ERR("RpcBindingFree failed with status %ld!\n", Status);
57  }
58 }
59 
62 {
64 }
65 
66 void __RPC_USER
68 {
70 }
71 
73 DllMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved)
74 {
75  TRACE("DllMain(%p, %lu, %p)\n", hinstDLL, fdwReason, lpvReserved);
76 
77  switch (fdwReason)
78  {
79  case DLL_PROCESS_ATTACH:
80  DisableThreadLibraryCalls(hinstDLL);
82  break;
83  }
84 
85  return TRUE;
86 }
87 
90 {
91  BOOL bReturnValue = FALSE;
92  DWORD dwErrorCode;
93 
94  TRACE("SpoolerInit()\n");
95 
96  // Nothing to initialize here yet, but pass this call to the Spool Service as well.
98  {
99  dwErrorCode = _RpcSpoolerInit();
100  SetLastError(dwErrorCode);
101  bReturnValue = (dwErrorCode == ERROR_SUCCESS);
102  }
104  {
105  ERR("_RpcSpoolerInit failed with exception code %lu!\n", RpcExceptionCode());
106  }
107  RpcEndExcept;
108 
109  return bReturnValue;
110 }
RPC_STATUS WINAPI RpcBindingFromStringBindingW(RPC_WSTR StringBinding, RPC_BINDING_HANDLE *Binding)
Definition: rpc_binding.c:877
#define RpcEndExcept
Definition: rpc.h:128
RPC_STATUS WINAPI RpcBindingFree(RPC_BINDING_HANDLE *Binding)
Definition: rpc_binding.c:784
#define TRUE
Definition: types.h:120
#define ERROR_SUCCESS
Definition: deptool.c:10
handle_t hBinding
Definition: ctx_c.c:54
RPC_STATUS WINAPI RpcStringFreeW(RPC_WSTR *String)
Definition: rpcrt4_main.c:177
uint16_t * PWSTR
Definition: typedefs.h:54
BOOL WINAPI DisableThreadLibraryCalls(IN HMODULE hLibModule)
Definition: loader.c:85
handle_t __RPC_USER WINSPOOL_HANDLE_bind(WINSPOOL_HANDLE wszName)
Definition: main.c:15
void __RPC_USER WINSPOOL_HANDLE_unbind(WINSPOOL_HANDLE wszName, handle_t hBinding)
Definition: main.c:49
#define DLL_PROCESS_ATTACH
Definition: compat.h:120
DWORD _RpcSpoolerInit(VOID)
Definition: init.c:11
RPC_STATUS WINAPI RpcStringBindingComposeW(RPC_WSTR ObjUuid, RPC_WSTR Protseq, RPC_WSTR NetworkAddr, RPC_WSTR Endpoint, RPC_WSTR Options, RPC_WSTR *StringBinding)
Definition: rpc_binding.c:511
static IN DWORD IN LPVOID lpvReserved
long RPC_STATUS
Definition: rpc.h:52
unsigned int BOOL
Definition: ntddk_ex.h:94
static PVOID ptr
Definition: dispmode.c:27
#define RpcTryExcept
Definition: rpc.h:126
#define EXCEPTION_EXECUTE_HANDLER
Definition: excpt.h:85
smooth NULL
Definition: ftsmooth.c:416
#define __RPC_FAR
Definition: rpc.h:56
#define __RPC_USER
Definition: rpc.h:65
#define RpcExceptionCode()
Definition: rpc.h:132
#define TRACE(s)
Definition: solgame.cpp:4
#define GetProcessHeap()
Definition: compat.h:403
PVOID WINAPI HeapAlloc(HANDLE, DWORD, SIZE_T)
#define WINAPI
Definition: msvc.h:8
unsigned long DWORD
Definition: ntddk_ex.h:95
#define SetLastError(x)
Definition: compat.h:417
void __RPC_USER midl_user_free(void __RPC_FAR *ptr)
Definition: main.c:395
static const WCHAR L[]
Definition: oid.c:1250
GLenum GLsizei len
Definition: glext.h:6722
HANDLE hProcessHeap
Definition: main.c:13
Status
Definition: gdiplustypes.h:24
#define ERR(fmt,...)
Definition: debug.h:109
ULONG_PTR SIZE_T
Definition: typedefs.h:78
void __RPC_FAR *__RPC_USER midl_user_allocate(SIZE_T len)
Definition: main.c:389
BOOL WINAPI SpoolerInit(VOID)
Definition: main.c:248
#define HEAP_ZERO_MEMORY
Definition: compat.h:123
#define HeapFree(x, y, z)
Definition: compat.h:402
WCHAR * WINSPOOL_HANDLE
Definition: winspool.idl:15
#define RPC_S_OK
Definition: rpcnterr.h:22
#define RpcExcept(expr)
Definition: rpc.h:127
BOOL WINAPI DllMain(HINSTANCE hInstance, DWORD dwReason, LPVOID lpReserved)
Definition: main.c:26