GetString() 개인적인 메소드

private GetString ( int index ) : string
index int
리턴 string
예제 #1
0
        private AssemblyName GetNameImpl(ref AssemblyTable.Record rec)
        {
            AssemblyName name = new AssemblyName();

            name.Name    = manifestModule.GetString(rec.Name);
            name.Version = new Version(rec.MajorVersion, rec.MinorVersion, rec.BuildNumber, rec.RevisionNumber);
            if (rec.PublicKey != 0)
            {
                name.SetPublicKey(manifestModule.GetBlobCopy(rec.PublicKey));
            }
            else
            {
                name.SetPublicKey(Empty <byte> .Array);
            }
            if (rec.Culture != 0)
            {
                name.Culture = manifestModule.GetString(rec.Culture);
            }
            else
            {
                name.Culture = "";
            }
            name.HashAlgorithm = (AssemblyHashAlgorithm)rec.HashAlgId;
            name.CodeBase      = this.CodeBase;
            name.RawFlags      = (AssemblyNameFlags)rec.Flags;
            return(name);
        }
예제 #2
0
 internal TypeDefImpl(ModuleReader module, int index)
 {
     this.module        = module;
     this.index         = index;
     this.typeName      = TypeNameParser.Escape(module.GetString(module.TypeDef.records[index].TypeName));
     this.typeNamespace = TypeNameParser.Escape(module.GetString(module.TypeDef.records[index].TypeNamespace));
 }
예제 #3
0
파일: TypeDefImpl.cs 프로젝트: ztzg/mono
		internal TypeDefImpl(ModuleReader module, int index)
		{
			this.module = module;
			this.index = index;
			this.typeName = module.GetString(module.TypeDef.records[index].TypeName);
			this.typeNamespace = module.GetString(module.TypeDef.records[index].TypeNamespace);
		}
예제 #4
0
 internal TypeDefImpl(ModuleReader module, int index)
 {
     this.module        = module;
     this.index         = index;
     this.typeName      = module.GetString(module.TypeDef.records[index].TypeName);
     this.typeNamespace = module.GetString(module.TypeDef.records[index].TypeNamespace);
     MarkEnumOrValueType(typeNamespace, typeName);
 }
예제 #5
0
 internal TypeDefImpl(ModuleReader module, int index)
 {
     this.module = module;
     this.index  = index;
     // empty typeName is not allowed, but obfuscators...
     this.typeName      = module.GetString(module.TypeDef.records[index].TypeName) ?? "";
     this.typeNamespace = module.GetString(module.TypeDef.records[index].TypeNamespace);
     MarkKnownType(typeNamespace, typeName);
 }
예제 #6
0
        private AssemblyName GetNameImpl(ref AssemblyTable.Record rec)
        {
            AssemblyName name = new AssemblyName();

            name.Name    = manifestModule.GetString(rec.Name);
            name.Version = new Version(rec.MajorVersion, rec.MinorVersion, rec.BuildNumber, rec.RevisionNumber);
            if (rec.PublicKey != 0)
            {
                name.SetPublicKey(manifestModule.GetBlobCopy(rec.PublicKey));
            }
            else
            {
                name.SetPublicKey(Empty <byte> .Array);
            }
            if (rec.Culture != 0)
            {
                name.CultureInfo = new System.Globalization.CultureInfo(manifestModule.GetString(rec.Culture));
            }
            else
            {
                name.CultureInfo = System.Globalization.CultureInfo.InvariantCulture;
            }
            switch (rec.HashAlgId)
            {
            case 0:
                name.HashAlgorithm = AssemblyHashAlgorithm.None;
                break;

            case 0x8003:
                name.HashAlgorithm = AssemblyHashAlgorithm.MD5;
                break;

            case 0x8004:
                name.HashAlgorithm = AssemblyHashAlgorithm.SHA1;
                break;

            default:
                throw new BadImageFormatException();
            }
            name.CodeBase = this.CodeBase;
            name.Flags    = (AssemblyNameFlags)rec.Flags;
            return(name);
        }
예제 #7
0
        private AssemblyName GetNameImpl(ref AssemblyTable.Record rec)
        {
            AssemblyName name = new AssemblyName();

            name.Name    = manifestModule.GetString(rec.Name);
            name.Version = new Version(rec.MajorVersion, rec.MinorVersion, rec.BuildNumber, rec.RevisionNumber);
            if (rec.PublicKey != 0)
            {
                name.SetPublicKey(manifestModule.GetBlobCopy(rec.PublicKey));
            }
            else
            {
                name.SetPublicKey(Empty <byte> .Array);
            }
            if (rec.Culture != 0)
            {
                name.Culture = manifestModule.GetString(rec.Culture);
            }
            else
            {
                name.Culture = "";
            }
            name.HashAlgorithm = (AssemblyHashAlgorithm)rec.HashAlgId;
            name.CodeBase      = this.CodeBase;
            PortableExecutableKinds peKind;
            ImageFileMachine        machine;

            manifestModule.GetPEKind(out peKind, out machine);
            switch (machine)
            {
            case ImageFileMachine.I386:
                // FXBUG we copy the .NET bug that Preferred32Bit implies x86
                if ((peKind & (PortableExecutableKinds.Required32Bit | PortableExecutableKinds.Preferred32Bit)) != 0)
                {
                    name.ProcessorArchitecture = ProcessorArchitecture.X86;
                }
                else if ((rec.Flags & 0x70) == 0x70)
                {
                    // it's a reference assembly
                    name.ProcessorArchitecture = ProcessorArchitecture.None;
                }
                else
                {
                    name.ProcessorArchitecture = ProcessorArchitecture.MSIL;
                }
                break;

            case ImageFileMachine.IA64:
                name.ProcessorArchitecture = ProcessorArchitecture.IA64;
                break;

            case ImageFileMachine.AMD64:
                name.ProcessorArchitecture = ProcessorArchitecture.Amd64;
                break;

            case ImageFileMachine.ARM:
                name.ProcessorArchitecture = ProcessorArchitecture.Arm;
                break;
            }
            name.RawFlags = (AssemblyNameFlags)rec.Flags;
            return(name);
        }
