Ejemplo n.º 1
0
        public System.IO.Stream WriteToScs(Endianness endian = Endianness.BigEndian, Bitness bits = Bitness.B32, GameTextEncoding encoding = GameTextEncoding.ShiftJIS)
        {
            System.IO.Stream stream     = new System.IO.MemoryStream();
            uint             entryCount = (uint)Entries.Count;

            stream.WriteUInt32(entryCount.ToEndian(endian));
            for (uint i = 0; i < entryCount; ++i)
            {
                stream.WriteUInt32(0);                 // reserve space
            }
            List <long> positions = new List <long>();

            for (uint i = 0; i < entryCount; ++i)
            {
                string s = Entries[(int)i];
                if (s != null)
                {
                    positions.Add(stream.Position);
                    stream.WriteNulltermString(s, encoding);
                }
                else
                {
                    positions.Add(0);
                }
            }
            stream.Position = 4;
            for (uint i = 0; i < entryCount; ++i)
            {
                stream.WriteUInt32(((uint)positions[(int)i]).ToEndian(endian));
            }
            stream.Position = 0;
            return(stream);
        }
Ejemplo n.º 2
0
        private static void CreateAssembly(string assembly, Bitness bitness, Action <ModuleDefMD> modifyAction = null)
        {
            var creationOptions = new ModuleCreationOptions
            {
                Context = ModuleDef.CreateModuleContext(),
                TryToLoadPdbFromDisk = true
            };

            using var module = ModuleDefMD.Load(assembly, creationOptions);

            ChangeBitness(module, bitness);

            modifyAction?.Invoke(module);

            DisableEditAndContinueForModule(module);

            var path         = Path.GetDirectoryName(module.Location);
            var filename     = Path.GetFileNameWithoutExtension(module.Location);
            var extension    = Path.GetExtension(module.Location);
            var saveFilename = $"{filename}.{bitness}{extension}";

            module.Name = saveFilename;

            var moduleWriterOptions = new ModuleWriterOptions(module)
            {
                AddCheckSum = true,
                WritePdb    = true
            };
            var moduleWriter = new ModuleWriter(module, moduleWriterOptions);

            ReplaceMSCOREEReferenceWithIJWHostForNetCoreApp(module, moduleWriter);

            moduleWriter.Write(Path.Combine(path, saveFilename));
        }
Ejemplo n.º 3
0
 public RegistryEntry(string key, string name, string value, RegistryValueKind type, Bitness bitness, FileMap fileMap)
 {
     Key     = key;
     Name    = name;
     Value   = fileMap.Replace(value);
     Type    = type;
     Bitness = bitness;
 }
Ejemplo n.º 4
0
        /// <summary>
        /// Initializes the <see cref="HawkeyeApplication"/> class.
        /// </summary>
        static HawkeyeApplication()
        {
            applicationInfo = new HawkeyeApplicationInfo();

            var clrVersion = typeof(int).Assembly.GetName().Version;
            currentClr = clrVersion.Major == 4 ? Clr.Net4 : Clr.Net2;
            currentBitness = IntPtr.Size == 8 ? Bitness.x64 : Bitness.x86;

            Shell = new Shell();
        }
