diff options
Diffstat (limited to 'CmdLine')
-rw-r--r-- | CmdLine/CmdLine.cpp | 115 | ||||
-rw-r--r-- | CmdLine/CmdLine.dsp | 361 | ||||
-rw-r--r-- | CmdLine/CmdLine.h | 57 | ||||
-rw-r--r-- | CmdLine/CmdLine.idl | 20 | ||||
-rw-r--r-- | CmdLine/CmdLine.rc | 170 | ||||
-rw-r--r-- | CmdLine/CmdLine.rgs | 11 | ||||
-rw-r--r-- | CmdLine/CmdLineApp.cpp | 104 | ||||
-rw-r--r-- | CmdLine/CmdLineApp.h | 26 | ||||
-rw-r--r-- | CmdLine/CmdLineDlg.cpp | 58 | ||||
-rw-r--r-- | CmdLine/CmdLineDlg.h | 39 | ||||
-rw-r--r-- | CmdLine/CmdLineps.def | 11 | ||||
-rw-r--r-- | CmdLine/CmdLineps.mk | 16 | ||||
-rw-r--r-- | CmdLine/StdAfx.cpp | 12 | ||||
-rw-r--r-- | CmdLine/StdAfx.h | 41 | ||||
-rw-r--r-- | CmdLine/res/Night Security Stub.ico | bin | 0 -> 1078 bytes | |||
-rw-r--r-- | CmdLine/resource.h | 20 |
16 files changed, 1061 insertions, 0 deletions
diff --git a/CmdLine/CmdLine.cpp b/CmdLine/CmdLine.cpp new file mode 100644 index 0000000..d23d34a --- /dev/null +++ b/CmdLine/CmdLine.cpp @@ -0,0 +1,115 @@ +// CmdLine.cpp : Implementation of WinMain + + +// Note: Proxy/Stub Information +// To build a separate proxy/stub DLL, +// run nmake -f CmdLineps.mk in the project directory. + +#include "stdafx.h" +#include "resource.h" +#include <initguid.h> +#include "CmdLine.h" + +#include "CmdLine_i.c" +#include "../common/Interfaces.cpp" +//#include "../common/NightSec_i.c" + +CCmdLineApp _Module; + +/*BEGIN_OBJECT_MAP(ObjectMap) +END_OBJECT_MAP() +*/ +const DWORD dwPause = 1000; // time to wait for threads to finish up + +LPCTSTR FindOneOf(LPCTSTR p1, LPCTSTR p2) +{ + while (p1 != NULL && *p1 != NULL) + { + LPCTSTR p = p2; + while (p != NULL && *p != NULL) + { + if (*p1 == *p) + return CharNext(p1); + p = CharNext(p); + } + p1 = CharNext(p1); + } + return NULL; +} + +///////////////////////////////////////////////////////////////////////////// +// +extern "C" int WINAPI _tWinMain(HINSTANCE hInstance, + HINSTANCE /*hPrevInstance*/, LPTSTR lpCmdLine, int /*nShowCmd*/) +{ + lpCmdLine = GetCommandLine(); //this line necessary for _ATL_MIN_CRT + +#if _WIN32_WINNT >= 0x0400 & defined(_ATL_FREE_THREADED) + HRESULT hRes = CoInitializeEx(NULL, COINIT_MULTITHREADED); +#else + HRESULT hRes = CoInitialize(NULL); +#endif + _ASSERTE(SUCCEEDED(hRes)); + _Module.Init(NULL/*ObjectMap*/, hInstance, &LIBID_CMDLINELib); +// _Module.dwThreadID = GetCurrentThreadId(); + TCHAR szTokens[] = _T("-/"); + + int nRet = 0; + BOOL bRun = TRUE; + LPCTSTR lpszToken = FindOneOf(lpCmdLine, szTokens); + while (lpszToken != NULL) + { + if (lstrcmpi(lpszToken, _T("UnregServer"))==0) + { +// _Module.UpdateRegistryFromResource(IDR_CmdLine, FALSE); +// nRet = _Module.UnregisterServer(TRUE); + bRun = FALSE; + break; + } + if (lstrcmpi(lpszToken, _T("RegServer"))==0) + { + _Module.RegisterDlls(); + +// _Module.UpdateRegistryFromResource(IDR_CmdLine, TRUE); +// nRet = _Module.RegisterServer(TRUE); + bRun = FALSE; + break; + } + lpszToken = FindOneOf(lpszToken, szTokens); + } + + if (bRun) + { +// _Module.StartMonitor(); +#if _WIN32_WINNT >= 0x0400 & defined(_ATL_FREE_THREADED) +// hRes = _Module.RegisterClassObjects(CLSCTX_LOCAL_SERVER, +// REGCLS_MULTIPLEUSE | REGCLS_SUSPENDED); +// _ASSERTE(SUCCEEDED(hRes)); +// hRes = CoResumeClassObjects(); +#else +// hRes = _Module.RegisterClassObjects(CLSCTX_LOCAL_SERVER, +// REGCLS_MULTIPLEUSE); +#endif +// _ASSERTE(SUCCEEDED(hRes)); + + if(_Module.InitInstance()) + { + + MSG msg; + while (GetMessage(&msg, 0, 0, 0)) + { + TranslateMessage(&msg); + DispatchMessage(&msg); + } + +// _Module.RevokeClassObjects(); +// Sleep(dwPause); //wait for any threads to finish + } + + _Module.ExitInstance(); + } + + _Module.Term(); + CoUninitialize(); + return nRet; +} diff --git a/CmdLine/CmdLine.dsp b/CmdLine/CmdLine.dsp new file mode 100644 index 0000000..a1b2d21 --- /dev/null +++ b/CmdLine/CmdLine.dsp @@ -0,0 +1,361 @@ +# Microsoft Developer Studio Project File - Name="CmdLine" - Package Owner=<4> +# Microsoft Developer Studio Generated Build File, Format Version 6.00 +# ** DO NOT EDIT ** + +# TARGTYPE "Win32 (x86) Application" 0x0101 + +CFG=CmdLine - Win32 Debug +!MESSAGE This is not a valid makefile. To build this project using NMAKE, +!MESSAGE use the Export Makefile command and run +!MESSAGE +!MESSAGE NMAKE /f "CmdLine.mak". +!MESSAGE +!MESSAGE You can specify a configuration when running NMAKE +!MESSAGE by defining the macro CFG on the command line. For example: +!MESSAGE +!MESSAGE NMAKE /f "CmdLine.mak" CFG="CmdLine - Win32 Debug" +!MESSAGE +!MESSAGE Possible choices for configuration are: +!MESSAGE +!MESSAGE "CmdLine - Win32 Debug" (based on "Win32 (x86) Application") +!MESSAGE "CmdLine - Win32 Unicode Debug" (based on "Win32 (x86) Application") +!MESSAGE "CmdLine - Win32 Release MinSize" (based on "Win32 (x86) Application") +!MESSAGE "CmdLine - Win32 Release MinDependency" (based on "Win32 (x86) Application") +!MESSAGE "CmdLine - Win32 Unicode Release MinSize" (based on "Win32 (x86) Application") +!MESSAGE "CmdLine - Win32 Unicode Release MinDependency" (based on "Win32 (x86) Application") +!MESSAGE + +# Begin Project +# PROP AllowPerConfigDependencies 0 +# PROP Scc_ProjName "" +# PROP Scc_LocalPath "" +CPP=cl.exe +MTL=midl.exe +RSC=rc.exe + +!IF "$(CFG)" == "CmdLine - Win32 Debug" + +# PROP BASE Use_MFC 0 +# PROP BASE Use_Debug_Libraries 1 +# PROP BASE Output_Dir "Debug" +# PROP BASE Intermediate_Dir "Debug" +# PROP BASE Target_Dir "" +# PROP Use_MFC 0 +# PROP Use_Debug_Libraries 1 +# PROP Output_Dir "Debug" +# PROP Intermediate_Dir "Debug" +# PROP Ignore_Export_Lib 0 +# PROP Target_Dir "" +# ADD BASE CPP /nologo /W3 /Gm /ZI /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /Yu"stdafx.h" /FD /GZ /c +# ADD CPP /nologo /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /Yu"stdafx.h" /FD /GZ /c +# ADD BASE RSC /l 0x409 /d "_DEBUG" +# ADD RSC /l 0x409 /d "_DEBUG" +BSC32=bscmake.exe +# ADD BASE BSC32 /nologo +# ADD BSC32 /nologo +LINK32=link.exe +# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:windows /debug /machine:I386 /pdbtype:sept +# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:windows /debug /machine:I386 /out:"../Debug/CmdLine.exe" /pdbtype:sept +# Begin Custom Build - Performing registration +OutDir=.\Debug +TargetPath=\Projects\NightSec\Debug\CmdLine.exe +InputPath=\Projects\NightSec\Debug\CmdLine.exe +SOURCE="$(InputPath)" + +"$(OutDir)\regsvr32.trg" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)" + "$(TargetPath)" /RegServer + echo regsvr32 exec. time > "$(OutDir)\regsvr32.trg" + echo Server registration done! + +# End Custom Build + +!ELSEIF "$(CFG)" == "CmdLine - Win32 Unicode Debug" + +# PROP BASE Use_MFC 0 +# PROP BASE Use_Debug_Libraries 1 +# PROP BASE Output_Dir "DebugU" +# PROP BASE Intermediate_Dir "DebugU" +# PROP BASE Target_Dir "" +# PROP Use_MFC 0 +# PROP Use_Debug_Libraries 1 +# PROP Output_Dir "DebugU" +# PROP Intermediate_Dir "DebugU" +# PROP Ignore_Export_Lib 0 +# PROP Target_Dir "" +# ADD BASE CPP /nologo /W3 /Gm /ZI /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_UNICODE" /Yu"stdafx.h" /FD /GZ /c +# ADD CPP /nologo /W3 /Gm /ZI /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_UNICODE" /Yu"stdafx.h" /FD /GZ /c +# ADD BASE RSC /l 0x409 /d "_DEBUG" +# ADD RSC /l 0x409 /d "_DEBUG" +BSC32=bscmake.exe +# ADD BASE BSC32 /nologo +# ADD BSC32 /nologo +LINK32=link.exe +# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /entry:"wWinMainCRTStartup" /subsystem:windows /debug /machine:I386 /pdbtype:sept +# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /entry:"wWinMainCRTStartup" /subsystem:windows /debug /machine:I386 /out:"../Debug/CmdLine.exe" /pdbtype:sept +# Begin Custom Build - Performing registration +OutDir=.\DebugU +TargetPath=\Projects\NightSec\Debug\CmdLine.exe +InputPath=\Projects\NightSec\Debug\CmdLine.exe +SOURCE="$(InputPath)" + +"$(OutDir)\regsvr32.trg" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)" + if "%OS%"=="" goto NOTNT + if not "%OS%"=="Windows_NT" goto NOTNT + "$(TargetPath)" /RegServer + echo regsvr32 exec. time > "$(OutDir)\regsvr32.trg" + echo Server registration done! + goto end + :NOTNT + echo Warning : Cannot register Unicode EXE on Windows 95 + :end + +# End Custom Build + +!ELSEIF "$(CFG)" == "CmdLine - Win32 Release MinSize" + +# PROP BASE Use_MFC 0 +# PROP BASE Use_Debug_Libraries 0 +# PROP BASE Output_Dir "ReleaseMinSize" +# PROP BASE Intermediate_Dir "ReleaseMinSize" +# PROP BASE Target_Dir "" +# PROP Use_MFC 0 +# PROP Use_Debug_Libraries 0 +# PROP Output_Dir "ReleaseMinSize" +# PROP Intermediate_Dir "ReleaseMinSize" +# PROP Ignore_Export_Lib 0 +# PROP Target_Dir "" +# ADD BASE CPP /nologo /W3 /O1 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /D "_ATL_DLL" /D "_ATL_MIN_CRT" /Yu"stdafx.h" /FD /c +# ADD CPP /nologo /W3 /GX /O1 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /D "_ATL_DLL" /Yu"stdafx.h" /FD /c +# ADD BASE RSC /l 0x409 /d "NDEBUG" +# ADD RSC /l 0x409 /d "NDEBUG" +BSC32=bscmake.exe +# ADD BASE BSC32 /nologo +# ADD BSC32 /nologo +LINK32=link.exe +# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:windows /machine:I386 +# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:windows /machine:I386 /out:"../Release/CmdLine.exe" /OPT:NOWIN98 +# SUBTRACT LINK32 /pdb:none +# Begin Custom Build - Performing registration +OutDir=.\ReleaseMinSize +TargetPath=\Projects\NightSec\Release\CmdLine.exe +InputPath=\Projects\NightSec\Release\CmdLine.exe +SOURCE="$(InputPath)" + +"$(OutDir)\regsvr32.trg" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)" + "$(TargetPath)" /RegServer + echo regsvr32 exec. time > "$(OutDir)\regsvr32.trg" + echo Server registration done! + +# End Custom Build + +!ELSEIF "$(CFG)" == "CmdLine - Win32 Release MinDependency" + +# PROP BASE Use_MFC 0 +# PROP BASE Use_Debug_Libraries 0 +# PROP BASE Output_Dir "ReleaseMinDependency" +# PROP BASE Intermediate_Dir "ReleaseMinDependency" +# PROP BASE Target_Dir "" +# PROP Use_MFC 0 +# PROP Use_Debug_Libraries 0 +# PROP Output_Dir "ReleaseMinDependency" +# PROP Intermediate_Dir "ReleaseMinDependency" +# PROP Target_Dir "" +# ADD BASE CPP /nologo /W3 /O1 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /D "_ATL_STATIC_REGISTRY" /D "_ATL_MIN_CRT" /Yu"stdafx.h" /FD /c +# ADD CPP /nologo /W3 /GX /O1 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /D "_ATL_STATIC_REGISTRY" /Yu"stdafx.h" /FD /c +# ADD BASE RSC /l 0x409 /d "NDEBUG" +# ADD RSC /l 0x409 /d "NDEBUG" +BSC32=bscmake.exe +# ADD BASE BSC32 /nologo +# ADD BSC32 /nologo +LINK32=link.exe +# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:windows /machine:I386 +# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:windows /machine:I386 +# Begin Custom Build - Performing registration +OutDir=.\ReleaseMinDependency +TargetPath=.\ReleaseMinDependency\CmdLine.exe +InputPath=.\ReleaseMinDependency\CmdLine.exe +SOURCE="$(InputPath)" + +"$(OutDir)\regsvr32.trg" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)" + "$(TargetPath)" /RegServer + echo regsvr32 exec. time > "$(OutDir)\regsvr32.trg" + echo Server registration done! + +# End Custom Build + +!ELSEIF "$(CFG)" == "CmdLine - Win32 Unicode Release MinSize" + +# PROP BASE Use_MFC 0 +# PROP BASE Use_Debug_Libraries 0 +# PROP BASE Output_Dir "ReleaseUMinSize" +# PROP BASE Intermediate_Dir "ReleaseUMinSize" +# PROP BASE Target_Dir "" +# PROP Use_MFC 0 +# PROP Use_Debug_Libraries 0 +# PROP Output_Dir "ReleaseUMinSize" +# PROP Intermediate_Dir "ReleaseUMinSize" +# PROP Ignore_Export_Lib 0 +# PROP Target_Dir "" +# ADD BASE CPP /nologo /W3 /O1 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_UNICODE" /D "_ATL_DLL" /D "_ATL_MIN_CRT" /Yu"stdafx.h" /FD /c +# ADD CPP /nologo /W3 /O1 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_UNICODE" /D "_ATL_DLL" /D "_ATL_MIN_CRT" /Yu"stdafx.h" /FD /c +# ADD BASE RSC /l 0x409 /d "NDEBUG" +# ADD RSC /l 0x409 /d "NDEBUG" +BSC32=bscmake.exe +# ADD BASE BSC32 /nologo +# ADD BSC32 /nologo +LINK32=link.exe +# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:windows /machine:I386 +# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:windows /machine:I386 /out:"../Release/CmdLine.exe" +# Begin Custom Build - Performing registration +OutDir=.\ReleaseUMinSize +TargetPath=\Projects\NightSec\Release\CmdLine.exe +InputPath=\Projects\NightSec\Release\CmdLine.exe +SOURCE="$(InputPath)" + +"$(OutDir)\regsvr32.trg" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)" + if "%OS%"=="" goto NOTNT + if not "%OS%"=="Windows_NT" goto NOTNT + "$(TargetPath)" /RegServer + echo regsvr32 exec. time > "$(OutDir)\regsvr32.trg" + echo Server registration done! + goto end + :NOTNT + echo Warning : Cannot register Unicode EXE on Windows 95 + :end + +# End Custom Build + +!ELSEIF "$(CFG)" == "CmdLine - Win32 Unicode Release MinDependency" + +# PROP BASE Use_MFC 0 +# PROP BASE Use_Debug_Libraries 0 +# PROP BASE Output_Dir "ReleaseUMinDependency" +# PROP BASE Intermediate_Dir "ReleaseUMinDependency" +# PROP BASE Target_Dir "" +# PROP Use_MFC 0 +# PROP Use_Debug_Libraries 0 +# PROP Output_Dir "ReleaseUMinDependency" +# PROP Intermediate_Dir "ReleaseUMinDependency" +# PROP Target_Dir "" +# ADD BASE CPP /nologo /W3 /O1 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_UNICODE" /D "_ATL_STATIC_REGISTRY" /D "_ATL_MIN_CRT" /Yu"stdafx.h" /FD /c +# ADD CPP /nologo /W3 /O1 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_UNICODE" /D "_ATL_STATIC_REGISTRY" /D "_ATL_MIN_CRT" /Yu"stdafx.h" /FD /c +# ADD BASE RSC /l 0x409 /d "NDEBUG" +# ADD RSC /l 0x409 /d "NDEBUG" +BSC32=bscmake.exe +# ADD BASE BSC32 /nologo +# ADD BSC32 /nologo +LINK32=link.exe +# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:windows /machine:I386 +# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:windows /machine:I386 +# Begin Custom Build - Performing registration +OutDir=.\ReleaseUMinDependency +TargetPath=.\ReleaseUMinDependency\CmdLine.exe +InputPath=.\ReleaseUMinDependency\CmdLine.exe +SOURCE="$(InputPath)" + +"$(OutDir)\regsvr32.trg" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)" + if "%OS%"=="" goto NOTNT + if not "%OS%"=="Windows_NT" goto NOTNT + "$(TargetPath)" /RegServer + echo regsvr32 exec. time > "$(OutDir)\regsvr32.trg" + echo Server registration done! + goto end + :NOTNT + echo Warning : Cannot register Unicode EXE on Windows 95 + :end + +# End Custom Build + +!ENDIF + +# Begin Target + +# Name "CmdLine - Win32 Debug" +# Name "CmdLine - Win32 Unicode Debug" +# Name "CmdLine - Win32 Release MinSize" +# Name "CmdLine - Win32 Release MinDependency" +# Name "CmdLine - Win32 Unicode Release MinSize" +# Name "CmdLine - Win32 Unicode Release MinDependency" +# Begin Group "Source Files" + +# PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat" +# Begin Source File + +SOURCE=..\..\Include\src\appmisc.cpp +# End Source File +# Begin Source File + +SOURCE=.\CmdLine.cpp +# End Source File +# Begin Source File + +SOURCE=.\CmdLine.rc +# End Source File +# Begin Source File + +SOURCE=.\CmdLineApp.cpp +# End Source File +# Begin Source File + +SOURCE=.\CmdLineDlg.cpp +# End Source File +# Begin Source File + +SOURCE=..\Common\ComponentArray.cpp +# End Source File +# Begin Source File + +SOURCE=..\Common\ComponentData.cpp +# End Source File +# Begin Source File + +SOURCE=..\Common\ComponentHolder.cpp +# End Source File +# Begin Source File + +SOURCE=..\Common\NightSecApp.cpp +# End Source File +# Begin Source File + +SOURCE=..\..\Include\src\path.cpp +# End Source File +# Begin Source File + +SOURCE=..\..\Include\src\RegSvr.cpp +# End Source File +# Begin Source File + +SOURCE=.\StdAfx.cpp +# ADD CPP /Yc"stdafx.h" +# End Source File +# End Group +# Begin Group "Header Files" + +# PROP Default_Filter "h;hpp;hxx;hm;inl" +# Begin Source File + +SOURCE=.\CmdLineApp.h +# End Source File +# Begin Source File + +SOURCE=.\CmdLineDlg.h +# End Source File +# Begin Source File + +SOURCE=.\Resource.h +# End Source File +# Begin Source File + +SOURCE=.\StdAfx.h +# End Source File +# End Group +# Begin Group "Resource Files" + +# PROP Default_Filter "ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe" +# Begin Source File + +SOURCE=".\res\Night Security Stub.ico" +# End Source File +# End Group +# End Target +# End Project diff --git a/CmdLine/CmdLine.h b/CmdLine/CmdLine.h new file mode 100644 index 0000000..b8e5971 --- /dev/null +++ b/CmdLine/CmdLine.h @@ -0,0 +1,57 @@ +/* this ALWAYS GENERATED file contains the definitions for the interfaces */ + + +/* File created by MIDL compiler version 5.01.0164 */ +/* at Wed Nov 03 12:24:06 1999 + */ +/* Compiler settings for E:\Projects\NightSec\CmdLine\CmdLine.idl: + Oicf (OptLev=i2), W1, Zp8, env=Win32, ms_ext, c_ext + error checks: allocation ref bounds_check enum stub_data +*/ +//@@MIDL_FILE_HEADING( ) + + +/* verify that the <rpcndr.h> version is high enough to compile this file*/ +#ifndef __REQUIRED_RPCNDR_H_VERSION__ +#define __REQUIRED_RPCNDR_H_VERSION__ 440 +#endif + +#include "rpc.h" +#include "rpcndr.h" + +#ifndef __CmdLine_h__ +#define __CmdLine_h__ + +#ifdef __cplusplus +extern "C"{ +#endif + +/* Forward Declarations */ + +/* header files for imported files */ +#include "oaidl.h" +#include "ocidl.h" + +void __RPC_FAR * __RPC_USER MIDL_user_allocate(size_t); +void __RPC_USER MIDL_user_free( void __RPC_FAR * ); + + +#ifndef __CMDLINELib_LIBRARY_DEFINED__ +#define __CMDLINELib_LIBRARY_DEFINED__ + +/* library CMDLINELib */ +/* [helpstring][version][uuid] */ + + +EXTERN_C const IID LIBID_CMDLINELib; +#endif /* __CMDLINELib_LIBRARY_DEFINED__ */ + +/* Additional Prototypes for ALL interfaces */ + +/* end of Additional Prototypes */ + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/CmdLine/CmdLine.idl b/CmdLine/CmdLine.idl new file mode 100644 index 0000000..3840ebf --- /dev/null +++ b/CmdLine/CmdLine.idl @@ -0,0 +1,20 @@ +// CmdLine.idl : IDL source for CmdLine.dll +// + +// This file will be processed by the MIDL tool to +// produce the type library (CmdLine.tlb) and marshalling code. + +import "oaidl.idl"; +import "ocidl.idl"; + +[ + uuid(E9C249C6-9196-11D3-BFBF-0020182B97FC), + version(1.0), + helpstring("CmdLine 1.0 Type Library") +] +library CMDLINELib +{ + importlib("stdole32.tlb"); + importlib("stdole2.tlb"); + +}; diff --git a/CmdLine/CmdLine.rc b/CmdLine/CmdLine.rc new file mode 100644 index 0000000..5a612a1 --- /dev/null +++ b/CmdLine/CmdLine.rc @@ -0,0 +1,170 @@ +//Microsoft Developer Studio generated resource script. +// +#include "resource.h" + +#define APSTUDIO_READONLY_SYMBOLS +///////////////////////////////////////////////////////////////////////////// +// +// Generated from the TEXTINCLUDE 2 resource. +// +#include "winres.h" + +///////////////////////////////////////////////////////////////////////////// +#undef APSTUDIO_READONLY_SYMBOLS + +///////////////////////////////////////////////////////////////////////////// +// English (U.S.) resources + +#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU) +#ifdef _WIN32 +LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US +#pragma code_page(1252) +#endif //_WIN32 + +#ifdef APSTUDIO_INVOKED +///////////////////////////////////////////////////////////////////////////// +// +// TEXTINCLUDE +// + +1 TEXTINCLUDE DISCARDABLE +BEGIN + "resource.h\0" +END + +2 TEXTINCLUDE DISCARDABLE +BEGIN + "#include ""winres.h""\r\n" + "\0" +END + +3 TEXTINCLUDE DISCARDABLE +BEGIN + "\r\n" + "\0" +END + +#endif // APSTUDIO_INVOKED + + +#ifndef _MAC +///////////////////////////////////////////////////////////////////////////// +// +// Version +// + +VS_VERSION_INFO VERSIONINFO + FILEVERSION 2,5,0,1 + PRODUCTVERSION 2,5,0,1 + FILEFLAGSMASK 0x3fL +#ifdef _DEBUG + FILEFLAGS 0x1L +#else + FILEFLAGS 0x0L +#endif + FILEOS 0x4L + FILETYPE 0x1L + FILESUBTYPE 0x0L +BEGIN + BLOCK "StringFileInfo" + BEGIN + BLOCK "040904b0" + BEGIN + VALUE "Comments", "Part of the Night Security Program\0" + VALUE "CompanyName", "The Family (Thailand)\0" + VALUE "FileDescription", "Night Security (Command Line Module)\0" + VALUE "FileVersion", "2, 5, 0, 1\0" + VALUE "InternalName", "Night Security CmdLine\0" + VALUE "LegalCopyright", "Copyright (C) 1998 - 1999, The Family (Thailand)\0" + VALUE "LegalTrademarks", "\0" + VALUE "OLESelfRegister", "\0" + VALUE "OriginalFilename", "nightsec.exe\0" + VALUE "PrivateBuild", "\0" + VALUE "ProductName", "Night Security 2.1\0" + VALUE "ProductVersion", "2, 5, 0, 1\0" + VALUE "SpecialBuild", "\0" + END + END + BLOCK "VarFileInfo" + BEGIN + VALUE "Translation", 0x409, 1200 + END +END + +#endif // !_MAC + + +///////////////////////////////////////////////////////////////////////////// +// +// Icon +// + +// Icon with lowest ID value placed first to ensure application icon +// remains consistent on all systems. +IDR_MAINFRAME ICON DISCARDABLE "res\\Night Security Stub.ico" + +///////////////////////////////////////////////////////////////////////////// +// +// Dialog +// + +IDD_CMDLINE_DLG DIALOGEX 0, 0, 224, 135 +STYLE DS_MODALFRAME | WS_POPUP | WS_VISIBLE | WS_CAPTION | WS_SYSMENU +EXSTYLE WS_EX_APPWINDOW +CAPTION "Night Security Command Line" +FONT 8, "MS Sans Serif" +BEGIN + DEFPUSHBUTTON "Close",IDCANCEL,167,114,50,14 + ICON IDR_MAINFRAME,IDC_STATIC,8,3,20,20 + LTEXT "You can run Night Security with the following command line parameters. (eg: cmdline -r)", + IDC_STATIC,38,4,181,18 + LTEXT "",IDC_PARAMETERS,7,31,210,76 + CONTROL "",IDC_STATIC,"Static",SS_ETCHEDHORZ,7,27,210,1 + CONTROL "",IDC_STATIC,"Static",SS_ETCHEDHORZ,7,110,210,1 +END + + +///////////////////////////////////////////////////////////////////////////// +// +// DESIGNINFO +// + +#ifdef APSTUDIO_INVOKED +GUIDELINES DESIGNINFO DISCARDABLE +BEGIN + IDD_CMDLINE_DLG, DIALOG + BEGIN + LEFTMARGIN, 7 + RIGHTMARGIN, 217 + TOPMARGIN, 7 + BOTTOMMARGIN, 128 + END +END +#endif // APSTUDIO_INVOKED + + +///////////////////////////////////////////////////////////////////////////// +// +// String Table +// + +STRINGTABLE DISCARDABLE +BEGIN + IDS_PROJNAME "CmdLine" +END + +#endif // English (U.S.) resources +///////////////////////////////////////////////////////////////////////////// + + + +#ifndef APSTUDIO_INVOKED +///////////////////////////////////////////////////////////////////////////// +// +// Generated from the TEXTINCLUDE 3 resource. +// + + +///////////////////////////////////////////////////////////////////////////// +#endif // not APSTUDIO_INVOKED + diff --git a/CmdLine/CmdLine.rgs b/CmdLine/CmdLine.rgs new file mode 100644 index 0000000..d30f527 --- /dev/null +++ b/CmdLine/CmdLine.rgs @@ -0,0 +1,11 @@ +HKCR
+{
+ NoRemove AppID
+ {
+ {E9C249C7-9196-11D3-BFBF-0020182B97FC} = s 'CmdLine'
+ 'CmdLine.EXE'
+ {
+ val AppID = s {E9C249C7-9196-11D3-BFBF-0020182B97FC}
+ }
+ }
+}
diff --git a/CmdLine/CmdLineApp.cpp b/CmdLine/CmdLineApp.cpp new file mode 100644 index 0000000..ff2b3ad --- /dev/null +++ b/CmdLine/CmdLineApp.cpp @@ -0,0 +1,104 @@ +// CmdLineApp.cpp: implementation of the CCmdLineApp class. +// +////////////////////////////////////////////////////////////////////// + +#include "stdafx.h" +#include "CmdLineApp.h" +#include "CmdLineDlg.h" + +////////////////////////////////////////////////////////////////////// +// Construction/Destruction +////////////////////////////////////////////////////////////////////// + +CCmdLineApp::CCmdLineApp() + : CNightSecApp(_T("Secure Shutdown")) +{ } + +CCmdLineApp::~CCmdLineApp() +{ } + +bool CCmdLineApp::InitInstance() +{ + if(!CNightSecApp::InitInstance()) + return false; + + // Get Parameters + bool bParams = false; + bool bShowHelp = true; + LPSTR szChar; + int nIndex = -1; + + // Loop through command line arguments + for (int i = 1; i < __argc; i++) + { + szChar = __targv[i]; + _tcslwr(szChar); + + // Check if it's a param + // Note we can use - as a param because we don't + // accept file names (otherwise - can be in file name) + if (szChar[0] == '/' || szChar[0] == '-') + { + // Accepts multiple arguments in one param + // eg: -rti + + // First skip over first token then go through + // other chars one by one + + for(szChar++; szChar[0] != '\0'; szChar++) + { + // Check if we have a match + if((nIndex = FindParam(szChar[0])) > -1) + { + + // If so then call it + g_aComponents[nIndex]->DoShutdown(NULL); + + // Set flag so we don't show dialog later on + bShowHelp = false; + + } + + } + } + + } + + // Return if no dialog + if(!bShowHelp) + return false; + + // Otherwise... + CCmdLineDlg dlg; + dlg.DoModal(); + + // Since the dialog has been closed, return FALSE so that we exit the + // application, rather than start the application's message pump. + return false; +} + +////////////////////////////////////////////////////////////////// +// Checks Component Array for any components with Param passed + +UINT CCmdLineApp::FindParam(TCHAR chParam) +{ + string sTemp; + + // Loop through'm all + for(int nCnt = 0; nCnt < g_aComponents.size(); nCnt++) + { + // Only Windows Components can be called from cmd line + if(g_aComponents[nCnt]->GetType() == COMPONENT_WIN) + { + // Check for match + sTemp = g_aComponents[nCnt]->GetInfoStr(nsCmdLine, _T("")); + sTemp.make_lower(); + + if(!sTemp.empty() && sTemp[0] == chParam) + return nCnt; + } + } + + return -1; + +} diff --git a/CmdLine/CmdLineApp.h b/CmdLine/CmdLineApp.h new file mode 100644 index 0000000..f0700d2 --- /dev/null +++ b/CmdLine/CmdLineApp.h @@ -0,0 +1,26 @@ +// CmdLineApp.h: interface for the CCmdLineApp class. +// +////////////////////////////////////////////////////////////////////// + +#if !defined(AFX_CmdLineApp_H__19178A46_7FDB_11D3_BF9E_0020182B97FC__INCLUDED_) +#define AFX_CmdLineApp_H__19178A46_7FDB_11D3_BF9E_0020182B97FC__INCLUDED_ + +#if _MSC_VER > 1000 +#pragma once +#endif // _MSC_VER > 1000 + +#include "..\common\NightSecApp.h" + +class CCmdLineApp : public CNightSecApp +{ +public: + CCmdLineApp(); + virtual ~CCmdLineApp(); + + virtual bool InitInstance(); + +protected: + UINT FindParam(TCHAR chParam); +}; + +#endif // !defined(AFX_CmdLineApp_H__19178A46_7FDB_11D3_BF9E_0020182B97FC__INCLUDED_) diff --git a/CmdLine/CmdLineDlg.cpp b/CmdLine/CmdLineDlg.cpp new file mode 100644 index 0000000..443d54b --- /dev/null +++ b/CmdLine/CmdLineDlg.cpp @@ -0,0 +1,58 @@ +// Night Security StubDlg.cpp : implementation file +// + +#include "stdafx.h" +#include "CmdLineDlg.h" + +///////////////////////////////////////////////////////////////////////////// +// CCmdLineDlg dialog + +CCmdLineDlg::CCmdLineDlg() +{ +} + +///////////////////////////////////////////////////////////////////////////// +// CCmdLineDlg message handlers + +LRESULT CCmdLineDlg::OnInitDialog(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled) +{ + // Need app pointer to access components + string sHelpText; + string sTemp; + + // Loop through'm + for(int nCnt = 0; nCnt < g_aComponents.size(); nCnt++) + { + + // Is it a Windows Component? + if(g_aComponents[nCnt]->GetType() == COMPONENT_WIN) + { + + // Get CmdLine + sTemp = g_aComponents[nCnt]->GetInfoStr(nsCmdLine, _T("")); + + // If component returns null then can't be called from + // command line + if(!sTemp.empty()) + { + + // Now add it to the complete string + sHelpText += _T(" -") + sTemp + _T("\t"); + + // Add Component Name + sHelpText += g_aComponents[nCnt]->GetName() + _T("\r\n"); + + } + + } + + } + + // Put the text in Dialog + SetDlgItemText(IDC_PARAMETERS, sHelpText); + + bHandled = FALSE; // Let CSimpleDialog also have a shot + return TRUE; // return TRUE unless you set the focus to a control +} + + diff --git a/CmdLine/CmdLineDlg.h b/CmdLine/CmdLineDlg.h new file mode 100644 index 0000000..8a214f9 --- /dev/null +++ b/CmdLine/CmdLineDlg.h @@ -0,0 +1,39 @@ +// Night Security StubDlg.h : header file +// + +#if !defined(AFX_CmdLineDLG_H__ADB16FC8_1B31_11D2_B2D4_0020182B97FC__INCLUDED_) +#define AFX_CmdLineDLG_H__ADB16FC8_1B31_11D2_B2D4_0020182B97FC__INCLUDED_ + +#if _MSC_VER >= 1000 +#pragma once +#endif // _MSC_VER >= 1000 + +#include <atlwin.h> +#include "resource.h" +typedef CSimpleDialog<IDD_CMDLINE_DLG, TRUE> CmdLineDlg; + +///////////////////////////////////////////////////////////////////////////// +// CCmdLineDlg dialog + +class CCmdLineDlg + : public CmdLineDlg +{ +// Construction +public: + CCmdLineDlg(); // standard constructor + +// Dialog Data + +BEGIN_MSG_MAP(CNormalPage) + MESSAGE_HANDLER(WM_INITDIALOG, OnInitDialog) + CHAIN_MSG_MAP(CmdLineDlg) +END_MSG_MAP() + + // Generated message map functions + LRESULT OnInitDialog(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled); +}; + +//{{AFX_INSERT_LOCATION}} +// Microsoft Developer Studio will insert additional declarations immediately before the previous line. + +#endif // !defined(AFX_CmdLineDLG_H__ADB16FC8_1B31_11D2_B2D4_0020182B97FC__INCLUDED_) diff --git a/CmdLine/CmdLineps.def b/CmdLine/CmdLineps.def new file mode 100644 index 0000000..43cf6f4 --- /dev/null +++ b/CmdLine/CmdLineps.def @@ -0,0 +1,11 @@ +
+LIBRARY "CmdLinePS"
+
+DESCRIPTION 'Proxy/Stub DLL'
+
+EXPORTS
+ DllGetClassObject @1 PRIVATE
+ DllCanUnloadNow @2 PRIVATE
+ GetProxyDllInfo @3 PRIVATE
+ DllRegisterServer @4 PRIVATE
+ DllUnregisterServer @5 PRIVATE
diff --git a/CmdLine/CmdLineps.mk b/CmdLine/CmdLineps.mk new file mode 100644 index 0000000..4ac65de --- /dev/null +++ b/CmdLine/CmdLineps.mk @@ -0,0 +1,16 @@ + +CmdLineps.dll: dlldata.obj CmdLine_p.obj CmdLine_i.obj + link /dll /out:CmdLineps.dll /def:CmdLineps.def /entry:DllMain dlldata.obj CmdLine_p.obj CmdLine_i.obj \ + kernel32.lib rpcndr.lib rpcns4.lib rpcrt4.lib oleaut32.lib uuid.lib \ + +.c.obj: + cl /c /Ox /DWIN32 /D_WIN32_WINNT=0x0400 /DREGISTER_PROXY_DLL \ + $< + +clean: + @del CmdLineps.dll + @del CmdLineps.lib + @del CmdLineps.exp + @del dlldata.obj + @del CmdLine_p.obj + @del CmdLine_i.obj diff --git a/CmdLine/StdAfx.cpp b/CmdLine/StdAfx.cpp new file mode 100644 index 0000000..a5eea17 --- /dev/null +++ b/CmdLine/StdAfx.cpp @@ -0,0 +1,12 @@ +// stdafx.cpp : source file that includes just the standard includes +// stdafx.pch will be the pre-compiled header +// stdafx.obj will contain the pre-compiled type information + +#include "stdafx.h" + +#ifdef _ATL_STATIC_REGISTRY +#include <statreg.h> +#include <statreg.cpp> +#endif + +#include <atlimpl.cpp> diff --git a/CmdLine/StdAfx.h b/CmdLine/StdAfx.h new file mode 100644 index 0000000..b806d84 --- /dev/null +++ b/CmdLine/StdAfx.h @@ -0,0 +1,41 @@ +// stdafx.h : include file for standard system include files, +// or project specific include files that are used frequently, +// but are changed infrequently + +#if !defined(AFX_STDAFX_H__E9C249C9_9196_11D3_BFBF_0020182B97FC__INCLUDED_) +#define AFX_STDAFX_H__E9C249C9_9196_11D3_BFBF_0020182B97FC__INCLUDED_ + +#if _MSC_VER > 1000 +#pragma once +#endif // _MSC_VER > 1000 + +#define STRICT + +// Windows 95 Compatible +#undef WINVER +#define WINVER 0x0400 +#undef _WIN32_WINNT + +// Don't want our program dependant on some browser! +#undef _WIN32_IE +#define _WIN32_IE 0x0000 + +#define _ATL_APARTMENT_THREADED + +#include <comdef.h> +#include <atlbase.h> +//You may derive a class from CComModule and use it if you want to override +//something, but do not change the name of _Module +#include "cmdlineapp.h" + +extern CCmdLineApp _Module; +#include <atlcom.h> + +#include "../common/componentarray.h" +extern CComponentArray g_aComponents; + + +//{{AFX_INSERT_LOCATION}} +// Microsoft Visual C++ will insert additional declarations immediately before the previous line. + +#endif // !defined(AFX_STDAFX_H__E9C249C9_9196_11D3_BFBF_0020182B97FC__INCLUDED) diff --git a/CmdLine/res/Night Security Stub.ico b/CmdLine/res/Night Security Stub.ico Binary files differnew file mode 100644 index 0000000..2b50f8a --- /dev/null +++ b/CmdLine/res/Night Security Stub.ico diff --git a/CmdLine/resource.h b/CmdLine/resource.h new file mode 100644 index 0000000..10c2feb --- /dev/null +++ b/CmdLine/resource.h @@ -0,0 +1,20 @@ +//{{NO_DEPENDENCIES}} +// Microsoft Developer Studio generated include file. +// Used by CmdLine.rc +// +#define IDS_PROJNAME 100 +#define IDR_CmdLine 100 +#define IDD_CMDLINE_DLG 102 +#define IDR_MAINFRAME 128 +#define IDC_PARAMETERS 1003 + +// Next default values for new objects +// +#ifdef APSTUDIO_INVOKED +#ifndef APSTUDIO_READONLY_SYMBOLS +#define _APS_NEXT_RESOURCE_VALUE 201 +#define _APS_NEXT_COMMAND_VALUE 32768 +#define _APS_NEXT_CONTROL_VALUE 201 +#define _APS_NEXT_SYMED_VALUE 101 +#endif +#endif |