2012-04-19 20:58:29 +02:00
|
|
|
/*
|
|
|
|
* InspIRCd -- Internet Relay Chat Daemon
|
2008-08-21 11:01:51 +00:00
|
|
|
*
|
2012-04-19 20:58:29 +02:00
|
|
|
* Copyright (C) 2008 Craig Edwards <craigedwards@brainbox.cc>
|
2008-08-21 11:01:51 +00:00
|
|
|
*
|
2012-04-19 20:58:29 +02:00
|
|
|
* This file is part of InspIRCd. InspIRCd is free software: you can
|
|
|
|
* redistribute it and/or modify it under the terms of the GNU General Public
|
|
|
|
* License as published by the Free Software Foundation, version 2.
|
2008-08-21 11:01:51 +00:00
|
|
|
*
|
2012-04-19 20:58:29 +02:00
|
|
|
* This program is distributed in the hope that it will be useful, but WITHOUT
|
|
|
|
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
|
|
|
|
* FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
|
|
|
|
* details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
2008-08-22 20:01:13 +00:00
|
|
|
*/
|
2012-04-19 20:58:29 +02:00
|
|
|
|
|
|
|
|
2008-08-22 20:01:13 +00:00
|
|
|
#include "inspircd_config.h"
|
|
|
|
#include "inspircd.h"
|
2008-08-28 20:30:32 +00:00
|
|
|
#include "exitcodes.h"
|
2008-08-22 20:01:13 +00:00
|
|
|
#include <windows.h>
|
|
|
|
#include <stdlib.h>
|
|
|
|
#include <string.h>
|
|
|
|
#include <stdio.h>
|
2012-10-14 02:13:49 +02:00
|
|
|
#include <iostream>
|
2008-08-22 20:01:13 +00:00
|
|
|
|
|
|
|
static SERVICE_STATUS_HANDLE serviceStatusHandle;
|
|
|
|
static HANDLE hThreadEvent;
|
|
|
|
static HANDLE killServiceEvent;
|
|
|
|
static int serviceCurrentStatus;
|
|
|
|
|
|
|
|
/** This is used to define ChangeServiceConf2() as we can't link
|
|
|
|
* directly against this symbol (see below where it is used)
|
|
|
|
*/
|
|
|
|
typedef BOOL (CALLBACK* SETSERVDESC)(SC_HANDLE,DWORD,LPVOID);
|
|
|
|
|
2008-08-24 23:05:51 +00:00
|
|
|
BOOL UpdateSCMStatus(DWORD dwCurrentState, DWORD dwWin32ExitCode, DWORD dwServiceSpecificExitCode, DWORD dwCheckPoint, DWORD dwWaitHint);
|
|
|
|
void terminateService(int code, int wincode);
|
2008-08-24 19:19:57 +00:00
|
|
|
|
2008-08-22 20:01:13 +00:00
|
|
|
/* A commandline parameter handler for service specific commandline parameters */
|
|
|
|
typedef void (*CommandlineParameterHandler)(void);
|
|
|
|
|
|
|
|
/* Represents a commandline and its handler */
|
|
|
|
struct Commandline
|
|
|
|
{
|
|
|
|
const char* Switch;
|
|
|
|
CommandlineParameterHandler Handler;
|
|
|
|
};
|
|
|
|
|
|
|
|
/* A function pointer for dynamic linking tricks */
|
|
|
|
SETSERVDESC ChangeServiceConf;
|
|
|
|
|
Windows: In-depth cleanup (see details)
-Fix x64 builds for Windows. Now all configurations compile.
-Remove the non-working rebase stuff.
-Remove the Windows fork hack and instead use FreeConsole() to emulate the behavior. This directly allows us to compile with ASLR, which is turned on now.
-Remove the old IPC mechanism for the removed GUI. This is not needed anymore as the GUI wasn't ever supported on anything newer than 1.2
-Remove the WIN32/WINDOWS macros. _WIN32 is supported on all x86-based VC++ targets, so that's what we need.
-Enable optimizations for release builds.
-De-duplicate printf_c(), it was previously copy-pasted into colors.h for configure
-Add the VC++ specific bad files in .gitignore
-Disable PID writing on Windows. This is only making sense for *nix builds.
-Replace the CPU usage retrieval with an algorithm analogous to the *nix behavior. Also supports separated now/total values. (Tested with a dummy busy loop - seems working)
-Removed certain unused functions and variables
-Remove stdint defines from the windows wrapper
-Remove CRT debug alloc. This is a bad idea as it would define a macro to replace free which breaks builds.
-Re-evaluated the warnings list, commented it.
-Moved inspircd_config/_version to include/ to match *nix
-Removed the creation of inspircd_se_config, as it isn't used at all.
-Made non-git builds show as "r0" instead of "r" (thanks to @SaberUK for pointing this out)
-Fixed up m_spanningtree's project paths. Now all configurations (debug/release x86/x64) have been tested and build properly.
-Moved FindDNS out of the wrapper and matched its log behavior with *nix. (It's pointless having it in the wrapper after the recent slimming down)
-Replaced random/srandom wrappers with a mechanism that tries to use Windows' Random API first is no SSL module is loaded.
-Removed more old junk from support for compilers older than VC++ 2010 (we don't have project files for these, so compiling them would be hard anyways)
-Removed the unused ClearConsole()
-Removed unused includes from the wrapper. Also, do not include psapi.h here if we don't link psapi.lib. This should be done where appropriate.
-Made inet_aton an inline function for increased performance
-C4800, performance warning about bool forcing, resolved at all occurrences.
-C4701, uninitialized variable 'cached', resolved at all occurrences.
-dlerror() was migrated out of the wrapper for more thread safety (no global buffer being shared) and increased performance.
-Removed the wrong CRT debug flags. This drains a lot of performance.
-Removed the clock_gettime/gettimeofday wrappers
-Replaced all TCHAR/ANSI mix-ups of functions with the correct respective function.
-Added a block of C4355 for < VS2012
-Update project files for c870714
2012-10-12 22:31:38 +02:00
|
|
|
LPCSTR RetrieveLastError()
|
|
|
|
{
|
|
|
|
static char err[100];
|
2012-12-03 20:32:22 +01:00
|
|
|
DWORD LastError = GetLastError();
|
|
|
|
if (FormatMessageA(FORMAT_MESSAGE_FROM_SYSTEM|FORMAT_MESSAGE_IGNORE_INSERTS, 0, LastError, MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), (LPSTR)err, sizeof(err), 0) == 0)
|
|
|
|
snprintf(err, sizeof(err), "Error code: %d", LastError);
|
Windows: In-depth cleanup (see details)
-Fix x64 builds for Windows. Now all configurations compile.
-Remove the non-working rebase stuff.
-Remove the Windows fork hack and instead use FreeConsole() to emulate the behavior. This directly allows us to compile with ASLR, which is turned on now.
-Remove the old IPC mechanism for the removed GUI. This is not needed anymore as the GUI wasn't ever supported on anything newer than 1.2
-Remove the WIN32/WINDOWS macros. _WIN32 is supported on all x86-based VC++ targets, so that's what we need.
-Enable optimizations for release builds.
-De-duplicate printf_c(), it was previously copy-pasted into colors.h for configure
-Add the VC++ specific bad files in .gitignore
-Disable PID writing on Windows. This is only making sense for *nix builds.
-Replace the CPU usage retrieval with an algorithm analogous to the *nix behavior. Also supports separated now/total values. (Tested with a dummy busy loop - seems working)
-Removed certain unused functions and variables
-Remove stdint defines from the windows wrapper
-Remove CRT debug alloc. This is a bad idea as it would define a macro to replace free which breaks builds.
-Re-evaluated the warnings list, commented it.
-Moved inspircd_config/_version to include/ to match *nix
-Removed the creation of inspircd_se_config, as it isn't used at all.
-Made non-git builds show as "r0" instead of "r" (thanks to @SaberUK for pointing this out)
-Fixed up m_spanningtree's project paths. Now all configurations (debug/release x86/x64) have been tested and build properly.
-Moved FindDNS out of the wrapper and matched its log behavior with *nix. (It's pointless having it in the wrapper after the recent slimming down)
-Replaced random/srandom wrappers with a mechanism that tries to use Windows' Random API first is no SSL module is loaded.
-Removed more old junk from support for compilers older than VC++ 2010 (we don't have project files for these, so compiling them would be hard anyways)
-Removed the unused ClearConsole()
-Removed unused includes from the wrapper. Also, do not include psapi.h here if we don't link psapi.lib. This should be done where appropriate.
-Made inet_aton an inline function for increased performance
-C4800, performance warning about bool forcing, resolved at all occurrences.
-C4701, uninitialized variable 'cached', resolved at all occurrences.
-dlerror() was migrated out of the wrapper for more thread safety (no global buffer being shared) and increased performance.
-Removed the wrong CRT debug flags. This drains a lot of performance.
-Removed the clock_gettime/gettimeofday wrappers
-Replaced all TCHAR/ANSI mix-ups of functions with the correct respective function.
-Added a block of C4355 for < VS2012
-Update project files for c870714
2012-10-12 22:31:38 +02:00
|
|
|
SetLastError(ERROR_SUCCESS);
|
|
|
|
return err;
|
|
|
|
}
|
|
|
|
|
2008-08-24 23:47:20 +00:00
|
|
|
/* Returns true if this program is running as a service, false if it is running interactive */
|
2008-08-24 19:19:57 +00:00
|
|
|
bool IsAService()
|
2008-08-24 19:08:36 +00:00
|
|
|
{
|
|
|
|
USEROBJECTFLAGS uoflags;
|
|
|
|
HWINSTA winstation = GetProcessWindowStation();
|
|
|
|
if (GetUserObjectInformation(winstation, UOI_FLAGS, &uoflags, sizeof(uoflags), NULL))
|
|
|
|
return ((uoflags.dwFlags & WSF_VISIBLE) == 0);
|
|
|
|
else
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2008-08-22 20:01:13 +00:00
|
|
|
/* Kills the service by setting an event which the other thread picks up and exits */
|
|
|
|
void KillService()
|
|
|
|
{
|
|
|
|
SetEvent(hThreadEvent);
|
|
|
|
Sleep(2000);
|
|
|
|
SetEvent(killServiceEvent);
|
|
|
|
}
|
|
|
|
|
|
|
|
/** The main part of inspircd runs within this thread function. This allows the service part to run
|
|
|
|
* seperately on its own and to be able to kill the worker thread when its time to quit.
|
|
|
|
*/
|
|
|
|
DWORD WINAPI WorkerThread(LPDWORD param)
|
|
|
|
{
|
|
|
|
char modname[MAX_PATH];
|
Windows: In-depth cleanup (see details)
-Fix x64 builds for Windows. Now all configurations compile.
-Remove the non-working rebase stuff.
-Remove the Windows fork hack and instead use FreeConsole() to emulate the behavior. This directly allows us to compile with ASLR, which is turned on now.
-Remove the old IPC mechanism for the removed GUI. This is not needed anymore as the GUI wasn't ever supported on anything newer than 1.2
-Remove the WIN32/WINDOWS macros. _WIN32 is supported on all x86-based VC++ targets, so that's what we need.
-Enable optimizations for release builds.
-De-duplicate printf_c(), it was previously copy-pasted into colors.h for configure
-Add the VC++ specific bad files in .gitignore
-Disable PID writing on Windows. This is only making sense for *nix builds.
-Replace the CPU usage retrieval with an algorithm analogous to the *nix behavior. Also supports separated now/total values. (Tested with a dummy busy loop - seems working)
-Removed certain unused functions and variables
-Remove stdint defines from the windows wrapper
-Remove CRT debug alloc. This is a bad idea as it would define a macro to replace free which breaks builds.
-Re-evaluated the warnings list, commented it.
-Moved inspircd_config/_version to include/ to match *nix
-Removed the creation of inspircd_se_config, as it isn't used at all.
-Made non-git builds show as "r0" instead of "r" (thanks to @SaberUK for pointing this out)
-Fixed up m_spanningtree's project paths. Now all configurations (debug/release x86/x64) have been tested and build properly.
-Moved FindDNS out of the wrapper and matched its log behavior with *nix. (It's pointless having it in the wrapper after the recent slimming down)
-Replaced random/srandom wrappers with a mechanism that tries to use Windows' Random API first is no SSL module is loaded.
-Removed more old junk from support for compilers older than VC++ 2010 (we don't have project files for these, so compiling them would be hard anyways)
-Removed the unused ClearConsole()
-Removed unused includes from the wrapper. Also, do not include psapi.h here if we don't link psapi.lib. This should be done where appropriate.
-Made inet_aton an inline function for increased performance
-C4800, performance warning about bool forcing, resolved at all occurrences.
-C4701, uninitialized variable 'cached', resolved at all occurrences.
-dlerror() was migrated out of the wrapper for more thread safety (no global buffer being shared) and increased performance.
-Removed the wrong CRT debug flags. This drains a lot of performance.
-Removed the clock_gettime/gettimeofday wrappers
-Replaced all TCHAR/ANSI mix-ups of functions with the correct respective function.
-Added a block of C4355 for < VS2012
-Update project files for c870714
2012-10-12 22:31:38 +02:00
|
|
|
GetModuleFileNameA(NULL, modname, sizeof(modname));
|
2008-08-27 11:04:19 +00:00
|
|
|
char* argv[] = { modname, "--nofork" };
|
|
|
|
smain(2, argv);
|
2008-08-22 20:01:13 +00:00
|
|
|
KillService();
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2008-08-24 19:08:36 +00:00
|
|
|
/* This is called when all startup is done */
|
|
|
|
void SetServiceRunning()
|
|
|
|
{
|
|
|
|
if (!IsAService())
|
|
|
|
return;
|
|
|
|
|
|
|
|
serviceCurrentStatus = SERVICE_RUNNING;
|
2008-08-24 19:19:57 +00:00
|
|
|
BOOL success = UpdateSCMStatus(SERVICE_RUNNING, NO_ERROR, 0, 0, 0);
|
2008-08-24 19:08:36 +00:00
|
|
|
if (!success)
|
|
|
|
{
|
2008-08-24 23:05:51 +00:00
|
|
|
terminateService(EXIT_STATUS_UPDATESCM_FAILED, GetLastError());
|
2008-08-24 19:08:36 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2008-08-22 20:01:13 +00:00
|
|
|
/** Starts the worker thread above */
|
|
|
|
void StartServiceThread()
|
|
|
|
{
|
2012-12-03 20:53:18 +01:00
|
|
|
HANDLE hThread = CreateThread(NULL,0,(LPTHREAD_START_ROUTINE)WorkerThread,NULL,0,NULL);
|
|
|
|
if (hThread != NULL)
|
|
|
|
CloseHandle(hThread);
|
2008-08-22 20:01:13 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/** This function updates the status of the service in the SCM
|
|
|
|
* (service control manager, the services.msc applet)
|
|
|
|
*/
|
2008-08-24 23:05:51 +00:00
|
|
|
BOOL UpdateSCMStatus(DWORD dwCurrentState, DWORD dwWin32ExitCode, DWORD dwServiceSpecificExitCode, DWORD dwCheckPoint, DWORD dwWaitHint)
|
2008-08-22 20:01:13 +00:00
|
|
|
{
|
|
|
|
BOOL success;
|
|
|
|
SERVICE_STATUS serviceStatus;
|
|
|
|
serviceStatus.dwServiceType = SERVICE_WIN32_OWN_PROCESS;
|
|
|
|
serviceStatus.dwCurrentState = dwCurrentState;
|
|
|
|
|
|
|
|
if (dwCurrentState == SERVICE_START_PENDING)
|
|
|
|
{
|
|
|
|
serviceStatus.dwControlsAccepted = 0;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
serviceStatus.dwControlsAccepted = SERVICE_ACCEPT_STOP | SERVICE_ACCEPT_SHUTDOWN;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (dwServiceSpecificExitCode == 0)
|
|
|
|
{
|
|
|
|
serviceStatus.dwWin32ExitCode = dwWin32ExitCode;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
serviceStatus.dwWin32ExitCode = ERROR_SERVICE_SPECIFIC_ERROR;
|
|
|
|
}
|
|
|
|
serviceStatus.dwServiceSpecificExitCode = dwServiceSpecificExitCode;
|
|
|
|
serviceStatus.dwCheckPoint = dwCheckPoint;
|
|
|
|
serviceStatus.dwWaitHint = dwWaitHint;
|
|
|
|
|
|
|
|
success = SetServiceStatus (serviceStatusHandle, &serviceStatus);
|
|
|
|
if (!success)
|
|
|
|
{
|
|
|
|
KillService();
|
|
|
|
}
|
|
|
|
return success;
|
|
|
|
}
|
|
|
|
|
|
|
|
/** This function is called by us when the service is being shut down or when it can't be started */
|
2008-08-24 23:05:51 +00:00
|
|
|
void terminateService(int code, int wincode)
|
2008-08-22 20:01:13 +00:00
|
|
|
{
|
2008-08-24 19:08:36 +00:00
|
|
|
UpdateSCMStatus(SERVICE_STOPPED, wincode ? wincode : ERROR_SERVICE_SPECIFIC_ERROR, wincode ? 0 : code, 0, 0);
|
2008-08-22 20:01:13 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2008-08-24 23:47:20 +00:00
|
|
|
/* In windows we hook this to InspIRCd::Exit() */
|
2008-08-24 19:19:57 +00:00
|
|
|
void SetServiceStopped(int status)
|
2008-08-24 19:08:36 +00:00
|
|
|
{
|
|
|
|
if (!IsAService())
|
|
|
|
exit(status);
|
|
|
|
|
|
|
|
/* Are we running as a service? If so, trigger the service specific exit code */
|
|
|
|
terminateService(status, 0);
|
|
|
|
KillService();
|
|
|
|
exit(status);
|
|
|
|
}
|
|
|
|
|
2008-08-22 20:01:13 +00:00
|
|
|
/** This callback is called by windows when the state of the service has been changed */
|
2008-08-24 23:05:51 +00:00
|
|
|
VOID ServiceCtrlHandler(DWORD controlCode)
|
2008-08-22 20:01:13 +00:00
|
|
|
{
|
|
|
|
switch(controlCode)
|
|
|
|
{
|
|
|
|
case SERVICE_CONTROL_INTERROGATE:
|
|
|
|
break;
|
|
|
|
case SERVICE_CONTROL_SHUTDOWN:
|
|
|
|
case SERVICE_CONTROL_STOP:
|
|
|
|
serviceCurrentStatus = SERVICE_STOP_PENDING;
|
|
|
|
UpdateSCMStatus(SERVICE_STOP_PENDING, NO_ERROR, 0, 1, 5000);
|
|
|
|
KillService();
|
|
|
|
UpdateSCMStatus(SERVICE_STOPPED, NO_ERROR, 0, 0, 0);
|
|
|
|
return;
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
UpdateSCMStatus(serviceCurrentStatus, NO_ERROR, 0, 0, 0);
|
|
|
|
}
|
|
|
|
|
|
|
|
/** This callback is called by windows when the service is started */
|
|
|
|
VOID ServiceMain(DWORD argc, LPTSTR *argv)
|
|
|
|
{
|
|
|
|
BOOL success;
|
|
|
|
|
Windows: In-depth cleanup (see details)
-Fix x64 builds for Windows. Now all configurations compile.
-Remove the non-working rebase stuff.
-Remove the Windows fork hack and instead use FreeConsole() to emulate the behavior. This directly allows us to compile with ASLR, which is turned on now.
-Remove the old IPC mechanism for the removed GUI. This is not needed anymore as the GUI wasn't ever supported on anything newer than 1.2
-Remove the WIN32/WINDOWS macros. _WIN32 is supported on all x86-based VC++ targets, so that's what we need.
-Enable optimizations for release builds.
-De-duplicate printf_c(), it was previously copy-pasted into colors.h for configure
-Add the VC++ specific bad files in .gitignore
-Disable PID writing on Windows. This is only making sense for *nix builds.
-Replace the CPU usage retrieval with an algorithm analogous to the *nix behavior. Also supports separated now/total values. (Tested with a dummy busy loop - seems working)
-Removed certain unused functions and variables
-Remove stdint defines from the windows wrapper
-Remove CRT debug alloc. This is a bad idea as it would define a macro to replace free which breaks builds.
-Re-evaluated the warnings list, commented it.
-Moved inspircd_config/_version to include/ to match *nix
-Removed the creation of inspircd_se_config, as it isn't used at all.
-Made non-git builds show as "r0" instead of "r" (thanks to @SaberUK for pointing this out)
-Fixed up m_spanningtree's project paths. Now all configurations (debug/release x86/x64) have been tested and build properly.
-Moved FindDNS out of the wrapper and matched its log behavior with *nix. (It's pointless having it in the wrapper after the recent slimming down)
-Replaced random/srandom wrappers with a mechanism that tries to use Windows' Random API first is no SSL module is loaded.
-Removed more old junk from support for compilers older than VC++ 2010 (we don't have project files for these, so compiling them would be hard anyways)
-Removed the unused ClearConsole()
-Removed unused includes from the wrapper. Also, do not include psapi.h here if we don't link psapi.lib. This should be done where appropriate.
-Made inet_aton an inline function for increased performance
-C4800, performance warning about bool forcing, resolved at all occurrences.
-C4701, uninitialized variable 'cached', resolved at all occurrences.
-dlerror() was migrated out of the wrapper for more thread safety (no global buffer being shared) and increased performance.
-Removed the wrong CRT debug flags. This drains a lot of performance.
-Removed the clock_gettime/gettimeofday wrappers
-Replaced all TCHAR/ANSI mix-ups of functions with the correct respective function.
-Added a block of C4355 for < VS2012
-Update project files for c870714
2012-10-12 22:31:38 +02:00
|
|
|
serviceStatusHandle = RegisterServiceCtrlHandler(TEXT("InspIRCd"), (LPHANDLER_FUNCTION)ServiceCtrlHandler);
|
2008-08-22 20:01:13 +00:00
|
|
|
if (!serviceStatusHandle)
|
|
|
|
{
|
2008-08-24 23:05:51 +00:00
|
|
|
terminateService(EXIT_STATUS_RSCH_FAILED, GetLastError());
|
2008-08-22 20:01:13 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
success = UpdateSCMStatus(SERVICE_START_PENDING, NO_ERROR, 0, 1, 1000);
|
|
|
|
if (!success)
|
|
|
|
{
|
2008-08-24 23:05:51 +00:00
|
|
|
terminateService(EXIT_STATUS_UPDATESCM_FAILED, GetLastError());
|
2008-08-22 20:01:13 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
killServiceEvent = CreateEvent(NULL, true, false, NULL);
|
|
|
|
hThreadEvent = CreateEvent(NULL, true, false, NULL);
|
|
|
|
|
|
|
|
if (!killServiceEvent || !hThreadEvent)
|
|
|
|
{
|
2008-08-24 23:05:51 +00:00
|
|
|
terminateService(EXIT_STATUS_CREATE_EVENT_FAILED, GetLastError());
|
2008-08-22 20:01:13 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
success = UpdateSCMStatus(SERVICE_START_PENDING, NO_ERROR, 0, 2, 1000);
|
|
|
|
if (!success)
|
|
|
|
{
|
2008-08-24 23:05:51 +00:00
|
|
|
terminateService(EXIT_STATUS_UPDATESCM_FAILED, GetLastError());
|
2008-08-22 20:01:13 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
StartServiceThread();
|
|
|
|
WaitForSingleObject (killServiceEvent, INFINITE);
|
|
|
|
}
|
|
|
|
|
|
|
|
/** Install the windows service. This requires administrator privileges. */
|
|
|
|
void InstallService()
|
|
|
|
{
|
|
|
|
SC_HANDLE myService, scm;
|
|
|
|
SERVICE_DESCRIPTION svDesc;
|
|
|
|
HINSTANCE advapi32;
|
|
|
|
|
Windows: In-depth cleanup (see details)
-Fix x64 builds for Windows. Now all configurations compile.
-Remove the non-working rebase stuff.
-Remove the Windows fork hack and instead use FreeConsole() to emulate the behavior. This directly allows us to compile with ASLR, which is turned on now.
-Remove the old IPC mechanism for the removed GUI. This is not needed anymore as the GUI wasn't ever supported on anything newer than 1.2
-Remove the WIN32/WINDOWS macros. _WIN32 is supported on all x86-based VC++ targets, so that's what we need.
-Enable optimizations for release builds.
-De-duplicate printf_c(), it was previously copy-pasted into colors.h for configure
-Add the VC++ specific bad files in .gitignore
-Disable PID writing on Windows. This is only making sense for *nix builds.
-Replace the CPU usage retrieval with an algorithm analogous to the *nix behavior. Also supports separated now/total values. (Tested with a dummy busy loop - seems working)
-Removed certain unused functions and variables
-Remove stdint defines from the windows wrapper
-Remove CRT debug alloc. This is a bad idea as it would define a macro to replace free which breaks builds.
-Re-evaluated the warnings list, commented it.
-Moved inspircd_config/_version to include/ to match *nix
-Removed the creation of inspircd_se_config, as it isn't used at all.
-Made non-git builds show as "r0" instead of "r" (thanks to @SaberUK for pointing this out)
-Fixed up m_spanningtree's project paths. Now all configurations (debug/release x86/x64) have been tested and build properly.
-Moved FindDNS out of the wrapper and matched its log behavior with *nix. (It's pointless having it in the wrapper after the recent slimming down)
-Replaced random/srandom wrappers with a mechanism that tries to use Windows' Random API first is no SSL module is loaded.
-Removed more old junk from support for compilers older than VC++ 2010 (we don't have project files for these, so compiling them would be hard anyways)
-Removed the unused ClearConsole()
-Removed unused includes from the wrapper. Also, do not include psapi.h here if we don't link psapi.lib. This should be done where appropriate.
-Made inet_aton an inline function for increased performance
-C4800, performance warning about bool forcing, resolved at all occurrences.
-C4701, uninitialized variable 'cached', resolved at all occurrences.
-dlerror() was migrated out of the wrapper for more thread safety (no global buffer being shared) and increased performance.
-Removed the wrong CRT debug flags. This drains a lot of performance.
-Removed the clock_gettime/gettimeofday wrappers
-Replaced all TCHAR/ANSI mix-ups of functions with the correct respective function.
-Added a block of C4355 for < VS2012
-Update project files for c870714
2012-10-12 22:31:38 +02:00
|
|
|
TCHAR modname[MAX_PATH];
|
2008-08-22 20:01:13 +00:00
|
|
|
GetModuleFileName(NULL, modname, sizeof(modname));
|
|
|
|
|
|
|
|
scm = OpenSCManager(0,0,SC_MANAGER_CREATE_SERVICE);
|
|
|
|
if (!scm)
|
|
|
|
{
|
2012-10-14 02:13:49 +02:00
|
|
|
std::cout << "Unable to open service control manager: " << RetrieveLastError() << std::endl;
|
2008-08-22 20:01:13 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
Windows: In-depth cleanup (see details)
-Fix x64 builds for Windows. Now all configurations compile.
-Remove the non-working rebase stuff.
-Remove the Windows fork hack and instead use FreeConsole() to emulate the behavior. This directly allows us to compile with ASLR, which is turned on now.
-Remove the old IPC mechanism for the removed GUI. This is not needed anymore as the GUI wasn't ever supported on anything newer than 1.2
-Remove the WIN32/WINDOWS macros. _WIN32 is supported on all x86-based VC++ targets, so that's what we need.
-Enable optimizations for release builds.
-De-duplicate printf_c(), it was previously copy-pasted into colors.h for configure
-Add the VC++ specific bad files in .gitignore
-Disable PID writing on Windows. This is only making sense for *nix builds.
-Replace the CPU usage retrieval with an algorithm analogous to the *nix behavior. Also supports separated now/total values. (Tested with a dummy busy loop - seems working)
-Removed certain unused functions and variables
-Remove stdint defines from the windows wrapper
-Remove CRT debug alloc. This is a bad idea as it would define a macro to replace free which breaks builds.
-Re-evaluated the warnings list, commented it.
-Moved inspircd_config/_version to include/ to match *nix
-Removed the creation of inspircd_se_config, as it isn't used at all.
-Made non-git builds show as "r0" instead of "r" (thanks to @SaberUK for pointing this out)
-Fixed up m_spanningtree's project paths. Now all configurations (debug/release x86/x64) have been tested and build properly.
-Moved FindDNS out of the wrapper and matched its log behavior with *nix. (It's pointless having it in the wrapper after the recent slimming down)
-Replaced random/srandom wrappers with a mechanism that tries to use Windows' Random API first is no SSL module is loaded.
-Removed more old junk from support for compilers older than VC++ 2010 (we don't have project files for these, so compiling them would be hard anyways)
-Removed the unused ClearConsole()
-Removed unused includes from the wrapper. Also, do not include psapi.h here if we don't link psapi.lib. This should be done where appropriate.
-Made inet_aton an inline function for increased performance
-C4800, performance warning about bool forcing, resolved at all occurrences.
-C4701, uninitialized variable 'cached', resolved at all occurrences.
-dlerror() was migrated out of the wrapper for more thread safety (no global buffer being shared) and increased performance.
-Removed the wrong CRT debug flags. This drains a lot of performance.
-Removed the clock_gettime/gettimeofday wrappers
-Replaced all TCHAR/ANSI mix-ups of functions with the correct respective function.
-Added a block of C4355 for < VS2012
-Update project files for c870714
2012-10-12 22:31:38 +02:00
|
|
|
myService = CreateService(scm,TEXT("InspIRCd"),TEXT("Inspire IRC Daemon"), SERVICE_ALL_ACCESS, SERVICE_WIN32_OWN_PROCESS,
|
2008-08-22 20:01:13 +00:00
|
|
|
SERVICE_AUTO_START, SERVICE_ERROR_NORMAL, modname, 0, 0, 0, NULL, NULL);
|
|
|
|
|
|
|
|
if (!myService)
|
|
|
|
{
|
2012-10-14 02:13:49 +02:00
|
|
|
std::cout << "Unable to create service: " << RetrieveLastError() << std::endl;
|
2008-08-22 20:01:13 +00:00
|
|
|
CloseServiceHandle(scm);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
// *** Set service description ***
|
|
|
|
// this is supported from 5.0 (win2k) onwards only, so we can't link to the definition of
|
|
|
|
// this function in advapi32.lib, otherwise the program will not run on windows NT 4. We
|
|
|
|
// must use LoadLibrary and GetProcAddress to export the function name from advapi32.dll
|
Windows: In-depth cleanup (see details)
-Fix x64 builds for Windows. Now all configurations compile.
-Remove the non-working rebase stuff.
-Remove the Windows fork hack and instead use FreeConsole() to emulate the behavior. This directly allows us to compile with ASLR, which is turned on now.
-Remove the old IPC mechanism for the removed GUI. This is not needed anymore as the GUI wasn't ever supported on anything newer than 1.2
-Remove the WIN32/WINDOWS macros. _WIN32 is supported on all x86-based VC++ targets, so that's what we need.
-Enable optimizations for release builds.
-De-duplicate printf_c(), it was previously copy-pasted into colors.h for configure
-Add the VC++ specific bad files in .gitignore
-Disable PID writing on Windows. This is only making sense for *nix builds.
-Replace the CPU usage retrieval with an algorithm analogous to the *nix behavior. Also supports separated now/total values. (Tested with a dummy busy loop - seems working)
-Removed certain unused functions and variables
-Remove stdint defines from the windows wrapper
-Remove CRT debug alloc. This is a bad idea as it would define a macro to replace free which breaks builds.
-Re-evaluated the warnings list, commented it.
-Moved inspircd_config/_version to include/ to match *nix
-Removed the creation of inspircd_se_config, as it isn't used at all.
-Made non-git builds show as "r0" instead of "r" (thanks to @SaberUK for pointing this out)
-Fixed up m_spanningtree's project paths. Now all configurations (debug/release x86/x64) have been tested and build properly.
-Moved FindDNS out of the wrapper and matched its log behavior with *nix. (It's pointless having it in the wrapper after the recent slimming down)
-Replaced random/srandom wrappers with a mechanism that tries to use Windows' Random API first is no SSL module is loaded.
-Removed more old junk from support for compilers older than VC++ 2010 (we don't have project files for these, so compiling them would be hard anyways)
-Removed the unused ClearConsole()
-Removed unused includes from the wrapper. Also, do not include psapi.h here if we don't link psapi.lib. This should be done where appropriate.
-Made inet_aton an inline function for increased performance
-C4800, performance warning about bool forcing, resolved at all occurrences.
-C4701, uninitialized variable 'cached', resolved at all occurrences.
-dlerror() was migrated out of the wrapper for more thread safety (no global buffer being shared) and increased performance.
-Removed the wrong CRT debug flags. This drains a lot of performance.
-Removed the clock_gettime/gettimeofday wrappers
-Replaced all TCHAR/ANSI mix-ups of functions with the correct respective function.
-Added a block of C4355 for < VS2012
-Update project files for c870714
2012-10-12 22:31:38 +02:00
|
|
|
advapi32 = LoadLibrary(TEXT("advapi32.dll"));
|
2008-08-22 20:01:13 +00:00
|
|
|
if (advapi32)
|
|
|
|
{
|
|
|
|
ChangeServiceConf = (SETSERVDESC)GetProcAddress(advapi32,"ChangeServiceConfig2A");
|
|
|
|
if (ChangeServiceConf)
|
|
|
|
{
|
Windows: In-depth cleanup (see details)
-Fix x64 builds for Windows. Now all configurations compile.
-Remove the non-working rebase stuff.
-Remove the Windows fork hack and instead use FreeConsole() to emulate the behavior. This directly allows us to compile with ASLR, which is turned on now.
-Remove the old IPC mechanism for the removed GUI. This is not needed anymore as the GUI wasn't ever supported on anything newer than 1.2
-Remove the WIN32/WINDOWS macros. _WIN32 is supported on all x86-based VC++ targets, so that's what we need.
-Enable optimizations for release builds.
-De-duplicate printf_c(), it was previously copy-pasted into colors.h for configure
-Add the VC++ specific bad files in .gitignore
-Disable PID writing on Windows. This is only making sense for *nix builds.
-Replace the CPU usage retrieval with an algorithm analogous to the *nix behavior. Also supports separated now/total values. (Tested with a dummy busy loop - seems working)
-Removed certain unused functions and variables
-Remove stdint defines from the windows wrapper
-Remove CRT debug alloc. This is a bad idea as it would define a macro to replace free which breaks builds.
-Re-evaluated the warnings list, commented it.
-Moved inspircd_config/_version to include/ to match *nix
-Removed the creation of inspircd_se_config, as it isn't used at all.
-Made non-git builds show as "r0" instead of "r" (thanks to @SaberUK for pointing this out)
-Fixed up m_spanningtree's project paths. Now all configurations (debug/release x86/x64) have been tested and build properly.
-Moved FindDNS out of the wrapper and matched its log behavior with *nix. (It's pointless having it in the wrapper after the recent slimming down)
-Replaced random/srandom wrappers with a mechanism that tries to use Windows' Random API first is no SSL module is loaded.
-Removed more old junk from support for compilers older than VC++ 2010 (we don't have project files for these, so compiling them would be hard anyways)
-Removed the unused ClearConsole()
-Removed unused includes from the wrapper. Also, do not include psapi.h here if we don't link psapi.lib. This should be done where appropriate.
-Made inet_aton an inline function for increased performance
-C4800, performance warning about bool forcing, resolved at all occurrences.
-C4701, uninitialized variable 'cached', resolved at all occurrences.
-dlerror() was migrated out of the wrapper for more thread safety (no global buffer being shared) and increased performance.
-Removed the wrong CRT debug flags. This drains a lot of performance.
-Removed the clock_gettime/gettimeofday wrappers
-Replaced all TCHAR/ANSI mix-ups of functions with the correct respective function.
-Added a block of C4355 for < VS2012
-Update project files for c870714
2012-10-12 22:31:38 +02:00
|
|
|
TCHAR desc[] = TEXT("The Inspire Internet Relay Chat Daemon hosts IRC channels and conversations.\
|
|
|
|
If this service is stopped, the IRC server will not run.");
|
2008-08-22 20:01:13 +00:00
|
|
|
svDesc.lpDescription = desc;
|
|
|
|
BOOL success = ChangeServiceConf(myService,SERVICE_CONFIG_DESCRIPTION, &svDesc);
|
|
|
|
if (!success)
|
|
|
|
{
|
2012-10-14 02:13:49 +02:00
|
|
|
std::cout << "Unable to set service description: " << RetrieveLastError() << std::endl;
|
2008-08-22 20:01:13 +00:00
|
|
|
CloseServiceHandle(myService);
|
|
|
|
CloseServiceHandle(scm);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
FreeLibrary(advapi32);
|
|
|
|
}
|
|
|
|
|
2012-10-14 02:13:49 +02:00
|
|
|
std::cout << "Service installed." << std::endl;
|
2008-08-22 20:01:13 +00:00
|
|
|
CloseServiceHandle(myService);
|
|
|
|
CloseServiceHandle(scm);
|
|
|
|
}
|
|
|
|
|
|
|
|
/** Remove the windows service. This requires administrator privileges. */
|
|
|
|
void RemoveService()
|
|
|
|
{
|
|
|
|
SC_HANDLE myService, scm;
|
|
|
|
|
|
|
|
scm = OpenSCManager(0,0,SC_MANAGER_CREATE_SERVICE);
|
|
|
|
if (!scm)
|
|
|
|
{
|
2012-10-14 02:13:49 +02:00
|
|
|
std::cout << "Unable to open service control manager: " << RetrieveLastError() << std::endl;
|
2008-08-22 20:01:13 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
Windows: In-depth cleanup (see details)
-Fix x64 builds for Windows. Now all configurations compile.
-Remove the non-working rebase stuff.
-Remove the Windows fork hack and instead use FreeConsole() to emulate the behavior. This directly allows us to compile with ASLR, which is turned on now.
-Remove the old IPC mechanism for the removed GUI. This is not needed anymore as the GUI wasn't ever supported on anything newer than 1.2
-Remove the WIN32/WINDOWS macros. _WIN32 is supported on all x86-based VC++ targets, so that's what we need.
-Enable optimizations for release builds.
-De-duplicate printf_c(), it was previously copy-pasted into colors.h for configure
-Add the VC++ specific bad files in .gitignore
-Disable PID writing on Windows. This is only making sense for *nix builds.
-Replace the CPU usage retrieval with an algorithm analogous to the *nix behavior. Also supports separated now/total values. (Tested with a dummy busy loop - seems working)
-Removed certain unused functions and variables
-Remove stdint defines from the windows wrapper
-Remove CRT debug alloc. This is a bad idea as it would define a macro to replace free which breaks builds.
-Re-evaluated the warnings list, commented it.
-Moved inspircd_config/_version to include/ to match *nix
-Removed the creation of inspircd_se_config, as it isn't used at all.
-Made non-git builds show as "r0" instead of "r" (thanks to @SaberUK for pointing this out)
-Fixed up m_spanningtree's project paths. Now all configurations (debug/release x86/x64) have been tested and build properly.
-Moved FindDNS out of the wrapper and matched its log behavior with *nix. (It's pointless having it in the wrapper after the recent slimming down)
-Replaced random/srandom wrappers with a mechanism that tries to use Windows' Random API first is no SSL module is loaded.
-Removed more old junk from support for compilers older than VC++ 2010 (we don't have project files for these, so compiling them would be hard anyways)
-Removed the unused ClearConsole()
-Removed unused includes from the wrapper. Also, do not include psapi.h here if we don't link psapi.lib. This should be done where appropriate.
-Made inet_aton an inline function for increased performance
-C4800, performance warning about bool forcing, resolved at all occurrences.
-C4701, uninitialized variable 'cached', resolved at all occurrences.
-dlerror() was migrated out of the wrapper for more thread safety (no global buffer being shared) and increased performance.
-Removed the wrong CRT debug flags. This drains a lot of performance.
-Removed the clock_gettime/gettimeofday wrappers
-Replaced all TCHAR/ANSI mix-ups of functions with the correct respective function.
-Added a block of C4355 for < VS2012
-Update project files for c870714
2012-10-12 22:31:38 +02:00
|
|
|
myService = OpenService(scm,TEXT("InspIRCd"),SERVICE_ALL_ACCESS);
|
2008-08-22 20:01:13 +00:00
|
|
|
if (!myService)
|
|
|
|
{
|
2012-10-14 02:13:49 +02:00
|
|
|
std::cout << "Unable to open service: " << RetrieveLastError() << std::endl;
|
2008-08-22 20:01:13 +00:00
|
|
|
CloseServiceHandle(scm);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!DeleteService(myService))
|
|
|
|
{
|
2012-10-14 02:13:49 +02:00
|
|
|
std::cout << "Unable to delete service: " << RetrieveLastError() << std::endl;
|
2008-08-22 20:01:13 +00:00
|
|
|
CloseServiceHandle(myService);
|
|
|
|
CloseServiceHandle(scm);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2012-10-14 02:13:49 +02:00
|
|
|
std::cout << "Service removed." << std::endl;
|
2008-08-22 20:01:13 +00:00
|
|
|
CloseServiceHandle(myService);
|
|
|
|
CloseServiceHandle(scm);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* In windows, our main() flows through here, before calling the 'real' main, smain() in inspircd.cpp */
|
|
|
|
int main(int argc, char** argv)
|
|
|
|
{
|
|
|
|
/* List of parameters and handlers */
|
|
|
|
Commandline params[] = {
|
|
|
|
{ "--installservice", InstallService },
|
|
|
|
{ "--removeservice", RemoveService },
|
|
|
|
{ NULL }
|
|
|
|
};
|
|
|
|
|
|
|
|
/* Check for parameters */
|
|
|
|
if (argc > 1)
|
|
|
|
{
|
|
|
|
for (int z = 0; params[z].Switch; ++z)
|
|
|
|
{
|
|
|
|
if (!_stricmp(argv[1], params[z].Switch))
|
|
|
|
{
|
|
|
|
params[z].Handler();
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* First, check if the service is installed.
|
|
|
|
* if it is not, or we're starting as non-administrator,
|
|
|
|
* just call smain() and start as normal non-service
|
|
|
|
* process.
|
|
|
|
*/
|
|
|
|
SC_HANDLE myService, scm;
|
|
|
|
scm = OpenSCManager(0,0,SC_MANAGER_CREATE_SERVICE);
|
|
|
|
if (scm)
|
|
|
|
{
|
Windows: In-depth cleanup (see details)
-Fix x64 builds for Windows. Now all configurations compile.
-Remove the non-working rebase stuff.
-Remove the Windows fork hack and instead use FreeConsole() to emulate the behavior. This directly allows us to compile with ASLR, which is turned on now.
-Remove the old IPC mechanism for the removed GUI. This is not needed anymore as the GUI wasn't ever supported on anything newer than 1.2
-Remove the WIN32/WINDOWS macros. _WIN32 is supported on all x86-based VC++ targets, so that's what we need.
-Enable optimizations for release builds.
-De-duplicate printf_c(), it was previously copy-pasted into colors.h for configure
-Add the VC++ specific bad files in .gitignore
-Disable PID writing on Windows. This is only making sense for *nix builds.
-Replace the CPU usage retrieval with an algorithm analogous to the *nix behavior. Also supports separated now/total values. (Tested with a dummy busy loop - seems working)
-Removed certain unused functions and variables
-Remove stdint defines from the windows wrapper
-Remove CRT debug alloc. This is a bad idea as it would define a macro to replace free which breaks builds.
-Re-evaluated the warnings list, commented it.
-Moved inspircd_config/_version to include/ to match *nix
-Removed the creation of inspircd_se_config, as it isn't used at all.
-Made non-git builds show as "r0" instead of "r" (thanks to @SaberUK for pointing this out)
-Fixed up m_spanningtree's project paths. Now all configurations (debug/release x86/x64) have been tested and build properly.
-Moved FindDNS out of the wrapper and matched its log behavior with *nix. (It's pointless having it in the wrapper after the recent slimming down)
-Replaced random/srandom wrappers with a mechanism that tries to use Windows' Random API first is no SSL module is loaded.
-Removed more old junk from support for compilers older than VC++ 2010 (we don't have project files for these, so compiling them would be hard anyways)
-Removed the unused ClearConsole()
-Removed unused includes from the wrapper. Also, do not include psapi.h here if we don't link psapi.lib. This should be done where appropriate.
-Made inet_aton an inline function for increased performance
-C4800, performance warning about bool forcing, resolved at all occurrences.
-C4701, uninitialized variable 'cached', resolved at all occurrences.
-dlerror() was migrated out of the wrapper for more thread safety (no global buffer being shared) and increased performance.
-Removed the wrong CRT debug flags. This drains a lot of performance.
-Removed the clock_gettime/gettimeofday wrappers
-Replaced all TCHAR/ANSI mix-ups of functions with the correct respective function.
-Added a block of C4355 for < VS2012
-Update project files for c870714
2012-10-12 22:31:38 +02:00
|
|
|
myService = OpenService(scm,TEXT("InspIRCd"),SERVICE_ALL_ACCESS);
|
2008-08-22 20:01:13 +00:00
|
|
|
if (!myService)
|
|
|
|
{
|
|
|
|
/* Service not installed or no permission to modify it */
|
|
|
|
CloseServiceHandle(scm);
|
|
|
|
return smain(argc, argv);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
/* Not enough privileges to open the SCM */
|
|
|
|
return smain(argc, argv);
|
|
|
|
}
|
|
|
|
|
|
|
|
CloseServiceHandle(myService);
|
|
|
|
CloseServiceHandle(scm);
|
|
|
|
|
|
|
|
/* Check if the process is running interactively. InspIRCd does not run interactively
|
|
|
|
* as a service so if this is true, we just run the non-service inspircd.
|
|
|
|
*/
|
2008-08-24 19:08:36 +00:00
|
|
|
if (!IsAService())
|
2008-08-24 19:19:57 +00:00
|
|
|
return smain(argc, argv);
|
2008-08-22 20:01:13 +00:00
|
|
|
|
|
|
|
/* If we get here, we know the service is installed so we can start it */
|
|
|
|
|
|
|
|
SERVICE_TABLE_ENTRY serviceTable[] =
|
|
|
|
{
|
Windows: In-depth cleanup (see details)
-Fix x64 builds for Windows. Now all configurations compile.
-Remove the non-working rebase stuff.
-Remove the Windows fork hack and instead use FreeConsole() to emulate the behavior. This directly allows us to compile with ASLR, which is turned on now.
-Remove the old IPC mechanism for the removed GUI. This is not needed anymore as the GUI wasn't ever supported on anything newer than 1.2
-Remove the WIN32/WINDOWS macros. _WIN32 is supported on all x86-based VC++ targets, so that's what we need.
-Enable optimizations for release builds.
-De-duplicate printf_c(), it was previously copy-pasted into colors.h for configure
-Add the VC++ specific bad files in .gitignore
-Disable PID writing on Windows. This is only making sense for *nix builds.
-Replace the CPU usage retrieval with an algorithm analogous to the *nix behavior. Also supports separated now/total values. (Tested with a dummy busy loop - seems working)
-Removed certain unused functions and variables
-Remove stdint defines from the windows wrapper
-Remove CRT debug alloc. This is a bad idea as it would define a macro to replace free which breaks builds.
-Re-evaluated the warnings list, commented it.
-Moved inspircd_config/_version to include/ to match *nix
-Removed the creation of inspircd_se_config, as it isn't used at all.
-Made non-git builds show as "r0" instead of "r" (thanks to @SaberUK for pointing this out)
-Fixed up m_spanningtree's project paths. Now all configurations (debug/release x86/x64) have been tested and build properly.
-Moved FindDNS out of the wrapper and matched its log behavior with *nix. (It's pointless having it in the wrapper after the recent slimming down)
-Replaced random/srandom wrappers with a mechanism that tries to use Windows' Random API first is no SSL module is loaded.
-Removed more old junk from support for compilers older than VC++ 2010 (we don't have project files for these, so compiling them would be hard anyways)
-Removed the unused ClearConsole()
-Removed unused includes from the wrapper. Also, do not include psapi.h here if we don't link psapi.lib. This should be done where appropriate.
-Made inet_aton an inline function for increased performance
-C4800, performance warning about bool forcing, resolved at all occurrences.
-C4701, uninitialized variable 'cached', resolved at all occurrences.
-dlerror() was migrated out of the wrapper for more thread safety (no global buffer being shared) and increased performance.
-Removed the wrong CRT debug flags. This drains a lot of performance.
-Removed the clock_gettime/gettimeofday wrappers
-Replaced all TCHAR/ANSI mix-ups of functions with the correct respective function.
-Added a block of C4355 for < VS2012
-Update project files for c870714
2012-10-12 22:31:38 +02:00
|
|
|
{TEXT("InspIRCd"), (LPSERVICE_MAIN_FUNCTION) ServiceMain },
|
2008-08-22 20:01:13 +00:00
|
|
|
{NULL, NULL}
|
|
|
|
};
|
|
|
|
|
|
|
|
StartServiceCtrlDispatcher(serviceTable);
|
|
|
|
return 0;
|
|
|
|
}
|