We need you! We're working hard on the next version of Developer Fusion -
Let us know what you think we should be up to!
- namespace Microsoft.Win32
- {
- using System;
- using System.IO;
- using System.Collections;
- using System.Runtime.InteropServices;
- using System.Runtime.CompilerServices;
- using System.Globalization;
- using StringBuilder = System.Text.StringBuilder;
- using Microsoft.Win32.SafeHandles;
-
-
-
- static internal class ASM_CACHE
- {
- public const uint ZAP = 1;
- public const uint GAC = 2;
- public const uint DOWNLOAD = 4;
- }
-
- static internal class CANOF
- {
- public const uint PARSE_DISPLAY_NAME = 1;
- public const uint SET_DEFAULT_VALUES = 2;
- }
-
- static internal class ASM_NAME
- {
- public const uint PUBLIC_KEY = 0;
- public const uint PUBLIC_KEY_TOKEN = PUBLIC_KEY + 1;
- public const uint HASH_VALUE = PUBLIC_KEY_TOKEN + 1;
- public const uint NAME = HASH_VALUE + 1;
- public const uint MAJOR_VERSION = NAME + 1;
- public const uint MINOR_VERSION = MAJOR_VERSION + 1;
- public const uint BUILD_NUMBER = MINOR_VERSION + 1;
- public const uint REVISION_NUMBER = BUILD_NUMBER + 1;
- public const uint CULTURE = REVISION_NUMBER + 1;
- public const uint PROCESSOR_ID_ARRAY = CULTURE + 1;
- public const uint OSINFO_ARRAY = PROCESSOR_ID_ARRAY + 1;
- public const uint HASH_ALGID = OSINFO_ARRAY + 1;
- public const uint ALIAS = HASH_ALGID + 1;
- public const uint CODEBASE_URL = ALIAS + 1;
- public const uint CODEBASE_LASTMOD = CODEBASE_URL + 1;
- public const uint NULL_PUBLIC_KEY = CODEBASE_LASTMOD + 1;
- public const uint NULL_PUBLIC_KEY_TOKEN = NULL_PUBLIC_KEY + 1;
- public const uint CUSTOM = NULL_PUBLIC_KEY_TOKEN + 1;
- public const uint NULL_CUSTOM = CUSTOM + 1;
- public const uint MVID = NULL_CUSTOM + 1;
- public const uint _32_BIT_ONLY = MVID + 1;
- public const uint MAX_PARAMS = _32_BIT_ONLY + 1;
- }
-
- static internal class Fusion
- {
- public static void ReadCache(ArrayList alAssems, string name, uint nFlag)
- {
- SafeFusionHandle aEnum = null;
- SafeFusionHandle aNameEnum = null;
- SafeFusionHandle AppCtx = SafeFusionHandle.InvalidHandle;
- int hr;
-
- if (name != null) {
- hr = Win32Native.CreateAssemblyNameObject(out aNameEnum, name, CANOF.PARSE_DISPLAY_NAME, IntPtr.Zero);
- if (hr != 0)
- Marshal.ThrowExceptionForHR(hr);
- }
-
- using (aNameEnum) {
-
- hr = Win32Native.CreateAssemblyEnum(out aEnum, AppCtx, aNameEnum, nFlag, IntPtr.Zero);
- if (hr != 0)
- Marshal.ThrowExceptionForHR(hr);
-
- using (aEnum) {
-
- for (;;)
- using (SafeFusionHandle aAppCtx = new SafeFusionHandle()SafeFusionHandle aName = new SafeFusionHandle()) {
- if (!GetNextAssembly(aEnum, aAppCtx, aName, 0))
- break;
-
- string sDisplayName = GetDisplayName(aName, 0);
- if (sDisplayName == null)
- continue;
-
- alAssems.Add(sDisplayName);
- }
-
- }
-
- }
-
- }
-
-
- [MethodImplAttribute(MethodImplOptions.InternalCall)]
- static extern bool GetNextAssembly(SafeFusionHandle pEnum, SafeFusionHandle pAppCtx, SafeFusionHandle pName, uint dwFlags);
-
- [MethodImplAttribute(MethodImplOptions.InternalCall)]
- static extern string GetDisplayName(SafeFusionHandle pName, uint dwDisplayFlags);
-
- }
- }