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
;
25 /* FUNCTIONS *****************************************************************/
26 static DWORD WINAPI
RpcThreadRoutine(LPVOID lpParameter
)
30 Status
= RpcServerUseProtseqEpW(L
"ncalrpc", 20, L
"wlansvc", NULL
);
31 if (Status
!= RPC_S_OK
)
33 DPRINT("RpcServerUseProtseqEpW() failed (Status %lx)\n", Status
);
37 Status
= RpcServerRegisterIf(wlansvc_interface_v1_0_s_ifspec
, NULL
, NULL
);
38 if (Status
!= RPC_S_OK
)
40 DPRINT("RpcServerRegisterIf() failed (Status %lx)\n", Status
);
44 Status
= RpcServerListen(1, RPC_C_LISTEN_MAX_CALLS_DEFAULT
, 0);
45 if (Status
!= RPC_S_OK
)
47 DPRINT("RpcServerListen() failed (Status %lx)\n", Status
);
50 DPRINT("RpcServerListen finished\n");
54 static void UpdateServiceStatus(HANDLE hServiceStatus
, DWORD NewStatus
, DWORD Increment
)
57 SvcStatus
.dwCheckPoint
+= Increment
;
59 SvcStatus
.dwCheckPoint
= 0;
61 SvcStatus
.dwCurrentState
= NewStatus
;
62 SetServiceStatus(hServiceStatus
, &SvcStatus
);
66 ServiceControlHandler(DWORD dwControl
,
73 case SERVICE_CONTROL_SHUTDOWN
:
74 case SERVICE_CONTROL_STOP
:
75 UpdateServiceStatus(ServiceStatusHandle
, SERVICE_STOP_PENDING
, 1);
76 RpcMgmtStopServerListening(NULL
);
78 case SERVICE_CONTROL_INTERROGATE
:
81 return ERROR_CALL_NOT_IMPLEMENTED
;
87 ServiceMain(DWORD argc
, LPWSTR
*argv
)
91 UNREFERENCED_PARAMETER(argc
);
92 UNREFERENCED_PARAMETER(argv
);
94 DPRINT("ServiceMain() called\n");
96 SvcStatus
.dwServiceType
= SERVICE_WIN32_OWN_PROCESS
;
97 SvcStatus
.dwControlsAccepted
= SERVICE_ACCEPT_STOP
| SERVICE_ACCEPT_SHUTDOWN
;
98 SvcStatus
.dwCheckPoint
= 0;
99 SvcStatus
.dwWin32ExitCode
= 0;
100 SvcStatus
.dwServiceSpecificExitCode
= 0;
101 SvcStatus
.dwWaitHint
= 4000;
103 ServiceStatusHandle
= RegisterServiceCtrlHandlerExW(SERVICE_NAME
,
104 ServiceControlHandler
,
107 UpdateServiceStatus(ServiceStatusHandle
, SERVICE_RUNNING
, 0);
109 hThread
= CreateThread(NULL
,
111 (LPTHREAD_START_ROUTINE
)
118 DPRINT("Can't create RpcThread\n");
121 WaitForSingleObject(hThread
, INFINITE
);
122 CloseHandle(hThread
);
125 UpdateServiceStatus(ServiceStatusHandle
, SERVICE_STOPPED
, 0);
127 DPRINT("ServiceMain() done\n");
131 wmain(int argc
, WCHAR
*argv
[])
133 SERVICE_TABLE_ENTRYW ServiceTable
[2] =
135 {SERVICE_NAME
, ServiceMain
},
139 UNREFERENCED_PARAMETER(argc
);
140 UNREFERENCED_PARAMETER(argv
);
142 DPRINT("wlansvc: main() started\n");
144 StartServiceCtrlDispatcherW(ServiceTable
);
146 DPRINT("wlansvc: main() done\n");