Skip to content
Permalink
Browse files

- Win32: Made UnrealIRCd run as a service under non-privileged accounts

  (ones that do not belong to the Administrator group). Reported by
  skyflash, Bock, zer, etc... Thanks to BuHHunyx for some hints on how to
  fix this.
  • Loading branch information
syzop committed Dec 23, 2008
1 parent aaae253 commit a77b8c4da25fac5c1b16f039d05bbc274ecbd818
Showing with 23 additions and 4 deletions.
  1. +4 −0 Changes
  2. +19 −4 src/win32/gui.c
@@ -1693,3 +1693,7 @@
- Fix OOB read caused by UHNAMES support.
- Added some countermeasures against crash-on-boot, #0003725 and #0003653,
reported by Ablom2008 and mist26.
- Win32: Made UnrealIRCd run as a service under non-privileged accounts
(ones that do not belong to the Administrator group). Reported by
skyflash, Bock, zer, etc... Thanks to BuHHunyx for some hints on how to
fix this.
@@ -109,6 +109,12 @@ char OSName[256];
extern char *find_loaded_remote_include(char *url);
#endif

char *show_error(DWORD code) {
static char buf[1024];
FormatMessage(FORMAT_MESSAGE_FROM_SYSTEM, NULL, code, 0, buf, 1024, NULL);
return buf;
}

void TaskBarCreated()
{
HICON hIcon = (HICON)LoadImage(hInst, MAKEINTRESOURCE(ICO_MAIN), IMAGE_ICON,16, 16, 0);
@@ -218,12 +224,20 @@ int APIENTRY WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLi
GetOSName(VerInfo, OSName);
if (VerInfo.dwPlatformId == VER_PLATFORM_WIN32_NT)
{
SC_HANDLE hService, hSCManager = OpenSCManager(NULL, NULL, GENERIC_EXECUTE);
if ((hService = OpenService(hSCManager, "UnrealIRCd", GENERIC_EXECUTE)))
DWORD new_save_err = 0;
SC_HANDLE hService, hSCManager;

hSCManager = OpenSCManager(NULL, NULL, SC_MANAGER_CONNECT);
Debug((DEBUG_DEBUG, "OpenSCManager(): ERR = %ld / %s\n", GetLastError(), show_error(GetLastError())));

if (hSCManager)
{
new_save_err = StartServiceCtrlDispatcher(DispatchTable);

if ((hService = OpenService(hSCManager, "UnrealIRCd", SERVICE_START|SERVICE_STOP|SERVICE_QUERY_STATUS)))
{
int save_err = 0;
StartServiceCtrlDispatcher(DispatchTable);
if (GetLastError() == ERROR_FAILED_SERVICE_CONTROLLER_CONNECT)
if (new_save_err == ERROR_FAILED_SERVICE_CONTROLLER_CONNECT)
{
SERVICE_STATUS status;
/* Restart handling, it's ugly but it's as
@@ -255,6 +269,7 @@ int APIENTRY WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLi
} else {
CloseServiceHandle(hSCManager);
}
}
}
InitCommonControls();
WM_TASKBARCREATED = RegisterWindowMessage("TaskbarCreated");

0 comments on commit a77b8c4

Please sign in to comment.
You can’t perform that action at this time.