Ejemplo n.º 5
0
        public bool TryFindExcelBitness(string excelExePath, out Bitness bitness)
        {
            bitness = Bitness.Unknown;

            if (!File.Exists(excelExePath))
            {
                throw new Exception("Excel path specified in Registry not found on disk: " + excelExePath);
            }

            using (var fileStream = File.OpenRead(excelExePath))
            {
                using (var reader = new BinaryReader(fileStream))
                {
                    // See http://www.microsoft.com/whdc/system/platform/firmware/PECOFF.mspx
                    // Offset to PE header is always at 0x3C.
                    // The PE header starts with "PE\0\0" =  0x50 0x45 0x00 0x00,
                    // followed by a 2-byte machine type field (see the document above for the enum).

                    fileStream.Seek(0x3c, SeekOrigin.Begin);
                    var peOffset = reader.ReadInt32();

                    fileStream.Seek(peOffset, SeekOrigin.Begin);
                    var peHead = reader.ReadUInt32();

                    if (peHead != 0x00004550) // "PE\0\0", little-endian
                    {
                        throw new Exception("Unable to find PE header in file");
                    }

                    var machineType = (MachineType)reader.ReadUInt16();

                    switch (machineType)
                    {
                    case MachineType.ImageFileMachineI386:
                    {
                        bitness = Bitness.Bit32;
                        return(true);
                    }

                    case MachineType.ImageFileMachineAmd64:
                    case MachineType.ImageFileMachineIa64:
                    {
                        bitness = Bitness.Bit64;
                        return(true);
                    }

                    default:
                    {
                        bitness = Bitness.Unknown;
                        return(false);
                    }
                    }
                }
            }
        }
Ejemplo n.º 6
0
        /// <summary>
        /// Initializes the <see cref="HawkeyeApplication"/> class.
        /// </summary>
        static HawkeyeApplication()
        {
            applicationInfo = new HawkeyeApplicationInfo();

            var clrVersion = typeof(int).Assembly.GetName().Version;

            currentClr     = clrVersion.Major == 4 ? Clr.Net4 : Clr.Net2;
            currentBitness = IntPtr.Size == 8 ? Bitness.x64 : Bitness.x86;

            Shell = new Shell();
        }
Ejemplo n.º 7
0
        public static HashSet <string> GetHostAbis(OS osType = OS.Any, Bitness bitness = Bitness.Any, bool includeAllHostOSes = true)
        {
            IEnumerable <string> abis = KnownAbis.Where
                                            (a =>
                                            a.Type == AbiType.HostJit &&
                                            OSMatches(a, osType) &&
                                            BitnessMatches(a, bitness) &&
                                            (includeAllHostOSes || IsCurrentHostOS(a))).Select(a => a.Name);

            return(MakeHashSet(abis));
        }
Ejemplo n.º 8
0
 /// <summary>
 /// Gets a value indicating if the bitness is supported
 /// </summary>
 /// <param name="bitness">The bitness.</param>
 /// <returns>True if supported.</returns>
 public override bool SupportsProjectBitness(Bitness bitness)
 {
     SafeDebug.Assume(bitness != Bitness.Unsupported, "bitness != Bitness.Unsupported");
     if (Net2process)
     {
         return(bitness == Bitness.AnyCpu || bitness == Bitness.x86);
     }
     else
     {
         return(true);
     }
 }
Ejemplo n.º 9
0
        private static string GetBootstrap(Clr clr, Bitness bitness)
        {
            string bitnessVersion;

            switch (bitness)
            {
            case Bitness.x86:
                bitnessVersion = "x86";
                break;

            case Bitness.x64:
                bitnessVersion = "x64";
                break;

            default: throw new ArgumentException($"Bitness Value {bitness} is invalid.", nameof(bitness));
            }

            string directory = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location);

            // Very special case: Hawkeye is x86 and the spied process is x64: we can't know for sure
            // whether the process is .NET 2 or 4 or none.
            // So, we must simply re-run Hawkeye.exe (which is compiled as Any Cpu and therefore
            // will run as x64 in a x64 environment) passing it the handle of the spied window so that another
            // detection is achieved, this time from a x64 process.
            // Note that because we run Hawkeye.exe, we won't inject anything.
            if (clr == Clr.Undefined && HawkeyeApplication.CurrentBitness == Bitness.x86 && bitness == Bitness.x64)
            {
                return(Path.Combine(directory, "Hawkeye.exe"));
            }

            string clrVersion = string.Empty;

            switch (clr)
            {
            case Clr.Net2:
                clrVersion = "N2";
                break;

            case Clr.Net4:
                clrVersion = "N4";
                break;

            default:
                throw new ArgumentException(
                          $"Clr Value {clr} is invalid.", nameof(clr));
            }

            string exe = $"HawkeyeBootstrap{clrVersion}{bitnessVersion}.exe";

            return(Path.Combine(directory, exe));
        }
