iSECPartners/yontma

Be smarter about deciding if yontma is running as a service

Closed this issue · 2 comments

Currently, yontma assumes that if yontma is installed as a service, the current instance must be running as a service. I think this breaks uninstall.

We need to figure out a new way to determine if the running instance of yontma was launched from the command line or as a service.

There is a super simple fix for this. In InstallHiber, change:
strcat_s(cFullPathName,".exe"); to strcat_s(cFullPathName,".exe service_i_am");

and in _tmain, remove:
hSCManager = OpenSCManager(NULL,NULL,SC_MANAGER_ENUMERATE_SERVICE);
if (hSCManager == NULL) {
printf("OpenSCManager error: %d\n",GetLastError());
return 1;
}
bExecutedAsService = GetServiceDisplayName(hSCManager,SERVICE_NAME,cDisplayName,&dwDisplayNameSize);
CloseServiceHandle(hSCManager);

and instead:
if((argc == 2) && (!strncmp(argv[1],"service_i_am))) bExecutedAsService = true;

the "service_i_am should probably be put in a #define