forked from waldo-irc/CVE-2021-21551
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathRpcHelpers.c
41 lines (31 loc) · 1 KB
/
RpcHelpers.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
#include <Windows.h>
#include <strsafe.h>
#include <sddl.h>
#include <wtsapi32.h>
#include <stdint.h>
#include "IWinSpool_h.h"
////////
////////
// RPC helpers
////////
handle_t __RPC_USER STRING_HANDLE_bind(STRING_HANDLE lpStr) {
RPC_STATUS RpcStatus;
RPC_WSTR StringBinding;
handle_t BindingHandle;
if (RpcStringBindingComposeW((RPC_WSTR)L"12345678-1234-ABCD-EF00-0123456789AB", (RPC_WSTR)L"ncacn_np", (RPC_WSTR)lpStr, (RPC_WSTR)L"\\pipe\\spoolss", NULL, &StringBinding) != RPC_S_OK)
return NULL;
RpcStatus = RpcBindingFromStringBindingW(StringBinding, &BindingHandle);
RpcStringFreeW(&StringBinding);
if (RpcStatus != RPC_S_OK)
return NULL;
return BindingHandle;
}
void __RPC_USER STRING_HANDLE_unbind(STRING_HANDLE lpStr, handle_t BindingHandle) {
RpcBindingFree(&BindingHandle);
}
void __RPC_FAR* __RPC_USER midl_user_allocate(size_t cBytes) {
return((void __RPC_FAR*) malloc(cBytes));
}
void __RPC_USER midl_user_free(void __RPC_FAR* p) {
free(p);
}