Ejemplo n.º 10
0
        static bool BitnessMatches(Abi abi, Bitness bitness)
        {
            if (bitness == Bitness.Any)
            {
                return(true);
            }

            if (bitness == Bitness.ThirtyTwo)
            {
                return(!abi.Is64Bit);
            }

            return(abi.Is64Bit);
        }
Ejemplo n.º 11
0
        public static long PeekInt(this Stream s, Bitness bits, Endianness endian)
        {
            switch (bits)
            {
            case Bitness.B8: return(s.PeekInt8());

            case Bitness.B16: return(s.PeekInt16().FromEndian(endian));

            case Bitness.B32: return(s.PeekInt32().FromEndian(endian));

            case Bitness.B64: return(s.PeekInt64().FromEndian(endian));
            }
            throw new Exception("Peeking int not implemented for bitness " + bits.ToString());
        }
Ejemplo n.º 12
0
        public static uint NumberOfBytes(this Bitness bits)
        {
            switch (bits)
            {
            case Bitness.B8: return(1);

            case Bitness.B16: return(2);

            case Bitness.B32: return(4);

            case Bitness.B64: return(8);
            }
            throw new Exception("Number of bits not implemented for bitness " + bits.ToString());
        }
Ejemplo n.º 13
0
        public string To_XML()
        {
            var ret = "<os>";

            ret += "<type arch='" + Bitness.ToString() + "' machine='" + machine + "'>" + type.ToString() + "</type>";//is everything a pc? I dont know..
            foreach (var item in BootOrder)
            {
                ret += "<boot dev='" + item.ToString() + "'/>";
            }
            if (ShowBootMenu)
            {
                ret += "<bootmenu enable='yes' timeout='3000'/>";
            }
            ret += "</os>";
            return(ret);
        }
        private string ReplacePlaceholder(string value, Bitness bitness)
        {
            switch (value)
            {
            case PlaceHolders.InstallPath:
                return(InstallPathVariable);

            case PlaceHolders.DllPath:
                return(string.Format(DllPathVariable, _dllName));

            case PlaceHolders.TlbPath:
                return(bitness == Bitness.Is64Bit ? string.Format(Tlb64PathVariable, _tlb64Name) : string.Format(Tlb32PathVariable, _tlb32Name));

            default:
                return(value);
            }
        }
Ejemplo n.º 15
0
        private string ReplacePlaceholder(string value, Bitness bitness)
        {
            switch (value)
            {
            case PlaceHolders.InstallPath:
                return(InstallPathVariable);

            case PlaceHolders.DllPath:
                return(DllPathVariable);

            case PlaceHolders.TlbPath:
                return(bitness == Bitness.Is64Bit ? Tlb64PathVariable : Tlb32PathVariable);

            default:
                return(value);
            }
        }
Ejemplo n.º 16
0
        private string ReplacePlaceholder(string value, Bitness bitness)
        {
            Debug.Assert(!string.IsNullOrWhiteSpace(CurrentPath));

            switch (value)
            {
            case PlaceHolders.InstallPath:
                return(CurrentPath);

            case PlaceHolders.DllPath:
                return(Path.Combine(CurrentPath, _dllName));

            case PlaceHolders.TlbPath:
                return(Path.Combine(CurrentPath, bitness == Bitness.Is64Bit ? _tlb64Name : _tlb32Name));

            default:
                return(value);
            }
        }
Ejemplo n.º 17
0
        private static void ChangeBitness(ModuleDefMD module, Bitness bitness)
        {
            switch (bitness)
            {
            case Bitness.x86:
                module.Machine           = dnlib.PE.Machine.I386;
                module.Cor20HeaderFlags &= ~ComImageFlags.ILOnly;
                module.Cor20HeaderFlags &= ~ComImageFlags.Bit32Preferred;
                module.Cor20HeaderFlags |= ComImageFlags.Bit32Required;
                break;

            case Bitness.x64:
                module.Machine           = dnlib.PE.Machine.AMD64;
                module.Cor20HeaderFlags &= ~ComImageFlags.ILOnly;
                module.Cor20HeaderFlags &= ~ComImageFlags.Bit32Preferred;
                module.Cor20HeaderFlags &= ~ComImageFlags.Bit32Required;
                break;
            }
        }
