Beispiel #1
0
        public Injector(InjectionMethod injectionMethod, string processName, string dllPath, bool randomiseDllName = false)
        {
            // Ensure the users operating system is valid

            ValidationHandler.ValidateOperatingSystem();

            // Ensure the arguments passed in are valid

            if (string.IsNullOrWhiteSpace(processName) || string.IsNullOrWhiteSpace(dllPath))
            {
                throw new ArgumentException("One or more of the arguments provided were invalid");
            }

            // Ensure a valid DLL exists at the provided path

            if (!File.Exists(dllPath) || Path.GetExtension(dllPath) != ".dll")
            {
                throw new ArgumentException("No DLL exists at the provided path");
            }

            if (randomiseDllName)
            {
                // Create a temporary DLL on disk

                var temporaryDllPath = DllTools.CreateTemporaryDll(DllTools.GenerateRandomDllName(), File.ReadAllBytes(dllPath));

                _injectionManager = new InjectionManager(injectionMethod, processName, temporaryDllPath);
            }

            else
            {
                _injectionManager = new InjectionManager(injectionMethod, processName, dllPath);
            }
        }
 public CalibrationSystemApiTests()
 {
     DllTools.AddPathVariable(Environment.ExpandEnvironmentVariables("%META_CORE%"));
     DllTools.AddPathVariable(Environment.ExpandEnvironmentVariables("%META_INTERNAL_UNITY_SDK%")
                              + DllTools.DirSep()
                              + "Plugins"
                              + DllTools.DirSep()
                              + "x86_64");
 }
 public PathApiTests()
 {
     DllTools.AddPathVariable(Environment.ExpandEnvironmentVariables("%META_CORE%"));
     DllTools.AddPathVariable(Environment.ExpandEnvironmentVariables("%META_INTERNAL_UNITY_SDK%")
                              + DllTools.DirSep()
                              + "Plugins"
                              + DllTools.DirSep()
                              + "x86_64");
     loadCalibDataAndSerialData =
         Environment.ExpandEnvironmentVariables("%META_INTERNAL_CONFIG%") +
         DllTools.DirSep() + "device" + DllTools.DirSep() + "calibration_data_integration_test.json";
 }
Beispiel #4
0
        internal InjectionManager(int targetProcessId, string dllPath, bool isExtension, bool randomiseDllName)
        {
            // Ensure the users operating system is valid

            ValidationHandler.ValidateOperatingSystem();

            // Ensure the arguments passed in are valid

            if (targetProcessId <= 0 || string.IsNullOrWhiteSpace(dllPath))
            {
                throw new ArgumentException("One or more of the arguments provided were invalid");
            }

            // Ensure a valid DLL exists at the provided path

            if (!File.Exists(dllPath) || Path.GetExtension(dllPath) != ".dll")
            {
                throw new ArgumentException("No DLL file exists at the provided path");
            }

            if (randomiseDllName && isExtension)
            {
                // Assume the DLL is the newest file in the directory

                var directoryInfo = new DirectoryInfo(Path.Combine(Path.GetTempPath(), "Bleak"));

                var newestFile = directoryInfo.GetFiles().OrderByDescending(file => file.LastWriteTime).First();

                _injectionProperties = new InjectionProperties(targetProcessId, newestFile.FullName);
            }

            else if (randomiseDllName)
            {
                // Create a temporary DLL on disk

                var temporaryDllPath = DllTools.CreateTemporaryDll(DllTools.GenerateRandomDllName(), File.ReadAllBytes(dllPath));

                _injectionProperties = new InjectionProperties(targetProcessId, temporaryDllPath);
            }

            else
            {
                _injectionProperties = new InjectionProperties(targetProcessId, dllPath);
            }

            // Ensure the architecture of the DLL is valid

            ValidationHandler.ValidateDllArchitecture(_injectionProperties);
        }
Beispiel #5
0
        public void SetUpSystemTest()
        {
            systemStarted = true;
            string loadCalibDataAndSerialData =
                Environment.ExpandEnvironmentVariables("%META_INTERNAL_CONFIG%") +
                DllTools.DirSep() + "device" + DllTools.DirSep() + "calibration_data_integration_test.json";

            systemStarted = Plugin.SystemApi.Start(loadCalibDataAndSerialData);

            // Abort test if system didn't start.
            if (!systemStarted)
            {
                Assert.Fail("System failed to start. ");
                return;
            }
        }
