public void RegisterNonAssemblySpecificSchema(InstallContext installContext) { SecurityHelper.UnmanagedCode.Demand(); WmiNetUtilsHelper.VerifyClientKey_f(); InstallLogWrapper context = new InstallLogWrapper(installContext); EnsureNamespace(context, this.GlobalRegistrationNamespace); EnsureClassExists(context, this.GlobalInstrumentationClassPath, new ClassMaker(this.MakeGlobalInstrumentationClass)); EnsureClassExists(context, this.GlobalRegistrationClassPath, new ClassMaker(this.MakeNamespaceRegistrationClass)); EnsureClassExists(context, this.GlobalNamingClassPath, new ClassMaker(this.MakeNamingClass)); EnsureNamespace(context, this.NamespaceName); EnsureClassExists(context, this.InstrumentationClassPath, new ClassMaker(this.MakeInstrumentationClass)); EnsureClassExists(context, this.RegistrationClassPath, new ClassMaker(this.MakeRegistrationClass)); try { ManagementClass class2 = new ManagementClass(this.DecoupledProviderClassPath); if (class2["HostingModel"].ToString() != "Decoupled:Com") { class2.Delete(); } } catch (ManagementException exception) { if (exception.ErrorCode != ManagementStatus.NotFound) { throw exception; } } EnsureClassExists(context, this.DecoupledProviderClassPath, new ClassMaker(this.MakeDecoupledProviderClass)); EnsureClassExists(context, this.ProviderClassPath, new ClassMaker(this.MakeProviderClass)); if (!DoesInstanceExist(this.GlobalRegistrationPath)) { this.RegisterNamespaceAsInstrumented(); } }
public void RegisterNonAssemblySpecificSchema(InstallContext installContext) { SecurityHelper.UnmanagedCode.Demand(); // Bug#112640 - Close off any potential use from anything but fully trusted code // Make sure the 'Client' key has the correct permissions WmiNetUtilsHelper.VerifyClientKey_f(); InstallLogWrapper context = new InstallLogWrapper(installContext); EnsureNamespace(context, GlobalRegistrationNamespace); EnsureClassExists(context, GlobalInstrumentationClassPath, new ClassMaker(MakeGlobalInstrumentationClass)); EnsureClassExists(context, GlobalRegistrationClassPath, new ClassMaker(MakeNamespaceRegistrationClass)); EnsureClassExists(context, GlobalNamingClassPath, new ClassMaker(MakeNamingClass)); EnsureNamespace(context, NamespaceName); EnsureClassExists(context, InstrumentationClassPath, new ClassMaker(MakeInstrumentationClass)); EnsureClassExists(context, RegistrationClassPath, new ClassMaker(MakeRegistrationClass)); // Make sure Hosting model is set correctly by default. If not, we blow away the class definition try { ManagementClass cls = new ManagementClass(DecoupledProviderClassPath); if (cls["HostingModel"].ToString() != "Decoupled:Com") { cls.Delete(); } } catch (ManagementException e) { if (e.ErrorCode != ManagementStatus.NotFound) { throw e; } } EnsureClassExists(context, DecoupledProviderClassPath, new ClassMaker(MakeDecoupledProviderClass)); EnsureClassExists(context, ProviderClassPath, new ClassMaker(MakeProviderClass)); if (!DoesInstanceExist(GlobalRegistrationPath)) { RegisterNamespaceAsInstrumented(); } }
static void EnsureNamespace(InstallLogWrapper context, string namespaceName) { context.LogMessage(RC.GetString("NAMESPACE_ENSURE") + " " + namespaceName); string fullNamespace = null; foreach (string name in namespaceName.Split(new char[] { '\\' })) { if (fullNamespace == null) { fullNamespace = name; continue; } EnsureNamespace(fullNamespace, name); fullNamespace += "\\" + name; } }
private static void EnsureClassExists(InstallLogWrapper context, string classPath, ClassMaker classMakerFunction) { try { context.LogMessage(RC.GetString("CLASS_ENSURE") + " " + classPath); new ManagementClass(classPath).Get(); } catch (ManagementException exception) { if (exception.ErrorCode != ManagementStatus.NotFound) { throw exception; } context.LogMessage(RC.GetString("CLASS_ENSURECREATE") + " " + classPath); classMakerFunction().Put(); } }
private static void EnsureNamespace(InstallLogWrapper context, string namespaceName) { context.LogMessage(RC.GetString("NAMESPACE_ENSURE") + " " + namespaceName); string baseNamespace = null; foreach (string str2 in namespaceName.Split(new char[] { '\\' })) { if (baseNamespace == null) { baseNamespace = str2; } else { EnsureNamespace(baseNamespace, str2); baseNamespace = baseNamespace + @"\" + str2; } } }
static void EnsureClassExists(InstallLogWrapper context, string classPath, ClassMaker classMakerFunction) { try { context.LogMessage(RC.GetString("CLASS_ENSURE") + " " + classPath); ManagementClass theClass = new ManagementClass(classPath); theClass.Get(); } catch (ManagementException e) { if (e.ErrorCode == ManagementStatus.NotFound) { // The class does not exist. Create it. context.LogMessage(RC.GetString("CLASS_ENSURECREATE") + " " + classPath); ManagementClass theClass = classMakerFunction(); theClass.Put(); } else { throw e; } } }
static void EnsureClassExists(InstallLogWrapper context, string classPath, ClassMaker classMakerFunction) { try { context.LogMessage(RC.GetString("CLASS_ENSURE") + " " +classPath); ManagementClass theClass = new ManagementClass(classPath); theClass.Get(); } catch(ManagementException e) { if(e.ErrorCode == ManagementStatus.NotFound) { // The class does not exist. Create it. context.LogMessage(RC.GetString("CLASS_ENSURECREATE")+ " " +classPath); ManagementClass theClass = classMakerFunction(); theClass.Put(); } else throw e; } }
static void EnsureNamespace(InstallLogWrapper context, string namespaceName) { context.LogMessage(RC.GetString("NAMESPACE_ENSURE")+ " " +namespaceName); string fullNamespace = null; foreach(string name in namespaceName.Split(new char[] {'\\'})) { if(fullNamespace == null) { fullNamespace = name; continue; } EnsureNamespace(fullNamespace, name); fullNamespace += "\\" + name; } }
public void RegisterNonAssemblySpecificSchema(InstallContext installContext) { SecurityHelper.UnmanagedCode.Demand(); // Bug#112640 - Close off any potential use from anything but fully trusted code // Make sure the 'Client' key has the correct permissions WmiNetUtilsHelper.VerifyClientKey_f(); InstallLogWrapper context = new InstallLogWrapper(installContext); EnsureNamespace(context, GlobalRegistrationNamespace); EnsureClassExists(context, GlobalInstrumentationClassPath, new ClassMaker(MakeGlobalInstrumentationClass)); EnsureClassExists(context, GlobalRegistrationClassPath, new ClassMaker(MakeNamespaceRegistrationClass)); EnsureClassExists(context, GlobalNamingClassPath, new ClassMaker(MakeNamingClass)); EnsureNamespace(context, NamespaceName); EnsureClassExists(context, InstrumentationClassPath, new ClassMaker(MakeInstrumentationClass)); EnsureClassExists(context, RegistrationClassPath, new ClassMaker(MakeRegistrationClass)); // Make sure Hosting model is set correctly by default. If not, we blow away the class definition try { ManagementClass cls = new ManagementClass(DecoupledProviderClassPath); if(cls["HostingModel"].ToString() != "Decoupled:Com") { cls.Delete(); } } catch(ManagementException e) { if(e.ErrorCode != ManagementStatus.NotFound) throw e; } EnsureClassExists(context, DecoupledProviderClassPath, new ClassMaker(MakeDecoupledProviderClass)); EnsureClassExists(context, ProviderClassPath, new ClassMaker(MakeProviderClass)); if(!DoesInstanceExist(GlobalRegistrationPath)) RegisterNamespaceAsInstrumented(); }