Ejemplo n.º 18
0
        private string ReplacePlaceholder(string value, Bitness bitness)
        {
            if (_currentPath == null)
            {
                _currentPath = AssemblyDirectory;
            }

            switch (value)
            {
            case PlaceHolders.InstallPath:
                return(_currentPath);

            case PlaceHolders.DllPath:
                return(Path.Combine(_currentPath, "Rubberduck.dll"));

            case PlaceHolders.TlbPath:
                return(Path.Combine(_currentPath, bitness == Bitness.Is64Bit ? "Rubberduck.x64.tlb" : "Rubberduck.x32.tlb"));

            default:
                return(value);
            }
        }
Ejemplo n.º 19
0
        private string ReplacePlaceholder(string value, Bitness bitness)
        {
            if (_currentPath == null)
            {
                _currentPath = AssemblyDirectory;
            }

            switch (value)
            {
            case PlaceHolders.InstallPath:
                return(_currentPath);

            case PlaceHolders.DllPath:
                return(Path.Combine(_currentPath, _dllName));

            case PlaceHolders.TlbPath:
                return(Path.Combine(_currentPath, bitness == Bitness.Is64Bit ? _tlb64Name : _tlb32Name));

            default:
                return(value);
            }
        }
Ejemplo n.º 20
0
        private static void GetBinaryData(XmlReader reader, ScanAndTempProperties <TScan, TRun> scan)
        {
            string      base64              = string.Empty;
            Bitness     bitness             = Bitness.NotSet;
            bool        isIntensityArray    = false;
            bool        isMzArray           = false;
            bool        binaryDataArrayRead = false;
            Compression compression         = Compression.Uncompressed;

            while (reader.Read() && !binaryDataArrayRead)
            {
                if (reader.IsStartElement())
                {
                    if ("cvParam".Equals(reader.LocalName))
                    {
                        switch (reader.GetAttribute("accession"))
                        {
                        case "MS:1000574":
                            if ("zlib compression".Equals(reader.GetAttribute("name")))
                            {
                                compression = Compression.Zlib;
                            }
                            break;

                        case "MS:1000521":
                            //32 bit float
                            bitness = Bitness.IEEE754FloatLittleEndian;
                            break;

                        case "MS:1000523":
                            //64 bit float
                            bitness = Bitness.IEEE754DoubleLittleEndian;
                            break;

                        case "MS:1000515":
                            //intensity array
                            isIntensityArray = true;
                            break;

                        case "MS:1000514":
                            //mz array
                            isMzArray = true;
                            break;
                        }
                    }
                    else if ("binary".Equals(reader.LocalName))
                    {
                        reader.ReadStartElement();
                        base64 = reader.ReadContentAsString();
                    }
                }
                else if (reader.NodeType == XmlNodeType.EndElement && "binaryDataArray".Equals(reader.LocalName))
                {
                    binaryDataArrayRead = true;
                    Base64StringAndDecodingHints base64StringAndDecodingHints = new Base64StringAndDecodingHints(base64, compression, bitness);
                    if (isIntensityArray)
                    {
                        scan.Intensities = base64StringAndDecodingHints;
                    }
                    else if (isMzArray)
                    {
                        scan.Mzs = base64StringAndDecodingHints;
                    }
                }
            }
        }