Beispiel #6
0
        public Injector(InjectionMethod injectionMethod, string processName, byte[] dllBytes)
        {
            // Ensure the users operating system is valid

            ValidationHandler.ValidateOperatingSystem();

            // Ensure the arguments passed in are valid

            if (string.IsNullOrWhiteSpace(processName) || dllBytes is null || dllBytes.Length == 0)
            {
                throw new ArgumentException("One or more of the arguments provided were invalid");
            }

            _injectionManager = injectionMethod == InjectionMethod.ManualMap
                              ? new InjectionManager(injectionMethod, processName, dllBytes)
                              : new InjectionManager(injectionMethod, processName, DllTools.CreateTemporaryDll(DllTools.GenerateRandomDllName(), dllBytes));
        }
Beispiel #7
0
        public Injector(InjectionMethod injectionMethod, int processId, byte[] dllBytes)
        {
            // Ensure the users operating system is valid

            ValidationHandler.ValidateOperatingSystem();

            // Ensure the arguments passed in are valid

            if (processId <= 0 || dllBytes is null || dllBytes.Length == 0)
            {
                throw new ArgumentException("One or more of the arguments provided were invalid");
            }

            _injectionContext = injectionMethod == InjectionMethod.ManualMap
                              ? new InjectionContext(injectionMethod, processId, dllBytes)
                              : new InjectionContext(injectionMethod, processId, DllTools.CreateTemporaryDll(DllTools.GenerateDllName(dllBytes), dllBytes));
        }
        public void SetUpSystemTest()
        {
            systemStarted = true;
            string loadCalibDataAndSerialData =
                Environment.ExpandEnvironmentVariables("%META_INTERNAL_CONFIG%") +
                DllTools.DirSep() + "core_api" + DllTools.DirSep() + "integration_test.json";
            var status = Interop.MetaCoreInterop.meta_init(loadCalibDataAndSerialData, true);

            // Abort test if system didn't start.
            if (status != InitStatus.SUCCESS)
            {
                Assert.Fail("System failed to start. ");
                return;
            }

            Interop.MetaCoreInterop.meta_start_application(false);
            Interop.MetaCoreInterop.meta_wait_start_complete();
        }
Beispiel #9
0
        internal InjectionManager(int targetProcessId, byte[] dllBytes, bool manualMap, bool isExtension, bool randomiseDllName)
        {
            // Ensure the users operating system is valid

            ValidationHandler.ValidateOperatingSystem();

            // Ensure the arguments passed in are valid

            if (targetProcessId <= 0 || dllBytes is null || dllBytes.Length == 0)
            {
                throw new ArgumentException("One or more of the arguments provided were invalid");
            }

            if (manualMap)
            {
                _injectionProperties = new InjectionProperties(targetProcessId, dllBytes);
            }

            else if (randomiseDllName && isExtension)
            {
                // Assume the DLL is the newest file in the directory

                var directoryInfo = new DirectoryInfo(Path.Combine(Path.GetTempPath(), "Bleak"));

                var newestFile = directoryInfo.GetFiles().OrderByDescending(file => file.LastWriteTime).First();

                _injectionProperties = new InjectionProperties(targetProcessId, newestFile.FullName);
            }

            else
            {
                // Create a temporary DLL on disk

                var temporaryDllName = randomiseDllName ? DllTools.GenerateRandomDllName() : DllTools.GenerateDllName(dllBytes);

                _injectionProperties = new InjectionProperties(targetProcessId, DllTools.CreateTemporaryDll(temporaryDllName, dllBytes));
            }

            // Ensure the architecture of the DLL is valid

            ValidationHandler.ValidateDllArchitecture(_injectionProperties);
        }
Beispiel #10
0
 public static void CreateDll()
 {
     DllTools.CreateDll();
 }
Beispiel #11
0
 public static void CopyDllToPersistentDataPath()
 {
     DllTools.CopyDllToPersistentDataPath();
 }
Beispiel #12
0
 public static void DeleteDll()
 {
     DllTools.DeleteDll();
 }