mirror of
https://github.com/arehnman/yttrium-virtio-gpu.git
synced 2026-10-31 02:05:04 +00:00
Static analysis was failing with: app\device.cpp(190): warning C6258: Using TerminateThread does not allow proper thread clean up. app\main.cpp(30): warning C28285: For function 'wmain' '_Param_(2)' syntax error in 'SAL_readableTo(elementCount(Argc))' near 'Argc))'. app\main.cpp(51): warning C6387: 'scm' could be '0': this does not adhere to the specification for the function 'OpenServiceW'. app\memstat.cpp(28): warning C6214: Cast between semantically different integer types: HRESULT to a Boolean type. app\memstat.cpp(162): warning C6386: Buffer overrun while writing to 'this->m_Stats': the writable size is '70' bytes, but '80' bytes might be written. app\service.cpp(231): warning C6031: Return value ignored: 'QueryServiceStatus'. app\service.cpp(257): warning C6001: Using uninitialized memory 'CurrentState'. app\utils.cpp(28): warning C6387: 'pLog' could be '0': this does not adhere to the specification for the function 'fprintf'. app\utils.cpp(29): warning C6387: 'pLog' could be '0': this does not adhere to the specification for the function 'fclose'. See line 28 for an earlier location where this can occur app\utils.cpp(104): warning C6387: 'scm' could be '0': this does not adhere to the specification for the function 'CloseServiceHandle'. See line 81 for an earlier location where this can occur app\utils.cpp(80): warning C6387: 'scm' could be '0': this does not adhere to the specification for the function 'CreateServiceW'. app\utils.cpp(140): warning C6387: 'service' could be '0': this does not adhere to the specification for the function 'DeleteService'. See line 126 for an earlier location where this can occur app\utils.cpp(147): warning C6387: 'service' could be '0': this does not adhere to the specification for the function 'CloseServiceHandle'. See line 126 for an earlier location where this can occur app\utils.cpp(148): warning C6387: 'scm' could be '0': this does not adhere to the specification for the function 'CloseServiceHandle'. See line 121 for an earlier location where this can occur app\utils.cpp(133): warning C6387: 'service' could be '0': this does not adhere to the specification for the function 'ControlService'. See line 126 for an earlier location where this can occur app\utils.cpp(121): warning C6387: 'scm' could be '0': this does not adhere to the specification for the function 'OpenServiceW'. app\utils.cpp(126): warning C6387: 'service' could be '0': this does not adhere to the specification for the function 'QueryServiceStatus'. app\utils.cpp(178): warning C28159: Consider using 'GetTickCount64' instead of 'GetTickCount'. Reason: GetTickCount overflows roughly every 49 days. Code that does not take that into account can loop indefinitely. GetTickCount64 operates on 64 bit values and does not have that problem app\utils.cpp(197): warning C28159: Consider using 'GetTickCount64' instead of 'GetTickCount'. Reason: GetTickCount overflows roughly every 49 days. Code that does not take that into account can loop indefinitely. GetTickCount64 operates on 64 bit values and does not have that problem app\utils.cpp(200): warning C28159: Consider using 'GetTickCount64' instead of 'GetTickCount'. Reason: GetTickCount overflows roughly every 49 days. Code that does not take that into account can loop indefinitely. GetTickCount64 operates on 64 bit values and does not have that problem app\utils.cpp(221): warning C6387: 'scm' could be '0': this does not adhere to the specification for the function 'CloseServiceHandle'. See line 167 for an earlier location where this can occur app\utils.cpp(167): warning C6387: 'scm' could be '0': this does not adhere to the specification for the function 'OpenServiceW'. app\utils.cpp(255): warning C6387: 'scm' could be '0': this does not adhere to the specification for the function 'CloseServiceHandle'. See line 238 for an earlier location where this can occur app\utils.cpp(254): warning C6387: 'service' could be '0': this does not adhere to the specification for the function 'CloseServiceHandle'. app\utils.cpp(238): warning C6387: 'scm' could be '0': this does not adhere to the specification for the function 'OpenServiceW'. app\utils.cpp(245): warning C6387: 'service' could be '0': this does not adhere to the specification for the function 'ControlService'. app\utils.cpp(248): warning C6001: Using uninitialized memory 'res'. app\utils.cpp(279): warning C6387: 'service' could be '0': this does not adhere to the specification for the function 'QueryServiceConfigW'. app\utils.cpp(273): warning C6387: 'scm' could be '0': this does not adhere to the specification for the function 'OpenServiceW'. app\utils.cpp(292): warning C6387: 'service' could be '0': this does not adhere to the specification for the function 'CloseServiceHandle'. See line 279 for an earlier location where this can occur app\utils.cpp(293): warning C6387: 'scm' could be '0': this does not adhere to the specification for the function 'CloseServiceHandle'. See line 273 for an earlier location where this can occur app\utils.cpp(284): warning C28182: Dereferencing NULL pointer. 'buffer' contains the same NULL value as 'LocalAlloc()`278' did. app\utils.cpp(317): warning C6387: 'service' could be '0': this does not adhere to the specification for the function 'ChangeServiceConfigW'. app\utils.cpp(339): warning C6387: 'service' could be '0': this does not adhere to the specification for the function 'CloseServiceHandle'. See line 318 for an earlier location where this can occur app\utils.cpp(335): warning C6387: 'lock' could be '0': this does not adhere to the specification for the function 'UnlockServiceDatabase'. app\utils.cpp(340): warning C6387: 'scm' could be '0': this does not adhere to the specification for the function 'CloseServiceHandle'. See line 309 for an earlier location where this can occur app\utils.cpp(309): warning C6387: 'scm' could be '0': this does not adhere to the specification for the function 'LockServiceDatabase'. app\utils.cpp(313): warning C6387: 'scm' could be '0': this does not adhere to the specification for the function 'OpenServiceW'. See line 309 for an earlier location where this can occur This commit fixes everything except for: app\device.cpp(190): warning C6258: Using TerminateThread does not allow proper thread clean up. app\utils.cpp(178): warning C28159: Consider using 'GetTickCount64' instead of 'GetTickCount'. Reason: GetTickCount overflows roughly every 49 days. Code that does not take that into account can loop indefinitely. GetTickCount64 operates on 64 bit values and does not have that problem app\utils.cpp(197): warning C28159: Consider using 'GetTickCount64' instead of 'GetTickCount'. Reason: GetTickCount overflows roughly every 49 days. Code that does not take that into account can loop indefinitely. GetTickCount64 operates on 64 bit values and does not have that problem app\utils.cpp(200): warning C28159: Consider using 'GetTickCount64' instead of 'GetTickCount'. Reason: GetTickCount overflows roughly every 49 days. Code that does not take that into account can loop indefinitely. GetTickCount64 operates on 64 bit values and does not have that problem Signed-off-by: Ladi Prosek <[email protected]>
73 lines
2.0 KiB
C++
73 lines
2.0 KiB
C++
#include "stdafx.h"
|
|
|
|
LPWSTR ServiceName = L"BalloonService";
|
|
LPWSTR DisplayName = L"Balloon Service";
|
|
|
|
CService srvc;
|
|
|
|
DWORD WINAPI HandlerEx(DWORD ctlcode, DWORD evtype, PVOID evdata, PVOID context)
|
|
{
|
|
CService *service = static_cast<CService*>(context);
|
|
|
|
return CService::HandlerExThunk(service, ctlcode, evtype, evdata);
|
|
}
|
|
|
|
void __stdcall ServiceMainEx(DWORD argc, TCHAR* argv[])
|
|
{
|
|
srvc.m_StatusHandle = RegisterServiceCtrlHandlerEx(ServiceName, HandlerEx,
|
|
&srvc);
|
|
CService::ServiceMainThunk(&srvc, argc, argv);
|
|
}
|
|
|
|
SERVICE_TABLE_ENTRY serviceTableEx[] =
|
|
{
|
|
{ ServiceName, (LPSERVICE_MAIN_FUNCTION) ServiceMainEx},
|
|
{ NULL, NULL}
|
|
};
|
|
|
|
ULONG
|
|
_cdecl
|
|
wmain(
|
|
__in ULONG argc,
|
|
__in_ecount(argc) PWCHAR argv[]
|
|
)
|
|
{
|
|
if(argc == 2)
|
|
{
|
|
if (_tcsicmp(L"-i", argv[1]) == 0) {
|
|
InstallService();
|
|
} else if (_tcsicmp(L"-u", argv[1]) == 0) {
|
|
UninstallService();
|
|
} else if (_tcsicmp(L"-r", argv[1]) == 0) {
|
|
ServiceRun();
|
|
} else if (_tcsicmp(L"-s", argv[1]) == 0) {
|
|
ServiceControl(SERVICE_CONTROL_STOP);
|
|
} else if (_tcsicmp(L"status", argv[1]) == 0) {
|
|
SC_HANDLE scm, service;
|
|
scm = OpenSCManager(NULL, NULL, SC_MANAGER_ALL_ACCESS);
|
|
if (!scm) {
|
|
ErrorHandler("OpenSCManager", GetLastError());
|
|
}
|
|
service = OpenService(scm, ServiceName, SERVICE_ALL_ACCESS);
|
|
if (!service) {
|
|
ErrorHandler("OpenService", GetLastError());
|
|
}
|
|
printf("STATUS: ");
|
|
srvc.GetStatus(service);
|
|
} else if (_tcsicmp(L"config", argv[1]) == 0) {
|
|
GetConfiguration();
|
|
} else if (_tcsicmp(L"help", argv[1]) == 0) {
|
|
ShowUsage();
|
|
} else {
|
|
ShowUsage();
|
|
}
|
|
} else {
|
|
BOOL success;
|
|
success = StartServiceCtrlDispatcher(serviceTableEx);
|
|
if (!success) {
|
|
ErrorHandler("StartServiceCtrlDispatcher",GetLastError());
|
|
}
|
|
}
|
|
return 0;
|
|
}
|