Ejemplo n.º 21
0
        // NOTE: Construction of this thing is quite inefficient-- it
        //       has several nested loops that could probably be
        //       improved. Such optimizations have been left for when
        //       it turns out to be a performance problem, for the
        //       sake of simplicity.
        //
        public ServiceInfo(Guid clsid,
                            ServiceElement service,
                            ComCatalogObject application,
                            ComCatalogObject classObject,
                            HostingMode hostingMode)
        {
            // Simple things...
            //
            this.service = service;
            this.clsid = clsid;
            this.appid = Fx.CreateGuid((string)application.GetValue("ID"));
            this.partitionId = Fx.CreateGuid((string)application.GetValue("AppPartitionID"));
            this.bitness = (Bitness)classObject.GetValue("Bitness");
            this.transactionOption = (TransactionOption)classObject.GetValue("Transaction");
            this.hostingMode = hostingMode;
            this.managedType = TypeCacheManager.ResolveClsidToType(clsid);
            this.serviceName = application.Name + "." + classObject.Name;
            this.udts = new Dictionary<Guid, List<Type>>();

            // Isolation Level
            COMAdminIsolationLevel adminIsolationLevel;
            adminIsolationLevel = (COMAdminIsolationLevel)classObject.GetValue("TxIsolationLevel");
            switch (adminIsolationLevel)
            {
                case COMAdminIsolationLevel.Any:
                    this.isolationLevel = IsolationLevel.Unspecified;
                    break;
                case COMAdminIsolationLevel.ReadUncommitted:
                    this.isolationLevel = IsolationLevel.ReadUncommitted;
                    break;
                case COMAdminIsolationLevel.ReadCommitted:
                    this.isolationLevel = IsolationLevel.ReadCommitted;
                    break;
                case COMAdminIsolationLevel.RepeatableRead:
                    this.isolationLevel = IsolationLevel.RepeatableRead;
                    break;
                case COMAdminIsolationLevel.Serializable:
                    this.isolationLevel = IsolationLevel.Serializable;
                    break;
                default:
                    throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(Error.ListenerInitFailed(
                        SR.GetString(SR.InvalidIsolationLevelValue,
                                     this.clsid, adminIsolationLevel)));
            }

            // Threading Model
            //
            COMAdminThreadingModel adminThreadingModel;
            adminThreadingModel = (COMAdminThreadingModel)classObject.GetValue("ThreadingModel");
            switch (adminThreadingModel)
            {
                case COMAdminThreadingModel.Apartment:
                case COMAdminThreadingModel.Main:
                    this.threadingModel = ThreadingModel.STA;
                    objectPoolingEnabled = false;
                    break;

                default:
                    this.threadingModel = ThreadingModel.MTA;
                    objectPoolingEnabled = (bool)classObject.GetValue("ObjectPoolingEnabled");
                    break;
            }

            // Object Pool settings
            // 

            if (objectPoolingEnabled)
            {
                maxPoolSize = (int)classObject.GetValue("MaxPoolSize");
            }
            else
                maxPoolSize = 0;
            // Security Settings
            //
            bool appSecurityEnabled;
            appSecurityEnabled = (bool)application.GetValue(
                "ApplicationAccessChecksEnabled");
            if (appSecurityEnabled)
            {

                bool classSecurityEnabled;
                classSecurityEnabled = (bool)classObject.GetValue(
                    "ComponentAccessChecksEnabled");
                if (classSecurityEnabled)
                {
                    this.checkRoles = true;
                }
            }

            // Component Roles
            //
            ComCatalogCollection roles;
            roles = classObject.GetCollection("RolesForComponent");
            this.componentRoleMembers = CatalogUtil.GetRoleMembers(application, roles);
            // Contracts
            // One ContractInfo per unique IID exposed, so we need to
            // filter duplicates.
            //
            this.contracts = new List<ContractInfo>();
            ComCatalogCollection interfaces;
            interfaces = classObject.GetCollection("InterfacesForComponent");
            foreach (ServiceEndpointElement endpoint in service.Endpoints)
            {
                ContractInfo contract = null;
                if (endpoint.Contract == ServiceMetadataBehavior.MexContractName)
                    continue;

                Guid iid;
                if (DiagnosticUtility.Utility.TryCreateGuid(endpoint.Contract, out iid))
                {
                    // (Filter duplicates.)
                    bool duplicate = false;
                    foreach (ContractInfo otherContract in this.contracts)
                    {
                        if (iid == otherContract.IID)
                        {
                            duplicate = true;
                            break;
                        }
                    }
                    if (duplicate) continue;

                    foreach (ComCatalogObject interfaceObject in interfaces)
                    {
                        Guid otherInterfaceID;
                        if (DiagnosticUtility.Utility.TryCreateGuid((string)interfaceObject.GetValue("IID"), out otherInterfaceID))
                        {
                            if (otherInterfaceID == iid)
                            {
                                contract = new ContractInfo(iid,
                                                            endpoint,
                                                            interfaceObject,
                                                            application);
                                break;
                            }
                        }
                    }
                }

                if (contract == null)
                {
                    throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(Error.ListenerInitFailed(
                        SR.GetString(SR.EndpointNotAnIID,
                                     clsid.ToString("B").ToUpperInvariant(),
                                     endpoint.Contract)));
                }
                this.contracts.Add(contract);
            }
        }
