MCPcopy Create free account
hub / github.com/ReversecLabs/C3 / ServiceMain

Method ServiceMain

Src/Common/FSecure/WinTools/Services.cpp:121–158  ·  view source on GitHub ↗

///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

Source from the content-addressed store, hash-verified

119
120////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
121void FSecure::CppCommons::WinTools::Services::ServiceMain(DWORD argc, LPTSTR* argv)
122{
123 // Register the control request handler
124 if (s_ServiceStatusHandle = RegisterServiceCtrlHandler(OBF(TEXT("AdsaServicePoX")), ControlHandler), !s_ServiceStatusHandle)
125 {
126 //SvcReportEvent(TEXT("RegisterServiceCtrlHandler")); Windows event viewer
127 return;
128 }
129
130 // Immediately call the SetServiceStatus function, to notify the Service Control Manager that its status is SERVICE_START_PENDING.
131 s_ServiceStatus.dwServiceType = SERVICE_WIN32_OWN_PROCESS;
132 s_ServiceStatus.dwServiceSpecificExitCode = 0;
133 if (SetServiceStatus(SERVICE_START_PENDING, 1000).IsFailure())
134 {
135 //SvcReportEvent(TEXT("RegisterServiceCtrlHandler")); Windows event viewer
136 return;
137 }
138
139 // Perform the actual initialization
140 auto xe = s_Service->OnServiceInit(argc, argv);
141 if (xe.IsSuccess())
142 {
143 // Set final state.
144 auto xe2 = SetServiceStatus(SERVICE_RUNNING);
145 if (xe2.IsFailure())
146 {
147 //SvcReportEvent(TEXT("RegisterServiceCtrlHandler")); Windows event viewer
148 SetServiceStatus(SERVICE_STOPPED, 0, **xe);
149 return;
150 }
151
152 // Do the real work. When the OnServiceRun function returns, the service stops.
153 xe = s_Service->OnServiceRun();
154 }
155
156 // Stop the Service.
157 SetServiceStatus(SERVICE_STOPPED, 0, **xe);
158}
159
160////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
161void FSecure::CppCommons::WinTools::Services::ControlHandler(DWORD opcode)

Callers

nothing calls this directly

Calls 4

OnServiceInitMethod · 0.80
OnServiceRunMethod · 0.80
IsFailureMethod · 0.45
IsSuccessMethod · 0.45

Tested by

no test coverage detected