ReactOS  0.4.14-dev-552-g2fad488
dnsrslvr.c
Go to the documentation of this file.
1 /*
2  * COPYRIGHT: See COPYING in the top level directory
3  * PROJECT: ReactOS DNS Resolver
4  * FILE: base/services/dnsrslvr/dnsrslvr.c
5  * PURPOSE: DNS Resolver Service
6  * PROGRAMMER: Christoph von Wittich
7  */
8 
9 /* INCLUDES *****************************************************************/
10 
11 #include "precomp.h"
12 
13 #define NDEBUG
14 #include <debug.h>
15 
16 /* GLOBALS ******************************************************************/
17 
21 static WCHAR ServiceName[] = L"Dnscache";
22 
24 
25 /* FUNCTIONS *****************************************************************/
26 
27 static
28 VOID
31  DWORD NewStatus,
33 {
34  if (Increment > 0)
36  else
38 
39  SvcStatus.dwCurrentState = NewStatus;
41 }
42 
43 static
44 DWORD
45 WINAPI
47  DWORD dwControl,
48  DWORD dwEventType,
49  LPVOID lpEventData,
50  LPVOID lpContext)
51 {
52  switch (dwControl)
53  {
60  break;
61 
63  return NO_ERROR;
64 
65  default:
67  }
68  return NO_ERROR;
69 }
70 
71 VOID
72 WINAPI
74  DWORD argc,
75  LPWSTR *argv)
76 {
78 
81 
82  DPRINT("ServiceMain() called\n");
83 
90  SvcStatus.dwWaitHint = 4000;
91 
94  NULL);
95 
97  {
98  DPRINT1("DNSRSLVR: Unable to register service control handler (%lx)\n", GetLastError());
99  return; // FALSE
100  }
101 
103 
104  ReadHostsFile();
105 
107  0,
110  NULL,
111  0,
112  NULL);
113 
114  if (!hThread)
115  {
116  DnsIntCacheFree();
117  DPRINT("Can't create RpcThread\n");
119  }
120  else
121  {
123  }
124 
125  DPRINT("ServiceMain() done\n");
127 }
128 
129 BOOL
130 WINAPI
132  _In_ HINSTANCE hinstDLL,
133  _In_ DWORD fdwReason,
135 {
137 
138  switch (fdwReason)
139  {
140  case DLL_PROCESS_ATTACH:
141  DisableThreadLibraryCalls(hinstDLL);
142  hDllInstance = hinstDLL;
143  break;
144 
145  case DLL_PROCESS_DETACH:
146  break;
147  }
148 
149  return TRUE;
150 }
151 
152 /* EOF */
VOID DnsIntCacheFree(VOID)
Definition: cache.c:36
static int argc
Definition: ServiceArgs.c:12
DWORD(WINAPI * LPTHREAD_START_ROUTINE)(LPVOID)
Definition: winbase.h:707
#define TRUE
Definition: types.h:120
#define CloseHandle
Definition: compat.h:406
RPC_STATUS WINAPI RpcMgmtStopServerListening(RPC_BINDING_HANDLE Binding)
Definition: rpc_server.c:1596
DWORD dwCurrentState
Definition: winsvc.h:100
SERVICE_STATUS SvcStatus
Definition: dnsrslvr.c:20
#define UNREFERENCED_PARAMETER(P)
Definition: ntbasedef.h:323
#define SERVICE_ACCEPT_STOP
Definition: winsvc.h:28
BOOL WINAPI DisableThreadLibraryCalls(IN HMODULE hLibModule)
Definition: loader.c:85
DWORD WINAPI GetLastError(VOID)
Definition: except.c:1059
#define SERVICE_START_PENDING
Definition: winsvc.h:22
DWORD dwServiceSpecificExitCode
Definition: winsvc.h:103
#define DLL_PROCESS_ATTACH
Definition: compat.h:120
HINSTANCE hDllInstance
Definition: dnsrslvr.c:18
#define argv
Definition: mplay32.c:18
#define NO_ERROR
Definition: dderror.h:5
BOOL WINAPI SetServiceStatus(SERVICE_STATUS_HANDLE hServiceStatus, LPSERVICE_STATUS lpServiceStatus)
Definition: sctrl.c:995
static DWORD WINAPI ServiceControlHandler(DWORD dwControl, DWORD dwEventType, LPVOID lpEventData, LPVOID lpContext)
Definition: dnsrslvr.c:46
DWORD dwCheckPoint
Definition: winsvc.h:104
#define SERVICE_STOPPED
Definition: winsvc.h:21
static VOID UpdateServiceStatus(HANDLE hServiceStatus, DWORD NewStatus, DWORD Increment)
Definition: dnsrslvr.c:29
unsigned int BOOL
Definition: ntddk_ex.h:94
#define SERVICE_RUNNING
Definition: winsvc.h:24
HANDLE WINAPI DECLSPEC_HOTPATCH CreateThread(IN LPSECURITY_ATTRIBUTES lpThreadAttributes, IN DWORD dwStackSize, IN LPTHREAD_START_ROUTINE lpStartAddress, IN LPVOID lpParameter, IN DWORD dwCreationFlags, OUT LPDWORD lpThreadId)
Definition: thread.c:136
smooth NULL
Definition: ftsmooth.c:416
void DPRINT(...)
Definition: polytest.cpp:61
#define SERVICE_CONTROL_INTERROGATE
Definition: winsvc.h:39
#define SERVICE_WIN32_OWN_PROCESS
Definition: cmtypes.h:960
#define DLL_PROCESS_DETACH
Definition: compat.h:119
BOOL WINAPI DllMain(_In_ HINSTANCE hinstDLL, _In_ DWORD fdwReason, _In_ PVOID pvReserved)
Definition: dnsrslvr.c:131
static SERVICE_STATUS_HANDLE(WINAPI *pRegisterServiceCtrlHandlerExA)(LPCSTR
BOOL ReadHostsFile(VOID)
Definition: hostsfile.c:283
#define SERVICE_ACCEPT_SHUTDOWN
Definition: winsvc.h:30
static WCHAR ServiceName[]
Definition: dnsrslvr.c:21
__wchar_t WCHAR
Definition: xmlstorage.h:180
DWORD dwWaitHint
Definition: winsvc.h:105
static LPCSTR DWORD void * pvReserved
Definition: str.c:196
#define WINAPI
Definition: msvc.h:8
DWORD dwWin32ExitCode
Definition: winsvc.h:102
unsigned long DWORD
Definition: ntddk_ex.h:95
DWORD dwServiceType
Definition: winsvc.h:99
static const WCHAR L[]
Definition: oid.c:1250
LPVOID lpParameter
Definition: kernel32.h:241
SERVICE_STATUS_HANDLE WINAPI RegisterServiceCtrlHandlerExW(LPCWSTR lpServiceName, LPHANDLER_FUNCTION_EX lpHandlerProc, LPVOID lpContext)
Definition: sctrl.c:810
SERVICE_STATUS_HANDLE hServiceStatus
Definition: main.c:10
#define _In_
Definition: no_sal2.h:204
DWORD dwControlsAccepted
Definition: winsvc.h:101
HANDLE hThread
Definition: wizard.c:27
#define DPRINT1
Definition: precomp.h:8
#define ERROR_CALL_NOT_IMPLEMENTED
Definition: compat.h:92
#define SERVICE_CONTROL_STOP
Definition: winsvc.h:36
VOID DnsIntCacheInitialize(VOID)
Definition: cache.c:21
WCHAR * LPWSTR
Definition: xmlstorage.h:184
VOID WINAPI ServiceMain(DWORD argc, LPWSTR *argv)
Definition: dnsrslvr.c:73
IN OUT PLONG IN OUT PLONG Addend IN OUT PLONG IN LONG Increment
Definition: CrNtStubs.h:42
DWORD WINAPI RpcThreadRoutine(LPVOID lpParameter)
Definition: rpcserver.c:16
#define SERVICE_STOP_PENDING
Definition: winsvc.h:23
SERVICE_STATUS_HANDLE ServiceStatusHandle
Definition: dnsrslvr.c:19
#define SERVICE_CONTROL_SHUTDOWN
Definition: winsvc.h:40