summaryrefslogtreecommitdiffstats
path: root/private/oleutest/act
diff options
context:
space:
mode:
Diffstat (limited to 'private/oleutest/act')
-rw-r--r--private/oleutest/act/acttest.h44
-rw-r--r--private/oleutest/act/client/client.cxx2122
-rw-r--r--private/oleutest/act/client/client.hxx43
-rw-r--r--private/oleutest/act/client/daytona/makefile1
-rw-r--r--private/oleutest/act/client/daytona/sources77
-rw-r--r--private/oleutest/act/client/dirs27
-rw-r--r--private/oleutest/act/client/pswrd.cxx58
-rw-r--r--private/oleutest/act/client/reg.cxx867
-rw-r--r--private/oleutest/act/common/clsid.c131
-rw-r--r--private/oleutest/act/common/daytona/makefile1
-rw-r--r--private/oleutest/act/common/daytona/sources69
-rw-r--r--private/oleutest/act/common/dirs27
-rw-r--r--private/oleutest/act/common/reg.c250
-rw-r--r--private/oleutest/act/dirs29
-rw-r--r--private/oleutest/act/dll/daytona/makefile1
-rw-r--r--private/oleutest/act/dll/daytona/sources77
-rw-r--r--private/oleutest/act/dll/dirs27
-rw-r--r--private/oleutest/act/dll/goober.def8
-rw-r--r--private/oleutest/act/dllsrv/actsrvd.def8
-rw-r--r--private/oleutest/act/dllsrv/daytona/makefile1
-rw-r--r--private/oleutest/act/dllsrv/daytona/sources79
-rw-r--r--private/oleutest/act/dllsrv/dirs27
-rw-r--r--private/oleutest/act/dllsrv/dllgco.cxx37
-rw-r--r--private/oleutest/act/dllsrv/goober.def8
-rw-r--r--private/oleutest/act/goober.idl17
-rw-r--r--private/oleutest/act/makefil021
-rw-r--r--private/oleutest/act/server/daytona/makefile1
-rw-r--r--private/oleutest/act/server/daytona/sources78
-rw-r--r--private/oleutest/act/server/dirs27
-rw-r--r--private/oleutest/act/server/pswrd.cxx66
-rw-r--r--private/oleutest/act/server/server.cxx1033
-rw-r--r--private/oleutest/act/server/server.hxx69
-rw-r--r--private/oleutest/act/srvcore/classes.cxx278
-rw-r--r--private/oleutest/act/srvcore/classes.hxx152
-rw-r--r--private/oleutest/act/srvcore/daytona/makefile1
-rw-r--r--private/oleutest/act/srvcore/daytona/sources69
-rw-r--r--private/oleutest/act/srvcore/dirs27
-rw-r--r--private/oleutest/act/srvcore/factory.cxx200
-rw-r--r--private/oleutest/act/srvcore/factory.hxx101
-rw-r--r--private/oleutest/act/tstsvc/client.cxx2231
-rw-r--r--private/oleutest/act/tstsvc/client.hxx38
-rw-r--r--private/oleutest/act/tstsvc/daytona/makefile1
-rw-r--r--private/oleutest/act/tstsvc/daytona/sources77
-rw-r--r--private/oleutest/act/tstsvc/dirs27
-rw-r--r--private/oleutest/act/tstsvc/pswrd.cxx56
-rw-r--r--private/oleutest/act/tstsvc/reg.cxx859
-rw-r--r--private/oleutest/act/tstsvc/service.cxx92
47 files changed, 9540 insertions, 0 deletions
diff --git a/private/oleutest/act/acttest.h b/private/oleutest/act/acttest.h
new file mode 100644
index 000000000..8ac135237
--- /dev/null
+++ b/private/oleutest/act/acttest.h
@@ -0,0 +1,44 @@
+/*
+ * acttest.h
+ */
+
+#ifndef _CLSID_
+#define _CLSID_
+
+#ifdef __cplusplus
+extern "C"{
+#endif
+
+
+extern CLSID CLSID_ActLocal;
+extern CLSID CLSID_ActRemote;
+extern CLSID CLSID_ActAtStorage;
+extern CLSID CLSID_ActInproc;
+extern CLSID CLSID_ActPreConfig;
+extern CLSID CLSID_ActRunAsLoggedOn;
+extern CLSID CLSID_ActService;
+extern CLSID CLSID_ActServerOnly;
+
+extern TCHAR * ClsidGoober32String;
+extern TCHAR * ClsidActLocalString;
+extern TCHAR * ClsidActRemoteString;
+extern TCHAR * ClsidActAtStorageString;
+extern TCHAR * ClsidActInprocString;
+extern TCHAR * ClsidActPreConfigString;
+extern TCHAR * ClsidActRunAsLoggedOnString;
+extern TCHAR * ClsidActServiceString;
+extern TCHAR * ClsidActServerOnlyString;
+
+void DeleteClsidKey( TCHAR * pwszClsid );
+
+long SetAppIDSecurity( TCHAR * pszAppID );
+
+
+int AddBatchPrivilege(const TCHAR *szUser);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
+
diff --git a/private/oleutest/act/client/client.cxx b/private/oleutest/act/client/client.cxx
new file mode 100644
index 000000000..cd13f1b7d
--- /dev/null
+++ b/private/oleutest/act/client/client.cxx
@@ -0,0 +1,2122 @@
+/*
+ * client.cxx
+ */
+
+#include "client.hxx"
+
+#define MIN_TEST_NUMBER 1
+#define MAX_TEST_NUMBER 27
+
+BOOL UnimplementedTest();
+BOOL UnsupportedTest();
+BOOL GenericCITest(REFCLSID clsid, REFIID iid, WCHAR * wszServerName, int n, DWORD ctxt);
+
+BOOL CGCOLocalEXE();
+BOOL CGCOExplicitActivator();
+BOOL CILocalDLL();
+BOOL CILocalEXE();
+BOOL CIExplicitActivator();
+BOOL CI3LocalEXE();
+BOOL CI3ExplicitActivator();
+BOOL CGIFFLocalEXE();
+BOOL CGIFFExplicitActivator();
+BOOL CGIFFRegistryActivator();
+BOOL CGIFFAtStorageActivator();
+BOOL IMBLocalEXE();
+BOOL IMBLocalService();
+BOOL IMBAtStorageActivator();
+BOOL IMBAtStorageService();
+BOOL IMBAtStoragePreCon();
+BOOL IMBAtStorageUser();
+BOOL CIFromStgLocalEXE();
+BOOL CIFromStgActivator();
+BOOL CICustomLocalDLL();
+BOOL CICustomLocalEXE();
+BOOL CILocalPreCon();
+BOOL CIExplicitPreCon();
+BOOL CILocalUser();
+BOOL CIExplicitUser();
+BOOL CILocalPreConACL();
+BOOL CIExplicitPreConACL();
+BOOL CILocalService();
+BOOL CIExplicitService();
+
+#ifdef NO_DCOM
+LPTESTFUNC rgTest[] =
+ {
+ NULL,
+ CGCOLocalEXE,
+ UnsupportedTest,
+ CILocalDLL,
+ CILocalEXE,
+ UnsupportedTest,
+ UnsupportedTest,
+ UnsupportedTest,
+ UnsupportedTest,
+ UnsupportedTest,
+ UnsupportedTest,
+ UnsupportedTest
+/* New tests
+ UnsupportedTest,
+ UnsupportedTest,
+end new tests */
+ CI3LocalEXE,
+ UnsupportedTest,
+ UnsupportedTest,
+ UnsupportedTest,
+ UnsupportedTest,
+ UnsupportedTest,
+ UnsupportedTest,
+ UnsupportedTest,
+ IMBLocalEXE,
+ UnsupportedTest,
+ UnsupportedTest,
+ UnsupportedTest,
+ UnsupportedTest,
+ UnsupportedTest,
+ UnsupportedTest,
+ UnsupportedTest,
+ NULL
+ };
+#else
+#ifdef CHICO
+LPTESTFUNC rgTest[] =
+ {
+ NULL,
+ CGCOLocalEXE,
+ CGCOExplicitActivator,
+ CILocalDLL,
+ CILocalEXE,
+ CIExplicitActivator,
+ CILocalPreCon,
+ CIExplicitPreCon,
+ CILocalUser,
+ CIExplicitUser,
+ UnsupportedTest,
+ CIExplicitService,
+/* new tests
+ CILocalPreConACL,
+ CIExplicitPreConACL,
+end new tests */
+ CI3LocalEXE,
+ CI3ExplicitActivator,
+ CICustomLocalDLL,
+ CICustomLocalEXE,
+ CGIFFLocalEXE,
+ CGIFFExplicitActivator,
+ CGIFFRegistryActivator,
+ CGIFFAtStorageActivator,
+ IMBLocalEXE,
+ UnsupportedTest,
+ IMBAtStorageActivator,
+ IMBAtStorageService,
+ IMBAtStoragePreCon,
+ IMBAtStorageUser,
+ CIFromStgLocalEXE,
+ CIFromStgActivator,
+ NULL
+ };
+#else
+LPTESTFUNC rgTest[] =
+ {
+ NULL,
+ CGCOLocalEXE,
+ CGCOExplicitActivator,
+ CILocalDLL,
+ CILocalEXE,
+ CIExplicitActivator,
+ CILocalPreCon,
+ CIExplicitPreCon,
+ CILocalUser,
+ CIExplicitUser,
+ CILocalService,
+ CIExplicitService,
+/* new tests
+ CILocalPreConACL,
+ CIExplicitPreConACL,
+end new tests */
+ CI3LocalEXE,
+ CI3ExplicitActivator,
+ CICustomLocalDLL,
+ CICustomLocalEXE,
+ CGIFFLocalEXE,
+ CGIFFExplicitActivator,
+ CGIFFRegistryActivator,
+ CGIFFAtStorageActivator,
+ IMBLocalEXE,
+ IMBLocalService,
+ IMBAtStorageActivator,
+ IMBAtStorageService,
+ IMBAtStoragePreCon,
+ IMBAtStorageUser,
+ CIFromStgLocalEXE,
+ CIFromStgActivator,
+ NULL
+ };
+#endif // CHICO
+#endif // NO_DCOM
+
+char * TestName[] =
+ {
+ NULL,
+ "CoGetClassObject local EXE",
+ "CoGetClassObject explicit activator",
+ "CoCreateInstance local DLL",
+ "CoCreateInstance local EXE",
+ "CoCreateInstance explicit activator",
+ "CoCreateInstance local pre-configured",
+ "CoCreateInstance explicit pre-configured",
+ "CoCreateInstance local user",
+ "CoCreateInstance explicit user",
+ "CoCreateInstance local service",
+ "CoCreateInstance explicit service",
+/* new tests
+ "CoCreateInstance local pre-configured ACL",
+ "CoCreateInstance explicit pre-configured ACL",
+end new tests */
+ "CoCreateInstance (3 IIDs) local EXE",
+ "CoCreateInstance (3 IIDs) explicit activator",
+ "CoCreateInstance from custom itf. local DLL",
+ "CoCreateInstance from custom itf. local EXE",
+ "CoGetInstanceFromFile local EXE",
+ "CoGetInstanceFromFile explicit activator",
+ "CoGetInstanceFromFile registry activator",
+ "CoGetInstanceFromFile AtStorage activator",
+ "IMoniker::BindToObject local EXE",
+ "IMoniker::BindToObject local service",
+ "IMoniker::BindToObject AtStorage activator",
+ "IMoniker::BindToObject AtStorage service",
+ "IMoniker::BindToObject AtStorage pre-configured",
+ "IMoniker::BindToObject AtStorage user",
+ "CoGetInstanceFromIStorage local EXE",
+ "CoGetInstanceFromIStorage explicit activator",
+ NULL
+ };
+
+char RunTest[] =
+ {
+ -1,
+ // CoGetClassObject
+ YES,
+ YES,
+ // CoCreateInstance
+ YES,
+ YES,
+ YES,
+ YES,
+ YES,
+ YES,
+ YES,
+ YES,
+ YES,
+/* new tests
+ YES,
+ YES,
+end new tests */
+ // CoCreateInstance (3 IIDs)
+ YES,
+ YES,
+ // CoGetInstanceFromFile
+ YES,
+ YES,
+ YES,
+ YES,
+ // IMoniker:Bind
+ YES,
+ YES,
+ YES,
+ YES,
+ YES,
+ YES,
+ YES,
+ YES,
+ YES,
+ YES,
+ -1
+ };
+
+char RunLocalTest[] =
+ {
+ -1,
+ // CoGetClassObject
+ YES,
+ NO,
+ // CreateInstance
+ YES,
+ YES,
+ NO,
+ YES,
+ NO,
+ YES,
+ NO,
+ YES,
+ NO,
+/* new tests
+ YES,
+ NO,
+end new tests */
+ // CreateInstance (3 IIDs)
+ YES,
+ NO,
+ // CreateInstance from custom Itf.
+ YES,
+ YES,
+ // CoGetInstanceFromFile
+ YES,
+ NO,
+ NO,
+ NO,
+ // IMoniker:Bind
+ YES,
+ YES,
+ NO,
+ NO,
+ NO,
+ NO,
+ // CoGetInstanceFromIStorage
+ YES,
+ NO,
+ -1
+ };
+
+WCHAR ServerName[32];
+WCHAR RemoteFileName[256];
+WCHAR * LocalFileName = L"c:\\acttest.dat";
+WCHAR * StorageName = L"c:\\acttest.stg";
+#ifndef UNICODE
+char szRemoteFileName[256];
+char * szLocalFileName = "c:\\acttest.dat";
+char * szStorageName = "c:\\acttest.stg";
+#endif
+
+LARGE_INTEGER liPerfFreq;
+LARGE_INTEGER liStart;
+LARGE_INTEGER liStop;
+LARGE_INTEGER liElapsedTime;
+
+#define RESET_CLOCK liElapsedTime.LowPart = liElapsedTime.HighPart = 0
+#define START_CLOCK QueryPerformanceCounter(&liStart)
+#define STOP_CLOCK QueryPerformanceCounter(&liStop); \
+ liElapsedTime.QuadPart += liStop.QuadPart - liStart.QuadPart
+#define DUMP_CLOCK DisplayElapsedTime()
+#define START_LOOP for (unsigned sl_n = uIterations+1; sl_n--;){
+#define STOP_LOOP if (uIterations == sl_n ) RESET_CLOCK;}
+#define SLEEP_IF_LOOPING if (sl_n && !gfHoldServer) Sleep(1000)
+
+unsigned uIterations = 0;
+
+BOOL gfRegister = TRUE;
+BOOL gfHoldServer = FALSE;
+BOOL gfLocal = FALSE;
+BOOL gfNolocal = FALSE;
+BOOL gfSpecificTest = FALSE;
+
+void DisplayElapsedTime(void)
+{
+ LONGLONG MicroPerIter;
+
+ liElapsedTime.QuadPart /= uIterations;
+
+ MicroPerIter = liElapsedTime.QuadPart * 1000000;
+ MicroPerIter /= liPerfFreq.QuadPart;
+
+ printf( "Time: %d microseconds per iteration", (DWORD) MicroPerIter );
+}
+
+BOOL AllLocal()
+{
+ for (int x = MIN_TEST_NUMBER; x<= MAX_TEST_NUMBER; x++)
+ {
+ if (RunTest[x] && !RunLocalTest[x])
+ return(FALSE);
+ }
+ return(TRUE);
+}
+
+void _cdecl main( int argc, char ** argv )
+{
+ HRESULT HResult;
+ HANDLE hFile;
+ int n;
+
+#ifndef NO_DCOM
+ if ( argc == 1 )
+ PrintUsageAndExit( FALSE );
+#endif // NO_DCOM
+
+ if ( argc > 1 && strcmp(argv[1],"-?") == 0 )
+ PrintUsageAndExit( TRUE );
+
+ n = 1;
+
+ while ( (n < argc) && (*argv[n] == '-') )
+ {
+ if ( (n < argc) && strcmp(argv[n],"-local") == 0 )
+ {
+ if (gfLocal | gfNolocal)
+ {
+ PrintUsageAndExit( FALSE );
+ }
+ gfLocal = TRUE;
+ memcpy(RunTest, RunLocalTest, MAX_TEST_NUMBER + MIN_TEST_NUMBER);
+ n++;
+ }
+
+ if ( (n < argc) && strcmp(argv[n],"-nolocal") == 0 )
+ {
+ if (gfLocal | gfNolocal)
+ {
+ PrintUsageAndExit( FALSE );
+ }
+ gfNolocal = TRUE;
+ for (int x = MIN_TEST_NUMBER; x<= MAX_TEST_NUMBER; x++)
+ {
+ RunTest[x] = !RunLocalTest[x];
+ }
+ n++;
+ }
+
+ if ( (n < argc) && strcmp(argv[n],"-noreg") == 0 )
+ {
+ gfRegister = FALSE;
+ n++;
+ continue;
+ }
+
+ if ( (n < argc) && strcmp(argv[n],"-hold") == 0 )
+ {
+ gfHoldServer = TRUE;
+ n++;
+ continue;
+ }
+
+ if ( (n < argc) && strcmp(argv[n],"-n") == 0 )
+ {
+ if ( ++n >= argc )
+ PrintUsageAndExit(FALSE);
+
+ uIterations = atoi(argv[n++]);
+ }
+
+ if ( (n < argc) && strcmp(argv[n],"-t") == 0 )
+ {
+ long TestNum1, TestNum2;
+
+ if ( ++n >= argc )
+ PrintUsageAndExit(FALSE);
+
+ TestNum1 = atoi(argv[n++]);
+
+ if ( (n < argc) && ((TestNum2 = atoi(argv[n])) != 0) )
+ n++;
+ else
+ TestNum2 = TestNum1;
+
+ if ( (TestNum1 < MIN_TEST_NUMBER) || (TestNum2 > MAX_TEST_NUMBER) )
+ {
+ printf( "Test number(s) must be between %d and %d.\n",
+ MIN_TEST_NUMBER,
+ MAX_TEST_NUMBER );
+ return;
+ }
+
+ if ( TestNum1 > TestNum2 )
+ {
+ printf( "Second test number must be greater than the first.\n" );
+ return;
+ }
+
+ if (!gfSpecificTest)
+ {
+ gfSpecificTest = TRUE;
+ // only do this the first time -t is found on the command line
+ memset(RunTest,NO,sizeof(RunTest));
+ }
+ memset(&RunTest[TestNum1],YES,sizeof(char)*(TestNum2-TestNum1+1));
+ }
+ }
+
+#ifndef NO_DCOM
+ if ( n != argc - 1 && !AllLocal())
+ {
+ printf("ERROR - Selected tests require a server name.\n");
+ ExitThread(0);
+ }
+
+ if ( n < argc )
+ {
+ MultiByteToWideChar( CP_ACP,
+ 0,
+ argv[n],
+ -1,
+ ServerName,
+ sizeof(ServerName) / sizeof(WCHAR) );
+ }
+ else
+ {
+ ServerName[0] = 0;
+ }
+#endif // NO_DCOM
+
+ hFile = CreateFile(
+#ifdef UNICODE
+ LocalFileName,
+#else
+ szLocalFileName,
+#endif
+ GENERIC_WRITE,
+ FILE_SHARE_READ,
+ 0,
+ OPEN_ALWAYS,
+ FILE_ATTRIBUTE_NORMAL,
+ 0 );
+
+ if ( hFile == INVALID_HANDLE_VALUE )
+ {
+ printf("CreateFile failed while creating local file: %d\n", GetLastError());
+ return;
+ }
+
+ CloseHandle( hFile );
+
+#ifndef NO_DCOM
+ if ( ServerName[0] != 0 )
+ {
+ RemoteFileName[0] = 0;
+
+ if ( ServerName[0] != L'\\' )
+ wcscat( RemoteFileName, L"\\\\" );
+
+ wcscat( RemoteFileName, ServerName );
+ wcscat( RemoteFileName, L"\\c$\\acttest.dat" );
+
+#ifndef UNICODE
+ WideCharToMultiByte(
+ CP_ACP,
+ 0,
+ RemoteFileName,
+ -1,
+ szRemoteFileName,
+ sizeof(szRemoteFileName),
+ NULL,
+ NULL );
+#endif
+
+ hFile = CreateFile(
+#ifdef UNICODE
+ RemoteFileName,
+#else
+ szRemoteFileName,
+#endif
+ GENERIC_WRITE,
+ FILE_SHARE_READ,
+ 0,
+ OPEN_ALWAYS,
+ FILE_ATTRIBUTE_NORMAL,
+ 0 );
+
+ if ( hFile == INVALID_HANDLE_VALUE )
+ {
+ printf("CreateFile failed while creating remote file: %d\n", GetLastError());
+ return;
+ }
+
+ CloseHandle( hFile );
+ }
+#endif // NO_DCOM
+
+ HResult = CoInitialize(NULL);
+
+ if( FAILED(HResult) )
+ {
+ printf( "Client CoInitialize failed Ox%x!\n", HResult );
+ return;
+ }
+
+ if ((!QueryPerformanceFrequency(&liPerfFreq)) && uIterations > 0)
+ {
+ printf("No high performance counter.\nTests cannot be timed.\nAborting.\n");
+ }
+ else
+ {
+ if ( ! Tests() )
+ printf("\nTests FAILED\n");
+ else
+ printf("\nTests SUCCEEDED\n");
+ }
+
+ CoUninitialize();
+#ifdef UNICODE
+ DeleteFile( LocalFileName );
+#ifndef NO_DCOM
+ DeleteFile( RemoteFileName );
+#endif // NO_DCOM
+#else
+ DeleteFile( szLocalFileName );
+#ifndef NO_DCOM
+ DeleteFile( szRemoteFileName );
+#endif // NO_DCOM
+#endif
+}
+
+BOOL Tests()
+{
+ HRESULT HResult;
+ long RegStatus;
+
+ if (gfRegister)
+ {
+ DeleteClsidKey( ClsidGoober32String );
+ DeleteClsidKey( ClsidActLocalString );
+ DeleteClsidKey( ClsidActRemoteString );
+ DeleteClsidKey( ClsidActAtStorageString );
+ DeleteClsidKey( ClsidActInprocString );
+ DeleteClsidKey( ClsidActPreConfigString );
+ DeleteClsidKey( ClsidActRunAsLoggedOnString );
+ DeleteClsidKey( ClsidActServiceString );
+ DeleteClsidKey( ClsidActServerOnlyString );
+
+ if ( (RegStatus = InitializeRegistryForInproc()) != ERROR_SUCCESS )
+ {
+ printf("InitializeRegistryForInproc failed %d.\n", RegStatus);
+ return FALSE;
+ }
+
+ if ( (RegStatus = InitializeRegistryForLocal()) != ERROR_SUCCESS )
+ {
+ printf("InitializeRegistryForLocal failed %d.\n", RegStatus);
+ return FALSE;
+ }
+
+ if ( (RegStatus = InitializeRegistryForCustom()) != ERROR_SUCCESS )
+ {
+ printf("InitializeRegistryForCustom failed %d.\n", RegStatus);
+ return FALSE;
+ }
+ #ifndef NO_DCOM
+ if ( (RegStatus = InitializeRegistryForRemote()) != ERROR_SUCCESS )
+ {
+ printf("InitializeRegistryForRemote failed %d.\n", RegStatus);
+ return FALSE;
+ }
+
+ if ( (RegStatus = InitializeRegistryForService()) != ERROR_SUCCESS )
+ {
+ printf("InitializeRegistryForService failed %d.\n", RegStatus);
+ return FALSE;
+ }
+ #endif // NO_DCOM
+ }
+ BOOL fAllTests = TRUE;
+
+ for (int x = MIN_TEST_NUMBER; x <= MAX_TEST_NUMBER; x++)
+ {
+ if (RunTest[x])
+ {
+ printf("\nTest %2d: %s\n",x, TestName[x]);
+ // prime the system once to ensure the test is fully cached
+ if (rgTest[x]())
+ {
+ printf("PASSED");
+ if (uIterations)
+ {
+ printf(" - ");
+ DUMP_CLOCK;
+ }
+ printf("\n");
+ }
+ else
+ {
+ printf("FAILED\n");
+ fAllTests = FALSE;
+ }
+
+ }
+ }
+
+ return(fAllTests);
+}
+
+void PrintUsageAndExit( BOOL bListTests )
+{
+#ifdef NO_DCOM
+ printf("Usage : %s [-hold] [-noreg] [-n #] [-t # [#]]\n", "actclt");
+ printf("\t-n # : Run specific number of timed iterations (default is 0).\n");
+ printf("\t-noreg : Don't update registry\n");
+ printf("\t-t # : Run specific test number or a range of tests.\n");
+ printf("\t-? : Print usage plus test descriptions.\n");
+#else
+ printf("Usage : %s [-hold] [-noreg] [[-local] | [-nolocal]] [-n #] [-t # [#]] [server_name]\n", "actclt");
+ printf("\t-hold : Hold the server up during all iterations.\n");
+ printf("\t-local : Run only local activation tests.\n");
+ printf("\t-n # : Run specific number of timed iterations (default is 0).\n");
+ printf("\t-nolocal : Run only remote activation tests.\n");
+ printf("\t-noreg : Don't update registry\n");
+ printf("\t-t # : Run specific test number or a range of tests.\n");
+ printf("\t-? : Print usage plus test descriptions.\n");
+#endif // NO_DCOM
+
+ if ( bListTests )
+ {
+ long n;
+
+ printf("\nTests :\n");
+ printf("\t # Method Location Security\n");
+ printf("\t-- ----------------------------------- ----------- --------------\n");
+
+ for ( n = MIN_TEST_NUMBER; n <= MAX_TEST_NUMBER; n++ )
+ {
+ printf("\t%2d %s\n", n, TestName[n]);
+ }
+ }
+
+ ExitThread(0);
+}
+
+void * __RPC_API
+MIDL_user_allocate(size_t len)
+{
+ return malloc(len);
+}
+
+void __RPC_API
+MIDL_user_free(void * vp)
+{
+ free(vp);
+}
+
+BOOL StampFileWithCLSID(WCHAR * szFilename, CLSID & clsid)
+{
+ HRESULT hr;
+ IStorage * pStg;
+
+ hr = StgCreateDocfile(
+ szFilename,
+ STGM_READWRITE | STGM_DIRECT | STGM_SHARE_EXCLUSIVE | STGM_CREATE,
+ 0,
+ &pStg);
+
+ if (FAILED (hr))
+ {
+ printf("StgCreateDocfile returned 0x%x\n", hr);
+ return(FALSE);
+ }
+
+ hr = WriteClassStg(pStg, clsid);
+
+ pStg->Release();
+
+ if (FAILED (hr))
+ {
+ printf("WriteClassStg returned 0x%x\n", hr);
+ return(FALSE);
+ }
+
+ return(TRUE);
+}
+
+//
+// Test Procedures:
+//
+
+BOOL UnimplementedTest()
+{
+ printf("Not implemented at this time.\n");
+ return(TRUE);
+}
+
+BOOL UnsupportedTest()
+{
+ printf("Not supported by this version.\n");
+ return(TRUE);
+}
+
+BOOL GenericCITest(REFCLSID clsid, REFIID iid, WCHAR * wszServerName, int n, DWORD ctxt)
+{
+ COSERVERINFO ServerInfo;
+ COSERVERINFO *pServerInfo;
+ IUnknown * punkHeld = NULL;
+
+ if (wszServerName)
+ {
+ memset( &ServerInfo, 0, sizeof(COSERVERINFO) );
+ ServerInfo.pwszName = wszServerName;
+ pServerInfo = &ServerInfo;
+ }
+ else
+ {
+ pServerInfo = NULL;
+ }
+
+ MULTI_QI QIStruct[10];
+ int x;
+ HRESULT hr;
+ BOOL fReturn = TRUE;
+
+ START_LOOP;
+
+ for (x = n; x--;)
+ {
+ QIStruct[x].pItf = NULL;
+ QIStruct[x].pIID = (IID *) &iid;
+ }
+
+
+ START_CLOCK;
+ hr = CoCreateInstanceEx(
+ clsid,
+ NULL,
+ ctxt,
+ pServerInfo,
+ n,
+ QIStruct);
+ STOP_CLOCK;
+
+ if ( FAILED(hr) )
+ {
+ printf("CoCreateInstanceEx returned 0x%x\n", hr);
+ if (punkHeld)
+ punkHeld->Release();
+ return FALSE;
+ }
+
+ if (gfHoldServer && NULL == punkHeld && SUCCEEDED(QIStruct[0].hr))
+ {
+ punkHeld = QIStruct[0].pItf;
+ punkHeld->AddRef();
+ }
+
+ for (x = 0; x < n; x++)
+ {
+ if (FAILED(QIStruct[x].hr))
+ {
+ printf("CoCreateInstanceEx returned 0x%x for interface %d\n",
+ QIStruct[x].hr, x);
+ fReturn = FALSE;
+ }
+ else
+ QIStruct[x].pItf->Release();
+ }
+ if (!fReturn)
+ {
+ if (punkHeld)
+ punkHeld->Release();
+ return(fReturn);
+ }
+
+ STOP_LOOP;
+
+ if (punkHeld)
+ punkHeld->Release();
+
+ return fReturn;
+}
+
+BOOL CGCOLocalEXE()
+{
+ IClassFactory * pClassFactory;
+ IUnknown * pUnknown;
+ IUnknown * punkHeld = NULL;
+ HRESULT hr;
+
+ START_LOOP;
+
+ START_CLOCK;
+ hr = CoGetClassObject(
+ CLSID_ActLocal,
+ CLSCTX_LOCAL_SERVER,
+ NULL,
+ IID_IClassFactory,
+ (void **) &pClassFactory );
+ STOP_CLOCK;
+
+ if ( FAILED(hr) )
+ {
+ printf("CoGetClassObject returned 0x%x\n", hr);
+ if (punkHeld)
+ punkHeld->Release();
+ return FALSE;
+ }
+
+ hr = pClassFactory->CreateInstance( NULL,
+ IID_IUnknown,
+ (void **) &pUnknown );
+
+ pClassFactory->Release();
+
+ if ( FAILED(hr) )
+ {
+ printf("CreateInstance returned 0x%x\n", hr);
+ if (punkHeld)
+ punkHeld->Release();
+ return FALSE;
+ }
+
+ if (gfHoldServer && NULL == punkHeld)
+ {
+ punkHeld = pUnknown;
+ punkHeld->AddRef();
+ }
+
+ pUnknown->Release();
+
+ STOP_LOOP;
+
+ if (punkHeld)
+ punkHeld->Release();
+
+ return TRUE;
+}
+
+#ifndef NO_DCOM
+BOOL CGCOExplicitActivator()
+{
+ COSERVERINFO ServerInfo;
+ IClassFactory * pClassFactory;
+ IUnknown * pUnknown;
+ IUnknown * punkHeld = NULL;
+ HRESULT hr;
+
+ memset( &ServerInfo, 0, sizeof(COSERVERINFO) );
+ ServerInfo.pwszName = ServerName;
+
+ START_LOOP;
+
+ START_CLOCK;
+ hr = CoGetClassObject(
+ CLSID_ActLocal,
+ CLSCTX_REMOTE_SERVER,
+ &ServerInfo,
+ IID_IClassFactory,
+ (void **) &pClassFactory );
+ STOP_CLOCK;
+
+ if ( FAILED(hr) )
+ {
+ printf("CoGetClassObject returned 0x%x\n", hr);
+ if (punkHeld)
+ punkHeld->Release();
+ return FALSE;
+ }
+
+ hr = pClassFactory->CreateInstance( NULL,
+ IID_IUnknown,
+ (void **) &pUnknown );
+
+ pClassFactory->Release();
+
+ if ( FAILED(hr) )
+ {
+ printf("CreateInstance returned 0x%x\n", hr);
+ if (punkHeld)
+ punkHeld->Release();
+ return FALSE;
+ }
+
+ if (gfHoldServer && NULL == punkHeld)
+ {
+ punkHeld = pUnknown;
+ punkHeld->AddRef();
+ }
+
+ pUnknown->Release();
+
+ STOP_LOOP;
+
+ if (punkHeld)
+ punkHeld->Release();
+ return TRUE;
+}
+#endif // NO_DCOM
+
+#ifdef NO_DCOM
+BOOL CILocalDLL()
+{
+ IUnknown * pUnknown;
+ IUnknown * punkHeld = NULL;
+ HRESULT hr;
+
+ START_LOOP;
+
+ START_CLOCK;
+ hr = CoCreateInstance(
+ CLSID_ActInproc,
+ NULL,
+ CLSCTX_INPROC_SERVER,
+ IID_IUnknown,
+ (void **) &pUnknown );
+ STOP_CLOCK;
+
+ if ( FAILED(hr) )
+ {
+ printf("CoCreateInstance returned 0x%x\n", hr);
+ if (punkHeld)
+ punkHeld->Release();
+ return FALSE;
+ }
+
+ if (gfHoldServer && NULL == punkHeld)
+ {
+ punkHeld = pUnknown;
+ punkHeld->AddRef();
+ }
+
+ pUnknown->Release();
+
+ STOP_LOOP;
+
+ if (punkHeld)
+ punkHeld->Release();
+ return TRUE;
+}
+
+BOOL CILocalEXE()
+{
+ IUnknown * pUnknown;
+ IUnknown * punkHeld = NULL;
+ HRESULT hr;
+
+ START_LOOP;
+
+ START_CLOCK;
+ hr = CoCreateInstance(
+ CLSID_ActLocal,
+ NULL,
+ CLSCTX_LOCAL_SERVER,
+ IID_IUnknown,
+ (void **) &pUnknown );
+ STOP_CLOCK;
+
+ if ( FAILED(hr) )
+ {
+ printf("CoCreateInstance returned 0x%x\n", hr);
+ if (punkHeld)
+ punkHeld->Release();
+ return FALSE;
+ }
+
+ if (gfHoldServer && NULL == punkHeld)
+ {
+ punkHeld = pUnknown;
+ punkHeld->AddRef();
+ }
+
+ pUnknown->Release();
+
+ STOP_LOOP;
+
+ if (punkHeld)
+ punkHeld->Release();
+
+ return TRUE;
+}
+#else
+BOOL CILocalDLL()
+{
+ return GenericCITest(CLSID_ActInproc, IID_IUnknown, NULL, 1, CLSCTX_INPROC_SERVER);
+}
+
+BOOL CILocalEXE()
+{
+ return GenericCITest(CLSID_ActLocal, IID_IUnknown, NULL, 1, CLSCTX_LOCAL_SERVER);
+}
+
+BOOL CIExplicitActivator()
+{
+#ifdef UNICODE
+ return GenericCITest(CLSID_ActLocal, IID_IUnknown, ServerName, 1, CLSCTX_REMOTE_SERVER);
+#else
+ return GenericCITest(CLSID_ActLocal, IID_IUnknown, wszServerName, 1, CLSCTX_REMOTE_SERVER);
+#endif
+}
+#endif // NO_DCOM
+
+#ifdef NO_DCOM
+// Pre-DCOM version of CI3LocalEXE which calls CoCreateInstance
+// once followed by 2 calls to QueryInterface
+// instead of calling CoCreateInstanceEx.
+BOOL CI3LocalEXE()
+{
+ IUnknown * pUnknown;
+ IUnknwon * punkHeld = NULL;
+ IPersist * pPersist;
+ IPersistFile * pPersistFile;
+
+ HRESULT hr;
+
+ START_LOOP;
+
+ START_CLOCK;
+ hr = CoCreateInstance(
+ CLSID_ActLocal,
+ NULL,
+ CLSCTX_LOCAL_SERVER,
+ IID_IUnknown,
+ (void **) &pUnknown );
+
+ if ( FAILED(hr) )
+ {
+ printf("CoCreateInstance returned 0x%x\n", hr);
+ if (punkHeld)
+ punkHeld->Release();
+ return FALSE;
+ }
+
+ if (gfHoldServer && NULL == punkHeld)
+ {
+ punkHeld = pUnknown;
+ punkHeld->AddRef();
+ }
+
+ pUnknown->QueryInterface( IID_IPersist, (void **)&pPersist );
+ pUnknown->QueryInterface( IID_IPersist, (void **)&pPersistFile );
+ STOP_CLOCK;
+
+ pUnknown->Release();
+ pPersist->Release();
+ pPersistFile->Release();
+
+ STOP_LOOP;
+
+ if (punkHeld)
+ punkHeld->Release();
+
+ return TRUE;
+}
+#else // NO_DCOM
+
+BOOL CI3LocalEXE()
+{
+ return GenericCITest(CLSID_ActLocal, IID_IPersist, NULL, 3, CLSCTX_LOCAL_SERVER);
+ /*
+ MULTI_QI QIStruct[3];
+ QIStruct[0].pIID = (IID *)&IID_IUnknown;
+ QIStruct[1].pIID = (IID *)&IID_IPersist;
+ QIStruct[2].pIID = (IID *)&IID_IPersistFile;
+ QIStruct[0].pItf = NULL;
+ QIStruct[1].pItf = NULL;
+ QIStruct[2].pItf = NULL;
+ */
+}
+
+BOOL CI3ExplicitActivator()
+{
+#ifdef UNICODE
+ return GenericCITest(CLSID_ActLocal, IID_IPersist, ServerName, 3, CLSCTX_REMOTE_SERVER);
+#else
+ return GenericCITest(CLSID_ActLocal, IID_IPersist, wszServerName, 3, CLSCTX_REMOTE_SERVER);
+#endif
+ /*
+ MULTI_QI QIStruct[3];
+ QIStruct[0].pIID = (IID *)&IID_IUnknown;
+ QIStruct[1].pIID = (IID *)&IID_IPersist;
+ QIStruct[2].pIID = (IID *)&IID_IPersistFile;
+ QIStruct[0].pItf = NULL;
+ QIStruct[1].pItf = NULL;
+ QIStruct[2].pItf = NULL;
+ */
+}
+
+BOOL CGIFFLocalEXE()
+{
+ MULTI_QI QIStruct[1];
+ IUnknown * punkHeld = NULL;
+
+ START_LOOP;
+
+ QIStruct[0].pIID = (IID *)&IID_IUnknown;
+ QIStruct[0].pItf = NULL;
+
+ START_CLOCK;
+ HRESULT HResult = CoGetInstanceFromFile(
+ NULL,
+ &CLSID_ActLocal,
+ NULL,
+ CLSCTX_LOCAL_SERVER,
+ STGM_READWRITE,
+ LocalFileName,
+ 1,
+ QIStruct );
+ STOP_CLOCK;
+
+ if ( FAILED(HResult) )
+ {
+ printf("CoGetInstanceFromFile returned 0x%x\n", HResult);
+ if (punkHeld)
+ punkHeld->Release();
+ return FALSE;
+ }
+
+ if (gfHoldServer && NULL == punkHeld)
+ {
+ punkHeld = QIStruct[0].pItf;
+ punkHeld->AddRef();
+ }
+
+ QIStruct[0].pItf->Release();
+
+ STOP_LOOP;
+
+ if (punkHeld)
+ punkHeld->Release();
+ return(TRUE);
+}
+
+BOOL CGIFFExplicitActivator()
+{
+ COSERVERINFO ServerInfo;
+ IUnknown * punkHeld = NULL;
+
+ memset( &ServerInfo, 0, sizeof(COSERVERINFO) );
+ ServerInfo.pwszName = ServerName;
+
+ MULTI_QI QIStruct[1];
+
+ START_LOOP;
+
+ QIStruct[0].pIID = (IID *)&IID_IUnknown;
+ QIStruct[0].pItf = NULL;
+
+ START_CLOCK;
+ HRESULT HResult = CoGetInstanceFromFile(
+ &ServerInfo,
+ &CLSID_ActLocal,
+ NULL,
+ CLSCTX_REMOTE_SERVER,
+ STGM_READWRITE,
+ RemoteFileName,
+ 1,
+ QIStruct );
+ STOP_CLOCK;
+
+ if ( FAILED(HResult) )
+ {
+ printf("CoGetInstanceFromFile returned 0x%x\n", HResult);
+ if (punkHeld)
+ punkHeld->Release();
+ return FALSE;
+ }
+
+ if (gfHoldServer && NULL == punkHeld)
+ {
+ punkHeld = QIStruct[0].pItf;
+ punkHeld->AddRef();
+ }
+
+ QIStruct[0].pItf->Release();
+
+ STOP_LOOP;
+
+ if (punkHeld)
+ punkHeld->Release();
+ return(TRUE);
+}
+
+BOOL CGIFFRegistryActivator()
+{
+ MULTI_QI QIStruct[1];
+ IUnknown * punkHeld = NULL;
+
+ START_LOOP;
+
+ QIStruct[0].pIID = (IID *)&IID_IUnknown;
+ QIStruct[0].pItf = NULL;
+ START_CLOCK;
+ HRESULT HResult = CoGetInstanceFromFile(
+ NULL,
+ &CLSID_ActRemote,
+ NULL,
+ CLSCTX_REMOTE_SERVER,
+ STGM_READWRITE,
+ RemoteFileName,
+ 1,
+ QIStruct );
+ STOP_CLOCK;
+
+ if ( FAILED(HResult) )
+ {
+ printf("CoGetInstanceFromFile returned 0x%x\n", HResult);
+ if (punkHeld)
+ punkHeld->Release();
+ return FALSE;
+ }
+
+ if (gfHoldServer && NULL == punkHeld)
+ {
+ punkHeld = QIStruct[0].pItf;
+ punkHeld->AddRef();
+ }
+
+ QIStruct[0].pItf->Release();
+
+ STOP_LOOP;
+
+ if (punkHeld)
+ punkHeld->Release();
+ return(TRUE);
+}
+
+BOOL CGIFFAtStorageActivator()
+{
+ MULTI_QI QIStruct[1];
+ IUnknown * punkHeld = NULL;
+
+ START_LOOP;
+
+ QIStruct[0].pIID = (IID *)&IID_IUnknown;
+ QIStruct[0].pItf = NULL;
+ START_CLOCK;
+ HRESULT HResult = CoGetInstanceFromFile(
+ NULL,
+ &CLSID_ActAtStorage,
+ NULL,
+ CLSCTX_REMOTE_SERVER,
+ STGM_READWRITE,
+ RemoteFileName,
+ 1,
+ QIStruct );
+ STOP_CLOCK;
+
+ if ( FAILED(HResult) )
+ {
+ printf("CoGetInstanceFromFile returned 0x%x\n", HResult);
+ if (punkHeld)
+ punkHeld->Release();
+ return FALSE;
+ }
+
+ if (gfHoldServer && NULL == punkHeld)
+ {
+ punkHeld = QIStruct[0].pItf;
+ punkHeld->AddRef();
+ }
+
+ QIStruct[0].pItf->Release();
+
+ STOP_LOOP;
+
+ if (punkHeld)
+ punkHeld->Release();
+ return(TRUE);
+}
+#endif // NO_DCOM
+
+BOOL IMBLocalEXE()
+{
+ IBindCtx * pBc;
+ IUnknown * pUnk;
+ IUnknown * punkHeld = NULL;
+ HRESULT hr;
+ IMoniker *pMon;
+
+ if (!StampFileWithCLSID(LocalFileName, CLSID_ActLocal))
+ {
+ return(FALSE);
+ }
+
+ hr = CreateFileMoniker(LocalFileName, &pMon);
+
+ if (FAILED(hr))
+ {
+ printf("CreateFileMoniker returned 0x%x\n", hr);
+ }
+
+ hr = CreateBindCtx(0, &pBc);
+
+ if (FAILED(hr))
+ {
+ printf("CreateBindCtx returned 0x%x\n", hr);
+ pMon->Release();
+ return(FALSE);
+ }
+
+ START_LOOP;
+
+ START_CLOCK;
+ hr = pMon->BindToObject(
+ pBc,
+ NULL,
+ IID_IUnknown,
+ (void **) &pUnk);
+ STOP_CLOCK;
+
+ if (FAILED(hr))
+ {
+ printf("IMoniker::BindToObject returned 0x%x\n", hr);
+ if (punkHeld)
+ punkHeld->Release();
+ return(FALSE);
+ }
+
+ if (gfHoldServer && NULL == punkHeld)
+ {
+ punkHeld = pUnk;
+ punkHeld->AddRef();
+ }
+
+ pUnk->Release();
+
+ STOP_LOOP
+
+ pMon->Release();
+ pBc->Release();
+
+ if (punkHeld)
+ punkHeld->Release();
+ return(TRUE);
+}
+
+#ifndef NO_DCOM
+BOOL IMBLocalService()
+{
+ IBindCtx * pBc;
+ IUnknown * pUnk;
+ IUnknown * punkHeld = NULL;
+ HRESULT hr;
+ IMoniker *pMon;
+
+ if (!StampFileWithCLSID(LocalFileName, CLSID_ActService))
+ {
+ return(FALSE);
+ }
+
+ hr = CreateFileMoniker(LocalFileName, &pMon);
+
+ if (FAILED(hr))
+ {
+ printf("CreateFileMoniker returned 0x%x\n", hr);
+ }
+
+ hr = CreateBindCtx(0, &pBc);
+
+ if (FAILED(hr))
+ {
+ printf("CreateBindCtx returned 0x%x\n", hr);
+ pMon->Release();
+ return(FALSE);
+ }
+
+ START_LOOP;
+
+ START_CLOCK;
+ hr = pMon->BindToObject(
+ pBc,
+ NULL,
+ IID_IUnknown,
+ (void **) &pUnk);
+ STOP_CLOCK;
+ if (FAILED(hr))
+ {
+ printf("IMoniker::BindToObject returned 0x%x\n", hr);
+ if (punkHeld)
+ punkHeld->Release();
+ return(FALSE);
+ }
+
+ if (gfHoldServer && NULL == punkHeld)
+ {
+ punkHeld = pUnk;
+ punkHeld->AddRef();
+ }
+ pUnk->Release();
+
+ SLEEP_IF_LOOPING;
+
+ STOP_LOOP;
+
+ pMon->Release();
+ pBc->Release();
+
+ if (punkHeld)
+ punkHeld->Release();
+ return(TRUE);
+}
+
+BOOL IMBAtStorageActivator()
+{
+ IBindCtx * pBc;
+ IUnknown * pUnk;
+ IUnknown * punkHeld = NULL;
+ HRESULT hr;
+ IMoniker *pMon;
+
+ if (!StampFileWithCLSID(RemoteFileName, CLSID_ActAtStorage))
+ {
+ return(FALSE);
+ }
+
+ hr = CreateFileMoniker(RemoteFileName, &pMon);
+
+ if (FAILED(hr))
+ {
+ printf("CreateFileMoniker returned 0x%x\n", hr);
+ }
+
+ hr = CreateBindCtx(0, &pBc);
+
+ if (FAILED(hr))
+ {
+ printf("CreateBindCtx returned 0x%x\n", hr);
+ pMon->Release();
+ return(FALSE);
+ }
+
+ START_LOOP;
+
+ START_CLOCK;
+ hr = pMon->BindToObject(
+ pBc,
+ NULL,
+ IID_IUnknown,
+ (void **) &pUnk);
+ STOP_CLOCK;
+
+ if (FAILED(hr))
+ {
+ printf("IMoniker::BindToObject returned 0x%x\n", hr);
+ if (punkHeld)
+ punkHeld->Release();
+ return(FALSE);
+ }
+
+ if (gfHoldServer && NULL == punkHeld)
+ {
+ punkHeld = pUnk;
+ punkHeld->AddRef();
+ }
+
+ pUnk->Release();
+
+ STOP_LOOP;
+
+ pMon->Release();
+ pBc->Release();
+
+ if (punkHeld)
+ punkHeld->Release();
+ return(TRUE);
+}
+
+BOOL IMBAtStorageService()
+{
+ IBindCtx * pBc;
+ IUnknown * pUnk;
+ IUnknown * punkHeld = NULL;
+ HRESULT hr;
+ IMoniker *pMon;
+
+ if (!StampFileWithCLSID(RemoteFileName, CLSID_ActService))
+ {
+ return(FALSE);
+ }
+
+ hr = CreateFileMoniker(RemoteFileName, &pMon);
+
+ if (FAILED(hr))
+ {
+ printf("CreateFileMoniker returned 0x%x\n", hr);
+ }
+
+ hr = CreateBindCtx(0, &pBc);
+
+ if (FAILED(hr))
+ {
+ printf("CreateBindCtx returned 0x%x\n", hr);
+ pMon->Release();
+ return(FALSE);
+ }
+
+ START_LOOP;
+
+ START_CLOCK;
+ hr = pMon->BindToObject(
+ pBc,
+ NULL,
+ IID_IUnknown,
+ (void **) &pUnk);
+ STOP_CLOCK;
+
+ if (FAILED(hr))
+ {
+ printf("IMoniker::BindToObject returned 0x%x\n", hr);
+ if (punkHeld)
+ punkHeld->Release();
+ return(FALSE);
+ }
+
+ if (gfHoldServer && NULL == punkHeld)
+ {
+ punkHeld = pUnk;
+ punkHeld->AddRef();
+ }
+
+ pUnk->Release();
+
+ SLEEP_IF_LOOPING;
+
+ STOP_LOOP;
+
+ pMon->Release();
+ pBc->Release();
+
+ if (punkHeld)
+ punkHeld->Release();
+ return(TRUE);
+}
+
+BOOL IMBAtStoragePreCon()
+{
+ IBindCtx * pBc;
+ IUnknown * pUnk;
+ IUnknown * punkHeld = NULL;
+ HRESULT hr;
+ IMoniker *pMon;
+
+ if (!StampFileWithCLSID(RemoteFileName, CLSID_ActPreConfig))
+ {
+ return(FALSE);
+ }
+
+ hr = CreateFileMoniker(RemoteFileName, &pMon);
+
+ if (FAILED(hr))
+ {
+ printf("CreateFileMoniker returned 0x%x\n", hr);
+ }
+
+ hr = CreateBindCtx(0, &pBc);
+
+ if (FAILED(hr))
+ {
+ printf("CreateBindCtx returned 0x%x\n", hr);
+ pMon->Release();
+ return(FALSE);
+ }
+
+ START_LOOP;
+
+ START_CLOCK;
+ hr = pMon->BindToObject(
+ pBc,
+ NULL,
+ IID_IUnknown,
+ (void **) &pUnk);
+ STOP_CLOCK;
+
+ if (FAILED(hr))
+ {
+ printf("IMoniker::BindToObject returned 0x%x\n", hr);
+ if (punkHeld)
+ punkHeld->Release();
+ return(FALSE);
+ }
+
+ if (gfHoldServer && NULL == punkHeld)
+ {
+ punkHeld = pUnk;
+ punkHeld->AddRef();
+ }
+
+ pUnk->Release();
+
+ STOP_LOOP;
+
+ pMon->Release();
+ pBc->Release();
+
+ if (punkHeld)
+ punkHeld->Release();
+ return(TRUE);
+}
+
+BOOL IMBAtStorageUser()
+{
+ IBindCtx * pBc;
+ IUnknown * pUnk;
+ IUnknown * punkHeld = NULL;
+ HRESULT hr;
+ IMoniker *pMon;
+
+ if (!StampFileWithCLSID(RemoteFileName, CLSID_ActRunAsLoggedOn))
+ {
+ return(FALSE);
+ }
+
+ hr = CreateFileMoniker(RemoteFileName, &pMon);
+
+ if (FAILED(hr))
+ {
+ printf("CreateFileMoniker returned 0x%x\n", hr);
+ }
+
+ hr = CreateBindCtx(0, &pBc);
+
+ if (FAILED(hr))
+ {
+ printf("CreateBindCtx returned 0x%x\n", hr);
+ pMon->Release();
+ return(FALSE);
+ }
+
+ START_LOOP;
+
+ START_CLOCK;
+ hr = pMon->BindToObject(
+ pBc,
+ NULL,
+ IID_IUnknown,
+ (void **) &pUnk);
+ STOP_CLOCK;
+
+ if (FAILED(hr))
+ {
+ printf("IMoniker::BindToObject returned 0x%x\n", hr);
+ if (punkHeld)
+ punkHeld->Release();
+ return(FALSE);
+ }
+
+ if (gfHoldServer && NULL == punkHeld)
+ {
+ punkHeld = pUnk;
+ punkHeld->AddRef();
+ }
+
+ pUnk->Release();
+
+ STOP_LOOP;
+
+ pMon->Release();
+ pBc->Release();
+
+ if (punkHeld)
+ punkHeld->Release();
+ return(TRUE);
+}
+
+BOOL CIFromStgLocalEXE()
+{
+ IStorage * pStorage;
+ MULTI_QI QIStruct[10];
+ IUnknown * punkHeld = NULL;
+
+ pStorage = 0;
+
+#ifdef UNICODE
+ DeleteFile( StorageName );
+#else
+ DeleteFile( szStorageName );
+#endif
+
+ HRESULT HResult = StgCreateDocfile(
+ StorageName,
+ STGM_READWRITE | STGM_DIRECT | STGM_SHARE_EXCLUSIVE | STGM_CREATE,
+ 0,
+ &pStorage );
+
+ if ( FAILED(HResult) )
+ {
+ printf("StgCreateDocfile returned 0x%x\n", HResult);
+ return FALSE;
+ }
+
+ START_LOOP;
+
+ QIStruct[0].pIID = (IID *)&IID_IUnknown;
+ QIStruct[0].pItf = NULL;
+
+ START_CLOCK;
+ HResult = CoGetInstanceFromIStorage(
+ NULL,
+ &CLSID_ActLocal,
+ NULL,
+ CLSCTX_SERVER,
+ pStorage,
+ 1,
+ QIStruct );
+ STOP_CLOCK;
+
+ if ( FAILED(HResult) )
+ {
+ printf("CoGetInstanceFromIStorage returned 0x%x\n", HResult);
+ if (punkHeld)
+ punkHeld->Release();
+ return FALSE;
+ }
+
+ if (gfHoldServer && NULL == punkHeld)
+ {
+ punkHeld = QIStruct[0].pItf;
+ punkHeld->AddRef();
+ }
+
+ QIStruct[0].pItf->Release();
+ QIStruct[0].pItf = 0;
+
+ STOP_LOOP;
+
+ pStorage->Release();
+
+ if (punkHeld)
+ punkHeld->Release();
+ return(TRUE);
+}
+
+BOOL CIFromStgActivator()
+{
+ IStorage * pStorage;
+ MULTI_QI QIStruct[10];
+ COSERVERINFO ServerInfo;
+ IUnknown * punkHeld = NULL;
+
+ memset( &ServerInfo, 0, sizeof(COSERVERINFO) );
+ ServerInfo.pwszName = ServerName;
+
+ pStorage = 0;
+
+#ifdef UNICODE
+ DeleteFile( StorageName );
+#else
+ DeleteFile( szStorageName );
+#endif
+
+ HRESULT HResult = StgCreateDocfile(
+ StorageName,
+ STGM_READWRITE | STGM_DIRECT | STGM_SHARE_EXCLUSIVE | STGM_CREATE,
+ 0,
+ &pStorage );
+
+ if ( FAILED(HResult) )
+ {
+ printf("StgCreateDocfile returned 0x%x\n", HResult);
+ return FALSE;
+ }
+
+ START_LOOP;
+
+ QIStruct[0].pIID = (IID *)&IID_IUnknown;
+ QIStruct[0].pItf = NULL;
+
+ START_CLOCK;
+ HResult = CoGetInstanceFromIStorage(
+ &ServerInfo,
+ &CLSID_ActRemote,
+ NULL,
+ CLSCTX_REMOTE_SERVER,
+ pStorage,
+ 1,
+ QIStruct );
+ STOP_CLOCK;
+
+ if ( FAILED(HResult) )
+ {
+ printf("CoGetInstanceFromIStorage returned 0x%x\n", HResult);
+ if (punkHeld)
+ punkHeld->Release();
+ return FALSE;
+ }
+
+ if (gfHoldServer && NULL == punkHeld)
+ {
+ punkHeld = QIStruct[0].pItf;
+ punkHeld->AddRef();
+ }
+
+ QIStruct[0].pItf->Release();
+ QIStruct[0].pItf = 0;
+
+ STOP_LOOP;
+
+ pStorage->Release();
+
+ if (punkHeld)
+ punkHeld->Release();
+ return(TRUE);
+}
+
+BOOL CICustomLocalDLL()
+{
+ IGoober * pGoober;
+ MULTI_QI QIStruct[10];
+ HRESULT hr;
+ IUnknown * punkHeld = NULL;
+
+ START_LOOP;
+
+ QIStruct[0].pItf = NULL;
+ QIStruct[0].pIID = (IID *) &IID_IGoober;
+
+ START_CLOCK;
+ hr = CoCreateInstanceEx(
+ CLSID_ActInproc,
+ NULL,
+ CLSCTX_INPROC_SERVER,
+ NULL,
+ 1,
+ QIStruct );
+ STOP_CLOCK;
+
+ pGoober = (IGoober *)QIStruct[0].pItf;
+
+ if ( FAILED(hr) )
+ {
+ printf("CoCreateInstanceEx returned 0x%x\n", hr);
+ if (punkHeld)
+ punkHeld->Release();
+ return FALSE;
+ }
+
+ if (gfHoldServer && NULL == punkHeld)
+ {
+ punkHeld = QIStruct[0].pItf;
+ punkHeld->AddRef();
+ }
+
+ START_CLOCK;
+ hr = pGoober->Ping();
+ STOP_CLOCK;
+
+ if ( hr != S_OK )
+ {
+ printf("IGoober::Ping returned %d\n", hr);
+ pGoober->Release();
+ if (punkHeld)
+ punkHeld->Release();
+ return FALSE;
+ }
+
+ pGoober->Release();
+
+ STOP_LOOP;
+
+ if (punkHeld)
+ punkHeld->Release();
+ return(TRUE);
+}
+
+BOOL CICustomLocalEXE()
+{
+ IGoober * pGoober;
+ MULTI_QI QIStruct[10];
+ HRESULT hr;
+ IUnknown * punkHeld = NULL;
+
+ START_LOOP;
+
+ QIStruct[0].pItf = NULL;
+ QIStruct[0].pIID = (IID *) &IID_IGoober;
+
+ START_CLOCK;
+ hr = CoCreateInstanceEx(
+ CLSID_ActLocal,
+ NULL,
+ CLSCTX_LOCAL_SERVER,
+ NULL,
+ 1,
+ QIStruct );
+ STOP_CLOCK;
+
+ pGoober = (IGoober *)QIStruct[0].pItf;
+
+ if ( FAILED(hr) )
+ {
+ printf("CoCreateInstanceEx returned 0x%x\n", hr);
+ if (punkHeld)
+ punkHeld->Release();
+ return FALSE;
+ }
+
+ if (gfHoldServer && NULL == punkHeld)
+ {
+ punkHeld = QIStruct[0].pItf;
+ punkHeld->AddRef();
+ }
+
+ START_CLOCK;
+ hr = pGoober->Ping();
+ STOP_CLOCK;
+
+ if ( hr != S_OK )
+ {
+ printf("IGoober::Ping returned %d\n", hr);
+ pGoober->Release();
+ if (punkHeld)
+ punkHeld->Release();
+ return FALSE;
+ }
+
+ pGoober->Release();
+
+ STOP_LOOP;
+
+ if (punkHeld)
+ punkHeld->Release();
+ return(TRUE);
+}
+
+BOOL CILocalPreCon()
+{
+ return GenericCITest(CLSID_ActPreConfig, IID_IUnknown, NULL, 1, CLSCTX_LOCAL_SERVER);
+}
+
+BOOL CIExplicitPreCon()
+{
+#ifdef UNICODE
+ return GenericCITest(CLSID_ActPreConfig, IID_IUnknown, ServerName, 1, CLSCTX_REMOTE_SERVER);
+#else
+ return GenericCITest(CLSID_ActPreConfig, IID_IUnknown, wszServerName, 1, CLSCTX_REMOTE_SERVER);
+#endif
+}
+
+BOOL CILocalUser()
+{
+ return GenericCITest(CLSID_ActRunAsLoggedOn, IID_IUnknown, NULL, 1, CLSCTX_LOCAL_SERVER);
+}
+
+BOOL CIExplicitUser()
+{
+#ifdef UNICODE
+ return GenericCITest(CLSID_ActRunAsLoggedOn, IID_IUnknown, ServerName, 1, CLSCTX_REMOTE_SERVER);
+#else
+ return GenericCITest(CLSID_ActRunAsLoggedOn, IID_IUnknown, wszServerName, 1, CLSCTX_REMOTE_SERVER);
+#endif
+}
+
+BOOL CILocalService()
+{
+ COSERVERINFO ServerInfo;
+ COSERVERINFO *pServerInfo;
+ IUnknown * punkHeld = NULL;
+
+ MULTI_QI QIStruct[1];
+ HRESULT hr;
+ BOOL fReturn = TRUE;
+
+ START_LOOP;
+
+ QIStruct[0].pItf = NULL;
+ QIStruct[0].pIID = (IID *) &IID_IUnknown;
+
+ START_CLOCK;
+ hr = CoCreateInstanceEx(
+ CLSID_ActService,
+ NULL,
+ CLSCTX_LOCAL_SERVER,
+ NULL,
+ 1,
+ QIStruct);
+ STOP_CLOCK;
+
+ if ( FAILED(hr) )
+ {
+ printf("CoCreateInstanceEx returned 0x%x\n", hr);
+ if (punkHeld)
+ punkHeld->Release();
+ return FALSE;
+ }
+
+ if (gfHoldServer && NULL == punkHeld && SUCCEEDED(QIStruct[0].hr))
+ {
+ punkHeld = QIStruct[0].pItf;
+ punkHeld->AddRef();
+ }
+
+ if (FAILED(QIStruct[0].hr))
+ {
+ printf("CoCreateInstanceEx returned 0x%x\n",
+ QIStruct[0].hr);
+ fReturn = FALSE;
+ }
+ else
+ QIStruct[0].pItf->Release();
+
+ if (!fReturn)
+ {
+ if (punkHeld)
+ punkHeld->Release();
+ return(fReturn);
+ }
+
+ SLEEP_IF_LOOPING;
+
+ STOP_LOOP;
+
+ if (punkHeld)
+ punkHeld->Release();
+
+ return fReturn;
+}
+
+BOOL CIExplicitService()
+{
+ COSERVERINFO ServerInfo;
+ COSERVERINFO *pServerInfo;
+ IUnknown * punkHeld = NULL;
+
+ memset( &ServerInfo, 0, sizeof(COSERVERINFO) );
+ ServerInfo.pwszName = ServerName;
+ pServerInfo = &ServerInfo;
+
+ MULTI_QI QIStruct[1];
+ HRESULT hr;
+ BOOL fReturn = TRUE;
+
+ START_LOOP;
+
+ QIStruct[0].pItf = NULL;
+ QIStruct[0].pIID = (IID *) &IID_IUnknown;
+
+ START_CLOCK;
+ hr = CoCreateInstanceEx(
+ CLSID_ActService,
+ NULL,
+ CLSCTX_REMOTE_SERVER,
+ pServerInfo,
+ 1,
+ QIStruct);
+ STOP_CLOCK;
+
+ if ( FAILED(hr) )
+ {
+ printf("CoCreateInstanceEx returned 0x%x\n", hr);
+ if (punkHeld)
+ punkHeld->Release();
+ return FALSE;
+ }
+
+ if (gfHoldServer && NULL == punkHeld && SUCCEEDED(QIStruct[0].hr))
+ {
+ punkHeld = QIStruct[0].pItf;
+ punkHeld->AddRef();
+ }
+
+ if (FAILED(QIStruct[0].hr))
+ {
+ printf("CoCreateInstanceEx returned 0x%x\n",
+ QIStruct[0].hr);
+ fReturn = FALSE;
+ }
+ else
+ QIStruct[0].pItf->Release();
+
+ if (!fReturn)
+ {
+ if (punkHeld)
+ punkHeld->Release();
+ return(fReturn);
+ }
+
+ SLEEP_IF_LOOPING;
+
+ STOP_LOOP;
+
+ if (punkHeld)
+ punkHeld->Release();
+
+ return fReturn;
+}
+
+BOOL CILocalPreConACL();
+BOOL CIExplicitPreConACL();
+
+#endif // NO_DCOM
diff --git a/private/oleutest/act/client/client.hxx b/private/oleutest/act/client/client.hxx
new file mode 100644
index 000000000..b5c9a412f
--- /dev/null
+++ b/private/oleutest/act/client/client.hxx
@@ -0,0 +1,43 @@
+/*
+ * client.hxx
+ */
+
+#ifdef UNICODE
+#define _UNICODE 1
+#endif
+
+#include <windows.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <tchar.h>
+#include <ole2.h>
+#include <oleext.h>
+#include "..\acttest.h"
+#include "..\dll\goober.h"
+#include <rpc.h>
+
+// To build performance tests for pre-DCOM systems
+// uncomment the following line.
+//#define NO_DCOM
+
+typedef unsigned long ulong;
+typedef unsigned char uchar;
+#define NO 0
+#define YES 1
+
+typedef BOOL (* LPTESTFUNC) (void);
+
+DWORD InstallService(TCHAR * Path);
+
+extern TCHAR ServerName[32];
+
+void PrintUsageAndExit( BOOL bListTests );
+long InitializeRegistryForLocal();
+long InitializeRegistryForInproc();
+long InitializeRegistryForCustom();
+long InitializeRegistryForRemote();
+long InitializeRegistryForService();
+
+BOOL Tests();
+
+
diff --git a/private/oleutest/act/client/daytona/makefile b/private/oleutest/act/client/daytona/makefile
new file mode 100644
index 000000000..5acbbd24c
--- /dev/null
+++ b/private/oleutest/act/client/daytona/makefile
@@ -0,0 +1 @@
+!INCLUDE $(NTMAKEENV)\makefile.def
diff --git a/private/oleutest/act/client/daytona/sources b/private/oleutest/act/client/daytona/sources
new file mode 100644
index 000000000..94b616c6a
--- /dev/null
+++ b/private/oleutest/act/client/daytona/sources
@@ -0,0 +1,77 @@
+!IF 0
+
+Copyright (c) 1989 Microsoft Corporation
+
+Module Name:
+
+ sources.
+
+Abstract:
+
+ This file specifies the target component being built and the list of
+ sources files needed to build that component. Also specifies optional
+ compiler switches and libraries that are unique for the component being
+ built.
+
+
+Author:
+
+ Steve Wood (stevewo) 12-Apr-1989
+
+
+Revision History:
+ Modified by Steve Blanding 15-Jan 1996 for DCOM performance tests
+
+!ENDIF
+
+#
+# The TARGETNAME variable is defined by the developer. It is the name of
+# the target (component) that is being built by this makefile. It
+# should NOT include any path or file extension information.
+#
+
+TARGETNAME=actclt
+
+#
+# The TARGETPATH and TARGETTYPE varialbes are defined by the developer.
+# The first specifies where the target is to be build. The second specifies
+# the type of target (either PROGRAM, DYNLINK or LIBRARY)
+#
+
+TARGETPATH=.
+TARGETTYPE=PROGRAM
+
+#
+# The INCLUDES variable specifies any include paths that are specific to
+# this source directory. Separate multiple directory paths with single
+# semicolons. Relative path specifications are okay.
+#
+
+INCLUDES=.
+
+#
+# The SOURCES variable is defined by the developer. It is a list of all the
+# source files for this component. Each source file should be on a separate
+# line using the line continuation character. This will minimize merge
+# conflicts if two developers adding source files to the same component.
+#
+
+SOURCES=\
+ ..\client.cxx \
+ ..\pswrd.cxx \
+ ..\reg.cxx
+
+C_DEFINES=-DUNICODE
+
+LINKLIBS=\
+ $(BASEDIR)\public\sdk\lib\*\kernel32.lib \
+ $(BASEDIR)\public\sdk\lib\*\user32.lib \
+ $(BASEDIR)\public\sdk\lib\*\advapi32.lib \
+ $(BASEDIR)\public\sdk\lib\*\ntdll.lib \
+ $(BASEDIR)\public\sdk\lib\*\ole32.lib \
+ $(BASEDIR)\public\sdk\lib\*\rpcrt4.lib \
+ $(BASEDIR)\public\sdk\lib\*\uuid.lib \
+ $(BASEDIR)\public\sdk\lib\*\mpr.lib \
+ ..\..\common\daytona\*\common.lib
+
+UMTYPE=console
diff --git a/private/oleutest/act/client/dirs b/private/oleutest/act/client/dirs
new file mode 100644
index 000000000..35b6c7372
--- /dev/null
+++ b/private/oleutest/act/client/dirs
@@ -0,0 +1,27 @@
+!IF 0
+
+Copyright (c) 1989 Microsoft Corporation
+
+Module Name:
+
+ dirs.
+
+Abstract:
+
+ This file specifies the subdirectories of the current directory that
+ contain component makefiles.
+
+
+Author:
+
+ Steve Wood (stevewo) 17-Apr-1990
+
+NOTE: Commented description of this file is in \nt\bak\bin\dirs.tpl
+
+!ENDIF
+
+DIRS=
+
+OPTIONAL_DIRS=\
+ daytona \
+
diff --git a/private/oleutest/act/client/pswrd.cxx b/private/oleutest/act/client/pswrd.cxx
new file mode 100644
index 000000000..3dd7f6545
--- /dev/null
+++ b/private/oleutest/act/client/pswrd.cxx
@@ -0,0 +1,58 @@
+extern "C"
+{
+#include <nt.h>
+#include <ntrtl.h>
+#include <nturtl.h>
+#include <ntlsa.h>
+}
+#include <stdarg.h>
+#include <windef.h>
+#include <winbase.h>
+#include <winnls.h>
+#include <stdio.h>
+
+BOOL SetPassword(TCHAR * szCID, TCHAR * pszPw)
+{
+#ifndef CHICO
+ WCHAR * szPw = pszPw;
+ LSA_OBJECT_ATTRIBUTES sObjAttributes;
+ LSA_HANDLE hPolicy;
+ LSA_UNICODE_STRING sKey;
+ LSA_UNICODE_STRING sPassword;
+ WCHAR szKey[256];
+ swprintf(szKey, L"SCM:%s", szCID);
+ sKey.Length = (wcslen(szKey) + 1) * sizeof(WCHAR);
+ sKey.MaximumLength = (wcslen(szKey) + 1) * sizeof(WCHAR);
+ sKey.Buffer = szKey;
+ sPassword.Length = (wcslen(szPw) + 1) * sizeof(WCHAR);
+ sPassword.MaximumLength = 80 * sizeof(WCHAR);
+ sPassword.Buffer = szPw;
+
+ InitializeObjectAttributes(&sObjAttributes, NULL, 0L, NULL, NULL);
+
+ // open the local security policy
+ if (!NT_SUCCESS(
+ LsaOpenPolicy(
+ NULL,
+ &sObjAttributes,
+ POLICY_CREATE_SECRET,
+ &hPolicy)))
+ {
+ printf("LsaOpenPolicy failed with %d\n",GetLastError());
+ return(FALSE);
+ }
+
+ // store private data
+ if (!NT_SUCCESS(
+ LsaStorePrivateData(hPolicy, &sKey, &sPassword)))
+ {
+ printf("LsaStorePrivateData failed with %d\n",GetLastError());
+ return(FALSE);
+ }
+
+ LsaClose(hPolicy);
+#endif
+ return(TRUE);
+}
+
+
diff --git a/private/oleutest/act/client/reg.cxx b/private/oleutest/act/client/reg.cxx
new file mode 100644
index 000000000..2b1639304
--- /dev/null
+++ b/private/oleutest/act/client/reg.cxx
@@ -0,0 +1,867 @@
+//
+// reg.cxx
+//
+
+#include "client.hxx"
+
+BOOL SetPassword(TCHAR * szCID, TCHAR * szPw);
+
+TCHAR * ServiceName = TEXT("ActTestService");
+TCHAR * ServiceDisplayName = TEXT("ActTestService");
+TCHAR * UserName = TEXT("redmond\\oleuser");
+TCHAR * Password = TEXT("stocksplit");
+
+long InitializeRegistryForLocal()
+{
+ SYSTEM_INFO SystemInfo;
+ long RegStatus;
+ ulong Disposition;
+ HKEY hInterface;
+ HKEY hClsidKey;
+ HKEY hActKey;
+ HKEY hActValueKey;
+ TCHAR Path[256];
+
+ //
+ // Get CLASSES_ROOT.
+ //
+ RegStatus = RegOpenKeyEx( HKEY_CLASSES_ROOT,
+ TEXT("CLSID"),
+ 0,
+ KEY_ALL_ACCESS,
+ &hClsidKey );
+
+ if ( RegStatus != ERROR_SUCCESS )
+ return RegStatus;
+
+ //
+ // Local CLSID entries.
+ //
+
+ RegStatus = RegCreateKeyEx(
+ hClsidKey,
+ ClsidActLocalString,
+ 0,
+ TEXT("REG_SZ"),
+ REG_OPTION_NON_VOLATILE,
+ KEY_ALL_ACCESS,
+ NULL,
+ &hActKey,
+ &Disposition );
+
+ if ( RegStatus != ERROR_SUCCESS )
+ return RegStatus;
+
+ RegStatus = RegCreateKeyEx(
+ hActKey,
+ TEXT("LocalServer32"),
+ 0,
+ TEXT("REG_SZ"),
+ REG_OPTION_NON_VOLATILE,
+ KEY_ALL_ACCESS,
+ NULL,
+ &hActValueKey,
+ &Disposition );
+
+ if ( RegStatus != ERROR_SUCCESS )
+ return RegStatus;
+
+ if ( ! GetModuleFileName( 0, Path, sizeof(Path) ) )
+ return RegStatus;
+
+ _tcslwr( Path );
+ _tcscpy( _tcsstr( Path, TEXT("actclt") ), TEXT("actsrv.exe 2") );
+
+ RegStatus = RegSetValueEx(
+ hActValueKey,
+ TEXT(""),
+ 0,
+ REG_SZ,
+ (const BYTE *)Path,
+ (_tcslen(Path) + 1) * sizeof(TCHAR) );
+
+ if ( RegStatus != ERROR_SUCCESS )
+ return RegStatus;
+
+ RegStatus = RegSetValueEx(
+ hClsidKey,
+ TEXT("AppID"),
+ 0,
+ REG_SZ,
+ (const BYTE *) ClsidActLocalString,
+ (_tcslen(ClsidActLocalString)+1)*sizeof(TCHAR));
+
+ if ( RegStatus != ERROR_SUCCESS )
+ return RegStatus;
+
+ RegStatus = SetAppIDSecurity( ClsidActLocalString );
+
+ if ( RegStatus != ERROR_SUCCESS )
+ return RegStatus;
+
+ return ERROR_SUCCESS;
+}
+
+long InitializeRegistryForInproc()
+{
+ SYSTEM_INFO SystemInfo;
+ long RegStatus;
+ ulong Disposition;
+ HKEY hInterface;
+ HKEY hClsidKey;
+ HKEY hActKey;
+ HKEY hActValueKey;
+ TCHAR Path[256];
+
+ //
+ // Get CLASSES_ROOT.
+ //
+ RegStatus = RegOpenKeyEx( HKEY_CLASSES_ROOT,
+ TEXT("CLSID"),
+ 0,
+ KEY_ALL_ACCESS,
+ &hClsidKey );
+
+ if ( RegStatus != ERROR_SUCCESS )
+ return RegStatus;
+
+ //
+ // Local CLSID entries.
+ //
+
+ RegStatus = RegCreateKeyEx(
+ hClsidKey,
+ ClsidActInprocString,
+ 0,
+ TEXT("REG_SZ"),
+ REG_OPTION_NON_VOLATILE,
+ KEY_ALL_ACCESS,
+ NULL,
+ &hActKey,
+ &Disposition );
+
+ if ( RegStatus != ERROR_SUCCESS )
+ return RegStatus;
+
+ // if ( Disposition == REG_OPENED_EXISTING_KEY )
+ // return TRUE;
+
+ RegStatus = RegCreateKeyEx(
+ hActKey,
+ TEXT("InprocServer32"),
+ 0,
+ TEXT("REG_SZ"),
+ REG_OPTION_NON_VOLATILE,
+ KEY_ALL_ACCESS,
+ NULL,
+ &hActValueKey,
+ &Disposition );
+
+ if ( RegStatus != ERROR_SUCCESS )
+ return RegStatus;
+
+ if ( ! GetModuleFileName( 0, Path, sizeof(Path) ) )
+ return RegStatus;
+
+ _tcslwr( Path );
+ _tcscpy( _tcsstr( Path, TEXT("actclt") ), TEXT("actsrvd.dll") );
+
+ RegStatus = RegSetValueEx(
+ hActValueKey,
+ TEXT(""),
+ 0,
+ REG_SZ,
+ (const BYTE *)Path,
+ (_tcslen(Path) + 1) * sizeof(TCHAR) );
+
+ if ( RegStatus != ERROR_SUCCESS )
+ return RegStatus;
+
+ RegStatus = RegSetValueEx(
+ hActValueKey,
+ TEXT("ThreadingModel"),
+ 0,
+ REG_SZ,
+ (const BYTE *)TEXT("Both"),
+ (_tcslen(TEXT("Both")) + 1) * sizeof(TCHAR) );
+
+ if ( RegStatus != ERROR_SUCCESS )
+ return RegStatus;
+
+ return ERROR_SUCCESS;
+}
+
+TCHAR * StringIidIGoober = TEXT("{ffffffff-0000-0000-0000-000000000000}");
+
+long InitializeRegistryForCustom()
+{
+ SYSTEM_INFO SystemInfo;
+ long RegStatus;
+ ulong Disposition;
+ HKEY hInterface;
+ HKEY hClsidKey;
+ HKEY hActKey;
+ HKEY hActValueKey;
+ TCHAR Path[256];
+
+ RegStatus = RegOpenKeyEx( HKEY_CLASSES_ROOT,
+ TEXT("Interface"),
+ 0,
+ KEY_ALL_ACCESS,
+ &hInterface );
+
+ if ( RegStatus != ERROR_SUCCESS )
+ return RegStatus;
+
+ RegStatus = RegCreateKeyEx(
+ hInterface,
+ StringIidIGoober,
+ 0,
+ TEXT("REG_SZ"),
+ REG_OPTION_NON_VOLATILE,
+ KEY_ALL_ACCESS,
+ NULL,
+ &hInterface,
+ &Disposition );
+
+ if ( RegStatus != ERROR_SUCCESS )
+ return RegStatus;
+
+ RegStatus = RegSetValueEx(
+ hInterface,
+ TEXT(""),
+ 0,
+ REG_SZ,
+ (const BYTE *)TEXT("IGoober"),
+ (_tcslen(TEXT("IGoober")) + 1) * sizeof(TCHAR) );
+
+ if ( RegStatus != ERROR_SUCCESS )
+ return RegStatus;
+
+ RegStatus = RegCreateKeyEx(
+ hInterface,
+ TEXT("ProxyStubClsid32"),
+ 0,
+ TEXT("REG_SZ"),
+ REG_OPTION_NON_VOLATILE,
+ KEY_ALL_ACCESS,
+ NULL,
+ &hInterface,
+ &Disposition );
+
+ if ( RegStatus != ERROR_SUCCESS )
+ return RegStatus;
+
+ RegStatus = RegSetValueEx(
+ hInterface,
+ TEXT(""),
+ 0,
+ REG_SZ,
+ (const BYTE *)ClsidGoober32String,
+ (_tcslen(ClsidGoober32String) + 1) * sizeof(TCHAR) );
+
+ if ( RegStatus != ERROR_SUCCESS )
+ return RegStatus;
+
+ RegStatus = RegOpenKeyEx( HKEY_CLASSES_ROOT,
+ TEXT("CLSID"),
+ 0,
+ KEY_ALL_ACCESS,
+ &hClsidKey );
+
+ if ( RegStatus != ERROR_SUCCESS )
+ return RegStatus;
+
+ RegStatus = RegCreateKeyEx(
+ hClsidKey,
+ ClsidGoober32String,
+ 0,
+ TEXT("REG_SZ"),
+ REG_OPTION_NON_VOLATILE,
+ KEY_ALL_ACCESS,
+ NULL,
+ &hActKey,
+ &Disposition );
+
+ if ( RegStatus != ERROR_SUCCESS )
+ return RegStatus;
+
+ // if ( Disposition == REG_OPENED_EXISTING_KEY )
+ // return TRUE;
+
+ RegStatus = RegCreateKeyEx(
+ hActKey,
+ TEXT("InProcServer32"),
+ 0,
+ TEXT("REG_SZ"),
+ REG_OPTION_NON_VOLATILE,
+ KEY_ALL_ACCESS,
+ NULL,
+ &hActValueKey,
+ &Disposition );
+
+ if ( RegStatus != ERROR_SUCCESS )
+ return RegStatus;
+
+ if ( ! GetModuleFileName( 0, Path, sizeof(Path) ) )
+ return RegStatus;
+
+ _tcslwr( Path );
+ _tcscpy( _tcsstr( Path, TEXT("actclt") ), TEXT("goober.dll") );
+
+ RegStatus = RegSetValueEx(
+ hActValueKey,
+ TEXT(""),
+ 0,
+ REG_SZ,
+ (const BYTE *)Path,
+ (_tcslen(Path) + 1) * sizeof(TCHAR) );
+
+ if ( RegStatus != ERROR_SUCCESS )
+ return RegStatus;
+
+ return ERROR_SUCCESS;
+}
+
+long InitializeRegistryForRemote()
+{
+ long RegStatus;
+ ulong Disposition;
+ HKEY hClsidKey;
+ HKEY hAppIDKey;
+ HKEY hThisClsidKey;
+ HKEY hActKey;
+ HKEY hActValueKey;
+ TCHAR Path[256];
+
+ RegStatus = RegOpenKeyEx( HKEY_CLASSES_ROOT,
+ TEXT("CLSID"),
+ 0,
+ KEY_ALL_ACCESS,
+ &hClsidKey );
+
+ if ( RegStatus != ERROR_SUCCESS )
+ return RegStatus;
+
+ //
+ // CLSID_ActRemote
+ //
+
+ RegStatus = RegCreateKeyEx(
+ hClsidKey,
+ ClsidActRemoteString,
+ 0,
+ TEXT("REG_SZ"),
+ REG_OPTION_NON_VOLATILE,
+ KEY_ALL_ACCESS,
+ NULL,
+ &hThisClsidKey,
+ &Disposition );
+
+ if ( RegStatus != ERROR_SUCCESS )
+ return RegStatus;
+
+ RegStatus = RegSetValueEx(
+ hThisClsidKey,
+ TEXT("AppID"),
+ 0,
+ REG_SZ,
+ (const BYTE *) ClsidActRemoteString,
+ (_tcslen(ClsidActRemoteString)+1)*sizeof(TCHAR));
+
+ if ( RegStatus != ERROR_SUCCESS )
+ return RegStatus;
+
+ RegStatus = SetAppIDSecurity( ClsidActRemoteString );
+
+ if ( RegStatus != ERROR_SUCCESS )
+ return RegStatus;
+
+ RegStatus = RegCreateKeyEx(
+ HKEY_CLASSES_ROOT,
+ TEXT("AppID"),
+ 0,
+ TEXT("REG_SZ"),
+ REG_OPTION_NON_VOLATILE,
+ KEY_ALL_ACCESS,
+ NULL,
+ &hAppIDKey,
+ &Disposition );
+
+ if ( RegStatus != ERROR_SUCCESS )
+ return RegStatus;
+
+ RegStatus = RegCreateKeyEx(
+ hAppIDKey,
+ ClsidActRemoteString,
+ 0,
+ TEXT("REG_SZ"),
+ REG_OPTION_NON_VOLATILE,
+ KEY_ALL_ACCESS,
+ NULL,
+ &hActKey,
+ &Disposition );
+
+ if ( RegStatus != ERROR_SUCCESS )
+ return RegStatus;
+
+ if ( *ServerName )
+ RegStatus = RegSetValueEx(
+ hActKey,
+ TEXT("RemoteServerName"),
+ 0,
+ REG_SZ,
+ (const BYTE *)ServerName,
+ (_tcslen(ServerName) + 1) * sizeof(TCHAR) );
+
+ if ( RegStatus != ERROR_SUCCESS )
+ return RegStatus;
+
+ //
+ // CLSID_ActAtStorage
+ //
+
+ RegStatus = RegCreateKeyEx(
+ hClsidKey,
+ ClsidActAtStorageString,
+ 0,
+ TEXT("REG_SZ"),
+ REG_OPTION_NON_VOLATILE,
+ KEY_ALL_ACCESS,
+ NULL,
+ &hThisClsidKey,
+ &Disposition );
+
+ if ( RegStatus != ERROR_SUCCESS )
+ return RegStatus;
+
+ RegStatus = RegSetValueEx(
+ hThisClsidKey,
+ TEXT("AppID"),
+ 0,
+ REG_SZ,
+ (const BYTE *) ClsidActAtStorageString,
+ (_tcslen(ClsidActAtStorageString)+1)*sizeof(TCHAR));
+
+ if ( RegStatus != ERROR_SUCCESS )
+ return RegStatus;
+
+ RegStatus = SetAppIDSecurity( ClsidActAtStorageString );
+
+ if ( RegStatus != ERROR_SUCCESS )
+ return RegStatus;
+
+ RegStatus = RegCreateKeyEx(
+ hAppIDKey,
+ ClsidActAtStorageString,
+ 0,
+ TEXT("REG_SZ"),
+ REG_OPTION_NON_VOLATILE,
+ KEY_ALL_ACCESS,
+ NULL,
+ &hActKey,
+ &Disposition );
+
+ if ( RegStatus != ERROR_SUCCESS )
+ return RegStatus;
+
+ RegStatus = RegSetValueEx(
+ hActKey,
+ TEXT("ActivateAtStorage"),
+ 0,
+ REG_SZ,
+ (const BYTE *)TEXT("Y"),
+ (_tcslen(TEXT("Y")) + 1) * sizeof(TCHAR) );
+
+ if ( RegStatus != ERROR_SUCCESS )
+ return RegStatus;
+
+ //
+ // CLSID_ActRunAsLoggedOnUser
+ //
+
+ RegStatus = RegCreateKeyEx(
+ hClsidKey,
+ ClsidActRunAsLoggedOnString,
+ 0,
+ TEXT("REG_SZ"),
+ REG_OPTION_NON_VOLATILE,
+ KEY_ALL_ACCESS,
+ NULL,
+ &hThisClsidKey,
+ &Disposition );
+
+ if ( RegStatus != ERROR_SUCCESS )
+ return RegStatus;
+
+ RegStatus = SetAppIDSecurity( ClsidActRunAsLoggedOnString );
+
+ if ( RegStatus != ERROR_SUCCESS )
+ return RegStatus;
+
+ RegStatus = RegSetValueEx(
+ hThisClsidKey,
+ TEXT("AppID"),
+ 0,
+ REG_SZ,
+ (const BYTE *) ClsidActRunAsLoggedOnString,
+ (_tcslen(ClsidActRunAsLoggedOnString)+1)*sizeof(TCHAR));
+
+ if ( RegStatus != ERROR_SUCCESS )
+ return RegStatus;
+
+ RegStatus = RegCreateKeyEx(
+ hAppIDKey,
+ ClsidActRunAsLoggedOnString,
+ 0,
+ TEXT("REG_SZ"),
+ REG_OPTION_NON_VOLATILE,
+ KEY_ALL_ACCESS,
+ NULL,
+ &hActKey,
+ &Disposition );
+
+ if ( RegStatus != ERROR_SUCCESS )
+ return RegStatus;
+
+ if ( *ServerName )
+ RegStatus = RegSetValueEx(
+ hActKey,
+ TEXT("RemoteServerName"),
+ 0,
+ REG_SZ,
+ (const BYTE *)ServerName,
+ (_tcslen(ServerName) + 1) * sizeof(TCHAR) );
+
+ if ( RegStatus != ERROR_SUCCESS )
+ return RegStatus;
+
+ RegStatus = RegCreateKeyEx(
+ hThisClsidKey,
+ TEXT("LocalServer32"),
+ 0,
+ TEXT("REG_SZ"),
+ REG_OPTION_NON_VOLATILE,
+ KEY_ALL_ACCESS,
+ NULL,
+ &hActValueKey,
+ &Disposition );
+
+ if ( RegStatus != ERROR_SUCCESS )
+ return RegStatus;
+
+ if ( ! GetModuleFileName( 0, Path, sizeof(Path) ) )
+ return RegStatus;
+
+ _tcslwr( Path );
+ _tcscpy( _tcsstr( Path, TEXT("actclt") ), TEXT("actsrv.exe 7") );
+
+ RegStatus = RegSetValueEx(
+ hActValueKey,
+ TEXT(""),
+ 0,
+ REG_SZ,
+ (const BYTE *)Path,
+ (_tcslen(Path) + 1) * sizeof(TCHAR) );
+
+ RegStatus = RegSetValueEx(
+ hActKey,
+ TEXT("RunAs"),
+ 0,
+ REG_SZ,
+ (const BYTE *)TEXT("Interactive User"),
+ (_tcslen(TEXT("Interactive User")) + 1) * sizeof(TCHAR) );
+
+
+ if ( RegStatus != ERROR_SUCCESS )
+ return RegStatus;
+
+ //
+ // RunAs CLSID entries.
+ //
+
+ RegStatus = RegCreateKeyEx(
+ hClsidKey,
+ ClsidActPreConfigString,
+ 0,
+ TEXT("REG_SZ"),
+ REG_OPTION_NON_VOLATILE,
+ KEY_ALL_ACCESS,
+ NULL,
+ &hThisClsidKey,
+ &Disposition );
+
+ if ( RegStatus != ERROR_SUCCESS )
+ return RegStatus;
+
+ RegStatus = RegSetValueEx(
+ hThisClsidKey,
+ TEXT("AppID"),
+ 0,
+ REG_SZ,
+ (const BYTE *) ClsidActPreConfigString,
+ (_tcslen(ClsidActPreConfigString)+1)*sizeof(TCHAR));
+
+ if ( RegStatus != ERROR_SUCCESS )
+ return RegStatus;
+
+ RegStatus = SetAppIDSecurity( ClsidActPreConfigString );
+
+ if ( RegStatus != ERROR_SUCCESS )
+ return RegStatus;
+
+ RegStatus = RegCreateKeyEx(
+ hAppIDKey,
+ ClsidActPreConfigString,
+ 0,
+ TEXT("REG_SZ"),
+ REG_OPTION_NON_VOLATILE,
+ KEY_ALL_ACCESS,
+ NULL,
+ &hActKey,
+ &Disposition );
+
+ if ( RegStatus != ERROR_SUCCESS )
+ return RegStatus;
+
+ if ( *ServerName )
+ RegStatus = RegSetValueEx(
+ hActKey,
+ TEXT("RemoteServerName"),
+ 0,
+ REG_SZ,
+ (const BYTE *)ServerName,
+ (_tcslen(ServerName) + 1) * sizeof(TCHAR) );
+
+ if ( RegStatus != ERROR_SUCCESS )
+ return RegStatus;
+
+ RegStatus = RegCreateKeyEx(
+ hThisClsidKey,
+ TEXT("LocalServer32"),
+ 0,
+ TEXT("REG_SZ"),
+ REG_OPTION_NON_VOLATILE,
+ KEY_ALL_ACCESS,
+ NULL,
+ &hActValueKey,
+ &Disposition );
+
+ if ( RegStatus != ERROR_SUCCESS )
+ return RegStatus;
+
+ if ( ! GetModuleFileName( 0, Path, sizeof(Path) ) )
+ return RegStatus;
+
+ _tcslwr( Path );
+ _tcscpy( _tcsstr( Path, TEXT("actclt") ), TEXT("actsrv.exe 6") );
+
+ RegStatus = RegSetValueEx(
+ hActValueKey,
+ TEXT(""),
+ 0,
+ REG_SZ,
+ (const BYTE *)Path,
+ (_tcslen(Path) + 1) * sizeof(TCHAR) );
+
+ RegStatus = RegSetValueEx(
+ hActKey,
+ TEXT("RunAs"),
+ 0,
+ REG_SZ,
+ (const BYTE *)UserName,
+ (_tcslen(UserName) + 1) * sizeof(TCHAR) );
+
+
+ if ( RegStatus != ERROR_SUCCESS )
+ return RegStatus;
+
+ if (!SetPassword(ClsidActPreConfigString, Password))
+ return(FALSE);
+
+ if (AddBatchPrivilege( UserName ) )
+ return(FALSE);
+
+ return ERROR_SUCCESS;
+}
+
+long InitializeRegistryForService()
+{
+ long RegStatus;
+ ulong Disposition;
+ HKEY hClsidKey;
+ HKEY hAppIDKey;
+ HKEY hThisClsidKey;
+ HKEY hActKey;
+ HKEY hActValueKey;
+ HKEY hServices;
+ TCHAR Path[256];
+
+ //
+ // Get CLASSES_ROOT.
+ //
+ RegStatus = RegOpenKeyEx( HKEY_CLASSES_ROOT,
+ TEXT("CLSID"),
+ 0,
+ KEY_ALL_ACCESS,
+ &hClsidKey );
+
+ if ( RegStatus != ERROR_SUCCESS )
+ return RegStatus;
+
+ RegStatus = RegCreateKeyEx(
+ HKEY_CLASSES_ROOT,
+ TEXT("AppID"),
+ 0,
+ TEXT("REG_SZ"),
+ REG_OPTION_NON_VOLATILE,
+ KEY_ALL_ACCESS,
+ NULL,
+ &hAppIDKey,
+ &Disposition );
+
+ if ( RegStatus != ERROR_SUCCESS )
+ return RegStatus;
+
+ //
+ // Local CLSID entries.
+ //
+
+ RegStatus = RegCreateKeyEx(
+ hClsidKey,
+ ClsidActServiceString,
+ 0,
+ TEXT("REG_SZ"),
+ REG_OPTION_NON_VOLATILE,
+ KEY_ALL_ACCESS,
+ NULL,
+ &hThisClsidKey,
+ &Disposition );
+
+ if ( RegStatus != ERROR_SUCCESS )
+ return RegStatus;
+
+ RegStatus = SetAppIDSecurity( ClsidActServiceString );
+
+ if ( RegStatus != ERROR_SUCCESS )
+ return RegStatus;
+
+ RegStatus = RegSetValueEx(
+ hThisClsidKey,
+ TEXT("AppID"),
+ 0,
+ REG_SZ,
+ (const BYTE *) ClsidActServiceString,
+ (_tcslen(ClsidActServiceString)+1)*sizeof(TCHAR));
+
+ if ( RegStatus != ERROR_SUCCESS )
+ return RegStatus;
+
+ // if ( Disposition == REG_OPENED_EXISTING_KEY )
+ // return TRUE;
+
+ RegStatus = RegCreateKeyEx(
+ hAppIDKey,
+ ClsidActServiceString,
+ 0,
+ TEXT("REG_SZ"),
+ REG_OPTION_NON_VOLATILE,
+ KEY_ALL_ACCESS,
+ NULL,
+ &hActKey,
+ &Disposition );
+
+ if ( RegStatus != ERROR_SUCCESS )
+ return RegStatus;
+
+ if ( ! GetModuleFileName( 0, Path, sizeof(Path) ) )
+ return RegStatus;
+
+ _tcslwr( Path );
+ _tcscpy( _tcsstr( Path, TEXT("actclt") ), TEXT("actsrv.exe 8") );
+
+ RegStatus = RegSetValueEx(
+ hActKey,
+ TEXT("LocalService"),
+ 0,
+ REG_SZ,
+ (const BYTE *)ServiceName,
+ (_tcslen(ServiceName) + 1) * sizeof(TCHAR) );
+
+ if ( RegStatus != ERROR_SUCCESS )
+ return RegStatus;
+
+ RegStatus = RegSetValueEx(
+ hActKey,
+ TEXT("ActivateAtStorage"),
+ 0,
+ REG_SZ,
+ (const BYTE *)TEXT("Y"),
+ (_tcslen(TEXT("Y")) + 1) * sizeof(TCHAR) );
+
+ if ( RegStatus != ERROR_SUCCESS )
+ return RegStatus;
+
+ RegStatus = RegOpenKeyEx( HKEY_LOCAL_MACHINE,
+ TEXT("SYSTEM\\CurrentControlSet\\Services"),
+ 0,
+ KEY_READ,
+ &hServices );
+
+ if ( RegStatus != ERROR_SUCCESS )
+ return RegStatus;
+
+ return InstallService(Path);
+}
+
+DWORD InstallService( TCHAR * Path )
+{
+#ifndef CHICO
+ SC_HANDLE hManager;
+ SC_HANDLE hService;
+
+ hManager = OpenSCManager( NULL,
+ NULL,
+ SC_MANAGER_ALL_ACCESS );
+
+ if ( ! hManager )
+ {
+ printf( "OpenSCManager returned %d\n", GetLastError() );
+ return GetLastError();
+ }
+
+ hService = OpenService( hManager,
+ ServiceName,
+ SERVICE_ALL_ACCESS );
+
+ if ( ! hService )
+ {
+ hService = CreateService(
+ hManager,
+ ServiceName,
+ ServiceDisplayName,
+ SERVICE_ALL_ACCESS,
+ SERVICE_WIN32_OWN_PROCESS,
+ SERVICE_DEMAND_START,
+ SERVICE_ERROR_NORMAL,
+ Path,
+ NULL,
+ NULL,
+ NULL,
+ NULL,
+ NULL);
+ }
+
+ if ( ! hService )
+ {
+ printf( "CreateService returned %d\n", GetLastError() );
+ CloseServiceHandle(hManager);
+ return GetLastError();
+ }
+
+ CloseServiceHandle(hService);
+ CloseServiceHandle(hManager);
+#endif
+ return ERROR_SUCCESS;
+}
+
diff --git a/private/oleutest/act/common/clsid.c b/private/oleutest/act/common/clsid.c
new file mode 100644
index 000000000..e55978a5f
--- /dev/null
+++ b/private/oleutest/act/common/clsid.c
@@ -0,0 +1,131 @@
+/*
+ * clsid.cxx
+ *
+ * IMPORTANT: Please DO NOT change these CLSIDs. If you need to add
+ * to this list, add new CLSIDs at the END of the list.
+ *
+ * The BVTs depend on these CLSIDs being defined as they are.
+ */
+#ifdef UNICODE
+#define _UNICODE 1
+#endif
+
+#include "windows.h"
+#include "tchar.h"
+
+typedef struct
+ {
+ unsigned long Data1;
+ unsigned short Data2;
+ unsigned short Data3;
+ unsigned char Data4[8];
+ } CLSID;
+
+//
+// This is the CLSID for the custom interface proxy, just to be different.
+//
+CLSID CLSID_GooberProxy = { /* 00000000-0000-0000-0000-000000000001 */
+ 0x00000000,
+ 0x0000,
+ 0x0000,
+ {0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x1}
+ };
+
+//
+// This one gets registered as LocalServer32.
+//
+CLSID CLSID_ActLocal = { /* 00000000-0000-0000-0000-000000000002 */
+ 0x00000000,
+ 0x0000,
+ 0x0000,
+ {0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x2}
+ };
+
+//
+// This one gets registered as LocalServer32 and has a Remote key on the
+// client side.
+//
+CLSID CLSID_ActRemote = { /* 00000000-0000-0000-0000-000000000003 */
+ 0x00000000,
+ 0x0000,
+ 0x0000,
+ {0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x3}
+ };
+
+//
+// This one gets registered as LocalServer32 and has an AtStorage key on the
+// client side.
+//
+CLSID CLSID_ActAtStorage = { /* 00000000-0000-0000-0000-000000000004 */
+ 0x00000000,
+ 0x0000,
+ 0x0000,
+ {0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x4}
+ };
+
+//
+// This one gets registered as InprocServer32.
+//
+CLSID CLSID_ActInproc = { /* 00000000-0000-0000-0000-000000000005 */
+ 0x00000000,
+ 0x0000,
+ 0x0000,
+ {0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x5}
+ };
+
+//
+// This one gets registered as InprocServer32.
+// It has an AtStorage key on the client side.
+// It is configured to run in Pre-Configured user mode on the server side.
+//
+CLSID CLSID_ActPreConfig = { /* 00000000-0000-0000-0000-000000000006 */
+ 0x00000000,
+ 0x0000,
+ 0x0000,
+ {0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x6}
+ };
+
+//
+// Configured with RemoteServerName on client and as
+// RunAs Logged On User on the server.
+//
+CLSID CLSID_ActRunAsLoggedOn = { /* 00000000-0000-0000-0000-000000000007 */
+ 0x00000000,
+ 0x0000,
+ 0x0000,
+ {0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x7}
+ };
+
+//
+// This one gets registered as an AtStorage service.
+//
+CLSID CLSID_ActService = { /* 00000000-0000-0000-0000-000000000008 */
+ 0x00000000,
+ 0x0000,
+ 0x0000,
+ {0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x8}
+ };
+
+//
+// This CLSID is registered only in the server's registry. Tests default
+// ActivateAtStorage on the client.
+//
+CLSID CLSID_ActServerOnly = { /* 00000000-0000-0000-0000-000000000009 */
+ 0x00000000,
+ 0x0000,
+ 0x0000,
+ {0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x9}
+ };
+
+typedef unsigned short wchar_t;
+
+TCHAR * ClsidGoober32String = TEXT("{00000000-0000-0000-0000-000000000001}");
+TCHAR * ClsidActLocalString = TEXT("{00000000-0000-0000-0000-000000000002}");
+TCHAR * ClsidActRemoteString = TEXT("{00000000-0000-0000-0000-000000000003}");
+TCHAR * ClsidActAtStorageString = TEXT("{00000000-0000-0000-0000-000000000004}");
+TCHAR * ClsidActInprocString = TEXT("{00000000-0000-0000-0000-000000000005}");
+TCHAR * ClsidActPreConfigString = TEXT("{00000000-0000-0000-0000-000000000006}");
+TCHAR * ClsidActRunAsLoggedOnString = TEXT("{00000000-0000-0000-0000-000000000007}");
+TCHAR * ClsidActServiceString = TEXT("{00000000-0000-0000-0000-000000000008}");
+TCHAR * ClsidActServerOnlyString = TEXT("{00000000-0000-0000-0000-000000000009}");
+
diff --git a/private/oleutest/act/common/daytona/makefile b/private/oleutest/act/common/daytona/makefile
new file mode 100644
index 000000000..5acbbd24c
--- /dev/null
+++ b/private/oleutest/act/common/daytona/makefile
@@ -0,0 +1 @@
+!INCLUDE $(NTMAKEENV)\makefile.def
diff --git a/private/oleutest/act/common/daytona/sources b/private/oleutest/act/common/daytona/sources
new file mode 100644
index 000000000..df5024241
--- /dev/null
+++ b/private/oleutest/act/common/daytona/sources
@@ -0,0 +1,69 @@
+!IF 0
+
+Copyright (c) 1989 Microsoft Corporation
+
+Module Name:
+
+ sources.
+
+Abstract:
+
+ This file specifies the target component being built and the list of
+ sources files needed to build that component. Also specifies optional
+ compiler switches and libraries that are unique for the component being
+ built.
+
+
+Author:
+
+ Steve Wood (stevewo) 12-Apr-1989
+
+
+Revision History:
+
+!ENDIF
+
+#
+# The TARGETNAME variable is defined by the developer. It is the name of
+# the target (component) that is being built by this makefile. It
+# should NOT include any path or file extension information.
+#
+
+TARGETNAME=common
+
+#
+# The TARGETPATH and TARGETTYPE varialbes are defined by the developer.
+# The first specifies where the target is to be build. The second specifies
+# the type of target (either PROGRAM, DYNLINK or LIBRARY)
+#
+
+TARGETPATH=.
+TARGETTYPE=LIBRARY
+
+#
+# The INCLUDES variable specifies any include paths that are specific to
+# this source directory. Separate multiple directory paths with single
+# semicolons. Relative path specifications are okay.
+#
+
+INCLUDES=.;..;..\..
+
+SYNCHRONIZE_BLOCK=1
+
+#
+# The SOURCES variable is defined by the developer. It is a list of all the
+# source files for this component. Each source file should be on a separate
+# line using the line continuation character. This will minimize merge
+# conflicts if two developers adding source files to the same component.
+#
+
+SOURCES=\
+ ..\clsid.c \
+ ..\reg.c \
+ ..\goober_i.c
+
+C_DEFINES=-DUNICODE
+
+LINKLIBS=
+
+UMTYPE=console
diff --git a/private/oleutest/act/common/dirs b/private/oleutest/act/common/dirs
new file mode 100644
index 000000000..35b6c7372
--- /dev/null
+++ b/private/oleutest/act/common/dirs
@@ -0,0 +1,27 @@
+!IF 0
+
+Copyright (c) 1989 Microsoft Corporation
+
+Module Name:
+
+ dirs.
+
+Abstract:
+
+ This file specifies the subdirectories of the current directory that
+ contain component makefiles.
+
+
+Author:
+
+ Steve Wood (stevewo) 17-Apr-1990
+
+NOTE: Commented description of this file is in \nt\bak\bin\dirs.tpl
+
+!ENDIF
+
+DIRS=
+
+OPTIONAL_DIRS=\
+ daytona \
+
diff --git a/private/oleutest/act/common/reg.c b/private/oleutest/act/common/reg.c
new file mode 100644
index 000000000..1c3ce233d
--- /dev/null
+++ b/private/oleutest/act/common/reg.c
@@ -0,0 +1,250 @@
+//
+// reg.c
+//
+// Common registry manipulation routines.
+//
+
+#ifdef UNICODE
+#define _UNICODE 1
+#endif
+
+#include <windows.h>
+#include <ole2.h>
+#include "acttest.h"
+#include "tchar.h"
+#ifndef CHICO
+#include <subauth.h>
+#include <ntlsa.h>
+#endif
+
+void DeleteSubTree( TCHAR * pszClsid, TCHAR * SubTree )
+{
+ HKEY hClsidRoot;
+ HKEY hClsid;
+ long RegStatus;
+ TCHAR szKeyName[256];
+ DWORD KeyNameSize;
+ FILETIME FileTime;
+ int SubKey;
+
+ RegStatus = RegOpenKeyEx( HKEY_CLASSES_ROOT,
+ SubTree,
+ 0,
+ KEY_ALL_ACCESS,
+ &hClsidRoot );
+
+ if ( RegStatus != ERROR_SUCCESS )
+ return;
+
+ RegStatus = RegOpenKeyEx( hClsidRoot,
+ pszClsid,
+ 0,
+ KEY_ALL_ACCESS,
+ &hClsid );
+
+ if ( RegStatus != ERROR_SUCCESS )
+ return;
+
+ for ( SubKey = 0; ; SubKey++ )
+ {
+ KeyNameSize = sizeof(szKeyName);
+
+ RegStatus = RegEnumKeyEx(
+ hClsid,
+ SubKey,
+ szKeyName,
+ &KeyNameSize,
+ 0,
+ NULL,
+ NULL,
+ &FileTime );
+
+ if ( RegStatus != ERROR_SUCCESS )
+ break;
+
+ RegStatus = RegDeleteKey( hClsid, szKeyName );
+ }
+
+ RegCloseKey( hClsid );
+ RegDeleteKey( hClsidRoot, pszClsid );
+ RegCloseKey( hClsidRoot );
+}
+
+
+void DeleteClsidKey( TCHAR * pwszClsid )
+{
+
+ // Note that we also delete the corresponding AppID entries
+
+ DeleteSubTree( pwszClsid, TEXT("CLSID"));
+ DeleteSubTree( pwszClsid, TEXT("AppID"));
+}
+
+long SetAppIDSecurity( TCHAR * pszAppID )
+{
+ HKEY hActKey;
+ HKEY hAppIDKey;
+ BYTE SecurityDescriptor[2000];
+ LONG RegStatus;
+ SECURITY_INFORMATION SI;
+ DWORD dwSize = sizeof( SecurityDescriptor );
+ DWORD Disposition;
+
+ RegStatus = RegOpenKeyEx( HKEY_CLASSES_ROOT,
+ TEXT("AppID"),
+ 0,
+ KEY_ALL_ACCESS,
+ &hAppIDKey );
+
+ if ( RegStatus != ERROR_SUCCESS )
+ return RegStatus;
+
+ RegStatus = RegCreateKeyEx(
+ hAppIDKey,
+ pszAppID,
+ 0,
+ TEXT("REG_SZ"),
+ REG_OPTION_NON_VOLATILE,
+ KEY_ALL_ACCESS,
+ NULL,
+ &hActKey,
+ &Disposition );
+
+ if ( RegStatus != ERROR_SUCCESS )
+ return RegStatus;
+#ifndef CHICO
+ RegStatus = RegGetKeySecurity( hActKey,
+ OWNER_SECURITY_INFORMATION
+ | GROUP_SECURITY_INFORMATION
+ | DACL_SECURITY_INFORMATION,
+ &SecurityDescriptor,
+ &dwSize );
+
+ if ( RegStatus != ERROR_SUCCESS )
+ return RegStatus;
+#endif
+ RegStatus = RegSetValueEx(
+ hActKey,
+ TEXT("LaunchPermission"),
+ 0,
+ REG_BINARY,
+ SecurityDescriptor,
+ dwSize );
+
+
+ if ( RegStatus != ERROR_SUCCESS )
+ return RegStatus;
+
+ RegStatus = RegSetValueEx(
+ hActKey,
+ TEXT("AccessPermission"),
+ 0,
+ REG_BINARY,
+ SecurityDescriptor,
+ dwSize );
+
+
+ if ( RegStatus != ERROR_SUCCESS )
+ return RegStatus;
+
+ RegCloseKey(hActKey);
+
+ // make the key for the exe
+ RegStatus = RegCreateKeyEx(
+ hAppIDKey,
+ TEXT("ActSrv.Exe"),
+ 0,
+ TEXT("REG_SZ"),
+ REG_OPTION_NON_VOLATILE,
+ KEY_ALL_ACCESS,
+ NULL,
+ &hActKey,
+ &Disposition );
+
+ if ( RegStatus != ERROR_SUCCESS )
+ return RegStatus;
+
+ RegStatus = RegSetValueEx(
+ hActKey,
+ TEXT("AppID"),
+ 0,
+ REG_SZ,
+ (BYTE*) pszAppID,
+ (_tcslen(pszAppID) + 1) * sizeof(TCHAR) );
+
+
+ if ( RegStatus != ERROR_SUCCESS )
+ return RegStatus;
+
+ RegCloseKey(hActKey);
+ RegCloseKey(hAppIDKey);
+
+ return ERROR_SUCCESS;
+}
+
+
+
+int SetAccountRights(const TCHAR *szUser, TCHAR *szPrivilege)
+{
+#ifndef CHICO
+ int err;
+ LSA_HANDLE hPolicy;
+ LSA_OBJECT_ATTRIBUTES objAtt;
+ DWORD cbSid = 1;
+ TCHAR szDomain[128];
+ DWORD cbDomain = 128;
+ PSID pSid = NULL;
+ SID_NAME_USE snu;
+ LSA_UNICODE_STRING privStr;
+
+ // Get a policy handle
+ memset(&objAtt, 0, sizeof(LSA_OBJECT_ATTRIBUTES));
+ if (!NT_SUCCESS(LsaOpenPolicy(NULL,
+ &objAtt,
+ POLICY_CREATE_ACCOUNT | POLICY_LOOKUP_NAMES,
+ &hPolicy)))
+ {
+ return GetLastError();
+ }
+
+ // Fetch the SID for the specified user
+ LookupAccountName(NULL, szUser, pSid, &cbSid, szDomain, &cbDomain, &snu);
+ if ((err = GetLastError()) != ERROR_INSUFFICIENT_BUFFER)
+ {
+ return err;
+ }
+ pSid = (PSID*) malloc(cbSid);
+ if (pSid == NULL)
+ {
+ return ERROR_OUTOFMEMORY;
+ }
+ if (!LookupAccountName(NULL, szUser, pSid, &cbSid,
+ szDomain, &cbDomain, &snu))
+ {
+ return GetLastError();
+ }
+
+ // Set the specified privilege on this account
+ privStr.Length = _tcslen(szPrivilege) * sizeof(WCHAR);
+ privStr.MaximumLength = privStr.Length + sizeof(WCHAR);
+ privStr.Buffer = szPrivilege;
+ if (!NT_SUCCESS(LsaAddAccountRights(hPolicy, pSid, &privStr, 1)))
+ {
+ return GetLastError();
+ }
+
+ // We're done
+ free( pSid );
+ LsaClose(hPolicy);
+#endif
+ return ERROR_SUCCESS;
+}
+
+int AddBatchPrivilege(const TCHAR *szUser)
+{
+#ifndef CHICO
+ return !SetAccountRights( szUser, SE_BATCH_LOGON_NAME );
+#else
+ return(TRUE);
+#endif
+}
diff --git a/private/oleutest/act/dirs b/private/oleutest/act/dirs
new file mode 100644
index 000000000..06124c36d
--- /dev/null
+++ b/private/oleutest/act/dirs
@@ -0,0 +1,29 @@
+!IF 0
+
+Copyright (c) 1989 Microsoft Corporation
+
+Module Name:
+
+ dirs.
+
+Abstract:
+
+ This file specifies the subdirectories of the current directory that
+ contain component makefiles.
+
+
+Author:
+
+ Steve Wood (stevewo) 17-Apr-1990
+
+NOTE: Commented description of this file is in \nt\bak\bin\dirs.tpl
+
+!ENDIF
+
+DIRS=\
+ common \
+ srvcore \
+ dllsrv \
+ client \
+ dll \
+ server
diff --git a/private/oleutest/act/dll/daytona/makefile b/private/oleutest/act/dll/daytona/makefile
new file mode 100644
index 000000000..5acbbd24c
--- /dev/null
+++ b/private/oleutest/act/dll/daytona/makefile
@@ -0,0 +1 @@
+!INCLUDE $(NTMAKEENV)\makefile.def
diff --git a/private/oleutest/act/dll/daytona/sources b/private/oleutest/act/dll/daytona/sources
new file mode 100644
index 000000000..88a3cdb33
--- /dev/null
+++ b/private/oleutest/act/dll/daytona/sources
@@ -0,0 +1,77 @@
+!IF 0
+
+Copyright (c) 1989 Microsoft Corporation
+
+Module Name:
+
+ sources.
+
+Abstract:
+
+ This file specifies the target component being built and the list of
+ sources files needed to build that component. Also specifies optional
+ compiler switches and libraries that are unique for the component being
+ built.
+
+
+Author:
+
+ Steve Wood (stevewo) 12-Apr-1989
+
+
+Revision History:
+
+!ENDIF
+
+#
+# The TARGETNAME variable is defined by the developer. It is the name of
+# the target (component) that is being built by this makefile. It
+# should NOT include any path or file extension information.
+#
+
+TARGETNAME=goober
+
+#
+# The TARGETPATH and TARGETTYPE varialbes are defined by the developer.
+# The first specifies where the target is to be build. The second specifies
+# the type of target (either PROGRAM, DYNLINK or LIBRARY)
+#
+
+TARGETPATH=.
+TARGETTYPE=DYNLINK
+
+#
+# The INCLUDES variable specifies any include paths that are specific to
+# this source directory. Separate multiple directory paths with single
+# semicolons. Relative path specifications are okay.
+#
+
+INCLUDES=.;..
+
+#
+# The SOURCES variable is defined by the developer. It is a list of all the
+# source files for this component. Each source file should be on a separate
+# line using the line continuation character. This will minimize merge
+# conflicts if two developers adding source files to the same component.
+#
+
+SOURCES=\
+ ..\dlldata.c \
+ ..\goober_p.c
+
+C_DEFINES=-DUNICODE -DPROXY_CLSID=CLSID_GooberProxy
+
+DLLDEF=..\goober.def
+
+LINKLIBS=\
+ $(BASEDIR)\public\sdk\lib\*\kernel32.lib \
+ $(BASEDIR)\public\sdk\lib\*\user32.lib \
+ $(BASEDIR)\public\sdk\lib\*\advapi32.lib \
+ $(BASEDIR)\public\sdk\lib\*\ntdll.lib \
+ $(BASEDIR)\public\sdk\lib\*\ole32.lib \
+ $(BASEDIR)\public\sdk\lib\*\rpcrt4.lib \
+ $(BASEDIR)\public\sdk\lib\*\uuid.lib \
+ ..\..\common\daytona\*\common.lib
+
+UMTYPE=console
+DLLBASE=@$(BASEDIR)\PUBLIC\SDK\LIB\coffbase.txt,usermode
diff --git a/private/oleutest/act/dll/dirs b/private/oleutest/act/dll/dirs
new file mode 100644
index 000000000..35b6c7372
--- /dev/null
+++ b/private/oleutest/act/dll/dirs
@@ -0,0 +1,27 @@
+!IF 0
+
+Copyright (c) 1989 Microsoft Corporation
+
+Module Name:
+
+ dirs.
+
+Abstract:
+
+ This file specifies the subdirectories of the current directory that
+ contain component makefiles.
+
+
+Author:
+
+ Steve Wood (stevewo) 17-Apr-1990
+
+NOTE: Commented description of this file is in \nt\bak\bin\dirs.tpl
+
+!ENDIF
+
+DIRS=
+
+OPTIONAL_DIRS=\
+ daytona \
+
diff --git a/private/oleutest/act/dll/goober.def b/private/oleutest/act/dll/goober.def
new file mode 100644
index 000000000..82ae45878
--- /dev/null
+++ b/private/oleutest/act/dll/goober.def
@@ -0,0 +1,8 @@
+
+LIBRARY GOOBER
+
+DESCRIPTION 'Microsoft (R) Example Proxy/Stub DLL 1.00'
+
+EXPORTS
+ DllGetClassObject
+ DllCanUnloadNow
diff --git a/private/oleutest/act/dllsrv/actsrvd.def b/private/oleutest/act/dllsrv/actsrvd.def
new file mode 100644
index 000000000..91bb46d64
--- /dev/null
+++ b/private/oleutest/act/dllsrv/actsrvd.def
@@ -0,0 +1,8 @@
+
+LIBRARY ActsrvD
+
+DESCRIPTION 'Microsoft (R) Example Proxy/Stub DLL 1.00'
+
+EXPORTS
+ DllGetClassObject
+ DllCanUnloadNow
diff --git a/private/oleutest/act/dllsrv/daytona/makefile b/private/oleutest/act/dllsrv/daytona/makefile
new file mode 100644
index 000000000..5acbbd24c
--- /dev/null
+++ b/private/oleutest/act/dllsrv/daytona/makefile
@@ -0,0 +1 @@
+!INCLUDE $(NTMAKEENV)\makefile.def
diff --git a/private/oleutest/act/dllsrv/daytona/sources b/private/oleutest/act/dllsrv/daytona/sources
new file mode 100644
index 000000000..b1e1259c7
--- /dev/null
+++ b/private/oleutest/act/dllsrv/daytona/sources
@@ -0,0 +1,79 @@
+!IF 0
+
+Copyright (c) 1989 Microsoft Corporation
+
+Module Name:
+
+ sources.
+
+Abstract:
+
+ This file specifies the target component being built and the list of
+ sources files needed to build that component. Also specifies optional
+ compiler switches and libraries that are unique for the component being
+ built.
+
+
+Author:
+
+ Steve Wood (stevewo) 12-Apr-1989
+
+
+Revision History:
+
+!ENDIF
+
+#
+# The TARGETNAME variable is defined by the developer. It is the name of
+# the target (component) that is being built by this makefile. It
+# should NOT include any path or file extension information.
+#
+
+TARGETNAME=ActSrvD
+
+#
+# The TARGETPATH and TARGETTYPE varialbes are defined by the developer.
+# The first specifies where the target is to be build. The second specifies
+# the type of target (either PROGRAM, DYNLINK or LIBRARY)
+#
+
+TARGETPATH=.
+TARGETTYPE=DYNLINK
+USE_CRTDLL=1
+
+#
+# The INCLUDES variable specifies any include paths that are specific to
+# this source directory. Separate multiple directory paths with single
+# semicolons. Relative path specifications are okay.
+#
+
+INCLUDES=.;..;..\..\srvcore;..\..\server
+
+#
+# The SOURCES variable is defined by the developer. It is a list of all the
+# source files for this component. Each source file should be on a separate
+# line using the line continuation character. This will minimize merge
+# conflicts if two developers adding source files to the same component.
+#
+
+C_DEFINES=-DUNICODE
+
+SOURCES=\
+ ..\DllGCO.cxx
+
+
+DLLDEF=..\ActSrvD.def
+
+LINKLIBS=\
+ ..\..\srvcore\daytona\obj\*\srvcore.lib \
+ $(BASEDIR)\public\sdk\lib\*\kernel32.lib \
+ $(BASEDIR)\public\sdk\lib\*\user32.lib \
+ $(BASEDIR)\public\sdk\lib\*\advapi32.lib \
+ $(BASEDIR)\public\sdk\lib\*\ntdll.lib \
+ $(BASEDIR)\public\sdk\lib\*\ole32.lib \
+ $(BASEDIR)\public\sdk\lib\*\rpcrt4.lib \
+ $(BASEDIR)\public\sdk\lib\*\uuid.lib \
+ ..\..\common\daytona\*\common.lib
+
+UMTYPE = windows
+DLLBASE=@$(BASEDIR)\PUBLIC\SDK\LIB\coffbase.txt,usermode
diff --git a/private/oleutest/act/dllsrv/dirs b/private/oleutest/act/dllsrv/dirs
new file mode 100644
index 000000000..35b6c7372
--- /dev/null
+++ b/private/oleutest/act/dllsrv/dirs
@@ -0,0 +1,27 @@
+!IF 0
+
+Copyright (c) 1989 Microsoft Corporation
+
+Module Name:
+
+ dirs.
+
+Abstract:
+
+ This file specifies the subdirectories of the current directory that
+ contain component makefiles.
+
+
+Author:
+
+ Steve Wood (stevewo) 17-Apr-1990
+
+NOTE: Commented description of this file is in \nt\bak\bin\dirs.tpl
+
+!ENDIF
+
+DIRS=
+
+OPTIONAL_DIRS=\
+ daytona \
+
diff --git a/private/oleutest/act/dllsrv/dllgco.cxx b/private/oleutest/act/dllsrv/dllgco.cxx
new file mode 100644
index 000000000..2ccf23160
--- /dev/null
+++ b/private/oleutest/act/dllsrv/dllgco.cxx
@@ -0,0 +1,37 @@
+/*
+ * DllGCO.cxx
+ * - DllGetClassObject implementation for inproc DLL
+ */
+
+
+#include "server.hxx"
+#include "factory.hxx"
+
+HANDLE hStopServiceEvent;
+BOOL fStartedAsService = FALSE;
+
+long ObjectCount = 0;
+
+STDAPI DllGetClassObject(REFCLSID rclsid, REFIID riid, LPVOID FAR* ppv)
+{
+ HRESULT hr = E_NOINTERFACE;
+
+ *ppv = NULL;
+
+ MyFactory * pClass = new FactoryInproc();
+
+ hr = pClass->QueryInterface( riid, ppv );
+
+ return hr;
+}
+
+
+STDAPI DllCanUnloadNow(void)
+{
+return S_FALSE;
+}
+
+void ShutDown()
+{
+}
+
diff --git a/private/oleutest/act/dllsrv/goober.def b/private/oleutest/act/dllsrv/goober.def
new file mode 100644
index 000000000..82ae45878
--- /dev/null
+++ b/private/oleutest/act/dllsrv/goober.def
@@ -0,0 +1,8 @@
+
+LIBRARY GOOBER
+
+DESCRIPTION 'Microsoft (R) Example Proxy/Stub DLL 1.00'
+
+EXPORTS
+ DllGetClassObject
+ DllCanUnloadNow
diff --git a/private/oleutest/act/goober.idl b/private/oleutest/act/goober.idl
new file mode 100644
index 000000000..d273b1180
--- /dev/null
+++ b/private/oleutest/act/goober.idl
@@ -0,0 +1,17 @@
+//
+// goober.idl
+//
+
+[
+ uuid(ffffffff-0000-0000-0000-000000000000),
+ version(0.0),
+ pointer_default(unique),
+ object
+]
+interface IGoober : IUnknown
+{
+ import "unknwn.idl";
+
+ HRESULT Ping();
+}
+ \ No newline at end of file
diff --git a/private/oleutest/act/makefil0 b/private/oleutest/act/makefil0
new file mode 100644
index 000000000..48e5b10ab
--- /dev/null
+++ b/private/oleutest/act/makefil0
@@ -0,0 +1,21 @@
+#
+#
+#
+
+MIDL_FLAGS=-Oi -oldnames -I\nt\public\sdk\inc
+
+all: dll\goober.h
+
+dll\goober.h: goober.idl
+ midl $(MIDL_FLAGS) \
+ -proxy dll/goober_p.c \
+ -dlldata dll/dlldata.c \
+ -header dll/goober.h \
+ -iid common/goober_i.c \
+ goober.idl
+
+clean: sweep all
+
+sweep:
+ del dll\goober.h
+
diff --git a/private/oleutest/act/server/daytona/makefile b/private/oleutest/act/server/daytona/makefile
new file mode 100644
index 000000000..5acbbd24c
--- /dev/null
+++ b/private/oleutest/act/server/daytona/makefile
@@ -0,0 +1 @@
+!INCLUDE $(NTMAKEENV)\makefile.def
diff --git a/private/oleutest/act/server/daytona/sources b/private/oleutest/act/server/daytona/sources
new file mode 100644
index 000000000..05467a74c
--- /dev/null
+++ b/private/oleutest/act/server/daytona/sources
@@ -0,0 +1,78 @@
+!IF 0
+
+Copyright (c) 1989 Microsoft Corporation
+
+Module Name:
+
+ sources.
+
+Abstract:
+
+ This file specifies the target component being built and the list of
+ sources files needed to build that component. Also specifies optional
+ compiler switches and libraries that are unique for the component being
+ built.
+
+
+Author:
+
+ Steve Wood (stevewo) 12-Apr-1989
+
+
+Revision History:
+
+!ENDIF
+
+#
+# The TARGETNAME variable is defined by the developer. It is the name of
+# the target (component) that is being built by this makefile. It
+# should NOT include any path or file extension information.
+#
+
+TARGETNAME=actsrv
+
+#
+# The TARGETPATH and TARGETTYPE varialbes are defined by the developer.
+# The first specifies where the target is to be build. The second specifies
+# the type of target (either PROGRAM, DYNLINK or LIBRARY)
+#
+
+TARGETPATH=.
+TARGETTYPE=PROGRAM
+
+USE_CRTDLL=1
+
+#
+# The INCLUDES variable specifies any include paths that are specific to
+# this source directory. Separate multiple directory paths with single
+# semicolons. Relative path specifications are okay.
+#
+
+INCLUDES=.;..\..\srvcore
+
+#
+# The SOURCES variable is defined by the developer. It is a list of all the
+# source files for this component. Each source file should be on a separate
+# line using the line continuation character. This will minimize merge
+# conflicts if two developers adding source files to the same component.
+#
+
+SOURCES=\
+ ..\server.cxx \
+ ..\pswrd.cxx
+
+
+C_DEFINES=-DUNICODE
+
+LINKLIBS=\
+ ..\..\srvcore\daytona\obj\*\srvcore.lib \
+ $(BASEDIR)\public\sdk\lib\*\kernel32.lib \
+ $(BASEDIR)\public\sdk\lib\*\user32.lib \
+ $(BASEDIR)\public\sdk\lib\*\advapi32.lib \
+ $(BASEDIR)\public\sdk\lib\*\ntdll.lib \
+ $(BASEDIR)\public\sdk\lib\*\ole32.lib \
+ $(BASEDIR)\public\sdk\lib\*\rpcrt4.lib \
+ $(BASEDIR)\public\sdk\lib\*\uuid.lib \
+ ..\..\common\daytona\*\common.lib
+
+UMTYPE=console
diff --git a/private/oleutest/act/server/dirs b/private/oleutest/act/server/dirs
new file mode 100644
index 000000000..35b6c7372
--- /dev/null
+++ b/private/oleutest/act/server/dirs
@@ -0,0 +1,27 @@
+!IF 0
+
+Copyright (c) 1989 Microsoft Corporation
+
+Module Name:
+
+ dirs.
+
+Abstract:
+
+ This file specifies the subdirectories of the current directory that
+ contain component makefiles.
+
+
+Author:
+
+ Steve Wood (stevewo) 17-Apr-1990
+
+NOTE: Commented description of this file is in \nt\bak\bin\dirs.tpl
+
+!ENDIF
+
+DIRS=
+
+OPTIONAL_DIRS=\
+ daytona \
+
diff --git a/private/oleutest/act/server/pswrd.cxx b/private/oleutest/act/server/pswrd.cxx
new file mode 100644
index 000000000..3b9d3cc79
--- /dev/null
+++ b/private/oleutest/act/server/pswrd.cxx
@@ -0,0 +1,66 @@
+extern "C"
+{
+#include <nt.h>
+#include <ntrtl.h>
+#include <nturtl.h>
+#include <ntlsa.h>
+}
+#include <stdarg.h>
+#include <windef.h>
+#include <winbase.h>
+#include <winnls.h>
+#include <stdio.h>
+
+BOOL SetPassword(TCHAR * szCID, TCHAR * pszPw)
+{
+#ifndef CHICO
+ WCHAR * szPw = pszPw;
+ LSA_OBJECT_ATTRIBUTES sObjAttributes;
+ LSA_HANDLE hPolicy;
+ LSA_UNICODE_STRING sKey;
+ LSA_UNICODE_STRING sPassword;
+ WCHAR szKey[256];
+ swprintf(szKey, L"SCM:%s", szCID);
+ sKey.Length = (wcslen(szKey) + 1) * sizeof(WCHAR);
+ sKey.MaximumLength = (wcslen(szKey) + 1) * sizeof(WCHAR);
+ sKey.Buffer = szKey;
+ sPassword.Length = (wcslen(szPw) + 1) * sizeof(WCHAR);
+ sPassword.MaximumLength = 80 * sizeof(WCHAR);
+ sPassword.Buffer = szPw;
+
+ InitializeObjectAttributes(&sObjAttributes, NULL, 0L, NULL, NULL);
+
+ // open the local security policy
+ if (!NT_SUCCESS(
+ LsaOpenPolicy(
+ NULL,
+ &sObjAttributes,
+ POLICY_CREATE_SECRET,
+ &hPolicy)))
+ {
+ printf("LsaOpenPolicy failed with %d\n",GetLastError());
+ return(FALSE);
+ }
+
+ // store private data
+ if (!NT_SUCCESS(
+ LsaStorePrivateData(hPolicy, &sKey, &sPassword)))
+ {
+ printf("LsaStorePrivateData failed with %d\n",GetLastError());
+ return(FALSE);
+ }
+
+ LsaClose(hPolicy);
+#else
+ WCHAR szPw[256];
+ MultiByteToWideChar( CP_ACP,
+ 0,
+ pszPw,
+ -1,
+ szPw,
+ sizeof(szPw) / sizeof(WCHAR) );
+#endif
+ return(TRUE);
+}
+
+
diff --git a/private/oleutest/act/server/server.cxx b/private/oleutest/act/server/server.cxx
new file mode 100644
index 000000000..7b400bc7d
--- /dev/null
+++ b/private/oleutest/act/server/server.cxx
@@ -0,0 +1,1033 @@
+/*
+ * server.cxx
+ */
+
+#ifdef UNICODE
+#define _UNICODE 1
+#endif
+
+#include "server.hxx"
+#include "factory.hxx"
+#include "tchar.h"
+
+long ObjectCount = 0;
+
+TCHAR * AtStorageFileName = TEXT("c:\\tmp\\atbits.dat");
+
+TCHAR * UserName = TEXT("redmond\\oleuser");
+TCHAR * Password = TEXT("stocksplit");
+TCHAR * ServiceName = TEXT("ActTestService");
+TCHAR * ServiceDisplayName = TEXT("ActTestService");
+BOOL fStartedAsService = FALSE;
+HANDLE hStopServiceEvent;
+SERVICE_STATUS SStatus;
+SERVICE_STATUS_HANDLE hService;
+BOOL InstallService(TCHAR * );
+
+HKEY ghClsidRootKey = 0;
+HKEY ghAppIDRootKey = 0;
+
+DWORD RegHandleLocal;
+DWORD RegHandleRemote;
+DWORD RegHandleAtStorage;
+DWORD RegHandlePreConfig;
+DWORD RegHandleRunAsLoggedOn;
+DWORD RegHandleService;
+DWORD RegHandleServerOnly;
+unsigned uClassIndex = 0;
+
+//+---------------------------------------------------------------------------
+//
+// Function: main
+//
+// Synopsis: main entry point for SCM
+//
+// History: 1-18-96 stevebl Created
+//
+//----------------------------------------------------------------------------
+void _cdecl RealMain( int argc, char ** argv )
+{
+ HRESULT hr;
+ MSG msg;
+
+ if ( (argc > 1) &&
+ ((strcmp(argv[1],"-?") == 0) || (strcmp(argv[1],"/?") == 0)) )
+ PrintUsageAndExit();
+
+ if ( (argc > 1) && (strcmp(argv[1],"-r") == 0) )
+ {
+ DebuggerType eDebug = same_debugger;
+ int n;
+
+ n = 2;
+
+ if ( n < argc )
+ {
+ if (strcmp(argv[n],"-d") == 0)
+ eDebug = windbg_debugger;
+ else if (strcmp(argv[n],"-n") == 0 )
+ eDebug = ntsd_debugger;
+ else if (strcmp(argv[n],"-x") == 0 )
+ eDebug = clear_debugger;
+ }
+
+ if ( hr = InitializeRegistry( eDebug ) )
+ printf("InitializeRegistry failed with %08x\n", hr);
+ else
+ printf("Registry updated successfully.\n");
+
+ return;
+ }
+
+ // Started manually. Don't go away.
+ if ( (argc == 1) && ! fStartedAsService )
+ ObjectCount = 1;
+
+ if ( ! fStartedAsService )
+ {
+ if ( (argc >= 3 && strcmp(argv[2], "-Embedding") == 0) )
+ uClassIndex = argv[1][0] - '0';
+ else
+ uClassIndex = 0;
+ }
+
+ if ( fStartedAsService )
+ {
+ uClassIndex = 8;
+
+#ifdef NT351
+ hr = E_FAIL;
+#else
+ hr = CoInitializeEx(NULL, COINIT_MULTITHREADED);
+#endif
+ }
+ else
+ {
+ hr = CoInitialize(NULL);
+ }
+
+ if ( FAILED(hr) )
+ {
+ printf( "Server: CoInitialize failed(%x)\n", hr );
+ return;
+ }
+
+ if (0 == uClassIndex || 2 == uClassIndex)
+ {
+ hr = CoRegisterClassObject( CLSID_ActLocal,
+ (IUnknown *)new FactoryLocal(),
+ CLSCTX_LOCAL_SERVER,
+ REGCLS_MULTIPLEUSE,
+ &RegHandleLocal );
+
+ if ( FAILED(hr) )
+ {
+ printf("Server: CoRegisterClassObject failed %x\n", hr);
+ CoUninitialize();
+ return;
+ }
+ }
+
+ if (0 == uClassIndex || 3 == uClassIndex)
+ {
+ hr = CoRegisterClassObject( CLSID_ActRemote,
+ (IUnknown *)new FactoryRemote(),
+ CLSCTX_LOCAL_SERVER,
+ REGCLS_MULTIPLEUSE,
+ &RegHandleRemote );
+
+ if ( FAILED(hr) )
+ {
+ printf("Server: CoRegisterClassObject failed %x\n", hr);
+ if (0 == uClassIndex)
+ {
+ CoRevokeClassObject( RegHandleLocal );
+ }
+ CoUninitialize();
+ return;
+ }
+ }
+
+ if (0 == uClassIndex || 4 == uClassIndex)
+ {
+ hr = CoRegisterClassObject( CLSID_ActAtStorage,
+ (IUnknown *)new FactoryAtStorage(),
+ CLSCTX_LOCAL_SERVER,
+ REGCLS_MULTIPLEUSE,
+ &RegHandleAtStorage );
+
+ if ( FAILED(hr) )
+ {
+ printf("Server: CoRegisterClassObject failed %x\n", hr);
+ if (0 == uClassIndex)
+ {
+ CoRevokeClassObject( RegHandleLocal );
+ CoRevokeClassObject( RegHandleRemote );
+ }
+ CoUninitialize();
+ return;
+ }
+ }
+
+ if (0 == uClassIndex || 6 == uClassIndex)
+ {
+ hr = CoRegisterClassObject( CLSID_ActPreConfig,
+ (IUnknown *)new FactoryAtStorage(),
+ CLSCTX_LOCAL_SERVER,
+ REGCLS_MULTIPLEUSE,
+ &RegHandlePreConfig );
+
+ if ( FAILED(hr) )
+ {
+ printf("Server: CoRegisterClassObject failed %x\n", hr);
+ if (0 == uClassIndex)
+ {
+ CoRevokeClassObject( RegHandleLocal );
+ CoRevokeClassObject( RegHandleRemote );
+ CoRevokeClassObject( RegHandleAtStorage );
+ }
+ CoUninitialize();
+ return;
+ }
+ }
+
+ if (0 == uClassIndex || 7 == uClassIndex)
+ {
+ hr = CoRegisterClassObject( CLSID_ActRunAsLoggedOn,
+ (IUnknown *)new FactoryAtStorage(),
+ CLSCTX_LOCAL_SERVER,
+ REGCLS_MULTIPLEUSE,
+ &RegHandleRunAsLoggedOn );
+
+ if ( FAILED(hr) )
+ {
+ printf("Server: CoRegisterClassObject failed %x\n", hr);
+ if (0 == uClassIndex)
+ {
+ CoRevokeClassObject( RegHandleLocal );
+ CoRevokeClassObject( RegHandleRemote );
+ CoRevokeClassObject( RegHandleAtStorage );
+ CoRevokeClassObject( RegHandlePreConfig );
+ }
+ CoUninitialize();
+ return;
+ }
+ }
+
+ if (0 == uClassIndex || 9 == uClassIndex)
+ {
+ hr = CoRegisterClassObject( CLSID_ActServerOnly,
+ (IUnknown *)new FactoryAtStorage(),
+ CLSCTX_LOCAL_SERVER,
+ REGCLS_MULTIPLEUSE,
+ &RegHandleServerOnly );
+
+ if ( FAILED(hr) )
+ {
+ printf("Server: CoRegisterClassObject failed %x\n", hr);
+ if (0 == uClassIndex)
+ {
+ CoRevokeClassObject( RegHandleLocal );
+ CoRevokeClassObject( RegHandleRemote );
+ CoRevokeClassObject( RegHandleAtStorage );
+ CoRevokeClassObject( RegHandlePreConfig );
+ CoRevokeClassObject( RegHandleRunAsLoggedOn );
+ }
+ CoUninitialize();
+ return;
+ }
+ }
+
+ if (fStartedAsService)
+ {
+ hr = CoRegisterClassObject( CLSID_ActService,
+ (IUnknown *)new FactoryAtStorage(),
+ CLSCTX_LOCAL_SERVER,
+ REGCLS_MULTIPLEUSE,
+ &RegHandleService );
+
+ if ( FAILED(hr) )
+ {
+ CoUninitialize();
+ return;
+ }
+
+ WaitForSingleObject(hStopServiceEvent, INFINITE);
+ }
+ else
+ {
+ // only do message loop if not a service
+ while (GetMessage(&msg, NULL, 0, 0))
+ {
+ TranslateMessage(&msg);
+ DispatchMessage(&msg);
+ }
+ }
+
+ CoUninitialize();
+
+ return;
+}
+
+int gargc;
+char * gargv[100];
+
+BOOL UpdateStatus(DWORD dwState)
+{
+ if (SERVICE_RUNNING == SStatus.dwCurrentState &&
+ SERVICE_START_PENDING == dwState)
+ {
+ return(TRUE);
+ }
+
+ SStatus.dwCurrentState = dwState;
+ if (SERVICE_START_PENDING == dwState ||
+ SERVICE_STOP_PENDING == dwState)
+ {
+ SStatus.dwCheckPoint++;
+ SStatus.dwWaitHint = 1;
+ }
+ else
+ {
+ SStatus.dwCheckPoint = 0;
+ SStatus.dwWaitHint = 0;
+ }
+
+ return(SetServiceStatus(hService, &SStatus));
+}
+
+DWORD StartMyMain(void * pArg)
+{
+ // reconstruct the command line args and call the real main
+ RealMain(gargc, gargv);
+ UpdateStatus(SERVICE_STOPPED);
+ return(0);
+}
+
+void Handler(DWORD fdwControl)
+{
+ switch (fdwControl)
+ {
+ case SERVICE_CONTROL_STOP:
+ UpdateStatus(SERVICE_STOP_PENDING);
+ SetEvent(hStopServiceEvent);
+ break;
+ case SERVICE_CONTROL_INTERROGATE:
+ UpdateStatus(SERVICE_RUNNING);
+ break;
+ default:
+ break;
+ }
+}
+
+//+---------------------------------------------------------------------------
+//
+// Function: ServiceMain
+//
+// Synopsis: main entry point for service
+//
+// History: 1-18-96 stevebl Created
+//
+//----------------------------------------------------------------------------
+
+void ServiceMain(DWORD argc, LPTSTR * argv)
+{
+ fStartedAsService = TRUE;
+
+ // register the service handler
+ hService = RegisterServiceCtrlHandler(ServiceName, Handler);
+
+ if (!hService)
+ return;
+
+ SStatus.dwServiceType = SERVICE_WIN32_OWN_PROCESS |
+ SERVICE_INTERACTIVE_PROCESS,
+ SStatus.dwControlsAccepted = SERVICE_CONTROL_STOP |
+ SERVICE_CONTROL_INTERROGATE;
+ SStatus.dwWin32ExitCode = NO_ERROR;
+ SStatus.dwServiceSpecificExitCode = 0;
+ SStatus.dwCheckPoint = 0;
+ SStatus.dwWaitHint = 0;
+
+ if (!UpdateStatus(SERVICE_START_PENDING))
+ return;
+
+ // create an event to signal when the service is to stop
+ hStopServiceEvent = CreateEvent(NULL, FALSE, FALSE, NULL);
+ if (!hStopServiceEvent)
+ {
+ return;
+ }
+
+ UpdateStatus(SERVICE_RUNNING);
+
+ StartMyMain( NULL );
+}
+
+void _cdecl main( int argc, char ** argv)
+{
+ if (argc > 1 && strcmp(argv[1], "8") == 0)
+ {
+ gargc = argc;
+
+ // save the command line arguments
+ gargc = (int) argc;
+ if (gargc > 100)
+ {
+ gargc = 100;
+ }
+ for (int k = 1; k <= gargc; k++)
+ {
+ gargv[k-1] = (char *) malloc(strlen(argv[k-1]) + 1);
+ strcpy(gargv[k-1], argv[k-1]);
+ }
+
+ // Start as a service
+ SERVICE_TABLE_ENTRY ServiceStart[2];
+ ServiceStart[0].lpServiceName = ServiceName;
+ ServiceStart[0].lpServiceProc = ServiceMain;
+ ServiceStart[1].lpServiceName = NULL;
+ ServiceStart[1].lpServiceProc = NULL;
+
+ if (!StartServiceCtrlDispatcher (ServiceStart))
+ {
+ ExitProcess(GetLastError());
+ }
+ ExitProcess(0);
+ }
+ else
+ {
+ // start as a regular app
+ RealMain(argc, argv);
+ }
+}
+
+
+long InitializeRegistry( DebuggerType eDebugServer )
+{
+ long RegStatus;
+ ulong Disposition;
+ HKEY hActKey;
+ HKEY hDebugKey;
+ HANDLE hFile;
+ TCHAR Path[256];
+ TCHAR * pwszServerExe;
+ TCHAR * pwszDebuggerName;
+ DWORD DebugFlags;
+
+ if ( ! GetModuleFileName( 0, Path, sizeof(Path) ) )
+ return ERROR_BAD_PATHNAME;
+
+ hFile = CreateFile( AtStorageFileName,
+ GENERIC_WRITE,
+ 0,
+ NULL,
+ CREATE_ALWAYS,
+ 0,
+ 0 );
+
+ if ( hFile == INVALID_HANDLE_VALUE )
+ {
+ printf("Couldn't create file %ws\n", AtStorageFileName );
+ return GetLastError();
+ }
+
+ CloseHandle( hFile );
+
+ RegStatus = RegOpenKeyEx( HKEY_CLASSES_ROOT,
+ TEXT("CLSID"),
+ 0,
+ KEY_ALL_ACCESS,
+ &ghClsidRootKey );
+
+ if ( RegStatus != ERROR_SUCCESS )
+ return RegStatus;
+
+ RegStatus = RegOpenKeyEx( HKEY_CLASSES_ROOT,
+ TEXT("APPID"),
+ 0,
+ KEY_ALL_ACCESS,
+ &ghAppIDRootKey );
+
+ if ( RegStatus != ERROR_SUCCESS )
+ return RegStatus;
+
+ DeleteClsidKey( ClsidGoober32String );
+ DeleteClsidKey( ClsidActLocalString );
+ DeleteClsidKey( ClsidActRemoteString );
+ DeleteClsidKey( ClsidActAtStorageString );
+ DeleteClsidKey( ClsidActInprocString );
+ DeleteClsidKey( ClsidActPreConfigString );
+ DeleteClsidKey( ClsidActRunAsLoggedOnString );
+ DeleteClsidKey( ClsidActServiceString );
+ DeleteClsidKey( ClsidActServerOnlyString );
+
+ //
+ // Local CLSID entries.
+ //
+
+ _tcscat(Path, TEXT(" 2"));
+
+ RegStatus = SetClsidRegKeyAndStringValue(
+ ClsidActLocalString,
+ TEXT("LocalServer32"),
+ Path,
+ NULL,
+ NULL );
+
+ if ( RegStatus != ERROR_SUCCESS )
+ return RegStatus;
+
+ RegStatus = SetAppIDSecurity( ClsidActLocalString );
+
+ if ( RegStatus != ERROR_SUCCESS )
+ return RegStatus;
+
+ //
+ // Remote CLSID entries.
+ //
+
+ Path[_tcslen(Path)-1] = TEXT('3');
+
+ RegStatus = SetClsidRegKeyAndStringValue(
+ ClsidActRemoteString,
+ TEXT("LocalServer32"),
+ Path,
+ NULL,
+ NULL );
+
+ if ( RegStatus != ERROR_SUCCESS )
+ return RegStatus;
+
+ RegStatus = SetAppIDSecurity( ClsidActRemoteString );
+
+ if ( RegStatus != ERROR_SUCCESS )
+ return RegStatus;
+
+ //
+ // AtStorage CLSID entries.
+ //
+
+ Path[_tcslen(Path)-1] = TEXT('4');
+
+ RegStatus = SetClsidRegKeyAndStringValue(
+ ClsidActAtStorageString,
+ TEXT("LocalServer32"),
+ Path,
+ NULL,
+ NULL );
+
+ if ( RegStatus != ERROR_SUCCESS )
+ return RegStatus;
+
+ RegStatus = SetAppIDSecurity( ClsidActAtStorageString );
+
+ if ( RegStatus != ERROR_SUCCESS )
+ return RegStatus;
+
+ //
+ // RunAs CLSID entries.'
+ //
+
+ Path[_tcslen(Path)-1] = TEXT('6');
+
+ RegStatus = SetClsidRegKeyAndStringValue(
+ ClsidActPreConfigString,
+ TEXT("LocalServer32"),
+ Path,
+ NULL,
+ NULL );
+
+ if ( RegStatus != ERROR_SUCCESS )
+ return RegStatus;
+
+ RegStatus = SetAppIDRegKeyAndNamedValue(
+ ClsidActPreConfigString,
+ TEXT("RunAs"),
+ UserName,
+ NULL );
+
+ if ( RegStatus != ERROR_SUCCESS )
+ return RegStatus;
+
+
+ RegStatus = SetAppIDSecurity( ClsidActPreConfigString );
+
+ if ( RegStatus != ERROR_SUCCESS )
+ return RegStatus;
+
+ if (!SetPassword(ClsidActPreConfigString, Password))
+ return(FALSE);
+
+ if (!AddBatchPrivilege( UserName ) )
+ return(FALSE);
+
+ //
+ // RunAs logged on user CLSID entries.
+ //
+
+ Path[_tcslen(Path)-1] = TEXT('7');
+
+ RegStatus = SetClsidRegKeyAndStringValue(
+ ClsidActRunAsLoggedOnString,
+ TEXT("LocalServer32"),
+ Path,
+ NULL,
+ NULL );
+
+ if ( RegStatus != ERROR_SUCCESS )
+ return RegStatus;
+
+ RegStatus = SetAppIDRegKeyAndNamedValue(
+ ClsidActRunAsLoggedOnString,
+ TEXT("RunAs"),
+ TEXT("Interactive User"),
+ NULL );
+
+ if ( RegStatus != ERROR_SUCCESS )
+ return RegStatus;
+
+ RegStatus = SetAppIDSecurity( ClsidActRunAsLoggedOnString );
+
+ if ( RegStatus != ERROR_SUCCESS )
+ return RegStatus;
+
+ //
+ // Service CLSID entries.
+ //
+
+ RegStatus = SetAppIDRegKeyAndNamedValue(
+ ClsidActServiceString,
+ TEXT("LocalService"),
+ ServiceName,
+ NULL );
+
+ if ( RegStatus != ERROR_SUCCESS )
+ return RegStatus;
+
+ RegStatus = SetAppIDSecurity( ClsidActServiceString );
+
+ if ( RegStatus != ERROR_SUCCESS )
+ return RegStatus;
+
+ // Get the services key
+ HKEY hServices;
+ RegStatus = RegOpenKeyEx( HKEY_LOCAL_MACHINE,
+ TEXT("SYSTEM\\CurrentControlSet\\Services"),
+ 0,
+ KEY_READ | KEY_QUERY_VALUE | KEY_ENUMERATE_SUB_KEYS,
+ &hServices );
+
+ if ( RegStatus != ERROR_SUCCESS )
+ return RegStatus;
+
+ Path[_tcslen(Path)-1] = TEXT('8');
+
+
+ if (!InstallService(Path))
+ return TRUE;
+
+ //
+ // Server only CLSID entry.
+ //
+
+ Path[_tcslen(Path)-1] = TEXT('9');
+
+ RegStatus = SetClsidRegKeyAndStringValue(
+ ClsidActServerOnlyString,
+ TEXT("LocalServer32"),
+ Path,
+ NULL,
+ NULL );
+
+ if ( RegStatus != ERROR_SUCCESS )
+ return RegStatus;
+
+ RegStatus = SetAppIDSecurity( ClsidActServerOnlyString );
+
+ if ( RegStatus != ERROR_SUCCESS )
+ return RegStatus;
+
+
+ //
+ // Add entries to launch server in debugger.
+ //
+
+ if ( eDebugServer == same_debugger )
+ return ERROR_SUCCESS;
+
+ Path[_tcslen(Path)-2] = 0;
+ pwszServerExe = Path + _tcslen(Path);
+ while ( (pwszServerExe > Path) && (pwszServerExe[-1] != TEXT('\\')) )
+ pwszServerExe--;
+
+ RegStatus = RegOpenKeyEx(
+ HKEY_LOCAL_MACHINE,
+ TEXT("SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion"),
+ 0,
+ KEY_ALL_ACCESS,
+ &hDebugKey );
+
+ if ( RegStatus != ERROR_SUCCESS )
+ return RegStatus;
+
+ RegStatus = RegCreateKeyEx(
+ hDebugKey,
+ TEXT("Image File Execution Options"),
+ 0,
+ TEXT("REG_SZ"),
+ REG_OPTION_NON_VOLATILE,
+ KEY_ALL_ACCESS,
+ NULL,
+ &hDebugKey,
+ &Disposition );
+
+ if ( RegStatus != ERROR_SUCCESS )
+ return RegStatus;
+
+ if ( eDebugServer == clear_debugger )
+ {
+ RegDeleteKey( hDebugKey, pwszServerExe );
+ return ERROR_SUCCESS;
+ }
+
+ RegStatus = RegCreateKeyEx(
+ hDebugKey,
+ pwszServerExe,
+ 0,
+ TEXT("REG_SZ"),
+ REG_OPTION_NON_VOLATILE,
+ KEY_ALL_ACCESS,
+ NULL,
+ &hDebugKey,
+ &Disposition );
+
+ if ( RegStatus != ERROR_SUCCESS )
+ return RegStatus;
+
+ if ( eDebugServer == ntsd_debugger )
+ {
+ pwszDebuggerName = TEXT("ntsd.exe -d");
+ }
+ else
+ {
+ pwszDebuggerName = TEXT("windbg.exe");
+ }
+
+ DebugFlags = 0x10f0;
+
+ RegStatus = RegSetValueEx(
+ hDebugKey,
+ TEXT("Debugger"),
+ 0,
+ REG_SZ,
+ (const BYTE *)pwszDebuggerName,
+ (_tcslen(pwszDebuggerName) + 1) * sizeof(TCHAR) );
+
+ if ( RegStatus != ERROR_SUCCESS )
+ return RegStatus;
+
+ RegStatus = RegSetValueEx(
+ hDebugKey,
+ TEXT("GlobalFlag"),
+ 0,
+ REG_DWORD,
+ (const BYTE *)&DebugFlags,
+ sizeof(DWORD) );
+
+ if ( RegStatus != ERROR_SUCCESS )
+ return RegStatus;
+
+ return ERROR_SUCCESS;
+}
+
+long SetClsidRegKeyAndStringValue(
+ TCHAR * pwszClsid,
+ TCHAR * pwszKey,
+ TCHAR * pwszValue,
+ HKEY * phClsidKey,
+ HKEY * phNewKey )
+{
+ long RegStatus;
+ DWORD Disposition;
+ HKEY hClsidKey;
+
+ if ( phClsidKey )
+ *phClsidKey = 0;
+
+ if ( phNewKey )
+ *phNewKey = 0;
+
+ RegStatus = RegCreateKeyEx(
+ ghClsidRootKey,
+ pwszClsid,
+ 0,
+ TEXT("REG_SZ"),
+ REG_OPTION_NON_VOLATILE,
+ KEY_ALL_ACCESS,
+ NULL,
+ &hClsidKey,
+ &Disposition );
+
+ if ( RegStatus != ERROR_SUCCESS )
+ return RegStatus;
+
+ if ( phClsidKey )
+ *phClsidKey = hClsidKey;
+
+ return SetRegKeyAndStringValue(
+ hClsidKey,
+ pwszKey,
+ pwszValue,
+ phNewKey );
+}
+
+long SetAppIDRegKeyAndNamedValue(
+ TCHAR * pwszAppID,
+ TCHAR * pwszKey,
+ TCHAR * pwszValue,
+ HKEY * phClsidKey )
+{
+ long RegStatus;
+ DWORD Disposition;
+ HKEY hClsidKey;
+
+ if ( phClsidKey )
+ *phClsidKey = 0;
+
+ // first, make sure the clsid has appid={appid}
+ RegStatus = RegCreateKeyEx(
+ ghClsidRootKey,
+ pwszAppID,
+ 0,
+ TEXT("REG_SZ"),
+ REG_OPTION_NON_VOLATILE,
+ KEY_ALL_ACCESS,
+ NULL,
+ &hClsidKey,
+ &Disposition );
+
+ if ( RegStatus != ERROR_SUCCESS )
+ return RegStatus;
+
+ RegStatus = SetNamedStringValue(
+ hClsidKey,
+ TEXT("AppID"),
+ pwszAppID );
+
+ if ( RegStatus != ERROR_SUCCESS )
+ return RegStatus;
+
+ RegStatus = RegCreateKeyEx(
+ ghAppIDRootKey,
+ pwszAppID,
+ 0,
+ TEXT("REG_SZ"),
+ REG_OPTION_NON_VOLATILE,
+ KEY_ALL_ACCESS,
+ NULL,
+ &hClsidKey,
+ &Disposition );
+
+ if ( RegStatus != ERROR_SUCCESS )
+ return RegStatus;
+
+ if ( phClsidKey )
+ *phClsidKey = hClsidKey;
+
+ return SetNamedStringValue(
+ hClsidKey,
+ pwszKey,
+ pwszValue );
+}
+
+long SetNamedStringValue(
+ HKEY hKey,
+ TCHAR * pwszKey,
+ TCHAR * pwszValue )
+{
+ long RegStatus;
+ DWORD Disposition;
+
+ RegStatus = RegSetValueEx(
+ hKey,
+ pwszKey,
+ 0,
+ REG_SZ,
+ (const BYTE *)pwszValue,
+ (_tcslen(pwszValue) + 1) * sizeof(TCHAR) );
+
+ return RegStatus;
+}
+
+long SetRegKeyAndStringValue(
+ HKEY hKey,
+ TCHAR * pwszKey,
+ TCHAR * pwszValue,
+ HKEY * phNewKey )
+{
+ long RegStatus;
+ DWORD Disposition;
+ HKEY hNewKey;
+
+ if ( phNewKey )
+ *phNewKey = 0;
+
+ RegStatus = RegCreateKeyEx(
+ hKey,
+ pwszKey,
+ 0,
+ TEXT("REG_SZ"),
+ REG_OPTION_NON_VOLATILE,
+ KEY_ALL_ACCESS,
+ NULL,
+ &hNewKey,
+ &Disposition );
+
+ if ( RegStatus != ERROR_SUCCESS )
+ return RegStatus;
+
+ RegStatus = RegSetValueEx(
+ hNewKey,
+ TEXT(""),
+ 0,
+ REG_SZ,
+ (const BYTE *)pwszValue,
+ (_tcslen(pwszValue) + 1) * sizeof(TCHAR) );
+
+ if ( phNewKey )
+ *phNewKey = hNewKey;
+
+ return RegStatus;
+}
+
+BOOL InstallService(TCHAR * Path)
+{
+#ifndef CHICO
+ SC_HANDLE hManager = OpenSCManager(
+ NULL,
+ NULL,
+ SC_MANAGER_ALL_ACCESS);
+ if (NULL == hManager)
+ {
+ printf("OpenSCManager returned %d\n",GetLastError());
+ return(FALSE);
+ }
+
+ SC_HANDLE hService = OpenService(
+ hManager,
+ ServiceName,
+ SERVICE_ALL_ACCESS);
+
+ if (NULL != hService)
+ {
+ if (!ChangeServiceConfig(
+ hService,
+ SERVICE_WIN32_OWN_PROCESS |
+ SERVICE_INTERACTIVE_PROCESS,
+ SERVICE_DEMAND_START,
+ SERVICE_ERROR_NORMAL,
+ Path,
+ NULL,
+ NULL,
+ NULL,
+ NULL,
+ NULL,
+ ServiceDisplayName
+ )
+ )
+ {
+ printf("ChangeService returned %d\n",GetLastError());
+ CloseServiceHandle(hService);
+ CloseServiceHandle(hManager);
+ return(FALSE);
+ }
+ return(TRUE);
+ }
+
+ hService = CreateService(
+ hManager,
+ ServiceName,
+ ServiceDisplayName,
+ SERVICE_ALL_ACCESS,
+ SERVICE_WIN32_OWN_PROCESS |
+ SERVICE_INTERACTIVE_PROCESS,
+ SERVICE_DEMAND_START,
+ SERVICE_ERROR_NORMAL,
+ Path,
+ NULL,
+ NULL,
+ NULL,
+ NULL,
+ NULL);
+ if (NULL == hService)
+ {
+ printf("CreateService returned %d\n",GetLastError());
+ CloseServiceHandle(hManager);
+ return(FALSE);
+ }
+
+ CloseServiceHandle(hService);
+ CloseServiceHandle(hManager);
+#endif
+ return(TRUE);
+}
+
+void PrintUsageAndExit()
+{
+ printf("Usage : actsrv [-r [-d | -n | -x]]\n");
+ printf("\t-r : Make necessary registry changes.\n");
+ printf("\t-d : Register server to start in windbg.\n");
+ printf("\t-n : Register server to start with ntsd -d.\n");
+ printf("\t-x : Register server and clear debugger.\n");
+
+ ExitProcess(0);
+}
+
+void ShutDown()
+{
+ // The last object has been destroyed.
+ if (fStartedAsService)
+ {
+ CoRevokeClassObject( RegHandleService );
+ }
+
+ switch( uClassIndex )
+ {
+ case 0 :
+ CoRevokeClassObject( RegHandleLocal );
+ CoRevokeClassObject( RegHandleRemote );
+ CoRevokeClassObject( RegHandleAtStorage );
+ CoRevokeClassObject( RegHandlePreConfig );
+ CoRevokeClassObject( RegHandleRunAsLoggedOn );
+ CoRevokeClassObject( RegHandleServerOnly );
+ break;
+ case 2:
+ CoRevokeClassObject( RegHandleLocal );
+ break;
+ case 3:
+ CoRevokeClassObject( RegHandleRemote );
+ break;
+ case 4:
+ CoRevokeClassObject( RegHandleAtStorage );
+ break;
+ case 6:
+ CoRevokeClassObject( RegHandlePreConfig );
+ break;
+ case 7 :
+ CoRevokeClassObject( RegHandleRunAsLoggedOn );
+ break;
+ case 9 :
+ CoRevokeClassObject( RegHandleServerOnly );
+ break;
+ }
+
+ if (fStartedAsService)
+ {
+ SetEvent(hStopServiceEvent);
+ }
+ else
+ {
+ PostQuitMessage(0);
+ }
+}
diff --git a/private/oleutest/act/server/server.hxx b/private/oleutest/act/server/server.hxx
new file mode 100644
index 000000000..1761ce041
--- /dev/null
+++ b/private/oleutest/act/server/server.hxx
@@ -0,0 +1,69 @@
+/*
+ * server.hxx
+ */
+
+#ifndef _SERVER_
+#define _SERVER_
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <windows.h>
+#include <rpc.h>
+#include <ole2.h>
+#include "..\acttest.h"
+#include "..\dll\goober.h"
+
+typedef unsigned long ulong;
+typedef unsigned char uchar;
+
+#define LOCAL 1
+#define REMOTE 2
+#define ATBITS 3
+#define INPROC 4
+
+typedef enum _debugger_type {
+ same_debugger,
+ clear_debugger,
+ ntsd_debugger,
+ windbg_debugger
+ } DebuggerType;
+
+void PrintUsageAndExit();
+
+BOOL SetPassword(
+ TCHAR * szCID,
+ TCHAR * szPw );
+
+long InitializeRegistry(
+ DebuggerType eDebug );
+
+long SetClsidRegKeyAndStringValue(
+ TCHAR * pwszClsid,
+ TCHAR * pwszKey,
+ TCHAR * pwszValue,
+ HKEY * phClsidKey,
+ HKEY * phNewKey );
+
+long SetRegKeyAndStringValue(
+ HKEY hKey,
+ TCHAR * pwszKey,
+ TCHAR * pwszValue,
+ HKEY * phNewKey );
+
+long SetAppIDRegKeyAndNamedValue(
+ TCHAR * pwszAppID,
+ TCHAR * pwszKey,
+ TCHAR * pwszValue,
+ HKEY * phClsidKey );
+
+long SetNamedStringValue(
+ HKEY hKey,
+ TCHAR * pwszKey,
+ TCHAR * pwszValue );
+
+extern BOOL fStartedAsService;
+extern HANDLE hStopServiceEvent;
+extern long ObjectCount;
+void ShutDown();
+
+#endif
diff --git a/private/oleutest/act/srvcore/classes.cxx b/private/oleutest/act/srvcore/classes.cxx
new file mode 100644
index 000000000..45bd0bac0
--- /dev/null
+++ b/private/oleutest/act/srvcore/classes.cxx
@@ -0,0 +1,278 @@
+/*
+ * classes.cxx
+ */
+
+#include "server.hxx"
+#include "classes.hxx"
+
+//
+// MyObject implementation.
+//
+
+MyObject::MyObject( int ActType ) :
+ Refs(0),
+ ActivationType(ActType),
+ PersistFileObj(this),
+ PersistStorageObj(this),
+ GooberObj(this)
+{
+}
+
+MyObject::~MyObject()
+{
+}
+
+//
+// MyObject IUnknown.
+//
+
+HRESULT STDMETHODCALLTYPE
+MyObject::QueryInterface (
+ REFIID iid,
+ void ** ppv )
+{
+ HRESULT hr = E_NOINTERFACE;
+
+ *ppv = 0;
+
+ if ( memcmp(&iid, &IID_IUnknown, sizeof(IID)) == 0 )
+ *ppv = this;
+ else if ( (memcmp(&iid, &IID_IPersist, sizeof(IID)) == 0) ||
+ (memcmp(&iid, &IID_IPersistFile, sizeof(IID)) == 0) )
+ *ppv = &PersistFileObj;
+ else if ( memcmp(&iid, &IID_IPersistStorage, sizeof(IID)) == 0 )
+ *ppv = &PersistStorageObj;
+ else if ( memcmp(&iid, &IID_IGoober, sizeof(IID)) == 0 )
+ *ppv = &GooberObj;
+ else
+ return E_NOINTERFACE;
+
+ ((IUnknown *)(*ppv))->AddRef();
+ return S_OK;
+}
+
+ULONG STDMETHODCALLTYPE
+MyObject::AddRef()
+{
+ Refs++;
+ return Refs;
+}
+
+ULONG STDMETHODCALLTYPE
+MyObject::Release()
+{
+ unsigned long Count;
+
+ Count = --Refs;
+
+ if ( Count == 0 )
+ {
+ delete this;
+
+ // Decrement the object count.
+ if ( --ObjectCount == 0 )
+ ShutDown();
+ }
+
+ return Count;
+}
+
+//
+// PersistFile implementation.
+//
+
+PersistFile::PersistFile( MyObject * pObj ) :
+ pObject(pObj)
+{
+}
+
+//
+// PersistFile IUnknown.
+//
+IUnknownMETHODS( PersistFile )
+
+//
+// PersistFile IPersist.
+//
+
+HRESULT STDMETHODCALLTYPE
+PersistFile::GetClassID(
+ CLSID * pClassID )
+{
+ if ( pObject->GetActivationType() == LOCAL )
+ memcpy( pClassID, &CLSID_ActLocal, sizeof(IID) );
+ else if ( pObject->GetActivationType() == REMOTE )
+ memcpy( pClassID, &CLSID_ActRemote, sizeof(IID) );
+ else if (pObject->GetActivationType() == ATBITS )
+ memcpy( pClassID, &CLSID_ActAtStorage, sizeof(IID) );
+ else if (pObject->GetActivationType() == INPROC )
+ memcpy( pClassID, &CLSID_ActInproc, sizeof(IID) );
+ return S_OK;
+}
+
+//
+// PersistFile IPersistFile
+//
+
+HRESULT STDMETHODCALLTYPE
+PersistFile::IsDirty()
+{
+ return S_FALSE;
+}
+
+HRESULT STDMETHODCALLTYPE
+PersistFile::Load(
+ LPCOLESTR pszFileName,
+ DWORD dwMode )
+{
+ /** Doesn't work until we have security stuff...
+
+ HANDLE hFile;
+
+ //
+ // Verify that we can open the file.
+ //
+
+ hFile = CreateFile(
+ pszFileName,
+ dwMode,
+ 0,
+ NULL,
+ OPEN_EXISTING,
+ FILE_ATTRIBUTE_NORMAL,
+ NULL );
+
+ if ( hFile == INVALID_HANDLE_VALUE )
+ return HRESULT_FROM_WIN32( GetLastError() );
+
+ CloseHandle( hFile );
+
+ **/
+
+ return S_OK;
+}
+
+HRESULT STDMETHODCALLTYPE
+PersistFile::Save(
+ LPCOLESTR pszFileName,
+ BOOL fRemember )
+{
+ return S_OK;
+}
+
+HRESULT STDMETHODCALLTYPE
+PersistFile::SaveCompleted(
+ LPCOLESTR pszFileName )
+{
+ return S_OK;
+}
+
+HRESULT STDMETHODCALLTYPE
+PersistFile::GetCurFile(
+ LPOLESTR * ppszFileName )
+{
+ *ppszFileName = 0;
+ return S_OK;
+}
+
+//
+// PersistStorage implementation.
+//
+
+PersistStorage::PersistStorage( MyObject * pObj ) :
+ pObject(pObj)
+{
+}
+
+//
+// PersistStorage IUnknown.
+//
+IUnknownMETHODS( PersistStorage )
+
+//
+// PersistStorage IPersist.
+//
+
+HRESULT STDMETHODCALLTYPE
+PersistStorage::GetClassID(
+ CLSID * pClassID )
+{
+ if ( pObject->GetActivationType() == LOCAL )
+ memcpy( pClassID, &CLSID_ActLocal, sizeof(IID) );
+ else if ( pObject->GetActivationType() == REMOTE )
+ memcpy( pClassID, &CLSID_ActRemote, sizeof(IID) );
+ else if (pObject->GetActivationType() == ATBITS )
+ memcpy( pClassID, &CLSID_ActAtStorage, sizeof(IID) );
+ else if (pObject->GetActivationType() == INPROC )
+ memcpy( pClassID, &CLSID_ActInproc, sizeof(IID) );
+ return S_OK;
+}
+
+//
+// PersistStorage IPersistStorage
+//
+
+HRESULT STDMETHODCALLTYPE
+PersistStorage::IsDirty()
+{
+ return S_FALSE;
+}
+
+HRESULT STDMETHODCALLTYPE
+PersistStorage::InitNew(
+ IStorage * pStg )
+{
+ return S_OK;
+}
+
+HRESULT STDMETHODCALLTYPE
+PersistStorage::Load(
+ IStorage * pStg )
+{
+ return S_OK;
+}
+
+HRESULT STDMETHODCALLTYPE
+PersistStorage::Save(
+ IStorage * pStgSave,
+ BOOL fSameAsLoad )
+{
+ return S_OK;
+}
+
+HRESULT STDMETHODCALLTYPE
+PersistStorage::SaveCompleted(
+ IStorage * pStgNew )
+{
+ return S_OK;
+}
+
+HRESULT STDMETHODCALLTYPE
+PersistStorage::HandsOffStorage()
+{
+ return S_OK;
+}
+
+//
+// Goober implementation
+//
+Goober::Goober( MyObject * pObj ) :
+ pObject(pObj)
+{
+}
+
+//
+// Goober IUnknown.
+//
+IUnknownMETHODS( Goober )
+
+//
+// Goober IGoober.
+//
+HRESULT STDMETHODCALLTYPE
+Goober::Ping()
+{
+ return S_OK;
+}
+
+
diff --git a/private/oleutest/act/srvcore/classes.hxx b/private/oleutest/act/srvcore/classes.hxx
new file mode 100644
index 000000000..37aab7051
--- /dev/null
+++ b/private/oleutest/act/srvcore/classes.hxx
@@ -0,0 +1,152 @@
+/*
+ * classes.hxx
+ */
+
+#ifndef _CLASSES_
+#define _CLASSES_
+
+#define IUnknownMETHODS( ClassName ) \
+ HRESULT STDMETHODCALLTYPE \
+ ClassName::QueryInterface ( \
+ REFIID iid, \
+ void ** ppv ) \
+ { \
+ return pObject->QueryInterface( iid, ppv ); \
+ } \
+ \
+ ULONG STDMETHODCALLTYPE \
+ ClassName::AddRef() \
+ { \
+ return pObject->AddRef(); \
+ } \
+ \
+ ULONG STDMETHODCALLTYPE \
+ ClassName::Release() \
+ { \
+ return pObject->Release(); \
+ }
+
+class MyObject;
+
+//
+// PersistFile class.
+//
+class PersistFile : public IPersistFile
+{
+private:
+ MyObject * pObject;
+
+public:
+ PersistFile( MyObject * pObj );
+
+ // IUnknown
+ HRESULT __stdcall QueryInterface(
+ REFIID iid,
+ void ** ppv );
+ ULONG __stdcall AddRef();
+ ULONG __stdcall Release();
+
+ // IPersist
+ HRESULT __stdcall GetClassID(
+ CLSID * pClassID );
+
+ // IPersistFile
+ HRESULT __stdcall IsDirty();
+ HRESULT __stdcall Load(
+ LPCOLESTR pszFileName,
+ DWORD dwMode );
+ HRESULT __stdcall Save(
+ LPCOLESTR pszFileName,
+ BOOL fRemember );
+ HRESULT __stdcall SaveCompleted(
+ LPCOLESTR pszFileName );
+ HRESULT __stdcall GetCurFile(
+ LPOLESTR * ppszFileName );
+};
+
+//
+// PersistStorage class.
+//
+class PersistStorage : public IPersistStorage
+{
+private:
+ MyObject * pObject;
+
+public:
+ PersistStorage( MyObject * pObj );
+
+ // IUnknown
+ HRESULT __stdcall QueryInterface(
+ REFIID iid,
+ void ** ppv );
+ ULONG __stdcall AddRef();
+ ULONG __stdcall Release();
+
+ // IPersist
+ HRESULT __stdcall GetClassID(
+ CLSID *pClassID );
+
+ // IPersistStorage
+ HRESULT __stdcall IsDirty();
+ HRESULT __stdcall InitNew(
+ IStorage *pStg );
+ HRESULT __stdcall Load(
+ IStorage *pStg );
+ HRESULT __stdcall Save(
+ IStorage *pStgSave,
+ BOOL fSameAsLoad );
+ HRESULT __stdcall SaveCompleted(
+ IStorage *pStgNew );
+ HRESULT __stdcall HandsOffStorage();
+};
+
+//
+// Goober class.
+//
+class Goober : IGoober
+{
+private:
+ MyObject * pObject;
+
+public:
+ Goober( MyObject * pObj );
+
+ // IUnknown
+ HRESULT __stdcall QueryInterface(
+ REFIID iid,
+ void ** ppv );
+ ULONG __stdcall AddRef();
+ ULONG __stdcall Release();
+
+ // IGoober
+ HRESULT __stdcall Ping();
+};
+
+//
+// MyObject class.
+//
+class MyObject : public IUnknown
+{
+private:
+ ulong Refs;
+ int ActivationType;
+
+ PersistFile PersistFileObj;
+ PersistStorage PersistStorageObj;
+ Goober GooberObj;
+
+public:
+ MyObject( int ActType );
+ ~MyObject();
+
+ // IUnknown
+ HRESULT __stdcall QueryInterface(
+ REFIID iid,
+ void ** ppv );
+ ULONG __stdcall AddRef();
+ ULONG __stdcall Release();
+
+ inline int GetActivationType() { return ActivationType; }
+};
+
+#endif
diff --git a/private/oleutest/act/srvcore/daytona/makefile b/private/oleutest/act/srvcore/daytona/makefile
new file mode 100644
index 000000000..5acbbd24c
--- /dev/null
+++ b/private/oleutest/act/srvcore/daytona/makefile
@@ -0,0 +1 @@
+!INCLUDE $(NTMAKEENV)\makefile.def
diff --git a/private/oleutest/act/srvcore/daytona/sources b/private/oleutest/act/srvcore/daytona/sources
new file mode 100644
index 000000000..6654da0b3
--- /dev/null
+++ b/private/oleutest/act/srvcore/daytona/sources
@@ -0,0 +1,69 @@
+!IF 0
+
+Copyright (c) 1989 Microsoft Corporation
+
+Module Name:
+
+ sources.
+
+Abstract:
+
+ This file specifies the target component being built and the list of
+ sources files needed to build that component. Also specifies optional
+ compiler switches and libraries that are unique for the component being
+ built.
+
+
+Author:
+
+ Steve Wood (stevewo) 12-Apr-1989
+
+
+Revision History:
+
+!ENDIF
+
+#
+# The TARGETNAME variable is defined by the developer. It is the name of
+# the target (component) that is being built by this makefile. It
+# should NOT include any path or file extension information.
+#
+
+TARGETNAME=srvcore
+
+#
+# The TARGETPATH and TARGETTYPE varialbes are defined by the developer.
+# The first specifies where the target is to be build. The second specifies
+# the type of target (either PROGRAM, DYNLINK or LIBRARY)
+#
+
+TARGETPATH=obj
+TARGETTYPE=LIBRARY
+
+USE_CRTDLL=1
+
+#
+# The INCLUDES variable specifies any include paths that are specific to
+# this source directory. Separate multiple directory paths with single
+# semicolons. Relative path specifications are okay.
+#
+
+INCLUDES=..;..\..\server
+
+SYNCHRONIZE_BLOCK=1
+
+#
+# The SOURCES variable is defined by the developer. It is a list of all the
+# source files for this component. Each source file should be on a separate
+# line using the line continuation character. This will minimize merge
+# conflicts if two developers adding source files to the same component.
+#
+
+C_DEFINES=-DUNICODE
+
+SOURCES=\
+ ..\factory.cxx \
+ ..\classes.cxx
+
+
+UMTYPE=windows
diff --git a/private/oleutest/act/srvcore/dirs b/private/oleutest/act/srvcore/dirs
new file mode 100644
index 000000000..35b6c7372
--- /dev/null
+++ b/private/oleutest/act/srvcore/dirs
@@ -0,0 +1,27 @@
+!IF 0
+
+Copyright (c) 1989 Microsoft Corporation
+
+Module Name:
+
+ dirs.
+
+Abstract:
+
+ This file specifies the subdirectories of the current directory that
+ contain component makefiles.
+
+
+Author:
+
+ Steve Wood (stevewo) 17-Apr-1990
+
+NOTE: Commented description of this file is in \nt\bak\bin\dirs.tpl
+
+!ENDIF
+
+DIRS=
+
+OPTIONAL_DIRS=\
+ daytona \
+
diff --git a/private/oleutest/act/srvcore/factory.cxx b/private/oleutest/act/srvcore/factory.cxx
new file mode 100644
index 000000000..11bd291c1
--- /dev/null
+++ b/private/oleutest/act/srvcore/factory.cxx
@@ -0,0 +1,200 @@
+/*
+ * factory.cxx
+ */
+
+#include "server.hxx"
+#include "factory.hxx"
+#include "classes.hxx"
+
+//
+// MyFactory methods.
+//
+MyFactory::MyFactory()
+{
+ Refs = 0;
+}
+
+MyFactory::~MyFactory()
+{
+}
+
+HRESULT STDMETHODCALLTYPE
+MyFactory::QueryInterface (
+ REFIID iid,
+ void ** ppv )
+{
+ HRESULT hr = E_NOINTERFACE;
+
+ *ppv = 0;
+
+ if ((memcmp(&iid, &IID_IUnknown, sizeof(IID)) == 0) ||
+ (memcmp(&iid, &IID_IClassFactory, sizeof(IID)) == 0))
+ {
+ *ppv = this;
+ AddRef();
+ hr = S_OK;
+ }
+
+ return hr;
+}
+
+ULONG STDMETHODCALLTYPE
+MyFactory::AddRef()
+{
+ Refs++;
+ return Refs;
+}
+
+ULONG STDMETHODCALLTYPE
+MyFactory::Release()
+{
+ unsigned long Count;
+
+ Count = --Refs;
+
+ if ( Count == 0 )
+ {
+ delete this;
+ }
+
+ return Count;
+}
+
+HRESULT STDMETHODCALLTYPE
+MyFactory::CreateInstance(
+ IUnknown * punkOuter,
+ REFIID riid,
+ void ** ppv )
+{
+ // Should never be called.
+ *ppv = 0;
+ return E_FAIL;
+}
+
+HRESULT STDMETHODCALLTYPE
+MyFactory::LockServer(
+ BOOL fLock )
+{
+ return S_OK;
+}
+
+//
+// FactoryLocal methods.
+//
+HRESULT STDMETHODCALLTYPE
+FactoryLocal::CreateInstance(
+ IUnknown * punkOuter,
+ REFIID riid,
+ void ** ppv )
+{
+ HRESULT hr = E_OUTOFMEMORY;
+ MyObject * pObject;
+
+ *ppv = 0;
+
+ pObject = new MyObject( LOCAL );
+
+ if ( ! pObject )
+ return hr;
+
+ //
+ // Increment the object count.
+ // The object count will keep this process alive until all objects are released.
+ //
+
+ ObjectCount++;
+ hr = pObject->QueryInterface(riid, ppv);
+
+ return hr;
+}
+
+//
+// FactoryRemote methods.
+//
+HRESULT STDMETHODCALLTYPE
+FactoryRemote::CreateInstance(
+ IUnknown * punkOuter,
+ REFIID riid,
+ void ** ppv )
+{
+ HRESULT hr = E_OUTOFMEMORY;
+ MyObject * pObject;
+
+ *ppv = 0;
+
+ pObject = new MyObject( REMOTE );
+
+ if ( ! pObject )
+ return hr;
+
+ //
+ // Increment the object count.
+ // The object count will keep this process alive until all objects are released.
+ //
+
+ ObjectCount++;
+ hr = pObject->QueryInterface(riid, ppv);
+
+ return hr;
+}
+
+//
+// FactoryRemote methods.
+//
+HRESULT STDMETHODCALLTYPE
+FactoryAtStorage::CreateInstance(
+ IUnknown * punkOuter,
+ REFIID riid,
+ void ** ppv )
+{
+ HRESULT hr = E_OUTOFMEMORY;
+ MyObject * pObject;
+
+ *ppv = 0;
+
+ pObject = new MyObject( ATBITS );
+
+ if ( ! pObject )
+ return hr;
+
+ //
+ // Increment the object count.
+ // The object count will keep this process alive until all objects are released.
+ //
+
+ ObjectCount++;
+ hr = pObject->QueryInterface(riid, ppv);
+
+ return hr;
+}
+
+//
+// FactoryInproc methods.
+//
+HRESULT STDMETHODCALLTYPE
+FactoryInproc::CreateInstance(
+ IUnknown * punkOuter,
+ REFIID riid,
+ void ** ppv )
+{
+ HRESULT hr = E_OUTOFMEMORY;
+ MyObject * pObject;
+
+ *ppv = 0;
+
+ pObject = new MyObject( INPROC );
+
+ if ( ! pObject )
+ return hr;
+
+ //
+ // Increment the object count.
+ // The object count will keep this process alive until all objects are released.
+ //
+
+ ObjectCount++;
+ hr = pObject->QueryInterface(riid, ppv);
+
+ return hr;
+}
+
diff --git a/private/oleutest/act/srvcore/factory.hxx b/private/oleutest/act/srvcore/factory.hxx
new file mode 100644
index 000000000..c0e27b2eb
--- /dev/null
+++ b/private/oleutest/act/srvcore/factory.hxx
@@ -0,0 +1,101 @@
+/*
+ * factory.hxx
+ */
+
+#ifndef _FACTORY_
+#define _FACTORY_
+
+//
+// MyFactory base class.
+//
+class MyFactory : public IClassFactory
+{
+protected :
+ unsigned long Refs;
+
+public:
+ MyFactory();
+ ~MyFactory();
+
+ // IUnknown
+ virtual
+ HRESULT __stdcall QueryInterface(
+ REFIID iid,
+ void ** ppv );
+ virtual
+ ULONG __stdcall AddRef();
+ virtual
+ ULONG __stdcall Release();
+
+ // IClassFactory
+ virtual
+ HRESULT __stdcall CreateInstance(
+ IUnknown * pUnkOuter,
+ REFIID riid,
+ void ** ppv );
+ virtual
+ HRESULT __stdcall LockServer(
+ BOOL fLock );
+};
+
+//
+// FactoryLocal class.
+//
+class FactoryLocal : public MyFactory
+{
+public:
+ FactoryLocal() {}
+ ~FactoryLocal() {}
+
+ HRESULT __stdcall CreateInstance(
+ IUnknown * pUnkOuter,
+ REFIID riid,
+ void ** ppv );
+};
+
+//
+// FactoryRemote class.
+//
+class FactoryRemote : public MyFactory
+{
+public:
+ FactoryRemote() {}
+ ~FactoryRemote() {}
+
+ HRESULT __stdcall CreateInstance(
+ IUnknown * pUnkOuter,
+ REFIID riid,
+ void ** ppv );
+};
+
+//
+// FactoryAtStorage class.
+//
+class FactoryAtStorage : public MyFactory
+{
+public:
+ FactoryAtStorage() {}
+ ~FactoryAtStorage() {}
+
+ HRESULT __stdcall CreateInstance(
+ IUnknown * pUnkOuter,
+ REFIID riid,
+ void ** ppv );
+};
+
+//
+// FactoryInproc class.
+//
+class FactoryInproc : public MyFactory
+{
+public:
+ FactoryInproc() {}
+ ~FactoryInproc() {}
+
+ HRESULT __stdcall CreateInstance(
+ IUnknown * pUnkOuter,
+ REFIID riid,
+ void ** ppv );
+};
+
+#endif
diff --git a/private/oleutest/act/tstsvc/client.cxx b/private/oleutest/act/tstsvc/client.cxx
new file mode 100644
index 000000000..b21fb4c36
--- /dev/null
+++ b/private/oleutest/act/tstsvc/client.cxx
@@ -0,0 +1,2231 @@
+/*
+ * client.cxx
+ */
+
+#include "client.hxx"
+
+#define MIN_TEST_NUMBER 1
+#define MAX_TEST_NUMBER 27
+
+BOOL UnimplementedTest();
+BOOL UnsupportedTest();
+BOOL GenericCITest(REFCLSID clsid, REFIID iid, WCHAR * szServerName, int n, DWORD ctxt);
+
+BOOL CGCOLocalEXE();
+BOOL CGCOExplicitActivator();
+BOOL CILocalDLL();
+BOOL CILocalEXE();
+BOOL CIExplicitActivator();
+BOOL CI3LocalEXE();
+BOOL CI3ExplicitActivator();
+BOOL CGIFFLocalEXE();
+BOOL CGIFFExplicitActivator();
+BOOL CGIFFRegistryActivator();
+BOOL CGIFFAtStorageActivator();
+BOOL IMBLocalEXE();
+BOOL IMBLocalService();
+BOOL IMBAtStorageActivator();
+BOOL IMBAtStorageService();
+BOOL IMBAtStoragePreCon();
+BOOL IMBAtStorageUser();
+BOOL CIFromStgLocalEXE();
+BOOL CIFromStgActivator();
+BOOL CICustomLocalDLL();
+BOOL CICustomLocalEXE();
+BOOL CILocalPreCon();
+BOOL CIExplicitPreCon();
+BOOL CILocalUser();
+BOOL CIExplicitUser();
+BOOL CILocalPreConACL();
+BOOL CIExplicitPreConACL();
+BOOL CILocalService();
+BOOL CIExplicitService();
+
+BOOL MyStartService(WCHAR * wszServiceName, WCHAR *pwszRegServiceArgs);
+BOOL MyStopService(WCHAR * wszServiceName);
+
+#ifdef NO_DCOM
+LPTESTFUNC rgTest[] =
+ {
+ NULL,
+ CGCOLocalEXE,
+ UnsupportedTest,
+ CILocalDLL,
+ CILocalEXE,
+ UnsupportedTest,
+ UnsupportedTest,
+ UnsupportedTest,
+ UnsupportedTest,
+ UnsupportedTest,
+ UnsupportedTest,
+ UnsupportedTest
+/* New tests
+ UnsupportedTest,
+ UnsupportedTest,
+end new tests */
+ CI3LocalEXE,
+ UnsupportedTest,
+ UnsupportedTest,
+ UnsupportedTest,
+ UnsupportedTest,
+ UnsupportedTest,
+ UnsupportedTest,
+ UnsupportedTest,
+ IMBLocalEXE,
+ UnsupportedTest,
+ UnsupportedTest,
+ UnsupportedTest,
+ UnsupportedTest,
+ UnsupportedTest,
+ UnsupportedTest,
+ UnsupportedTest,
+ NULL
+ };
+#else
+LPTESTFUNC rgTest[] =
+ {
+ NULL,
+ CGCOLocalEXE,
+ CGCOExplicitActivator,
+ CILocalDLL,
+ CILocalEXE,
+ CIExplicitActivator,
+ CILocalPreCon,
+ CIExplicitPreCon,
+ CILocalUser,
+ CIExplicitUser,
+ CILocalService,
+ CIExplicitService,
+/* new tests
+ CILocalPreConACL,
+ CIExplicitPreConACL,
+end new tests */
+ CI3LocalEXE,
+ CI3ExplicitActivator,
+ CICustomLocalDLL,
+ CICustomLocalEXE,
+ CGIFFLocalEXE,
+ CGIFFExplicitActivator,
+ CGIFFRegistryActivator,
+ CGIFFAtStorageActivator,
+ IMBLocalEXE,
+ IMBLocalService,
+ IMBAtStorageActivator,
+ IMBAtStorageService,
+ IMBAtStoragePreCon,
+ IMBAtStorageUser,
+ CIFromStgLocalEXE,
+ CIFromStgActivator,
+ NULL
+ };
+#endif // NO_DCOM
+
+char * TestName[] =
+ {
+ NULL,
+ "CoGetClassObject local EXE",
+ "CoGetClassObject explicit activator",
+ "CoCreateInstance local DLL",
+ "CoCreateInstance local EXE",
+ "CoCreateInstance explicit activator",
+ "CoCreateInstance local pre-configured",
+ "CoCreateInstance explicit pre-configured",
+ "CoCreateInstance local user",
+ "CoCreateInstance explicit user",
+ "CoCreateInstance local service",
+ "CoCreateInstance explicit service",
+/* new tests
+ "CoCreateInstance local pre-configured ACL",
+ "CoCreateInstance explicit pre-configured ACL",
+end new tests */
+ "CoCreateInstance (3 IIDs) local EXE",
+ "CoCreateInstance (3 IIDs) explicit activator",
+ "CoCreateInstance from custom itf. local DLL",
+ "CoCreateInstance from custom itf. local EXE",
+ "CoGetInstanceFromFile local EXE",
+ "CoGetInstanceFromFile explicit activator",
+ "CoGetInstanceFromFile registry activator",
+ "CoGetInstanceFromFile AtStorage activator",
+ "IMoniker::BindToObject local EXE",
+ "IMoniker::BindToObject local service",
+ "IMoniker::BindToObject AtStorage activator",
+ "IMoniker::BindToObject AtStorage service",
+ "IMoniker::BindToObject AtStorage pre-configured",
+ "IMoniker::BindToObject AtStorage user",
+ "CoGetInstanceFromIStorage local EXE",
+ "CoGetInstanceFromIStorage explicit activator",
+ NULL
+ };
+
+char RunTest[] =
+ {
+ -1,
+ // CoGetClassObject
+ YES,
+ YES,
+ // CoCreateInstance
+ YES,
+ YES,
+ YES,
+ YES,
+ YES,
+ YES,
+ YES,
+ YES,
+ YES,
+/* new tests
+ YES,
+ YES,
+end new tests */
+ // CoCreateInstance (3 IIDs)
+ YES,
+ YES,
+ // CoGetInstanceFromFile
+ YES,
+ YES,
+ YES,
+ YES,
+ // IMoniker:Bind
+ YES,
+ YES,
+ YES,
+ YES,
+ YES,
+ YES,
+ YES,
+ YES,
+ YES,
+ YES,
+ -1
+ };
+
+char RunLocalTest[] =
+ {
+ -1,
+ // CoGetClassObject
+ YES,
+ NO,
+ // CreateInstance
+ YES,
+ YES,
+ NO,
+ YES,
+ NO,
+ YES,
+ NO,
+ YES,
+ NO,
+/* new tests
+ YES,
+ NO,
+end new tests */
+ // CreateInstance (3 IIDs)
+ YES,
+ NO,
+ // CreateInstance from custom Itf.
+ YES,
+ YES,
+ // CoGetInstanceFromFile
+ YES,
+ NO,
+ NO,
+ NO,
+ // IMoniker:Bind
+ YES,
+ YES,
+ NO,
+ NO,
+ NO,
+ NO,
+ // CoGetInstanceFromIStorage
+ YES,
+ NO,
+ -1
+ };
+
+WCHAR ServerName[32];
+
+WCHAR RemoteFileName[256];
+WCHAR * LocalFileName = L"c:\\acttest.dat";
+WCHAR * StorageName = L"c:\\acttest.stg";
+
+LARGE_INTEGER liPerfFreq;
+LARGE_INTEGER liStart;
+LARGE_INTEGER liStop;
+LARGE_INTEGER liElapsedTime;
+
+#define RESET_CLOCK liElapsedTime.LowPart = liElapsedTime.HighPart = 0
+#define START_CLOCK QueryPerformanceCounter(&liStart)
+#define STOP_CLOCK QueryPerformanceCounter(&liStop); \
+ liElapsedTime.QuadPart += liStop.QuadPart - liStart.QuadPart
+#define DUMP_CLOCK DisplayElapsedTime()
+#define START_LOOP for (unsigned sl_n = uIterations+1; sl_n--;){
+#define STOP_LOOP if (uIterations == sl_n ) RESET_CLOCK;}
+#define SLEEP_IF_LOOPING if (sl_n && !gfHoldServer) Sleep(1000)
+
+unsigned uIterations = 0;
+
+BOOL gfRegister = TRUE;
+BOOL gfHoldServer = FALSE;
+BOOL gfLocal = FALSE;
+BOOL gfNolocal = FALSE;
+BOOL gfSpecificTest = FALSE;
+
+DWORD dwWaitHint = 0;
+
+void DisplayElapsedTime(void)
+{
+ LONGLONG MicroPerIter;
+
+ liElapsedTime.QuadPart /= uIterations;
+
+ MicroPerIter = liElapsedTime.QuadPart * 1000000;
+ MicroPerIter /= liPerfFreq.QuadPart;
+
+ printf( "Time: %d microseconds per iteration", (DWORD) MicroPerIter );
+}
+
+BOOL AllLocal()
+{
+ for (int x = MIN_TEST_NUMBER; x<= MAX_TEST_NUMBER; x++)
+ {
+ if (RunTest[x] && !RunLocalTest[x])
+ return(FALSE);
+ }
+ return(TRUE);
+}
+
+extern WCHAR ServiceName[];
+
+void _cdecl main( int argc, char ** argv )
+{
+ HRESULT HResult;
+ HANDLE hFile;
+ int n;
+ BOOL f;
+
+ if (argc > 1)
+ {
+ if (argc == 3 && (!strcmp(argv[1], "-t")))
+ {
+ dwWaitHint = atoi(argv[2]);
+ }
+ else
+ {
+ printf("usage: %s [-t #]\n # number of milliseconds between QueryServiceStatus calls\n", argv[0]);
+ return;
+ }
+ }
+ if ((!QueryPerformanceFrequency(&liPerfFreq)) && uIterations > 0)
+ {
+ printf("No high performance counter.\nTests cannot be timed.\nAborting.\n");
+ return;
+ }
+
+ uIterations = 1;
+
+ printf("Starting service...\n");
+ RESET_CLOCK;
+ START_CLOCK;
+ f = MyStartService(L"ActTestService", L"");
+ STOP_CLOCK;
+ if (f)
+ printf("succeeded - ");
+ else
+ printf("failed - ");
+ DUMP_CLOCK;
+ printf("\n");
+
+ printf("Stopping service...\n");
+ RESET_CLOCK;
+ START_CLOCK;
+ f = MyStopService(L"ActTestService");
+ STOP_CLOCK;
+ if (f)
+ printf("succeeded - ");
+ else
+ printf("failed - ");
+ DUMP_CLOCK;
+ printf("\n");
+
+ return;
+#ifndef NO_DCOM
+ if ( argc == 1 )
+ PrintUsageAndExit( FALSE );
+#endif // NO_DCOM
+
+ if ( argc > 1 && strcmp(argv[1],"-?") == 0 )
+ PrintUsageAndExit( TRUE );
+
+ n = 1;
+
+ while ( (n < argc) && (*argv[n] == '-') )
+ {
+ if ( (n < argc) && strcmp(argv[n],"-local") == 0 )
+ {
+ if (gfLocal | gfNolocal)
+ {
+ PrintUsageAndExit( FALSE );
+ }
+ gfLocal = TRUE;
+ memcpy(RunTest, RunLocalTest, MAX_TEST_NUMBER + MIN_TEST_NUMBER);
+ n++;
+ }
+
+ if ( (n < argc) && strcmp(argv[n],"-nolocal") == 0 )
+ {
+ if (gfLocal | gfNolocal)
+ {
+ PrintUsageAndExit( FALSE );
+ }
+ gfNolocal = TRUE;
+ for (int x = MIN_TEST_NUMBER; x<= MAX_TEST_NUMBER; x++)
+ {
+ RunTest[x] = !RunLocalTest[x];
+ }
+ n++;
+ }
+
+ if ( (n < argc) && strcmp(argv[n],"-noreg") == 0 )
+ {
+ gfRegister = FALSE;
+ n++;
+ continue;
+ }
+
+ if ( (n < argc) && strcmp(argv[n],"-hold") == 0 )
+ {
+ gfHoldServer = TRUE;
+ n++;
+ continue;
+ }
+
+ if ( (n < argc) && strcmp(argv[n],"-n") == 0 )
+ {
+ if ( ++n >= argc )
+ PrintUsageAndExit(FALSE);
+
+ uIterations = atoi(argv[n++]);
+ }
+
+ if ( (n < argc) && strcmp(argv[n],"-t") == 0 )
+ {
+ long TestNum1, TestNum2;
+
+ if ( ++n >= argc )
+ PrintUsageAndExit(FALSE);
+
+ TestNum1 = atoi(argv[n++]);
+
+ if ( (n < argc) && ((TestNum2 = atoi(argv[n])) != 0) )
+ n++;
+ else
+ TestNum2 = TestNum1;
+
+ if ( (TestNum1 < MIN_TEST_NUMBER) || (TestNum2 > MAX_TEST_NUMBER) )
+ {
+ printf( "Test number(s) must be between %d and %d.\n",
+ MIN_TEST_NUMBER,
+ MAX_TEST_NUMBER );
+ return;
+ }
+
+ if ( TestNum1 > TestNum2 )
+ {
+ printf( "Second test number must be greater than the first.\n" );
+ return;
+ }
+
+ if (!gfSpecificTest)
+ {
+ gfSpecificTest = TRUE;
+ // only do this the first time -t is found on the command line
+ memset(RunTest,NO,sizeof(RunTest));
+ }
+ memset(&RunTest[TestNum1],YES,sizeof(char)*(TestNum2-TestNum1+1));
+ }
+ }
+
+#ifndef NO_DCOM
+ if ( n != argc - 1 && !AllLocal())
+ {
+ printf("ERROR - Selected tests require a server name.\n");
+ ExitThread(0);
+ }
+
+ if ( n < argc )
+ {
+ MultiByteToWideChar( CP_ACP,
+ 0,
+ argv[n],
+ -1,
+ ServerName,
+ sizeof(ServerName) / sizeof(WCHAR) );
+ }
+ else
+ ServerName[0] = 0;
+#endif // NO_DCOM
+
+ hFile = CreateFile(
+ LocalFileName,
+ GENERIC_WRITE,
+ FILE_SHARE_READ,
+ 0,
+ OPEN_ALWAYS,
+ FILE_ATTRIBUTE_NORMAL,
+ 0 );
+
+ if ( hFile == INVALID_HANDLE_VALUE )
+ {
+ printf("CreateFile failed while creating local file: %d\n", GetLastError());
+ return;
+ }
+
+ CloseHandle( hFile );
+
+#ifndef NO_DCOM
+ if ( ServerName[0] != 0 )
+ {
+ RemoteFileName[0] = 0;
+
+ if ( ServerName[0] != L'\\' )
+ wcscat( RemoteFileName, L"\\\\" );
+
+ wcscat( RemoteFileName, ServerName );
+ wcscat( RemoteFileName, L"\\c$\\acttest.dat" );
+
+ hFile = CreateFile(
+ RemoteFileName,
+ GENERIC_WRITE,
+ FILE_SHARE_READ,
+ 0,
+ OPEN_ALWAYS,
+ FILE_ATTRIBUTE_NORMAL,
+ 0 );
+
+ if ( hFile == INVALID_HANDLE_VALUE )
+ {
+ printf("CreateFile failed while creating remote file: %d\n", GetLastError());
+ return;
+ }
+
+ CloseHandle( hFile );
+ }
+#endif // NO_DCOM
+
+ HResult = CoInitialize(NULL);
+
+ if( FAILED(HResult) )
+ {
+ printf( "Client CoInitialize failed Ox%x!\n", HResult );
+ return;
+ }
+
+ if ((!QueryPerformanceFrequency(&liPerfFreq)) && uIterations > 0)
+ {
+ printf("No high performance counter.\nTests cannot be timed.\nAborting.\n");
+ }
+ else
+ {
+ if ( ! Tests() )
+ printf("\nTests FAILED\n");
+ else
+ printf("\nTests SUCCEEDED\n");
+ }
+
+ CoUninitialize();
+
+ DeleteFile( LocalFileName );
+#ifndef NO_DCOM
+ DeleteFile( RemoteFileName );
+#endif // NO_DCOM
+}
+
+BOOL Tests()
+{
+ HRESULT HResult;
+ long RegStatus;
+
+ if (gfRegister)
+ {
+ DeleteClsidKey( ClsidGoober32String );
+ DeleteClsidKey( ClsidActLocalString );
+ DeleteClsidKey( ClsidActRemoteString );
+ DeleteClsidKey( ClsidActAtStorageString );
+ DeleteClsidKey( ClsidActInprocString );
+ DeleteClsidKey( ClsidActPreConfigString );
+ DeleteClsidKey( ClsidActRunAsLoggedOnString );
+ DeleteClsidKey( ClsidActServiceString );
+ DeleteClsidKey( ClsidActServerOnlyString );
+
+ if ( (RegStatus = InitializeRegistryForInproc()) != ERROR_SUCCESS )
+ {
+ printf("InitializeRegistryForInproc failed %d.\n", RegStatus);
+ return FALSE;
+ }
+
+ if ( (RegStatus = InitializeRegistryForLocal()) != ERROR_SUCCESS )
+ {
+ printf("InitializeRegistryForLocal failed %d.\n", RegStatus);
+ return FALSE;
+ }
+
+ if ( (RegStatus = InitializeRegistryForCustom()) != ERROR_SUCCESS )
+ {
+ printf("InitializeRegistryForCustom failed %d.\n", RegStatus);
+ return FALSE;
+ }
+ #ifndef NO_DCOM
+ if ( (RegStatus = InitializeRegistryForRemote()) != ERROR_SUCCESS )
+ {
+ printf("InitializeRegistryForRemote failed %d.\n", RegStatus);
+ return FALSE;
+ }
+
+ if ( (RegStatus = InitializeRegistryForService()) != ERROR_SUCCESS )
+ {
+ printf("InitializeRegistryForService failed %d.\n", RegStatus);
+ return FALSE;
+ }
+ #endif // NO_DCOM
+ }
+ BOOL fAllTests = TRUE;
+
+ for (int x = MIN_TEST_NUMBER; x <= MAX_TEST_NUMBER; x++)
+ {
+ if (RunTest[x])
+ {
+ printf("\nTest %2d: %s\n",x, TestName[x]);
+ // prime the system once to ensure the test is fully cached
+ if (rgTest[x]())
+ {
+ printf("PASSED");
+ if (uIterations)
+ {
+ printf(" - ");
+ DUMP_CLOCK;
+ }
+ printf("\n");
+ }
+ else
+ {
+ printf("FAILED\n");
+ fAllTests = FALSE;
+ }
+
+ }
+ }
+
+ return(fAllTests);
+}
+
+void PrintUsageAndExit( BOOL bListTests )
+{
+#ifdef NO_DCOM
+ printf("Usage : %s [-hold] [-noreg] [-n #] [-t # [#]]\n", "actclt");
+ printf("\t-n # : Run specific number of timed iterations (default is 0).\n");
+ printf("\t-noreg : Don't update registry\n");
+ printf("\t-t # : Run specific test number or a range of tests.\n");
+ printf("\t-? : Print usage plus test descriptions.\n");
+#else
+ printf("Usage : %s [-hold] [-noreg] [[-local] | [-nolocal]] [-n #] [-t # [#]] [server_name]\n", "actclt");
+ printf("\t-hold : Hold the server up during all iterations.\n");
+ printf("\t-local : Run only local activation tests.\n");
+ printf("\t-n # : Run specific number of timed iterations (default is 0).\n");
+ printf("\t-nolocal : Run only remote activation tests.\n");
+ printf("\t-noreg : Don't update registry\n");
+ printf("\t-t # : Run specific test number or a range of tests.\n");
+ printf("\t-? : Print usage plus test descriptions.\n");
+#endif // NO_DCOM
+
+ if ( bListTests )
+ {
+ long n;
+
+ printf("\nTests :\n");
+ printf("\t # Method Location Security\n");
+ printf("\t-- ----------------------------------- ----------- --------------\n");
+
+ for ( n = MIN_TEST_NUMBER; n <= MAX_TEST_NUMBER; n++ )
+ {
+ printf("\t%2d %s\n", n, TestName[n]);
+ }
+ }
+
+ ExitThread(0);
+}
+
+void * __RPC_API
+MIDL_user_allocate(size_t len)
+{
+ return malloc(len);
+}
+
+void __RPC_API
+MIDL_user_free(void * vp)
+{
+ free(vp);
+}
+
+BOOL StampFileWithCLSID(WCHAR * szFilename, CLSID & clsid)
+{
+ HRESULT hr;
+ IStorage * pStg;
+
+ hr = StgCreateDocfile(
+ szFilename,
+ STGM_READWRITE | STGM_DIRECT | STGM_SHARE_EXCLUSIVE | STGM_CREATE,
+ 0,
+ &pStg);
+
+ if (FAILED (hr))
+ {
+ printf("StgCreateDocfile returned 0x%x\n", hr);
+ return(FALSE);
+ }
+
+ hr = WriteClassStg(pStg, clsid);
+
+ pStg->Release();
+
+ if (FAILED (hr))
+ {
+ printf("WriteClassStg returned 0x%x\n", hr);
+ return(FALSE);
+ }
+
+ return(TRUE);
+}
+
+//
+// Test Procedures:
+//
+
+BOOL UnimplementedTest()
+{
+ printf("Not implemented at this time.\n");
+ return(TRUE);
+}
+
+BOOL UnsupportedTest()
+{
+ printf("Not supported by this version.\n");
+ return(TRUE);
+}
+
+BOOL GenericCITest(REFCLSID clsid, REFIID iid, WCHAR * szServerName, int n, DWORD ctxt)
+{
+ COSERVERINFO ServerInfo;
+ COSERVERINFO *pServerInfo;
+ IUnknown * punkHeld = NULL;
+
+ if (szServerName)
+ {
+ memset( &ServerInfo, 0, sizeof(COSERVERINFO) );
+ ServerInfo.pwszName = szServerName;
+ pServerInfo = &ServerInfo;
+ }
+ else
+ {
+ pServerInfo = NULL;
+ }
+
+ MULTI_QI QIStruct[10];
+ int x;
+ HRESULT hr;
+ BOOL fReturn = TRUE;
+
+ START_LOOP;
+
+ for (x = n; x--;)
+ {
+ QIStruct[x].pItf = NULL;
+ QIStruct[x].pIID = (IID *) &iid;
+ }
+
+
+ START_CLOCK;
+ hr = CoCreateInstanceEx(
+ clsid,
+ NULL,
+ ctxt,
+ pServerInfo,
+ n,
+ QIStruct);
+ STOP_CLOCK;
+
+ if ( FAILED(hr) )
+ {
+ printf("CoCreateInstanceEx returned 0x%x\n", hr);
+ if (punkHeld)
+ punkHeld->Release();
+ return FALSE;
+ }
+
+ if (gfHoldServer && NULL == punkHeld && SUCCEEDED(QIStruct[0].hr))
+ {
+ punkHeld = QIStruct[0].pItf;
+ punkHeld->AddRef();
+ }
+
+ for (x = 0; x < n; x++)
+ {
+ if (FAILED(QIStruct[x].hr))
+ {
+ printf("CoCreateInstanceEx returned 0x%x for interface %d\n",
+ QIStruct[x].hr, x);
+ fReturn = FALSE;
+ }
+ else
+ QIStruct[x].pItf->Release();
+ }
+ if (!fReturn)
+ {
+ if (punkHeld)
+ punkHeld->Release();
+ return(fReturn);
+ }
+
+ STOP_LOOP;
+
+ if (punkHeld)
+ punkHeld->Release();
+
+ return fReturn;
+}
+
+BOOL CGCOLocalEXE()
+{
+ IClassFactory * pClassFactory;
+ IUnknown * pUnknown;
+ IUnknown * punkHeld = NULL;
+ HRESULT hr;
+
+ START_LOOP;
+
+ START_CLOCK;
+ hr = CoGetClassObject(
+ CLSID_ActLocal,
+ CLSCTX_LOCAL_SERVER,
+ NULL,
+ IID_IClassFactory,
+ (void **) &pClassFactory );
+ STOP_CLOCK;
+
+ if ( FAILED(hr) )
+ {
+ printf("CoGetClassObject returned 0x%x\n", hr);
+ if (punkHeld)
+ punkHeld->Release();
+ return FALSE;
+ }
+
+ hr = pClassFactory->CreateInstance( NULL,
+ IID_IUnknown,
+ (void **) &pUnknown );
+
+ pClassFactory->Release();
+
+ if ( FAILED(hr) )
+ {
+ printf("CreateInstance returned 0x%x\n", hr);
+ if (punkHeld)
+ punkHeld->Release();
+ return FALSE;
+ }
+
+ if (gfHoldServer && NULL == punkHeld)
+ {
+ punkHeld = pUnknown;
+ punkHeld->AddRef();
+ }
+
+ pUnknown->Release();
+
+ STOP_LOOP;
+
+ if (punkHeld)
+ punkHeld->Release();
+
+ return TRUE;
+}
+
+#ifndef NO_DCOM
+BOOL CGCOExplicitActivator()
+{
+ COSERVERINFO ServerInfo;
+
+ memset( &ServerInfo, 0, sizeof(COSERVERINFO) );
+ ServerInfo.pwszName = ServerName;
+
+ IClassFactory * pClassFactory;
+ IUnknown * pUnknown;
+ IUnknown * punkHeld = NULL;
+ HRESULT hr;
+
+ START_LOOP;
+
+ START_CLOCK;
+ hr = CoGetClassObject(
+ CLSID_ActLocal,
+ CLSCTX_REMOTE_SERVER,
+ &ServerInfo,
+ IID_IClassFactory,
+ (void **) &pClassFactory );
+ STOP_CLOCK;
+
+ if ( FAILED(hr) )
+ {
+ printf("CoGetClassObject returned 0x%x\n", hr);
+ if (punkHeld)
+ punkHeld->Release();
+ return FALSE;
+ }
+
+ hr = pClassFactory->CreateInstance( NULL,
+ IID_IUnknown,
+ (void **) &pUnknown );
+
+ pClassFactory->Release();
+
+ if ( FAILED(hr) )
+ {
+ printf("CreateInstance returned 0x%x\n", hr);
+ if (punkHeld)
+ punkHeld->Release();
+ return FALSE;
+ }
+
+ if (gfHoldServer && NULL == punkHeld)
+ {
+ punkHeld = pUnknown;
+ punkHeld->AddRef();
+ }
+
+ pUnknown->Release();
+
+ STOP_LOOP;
+
+ if (punkHeld)
+ punkHeld->Release();
+ return TRUE;
+}
+#endif // NO_DCOM
+
+#ifdef NO_DCOM
+BOOL CILocalDLL()
+{
+ IUnknown * pUnknown;
+ IUnknown * punkHeld = NULL;
+ HRESULT hr;
+
+ START_LOOP;
+
+ START_CLOCK;
+ hr = CoCreateInstance(
+ CLSID_ActInproc,
+ NULL,
+ CLSCTX_INPROC_SERVER,
+ IID_IUnknown,
+ (void **) &pUnknown );
+ STOP_CLOCK;
+
+ if ( FAILED(hr) )
+ {
+ printf("CoCreateInstance returned 0x%x\n", hr);
+ if (punkHeld)
+ punkHeld->Release();
+ return FALSE;
+ }
+
+ if (gfHoldServer && NULL == punkHeld)
+ {
+ punkHeld = pUnknown;
+ punkHeld->AddRef();
+ }
+
+ pUnknown->Release();
+
+ STOP_LOOP;
+
+ if (punkHeld)
+ punkHeld->Release();
+ return TRUE;
+}
+
+BOOL CILocalEXE()
+{
+ IUnknown * pUnknown;
+ IUnknown * punkHeld = NULL;
+ HRESULT hr;
+
+ START_LOOP;
+
+ START_CLOCK;
+ hr = CoCreateInstance(
+ CLSID_ActLocal,
+ NULL,
+ CLSCTX_LOCAL_SERVER,
+ IID_IUnknown,
+ (void **) &pUnknown );
+ STOP_CLOCK;
+
+ if ( FAILED(hr) )
+ {
+ printf("CoCreateInstance returned 0x%x\n", hr);
+ if (punkHeld)
+ punkHeld->Release();
+ return FALSE;
+ }
+
+ if (gfHoldServer && NULL == punkHeld)
+ {
+ punkHeld = pUnknown;
+ punkHeld->AddRef();
+ }
+
+ pUnknown->Release();
+
+ STOP_LOOP;
+
+ if (punkHeld)
+ punkHeld->Release();
+
+ return TRUE;
+}
+#else
+BOOL CILocalDLL()
+{
+ return GenericCITest(CLSID_ActInproc, IID_IUnknown, NULL, 1, CLSCTX_INPROC_SERVER);
+}
+
+BOOL CILocalEXE()
+{
+ return GenericCITest(CLSID_ActLocal, IID_IUnknown, NULL, 1, CLSCTX_LOCAL_SERVER);
+}
+
+BOOL CIExplicitActivator()
+{
+ return GenericCITest(CLSID_ActLocal, IID_IUnknown, ServerName, 1, CLSCTX_REMOTE_SERVER);
+}
+#endif // NO_DCOM
+
+#ifdef NO_DCOM
+// Pre-DCOM version of CI3LocalEXE which calls CoCreateInstance
+// once followed by 2 calls to QueryInterface
+// instead of calling CoCreateInstanceEx.
+BOOL CI3LocalEXE()
+{
+ IUnknown * pUnknown;
+ IUnknwon * punkHeld = NULL;
+ IPersist * pPersist;
+ IPersistFile * pPersistFile;
+
+ HRESULT hr;
+
+ START_LOOP;
+
+ START_CLOCK;
+ hr = CoCreateInstance(
+ CLSID_ActLocal,
+ NULL,
+ CLSCTX_LOCAL_SERVER,
+ IID_IUnknown,
+ (void **) &pUnknown );
+
+ if ( FAILED(hr) )
+ {
+ printf("CoCreateInstance returned 0x%x\n", hr);
+ if (punkHeld)
+ punkHeld->Release();
+ return FALSE;
+ }
+
+ if (gfHoldServer && NULL == punkHeld)
+ {
+ punkHeld = pUnknown;
+ punkHeld->AddRef();
+ }
+
+ pUnknown->QueryInterface( IID_IPersist, (void **)&pPersist );
+ pUnknown->QueryInterface( IID_IPersist, (void **)&pPersistFile );
+ STOP_CLOCK;
+
+ pUnknown->Release();
+ pPersist->Release();
+ pPersistFile->Release();
+
+ STOP_LOOP;
+
+ if (punkHeld)
+ punkHeld->Release();
+
+ return TRUE;
+}
+#else // NO_DCOM
+
+BOOL CI3LocalEXE()
+{
+ return GenericCITest(CLSID_ActLocal, IID_IPersist, NULL, 3, CLSCTX_LOCAL_SERVER);
+ /*
+ MULTI_QI QIStruct[3];
+ QIStruct[0].pIID = (IID *)&IID_IUnknown;
+ QIStruct[1].pIID = (IID *)&IID_IPersist;
+ QIStruct[2].pIID = (IID *)&IID_IPersistFile;
+ QIStruct[0].pItf = NULL;
+ QIStruct[1].pItf = NULL;
+ QIStruct[2].pItf = NULL;
+ */
+}
+
+BOOL CI3ExplicitActivator()
+{
+ return GenericCITest(CLSID_ActLocal, IID_IPersist, ServerName, 3, CLSCTX_REMOTE_SERVER);
+ /*
+ MULTI_QI QIStruct[3];
+ QIStruct[0].pIID = (IID *)&IID_IUnknown;
+ QIStruct[1].pIID = (IID *)&IID_IPersist;
+ QIStruct[2].pIID = (IID *)&IID_IPersistFile;
+ QIStruct[0].pItf = NULL;
+ QIStruct[1].pItf = NULL;
+ QIStruct[2].pItf = NULL;
+ */
+}
+
+BOOL CGIFFLocalEXE()
+{
+ MULTI_QI QIStruct[1];
+ IUnknown * punkHeld = NULL;
+
+ START_LOOP;
+
+ QIStruct[0].pIID = (IID *)&IID_IUnknown;
+ QIStruct[0].pItf = NULL;
+
+ START_CLOCK;
+ HRESULT HResult = CoGetInstanceFromFile(
+ NULL,
+ &CLSID_ActLocal,
+ NULL,
+ CLSCTX_LOCAL_SERVER,
+ STGM_READWRITE,
+ LocalFileName,
+ 1,
+ QIStruct );
+ STOP_CLOCK;
+
+ if ( FAILED(HResult) )
+ {
+ printf("CoGetInstanceFromFile returned 0x%x\n", HResult);
+ if (punkHeld)
+ punkHeld->Release();
+ return FALSE;
+ }
+
+ if (gfHoldServer && NULL == punkHeld)
+ {
+ punkHeld = QIStruct[0].pItf;
+ punkHeld->AddRef();
+ }
+
+ QIStruct[0].pItf->Release();
+
+ STOP_LOOP;
+
+ if (punkHeld)
+ punkHeld->Release();
+ return(TRUE);
+}
+
+BOOL CGIFFExplicitActivator()
+{
+ COSERVERINFO ServerInfo;
+ IUnknown * punkHeld = NULL;
+
+ memset( &ServerInfo, 0, sizeof(COSERVERINFO) );
+ ServerInfo.pwszName = ServerName;
+
+ MULTI_QI QIStruct[1];
+
+ START_LOOP;
+
+ QIStruct[0].pIID = (IID *)&IID_IUnknown;
+ QIStruct[0].pItf = NULL;
+
+ START_CLOCK;
+ HRESULT HResult = CoGetInstanceFromFile(
+ &ServerInfo,
+ &CLSID_ActLocal,
+ NULL,
+ CLSCTX_REMOTE_SERVER,
+ STGM_READWRITE,
+ RemoteFileName,
+ 1,
+ QIStruct );
+ STOP_CLOCK;
+
+ if ( FAILED(HResult) )
+ {
+ printf("CoGetInstanceFromFile returned 0x%x\n", HResult);
+ if (punkHeld)
+ punkHeld->Release();
+ return FALSE;
+ }
+
+ if (gfHoldServer && NULL == punkHeld)
+ {
+ punkHeld = QIStruct[0].pItf;
+ punkHeld->AddRef();
+ }
+
+ QIStruct[0].pItf->Release();
+
+ STOP_LOOP;
+
+ if (punkHeld)
+ punkHeld->Release();
+ return(TRUE);
+}
+
+BOOL CGIFFRegistryActivator()
+{
+ MULTI_QI QIStruct[1];
+ IUnknown * punkHeld = NULL;
+
+ START_LOOP;
+
+ QIStruct[0].pIID = (IID *)&IID_IUnknown;
+ QIStruct[0].pItf = NULL;
+ START_CLOCK;
+ HRESULT HResult = CoGetInstanceFromFile(
+ NULL,
+ &CLSID_ActRemote,
+ NULL,
+ CLSCTX_REMOTE_SERVER,
+ STGM_READWRITE,
+ RemoteFileName,
+ 1,
+ QIStruct );
+ STOP_CLOCK;
+
+ if ( FAILED(HResult) )
+ {
+ printf("CoGetInstanceFromFile returned 0x%x\n", HResult);
+ if (punkHeld)
+ punkHeld->Release();
+ return FALSE;
+ }
+
+ if (gfHoldServer && NULL == punkHeld)
+ {
+ punkHeld = QIStruct[0].pItf;
+ punkHeld->AddRef();
+ }
+
+ QIStruct[0].pItf->Release();
+
+ STOP_LOOP;
+
+ if (punkHeld)
+ punkHeld->Release();
+ return(TRUE);
+}
+
+BOOL CGIFFAtStorageActivator()
+{
+ MULTI_QI QIStruct[1];
+ IUnknown * punkHeld = NULL;
+
+ START_LOOP;
+
+ QIStruct[0].pIID = (IID *)&IID_IUnknown;
+ QIStruct[0].pItf = NULL;
+ START_CLOCK;
+ HRESULT HResult = CoGetInstanceFromFile(
+ NULL,
+ &CLSID_ActAtStorage,
+ NULL,
+ CLSCTX_REMOTE_SERVER,
+ STGM_READWRITE,
+ RemoteFileName,
+ 1,
+ QIStruct );
+ STOP_CLOCK;
+
+ if ( FAILED(HResult) )
+ {
+ printf("CoGetInstanceFromFile returned 0x%x\n", HResult);
+ if (punkHeld)
+ punkHeld->Release();
+ return FALSE;
+ }
+
+ if (gfHoldServer && NULL == punkHeld)
+ {
+ punkHeld = QIStruct[0].pItf;
+ punkHeld->AddRef();
+ }
+
+ QIStruct[0].pItf->Release();
+
+ STOP_LOOP;
+
+ if (punkHeld)
+ punkHeld->Release();
+ return(TRUE);
+}
+#endif // NO_DCOM
+
+BOOL IMBLocalEXE()
+{
+ IBindCtx * pBc;
+ IUnknown * pUnk;
+ IUnknown * punkHeld = NULL;
+ HRESULT hr;
+ IMoniker *pMon;
+
+ if (!StampFileWithCLSID(LocalFileName, CLSID_ActLocal))
+ {
+ return(FALSE);
+ }
+
+ hr = CreateFileMoniker(LocalFileName, &pMon);
+
+ if (FAILED(hr))
+ {
+ printf("CreateFileMoniker returned 0x%x\n", hr);
+ }
+
+ hr = CreateBindCtx(0, &pBc);
+
+ if (FAILED(hr))
+ {
+ printf("CreateBindCtx returned 0x%x\n", hr);
+ pMon->Release();
+ return(FALSE);
+ }
+
+ START_LOOP;
+
+ START_CLOCK;
+ hr = pMon->BindToObject(
+ pBc,
+ NULL,
+ IID_IUnknown,
+ (void **) &pUnk);
+ STOP_CLOCK;
+
+ if (FAILED(hr))
+ {
+ printf("IMoniker::BindToObject returned 0x%x\n", hr);
+ if (punkHeld)
+ punkHeld->Release();
+ return(FALSE);
+ }
+
+ if (gfHoldServer && NULL == punkHeld)
+ {
+ punkHeld = pUnk;
+ punkHeld->AddRef();
+ }
+
+ pUnk->Release();
+
+ STOP_LOOP
+
+ pMon->Release();
+ pBc->Release();
+
+ if (punkHeld)
+ punkHeld->Release();
+ return(TRUE);
+}
+
+#ifndef NO_DCOM
+BOOL IMBLocalService()
+{
+ IBindCtx * pBc;
+ IUnknown * pUnk;
+ IUnknown * punkHeld = NULL;
+ HRESULT hr;
+ IMoniker *pMon;
+
+ if (!StampFileWithCLSID(LocalFileName, CLSID_ActService))
+ {
+ return(FALSE);
+ }
+
+ hr = CreateFileMoniker(LocalFileName, &pMon);
+
+ if (FAILED(hr))
+ {
+ printf("CreateFileMoniker returned 0x%x\n", hr);
+ }
+
+ hr = CreateBindCtx(0, &pBc);
+
+ if (FAILED(hr))
+ {
+ printf("CreateBindCtx returned 0x%x\n", hr);
+ pMon->Release();
+ return(FALSE);
+ }
+
+ START_LOOP;
+
+ START_CLOCK;
+ hr = pMon->BindToObject(
+ pBc,
+ NULL,
+ IID_IUnknown,
+ (void **) &pUnk);
+ STOP_CLOCK;
+ if (FAILED(hr))
+ {
+ printf("IMoniker::BindToObject returned 0x%x\n", hr);
+ if (punkHeld)
+ punkHeld->Release();
+ return(FALSE);
+ }
+
+ if (gfHoldServer && NULL == punkHeld)
+ {
+ punkHeld = pUnk;
+ punkHeld->AddRef();
+ }
+ pUnk->Release();
+
+ SLEEP_IF_LOOPING;
+
+ STOP_LOOP;
+
+ pMon->Release();
+ pBc->Release();
+
+ if (punkHeld)
+ punkHeld->Release();
+ return(TRUE);
+}
+
+BOOL IMBAtStorageActivator()
+{
+ IBindCtx * pBc;
+ IUnknown * pUnk;
+ IUnknown * punkHeld = NULL;
+ HRESULT hr;
+ IMoniker *pMon;
+
+ if (!StampFileWithCLSID(RemoteFileName, CLSID_ActAtStorage))
+ {
+ return(FALSE);
+ }
+
+ hr = CreateFileMoniker(RemoteFileName, &pMon);
+
+ if (FAILED(hr))
+ {
+ printf("CreateFileMoniker returned 0x%x\n", hr);
+ }
+
+ hr = CreateBindCtx(0, &pBc);
+
+ if (FAILED(hr))
+ {
+ printf("CreateBindCtx returned 0x%x\n", hr);
+ pMon->Release();
+ return(FALSE);
+ }
+
+ START_LOOP;
+
+ START_CLOCK;
+ hr = pMon->BindToObject(
+ pBc,
+ NULL,
+ IID_IUnknown,
+ (void **) &pUnk);
+ STOP_CLOCK;
+
+ if (FAILED(hr))
+ {
+ printf("IMoniker::BindToObject returned 0x%x\n", hr);
+ if (punkHeld)
+ punkHeld->Release();
+ return(FALSE);
+ }
+
+ if (gfHoldServer && NULL == punkHeld)
+ {
+ punkHeld = pUnk;
+ punkHeld->AddRef();
+ }
+
+ pUnk->Release();
+
+ STOP_LOOP;
+
+ pMon->Release();
+ pBc->Release();
+
+ if (punkHeld)
+ punkHeld->Release();
+ return(TRUE);
+}
+
+BOOL IMBAtStorageService()
+{
+ IBindCtx * pBc;
+ IUnknown * pUnk;
+ IUnknown * punkHeld = NULL;
+ HRESULT hr;
+ IMoniker *pMon;
+
+ if (!StampFileWithCLSID(RemoteFileName, CLSID_ActService))
+ {
+ return(FALSE);
+ }
+
+ hr = CreateFileMoniker(RemoteFileName, &pMon);
+
+ if (FAILED(hr))
+ {
+ printf("CreateFileMoniker returned 0x%x\n", hr);
+ }
+
+ hr = CreateBindCtx(0, &pBc);
+
+ if (FAILED(hr))
+ {
+ printf("CreateBindCtx returned 0x%x\n", hr);
+ pMon->Release();
+ return(FALSE);
+ }
+
+ START_LOOP;
+
+ START_CLOCK;
+ hr = pMon->BindToObject(
+ pBc,
+ NULL,
+ IID_IUnknown,
+ (void **) &pUnk);
+ STOP_CLOCK;
+
+ if (FAILED(hr))
+ {
+ printf("IMoniker::BindToObject returned 0x%x\n", hr);
+ if (punkHeld)
+ punkHeld->Release();
+ return(FALSE);
+ }
+
+ if (gfHoldServer && NULL == punkHeld)
+ {
+ punkHeld = pUnk;
+ punkHeld->AddRef();
+ }
+
+ pUnk->Release();
+
+ SLEEP_IF_LOOPING;
+
+ STOP_LOOP;
+
+ pMon->Release();
+ pBc->Release();
+
+ if (punkHeld)
+ punkHeld->Release();
+ return(TRUE);
+}
+
+BOOL IMBAtStoragePreCon()
+{
+ IBindCtx * pBc;
+ IUnknown * pUnk;
+ IUnknown * punkHeld = NULL;
+ HRESULT hr;
+ IMoniker *pMon;
+
+ if (!StampFileWithCLSID(RemoteFileName, CLSID_ActPreConfig))
+ {
+ return(FALSE);
+ }
+
+ hr = CreateFileMoniker(RemoteFileName, &pMon);
+
+ if (FAILED(hr))
+ {
+ printf("CreateFileMoniker returned 0x%x\n", hr);
+ }
+
+ hr = CreateBindCtx(0, &pBc);
+
+ if (FAILED(hr))
+ {
+ printf("CreateBindCtx returned 0x%x\n", hr);
+ pMon->Release();
+ return(FALSE);
+ }
+
+ START_LOOP;
+
+ START_CLOCK;
+ hr = pMon->BindToObject(
+ pBc,
+ NULL,
+ IID_IUnknown,
+ (void **) &pUnk);
+ STOP_CLOCK;
+
+ if (FAILED(hr))
+ {
+ printf("IMoniker::BindToObject returned 0x%x\n", hr);
+ if (punkHeld)
+ punkHeld->Release();
+ return(FALSE);
+ }
+
+ if (gfHoldServer && NULL == punkHeld)
+ {
+ punkHeld = pUnk;
+ punkHeld->AddRef();
+ }
+
+ pUnk->Release();
+
+ STOP_LOOP;
+
+ pMon->Release();
+ pBc->Release();
+
+ if (punkHeld)
+ punkHeld->Release();
+ return(TRUE);
+}
+
+BOOL IMBAtStorageUser()
+{
+ IBindCtx * pBc;
+ IUnknown * pUnk;
+ IUnknown * punkHeld = NULL;
+ HRESULT hr;
+ IMoniker *pMon;
+
+ if (!StampFileWithCLSID(RemoteFileName, CLSID_ActRunAsLoggedOn))
+ {
+ return(FALSE);
+ }
+
+ hr = CreateFileMoniker(RemoteFileName, &pMon);
+
+ if (FAILED(hr))
+ {
+ printf("CreateFileMoniker returned 0x%x\n", hr);
+ }
+
+ hr = CreateBindCtx(0, &pBc);
+
+ if (FAILED(hr))
+ {
+ printf("CreateBindCtx returned 0x%x\n", hr);
+ pMon->Release();
+ return(FALSE);
+ }
+
+ START_LOOP;
+
+ START_CLOCK;
+ hr = pMon->BindToObject(
+ pBc,
+ NULL,
+ IID_IUnknown,
+ (void **) &pUnk);
+ STOP_CLOCK;
+
+ if (FAILED(hr))
+ {
+ printf("IMoniker::BindToObject returned 0x%x\n", hr);
+ if (punkHeld)
+ punkHeld->Release();
+ return(FALSE);
+ }
+
+ if (gfHoldServer && NULL == punkHeld)
+ {
+ punkHeld = pUnk;
+ punkHeld->AddRef();
+ }
+
+ pUnk->Release();
+
+ STOP_LOOP;
+
+ pMon->Release();
+ pBc->Release();
+
+ if (punkHeld)
+ punkHeld->Release();
+ return(TRUE);
+}
+
+BOOL CIFromStgLocalEXE()
+{
+ IStorage * pStorage;
+ MULTI_QI QIStruct[10];
+ IUnknown * punkHeld = NULL;
+
+ pStorage = 0;
+
+ DeleteFile( StorageName );
+
+ HRESULT HResult = StgCreateDocfile(
+ StorageName,
+ STGM_READWRITE | STGM_DIRECT | STGM_SHARE_EXCLUSIVE | STGM_CREATE,
+ 0,
+ &pStorage );
+
+ if ( FAILED(HResult) )
+ {
+ printf("StgCreateDocfile returned 0x%x\n", HResult);
+ return FALSE;
+ }
+
+ START_LOOP;
+
+ QIStruct[0].pIID = (IID *)&IID_IUnknown;
+ QIStruct[0].pItf = NULL;
+
+ START_CLOCK;
+ HResult = CoGetInstanceFromIStorage(
+ NULL,
+ &CLSID_ActLocal,
+ NULL,
+ CLSCTX_SERVER,
+ pStorage,
+ 1,
+ QIStruct );
+ STOP_CLOCK;
+
+ if ( FAILED(HResult) )
+ {
+ printf("CoGetInstanceFromIStorage returned 0x%x\n", HResult);
+ if (punkHeld)
+ punkHeld->Release();
+ return FALSE;
+ }
+
+ if (gfHoldServer && NULL == punkHeld)
+ {
+ punkHeld = QIStruct[0].pItf;
+ punkHeld->AddRef();
+ }
+
+ QIStruct[0].pItf->Release();
+ QIStruct[0].pItf = 0;
+
+ STOP_LOOP;
+
+ pStorage->Release();
+
+ if (punkHeld)
+ punkHeld->Release();
+ return(TRUE);
+}
+
+BOOL CIFromStgActivator()
+{
+ IStorage * pStorage;
+ MULTI_QI QIStruct[10];
+ COSERVERINFO ServerInfo;
+ IUnknown * punkHeld = NULL;
+
+ memset( &ServerInfo, 0, sizeof(COSERVERINFO) );
+ ServerInfo.pwszName = ServerName;
+
+ pStorage = 0;
+
+ DeleteFile( StorageName );
+
+ HRESULT HResult = StgCreateDocfile(
+ StorageName,
+ STGM_READWRITE | STGM_DIRECT | STGM_SHARE_EXCLUSIVE | STGM_CREATE,
+ 0,
+ &pStorage );
+
+ if ( FAILED(HResult) )
+ {
+ printf("StgCreateDocfile returned 0x%x\n", HResult);
+ return FALSE;
+ }
+
+ START_LOOP;
+
+ QIStruct[0].pIID = (IID *)&IID_IUnknown;
+ QIStruct[0].pItf = NULL;
+
+ START_CLOCK;
+ HResult = CoGetInstanceFromIStorage(
+ &ServerInfo,
+ &CLSID_ActRemote,
+ NULL,
+ CLSCTX_REMOTE_SERVER,
+ pStorage,
+ 1,
+ QIStruct );
+ STOP_CLOCK;
+
+ if ( FAILED(HResult) )
+ {
+ printf("CoGetInstanceFromIStorage returned 0x%x\n", HResult);
+ if (punkHeld)
+ punkHeld->Release();
+ return FALSE;
+ }
+
+ if (gfHoldServer && NULL == punkHeld)
+ {
+ punkHeld = QIStruct[0].pItf;
+ punkHeld->AddRef();
+ }
+
+ QIStruct[0].pItf->Release();
+ QIStruct[0].pItf = 0;
+
+ STOP_LOOP;
+
+ pStorage->Release();
+
+ if (punkHeld)
+ punkHeld->Release();
+ return(TRUE);
+}
+
+BOOL CICustomLocalDLL()
+{
+ IGoober * pGoober;
+ MULTI_QI QIStruct[10];
+ HRESULT hr;
+ IUnknown * punkHeld = NULL;
+
+ START_LOOP;
+
+ QIStruct[0].pItf = NULL;
+ QIStruct[0].pIID = (IID *) &IID_IGoober;
+
+ START_CLOCK;
+ hr = CoCreateInstanceEx(
+ CLSID_ActInproc,
+ NULL,
+ CLSCTX_INPROC_SERVER,
+ NULL,
+ 1,
+ QIStruct );
+ STOP_CLOCK;
+
+ pGoober = (IGoober *)QIStruct[0].pItf;
+
+ if ( FAILED(hr) )
+ {
+ printf("CoCreateInstanceEx returned 0x%x\n", hr);
+ if (punkHeld)
+ punkHeld->Release();
+ return FALSE;
+ }
+
+ if (gfHoldServer && NULL == punkHeld)
+ {
+ punkHeld = QIStruct[0].pItf;
+ punkHeld->AddRef();
+ }
+
+ START_CLOCK;
+ hr = pGoober->Ping();
+ STOP_CLOCK;
+
+ if ( hr != S_OK )
+ {
+ printf("IGoober::Ping returned %d\n", hr);
+ pGoober->Release();
+ if (punkHeld)
+ punkHeld->Release();
+ return FALSE;
+ }
+
+ pGoober->Release();
+
+ STOP_LOOP;
+
+ if (punkHeld)
+ punkHeld->Release();
+ return(TRUE);
+}
+
+BOOL CICustomLocalEXE()
+{
+ IGoober * pGoober;
+ MULTI_QI QIStruct[10];
+ HRESULT hr;
+ IUnknown * punkHeld = NULL;
+
+ START_LOOP;
+
+ QIStruct[0].pItf = NULL;
+ QIStruct[0].pIID = (IID *) &IID_IGoober;
+
+ START_CLOCK;
+ hr = CoCreateInstanceEx(
+ CLSID_ActLocal,
+ NULL,
+ CLSCTX_LOCAL_SERVER,
+ NULL,
+ 1,
+ QIStruct );
+ STOP_CLOCK;
+
+ pGoober = (IGoober *)QIStruct[0].pItf;
+
+ if ( FAILED(hr) )
+ {
+ printf("CoCreateInstanceEx returned 0x%x\n", hr);
+ if (punkHeld)
+ punkHeld->Release();
+ return FALSE;
+ }
+
+ if (gfHoldServer && NULL == punkHeld)
+ {
+ punkHeld = QIStruct[0].pItf;
+ punkHeld->AddRef();
+ }
+
+ START_CLOCK;
+ hr = pGoober->Ping();
+ STOP_CLOCK;
+
+ if ( hr != S_OK )
+ {
+ printf("IGoober::Ping returned %d\n", hr);
+ pGoober->Release();
+ if (punkHeld)
+ punkHeld->Release();
+ return FALSE;
+ }
+
+ pGoober->Release();
+
+ STOP_LOOP;
+
+ if (punkHeld)
+ punkHeld->Release();
+ return(TRUE);
+}
+
+BOOL CILocalPreCon()
+{
+ return GenericCITest(CLSID_ActPreConfig, IID_IUnknown, NULL, 1, CLSCTX_LOCAL_SERVER);
+}
+
+BOOL CIExplicitPreCon()
+{
+ return GenericCITest(CLSID_ActPreConfig, IID_IUnknown, ServerName, 1, CLSCTX_REMOTE_SERVER);
+}
+
+BOOL CILocalUser()
+{
+ return GenericCITest(CLSID_ActRunAsLoggedOn, IID_IUnknown, NULL, 1, CLSCTX_LOCAL_SERVER);
+}
+
+BOOL CIExplicitUser()
+{
+ return GenericCITest(CLSID_ActRunAsLoggedOn, IID_IUnknown, ServerName, 1, CLSCTX_REMOTE_SERVER);
+}
+
+BOOL CILocalService()
+{
+ COSERVERINFO ServerInfo;
+ COSERVERINFO *pServerInfo;
+ IUnknown * punkHeld = NULL;
+
+ MULTI_QI QIStruct[1];
+ HRESULT hr;
+ BOOL fReturn = TRUE;
+
+ START_LOOP;
+
+ QIStruct[0].pItf = NULL;
+ QIStruct[0].pIID = (IID *) &IID_IUnknown;
+
+ START_CLOCK;
+ hr = CoCreateInstanceEx(
+ CLSID_ActService,
+ NULL,
+ CLSCTX_LOCAL_SERVER,
+ NULL,
+ 1,
+ QIStruct);
+ STOP_CLOCK;
+
+ if ( FAILED(hr) )
+ {
+ printf("CoCreateInstanceEx returned 0x%x\n", hr);
+ if (punkHeld)
+ punkHeld->Release();
+ return FALSE;
+ }
+
+ if (gfHoldServer && NULL == punkHeld && SUCCEEDED(QIStruct[0].hr))
+ {
+ punkHeld = QIStruct[0].pItf;
+ punkHeld->AddRef();
+ }
+
+ if (FAILED(QIStruct[0].hr))
+ {
+ printf("CoCreateInstanceEx returned 0x%x\n",
+ QIStruct[0].hr);
+ fReturn = FALSE;
+ }
+ else
+ QIStruct[0].pItf->Release();
+
+ if (!fReturn)
+ {
+ if (punkHeld)
+ punkHeld->Release();
+ return(fReturn);
+ }
+
+ SLEEP_IF_LOOPING;
+
+ STOP_LOOP;
+
+ if (punkHeld)
+ punkHeld->Release();
+
+ return fReturn;
+}
+
+BOOL CIExplicitService()
+{
+ COSERVERINFO ServerInfo;
+ COSERVERINFO *pServerInfo;
+ IUnknown * punkHeld = NULL;
+
+ memset( &ServerInfo, 0, sizeof(COSERVERINFO) );
+ ServerInfo.pwszName = ServerName;
+ pServerInfo = &ServerInfo;
+
+ MULTI_QI QIStruct[1];
+ HRESULT hr;
+ BOOL fReturn = TRUE;
+
+ START_LOOP;
+
+ QIStruct[0].pItf = NULL;
+ QIStruct[0].pIID = (IID *) &IID_IUnknown;
+
+ START_CLOCK;
+ hr = CoCreateInstanceEx(
+ CLSID_ActService,
+ NULL,
+ CLSCTX_REMOTE_SERVER,
+ pServerInfo,
+ 1,
+ QIStruct);
+ STOP_CLOCK;
+
+ if ( FAILED(hr) )
+ {
+ printf("CoCreateInstanceEx returned 0x%x\n", hr);
+ if (punkHeld)
+ punkHeld->Release();
+ return FALSE;
+ }
+
+ if (gfHoldServer && NULL == punkHeld && SUCCEEDED(QIStruct[0].hr))
+ {
+ punkHeld = QIStruct[0].pItf;
+ punkHeld->AddRef();
+ }
+
+ if (FAILED(QIStruct[0].hr))
+ {
+ printf("CoCreateInstanceEx returned 0x%x\n",
+ QIStruct[0].hr);
+ fReturn = FALSE;
+ }
+ else
+ QIStruct[0].pItf->Release();
+
+ if (!fReturn)
+ {
+ if (punkHeld)
+ punkHeld->Release();
+ return(fReturn);
+ }
+
+ SLEEP_IF_LOOPING;
+
+ STOP_LOOP;
+
+ if (punkHeld)
+ punkHeld->Release();
+
+ return fReturn;
+}
+
+BOOL CILocalPreConACL();
+BOOL CIExplicitPreConACL();
+
+#define MAX_SERVICE_ARGS 10
+
+BOOL MyStartService(WCHAR * wszServiceName, WCHAR *pwszRegServiceArgs)
+{
+ SC_HANDLE hSCManager;
+ SC_HANDLE hService;
+ WCHAR *pwszServiceArgs = NULL;
+ ULONG cArgs = 0;
+ WCHAR *apwszArgs[MAX_SERVICE_ARGS];
+
+ // Get a handle to the Service Control Manager
+ if (hSCManager = OpenSCManager(NULL, NULL, GENERIC_EXECUTE | SERVICE_QUERY_STATUS ))
+ {
+ // Open a handle to the requested service
+ if (hService = OpenService(hSCManager, wszServiceName, GENERIC_EXECUTE | SERVICE_QUERY_STATUS ))
+ {
+ // Close the service manager's database
+ CloseServiceHandle(hSCManager);
+
+ // Formulate the arguments (if any)
+ if (pwszRegServiceArgs)
+ {
+ UINT k = 0;
+
+ // Make a copy of the service arguments
+ pwszServiceArgs = new WCHAR[(lstrlenW(pwszRegServiceArgs) + 1)];
+ if (pwszServiceArgs == NULL)
+ {
+ CloseServiceHandle(hService);
+ return FALSE;
+ }
+ lstrcpyW(pwszServiceArgs, pwszRegServiceArgs);
+
+ // Scan the arguments
+ do
+ {
+ // Scan to the next non-whitespace character
+ while(pwszServiceArgs[k] &&
+ (pwszServiceArgs[k] == L' ' ||
+ pwszServiceArgs[k] == L'\t'))
+ {
+ k++;
+ }
+
+ // Store the next argument
+ if (pwszServiceArgs[k])
+ {
+ apwszArgs[cArgs++] = &pwszServiceArgs[k];
+ }
+
+ // Scan to the next whitespace char
+ while(pwszServiceArgs[k] &&
+ pwszServiceArgs[k] != L' ' &&
+ pwszServiceArgs[k] != L'\t')
+ {
+ k++;
+ }
+
+ // Null terminate the previous argument
+ if (pwszServiceArgs[k])
+ {
+ pwszServiceArgs[k++] = L'\0';
+ }
+ } while(pwszServiceArgs[k]);
+ }
+
+ // Start the service
+ if (StartService(hService, cArgs,
+ cArgs > 0 ? (LPCTSTR *) apwszArgs : NULL))
+ {
+ SERVICE_STATUS ss;
+ do
+ {
+ QueryServiceStatus(hService, &ss);
+ if (dwWaitHint)
+ {
+ Sleep(dwWaitHint);
+ }
+ else
+ Sleep(ss.dwWaitHint);
+ } while (ss.dwCurrentState == SERVICE_START_PENDING);
+
+ CloseServiceHandle(hService);
+ delete [] pwszServiceArgs;
+ return TRUE;
+ }
+ else
+ {
+ CloseServiceHandle(hService);
+ delete [] pwszServiceArgs;
+ }
+ }
+ else
+ {
+ CloseServiceHandle(hSCManager);
+ }
+ }
+
+ DWORD err = GetLastError();
+ return FALSE;
+}
+
+BOOL MyStopService(WCHAR * wszServiceName)
+{
+ SC_HANDLE hSCManager;
+ SC_HANDLE hService;
+ SERVICE_STATUS ss;
+
+ // Get a handle to the Service Control Manager
+ if (hSCManager = OpenSCManager(NULL, NULL, GENERIC_EXECUTE | SERVICE_QUERY_STATUS ))
+ {
+ // Open a handle to the requested service
+ if (hService = OpenService(hSCManager, wszServiceName, GENERIC_EXECUTE | SERVICE_QUERY_STATUS ))
+ {
+ // Close the service manager's database
+ CloseServiceHandle(hSCManager);
+
+ // Stop the service
+ if (ControlService(hService, SERVICE_CONTROL_STOP, &ss))
+ {
+
+ while (ss.dwCurrentState == SERVICE_STOP_PENDING)
+ {
+ if (dwWaitHint)
+ {
+ Sleep(dwWaitHint);
+ }
+ else
+ Sleep(ss.dwWaitHint);
+ QueryServiceStatus(hService, &ss);
+ };
+
+ CloseServiceHandle(hService);
+ return TRUE;
+ }
+ else
+ {
+ CloseServiceHandle(hService);
+ }
+ }
+ else
+ {
+ CloseServiceHandle(hSCManager);
+ }
+ }
+
+ DWORD err = GetLastError();
+ return FALSE;
+}
+
+#endif // NO_DCOM
diff --git a/private/oleutest/act/tstsvc/client.hxx b/private/oleutest/act/tstsvc/client.hxx
new file mode 100644
index 000000000..6ce43a62a
--- /dev/null
+++ b/private/oleutest/act/tstsvc/client.hxx
@@ -0,0 +1,38 @@
+/*
+ * client.hxx
+ */
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <windows.h>
+#include <rpc.h>
+#include <ole2.h>
+#include <oleext.h>
+#include "..\acttest.h"
+#include "..\dll\goober.h"
+
+// To build performance tests for pre-DCOM systems
+// uncomment the following line.
+//#define NO_DCOM
+
+typedef unsigned long ulong;
+typedef unsigned char uchar;
+#define NO 0
+#define YES 1
+
+typedef BOOL (* LPTESTFUNC) (void);
+
+DWORD InstallService(WCHAR * Path);
+
+extern WCHAR ServerName[32];
+
+void PrintUsageAndExit( BOOL bListTests );
+long InitializeRegistryForLocal();
+long InitializeRegistryForInproc();
+long InitializeRegistryForCustom();
+long InitializeRegistryForRemote();
+long InitializeRegistryForService();
+
+BOOL Tests();
+
+
diff --git a/private/oleutest/act/tstsvc/daytona/makefile b/private/oleutest/act/tstsvc/daytona/makefile
new file mode 100644
index 000000000..5acbbd24c
--- /dev/null
+++ b/private/oleutest/act/tstsvc/daytona/makefile
@@ -0,0 +1 @@
+!INCLUDE $(NTMAKEENV)\makefile.def
diff --git a/private/oleutest/act/tstsvc/daytona/sources b/private/oleutest/act/tstsvc/daytona/sources
new file mode 100644
index 000000000..8b3f29902
--- /dev/null
+++ b/private/oleutest/act/tstsvc/daytona/sources
@@ -0,0 +1,77 @@
+!IF 0
+
+Copyright (c) 1989 Microsoft Corporation
+
+Module Name:
+
+ sources.
+
+Abstract:
+
+ This file specifies the target component being built and the list of
+ sources files needed to build that component. Also specifies optional
+ compiler switches and libraries that are unique for the component being
+ built.
+
+
+Author:
+
+ Steve Wood (stevewo) 12-Apr-1989
+
+
+Revision History:
+ Modified by Steve Blanding 15-Jan 1996 for DCOM performance tests
+
+!ENDIF
+
+#
+# The TARGETNAME variable is defined by the developer. It is the name of
+# the target (component) that is being built by this makefile. It
+# should NOT include any path or file extension information.
+#
+
+TARGETNAME=tstsvc
+
+#
+# The TARGETPATH and TARGETTYPE varialbes are defined by the developer.
+# The first specifies where the target is to be build. The second specifies
+# the type of target (either PROGRAM, DYNLINK or LIBRARY)
+#
+
+TARGETPATH=.
+TARGETTYPE=PROGRAM
+
+#
+# The INCLUDES variable specifies any include paths that are specific to
+# this source directory. Separate multiple directory paths with single
+# semicolons. Relative path specifications are okay.
+#
+
+INCLUDES=.
+
+#
+# The SOURCES variable is defined by the developer. It is a list of all the
+# source files for this component. Each source file should be on a separate
+# line using the line continuation character. This will minimize merge
+# conflicts if two developers adding source files to the same component.
+#
+
+SOURCES=\
+ ..\client.cxx \
+ ..\pswrd.cxx \
+ ..\reg.cxx
+
+C_DEFINES=-DUNICODE
+
+LINKLIBS=\
+ $(BASEDIR)\public\sdk\lib\*\kernel32.lib \
+ $(BASEDIR)\public\sdk\lib\*\user32.lib \
+ $(BASEDIR)\public\sdk\lib\*\advapi32.lib \
+ $(BASEDIR)\public\sdk\lib\*\ntdll.lib \
+ $(BASEDIR)\public\sdk\lib\*\ole32.lib \
+ $(BASEDIR)\public\sdk\lib\*\rpcrt4.lib \
+ $(BASEDIR)\public\sdk\lib\*\uuid.lib \
+ $(BASEDIR)\public\sdk\lib\*\mpr.lib \
+ ..\..\common\*\common.lib
+
+UMTYPE=console
diff --git a/private/oleutest/act/tstsvc/dirs b/private/oleutest/act/tstsvc/dirs
new file mode 100644
index 000000000..35b6c7372
--- /dev/null
+++ b/private/oleutest/act/tstsvc/dirs
@@ -0,0 +1,27 @@
+!IF 0
+
+Copyright (c) 1989 Microsoft Corporation
+
+Module Name:
+
+ dirs.
+
+Abstract:
+
+ This file specifies the subdirectories of the current directory that
+ contain component makefiles.
+
+
+Author:
+
+ Steve Wood (stevewo) 17-Apr-1990
+
+NOTE: Commented description of this file is in \nt\bak\bin\dirs.tpl
+
+!ENDIF
+
+DIRS=
+
+OPTIONAL_DIRS=\
+ daytona \
+
diff --git a/private/oleutest/act/tstsvc/pswrd.cxx b/private/oleutest/act/tstsvc/pswrd.cxx
new file mode 100644
index 000000000..d504539b7
--- /dev/null
+++ b/private/oleutest/act/tstsvc/pswrd.cxx
@@ -0,0 +1,56 @@
+extern "C"
+{
+#include <nt.h>
+#include <ntrtl.h>
+#include <nturtl.h>
+#include <ntlsa.h>
+}
+#include <stdarg.h>
+#include <windef.h>
+#include <winbase.h>
+#include <winnls.h>
+#include <stdio.h>
+
+BOOL SetPassword(WCHAR * szCID, WCHAR * szPw)
+{
+ LSA_OBJECT_ATTRIBUTES sObjAttributes;
+ LSA_HANDLE hPolicy;
+ LSA_UNICODE_STRING sKey;
+ LSA_UNICODE_STRING sPassword;
+ WCHAR szKey[256];
+
+ swprintf(szKey, L"SCM:%s", szCID);
+ sKey.Length = (wcslen(szKey) + 1) * sizeof(WCHAR);
+ sKey.MaximumLength = (wcslen(szKey) + 1) * sizeof(WCHAR);
+ sKey.Buffer = szKey;
+ sPassword.Length = (wcslen(szPw) + 1) * sizeof(WCHAR);
+ sPassword.MaximumLength = 80 * sizeof(WCHAR);
+ sPassword.Buffer = szPw;
+
+ InitializeObjectAttributes(&sObjAttributes, NULL, 0L, NULL, NULL);
+
+ // open the local security policy
+ if (!NT_SUCCESS(
+ LsaOpenPolicy(
+ NULL,
+ &sObjAttributes,
+ POLICY_CREATE_SECRET,
+ &hPolicy)))
+ {
+ printf("LsaOpenPolicy failed with %d\n",GetLastError());
+ return(FALSE);
+ }
+
+ // store private data
+ if (!NT_SUCCESS(
+ LsaStorePrivateData(hPolicy, &sKey, &sPassword)))
+ {
+ printf("LsaStorePrivateData failed with %d\n",GetLastError());
+ return(FALSE);
+ }
+
+ LsaClose(hPolicy);
+ return(TRUE);
+}
+
+
diff --git a/private/oleutest/act/tstsvc/reg.cxx b/private/oleutest/act/tstsvc/reg.cxx
new file mode 100644
index 000000000..74cc6e4a1
--- /dev/null
+++ b/private/oleutest/act/tstsvc/reg.cxx
@@ -0,0 +1,859 @@
+//
+// reg.cxx
+//
+
+#include "client.hxx"
+
+BOOL SetPassword(WCHAR * szCID, WCHAR * szPw);
+
+WCHAR * ServiceName = L"ActTestService";
+WCHAR * ServiceDisplayName = L"ActTestService";
+WCHAR * UserName = L"redmond\\oleuser";
+WCHAR * Password = L"stocksplit";
+
+long InitializeRegistryForLocal()
+{
+ SYSTEM_INFO SystemInfo;
+ long RegStatus;
+ ulong Disposition;
+ HKEY hInterface;
+ HKEY hClsidKey;
+ HKEY hActKey;
+ HKEY hActValueKey;
+ WCHAR Path[256];
+
+ //
+ // Get CLASSES_ROOT.
+ //
+ RegStatus = RegOpenKeyEx( HKEY_CLASSES_ROOT,
+ L"CLSID",
+ 0,
+ KEY_ALL_ACCESS,
+ &hClsidKey );
+
+ if ( RegStatus != ERROR_SUCCESS )
+ return RegStatus;
+
+ //
+ // Local CLSID entries.
+ //
+
+ RegStatus = RegCreateKeyEx(
+ hClsidKey,
+ ClsidActLocalString,
+ 0,
+ L"REG_SZ",
+ REG_OPTION_NON_VOLATILE,
+ KEY_ALL_ACCESS,
+ NULL,
+ &hActKey,
+ &Disposition );
+
+ if ( RegStatus != ERROR_SUCCESS )
+ return RegStatus;
+
+ RegStatus = RegCreateKeyEx(
+ hActKey,
+ L"LocalServer32",
+ 0,
+ L"REG_SZ",
+ REG_OPTION_NON_VOLATILE,
+ KEY_ALL_ACCESS,
+ NULL,
+ &hActValueKey,
+ &Disposition );
+
+ if ( RegStatus != ERROR_SUCCESS )
+ return RegStatus;
+
+ if ( ! GetModuleFileName( 0, Path, sizeof(Path) ) )
+ return RegStatus;
+
+ _wcslwr( Path );
+ wcscpy( wcsstr( Path, L"actclt" ), L"actsrv.exe 2" );
+
+ RegStatus = RegSetValueEx(
+ hActValueKey,
+ L"",
+ 0,
+ REG_SZ,
+ (const BYTE *)Path,
+ (wcslen(Path) + 1) * sizeof(WCHAR) );
+
+ if ( RegStatus != ERROR_SUCCESS )
+ return RegStatus;
+
+ RegStatus = RegSetValueEx(
+ hClsidKey,
+ L"AppID",
+ 0,
+ REG_SZ,
+ (const BYTE *) ClsidActLocalString,
+ (wcslen(ClsidActLocalString)+1)*sizeof(WCHAR));
+
+ if ( RegStatus != ERROR_SUCCESS )
+ return RegStatus;
+
+ RegStatus = SetAppIDSecurity( ClsidActLocalString );
+
+ if ( RegStatus != ERROR_SUCCESS )
+ return RegStatus;
+
+ return ERROR_SUCCESS;
+}
+
+long InitializeRegistryForInproc()
+{
+ SYSTEM_INFO SystemInfo;
+ long RegStatus;
+ ulong Disposition;
+ HKEY hInterface;
+ HKEY hClsidKey;
+ HKEY hActKey;
+ HKEY hActValueKey;
+ WCHAR Path[256];
+
+ //
+ // Get CLASSES_ROOT.
+ //
+ RegStatus = RegOpenKeyEx( HKEY_CLASSES_ROOT,
+ L"CLSID",
+ 0,
+ KEY_ALL_ACCESS,
+ &hClsidKey );
+
+ if ( RegStatus != ERROR_SUCCESS )
+ return RegStatus;
+
+ //
+ // Local CLSID entries.
+ //
+
+ RegStatus = RegCreateKeyEx(
+ hClsidKey,
+ ClsidActInprocString,
+ 0,
+ L"REG_SZ",
+ REG_OPTION_NON_VOLATILE,
+ KEY_ALL_ACCESS,
+ NULL,
+ &hActKey,
+ &Disposition );
+
+ if ( RegStatus != ERROR_SUCCESS )
+ return RegStatus;
+
+ // if ( Disposition == REG_OPENED_EXISTING_KEY )
+ // return TRUE;
+
+ RegStatus = RegCreateKeyEx(
+ hActKey,
+ L"InprocServer32",
+ 0,
+ L"REG_SZ",
+ REG_OPTION_NON_VOLATILE,
+ KEY_ALL_ACCESS,
+ NULL,
+ &hActValueKey,
+ &Disposition );
+
+ if ( RegStatus != ERROR_SUCCESS )
+ return RegStatus;
+
+ if ( ! GetModuleFileName( 0, Path, sizeof(Path) ) )
+ return RegStatus;
+
+ _wcslwr( Path );
+ wcscpy( wcsstr( Path, L"actclt" ), L"actsrvd.dll" );
+
+ RegStatus = RegSetValueEx(
+ hActValueKey,
+ L"",
+ 0,
+ REG_SZ,
+ (const BYTE *)Path,
+ (wcslen(Path) + 1) * sizeof(WCHAR) );
+
+ if ( RegStatus != ERROR_SUCCESS )
+ return RegStatus;
+
+ RegStatus = RegSetValueEx(
+ hActValueKey,
+ L"ThreadingModel",
+ 0,
+ REG_SZ,
+ (const BYTE *)L"Both",
+ (wcslen(L"Both") + 1) * sizeof(WCHAR) );
+
+ if ( RegStatus != ERROR_SUCCESS )
+ return RegStatus;
+
+ return ERROR_SUCCESS;
+}
+
+WCHAR * StringIidIGoober = L"{ffffffff-0000-0000-0000-000000000000}";
+
+long InitializeRegistryForCustom()
+{
+ SYSTEM_INFO SystemInfo;
+ long RegStatus;
+ ulong Disposition;
+ HKEY hInterface;
+ HKEY hClsidKey;
+ HKEY hActKey;
+ HKEY hActValueKey;
+ WCHAR Path[256];
+
+ RegStatus = RegOpenKeyEx( HKEY_CLASSES_ROOT,
+ L"Interface",
+ 0,
+ KEY_ALL_ACCESS,
+ &hInterface );
+
+ if ( RegStatus != ERROR_SUCCESS )
+ return RegStatus;
+
+ RegStatus = RegCreateKeyEx(
+ hInterface,
+ StringIidIGoober,
+ 0,
+ L"REG_SZ",
+ REG_OPTION_NON_VOLATILE,
+ KEY_ALL_ACCESS,
+ NULL,
+ &hInterface,
+ &Disposition );
+
+ if ( RegStatus != ERROR_SUCCESS )
+ return RegStatus;
+
+ RegStatus = RegSetValueEx(
+ hInterface,
+ L"",
+ 0,
+ REG_SZ,
+ (const BYTE *)L"IGoober",
+ (wcslen(L"IGoober") + 1) * sizeof(WCHAR) );
+
+ if ( RegStatus != ERROR_SUCCESS )
+ return RegStatus;
+
+ RegStatus = RegCreateKeyEx(
+ hInterface,
+ L"ProxyStubClsid32",
+ 0,
+ L"REG_SZ",
+ REG_OPTION_NON_VOLATILE,
+ KEY_ALL_ACCESS,
+ NULL,
+ &hInterface,
+ &Disposition );
+
+ if ( RegStatus != ERROR_SUCCESS )
+ return RegStatus;
+
+ RegStatus = RegSetValueEx(
+ hInterface,
+ L"",
+ 0,
+ REG_SZ,
+ (const BYTE *)ClsidGoober32String,
+ (wcslen(ClsidGoober32String) + 1) * sizeof(WCHAR) );
+
+ if ( RegStatus != ERROR_SUCCESS )
+ return RegStatus;
+
+ RegStatus = RegOpenKeyEx( HKEY_CLASSES_ROOT,
+ L"CLSID",
+ 0,
+ KEY_ALL_ACCESS,
+ &hClsidKey );
+
+ if ( RegStatus != ERROR_SUCCESS )
+ return RegStatus;
+
+ RegStatus = RegCreateKeyEx(
+ hClsidKey,
+ ClsidGoober32String,
+ 0,
+ L"REG_SZ",
+ REG_OPTION_NON_VOLATILE,
+ KEY_ALL_ACCESS,
+ NULL,
+ &hActKey,
+ &Disposition );
+
+ if ( RegStatus != ERROR_SUCCESS )
+ return RegStatus;
+
+ // if ( Disposition == REG_OPENED_EXISTING_KEY )
+ // return TRUE;
+
+ RegStatus = RegCreateKeyEx(
+ hActKey,
+ L"InProcServer32",
+ 0,
+ L"REG_SZ",
+ REG_OPTION_NON_VOLATILE,
+ KEY_ALL_ACCESS,
+ NULL,
+ &hActValueKey,
+ &Disposition );
+
+ if ( RegStatus != ERROR_SUCCESS )
+ return RegStatus;
+
+ if ( ! GetModuleFileName( 0, Path, sizeof(Path) ) )
+ return RegStatus;
+
+ _wcslwr( Path );
+ wcscpy( wcsstr( Path, L"actclt" ), L"goober.dll" );
+
+ RegStatus = RegSetValueEx(
+ hActValueKey,
+ L"",
+ 0,
+ REG_SZ,
+ (const BYTE *)Path,
+ (wcslen(Path) + 1) * sizeof(WCHAR) );
+
+ if ( RegStatus != ERROR_SUCCESS )
+ return RegStatus;
+
+ return ERROR_SUCCESS;
+}
+
+long InitializeRegistryForRemote()
+{
+ long RegStatus;
+ ulong Disposition;
+ HKEY hClsidKey;
+ HKEY hAppIDKey;
+ HKEY hThisClsidKey;
+ HKEY hActKey;
+ HKEY hActValueKey;
+ WCHAR Path[256];
+
+ RegStatus = RegOpenKeyEx( HKEY_CLASSES_ROOT,
+ L"CLSID",
+ 0,
+ KEY_ALL_ACCESS,
+ &hClsidKey );
+
+ if ( RegStatus != ERROR_SUCCESS )
+ return RegStatus;
+
+ //
+ // CLSID_ActRemote
+ //
+
+ RegStatus = RegCreateKeyEx(
+ hClsidKey,
+ ClsidActRemoteString,
+ 0,
+ L"REG_SZ",
+ REG_OPTION_NON_VOLATILE,
+ KEY_ALL_ACCESS,
+ NULL,
+ &hThisClsidKey,
+ &Disposition );
+
+ if ( RegStatus != ERROR_SUCCESS )
+ return RegStatus;
+
+ RegStatus = RegSetValueEx(
+ hThisClsidKey,
+ L"AppID",
+ 0,
+ REG_SZ,
+ (const BYTE *) ClsidActRemoteString,
+ (wcslen(ClsidActRemoteString)+1)*sizeof(WCHAR));
+
+ if ( RegStatus != ERROR_SUCCESS )
+ return RegStatus;
+
+ RegStatus = SetAppIDSecurity( ClsidActRemoteString );
+
+ if ( RegStatus != ERROR_SUCCESS )
+ return RegStatus;
+
+ RegStatus = RegCreateKeyEx(
+ HKEY_CLASSES_ROOT,
+ L"AppID",
+ 0,
+ L"REG_SZ",
+ REG_OPTION_NON_VOLATILE,
+ KEY_ALL_ACCESS,
+ NULL,
+ &hAppIDKey,
+ &Disposition );
+
+ if ( RegStatus != ERROR_SUCCESS )
+ return RegStatus;
+
+ RegStatus = RegCreateKeyEx(
+ hAppIDKey,
+ ClsidActRemoteString,
+ 0,
+ L"REG_SZ",
+ REG_OPTION_NON_VOLATILE,
+ KEY_ALL_ACCESS,
+ NULL,
+ &hActKey,
+ &Disposition );
+
+ if ( RegStatus != ERROR_SUCCESS )
+ return RegStatus;
+
+ RegStatus = RegSetValueEx(
+ hActKey,
+ L"RemoteServerName",
+ 0,
+ REG_SZ,
+ (const BYTE *)ServerName,
+ (wcslen(ServerName) + 1) * sizeof(WCHAR) );
+
+ if ( RegStatus != ERROR_SUCCESS )
+ return RegStatus;
+
+ //
+ // CLSID_ActAtStorage
+ //
+
+ RegStatus = RegCreateKeyEx(
+ hClsidKey,
+ ClsidActAtStorageString,
+ 0,
+ L"REG_SZ",
+ REG_OPTION_NON_VOLATILE,
+ KEY_ALL_ACCESS,
+ NULL,
+ &hThisClsidKey,
+ &Disposition );
+
+ if ( RegStatus != ERROR_SUCCESS )
+ return RegStatus;
+
+ RegStatus = RegSetValueEx(
+ hThisClsidKey,
+ L"AppID",
+ 0,
+ REG_SZ,
+ (const BYTE *) ClsidActAtStorageString,
+ (wcslen(ClsidActAtStorageString)+1)*sizeof(WCHAR));
+
+ if ( RegStatus != ERROR_SUCCESS )
+ return RegStatus;
+
+ RegStatus = SetAppIDSecurity( ClsidActAtStorageString );
+
+ if ( RegStatus != ERROR_SUCCESS )
+ return RegStatus;
+
+ RegStatus = RegCreateKeyEx(
+ hAppIDKey,
+ ClsidActAtStorageString,
+ 0,
+ L"REG_SZ",
+ REG_OPTION_NON_VOLATILE,
+ KEY_ALL_ACCESS,
+ NULL,
+ &hActKey,
+ &Disposition );
+
+ if ( RegStatus != ERROR_SUCCESS )
+ return RegStatus;
+
+ RegStatus = RegSetValueEx(
+ hActKey,
+ L"ActivateAtStorage",
+ 0,
+ REG_SZ,
+ (const BYTE *)L"Y",
+ (wcslen(L"Y") + 1) * sizeof(WCHAR) );
+
+ if ( RegStatus != ERROR_SUCCESS )
+ return RegStatus;
+
+ //
+ // CLSID_ActRunAsLoggedOnUser
+ //
+
+ RegStatus = RegCreateKeyEx(
+ hClsidKey,
+ ClsidActRunAsLoggedOnString,
+ 0,
+ L"REG_SZ",
+ REG_OPTION_NON_VOLATILE,
+ KEY_ALL_ACCESS,
+ NULL,
+ &hThisClsidKey,
+ &Disposition );
+
+ if ( RegStatus != ERROR_SUCCESS )
+ return RegStatus;
+
+ RegStatus = SetAppIDSecurity( ClsidActRunAsLoggedOnString );
+
+ if ( RegStatus != ERROR_SUCCESS )
+ return RegStatus;
+
+ RegStatus = RegSetValueEx(
+ hThisClsidKey,
+ L"AppID",
+ 0,
+ REG_SZ,
+ (const BYTE *) ClsidActRunAsLoggedOnString,
+ (wcslen(ClsidActRunAsLoggedOnString)+1)*sizeof(WCHAR));
+
+ if ( RegStatus != ERROR_SUCCESS )
+ return RegStatus;
+
+ RegStatus = RegCreateKeyEx(
+ hAppIDKey,
+ ClsidActRunAsLoggedOnString,
+ 0,
+ L"REG_SZ",
+ REG_OPTION_NON_VOLATILE,
+ KEY_ALL_ACCESS,
+ NULL,
+ &hActKey,
+ &Disposition );
+
+ if ( RegStatus != ERROR_SUCCESS )
+ return RegStatus;
+
+ RegStatus = RegSetValueEx(
+ hActKey,
+ L"RemoteServerName",
+ 0,
+ REG_SZ,
+ (const BYTE *)ServerName,
+ (wcslen(ServerName) + 1) * sizeof(WCHAR) );
+
+ if ( RegStatus != ERROR_SUCCESS )
+ return RegStatus;
+
+ RegStatus = RegCreateKeyEx(
+ hThisClsidKey,
+ L"LocalServer32",
+ 0,
+ L"REG_SZ",
+ REG_OPTION_NON_VOLATILE,
+ KEY_ALL_ACCESS,
+ NULL,
+ &hActValueKey,
+ &Disposition );
+
+ if ( RegStatus != ERROR_SUCCESS )
+ return RegStatus;
+
+ if ( ! GetModuleFileName( 0, Path, sizeof(Path) ) )
+ return RegStatus;
+
+ _wcslwr( Path );
+ wcscpy( wcsstr( Path, L"actclt" ), L"actsrv.exe 7" );
+
+ RegStatus = RegSetValueEx(
+ hActValueKey,
+ L"",
+ 0,
+ REG_SZ,
+ (const BYTE *)Path,
+ (wcslen(Path) + 1) * sizeof(WCHAR) );
+
+ RegStatus = RegSetValueEx(
+ hActKey,
+ L"RunAs",
+ 0,
+ REG_SZ,
+ (const BYTE *)L"Interactive User",
+ (wcslen(L"Interactive User") + 1) * sizeof(WCHAR) );
+
+
+ if ( RegStatus != ERROR_SUCCESS )
+ return RegStatus;
+
+ //
+ // RunAs CLSID entries.
+ //
+
+ RegStatus = RegCreateKeyEx(
+ hClsidKey,
+ ClsidActPreConfigString,
+ 0,
+ L"REG_SZ",
+ REG_OPTION_NON_VOLATILE,
+ KEY_ALL_ACCESS,
+ NULL,
+ &hThisClsidKey,
+ &Disposition );
+
+ if ( RegStatus != ERROR_SUCCESS )
+ return RegStatus;
+
+ RegStatus = RegSetValueEx(
+ hThisClsidKey,
+ L"AppID",
+ 0,
+ REG_SZ,
+ (const BYTE *) ClsidActPreConfigString,
+ (wcslen(ClsidActPreConfigString)+1)*sizeof(WCHAR));
+
+ if ( RegStatus != ERROR_SUCCESS )
+ return RegStatus;
+
+ RegStatus = SetAppIDSecurity( ClsidActPreConfigString );
+
+ if ( RegStatus != ERROR_SUCCESS )
+ return RegStatus;
+
+ RegStatus = RegCreateKeyEx(
+ hAppIDKey,
+ ClsidActPreConfigString,
+ 0,
+ L"REG_SZ",
+ REG_OPTION_NON_VOLATILE,
+ KEY_ALL_ACCESS,
+ NULL,
+ &hActKey,
+ &Disposition );
+
+ if ( RegStatus != ERROR_SUCCESS )
+ return RegStatus;
+
+ RegStatus = RegSetValueEx(
+ hActKey,
+ L"RemoteServerName",
+ 0,
+ REG_SZ,
+ (const BYTE *)ServerName,
+ (wcslen(ServerName) + 1) * sizeof(WCHAR) );
+
+ if ( RegStatus != ERROR_SUCCESS )
+ return RegStatus;
+
+ RegStatus = RegCreateKeyEx(
+ hThisClsidKey,
+ L"LocalServer32",
+ 0,
+ L"REG_SZ",
+ REG_OPTION_NON_VOLATILE,
+ KEY_ALL_ACCESS,
+ NULL,
+ &hActValueKey,
+ &Disposition );
+
+ if ( RegStatus != ERROR_SUCCESS )
+ return RegStatus;
+
+ if ( ! GetModuleFileName( 0, Path, sizeof(Path) ) )
+ return RegStatus;
+
+ _wcslwr( Path );
+ wcscpy( wcsstr( Path, L"actclt" ), L"actsrv.exe 6" );
+
+ RegStatus = RegSetValueEx(
+ hActValueKey,
+ L"",
+ 0,
+ REG_SZ,
+ (const BYTE *)Path,
+ (wcslen(Path) + 1) * sizeof(WCHAR) );
+
+ RegStatus = RegSetValueEx(
+ hActKey,
+ L"RunAs",
+ 0,
+ REG_SZ,
+ (const BYTE *)UserName,
+ (wcslen(UserName) + 1) * sizeof(WCHAR) );
+
+
+ if ( RegStatus != ERROR_SUCCESS )
+ return RegStatus;
+
+ if (!SetPassword(ClsidActPreConfigString, Password))
+ return(FALSE);
+
+ return ERROR_SUCCESS;
+}
+
+long InitializeRegistryForService()
+{
+ long RegStatus;
+ ulong Disposition;
+ HKEY hClsidKey;
+ HKEY hAppIDKey;
+ HKEY hThisClsidKey;
+ HKEY hActKey;
+ HKEY hActValueKey;
+ HKEY hServices;
+ WCHAR Path[256];
+
+ //
+ // Get CLASSES_ROOT.
+ //
+ RegStatus = RegOpenKeyEx( HKEY_CLASSES_ROOT,
+ L"CLSID",
+ 0,
+ KEY_ALL_ACCESS,
+ &hClsidKey );
+
+ if ( RegStatus != ERROR_SUCCESS )
+ return RegStatus;
+
+ RegStatus = RegCreateKeyEx(
+ HKEY_CLASSES_ROOT,
+ L"AppID",
+ 0,
+ L"REG_SZ",
+ REG_OPTION_NON_VOLATILE,
+ KEY_ALL_ACCESS,
+ NULL,
+ &hAppIDKey,
+ &Disposition );
+
+ if ( RegStatus != ERROR_SUCCESS )
+ return RegStatus;
+
+ //
+ // Local CLSID entries.
+ //
+
+ RegStatus = RegCreateKeyEx(
+ hClsidKey,
+ ClsidActServiceString,
+ 0,
+ L"REG_SZ",
+ REG_OPTION_NON_VOLATILE,
+ KEY_ALL_ACCESS,
+ NULL,
+ &hThisClsidKey,
+ &Disposition );
+
+ if ( RegStatus != ERROR_SUCCESS )
+ return RegStatus;
+
+ RegStatus = SetAppIDSecurity( ClsidActServiceString );
+
+ if ( RegStatus != ERROR_SUCCESS )
+ return RegStatus;
+
+ RegStatus = RegSetValueEx(
+ hThisClsidKey,
+ L"AppID",
+ 0,
+ REG_SZ,
+ (const BYTE *) ClsidActServiceString,
+ (wcslen(ClsidActServiceString)+1)*sizeof(WCHAR));
+
+ if ( RegStatus != ERROR_SUCCESS )
+ return RegStatus;
+
+ // if ( Disposition == REG_OPENED_EXISTING_KEY )
+ // return TRUE;
+
+ RegStatus = RegCreateKeyEx(
+ hAppIDKey,
+ ClsidActServiceString,
+ 0,
+ L"REG_SZ",
+ REG_OPTION_NON_VOLATILE,
+ KEY_ALL_ACCESS,
+ NULL,
+ &hActKey,
+ &Disposition );
+
+ if ( RegStatus != ERROR_SUCCESS )
+ return RegStatus;
+
+ if ( ! GetModuleFileName( 0, Path, sizeof(Path) ) )
+ return RegStatus;
+
+ _wcslwr( Path );
+ wcscpy( wcsstr( Path, L"actclt" ), L"actsrv.exe 8" );
+
+ RegStatus = RegSetValueEx(
+ hActKey,
+ L"LocalService",
+ 0,
+ REG_SZ,
+ (const BYTE *)ServiceName,
+ (wcslen(ServiceName) + 1) * sizeof(WCHAR) );
+
+ if ( RegStatus != ERROR_SUCCESS )
+ return RegStatus;
+
+ RegStatus = RegSetValueEx(
+ hActKey,
+ L"ActivateAtStorage",
+ 0,
+ REG_SZ,
+ (const BYTE *)L"Y",
+ (wcslen(L"Y") + 1) * sizeof(WCHAR) );
+
+ if ( RegStatus != ERROR_SUCCESS )
+ return RegStatus;
+
+ RegStatus = RegOpenKeyEx( HKEY_LOCAL_MACHINE,
+ L"SYSTEM\\CurrentControlSet\\Services",
+ 0,
+ KEY_READ,
+ &hServices );
+
+ if ( RegStatus != ERROR_SUCCESS )
+ return RegStatus;
+
+ return InstallService(Path);
+}
+
+DWORD InstallService( WCHAR * Path )
+{
+ SC_HANDLE hManager;
+ SC_HANDLE hService;
+
+ hManager = OpenSCManager( NULL,
+ NULL,
+ SC_MANAGER_ALL_ACCESS );
+
+ if ( ! hManager )
+ {
+ printf( "OpenSCManager returned %d\n", GetLastError() );
+ return GetLastError();
+ }
+
+ hService = OpenService( hManager,
+ ServiceName,
+ SERVICE_ALL_ACCESS );
+
+ if ( ! hService )
+ {
+ hService = CreateService(
+ hManager,
+ ServiceName,
+ ServiceDisplayName,
+ SERVICE_ALL_ACCESS,
+ SERVICE_WIN32_OWN_PROCESS,
+ SERVICE_DEMAND_START,
+ SERVICE_ERROR_NORMAL,
+ Path,
+ NULL,
+ NULL,
+ NULL,
+ NULL,
+ NULL);
+ }
+
+ if ( ! hService )
+ {
+ printf( "CreateService returned %d\n", GetLastError() );
+ CloseServiceHandle(hManager);
+ return GetLastError();
+ }
+
+ CloseServiceHandle(hService);
+ CloseServiceHandle(hManager);
+ return ERROR_SUCCESS;
+}
+
diff --git a/private/oleutest/act/tstsvc/service.cxx b/private/oleutest/act/tstsvc/service.cxx
new file mode 100644
index 000000000..689076d78
--- /dev/null
+++ b/private/oleutest/act/tstsvc/service.cxx
@@ -0,0 +1,92 @@
+
+BOOL TimeStartService(WCHAR * wszServiceName, WCHAR *pwszRegServiceArgs, HANDLE *phProcess)
+{
+ SC_HANDLE hSCManager;
+ SC_HANDLE hService;
+ WCHAR *pwszServiceArgs = NULL;
+ ULONG cArgs = 0;
+ WCHAR *apwszArgs[MAX_SERVICE_ARGS];
+
+ *phProcess = NULL;
+
+ // Get a handle to the Service Control Manager
+ if (hSCManager = OpenSCManager(NULL, NULL, GENERIC_EXECUTE))
+ {
+ // Open a handle to the requested service
+ if (hService = OpenService(hSCManager, wszServiceName, GENERIC_EXECUTE))
+ {
+ // Close the service manager's database
+ CloseServiceHandle(hSCManager);
+
+ // Formulate the arguments (if any)
+ if (pwszRegServiceArgs)
+ {
+ UINT k = 0;
+
+ // Make a copy of the service arguments
+ pwszServiceArgs = (WCHAR *) PrivMemAlloc(
+ (lstrlenW(pwszRegServiceArgs) + 1) * sizeof(WCHAR));
+ if (pwszServiceArgs == NULL)
+ {
+ CloseServiceHandle(hService);
+ return FALSE;
+ }
+ lstrcpyW(pwszServiceArgs, pwszRegServiceArgs);
+
+ // Scan the arguments
+ do
+ {
+ // Scan to the next non-whitespace character
+ while(pwszServiceArgs[k] &&
+ (pwszServiceArgs[k] == L' ' ||
+ pwszServiceArgs[k] == L'\t'))
+ {
+ k++;
+ }
+
+ // Store the next argument
+ if (pwszServiceArgs[k])
+ {
+ apwszArgs[cArgs++] = &pwszServiceArgs[k];
+ }
+
+ // Scan to the next whitespace char
+ while(pwszServiceArgs[k] &&
+ pwszServiceArgs[k] != L' ' &&
+ pwszServiceArgs[k] != L'\t')
+ {
+ k++;
+ }
+
+ // Null terminate the previous argument
+ if (pwszServiceArgs[k])
+ {
+ pwszServiceArgs[k++] = L'\0';
+ }
+ } while(pwszServiceArgs[k]);
+ }
+
+ // Start the service
+ if (StartService(hService, cArgs,
+ cArgs > 0 ? (LPCTSTR *) apwszArgs : NULL))
+ {
+ CloseServiceHandle(hService);
+ PrivMemFree(pwszServiceArgs);
+ return TRUE;
+ }
+ else
+ {
+ CloseServiceHandle(hService);
+ PrivMemFree(pwszServiceArgs);
+ }
+ }
+ else
+ {
+ CloseServiceHandle(hSCManager);
+ }
+ }
+
+ DWORD err = GetLastError();
+ return FALSE;
+}
+