private static string GetFusionString(SystemOp.IAssemblyName assemblyName, uint item) { string text1 = string.Empty; uint num1 = 0; if ((assemblyName.GetProperty(item, IntPtr.Zero, ref num1) == 0) && (num1 > 0)) { IntPtr ptr1 = IntPtr.Zero; try { ptr1 = Marshal.AllocHGlobal((int)((num1 + 1) * 2)); if (assemblyName.GetProperty(item, ptr1, ref num1) == 0) { text1 = Marshal.PtrToStringUni(ptr1); } } finally { if (ptr1 != IntPtr.Zero) { Marshal.FreeHGlobal(ptr1); } } } return(text1); }
/// <exclude/> public static ICollection GetAssemblies() { ArrayList list1 = new ArrayList(); SystemOp.IAssemblyEnum enum1 = null; SystemOp.IAssemblyName name1 = null; int num1 = SystemOp.CreateAssemblyEnum(out enum1, IntPtr.Zero, null, 2, 0); while (num1 == 0) { num1 = enum1.GetNextAssembly(IntPtr.Zero, out name1, 0); if (num1 == 0) { uint num2 = 0; name1.GetDisplayName(IntPtr.Zero, ref num2, 0); if (num2 > 0) { IntPtr ptr1 = IntPtr.Zero; string text1 = null; try { ptr1 = Marshal.AllocHGlobal((int)((num2 + 1) * 2)); name1.GetDisplayName(ptr1, ref num2, 0); text1 = Marshal.PtrToStringUni(ptr1); } finally { if (ptr1 != IntPtr.Zero) { Marshal.FreeHGlobal(ptr1); } } if (text1 != null) { AssemblyName name2 = new AssemblyName(); string[] textArray1 = text1.Split(new char[] { ',' }); if (textArray1.Length >= 4) { try { name2.Name = textArray1[0]; name2.Version = new Version(textArray1[1].Substring(textArray1[1].IndexOf('=') + 1)); string text2 = textArray1[3].Substring(textArray1[3].IndexOf('=') + 1); if (!text2.Equals("null")) { byte[] buffer1 = new byte[text2.Length / 2]; for (int num3 = 0; num3 < buffer1.Length; num3++) { buffer1[num3] = byte.Parse(text2.Substring(num3 * 2, 2), NumberStyles.HexNumber); } name2.SetPublicKeyToken(buffer1); } name2.CodeBase = GacUtil.GetFusionString(name1, 13); string text3 = GacUtil.GetFusionString(name1, 8); name2.CultureInfo = new CultureInfo(text3); list1.Add(name2); continue; } catch (Exception) { continue; } } } } } } return(list1); }