Ejemplo n.º 22
0
 public static HashSet <string> GetTargetJitAbis(Bitness bitness = Bitness.Any)
 {
     return(MakeHashSet(KnownAbis.Where(a => a.Type == AbiType.TargetJit && BitnessMatches(a, bitness)).Select(a => a.Name)));
 }
Ejemplo n.º 23
0
        private static string GetBootstrap(Clr clr, Bitness bitness)
        {
            var bitnessVersion = string.Empty;
            switch (bitness)
            {
                case Bitness.x86: bitnessVersion = "x86"; break;
                case Bitness.x64: bitnessVersion = "x64"; break;
                default: throw new ArgumentException(string.Format(
                    "Bitness Value {0} is invalid.", bitness), "bitness");
            }

            var directory = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location);

            // Very special case: Hawkeye is x86 and the spied process is x64: we can't know for sure
            // whether the process is .NET 2 or 4 or none.
            // So, we must simply re-run Hawkeye.exe (which is compiled as Any Cpu and therefore
            // will run as x64 in a x64 environment) passing it the handle of the spied window so that another
            // detection is achieved, this time from a x64 process.
            // Note that because we run Hawkeye.exe, we won't inject anything.
            if (clr == Clr.Undefined && HawkeyeApplication.CurrentBitness == Bitness.x86 && bitness == Bitness.x64)
                return Path.Combine(directory, "Hawkeye.exe");

            var clrVersion = string.Empty;
            switch (clr)
            {
                case Clr.Net2: clrVersion = "N2"; break;
                case Clr.Net4: clrVersion = "N4"; break;
                default: throw new ArgumentException(
                    string.Format("Clr Value {0} is invalid.", clr), "clr");
            }

            var exe = string.Format("HawkeyeBootstrap{0}{1}.exe", clrVersion, bitnessVersion);
            return Path.Combine(directory, exe);
        }
Ejemplo n.º 24
0
 public JitBinary(Bitness bitness)
 {
     bness = bitness;
 }
Ejemplo n.º 25
0
 /// <summary>
 /// The supports project bitness.
 /// </summary>
 /// <param name="bitness">
 /// The bitness.
 /// </param>
 /// <returns>
 /// The <see cref="bool"/>.
 /// </returns>
 public override bool SupportsProjectBitness(Bitness bitness)
 {
     SafeDebug.Assume(bitness != Bitness.Unsupported, "bitness != Bitness.Unsupported");
     return(true);
 }
Ejemplo n.º 26
0
 public static HashSet <string> GetCrossAbis(OS osType = OS.Any, Bitness bitness = Bitness.Any)
 {
     return(MakeHashSet(KnownAbis.Where(a => a.Type == AbiType.CrossAot && OSMatches(a, osType) && BitnessMatches(a, bitness)).Select(a => a.Name)));
 }
 /// <summary>
 /// The supports project bitness.
 /// </summary>
 /// <param name="bitness">
 /// The bitness.
 /// </param>
 /// <returns>
 /// The <see cref="bool"/>.
 /// </returns>
 public override bool SupportsProjectBitness(Bitness bitness)
 {
     SafeDebug.Assume(bitness != Bitness.Unsupported, "bitness != Bitness.Unsupported");
     return true;
 }
