Пример #1
0
 private static void Initialize(Assembly assembly)
 {
     lock (Instrumentation.instrumentedAssemblies)
     {
         if (!Instrumentation.instrumentedAssemblies.ContainsKey(assembly))
         {
             SchemaNaming schemaNaming = SchemaNaming.GetSchemaNaming(assembly);
             if (schemaNaming != null)
             {
                 if (!schemaNaming.IsAssemblyRegistered())
                 {
                     if (WMICapabilities.IsUserAdmin())
                     {
                         schemaNaming.DecoupledProviderInstanceName = AssemblyNameUtility.UniqueToAssemblyFullVersion(assembly);
                         schemaNaming.RegisterNonAssemblySpecificSchema(null);
                         schemaNaming.RegisterAssemblySpecificSchema();
                     }
                     else
                     {
                         throw new Exception(RC.GetString("ASSEMBLY_NOT_REGISTERED"));
                     }
                 }
                 InstrumentedAssembly instrumentedAssembly = new InstrumentedAssembly(assembly, schemaNaming);
                 Instrumentation.instrumentedAssemblies.Add(assembly, instrumentedAssembly);
             }
         }
     }
 }
Пример #2
0
        private static void Initialize(Assembly assembly)
        {
            lock (instrumentedAssemblies)
            {
                if (instrumentedAssemblies.ContainsKey(assembly))
                {
                    return;
                }

                SchemaNaming naming = SchemaNaming.GetSchemaNaming(assembly);
                if (naming == null)
                {
                    return;
                }

                if (false == naming.IsAssemblyRegistered())
                {
                    // If we are not an administrator, don't try to JIT install the schema
                    if (!WMICapabilities.IsUserAdmin())
                    {
                        throw new Exception(RC.GetString("ASSEMBLY_NOT_REGISTERED"));
                    }

                    naming.RegisterNonAssemblySpecificSchema(null);
                    naming.RegisterAssemblySpecificSchema();
                }

                InstrumentedAssembly instrumentedAssembly = new InstrumentedAssembly(assembly, naming);
                instrumentedAssemblies.Add(assembly, instrumentedAssembly);
            }
        }
Пример #3
0
        public void RegisterAssemblySpecificSchema()
        {
            Type[] types = InstrumentedAttribute.GetInstrumentedTypes(assembly);

            StringCollection events    = new StringCollection();
            StringCollection instances = new StringCollection();
            StringCollection abstracts = new StringCollection();

            string[] mofs = new string[types.Length];

            HelperAssembly helper = new HelperAssembly("WMINET_Converter", NamespaceName);

            for (int i = 0; i < types.Length; i++)
            {
                SchemaMapping mapping = new SchemaMapping(types[i], this);
                ReplaceClassIfNecessary(mapping.ClassPath, mapping.NewClass);
                mofs[i] = GetMofFormat(mapping.NewClass);
                switch (mapping.InstrumentationType)
                {
                case InstrumentationType.Event:
                    events.Add(mapping.ClassName);
                    helper.AddType(mapping.ClassType);
                    break;

                case InstrumentationType.Instance:
                    instances.Add(mapping.ClassName);
                    helper.AddType(mapping.ClassType);
                    break;

                case InstrumentationType.Abstract:
                    abstracts.Add(mapping.ClassName);
                    break;

                default:
                    break;
                }
            }

            RegisterAssemblySpecificDecoupledProviderInstance();
            RegisterProviderAsEventProvider(events);
            RegisterProviderAsInstanceProvider();

            RegisterAssemblyAsInstrumented();

            Directory.CreateDirectory(DataDirectory);

            using (StreamWriter log = new StreamWriter(CodePath, false, Encoding.ASCII))
            {
                log.WriteLine(helper.Code);
            }

            // Always generate the MOF in unicode
            using (StreamWriter log = new StreamWriter(MofPath, false, Encoding.Unicode))
            {
                log.WriteLine(GenerateMof(mofs));
            }
            WMICapabilities.AddAutorecoverMof(MofPath);
        }
Пример #4
0
        private static bool MultiIndicatePossible()
        {
            OperatingSystem oSVersion = Environment.OSVersion;

            if (oSVersion.Platform != PlatformID.Win32NT || !(oSVersion.Version >= new Version(5, 1)))
            {
                string          str         = Path.Combine(Environment.SystemDirectory, "wbem\\fastprox.dll");
                FileVersionInfo versionInfo = FileVersionInfo.GetVersionInfo(str);
                if (!WMICapabilities.IsNovaFile(versionInfo) || versionInfo.FilePrivatePart < 56)
                {
                    return(false);
                }
                else
                {
                    return(true);
                }
            }
            else
            {
                return(true);
            }
        }
Пример #5
0
        private static void Initialize(Assembly assembly)
        {
            lock (instrumentedAssemblies)
            {
                if (instrumentedAssemblies.ContainsKey(assembly))
                {
                    return;
                }

                SchemaNaming naming = SchemaNaming.GetSchemaNaming(assembly);
                if (naming == null)
                {
                    return;
                }

                if (false == naming.IsAssemblyRegistered())
                {
                    // If we are not an administrator, don't try to JIT install the schema
                    if (!WMICapabilities.IsUserAdmin())
                    {
                        throw new Exception(RC.GetString("ASSEMBLY_NOT_REGISTERED"));
                    }

                    //
                    // We always use the full version number for Whidbey.
                    //
                    naming.DecoupledProviderInstanceName = AssemblyNameUtility.UniqueToAssemblyFullVersion(assembly);

                    naming.RegisterNonAssemblySpecificSchema(null);
                    naming.RegisterAssemblySpecificSchema();
                }

                InstrumentedAssembly instrumentedAssembly = new InstrumentedAssembly(assembly, naming);
                instrumentedAssemblies.Add(assembly, instrumentedAssembly);
            }
        }