vlmcsd-1107-2016-12-12-Hotbird64

pull/5/head svn1107
Wind4 8 years ago
parent af593fc11b
commit c5e1a0a591

@ -198,6 +198,7 @@ help:
@echo " -DNO_SOCKETS Don't support standalone operation. Requires an internet superserver to start $(BASE_PROGRAM_NAME)."
@echo " -DSIMPLE_SOCKETS Compile $(BASE_PROGRAM_NAME) with basic socket support only. Removes -L option."
@echo " -DSIMPLE_RPC Don't support RPC with NDR64 and BTFN in $(BASE_PROGRAM_NAME) (but do in $(BASE_CLIENT_NAME)). Makes emulator detection easy."
@echo " -DNO_TAP Compile $(BASE_PROGRAM_NAME) without VPN support (Windows and Cygwin only)."
@echo " -DNO_CL_PIDS Don't support specifying ePIDs and HwId from the command line in $(BASE_PROGRAM_NAME)."
@echo " -DNO_LIMIT Don't support limiting concurrent clients in $(BASE_PROGRAM_NAME)."
@echo " -DNO_SIGHUP Don't support SIGHUP handling in $(BASE_PROGRAM_NAME)."

Binary file not shown.

@ -1,5 +1,5 @@
<!-- Creator : groff version 1.22.3 -->
<!-- CreationDate: Mon Dec 5 18:18:46 2016 -->
<!-- CreationDate: Sun Dec 11 22:03:19 2016 -->
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>

Binary file not shown.

@ -1,5 +1,5 @@
<!-- Creator : groff version 1.22.3 -->
<!-- CreationDate: Mon Dec 5 18:18:46 2016 -->
<!-- CreationDate: Sun Dec 11 22:03:20 2016 -->
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>

Binary file not shown.

@ -1,5 +1,5 @@
<!-- Creator : groff version 1.22.3 -->
<!-- CreationDate: Mon Dec 5 18:18:46 2016 -->
<!-- CreationDate: Sun Dec 11 22:03:19 2016 -->
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>

Binary file not shown.

@ -1,5 +1,5 @@
<!-- Creator : groff version 1.22.3 -->
<!-- CreationDate: Mon Dec 5 18:18:46 2016 -->
<!-- CreationDate: Sun Dec 11 22:03:20 2016 -->
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>

Binary file not shown.

@ -1,5 +1,5 @@
<!-- Creator : groff version 1.22.3 -->
<!-- CreationDate: Mon Dec 5 18:18:46 2016 -->
<!-- CreationDate: Sun Dec 11 22:03:20 2016 -->
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>

Binary file not shown.

@ -1,5 +1,5 @@
<!-- Creator : groff version 1.22.3 -->
<!-- CreationDate: Mon Dec 5 18:18:46 2016 -->
<!-- CreationDate: Sun Dec 11 22:03:19 2016 -->
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>

Binary file not shown.

