174{
175 std::string command = epee::string_tools::get_current_module_path();
176 std::string full_command = command + arguments;
177
178 service_handle p_manager{
179 OpenSCManager(
180 nullptr
181 , nullptr
182 , SC_MANAGER_CONNECT | SC_MANAGER_CREATE_SERVICE
183 )
184 , &::CloseServiceHandle
185 };
186 if (p_manager == nullptr)
187 {
189 return false;
190 }
191
192 service_handle p_service{
193 CreateService(
194 p_manager.get()
195 , service_name.c_str()
196 , service_name.c_str()
197 , 0
198
199 , SERVICE_WIN32_OWN_PROCESS
200 , SERVICE_DEMAND_START
201 , SERVICE_ERROR_NORMAL
202 , full_command.c_str()
203 , nullptr
204 , nullptr
205 , ""
206
207 , nullptr
208 , nullptr
209 )
210 , &::CloseServiceHandle
211 };
212 if (p_service == nullptr)
213 {
215 return false;
216 }
217
219
220 pause_to_display_admin_window_messages();
221
222 return true;
223}