/* **++ ** ** Copyright (c) 2000-2002 Microsoft Corporation ** ** ** Module Name: ** ** sec.h ** ** ** Abstract: ** ** Test program for VSS security ** ** Author: ** ** Adi Oltean [aoltean] 02/12/2002 ** ** Revision History: ** **-- */ #ifndef __VSS_SEC_HEADER_H__ #define __VSS_SEC_HEADER_H__ #if _MSC_VER > 1000 #pragma once #endif /* ** Defines ** ** ** C4290: C++ Exception Specification ignored ** warning C4511: 'class' : copy constructor could not be generated ** warning C4127: conditional expression is constant */ #pragma warning(disable:4290) #pragma warning(disable:4511) #pragma warning(disable:4127) /* ** Includes */ // Disable warning: 'identifier' : identifier was truncated to 'number' characters in the debug information //#pragma warning(disable:4786) // // C4290: C++ Exception Specification ignored // #pragma warning(disable:4290) // // C4511: copy constructor could not be generated // #pragma warning(disable:4511) #include #include #include #include #include #include #pragma warning( disable: 4201 ) // C4201: nonstandard extension used : nameless struct/union #include #pragma warning( default: 4201 ) // C4201: nonstandard extension used : nameless struct/union #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include // Enabling asserts in ATL and VSS #include "vs_assert.hxx" #define STRSAFE_NO_DEPRECATE #include #include #include #pragma warning( disable: 4127 ) // warning C4127: conditional expression is constant //#include #include #include "resource.h" extern CComModule _Module; #include #include "macros.h" #include "test.h" #include "cmdparse.h" #include "vs_inc.hxx" #include "vs_sec.hxx" /////////////////////////////////////////////////////////////////////////////// // Constants const MAX_TEXT_BUFFER = 512; const VSS_SEED = 1234; const MAX_ARGS = 40; /////////////////////////////////////////////////////////////////////////////// // Main class class CVssSecurityTest: public CGxnCmdLineParser { // Constructors& destructors private: CVssSecurityTest(const CVssSecurityTest&); public: CVssSecurityTest(); ~CVssSecurityTest(); // Main routines public: // Initialize internal members void Initialize(); // Run the test void Run(); // Internal tests public: void TestLookupName(); void TestLookupSid(); void TestLookupPrimaryDomainName(); void TestLookupTrustedName(); void TestLookupGroupMembers(); void IsAllowedToFire(); void WriteRegistry(); void DoQuerySnapshots(); void DoQueryProviders(); void DoFsctlDismount(); void DisplayMessage(); void AddDependency(); void RemoveDependency(); void AddRegKey(); void RemoveRegKey(); void AddTask(); void UpdateTask(); void RemoveTask(); void DisplaySD(); void GetVolumePath(); void DisplayQuorumVolume(); void GetVolumeName(); void CoCreateInstance(); // Command line processing public: BEGIN_CMD_PARSER(VSST) CMD_ENTRY(TestLookupName, L"-ln ", L"Lookup for an account name") CMD_ENTRY(TestLookupSid, L"-ls ", L"Lookup for SID") CMD_ENTRY(TestLookupPrimaryDomainName, L"-lpdn", L"Lookup for primary domain name") CMD_ENTRY(TestLookupTrustedName, L"-lt", L"Lookup for trusted names") CMD_ENTRY(TestLookupGroupMembers, L"-gm ", L"Lookup for group members") CMD_ENTRY(IsAllowedToFire, L"-af ", L"Check if hte account is allowed to fire") CMD_ENTRY(WriteRegistry, L"-wr ", L"Write diag keys times") CMD_ENTRY(DoQuerySnapshots, L"-qs", L"Query snapshots sample code") CMD_ENTRY(DoQueryProviders, L"-qp", L"Query providers sample code") CMD_ENTRY(DoFsctlDismount, L"-dismount ", L"Sends a FSCTL_DISMOUNT_VOLUME to the device") CMD_ENTRY(DisplayMessage, L"-msg ", L"Prints the message from this file") CMD_ENTRY(AddDependency, L"-cad ", L"Add a cluster dependency") CMD_ENTRY(RemoveDependency, L"-crd ", L"Remove a cluster dependency") CMD_ENTRY(AddRegKey, L"-car ", L"Add a reg key to a disk") CMD_ENTRY(RemoveRegKey, L"-crr ", L"Remove a reg key from a disk") CMD_ENTRY(AddTask, L"-cat ", L"Add a task") CMD_ENTRY(UpdateTask, L"-cut ", L"Update the task") CMD_ENTRY(RemoveTask, L"-crt ", L"Remove the task") CMD_ENTRY(DisplaySD, L"-dsd", L"Display the current writer security descriptor") CMD_ENTRY(GetVolumePath, L"-vol ", L"Display the volume that contains the path") CMD_ENTRY(DisplayQuorumVolume, L"-quorum ", L"Display the quorum volume N times") CMD_ENTRY(GetVolumeName, L"-volname ", L"Display the volume name for this mount point") CMD_ENTRY(CoCreateInstance, L"-clsid ", L"Creates an object using the given CLSID") END_CMD_PARSER // Utility methods: public: static LPCWSTR GetStringFromFailureType(HRESULT hrStatus); static BOOL IsAdmin(); static DWORD WINAPI ThreadRoutine(LPVOID); // Private data members private: bool m_bCoInitializeSucceeded; static CRITICAL_SECTION m_csTest; static volatile LONG m_lTestCounter; }; HRESULT QuerySnapshots(); HRESULT QueryProviders(); HRESULT IsAdministrator2(); /* // Sample COM server class CTestCOMServer: public CComObjectRoot, // public CComCoClass, public CComCoClass, public IFsaRecallNotifyClient { public: DECLARE_REGISTRY_RESOURCEID(IDR_TEST) DECLARE_NOT_AGGREGATABLE(CTestCOMServer) BEGIN_COM_MAP(CTestCOMServer) COM_INTERFACE_ENTRY(IRssSecTest) COM_INTERFACE_ENTRY(IFsaRecallNotifyClient) END_COM_MAP() // ITest interface STDMETHOD(Test)(); // IFsaRecallNotifyClient interface STDMETHOD(IdentifyWithServer)( IN OLECHAR * szServerName ); protected: CGxnTracer ft; }; */ #endif // __VSS_SEC_HEADER_H__