@ -257,14 +257,14 @@ else
STRIPFLAGS += -s
endif
LIBRARY_CFLAGS = -DSIMPLE_SOCKETS -DNO_TIMEOUT -DNO_SIGHUP -DNO_CL_PIDS -DNO_LOG -DNO_RANDOM_EPID -DNO_INI_FILE -DNO_HELP -DNO_CUSTOM_INTERVALS -DNO_PID_FILE -DNO_USER_SWITCH -DNO_VERBOSE_LOG -DNO_LIMIT -DNO_VERSION_INFORMATION -DNO_PRIVATE_IP_DETECT -DNO_STRICT_MODES -DNO_CLIENT_LIST -UNO_SOCKETS -USIMPLE_RPC
LIBRARY_CFLAGS = -DSIMPLE_SOCKETS -DNO_TIMEOUT -DNO_SIGHUP -DNO_CL_PIDS -DNO_LOG -DNO_RANDOM_EPID -DNO_INI_FILE -DNO_HELP -DNO_CUSTOM_INTERVALS -DNO_PID_FILE -DNO_USER_SWITCH -DNO_VERBOSE_LOG -DNO_LIMIT -DNO_VERSION_INFORMATION -DNO_PRIVATE_IP_DETECT -DNO_STRICT_MODES -DNO_CLIENT_LIST -DNO_TAP -UNO_SOCKETS -USIMPLE_RPC
ifeq ($(FEATURES), embedded)
BASECFLAGS += -DNO_HELP -DNO_USER_SWITCH -DNO_CUSTOM_INTERVALS -DNO_PID_FILE -DNO_VERBOSE_LOG -DNO_VERSION_INFORMATION
else ifeq ($(FEATURES), autostart)
BASECFLAGS += -DNO_HELP -DNO_VERSION_INFORMATION
else ifeq ($(FEATURES), minimum)
BASECFLAGS += -DSIMPLE_RPC -DSIMPLE_SOCKETS -DNO_TIMEOUT -DNO_SIGHUP -DNO_CL_PIDS -DNO_LOG -DNO_RANDOM_EPID -DNO_INI_FILE -DNO_HELP -DNO_CUSTOM_INTERVALS -DNO_PID_FILE -DNO_USER_SWITCH -DNO_VERBOSE_LOG -DNO_LIMIT -DNO_VERSION_INFORMATION -DNO_PRIVATE_IP_DETECT -DSMALL_AES -DNO_STRICT_MODES -DNO_CLIENT_LIST -DUNSAFE_DATA_LOAD -DNO_EXTERNAL_DATA -UFULL_INTERNAL_DATA -U_PEDANTIC
BASECFLAGS += -DSIMPLE_RPC -DSIMPLE_SOCKETS -DNO_TIMEOUT -DNO_SIGHUP -DNO_CL_PIDS -DNO_LOG -DNO_RANDOM_EPID -DNO_INI_FILE -DNO_HELP -DNO_CUSTOM_INTERVALS -DNO_PID_FILE -DNO_USER_SWITCH -DNO_VERBOSE_LOG -DNO_LIMIT -DNO_VERSION_INFORMATION -DNO_PRIVATE_IP_DETECT -DSMALL_AES -DNO_STRICT_MODES -DNO_TAP -DNO_CLIENT_LIST -DUNSAFE_DATA_LOAD -DNO_EXTERNAL_DATA -UFULL_INTERNAL_DATA -U_PEDANTIC
else ifeq ($(FEATURES), most)
BASECFLAGS += -DNO_SIGHUP -DNO_PID_FILE -DNO_LIMIT
else ifeq ($(FEATURES), inetd)

