public void CreateExecutable_WhenInvoke_ThenCanBeExecutableIsTrue()
        {
            //Act
            var operationInfo = ExecutableInfo.CreateExecutable();

            //Assert
            Assert.That(operationInfo.CanBeExecuted, Is.True);
        }
        public void CreateExecutable_WhenInvoke_ThenMessageIsNull()
        {
            //Act
            var operationInfo = ExecutableInfo.CreateExecutable();

            //Assert
            Assert.That(operationInfo.Message, Is.Null);
        }
Beispiel #3
0
        public ExecutableInfo GetExecutableInfo(double value)
        {
            if (value < 0)
            {
                return(ExecutableInfo.CreateNotExecutable(ErrorMessages.InvalidInput));
            }

            return(ExecutableInfo.CreateExecutable());
        }
Beispiel #4
0
        public ExecutableInfo GetExecutableInfo(double value)
        {
            if (value == 0.0)
            {
                return(ExecutableInfo.CreateNotExecutable(ErrorMessages.DivisionOnZero));
            }

            return(ExecutableInfo.CreateExecutable());
        }
        public static ExecutableInfo GetExecutableInfo(int index)
        {
            ExecutableInfo i = default;

            if (PortExploits.cracks.TryGetValue(index, out var n) && nameToExeStruct.TryGetValue(n, out i))
            {
                return(i);
            }
            return(i);
        }
 public bool Equals(ExecutableInfo o)
 {
     return(o.PortNumber == PortNumber &&
            o.Number == Number &&
            o.NumberIndex == NumberIndex &&
            o.Name == Name &&
            o.ServiceName == ServiceName &&
            o.NeedsPort == NeedsPort &&
            o.Data == Data &&
            o.LocalData == LocalData);
 }
        public void CreateNotExecutable_WhenPassMessage_ThenMessageIsTheSame()
        {
            //Arrange
            const string message = "Some message";

            //Act
            var operationInfo = ExecutableInfo.CreateNotExecutable(message);

            //Assert
            Assert.That(operationInfo.CanBeExecuted, Is.False);
        }
        public IExecutable Create(ExecutableInfo executableInfo)
        {
            var executableType = _executables
                                 .SingleOrDefault(t => t.Name == executableInfo.Name);

            if (executableType == null)
            {
                throw new TypeNotFoundException(executableInfo.Name);
            }

            return(Create(executableType, executableInfo.Parameters.ToArray()));
        }
