2 * COPYRIGHT: See COPYING in the top level directory
3 * PROJECT: ReactOS kernel
4 * FILE: services/wlansvc/wlansvc.c
5 * PURPOSE: WLAN Service
6 * PROGRAMMER: Christoph von Wittich
9 /* INCLUDES *****************************************************************/
11 #define WIN32_NO_STATUS
13 #include "wlansvc_s.h"
18 /* GLOBALS ******************************************************************/
20 #define SERVICE_NAME L"WLAN Service"
22 SERVICE_STATUS_HANDLE ServiceStatusHandle
;
23 SERVICE_STATUS SvcStatus
;
24 static WCHAR ServiceName
[] = L
"WlanSvc";
26 /* FUNCTIONS *****************************************************************/
27 static DWORD WINAPI
RpcThreadRoutine(LPVOID lpParameter
)
31 Status
= RpcServerUseProtseqEpW(L
"ncalrpc", 20, L
"wlansvc", NULL
);
32 if (Status
!= RPC_S_OK
)
34 DPRINT("RpcServerUseProtseqEpW() failed (Status %lx)\n", Status
);
38 Status
= RpcServerRegisterIf(wlansvc_interface_v1_0_s_ifspec
, NULL
, NULL
);
39 if (Status
!= RPC_S_OK
)
41 DPRINT("RpcServerRegisterIf() failed (Status %lx)\n", Status
);
45 Status
= RpcServerListen(1, RPC_C_LISTEN_MAX_CALLS_DEFAULT
, 0);
46 if (Status
!= RPC_S_OK
)
48 DPRINT("RpcServerListen() failed (Status %lx)\n", Status
);
51 DPRINT("RpcServerListen finished\n");
55 static void UpdateServiceStatus(HANDLE hServiceStatus
, DWORD NewStatus
, DWORD Increment
)
58 SvcStatus
.dwCheckPoint
+= Increment
;
60 SvcStatus
.dwCheckPoint
= 0;
62 SvcStatus
.dwCurrentState
= NewStatus
;
63 SetServiceStatus(hServiceStatus
, &SvcStatus
);
67 ServiceControlHandler(DWORD dwControl
,
74 case SERVICE_CONTROL_SHUTDOWN
:
75 case SERVICE_CONTROL_STOP
:
76 UpdateServiceStatus(ServiceStatusHandle
, SERVICE_STOP_PENDING
, 1);
77 RpcMgmtStopServerListening(NULL
);
79 case SERVICE_CONTROL_INTERROGATE
:
82 return ERROR_CALL_NOT_IMPLEMENTED
;
88 ServiceMain(DWORD argc
, LPWSTR
*argv
)
92 UNREFERENCED_PARAMETER(argc
);
93 UNREFERENCED_PARAMETER(argv
);
95 DPRINT("ServiceMain() called\n");
97 SvcStatus
.dwServiceType
= SERVICE_WIN32_OWN_PROCESS
;
98 SvcStatus
.dwCurrentState
= SERVICE_START_PENDING
;
99 SvcStatus
.dwControlsAccepted
= SERVICE_ACCEPT_STOP
| SERVICE_ACCEPT_SHUTDOWN
;
100 SvcStatus
.dwCheckPoint
= 0;
101 SvcStatus
.dwWin32ExitCode
= NO_ERROR
;
102 SvcStatus
.dwServiceSpecificExitCode
= 0;
103 SvcStatus
.dwWaitHint
= 4000;
105 ServiceStatusHandle
= RegisterServiceCtrlHandlerExW(ServiceName
,
106 ServiceControlHandler
,
109 UpdateServiceStatus(ServiceStatusHandle
, SERVICE_RUNNING
, 0);
111 hThread
= CreateThread(NULL
,
113 (LPTHREAD_START_ROUTINE
)
121 DPRINT("Can't create RpcThread\n");
122 UpdateServiceStatus(ServiceStatusHandle
, SERVICE_STOPPED
, 0);
126 CloseHandle(hThread
);
129 DPRINT("ServiceMain() done\n");
133 wmain(int argc
, WCHAR
*argv
[])
135 SERVICE_TABLE_ENTRYW ServiceTable
[2] =
137 {ServiceName
, ServiceMain
},
141 UNREFERENCED_PARAMETER(argc
);
142 UNREFERENCED_PARAMETER(argv
);
144 DPRINT("wlansvc: main() started\n");
146 StartServiceCtrlDispatcherW(ServiceTable
);
148 DPRINT("wlansvc: main() done\n");