1 #define WIN32_NO_STATUS
2 #define _INC_WINDOWS
3 #define COM_NO_WINDOWS_H
4 #include <stdarg.h>
5 #include <windef.h>
6 #include <winbase.h>
7 #include <dnsrslvr_c.h>
8
9 #define NDEBUG
10 #include <debug.h>
11
12 handle_t __RPC_USER
DNSRSLVR_HANDLE_bind(DNSRSLVR_HANDLE pszMachineName)13 DNSRSLVR_HANDLE_bind(DNSRSLVR_HANDLE pszMachineName)
14 {
15 handle_t hBinding = NULL;
16 LPWSTR pszStringBinding;
17 RPC_STATUS Status;
18
19 DPRINT("DNSRSLVR_HANDLE_bind(%S)\n", pszMachineName);
20
21 Status = RpcStringBindingComposeW(NULL,
22 L"ncalrpc",
23 pszMachineName,
24 L"DNSResolver",
25 NULL,
26 &pszStringBinding);
27 if (Status != RPC_S_OK)
28 {
29 DPRINT1("RpcStringBindingCompose returned 0x%x\n", Status);
30 return NULL;
31 }
32
33 /* Set the binding handle that will be used to bind to the server. */
34 Status = RpcBindingFromStringBindingW(pszStringBinding,
35 &hBinding);
36 if (Status != RPC_S_OK)
37 {
38 DPRINT1("RpcBindingFromStringBinding returned 0x%x\n", Status);
39 }
40
41 Status = RpcStringFreeW(&pszStringBinding);
42 if (Status != RPC_S_OK)
43 {
44 DPRINT1("RpcStringFree returned 0x%x\n", Status);
45 }
46
47 return hBinding;
48 }
49
50 void __RPC_USER
DNSRSLVR_HANDLE_unbind(DNSRSLVR_HANDLE pszMachineName,handle_t hBinding)51 DNSRSLVR_HANDLE_unbind(DNSRSLVR_HANDLE pszMachineName,
52 handle_t hBinding)
53 {
54 RPC_STATUS Status;
55
56 DPRINT("DNSRSLVR_HANDLE_unbind(%S)\n", pszMachineName);
57
58 Status = RpcBindingFree(&hBinding);
59 if (Status != RPC_S_OK)
60 {
61 DPRINT1("RpcBindingFree returned 0x%x\n", Status);
62 }
63 }
64
65 void __RPC_FAR * __RPC_USER
midl_user_allocate(SIZE_T len)66 midl_user_allocate(SIZE_T len)
67 {
68 return HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, len);
69 }
70
71 void __RPC_USER
midl_user_free(void __RPC_FAR * ptr)72 midl_user_free(void __RPC_FAR * ptr)
73 {
74 HeapFree(GetProcessHeap(), 0, ptr);
75 }
76