@ -31,26 +31,6 @@
/*
* Define default ePIDs and HWID here. Preferrably grab ePIDs and HWID
* from a real KMS server.
*/
//#ifndef EPID_WINDOWS
//#define EPID_WINDOWS "03612-00206-471-452343-03-1033-14393.0000-2932016"
//#endif
//
//#ifndef EPID_OFFICE2010
//#define EPID_OFFICE2010 "03612-00096-199-303490-03-1033-14393.0000-2932016"
//#endif
//
//#ifndef EPID_OFFICE2013
//#define EPID_OFFICE2013 "03612-00206-234-394838-03-1033-14393.0000-2932016"
//#endif
//
//#ifndef EPID_OFFICE2016
//#define EPID_OFFICE2016 "03612-00206-437-938923-03-1033-14393.0000-2932016"
//#endif
#ifndef HWID // HwId from the Ratiborus VM
#define HWID 0x3A, 0x1C, 0x04, 0x96, 0x00, 0xB6, 0x00, 0x76
@ -67,21 +47,21 @@
/*
* -------------------------------
* Defaults
* -------------------------------
*/
/*
* -------------------------------
* Defaults
* -------------------------------
*/
#ifndef INI_FILE
/*
* Uncomment and customize the following line if you want vlmcsd to look for an ini file
* at a default location.
*/
/*
* Uncomment and customize the following line if you want vlmcsd to look for an ini file
* at a default location.
*/
//#define INI_FILE "/etc/vlmcsd.ini"
//#define INI_FILE "/etc/vlmcsd.ini"
#endif // INI_FILE
@ -95,7 +75,7 @@
* at a custom default location.
*/
//#define DATA_FILE "/etc/vlmcsd.kmd"
//#define DATA_FILE "/etc/vlmcsd.kmd"
#endif // DATA_FILE
@ -353,7 +333,7 @@
* Includes the full database in vlmcsd.
*/
//#define FULL_INTERNAL_DATA
//#define FULL_INTERNAL_DATA
#endif // FULL_INTERNAL_DATA
@ -374,13 +354,25 @@
* your system.
*/
//#define NO_FREEBIND
//#define NO_FREEBIND
#endif // NO_FREEBIND
#ifndef NO_TAP
/*
* Do not compile support for using a VPN adapter under Windows. Disables -O command line option.
*/
//#define NO_TAP
#endif // NO_TAP
#ifndef NO_VERSION_INFORMATION
/*
* Removes the -V option from vlmcsd and vlmcs that displays the version information
@ -493,7 +485,7 @@
* and ini file parameter KmsData. Implies UNSAFE_DATA_LOAD.
*/
//#define NO_EXTERNAL_DATA
//#define NO_EXTERNAL_DATA
#endif // NO_EXTERNAL_DATA
@ -507,7 +499,7 @@
* the program exits with an error message.
*/
//#define NO_INTERNAL_DATA
//#define NO_INTERNAL_DATA
#endif // NO_INTERNAL_DATA
@ -658,7 +650,7 @@
* smaller binaries but makes emulator detection easier.
*/
//#define SIMPLE_RPC
//#define SIMPLE_RPC
#endif // !SIMPLE_RPC
@ -670,7 +662,7 @@
* It still supports IPv4 and IPv6.
*/
//#define SIMPLE_SOCKETS
//#define SIMPLE_SOCKETS
#endif // SIMPLE_SOCKETS

@ -455,7 +455,7 @@ void getExeName()
fn_exe = (char*)getauxval(AT_EXECFN);
# elif __UCLIBC__ && __UCLIBC_MAJOR__ < 1 && !defined(NO_PROCFS) // Workaround for older uclibc
# elif (__ANDROID__ && __ANDROID_API__ < 16) || (__UCLIBC__ && __UCLIBC_MAJOR__ < 1 && !defined(NO_PROCFS)) // Workaround for older uclibc
char temp[PATH_MAX + 1];

