ReactOS
0.4.16-dev-329-g9223134
rpc.c
Go to the documentation of this file.
1
/*
2
* RPC support routines
3
*
4
* Copyright 2005 Eric Kohl
5
*
6
* This library is free software; you can redistribute it and/or
7
* modify it under the terms of the GNU Lesser General Public
8
* License as published by the Free Software Foundation; either
9
* version 2.1 of the License, or (at your option) any later version.
10
*
11
* This library is distributed in the hope that it will be useful,
12
* but WITHOUT ANY WARRANTY; without even the implied warranty of
13
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14
* Lesser General Public License for more details.
15
*
16
* You should have received a copy of the GNU Lesser General Public
17
* License along with this library; if not, write to the Free Software
18
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
19
*/
20
21
#include "
setupapi_private.h
"
22
23
static
RPC_BINDING_HANDLE
LocalBindingHandle
=
NULL
;
24
static
HSTRING_TABLE
LocalStringTable
=
NULL
;
25
26
27
RPC_STATUS
28
PnpBindRpc
(
LPCWSTR
pszMachine,
29
RPC_BINDING_HANDLE
*
BindingHandle
)
30
{
31
PWSTR
pszStringBinding =
NULL
;
32
RPC_STATUS
Status
;
33
34
Status
=
RpcStringBindingComposeW
(
NULL
,
35
L
"ncacn_np"
,
36
(
LPWSTR
)pszMachine,
37
L
"\\pipe\\plugplay"
,
38
NULL
,
39
&pszStringBinding);
40
if
(
Status
!=
RPC_S_OK
)
41
return
Status
;
42
43
Status
=
RpcBindingFromStringBindingW
(pszStringBinding,
44
BindingHandle
);
45
46
RpcStringFreeW
(&pszStringBinding);
47
48
return
Status
;
49
}
50
51
52
RPC_STATUS
53
PnpUnbindRpc
(
RPC_BINDING_HANDLE
*
BindingHandle
)
54
{
55
if
(
BindingHandle
!=
NULL
)
56
{
57
RpcBindingFree
(*
BindingHandle
);
58
*
BindingHandle
=
NULL
;
59
}
60
61
return
RPC_S_OK
;
62
}
63
64
65
BOOL
66
PnpGetLocalHandles
(
RPC_BINDING_HANDLE
*
BindingHandle
,
67
HSTRING_TABLE
*StringTable)
68
{
69
if
(
LocalBindingHandle
!=
NULL
)
70
{
71
if
(
BindingHandle
!=
NULL
)
72
*
BindingHandle
=
LocalBindingHandle
;
73
74
if
(StringTable !=
NULL
)
75
*StringTable =
LocalStringTable
;
76
77
return
TRUE
;
78
}
79
80
LocalStringTable
=
pSetupStringTableInitialize
();
81
if
(
LocalStringTable
==
NULL
)
82
return
FALSE
;
83
84
if
(
PnpBindRpc
(
NULL
, &
LocalBindingHandle
) !=
RPC_S_OK
)
85
{
86
pSetupStringTableDestroy
(
LocalStringTable
);
87
return
FALSE
;
88
}
89
90
pSetupStringTableAddString
(
LocalStringTable
,
L
"PLT"
, 1);
91
92
if
(
BindingHandle
!=
NULL
)
93
*
BindingHandle
=
LocalBindingHandle
;
94
95
if
(StringTable !=
NULL
)
96
*StringTable =
LocalStringTable
;
97
98
return
TRUE
;
99
}
100
101
102
RPC_STATUS
103
PnpUnbindLocalBindingHandle
(
VOID
)
104
{
105
pSetupStringTableDestroy
(
LocalStringTable
);
106
LocalStringTable
=
NULL
;
107
return
PnpUnbindRpc
(&
LocalBindingHandle
);
108
}
109
110
111
void
__RPC_FAR
*
__RPC_USER
112
midl_user_allocate
(
SIZE_T
len
)
113
{
114
return
HeapAlloc
(
GetProcessHeap
(),
HEAP_ZERO_MEMORY
,
len
);
115
}
116
117
118
void
__RPC_USER
119
midl_user_free
(
void
__RPC_FAR
*
ptr
)
120
{
121
HeapFree
(
GetProcessHeap
(), 0,
ptr
);
122
}
123
124
/* EOF */
NULL
#define NULL
Definition:
types.h:112
TRUE
#define TRUE
Definition:
types.h:120
FALSE
#define FALSE
Definition:
types.h:117
GetProcessHeap
#define GetProcessHeap()
Definition:
compat.h:736
HeapAlloc
#define HeapAlloc
Definition:
compat.h:733
HeapFree
#define HeapFree(x, y, z)
Definition:
compat.h:735
HEAP_ZERO_MEMORY
#define HEAP_ZERO_MEMORY
Definition:
compat.h:134
PnpBindRpc
RPC_STATUS PnpBindRpc(LPCWSTR pszMachine, RPC_BINDING_HANDLE *BindingHandle)
Definition:
rpc.c:28
PnpGetLocalHandles
BOOL PnpGetLocalHandles(RPC_BINDING_HANDLE *BindingHandle, HSTRING_TABLE *StringTable)
Definition:
rpc.c:66
PnpUnbindRpc
RPC_STATUS PnpUnbindRpc(RPC_BINDING_HANDLE *BindingHandle)
Definition:
rpc.c:53
LocalBindingHandle
static RPC_BINDING_HANDLE LocalBindingHandle
Definition:
rpc.c:23
LocalStringTable
static HSTRING_TABLE LocalStringTable
Definition:
rpc.c:24
PnpUnbindLocalBindingHandle
RPC_STATUS PnpUnbindLocalBindingHandle(VOID)
Definition:
rpc.c:103
pSetupStringTableInitialize
HSTRING_TABLE WINAPI pSetupStringTableInitialize(VOID)
Definition:
stringtable.c:54
pSetupStringTableAddString
DWORD WINAPI pSetupStringTableAddString(HSTRING_TABLE hStringTable, LPWSTR lpString, DWORD dwFlags)
Definition:
stringtable.c:196
pSetupStringTableDestroy
VOID WINAPI pSetupStringTableDestroy(HSTRING_TABLE hStringTable)
Definition:
stringtable.c:145
BOOL
unsigned int BOOL
Definition:
ntddk_ex.h:94
Status
Status
Definition:
gdiplustypes.h:25
len
GLenum GLsizei len
Definition:
glext.h:6722
void
Definition:
nsiface.idl:2307
ptr
static PVOID ptr
Definition:
dispmode.c:27
L
#define L(x)
Definition:
ntvdm.h:50
RpcBindingFromStringBindingW
RPC_STATUS WINAPI RpcBindingFromStringBindingW(RPC_WSTR StringBinding, RPC_BINDING_HANDLE *Binding)
Definition:
rpc_binding.c:880
RpcStringBindingComposeW
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
RpcBindingFree
RPC_STATUS WINAPI RpcBindingFree(RPC_BINDING_HANDLE *Binding)
Definition:
rpc_binding.c:787
RPC_S_OK
#define RPC_S_OK
Definition:
rpcnterr.h:22
RpcStringFreeW
RPC_STATUS WINAPI RpcStringFreeW(RPC_WSTR *String)
Definition:
rpcrt4_main.c:175
midl_user_free
#define midl_user_free
Definition:
rpc.h:45
__RPC_FAR
#define __RPC_FAR
Definition:
rpc.h:56
RPC_STATUS
long RPC_STATUS
Definition:
rpc.h:52
__RPC_USER
#define __RPC_USER
Definition:
rpc.h:65
midl_user_allocate
#define midl_user_allocate
Definition:
rpc.h:44
setupapi_private.h
BindingHandle
_In_ ULONG _Out_ HANDLE * BindingHandle
Definition:
tdikrnl.h:1147
PWSTR
uint16_t * PWSTR
Definition:
typedefs.h:56
SIZE_T
ULONG_PTR SIZE_T
Definition:
typedefs.h:80
LPWSTR
WCHAR * LPWSTR
Definition:
xmlstorage.h:184
LPCWSTR
const WCHAR * LPCWSTR
Definition:
xmlstorage.h:185
dll
win32
setupapi
rpc.c
Generated on Sun Dec 8 2024 06:10:30 for ReactOS by
1.9.6