Beispiel #9
0
        private void Load()
        {
            using (var r = new BinaryReader(new SubStream(rootStream, 0))) {
                GameTitle = r.ReadUTFString(12);
                GameCode  = r.Read4C();
                MakerCode = r.ReadUTFString(2);
                UnitCode  = (UnitCodeEnum)r.ReadByte();
                r.Skip(1 + 1 + 7 + 1);
                Region     = (RegionEnum)r.ReadByte();
                RomVersion = r.ReadByte();
                RomFlags   = (RomFlagsEnum)r.ReadByte();

                ARM9 = new ExecutableInfo(r.ReadUInt32(), r.ReadUInt32(), r.ReadUInt32(), r.ReadUInt32());
                ARM7 = new ExecutableInfo(r.ReadUInt32(), r.ReadUInt32(), r.ReadUInt32(), r.ReadUInt32());

                {
                    uint FNTOffset = r.ReadUInt32();
                    uint FNTSize   = r.ReadUInt32();
                    uint FATOffset = r.ReadUInt32();
                    uint FATSize   = r.ReadUInt32();

                    if (FNTSize != 0 && FATSize != 0)
                    {
                        FileSystem = new FileSystem(
                            new SubStream(rootStream, FNTOffset, FNTSize),
                            new SubStream(rootStream, FATOffset, FATSize),
                            rootStream
                            );
                    }
                }

                {
                    uint ARM9OverlayOffset = r.ReadUInt32();
                    uint ARM9OverlaySize   = r.ReadUInt32();
                    uint ARM7OverlayOffset = r.ReadUInt32();
                    uint ARM7OverlaySize   = r.ReadUInt32();
                }

                r.Skip(4 * 2);

                {
                    uint bannerOffset = r.ReadUInt32();
                    Banner = new Banner(new SubStream(rootStream, bannerOffset));
                }

                UInt16 SecureAreaChecksum = r.ReadUInt16();
                UInt16 SecureAreaDelay    = r.ReadUInt16();

                r.Skip(4 * 2);
            }
        }
            public bool FindPluginInstances(string inAssemblyPath, ref OrderedSet <SimpleDataService> ioImplementers)
            {
                FileVersionInfo fileVersionInfo = FileVersionInfo.GetVersionInfo(inAssemblyPath);
                Assembly        assembly        = Assembly.LoadFile(inAssemblyPath);

                Type[] exportedTypes = assembly.GetExportedTypes();
                Type   findType      = typeof(BaseWNOSPlugin);
                bool   addedAny      = false;

                foreach (Type exportedType in exportedTypes)
                {
                    if (exportedType.IsClass && !exportedType.IsAbstract && findType.IsAssignableFrom(exportedType))
                    {
                        ExecutableInfo executableInfo =
                            new ExecutableInfo(exportedType.Assembly.ManifestModule.Name,
                                               exportedType.FullName);

                        BaseWNOSPlugin plugin;
                        try
                        {
                            plugin =
                                AppDomainInstanceLoader.GetInstance <BaseWNOSPlugin>(AppDomain.CurrentDomain, inAssemblyPath,
                                                                                     exportedType.FullName);
                        }
                        catch (Exception)
                        {
                            continue;
                        }
                        SimpleDataService dataService = new SimpleDataService();
                        if (!CollectionUtils.IsNullOrEmpty(plugin.ConfigurationArguments))
                        {
                            dataService.Args = new List <string>(plugin.ConfigurationArguments.Keys);
                        }
                        if (!CollectionUtils.IsNullOrEmpty(plugin.DataProviders))
                        {
                            dataService.DataSources = new List <string>(plugin.DataProviders.Keys);
                        }
                        dataService.Type = PluginLoader.GetServiceType(plugin);
                        if (dataService.Type != ServiceType.None)
                        {
                            dataService.PluginInfo = executableInfo;
                            dataService.Version    = new VersionInfo(fileVersionInfo);
                            ioImplementers.Add(dataService);
                            addedAny = true;
                        }
                    }
                }
                return(addedAny);
            }
Beispiel #11
0
        /// <summary>
        /// Tries to remove itself from registry startup and then delete the .exe
        /// </summary>
        /// <returns></returns>
        public bool Execute()
        {
            var execInfo = new ExecutableInfo();

            string keyName = @"Software\Microsoft\Windows\CurrentVersion\Run";

            using (RegistryKey key = Registry.CurrentUser.OpenSubKey(execInfo.AssemblyName, true))
            {
                if (key == null)
                {
                    // Key doesn't exist. Do whatever you want to handle
                    // this case
                }
                else
                {
                    key.DeleteValue("MyApp");
                }
            }

            execInfo.StartMelt();
            Environment.Exit(0);

            return(true);
        }
Beispiel #12
0
 private static void SetCachedPath(string toolEntry, string location, ExecutableInfo executableInfo, string minimumToolVersion)
 {
     SetCachedPath("{0}/{1}/{2}".format(toolEntry, executableInfo, minimumToolVersion), location);
 }