Ejemplo n.º 28
0
        // NOTE: Construction of this thing is quite inefficient-- it
        //       has several nested loops that could probably be
        //       improved. Such optimizations have been left for when
        //       it turns out to be a performance problem, for the
        //       sake of simplicity.
        //
        public ServiceInfo(Guid clsid,
                           ServiceElement service,
                           ComCatalogObject application,
                           ComCatalogObject classObject,
                           HostingMode hostingMode)
        {
            // Simple things...
            //
            this.service           = service;
            this.clsid             = clsid;
            this.appid             = Fx.CreateGuid((string)application.GetValue("ID"));
            this.partitionId       = Fx.CreateGuid((string)application.GetValue("AppPartitionID"));
            this.bitness           = (Bitness)classObject.GetValue("Bitness");
            this.transactionOption = (TransactionOption)classObject.GetValue("Transaction");
            this.hostingMode       = hostingMode;
            this.managedType       = TypeCacheManager.ResolveClsidToType(clsid);
            this.serviceName       = application.Name + "." + classObject.Name;
            this.udts = new Dictionary <Guid, List <Type> >();

            // Isolation Level
            COMAdminIsolationLevel adminIsolationLevel;

            adminIsolationLevel = (COMAdminIsolationLevel)classObject.GetValue("TxIsolationLevel");
            switch (adminIsolationLevel)
            {
            case COMAdminIsolationLevel.Any:
                this.isolationLevel = IsolationLevel.Unspecified;
                break;

            case COMAdminIsolationLevel.ReadUncommitted:
                this.isolationLevel = IsolationLevel.ReadUncommitted;
                break;

            case COMAdminIsolationLevel.ReadCommitted:
                this.isolationLevel = IsolationLevel.ReadCommitted;
                break;

            case COMAdminIsolationLevel.RepeatableRead:
                this.isolationLevel = IsolationLevel.RepeatableRead;
                break;

            case COMAdminIsolationLevel.Serializable:
                this.isolationLevel = IsolationLevel.Serializable;
                break;

            default:
                throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(Error.ListenerInitFailed(
                                                                              SR.GetString(SR.InvalidIsolationLevelValue,
                                                                                           this.clsid, adminIsolationLevel)));
            }

            // Threading Model
            //
            COMAdminThreadingModel adminThreadingModel;

            adminThreadingModel = (COMAdminThreadingModel)classObject.GetValue("ThreadingModel");
            switch (adminThreadingModel)
            {
            case COMAdminThreadingModel.Apartment:
            case COMAdminThreadingModel.Main:
                this.threadingModel  = ThreadingModel.STA;
                objectPoolingEnabled = false;
                break;

            default:
                this.threadingModel  = ThreadingModel.MTA;
                objectPoolingEnabled = (bool)classObject.GetValue("ObjectPoolingEnabled");
                break;
            }

            // Object Pool settings
            //

            if (objectPoolingEnabled)
            {
                maxPoolSize = (int)classObject.GetValue("MaxPoolSize");
            }
            else
            {
                maxPoolSize = 0;
            }
            // Security Settings
            //
            bool appSecurityEnabled;

            appSecurityEnabled = (bool)application.GetValue(
                "ApplicationAccessChecksEnabled");
            if (appSecurityEnabled)
            {
                bool classSecurityEnabled;
                classSecurityEnabled = (bool)classObject.GetValue(
                    "ComponentAccessChecksEnabled");
                if (classSecurityEnabled)
                {
                    this.checkRoles = true;
                }
            }

            // Component Roles
            //
            ComCatalogCollection roles;

            roles = classObject.GetCollection("RolesForComponent");
            this.componentRoleMembers = CatalogUtil.GetRoleMembers(application, roles);
            // Contracts
            // One ContractInfo per unique IID exposed, so we need to
            // filter duplicates.
            //
            this.contracts = new List <ContractInfo>();
            ComCatalogCollection interfaces;

            interfaces = classObject.GetCollection("InterfacesForComponent");
            foreach (ServiceEndpointElement endpoint in service.Endpoints)
            {
                ContractInfo contract = null;
                if (endpoint.Contract == ServiceMetadataBehavior.MexContractName)
                {
                    continue;
                }

                Guid iid;
                if (DiagnosticUtility.Utility.TryCreateGuid(endpoint.Contract, out iid))
                {
                    // (Filter duplicates.)
                    bool duplicate = false;
                    foreach (ContractInfo otherContract in this.contracts)
                    {
                        if (iid == otherContract.IID)
                        {
                            duplicate = true;
                            break;
                        }
                    }
                    if (duplicate)
                    {
                        continue;
                    }

                    foreach (ComCatalogObject interfaceObject in interfaces)
                    {
                        Guid otherInterfaceID;
                        if (DiagnosticUtility.Utility.TryCreateGuid((string)interfaceObject.GetValue("IID"), out otherInterfaceID))
                        {
                            if (otherInterfaceID == iid)
                            {
                                contract = new ContractInfo(iid,
                                                            endpoint,
                                                            interfaceObject,
                                                            application);
                                break;
                            }
                        }
                    }
                }

                if (contract == null)
                {
                    throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(Error.ListenerInitFailed(
                                                                                  SR.GetString(SR.EndpointNotAnIID,
                                                                                               clsid.ToString("B").ToUpperInvariant(),
                                                                                               endpoint.Contract)));
                }
                this.contracts.Add(contract);
            }
        }
 /// <inheritdoc/>
 public override bool SupportsProjectBitness(Bitness bitness)
 {
     return true;
 }
