ReactOS  0.4.15-dev-2765-g10e48fa
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
14 
17 {
19  PWSTR wszStringBinding;
21 
22  // Get us a string binding handle from the supplied connection information
23  Status = RpcStringBindingComposeW(NULL, L"ncalrpc", NULL, L"spoolss", NULL, &wszStringBinding);
24  if (Status != RPC_S_OK)
25  {
26  ERR("RpcStringBindingComposeW failed with status %ld!\n", Status);
27  return NULL;
28  }
29 
30  // Get a handle_t binding handle from the string binding handle
31  Status = RpcBindingFromStringBindingW(wszStringBinding, &hBinding);
32  if (Status != RPC_S_OK)
33  {
34  ERR("RpcBindingFromStringBindingW failed with status %ld!\n", Status);
35  return NULL;
36  }
37 
38  // Free the string binding handle
39  Status = RpcStringFreeW(&wszStringBinding);
40  if (Status != RPC_S_OK)
41  {
42  ERR("RpcStringFreeW failed with status %ld!\n", Status);
43  return NULL;
44  }
45 
46  return hBinding;
47 }
48 
49 void __RPC_USER
51 {
53 
55  if (Status != RPC_S_OK)
56  {
57  ERR("RpcBindingFree failed with status %ld!\n", Status);
58  }
59 }
60 
63 {
65 }
66 
67 void __RPC_USER
69 {
71 }
72 
74 DllMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved)
75 {
76  TRACE("DllMain(%p, %lu, %p)\n", hinstDLL, fdwReason, lpvReserved);
77 
78  switch (fdwReason)
79  {
80  case DLL_PROCESS_ATTACH:
81  DisableThreadLibraryCalls(hinstDLL);
83  hinstWinSpool = hinstDLL;
85  break;
86 
87  case DLL_PROCESS_DETACH:
89  break;
90  }
91 
92  return TRUE;
93 }
94 
97 {
98  BOOL bReturnValue = FALSE;
99  DWORD dwErrorCode;
100 
101  TRACE("SpoolerInit()\n");
102 
103  // Nothing to initialize here yet, but pass this call to the Spool Service as well.
105  {
106  dwErrorCode = _RpcSpoolerInit();
107  SetLastError(dwErrorCode);
108  bReturnValue = (dwErrorCode == ERROR_SUCCESS);
109  }
111  {
112  ERR("_RpcSpoolerInit failed with exception code %lu!\n", RpcExceptionCode());
113  }
114  RpcEndExcept;
115 
116  return bReturnValue;
117 }
RPC_STATUS WINAPI RpcBindingFromStringBindingW(RPC_WSTR StringBinding, RPC_BINDING_HANDLE *Binding)
Definition: rpc_binding.c:876
#define RpcEndExcept
Definition: rpc.h:128
RPC_STATUS WINAPI RpcBindingFree(RPC_BINDING_HANDLE *Binding)
Definition: rpc_binding.c:783
#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:174
#define TRUE
Definition: types.h:120
uint16_t * PWSTR
Definition: typedefs.h:56
BOOL WINAPI DisableThreadLibraryCalls(IN HMODULE hLibModule)
Definition: loader.c:85
handle_t __RPC_USER WINSPOOL_HANDLE_bind(WINSPOOL_HANDLE wszName)
Definition: main.c:16
void __RPC_USER WINSPOOL_HANDLE_unbind(WINSPOOL_HANDLE wszName, handle_t hBinding)
Definition: main.c:50
#define DLL_PROCESS_ATTACH
Definition: compat.h:131
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:510
static IN DWORD IN LPVOID lpvReserved
long RPC_STATUS
Definition: rpc.h:52
#define FALSE
Definition: types.h:117
unsigned int BOOL
Definition: ntddk_ex.h:94
static PVOID ptr
Definition: dispmode.c:27
#define RpcTryExcept
Definition: rpc.h:126
VOID WINAPI InitializeCriticalSection(OUT LPCRITICAL_SECTION lpCriticalSection)
Definition: synch.c:751
#define __RPC_FAR
Definition: rpc.h:56
#define __RPC_USER
Definition: rpc.h:65
#define DLL_PROCESS_DETACH
Definition: compat.h:130
Status
Definition: gdiplustypes.h:24
#define RpcExceptionCode()
Definition: rpc.h:132
#define TRACE(s)
Definition: solgame.cpp:4
#define GetProcessHeap()
Definition: compat.h:595
PVOID WINAPI HeapAlloc(HANDLE, DWORD, SIZE_T)
void WINAPI DeleteCriticalSection(PCRITICAL_SECTION)
#define EXCEPTION_EXECUTE_HANDLER
Definition: excpt.h:85
#define WINAPI
Definition: msvc.h:6
unsigned long DWORD
Definition: ntddk_ex.h:95
#define SetLastError(x)
Definition: compat.h:611
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
#define ERR(fmt,...)
Definition: debug.h:110
ULONG_PTR SIZE_T
Definition: typedefs.h:80
CRITICAL_SECTION rtlCritSec
Definition: main.c:13
void __RPC_FAR *__RPC_USER midl_user_allocate(SIZE_T len)
Definition: main.c:389
BOOL WINAPI SpoolerInit(VOID)
Definition: main.c:248
#define NULL
Definition: types.h:112
#define HEAP_ZERO_MEMORY
Definition: compat.h:134
#define HeapFree(x, y, z)
Definition: compat.h:594
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
HINSTANCE hinstWinSpool
Definition: main.c:12