예제 #8
0
        private void CreateDllImportPseudoCustomAttribute(List <CustomAttributeData> attribs)
        {
            int token = this.MetadataToken;

            // TODO use binary search?
            for (int i = 0; i < module.ImplMap.records.Length; i++)
            {
                if (module.ImplMap.records[i].MemberForwarded == token)
                {
                    const short NoMangle          = 0x0001;
                    const short CharSetMask       = 0x0006;
                    const short CharSetNotSpec    = 0x0000;
                    const short CharSetAnsi       = 0x0002;
                    const short CharSetUnicode    = 0x0004;
                    const short CharSetAuto       = 0x0006;
                    const short SupportsLastError = 0x0040;
                    const short CallConvMask      = 0x0700;
                    const short CallConvWinapi    = 0x0100;
                    const short CallConvCdecl     = 0x0200;
                    const short CallConvStdcall   = 0x0300;
                    const short CallConvThiscall  = 0x0400;
                    const short CallConvFastcall  = 0x0500;
                    // non-standard flags
                    const short BestFitOn       = 0x0010;
                    const short BestFitOff      = 0x0020;
                    const short CharMapErrorOn  = 0x1000;
                    const short CharMapErrorOff = 0x2000;

                    Type            type        = module.universe.System_Runtime_InteropServices_DllImportAttribute;
                    ConstructorInfo constructor = type.GetConstructor(new Type[] { module.universe.System_String });
                    List <CustomAttributeNamedArgument> list = new List <CustomAttributeNamedArgument>();
                    int    flags      = module.ImplMap.records[i].MappingFlags;
                    string entryPoint = module.GetString(module.ImplMap.records[i].ImportName);
                    string dllName    = module.GetString(module.ModuleRef.records[(module.ImplMap.records[i].ImportScope & 0xFFFFFF) - 1]);
                    System.Runtime.InteropServices.CharSet?charSet;
                    switch (flags & CharSetMask)
                    {
                    case CharSetAnsi:
                        charSet = System.Runtime.InteropServices.CharSet.Ansi;
                        break;

                    case CharSetUnicode:
                        charSet = System.Runtime.InteropServices.CharSet.Unicode;
                        break;

                    case CharSetAuto:
                        charSet = System.Runtime.InteropServices.CharSet.Auto;
                        break;

                    case CharSetNotSpec:
                    default:
                        charSet = null;
                        break;
                    }
                    System.Runtime.InteropServices.CallingConvention callingConvention;
                    switch (flags & CallConvMask)
                    {
                    case CallConvCdecl:
                        callingConvention = System.Runtime.InteropServices.CallingConvention.Cdecl;
                        break;

                    case CallConvFastcall:
                        callingConvention = System.Runtime.InteropServices.CallingConvention.FastCall;
                        break;

                    case CallConvStdcall:
                        callingConvention = System.Runtime.InteropServices.CallingConvention.StdCall;
                        break;

                    case CallConvThiscall:
                        callingConvention = System.Runtime.InteropServices.CallingConvention.ThisCall;
                        break;

                    case CallConvWinapi:
                    default:
                        callingConvention = System.Runtime.InteropServices.CallingConvention.Winapi;
                        break;
                    }
                    list.Add(MakeNamedArgument(type, "EntryPoint", entryPoint));
                    list.Add(MakeNamedArgument(type, "ExactSpelling", flags, NoMangle));
                    list.Add(MakeNamedArgument(type, "SetLastError", flags, SupportsLastError));
                    list.Add(MakeNamedArgument(type, "PreserveSig", (int)GetMethodImplementationFlags(), (int)MethodImplAttributes.PreserveSig));
                    list.Add(MakeNamedArgument(type, "CallingConvention", (int)callingConvention));
                    if (charSet.HasValue)
                    {
                        list.Add(MakeNamedArgument(type, "CharSet", (int)charSet.Value));
                    }
                    if ((flags & (BestFitOn | BestFitOff)) != 0)
                    {
                        list.Add(MakeNamedArgument(type, "BestFitMapping", flags, BestFitOn));
                    }
                    if ((flags & (CharMapErrorOn | CharMapErrorOff)) != 0)
                    {
                        list.Add(MakeNamedArgument(type, "ThrowOnUnmappableChar", flags, CharMapErrorOn));
                    }
                    attribs.Add(new CustomAttributeData(constructor, new object[] { dllName }, list));
                    return;
                }
            }
        }