Beispiel #13
0
 public ExecutableInfo GetExecutableInfo(double value1, double value2)
 {
     return(ExecutableInfo.CreateExecutable());
 }
        /// <summary>
        /// Finds a tool in the file system
        /// </summary>
        /// <param name="filename">The name of the tool</param>
        /// <param name="executableType">Platform or assembly info</param>
        /// <param name="minimumVersion">Minimum required version</param>
        /// <param name="excludeFilters">A list of tool names which should be excluded from the scan</param>
        /// <param name="includeFilters">A list of tool names which should be included in the scan</param>
        /// <param name="rememberMissingFile">Disables searching for files which are known to be missing.</param>
        /// <param name="tagWithCosmeticVersion"></param>
        /// <returns></returns>
        public string ScanForFile(string filename, ExecutableInfo executableType = ExecutableInfo.none, string minimumVersion = "0.0",
            IEnumerable<string> excludeFilters = null, IEnumerable<string> includeFilters= null, bool rememberMissingFile = false, string tagWithCosmeticVersion = null ) {
            if (!IgnoreCache) {
                var result = GetCachedPath(filename, executableType, tagWithCosmeticVersion ?? minimumVersion);

                if ("NOT-FOUND".Equals(result)) {
                    if (rememberMissingFile) {
                        return null; // we've asked to remember that we haven't found this
                    }
                    result = null; // we've not asked to remember that, so we'll let it try to find it again.
                }

                if (!string.IsNullOrEmpty(result)) {
                    return result;
                }
            }

            Notify("[One moment.. Scanning for utility({0}/{1}/{2})]", filename, executableType.ToString(), tagWithCosmeticVersion ?? minimumVersion);

            var ver = VersionStringToUInt64(minimumVersion);

            var files = _commonSearchLocations.Union(_searchLocations).SelectMany(
                directory => directory.DirectoryEnumerateFilesSmarter("**\\"+filename, SearchOption.TopDirectoryOnly))
                .Union(
                    _recursiveSearchLocations.AsParallel().SelectMany(
                        directory => directory.DirectoryEnumerateFilesSmarter("**\\"+filename, SearchOption.AllDirectories)));

            

            if (executableType != ExecutableInfo.none || ver != 0) {
                files =
                    files.Where( file =>
                            (PEInfo.Scan(file).ExecutableInfo & executableType) == executableType &&
                                PEInfo.Scan(file).FileVersionLong >= ver);
            }
 
            if (includeFilters != null) {
                files = includeFilters.Aggregate(files, (current, filter) => (from eachFile in current
                                                                              where eachFile.ToLower().NewIsWildcardMatch(filter.ToLower())
                                                                              select eachFile));
            }


            if (excludeFilters != null) {
                files = excludeFilters.Aggregate(files, (current, filter) => (from eachFile in current
                                                                              where !eachFile.ToLower().NewIsWildcardMatch(filter.ToLower())
                                                                              select eachFile));
            }



            var filePath = files.MaxElement(each => PEInfo.Scan(each).FileVersionLong);

            if (!string.IsNullOrEmpty(filePath) || rememberMissingFile) {
                SetCachedPath(filename, string.IsNullOrEmpty(filePath) ? "NOT-FOUND" : filePath , executableType, tagWithCosmeticVersion ?? minimumVersion);
                try {
                    SetCachedPath(filename, string.IsNullOrEmpty(filePath) ? "NOT-FOUND" : filePath, executableType,
                        PEInfo.Scan(filePath).FileVersion);
                } catch {
                    
                }
            }

            return filePath;
        }
Beispiel #15
0
 private static string GetCachedPath(string toolEntry, ExecutableInfo executableInfo, string minimumToolVersion)
 {
     return(GetCachedPath("{0}/{1}/{2}".format(toolEntry, executableInfo, minimumToolVersion)));
 }
Beispiel #16
0
 /// <summary>
 /// Save a tool to the registry
 /// </summary>
 /// <param name="toolEntry">Name of the tool</param>
 /// <param name="location">Full path to the tool</param>
 /// <param name="executableInfo">Platform or assembly information</param>
 /// <param name="minimumToolVersion"></param>
 private static void SetCachedPath(string toolEntry, string location, ExecutableInfo executableInfo, string minimumToolVersion)
 {
     SetCachedPath("{0}/{1}/{2}".format(toolEntry, executableInfo, minimumToolVersion), location);
 }
