mirror of
https://github.com/reactos/reactos.git
synced 2024-12-28 18:15:11 +00:00
Merge tcpsvcs changes from audited repositry
Revision: 73 Author: gedmurphy Date: 17:36:44, 03 February 2006 Message: fixed security issues - fixes bug 1307 fixed unicode over network issues ---- Modified : /trunk/reactos/base/services/tcpsvcs/chargen.c Modified : /trunk/reactos/base/services/tcpsvcs/daytime.c Modified : /trunk/reactos/base/services/tcpsvcs/discard.c Modified : /trunk/reactos/base/services/tcpsvcs/echo.c Modified : /trunk/reactos/base/services/tcpsvcs/qotd.c Modified : /trunk/reactos/base/services/tcpsvcs/skelserver.c Modified : /trunk/reactos/base/services/tcpsvcs/tcpsvcs.c Modified : /trunk/reactos/base/services/tcpsvcs/tcpsvcs.h svn path=/trunk/; revision=21163
This commit is contained in:
parent
fb1a32ea73
commit
db000e5299
9 changed files with 87 additions and 127 deletions
|
@ -1,14 +1,9 @@
|
||||||
/*
|
/*
|
||||||
* ReactOS Services
|
|
||||||
* Copyright (C) 2005 ReactOS Team
|
|
||||||
*
|
|
||||||
* LICENCE: GPL - See COPYING in the top level directory
|
|
||||||
* PROJECT: ReactOS simple TCP/IP services
|
* PROJECT: ReactOS simple TCP/IP services
|
||||||
* FILE: apps/utils/net/tcpsvcs/chargen.c
|
* LICENSE: GPL - See COPYING in the top level directory
|
||||||
* PURPOSE: Provide CharGen, Daytime, Discard, Echo, and Qotd services
|
* FILE: /base/services/tcpsvcs/chargen.c
|
||||||
* PROGRAMMERS: Ged Murphy (gedmurphy@gmail.com)
|
* PURPOSE: Provide CharGen, Daytime, Discard, Echo, and Qotd services
|
||||||
* REVISIONS:
|
* COPYRIGHT: Copyright 2005 - 2006 Ged Murphy <gedmurphy@gmail.com>
|
||||||
* GM 04/10/05 Created
|
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
@ -35,7 +30,7 @@ DWORD WINAPI ChargenHandler(VOID* Sock_)
|
||||||
LogEvent(_T("Chargen: Connection shutdown failed\n"), 0, FALSE);
|
LogEvent(_T("Chargen: Connection shutdown failed\n"), 0, FALSE);
|
||||||
RetVal = 1;
|
RetVal = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
LogEvent(_T("Chargen: Terminating thread\n"), 0, FALSE);
|
LogEvent(_T("Chargen: Terminating thread\n"), 0, FALSE);
|
||||||
ExitThread(RetVal);
|
ExitThread(RetVal);
|
||||||
|
|
||||||
|
@ -78,8 +73,8 @@ BOOL GenerateChars(SOCKET Sock)
|
||||||
charIndex++;
|
charIndex++;
|
||||||
}
|
}
|
||||||
|
|
||||||
Line[LINESIZ - 2] = L'\r';
|
Line[LINESIZ - 2] = '\r';
|
||||||
Line[LINESIZ - 1] = L'\n';
|
Line[LINESIZ - 1] = '\n';
|
||||||
|
|
||||||
if (! SendLine(Sock, Line))
|
if (! SendLine(Sock, Line))
|
||||||
break;
|
break;
|
||||||
|
@ -87,14 +82,14 @@ BOOL GenerateChars(SOCKET Sock)
|
||||||
/* increment loop index to start printing from next char in ring */
|
/* increment loop index to start printing from next char in ring */
|
||||||
loopIndex++;
|
loopIndex++;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (bShutDown)
|
if (bShutDown)
|
||||||
return FALSE;
|
return FALSE;
|
||||||
else
|
else
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
BOOL SendLine(SOCKET Sock, TCHAR* Line)
|
BOOL SendLine(SOCKET Sock, char* Line)
|
||||||
{
|
{
|
||||||
INT RetVal;
|
INT RetVal;
|
||||||
INT SentBytes;
|
INT SentBytes;
|
||||||
|
|
|
@ -1,14 +1,9 @@
|
||||||
/*
|
/*
|
||||||
* ReactOS Services
|
|
||||||
* Copyright (C) 2005 ReactOS Team
|
|
||||||
*
|
|
||||||
* LICENCE: GPL - See COPYING in the top level directory
|
|
||||||
* PROJECT: ReactOS simple TCP/IP services
|
* PROJECT: ReactOS simple TCP/IP services
|
||||||
* FILE: apps/utils/net/tcpsvcs/daytime.c
|
* LICENSE: GPL - See COPYING in the top level directory
|
||||||
* PURPOSE: Provide CharGen, Daytime, Discard, Echo, and Qotd services
|
* FILE: /base/services/tcpsvcs/daytime.c
|
||||||
* PROGRAMMERS: Ged Murphy (gedmurphy@gmail.com)
|
* PURPOSE: Provide CharGen, Daytime, Discard, Echo, and Qotd services
|
||||||
* REVISIONS:
|
* COPYRIGHT: Copyright 2005 - 2006 Ged Murphy <gedmurphy@gmail.com>
|
||||||
* GM 04/10/05 Created
|
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
@ -18,14 +13,14 @@ DWORD WINAPI DaytimeHandler(VOID* Sock_)
|
||||||
{
|
{
|
||||||
struct tm *newtime;
|
struct tm *newtime;
|
||||||
time_t aclock;
|
time_t aclock;
|
||||||
TCHAR *pszTime;
|
CHAR *pszTime;
|
||||||
DWORD RetVal = 0;
|
DWORD RetVal = 0;
|
||||||
SOCKET Sock = (SOCKET)Sock_;
|
SOCKET Sock = (SOCKET)Sock_;
|
||||||
|
|
||||||
time(&aclock);
|
time(&aclock);
|
||||||
newtime = localtime(&aclock);
|
newtime = localtime(&aclock);
|
||||||
pszTime = _tasctime(newtime);
|
pszTime = asctime(newtime);
|
||||||
|
|
||||||
SendTime(Sock, pszTime);
|
SendTime(Sock, pszTime);
|
||||||
|
|
||||||
LogEvent(_T("DayTime: Shutting connection down...\n"), 0, FALSE);
|
LogEvent(_T("DayTime: Shutting connection down...\n"), 0, FALSE);
|
||||||
|
@ -36,17 +31,17 @@ DWORD WINAPI DaytimeHandler(VOID* Sock_)
|
||||||
LogEvent(_T("DayTime: Connection shutdown failed\n"), 0, FALSE);
|
LogEvent(_T("DayTime: Connection shutdown failed\n"), 0, FALSE);
|
||||||
RetVal = 1;
|
RetVal = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
LogEvent(_T("DayTime: Terminating thread\n"), 0, FALSE);
|
LogEvent(_T("DayTime: Terminating thread\n"), 0, FALSE);
|
||||||
ExitThread(RetVal);
|
ExitThread(RetVal);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
BOOL SendTime(SOCKET Sock, TCHAR *time)
|
BOOL SendTime(SOCKET Sock, CHAR *time)
|
||||||
{
|
{
|
||||||
INT StringSize = (INT)_tcsclen(time);
|
INT StringSize = (INT)strlen(time);
|
||||||
INT RetVal = send(Sock, time, sizeof(TCHAR) * StringSize, 0);
|
INT RetVal = send(Sock, time, sizeof(CHAR) * StringSize, 0);
|
||||||
|
|
||||||
if (RetVal == SOCKET_ERROR)
|
if (RetVal == SOCKET_ERROR)
|
||||||
return FALSE;
|
return FALSE;
|
||||||
|
|
||||||
|
|
|
@ -1,14 +1,9 @@
|
||||||
/*
|
/*
|
||||||
* ReactOS Services
|
|
||||||
* Copyright (C) 2005 ReactOS Team
|
|
||||||
*
|
|
||||||
* LICENCE: GPL - See COPYING in the top level directory
|
|
||||||
* PROJECT: ReactOS simple TCP/IP services
|
* PROJECT: ReactOS simple TCP/IP services
|
||||||
* FILE: apps/utils/net/tcpsvcs/discard.c
|
* LICENSE: GPL - See COPYING in the top level directory
|
||||||
* PURPOSE: Provide CharGen, Daytime, Discard, Echo, and Qotd services
|
* FILE: /base/services/tcpsvcs/discard.c
|
||||||
* PROGRAMMERS: Ged Murphy (gedmurphy@gmail.com)
|
* PURPOSE: Provide CharGen, Daytime, Discard, Echo, and Qotd services
|
||||||
* REVISIONS:
|
* COPYRIGHT: Copyright 2005 - 2006 Ged Murphy <gedmurphy@gmail.com>
|
||||||
* GM 04/10/05 Created
|
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
@ -35,7 +30,7 @@ DWORD WINAPI DiscardHandler(VOID* Sock_)
|
||||||
LogEvent(_T("Discard: Connection shutdown failed\n"), 0, FALSE);
|
LogEvent(_T("Discard: Connection shutdown failed\n"), 0, FALSE);
|
||||||
RetVal = 1;
|
RetVal = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
LogEvent(_T("Discard: Terminating thread\n"), 0, FALSE);
|
LogEvent(_T("Discard: Terminating thread\n"), 0, FALSE);
|
||||||
ExitThread(RetVal);
|
ExitThread(RetVal);
|
||||||
}
|
}
|
||||||
|
@ -44,7 +39,7 @@ DWORD WINAPI DiscardHandler(VOID* Sock_)
|
||||||
|
|
||||||
BOOL RecieveIncomingPackets(SOCKET Sock)
|
BOOL RecieveIncomingPackets(SOCKET Sock)
|
||||||
{
|
{
|
||||||
TCHAR ReadBuffer[BUF];
|
char ReadBuffer[BUF];
|
||||||
TCHAR buf[256];
|
TCHAR buf[256];
|
||||||
INT ReadBytes;
|
INT ReadBytes;
|
||||||
|
|
||||||
|
@ -58,7 +53,7 @@ BOOL RecieveIncomingPackets(SOCKET Sock)
|
||||||
}
|
}
|
||||||
else if (ReadBytes == SOCKET_ERROR)
|
else if (ReadBytes == SOCKET_ERROR)
|
||||||
{
|
{
|
||||||
_stprintf(buf, ("Socket Error: %d\n"), WSAGetLastError());
|
_stprintf(buf, _T("Socket Error: %d\n"), WSAGetLastError());
|
||||||
LogEvent(buf, 0, TRUE);
|
LogEvent(buf, 0, TRUE);
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,14 +1,9 @@
|
||||||
/*
|
/*
|
||||||
* ReactOS Services
|
|
||||||
* Copyright (C) 2005 ReactOS Team
|
|
||||||
*
|
|
||||||
* LICENCE: GPL - See COPYING in the top level directory
|
|
||||||
* PROJECT: ReactOS simple TCP/IP services
|
* PROJECT: ReactOS simple TCP/IP services
|
||||||
* FILE: apps/utils/net/tcpsvcs/echo.c
|
* LICENSE: GPL - See COPYING in the top level directory
|
||||||
* PURPOSE: Provide CharGen, Daytime, Discard, Echo, and Qotd services
|
* FILE: /base/services/tcpsvcs/echo.c
|
||||||
* PROGRAMMERS: Ged Murphy (gedmurphy@gmail.com)
|
* PURPOSE: Provide CharGen, Daytime, Discard, Echo, and Qotd services
|
||||||
* REVISIONS:
|
* COPYRIGHT: Copyright 2005 - 2006 Ged Murphy <gedmurphy@gmail.com>
|
||||||
* GM 04/10/05 Created
|
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
@ -27,7 +22,7 @@ DWORD WINAPI EchoHandler(VOID* Sock_)
|
||||||
}
|
}
|
||||||
|
|
||||||
LogEvent(_T("Echo: Shutting connection down...\n"), 0, FALSE);
|
LogEvent(_T("Echo: Shutting connection down...\n"), 0, FALSE);
|
||||||
|
|
||||||
if (ShutdownConnection(Sock, TRUE))
|
if (ShutdownConnection(Sock, TRUE))
|
||||||
LogEvent(_T("Echo: Connection is down\n"), 0, FALSE);
|
LogEvent(_T("Echo: Connection is down\n"), 0, FALSE);
|
||||||
else
|
else
|
||||||
|
@ -35,7 +30,7 @@ DWORD WINAPI EchoHandler(VOID* Sock_)
|
||||||
LogEvent(_T("Echo: Connection shutdown failed\n"), 0, FALSE);
|
LogEvent(_T("Echo: Connection shutdown failed\n"), 0, FALSE);
|
||||||
RetVal = 1;
|
RetVal = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
LogEvent(_T("Echo: Terminating thread\n"), 0, FALSE);
|
LogEvent(_T("Echo: Terminating thread\n"), 0, FALSE);
|
||||||
ExitThread(RetVal);
|
ExitThread(RetVal);
|
||||||
}
|
}
|
||||||
|
@ -44,7 +39,7 @@ DWORD WINAPI EchoHandler(VOID* Sock_)
|
||||||
|
|
||||||
BOOL EchoIncomingPackets(SOCKET Sock)
|
BOOL EchoIncomingPackets(SOCKET Sock)
|
||||||
{
|
{
|
||||||
TCHAR ReadBuffer[BUF];
|
char ReadBuffer[BUF];
|
||||||
TCHAR buf[256]; // temp for holding LogEvent text
|
TCHAR buf[256]; // temp for holding LogEvent text
|
||||||
INT Temp;
|
INT Temp;
|
||||||
INT ReadBytes;
|
INT ReadBytes;
|
||||||
|
|
|
@ -1,29 +1,24 @@
|
||||||
/*
|
/*
|
||||||
* ReactOS Services
|
|
||||||
* Copyright (C) 2005 ReactOS Team
|
|
||||||
*
|
|
||||||
* LICENCE: GPL - See COPYING in the top level directory
|
|
||||||
* PROJECT: ReactOS simple TCP/IP services
|
* PROJECT: ReactOS simple TCP/IP services
|
||||||
* FILE: apps/utils/net/tcpsvcs/qotd.c
|
* LICENSE: GPL - See COPYING in the top level directory
|
||||||
* PURPOSE: Provide CharGen, Daytime, Discard, Echo, and Qotd services
|
* FILE: /base/services/tcpsvcs/qotd.c
|
||||||
* PROGRAMMERS: Ged Murphy (gedmurphy@gmail.com)
|
* PURPOSE: Provide CharGen, Daytime, Discard, Echo, and Qotd services
|
||||||
* REVISIONS:
|
* COPYRIGHT: Copyright 2005 - 2006 Ged Murphy <gedmurphy@gmail.com>
|
||||||
* GM 04/10/05 Created
|
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "tcpsvcs.h"
|
#include "tcpsvcs.h"
|
||||||
|
|
||||||
#define QBUFSIZ 160
|
#define QBUFSIZ 60
|
||||||
|
|
||||||
LPCTSTR FilePath = _T("\\drivers\\etc\\quotes");
|
LPCTSTR FilePath = _T("\\drivers\\etc\\quotes"); /* 19 chars */
|
||||||
|
|
||||||
DWORD WINAPI QotdHandler(VOID* Sock_)
|
DWORD WINAPI QotdHandler(VOID* Sock_)
|
||||||
{
|
{
|
||||||
FILE *fp;
|
FILE *fp;
|
||||||
SOCKET Sock;
|
SOCKET Sock;
|
||||||
TCHAR Sys[MAX_PATH];
|
TCHAR Sys[MAX_PATH + 20];
|
||||||
TCHAR Quote[60][BUFSIZ]; // need to set this dynamically
|
char Quote[QBUFSIZ][BUFSIZ]; // need to set this dynamically
|
||||||
INT QuoteToPrint;
|
INT QuoteToPrint;
|
||||||
INT NumQuotes;
|
INT NumQuotes;
|
||||||
|
|
||||||
|
@ -34,15 +29,15 @@ DWORD WINAPI QotdHandler(VOID* Sock_)
|
||||||
LogEvent(_T("QOTD: Getting system path failed.\n"), 0, TRUE);
|
LogEvent(_T("QOTD: Getting system path failed.\n"), 0, TRUE);
|
||||||
ExitThread(1);
|
ExitThread(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
_tcscat(Sys, FilePath);
|
_tcsncat(Sys, FilePath, _tcslen(FilePath));
|
||||||
|
|
||||||
LogEvent(_T("QOTD: Opening quotes file\n"), 0, FALSE);
|
LogEvent(_T("QOTD: Opening quotes file\n"), 0, FALSE);
|
||||||
if ((fp = _tfopen(Sys, "r")) == NULL)
|
if ((fp = _tfopen(Sys, _T("r"))) == NULL)
|
||||||
{
|
{
|
||||||
TCHAR buf[256];
|
TCHAR buf[320];
|
||||||
|
|
||||||
_stprintf(buf, _T("QOTD: Error opening quote file : %s\n"), Sys);
|
_sntprintf(buf, 320, _T("QOTD: Error opening quote file : %s\n"), Sys);
|
||||||
LogEvent(buf, 0, TRUE);
|
LogEvent(buf, 0, TRUE);
|
||||||
LogEvent(_T("QOTD: Terminating thread\n"), 0, FALSE);
|
LogEvent(_T("QOTD: Terminating thread\n"), 0, FALSE);
|
||||||
ExitThread(1);
|
ExitThread(1);
|
||||||
|
@ -50,7 +45,8 @@ DWORD WINAPI QotdHandler(VOID* Sock_)
|
||||||
|
|
||||||
/* read all quotes in the file into an array */
|
/* read all quotes in the file into an array */
|
||||||
NumQuotes = 0;
|
NumQuotes = 0;
|
||||||
while (_fgetts(Quote[NumQuotes], QBUFSIZ, fp) != NULL)
|
while ((fgets(Quote[NumQuotes], QBUFSIZ, fp) != NULL) &&
|
||||||
|
(NumQuotes != QBUFSIZ))
|
||||||
NumQuotes++;
|
NumQuotes++;
|
||||||
|
|
||||||
LogEvent(_T("QOTD: Closing quotes file\n"), 0, FALSE);
|
LogEvent(_T("QOTD: Closing quotes file\n"), 0, FALSE);
|
||||||
|
@ -73,21 +69,20 @@ DWORD WINAPI QotdHandler(VOID* Sock_)
|
||||||
LogEvent(_T("QOTD: Terminating thread\n"), 0, FALSE);
|
LogEvent(_T("QOTD: Terminating thread\n"), 0, FALSE);
|
||||||
ExitThread(1);
|
ExitThread(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
LogEvent(_T("QOTD: Terminating thread\n"), 0, FALSE);
|
LogEvent(_T("QOTD: Terminating thread\n"), 0, FALSE);
|
||||||
ExitThread(0);
|
ExitThread(0);
|
||||||
|
|
||||||
//return Retval;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
BOOL SendQuote(SOCKET Sock, TCHAR* Quote)
|
BOOL SendQuote(SOCKET Sock, char* Quote)
|
||||||
{
|
{
|
||||||
INT StringSize;
|
INT StringSize;
|
||||||
INT RetVal;
|
INT RetVal;
|
||||||
|
|
||||||
StringSize = (INT)_tcsclen(Quote);
|
StringSize = (INT)strlen(Quote);
|
||||||
RetVal = send(Sock, Quote, sizeof(TCHAR) * StringSize, 0);
|
RetVal = send(Sock, Quote, sizeof(char) * StringSize, 0);
|
||||||
|
|
||||||
if (RetVal == SOCKET_ERROR)
|
if (RetVal == SOCKET_ERROR)
|
||||||
return FALSE;
|
return FALSE;
|
||||||
|
|
|
@ -1,14 +1,9 @@
|
||||||
/*
|
/*
|
||||||
* ReactOS Services
|
|
||||||
* Copyright (C) 2005 ReactOS Team
|
|
||||||
*
|
|
||||||
* LICENCE: GPL - See COPYING in the top level directory
|
|
||||||
* PROJECT: ReactOS simple TCP/IP services
|
* PROJECT: ReactOS simple TCP/IP services
|
||||||
* FILE: apps/utils/net/tcpsvcs/skelserver.c
|
* LICENSE: GPL - See COPYING in the top level directory
|
||||||
|
* FILE: /base/services/tcpsvcs/skelserver.c
|
||||||
* PURPOSE: Provide CharGen, Daytime, Discard, Echo, and Qotd services
|
* PURPOSE: Provide CharGen, Daytime, Discard, Echo, and Qotd services
|
||||||
* PROGRAMMERS: Ged Murphy (gedmurphy@gmail.com)
|
* COPYRIGHT: Copyright 2005 - 2006 Ged Murphy <gedmurphy@gmail.com>
|
||||||
* REVISIONS:
|
|
||||||
* GM 04/10/05 Created
|
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
@ -29,7 +24,7 @@ DWORD WINAPI StartServer(LPVOID lpParam)
|
||||||
ListeningSocket = SetUpListener(htons(pServices->Port));
|
ListeningSocket = SetUpListener(htons(pServices->Port));
|
||||||
if (ListeningSocket == INVALID_SOCKET)
|
if (ListeningSocket == INVALID_SOCKET)
|
||||||
{
|
{
|
||||||
LogEvent("Socket error when setting up listener\n", 0, TRUE);
|
LogEvent(_T("Socket error when setting up listener\n"), 0, TRUE);
|
||||||
return 3;
|
return 3;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -136,7 +131,7 @@ VOID AcceptConnections(SOCKET ListeningSocket,
|
||||||
}
|
}
|
||||||
|
|
||||||
WaitForSingleObject(hThread, INFINITE);
|
WaitForSingleObject(hThread, INFINITE);
|
||||||
|
|
||||||
CloseHandle(hThread);
|
CloseHandle(hThread);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
|
|
@ -1,14 +1,9 @@
|
||||||
/*
|
/*
|
||||||
* ReactOS Services
|
|
||||||
* Copyright (C) 2005 ReactOS Team
|
|
||||||
*
|
|
||||||
* LICENCE: GPL - See COPYING in the top level directory
|
|
||||||
* PROJECT: ReactOS simple TCP/IP services
|
* PROJECT: ReactOS simple TCP/IP services
|
||||||
* FILE: apps/utils/net/tcpsvcs/tcpsvcs.c
|
* LICENSE: GPL - See COPYING in the top level directory
|
||||||
|
* FILE: /base/services/tcpsvcs/tcpsvcs.c
|
||||||
* PURPOSE: Provide CharGen, Daytime, Discard, Echo, and Qotd services
|
* PURPOSE: Provide CharGen, Daytime, Discard, Echo, and Qotd services
|
||||||
* PROGRAMMERS: Ged Murphy (gedmurphy@gmail.com)
|
* COPYRIGHT: Copyright 2005 - 2006 Ged Murphy <gedmurphy@gmail.com>
|
||||||
* REVISIONS:
|
|
||||||
* GM 04/10/05 Created
|
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
/*
|
/*
|
||||||
|
@ -36,7 +31,7 @@ FILE *hLogFile;
|
||||||
BOOL bShutDown = FALSE;
|
BOOL bShutDown = FALSE;
|
||||||
BOOL bPause = FALSE;
|
BOOL bPause = FALSE;
|
||||||
|
|
||||||
LPCTSTR LogFileName = "\\tcpsvcs_log.log";
|
LPCTSTR LogFileName = _T("\\tcpsvcs_log.log");
|
||||||
LPTSTR ServiceName = _T("Simp Tcp");
|
LPTSTR ServiceName = _T("Simp Tcp");
|
||||||
//LPTSTR DisplayName = _T("Simple TCP/IP Services");
|
//LPTSTR DisplayName = _T("Simple TCP/IP Services");
|
||||||
|
|
||||||
|
@ -74,19 +69,19 @@ main(void)
|
||||||
VOID WINAPI
|
VOID WINAPI
|
||||||
ServiceMain(DWORD argc, LPTSTR argv[])
|
ServiceMain(DWORD argc, LPTSTR argv[])
|
||||||
{
|
{
|
||||||
TCHAR LogFilePath[MAX_PATH];
|
TCHAR LogFilePath[MAX_PATH + 17];
|
||||||
|
|
||||||
if(! GetSystemDirectory(LogFilePath, MAX_PATH))
|
if(! GetSystemDirectory(LogFilePath, MAX_PATH))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
_tcscat(LogFilePath, LogFileName);
|
_tcsncat(LogFilePath, LogFileName, 17);
|
||||||
|
|
||||||
hLogFile = fopen(LogFilePath, _T("a+"));
|
hLogFile = _tfopen(LogFilePath, _T("a+"));
|
||||||
if (hLogFile == NULL)
|
if (hLogFile == NULL)
|
||||||
{
|
{
|
||||||
TCHAR buf[50];
|
TCHAR buf[300];
|
||||||
|
|
||||||
_stprintf(buf, _T("Could not open log file: %s\n"), LogFilePath);
|
_sntprintf(buf, 300, _T("Could not open log file: %s\n"), LogFilePath);
|
||||||
MessageBox(NULL, buf, NULL, MB_OK);
|
MessageBox(NULL, buf, NULL, MB_OK);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -125,7 +120,7 @@ ServiceMain(DWORD argc, LPTSTR argv[])
|
||||||
UpdateStatus (SERVICE_STOPPED, 0);
|
UpdateStatus (SERVICE_STOPPED, 0);
|
||||||
LogEvent(_T("Service status set to SERVICE_STOPPED\n"), 0, FALSE);
|
LogEvent(_T("Service status set to SERVICE_STOPPED\n"), 0, FALSE);
|
||||||
LogEvent(_T("Leaving ServiceMain\n"), 0, FALSE);
|
LogEvent(_T("Leaving ServiceMain\n"), 0, FALSE);
|
||||||
|
|
||||||
fclose(hLogFile);
|
fclose(hLogFile);
|
||||||
|
|
||||||
return;
|
return;
|
||||||
|
@ -237,10 +232,10 @@ CreateServers()
|
||||||
{
|
{
|
||||||
CloseHandle(hThread[i]);
|
CloseHandle(hThread[i]);
|
||||||
}
|
}
|
||||||
|
|
||||||
LogEvent(_T("Detaching Winsock2...\n"), 0, FALSE);
|
LogEvent(_T("Detaching Winsock2...\n"), 0, FALSE);
|
||||||
WSACleanup();
|
WSACleanup();
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -252,7 +247,7 @@ LogEvent (LPCTSTR UserMessage, INT ExitCode, BOOL PrintErrorMsg)
|
||||||
{
|
{
|
||||||
DWORD eMsgLen, ErrNum = GetLastError ();
|
DWORD eMsgLen, ErrNum = GetLastError ();
|
||||||
LPTSTR lpvSysMsg;
|
LPTSTR lpvSysMsg;
|
||||||
TCHAR MessageBuffer[512];
|
TCHAR MessageBuffer[1024];
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -263,16 +258,16 @@ LogEvent (LPCTSTR UserMessage, INT ExitCode, BOOL PrintErrorMsg)
|
||||||
ErrNum, MAKELANGID (LANG_NEUTRAL, SUBLANG_DEFAULT),
|
ErrNum, MAKELANGID (LANG_NEUTRAL, SUBLANG_DEFAULT),
|
||||||
(LPTSTR)&lpvSysMsg, 0, NULL);
|
(LPTSTR)&lpvSysMsg, 0, NULL);
|
||||||
|
|
||||||
_stprintf(MessageBuffer, _T("%s %s ErrNum = %lu. ExitCode = %d."),
|
_sntprintf(MessageBuffer, 1024, _T("%s %s ErrNum = %lu. ExitCode = %d."),
|
||||||
UserMessage, lpvSysMsg, ErrNum, ExitCode);
|
UserMessage, lpvSysMsg, ErrNum, ExitCode);
|
||||||
HeapFree(GetProcessHeap (), 0, lpvSysMsg);
|
HeapFree(GetProcessHeap (), 0, lpvSysMsg);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
_stprintf(MessageBuffer, _T("%s"), UserMessage);
|
_sntprintf(MessageBuffer, 1024, _T("%s"), UserMessage);
|
||||||
}
|
}
|
||||||
|
|
||||||
fputs (MessageBuffer, hLogFile);
|
_fputts(MessageBuffer, hLogFile);
|
||||||
|
|
||||||
if (ExitCode != 0)
|
if (ExitCode != 0)
|
||||||
ExitProcess(ExitCode);
|
ExitProcess(ExitCode);
|
||||||
|
|
|
@ -1,14 +1,9 @@
|
||||||
/*
|
/*
|
||||||
* ReactOS Services
|
|
||||||
* Copyright (C) 2005 ReactOS Team
|
|
||||||
*
|
|
||||||
* LICENCE: GPL - See COPYING in the top level directory
|
|
||||||
* PROJECT: ReactOS simple TCP/IP services
|
* PROJECT: ReactOS simple TCP/IP services
|
||||||
* FILE: apps/utils/net/tcpsvcs/tcpsvcs.h
|
* LICENSE: GPL - See COPYING in the top level directory
|
||||||
|
* FILE: /base/services/tcpsvcs/tcpsvcs.h
|
||||||
* PURPOSE: Provide CharGen, Daytime, Discard, Echo, and Qotd services
|
* PURPOSE: Provide CharGen, Daytime, Discard, Echo, and Qotd services
|
||||||
* PROGRAMMERS: Ged Murphy (gedmurphy@gmail.com)
|
* COPYRIGHT: Copyright 2005 - 2006 Ged Murphy <gedmurphy@gmail.com>
|
||||||
* REVISIONS:
|
|
||||||
* GM 04/10/05 Created
|
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
@ -17,9 +12,6 @@
|
||||||
#include <tchar.h>
|
#include <tchar.h>
|
||||||
#include <time.h>
|
#include <time.h>
|
||||||
|
|
||||||
#define UNICODE
|
|
||||||
#define _UNICODE
|
|
||||||
|
|
||||||
/* default port numbers */
|
/* default port numbers */
|
||||||
#define ECHO_PORT 7
|
#define ECHO_PORT 7
|
||||||
#define DISCARD_PORT 9
|
#define DISCARD_PORT 9
|
||||||
|
@ -68,11 +60,11 @@ BOOL ShutdownConnection(SOCKET Sock, BOOL bRec);
|
||||||
/* chargen functions */
|
/* chargen functions */
|
||||||
DWORD WINAPI ChargenHandler(VOID* Sock_);
|
DWORD WINAPI ChargenHandler(VOID* Sock_);
|
||||||
BOOL GenerateChars(SOCKET Sock);
|
BOOL GenerateChars(SOCKET Sock);
|
||||||
BOOL SendLine(SOCKET Sock, TCHAR* Line);
|
BOOL SendLine(SOCKET Sock, char* Line);
|
||||||
|
|
||||||
/* daytime functions */
|
/* daytime functions */
|
||||||
DWORD WINAPI DaytimeHandler(VOID* Sock_);
|
DWORD WINAPI DaytimeHandler(VOID* Sock_);
|
||||||
BOOL SendTime(SOCKET Sock, TCHAR *time);
|
BOOL SendTime(SOCKET Sock, char *time);
|
||||||
|
|
||||||
/* echo functions */
|
/* echo functions */
|
||||||
DWORD WINAPI EchoHandler(VOID* Sock_);
|
DWORD WINAPI EchoHandler(VOID* Sock_);
|
||||||
|
@ -84,4 +76,4 @@ BOOL RecieveIncomingPackets(SOCKET Sock);
|
||||||
|
|
||||||
/* qotd functions */
|
/* qotd functions */
|
||||||
DWORD WINAPI QotdHandler(VOID* Sock_);
|
DWORD WINAPI QotdHandler(VOID* Sock_);
|
||||||
BOOL SendQuote(SOCKET Sock, TCHAR* Quote);
|
BOOL SendQuote(SOCKET Sock, char* Quote);
|
||||||
|
|
|
@ -1,4 +1,6 @@
|
||||||
<module name="tcpsvcs" type="win32cui" installbase="system32" installname="tcpsvcs.exe">
|
<?xml version="1.0"?>
|
||||||
|
<rbuild xmlns:xi="http://www.w3.org/2001/XInclude">
|
||||||
|
<module name="tcpsvcs" type="win32cui" installbase="system32" installname="tcpsvcs.exe">
|
||||||
<include base="arp">.</include>
|
<include base="arp">.</include>
|
||||||
<define name="__USE_W32API" />
|
<define name="__USE_W32API" />
|
||||||
<library>kernel32</library>
|
<library>kernel32</library>
|
||||||
|
@ -14,4 +16,5 @@
|
||||||
<file>chargen.c</file>
|
<file>chargen.c</file>
|
||||||
<file>tcpsvcs.rc</file>
|
<file>tcpsvcs.rc</file>
|
||||||
<pch>tcpsvcs.h</pch>
|
<pch>tcpsvcs.h</pch>
|
||||||
</module>
|
</module>
|
||||||
|
</rbuild>
|
||||||
|
|
Loading…
Reference in a new issue