// This is used to define ChangeServiceConf2() as we can't link\r
// directly against this symbol (see below where it is used)\r
typedef BOOL (CALLBACK* SETSERVDESC)(SC_HANDLE,DWORD,LPVOID);\r
+\r
+/* A commandline parameter handler for service specific commandline parameters */\r
typedef void (*CommandlineParameterHandler)(void);\r
\r
+/* Represents a commandline and its handler */\r
+struct Commandline\r
+{\r
+ const char* Switch;\r
+ CommandlineParameterHandler Handler;\r
+};\r
+\r
+\r
SETSERVDESC ChangeServiceConf; // A function pointer for dynamic linking tricks\r
\r
\r
CloseServiceHandle(scm);\r
}\r
\r
-struct Commandline\r
-{\r
- const char* Switch;\r
- CommandlineParameterHandler Handler;\r
-};\r
-\r
/* In windows, our main() flows through here, before calling the 'real' main, smain() in inspircd.cpp */\r
int main(int argc, char** argv)\r
{\r
{\r
/* Service not installed or no permission to modify it */\r
CloseServiceHandle(scm);\r
- smain(argc, argv);\r
+ return smain(argc, argv);\r
}\r
}\r
else\r
{\r
/* Not enough privileges to open the SCM */\r
- smain(argc, argv);\r
+ return smain(argc, argv);\r
}\r
\r
CloseServiceHandle(myService);\r
CloseServiceHandle(scm);\r
\r
+ /* Check if the process is running interactively. InspIRCd does not run interactively\r
+ * as a service so if this is true, we just run the non-service inspircd.\r
+ */\r
+ USEROBJECTFLAGS uoflags;\r
+ HWINSTA winstation = GetProcessWindowStation();\r
+ if (GetUserObjectInformation(winstation, UOI_FLAGS, &uoflags, sizeof(uoflags), NULL))\r
+ {\r
+ if (uoflags.dwFlags == WSF_VISIBLE)\r
+ return smain(argc, argv);\r
+ }\r
+\r
/* If we get here, we know the service is installed so we can start it */\r
\r
SERVICE_TABLE_ENTRY serviceTable[] =\r