Beispiel #17
0
        /// <summary>
        /// Finds a tool in the file system
        /// </summary>
        /// <param name="filename">The name of the tool</param>
        /// <param name="executableType">Platform or assembly info</param>
        /// <param name="minimumVersion">Minimum required version</param>
        /// <param name="excludeFilters">A list of tool names which should be excluded from the scan</param>
        /// <param name="includeFilters">A list of tool names which should be included in the scan</param>
        /// <param name="rememberMissingFile">Disables searching for files which are known to be missing.</param>
        /// <param name="tagWithCosmeticVersion"></param>
        /// <returns></returns>
        public string ScanForFile(string filename, ExecutableInfo executableType = ExecutableInfo.none, string minimumVersion = "0.0",
                                  IEnumerable <string> excludeFilters            = null, IEnumerable <string> includeFilters  = null, bool rememberMissingFile = false, string tagWithCosmeticVersion = null)
        {
            if (!IgnoreCache)
            {
                var result = GetCachedPath(filename, executableType, tagWithCosmeticVersion ?? minimumVersion);

                if ("NOT-FOUND".Equals(result))
                {
                    if (rememberMissingFile)
                    {
                        return(null); // we've asked to remember that we haven't found this
                    }
                    result = null;    // we've not asked to remember that, so we'll let it try to find it again.
                }

                if (!string.IsNullOrEmpty(result))
                {
                    return(result);
                }
            }

            Notify("[One moment.. Scanning for utility({0}/{1}/{2})]", filename, executableType.ToString(), tagWithCosmeticVersion ?? minimumVersion);

            var ver = VersionStringToUInt64(minimumVersion);

            var files = _commonSearchLocations.Union(_searchLocations).SelectMany(
                directory => directory.DirectoryEnumerateFilesSmarter("**\\" + filename, SearchOption.TopDirectoryOnly))
                        .Union(
                _recursiveSearchLocations.AsParallel().SelectMany(
                    directory => directory.DirectoryEnumerateFilesSmarter("**\\" + filename, SearchOption.AllDirectories)));



            if (executableType != ExecutableInfo.none || ver != 0)
            {
                files =
                    files.Where(file =>
                                (PEInfo.Scan(file).ExecutableInfo & executableType) == executableType &&
                                PEInfo.Scan(file).FileVersionLong >= ver);
            }

            if (includeFilters != null)
            {
                files = includeFilters.Aggregate(files, (current, filter) => (from eachFile in current
                                                                              where eachFile.ToLower().NewIsWildcardMatch(filter.ToLower())
                                                                              select eachFile));
            }


            if (excludeFilters != null)
            {
                files = excludeFilters.Aggregate(files, (current, filter) => (from eachFile in current
                                                                              where !eachFile.ToLower().NewIsWildcardMatch(filter.ToLower())
                                                                              select eachFile));
            }



            var filePath = files.MaxElement(each => PEInfo.Scan(each).FileVersionLong);

            if (!string.IsNullOrEmpty(filePath) || rememberMissingFile)
            {
                SetCachedPath(filename, string.IsNullOrEmpty(filePath) ? "NOT-FOUND" : filePath, executableType, tagWithCosmeticVersion ?? minimumVersion);
                try {
                    SetCachedPath(filename, string.IsNullOrEmpty(filePath) ? "NOT-FOUND" : filePath, executableType,
                                  PEInfo.Scan(filePath).FileVersion);
                } catch {
                }
            }

            return(filePath);
        }
Beispiel #18
0
 /// <summary>
 /// Finds a tool in the file system
 /// </summary>
 /// <param name="filename">The name of the tool</param>
 /// <param name="executableType">Platform or assembly information</param>
 /// <param name="filters">A list of tool names which should be excluded from the scan</param>
 /// <returns></returns>
 public string ScanForFile(string filename, ExecutableInfo executableType, IEnumerable <string> filters)
 {
     return(ScanForFile(filename, executableType, "0.0", filters));
 }
Beispiel #19
0
 public string ScanForFile(string filename, ExecutableInfo executableType, IEnumerable<string> filters)
 {
     return ScanForFile(filename, executableType, "0.0", filters);
 }
Beispiel #20
0
        public string ScanForFile(string filename, ExecutableInfo executableType = ExecutableInfo.none, string minimumVersion = "0.0", IEnumerable<string> filters = null)
        {
            if (!IgnoreCache) {
                string result = GetCachedPath(filename, executableType, minimumVersion);
                if (!string.IsNullOrEmpty(result))
                    return result;
            }

            var ver = minimumVersion.VersionStringToUInt64();

            var files = commonSearchLocations.Union(searchLocations).AsParallel().SelectMany(
                directory => directory.DirectoryEnumerateFilesSmarter(filename, SearchOption.TopDirectoryOnly))
                .Union(
                    recursiveSearchLocations.AsParallel().SelectMany(
                        directory => directory.DirectoryEnumerateFilesSmarter(filename, SearchOption.AllDirectories)));

            files = files.Where(file => (GetExeType(file) & executableType) == executableType && GetToolVersionNumeric(file) >= ver);

            if( filters != null  ) {
                files = filters.Aggregate(files, (current, filter) => (from eachFile in current
                                                                       where !eachFile.IsWildcardMatch(filter)
                                                                       select eachFile));
            }

            var filePath = files.MaxElement(GetToolVersionNumeric);
            if (!string.IsNullOrEmpty(filePath)) {
                SetCachedPath(filename, filePath, executableType, minimumVersion);
                SetCachedPath(filename, filePath, executableType, GetToolVersion(filePath));
            }

            return filePath;
        }
Beispiel #21
0
 private static string GetCachedPath(string toolEntry, ExecutableInfo executableInfo, string minimumToolVersion)
 {
     return GetCachedPath("{0}/{1}/{2}".format(toolEntry, executableInfo, minimumToolVersion));
 }