Exemplo n.º 1
0
        public string GetModuleRefProps(uint token)
        {
            string name;
            IntPtr pName;
            uint   pchName, maxChName = 50;

            pName = Marshal.AllocCoTaskMem((int)(2 * maxChName + 1));
            importer.GetModuleRefProps(token, pName, maxChName, out pchName);
            if (pchName > maxChName)
            {
                Marshal.FreeCoTaskMem(pName);
                pName = Marshal.AllocCoTaskMem((int)(2 * pchName + 1));
                importer.GetModuleRefProps(token, pName, pchName, out pchName);
            }
            name = Marshal.PtrToStringUni(pName);
            Marshal.FreeCoTaskMem(pName);
            return(name);
        }
Exemplo n.º 2
0
        public ModuleRefProps GetModuleRefProps(uint token)
        {
            ModuleRefProps ret = new ModuleRefProps();

            ret.Token = token;
            ret.Name  = Util.GetString(delegate(uint pStringLenght, out uint stringLenght, System.IntPtr pString) {
                metaData.GetModuleRefProps(
                    token,
                    pString, pStringLenght, out stringLenght
                    );
            });
            return(ret);
        }
Exemplo n.º 3
0
        public IList <string> GetModuleNames(bool includeModuleDef)
        {
            List <string> names = new List <string>();
            List <uint>   moduleToks;

            GetModuleRefs(out moduleToks);

            char[] szName = new char[256];
            uint   actual;

            foreach (uint token in moduleToks)
            {
                m_import.GetModuleRefProps(token, szName, 256, out actual);
                names.Add(new string(szName, 0, (int)actual));
            }

            if (includeModuleDef)
            {
                Guid mvid = new Guid();
                m_import.GetScopeProps(szName, 256, out actual, ref mvid);
                names.Add(new string(szName, 0, (int)actual));
            }
            return(names);
        }
Exemplo n.º 4
0
		public unsafe static string GetModuleRefName(IMetaDataImport mdi, uint token) {
			if (mdi == null)
				return null;
			uint chName;
			char[] nameBuf = null;
			int hr = mdi.GetModuleRefProps(token, IntPtr.Zero, 0, out chName);
			if (hr >= 0 && chName != 0) {
				nameBuf = new char[chName];
				fixed (char* p = &nameBuf[0])
					hr = mdi.GetModuleRefProps(token, new IntPtr(p), (uint)nameBuf.Length, out chName);
			}
			if (hr < 0)
				return null;

			if (chName <= 1)
				return string.Empty;
			return new string(nameBuf, 0, (int)chName - 1);
		}