@ -301,7 +301,7 @@ static void generateRandomPid(int index, char *const szPid, int serverType, int1
time(&maxTime);
# ifndef BUILD_TIME
# define BUILD_TIME 1479938320
# define BUILD_TIME 1481079869
# endif
if (maxTime < (time_t)BUILD_TIME) // Just in case the system time is < 10/17/2013 1:00 pm

@ -294,7 +294,6 @@ SOCKET connectToAddress(const char *const addr, const int AddressFamily, int_fas
#ifndef NO_SOCKETS
#ifdef SIMPLE_SOCKETS
static int_fast8_t allowSocketReuse(SOCKET s)
{
@ -322,6 +321,8 @@ static int_fast8_t allowSocketReuse(SOCKET s)
}
#ifdef SIMPLE_SOCKETS
int listenOnAllAddresses()
{
uint32_t port_listen;
@ -575,14 +576,7 @@ static int listenOnAddress(const struct addrinfo *const ai, SOCKET *s)
}
# endif
# if !_WIN32 && !__CYGWIN__
if (setsockopt(*s, SOL_SOCKET, SO_REUSEADDR, (sockopt_t)&socketOption, sizeof(socketOption)))
{
# ifdef _PEDANTIC
printerrorf("Warning: %s does not support socket option SO_REUSEADDR: %s\n", ipstr, vlmcsd_strerror(socket_errno));
# endif // _PEDANTIC
}
# endif // !_WIN32 && !__CYGWIN__
allowSocketReuse(*s);
# if HAVE_FREEBIND
# if (defined(IP_NONLOCALOK) || __FreeBSD_kernel__ || __FreeBSD__) && !defined(IPV6_BINDANY)

@ -16,115 +16,108 @@ SERVICE_STATUS_HANDLE gSvcStatusHandle;
VOID WINAPI ServiceCtrlHandler(DWORD dwCtrl)
{
// Handle the requested control code.
// Handle the requested control code.
switch(dwCtrl)
switch (dwCtrl)
{
case SERVICE_CONTROL_STOP:
case SERVICE_CONTROL_SHUTDOWN:
case SERVICE_CONTROL_STOP:
case SERVICE_CONTROL_SHUTDOWN:
ServiceShutdown = TRUE;
ReportServiceStatus(SERVICE_STOP_PENDING, NO_ERROR, 0);
ServiceShutdown = TRUE;
ReportServiceStatus(SERVICE_STOP_PENDING, NO_ERROR, 0);
// Remove PID file and free ressources
cleanup();
# ifdef USE_MSRPC
ReportServiceStatus(SERVICE_STOPPED, NO_ERROR, 0);
# endif // !USE_MSRPC
return;
// Remove PID file and free ressources
cleanup();
# if __CYGWIN__ || defined(USE_MSRPC)
ReportServiceStatus(SERVICE_STOPPED, NO_ERROR, 0);
# endif // __CYGWIN__
default:
break;
default:
break;
}
}
static VOID WINAPI ServiceMain(const int argc_unused, CARGV argv_unused)
{
// Register the handler function for the service
gSvcStatusHandle = RegisterServiceCtrlHandler(
NT_SERVICE_NAME,
ServiceCtrlHandler
);
// Register the handler function for the service
if(!gSvcStatusHandle)
{
//ServiceReportEvent(RegisterServiceCtrlHandler);
return;
}
if (!((gSvcStatusHandle = RegisterServiceCtrlHandler(NT_SERVICE_NAME, ServiceCtrlHandler))))
{
return;
}
// These SERVICE_STATUS members remain as set here
// These SERVICE_STATUS members remain as set here
gSvcStatus.dwServiceType = SERVICE_WIN32_OWN_PROCESS;
gSvcStatus.dwServiceSpecificExitCode = 0;
gSvcStatus.dwServiceType = SERVICE_WIN32_OWN_PROCESS;
gSvcStatus.dwServiceSpecificExitCode = 0;
// Run the actual program
ReportServiceStatus(SERVICE_STOPPED, newmain(), 3000);
// Run the actual program
ReportServiceStatus(SERVICE_STOPPED, newmain(), 3000);
}
SERVICE_TABLE_ENTRY NTServiceDispatchTable[] = {
{
(LPSTR)NT_SERVICE_NAME,
(LPSERVICE_MAIN_FUNCTION) ServiceMain
},
{
NULL,
NULL
}
{
(LPSTR)NT_SERVICE_NAME,
(LPSERVICE_MAIN_FUNCTION)ServiceMain
},
{
NULL,
NULL
}
};
VOID ReportServiceStatus(const DWORD dwCurrentState, const DWORD dwWin32ExitCode, const DWORD dwWaitHint)
{
static DWORD dwCheckPoint = 1;
static DWORD dwCheckPoint = 1;
// Fill in the SERVICE_STATUS structure.
// Fill in the SERVICE_STATUS structure.
gSvcStatus.dwCurrentState = dwCurrentState;
gSvcStatus.dwWin32ExitCode = dwWin32ExitCode;
gSvcStatus.dwWaitHint = dwWaitHint;
gSvcStatus.dwCurrentState = dwCurrentState;
gSvcStatus.dwWin32ExitCode = dwWin32ExitCode;
gSvcStatus.dwWaitHint = dwWaitHint;
if (dwCurrentState == SERVICE_START_PENDING)
gSvcStatus.dwControlsAccepted = 0;
else
gSvcStatus.dwControlsAccepted = SERVICE_ACCEPT_STOP;
if (dwCurrentState == SERVICE_START_PENDING)
gSvcStatus.dwControlsAccepted = 0;
else
gSvcStatus.dwControlsAccepted = SERVICE_ACCEPT_STOP;
if ( (dwCurrentState == SERVICE_RUNNING) ||
(dwCurrentState == SERVICE_STOPPED) )
gSvcStatus.dwCheckPoint = 0;
else
gSvcStatus.dwCheckPoint = dwCheckPoint++;
if ((dwCurrentState == SERVICE_RUNNING) ||
(dwCurrentState == SERVICE_STOPPED))
gSvcStatus.dwCheckPoint = 0;
else
gSvcStatus.dwCheckPoint = dwCheckPoint++;
// Report the status of the service to the SCM.
SetServiceStatus(gSvcStatusHandle, &gSvcStatus);
// Report the status of the service to the SCM.
SetServiceStatus(gSvcStatusHandle, &gSvcStatus);
}
/*VOID ServiceReportEvent(char *szFunction)
{
HANDLE hEventSource;
const char *eventStrings[2];
TCHAR Buffer[80];
hEventSource = RegisterEventSource(NULL, NT_SERVICE_NAME);
if (hEventSource)
{
snprintf(Buffer, 80, "%s failed with %d", szFunction, GetLastError());
eventStrings[0] = NT_SERVICE_NAME;
eventStrings[1] = Buffer;
ReportEvent(hEventSource, // event log handle
EVENTLOG_ERROR_TYPE, // event type
0, // event category
00, // event identifier
NULL, // no security identifier
2, // size of lpszStrings array
0, // no binary data
eventStrings, // array of strings
NULL); // no binary data
DeregisterEventSource(hEventSource);
}
HANDLE hEventSource;
const char *eventStrings[2];
TCHAR Buffer[80];
hEventSource = RegisterEventSource(NULL, NT_SERVICE_NAME);
if (hEventSource)
{
snprintf(Buffer, 80, "%s failed with %d", szFunction, GetLastError());
eventStrings[0] = NT_SERVICE_NAME;
eventStrings[1] = Buffer;
ReportEvent(hEventSource, // event log handle
EVENTLOG_ERROR_TYPE, // event type
0, // event category
00, // event identifier
NULL, // no security identifier
2, // size of lpszStrings array
0, // no binary data
eventStrings, // array of strings
NULL); // no binary data
DeregisterEventSource(hEventSource);
}
}*/
//Returns 0=Error, 1=Success, 2=Doesn't exist
@ -146,12 +139,12 @@ static uint_fast8_t OpenAndRemoveService(DWORD *dwPreviousState, SC_HANDLE *schS
closeManager = TRUE;
}
*schSCManager = OpenSCManager(
NULL, // local computer
NULL, // ServicesActive database
SC_MANAGER_ALL_ACCESS); // full access rights
*schSCManager = OpenSCManager(
NULL, // local computer
NULL, // ServicesActive database
SC_MANAGER_ALL_ACCESS); // full access rights
if (!*schSCManager) return 0;
if (!*schSCManager) return 0;
if (!((installedService = OpenService(*schSCManager, NT_SERVICE_NAME, SERVICE_ALL_ACCESS))))
{
@ -182,86 +175,86 @@ static uint_fast8_t OpenAndRemoveService(DWORD *dwPreviousState, SC_HANDLE *schS
static VOID ServiceInstaller(const char *restrict ServiceUser, const char *const ServicePassword)
{
SC_HANDLE schSCManager;
SC_HANDLE schService;
char szPath[MAX_PATH] = "\"";
if (!GetModuleFileName(NULL, szPath + sizeof(char), MAX_PATH - 1))
{
errorout("Cannot install service (%d)\n", (uint32_t)GetLastError());
return;
}
strcat(szPath,"\"");
int i;
for (i = 1; i < global_argc; i ++)
{
// Strip unneccessary parameters, especially the password
if (!strcmp(global_argv[i], "-s")) continue;
if (!strcmp(global_argv[i], "-W") ||
!strcmp(global_argv[i], "-U"))
{
i++;
continue;
}
strcat(szPath, " ");
if (strchr(global_argv[i], ' '))
{
strcat(szPath, "\"");
strcat(szPath, global_argv[i]);
strcat(szPath, "\"");
}
else
strcat(szPath, global_argv[i]);
}
// Get a handle to the SCM database.
SC_HANDLE schSCManager;
SC_HANDLE schService;
char szPath[MAX_PATH] = "\"";
if (!GetModuleFileName(NULL, szPath + sizeof(char), MAX_PATH - 1))
{
errorout("Cannot install service (%d)\n", (uint32_t)GetLastError());
return;
}
strcat(szPath, "\"");
int i;
for (i = 1; i < global_argc; i++)
{
// Strip unneccessary parameters, especially the password
if (!strcmp(global_argv[i], "-s")) continue;
if (!strcmp(global_argv[i], "-W") ||
!strcmp(global_argv[i], "-U"))
{
i++;
continue;
}
strcat(szPath, " ");
if (strchr(global_argv[i], ' '))
{
strcat(szPath, "\"");
strcat(szPath, global_argv[i]);
strcat(szPath, "\"");
}
else
strcat(szPath, global_argv[i]);
}
// Get a handle to the SCM database.
SERVICE_STATUS status;
DWORD dwPreviousState;
if (!OpenAndRemoveService(&dwPreviousState, &schSCManager))
{
errorout("Service removal failed (%d)\n", (uint32_t)GetLastError());
return;
}
if (!OpenAndRemoveService(&dwPreviousState, &schSCManager))
{
errorout("Service removal failed (%d)\n", (uint32_t)GetLastError());
return;
}
char *tempUser = NULL;
if (ServiceUser)
{
// Shortcuts for some well known users
if (!strcasecmp(ServiceUser, "/l")) ServiceUser="NT AUTHORITY\\LocalService";
if (!strcasecmp(ServiceUser, "/n")) ServiceUser="NT AUTHORITY\\NetworkService";
// Allow Local Users without .\ , e.g. "johndoe" instead of ".\johndoe"
if (!strchr(ServiceUser, '\\'))
{
tempUser = (char*)vlmcsd_malloc(strlen(ServiceUser) + 3);
strcpy(tempUser, ".\\");
strcat(tempUser, ServiceUser);
ServiceUser = tempUser;
}
}
{
// Shortcuts for some well known users
if (!strcasecmp(ServiceUser, "/l")) ServiceUser = "NT AUTHORITY\\LocalService";
if (!strcasecmp(ServiceUser, "/n")) ServiceUser = "NT AUTHORITY\\NetworkService";
// Allow Local Users without .\ , e.g. "johndoe" instead of ".\johndoe"
if (!strchr(ServiceUser, '\\'))
{
tempUser = (char*)vlmcsd_malloc(strlen(ServiceUser) + 3);
strcpy(tempUser, ".\\");
strcat(tempUser, ServiceUser);
ServiceUser = tempUser;
}
}
schService = CreateService(
schSCManager, // SCM database
NT_SERVICE_NAME, // name of service
NT_SERVICE_DISPLAY_NAME, // service name to display
SERVICE_ALL_ACCESS, // desired access
SERVICE_WIN32_OWN_PROCESS, // service type
SERVICE_AUTO_START, // start type
SERVICE_ERROR_NORMAL, // error control type
szPath, // path to service's binary
NULL, // no load ordering group
NULL, // no tag identifier
"tcpip\0", // depends on TCP/IP
ServiceUser, // LocalSystem account
ServicePassword); // no password
schSCManager, // SCM database
NT_SERVICE_NAME, // name of service
NT_SERVICE_DISPLAY_NAME, // service name to display
SERVICE_ALL_ACCESS, // desired access
SERVICE_WIN32_OWN_PROCESS, // service type
SERVICE_AUTO_START, // start type
SERVICE_ERROR_NORMAL, // error control type
szPath, // path to service's binary
NULL, // no load ordering group
NULL, // no tag identifier
"tcpip\0", // depends on TCP/IP
ServiceUser, // LocalSystem account
ServicePassword); // no password
# if __clang__ && (__CYGWIN__ || __MINGW64__ )
// Workaround for clang not understanding some GCC asm syntax used in <w32api/psdk_inc/intrin-impl.h>
@ -271,43 +264,43 @@ static VOID ServiceInstaller(const char *restrict ServiceUser, const char *const
# endif
if (tempUser) free(tempUser);
if (schService == NULL)
{
errorout("CreateService failed (%u)\n", (uint32_t)GetLastError());
CloseServiceHandle(schSCManager);
return;
}
else
{
errorout("Service installed successfully\n");
if (dwPreviousState == SERVICE_RUNNING)
{
printf("Restarting " NT_SERVICE_NAME " service => ");
status.dwCurrentState = SERVICE_STOPPED;
if (StartService(schService, 0, NULL))
{
for (i = 0; i < 10; i++)
{
if (!QueryServiceStatus(schService, &status) || status.dwCurrentState != SERVICE_START_PENDING) break;
Sleep(100);
}
if (status.dwCurrentState == SERVICE_RUNNING)
printf("Success\n");
else if (status.dwCurrentState == SERVICE_START_PENDING)
printf("Not ready within a second\n");
else
errorout("Error\n");
}
else
errorout("Error %u\n", (uint32_t)GetLastError());
}
}
CloseServiceHandle(schService);
CloseServiceHandle(schSCManager);
if (schService == NULL)
{
errorout("CreateService failed (%u)\n", (uint32_t)GetLastError());
CloseServiceHandle(schSCManager);
return;
}
else
{
errorout("Service installed successfully\n");
if (dwPreviousState == SERVICE_RUNNING)
{
printf("Restarting " NT_SERVICE_NAME " service => ");
status.dwCurrentState = SERVICE_STOPPED;
if (StartService(schService, 0, NULL))
{
for (i = 0; i < 10; i++)
{
if (!QueryServiceStatus(schService, &status) || status.dwCurrentState != SERVICE_START_PENDING) break;
Sleep(100);
}
if (status.dwCurrentState == SERVICE_RUNNING)
printf("Success\n");
else if (status.dwCurrentState == SERVICE_START_PENDING)
printf("Not ready within a second\n");
else
errorout("Error\n");
}
else
errorout("Error %u\n", (uint32_t)GetLastError());
}
}
CloseServiceHandle(schService);
CloseServiceHandle(schSCManager);
}
int NtServiceInstallation(const int_fast8_t installService, const char *restrict ServiceUser, const char *const ServicePassword)
@ -322,7 +315,7 @@ int NtServiceInstallation(const int_fast8_t installService, const char *restrict
if (installService == 2) // Remove
{
switch(OpenAndRemoveService(NULL, NULL))
switch (OpenAndRemoveService(NULL, NULL))
{
case 0:
errorout("Error removing service %s\n", NT_SERVICE_NAME);

@ -17,6 +17,10 @@
#include "tap-windows.h"
#include <iphlpapi.h>
#if !_WIN32
#include <arpa/inet.h>
#endif // !_WIN32
static char* szIpAddress = "10.10.10.9";
static char* szMask = "30";
static char* szTapName;
@ -117,7 +121,7 @@ static void parseTapArgument(char* argument)
exit(VLMCSD_EINVAL);
}
Mask = (uint32_t)~(UINT_MAX >> Cidr);
Mask = (uint32_t)~(0xffffffff >> Cidr);
Network = IpAddress & Mask;
Broadcast = IpAddress | ~Mask;
DhcpServer = IpAddress + 1;

Loading…
Cancel
Save