Ejemplo n.º 30
0
 public Base64StringAndDecodingHints(string base64Data, Compression compression, Bitness bitness)
 {
     Base64Data  = base64Data;
     Compression = compression;
     Bitness     = bitness;
 }
Ejemplo n.º 31
0
 /// <summary>
 /// Ctor.
 /// </summary>
 /// <param name="platform">Binary platform.</param>
 /// <param name="bitness">Binary bitness.</param>
 /// <param name="files">A collection of files for this bitness and platform.</param>
 public LibraryItem(Platform platform, Bitness bitness, params LibraryFile[] files)
 {
     Platform = platform;
     Bitness  = bitness;
     Files    = files;
 }
Ejemplo n.º 32
0
        public SCS(DuplicatableStream stream, Endianness endian = Endianness.BigEndian, Bitness bits = Bitness.B32, GameTextEncoding encoding = GameTextEncoding.ShiftJIS)
        {
            ulong entryCount = stream.ReadUInt(bits, endian);

            Entries = new List <string>((int)entryCount);
            for (uint i = 0; i < entryCount; ++i)
            {
                ulong offset = stream.ReadUInt(bits, endian);
                if (offset != 0)
                {
                    Entries.Add(stream.ReadNulltermStringFromLocationAndReset(offset, encoding));
                }
                else
                {
                    Entries.Add(null);
                }
            }
        }
Ejemplo n.º 33
0
 public SCS(string filename, Endianness endian = Endianness.BigEndian, Bitness bits = Bitness.B32, GameTextEncoding encoding = GameTextEncoding.ShiftJIS)
     : this(new DuplicatableFileStream(filename), endian, bits, encoding)
 {
 }
Ejemplo n.º 34
0
 public BitInstance(string data, Bitness bitness)
 {
     Data    = data;
     Bitness = Bitness;
 }
Ejemplo n.º 35
0
 /// <inheritdoc/>
 public override bool SupportsProjectBitness(Bitness bitness)
 {
     return(true);
 }