public bool Run() { string manifestFile = opts.OutputManifest; var metadata = EventManifestParser.LoadWinmeta(diags); var reader = new EventTemplateReader(diags, metadata); EventManifest manifest; IEnumerable <Message> messages; if (opts.InputModule != null) { string providerBinary = Path.GetFullPath(opts.InputModule); using var module = SafeModuleHandle.LoadImageResource(providerBinary); if (module.IsInvalid) { throw new Win32Exception(); } using (var stream = module.OpenResource(UnsafeNativeMethods.RT_MESSAGETABLE, 1)) messages = reader.ReadMessageTable(stream); using (var stream = module.OpenResource("WEVT_TEMPLATE", 1)) manifest = reader.ReadWevtTemplate(stream, messages); foreach (var provider in manifest.Providers) { provider.ResourceFileName = providerBinary; provider.MessageFileName = providerBinary; } } else { using (var stream = File.OpenRead(opts.InputMessageTable)) messages = reader.ReadMessageTable(stream); using (var stream = File.OpenRead(opts.InputEventTemplate)) manifest = reader.ReadWevtTemplate(stream, messages); } StripReservedMetadata(manifest, metadata); InferSymbols(manifest); StripDefaultMessageIds(manifest); XDocument doc = manifest.ToXml(); var settings = new XmlWriterSettings { Indent = true, IndentChars = " " }; using var output = File.Create(manifestFile); using var writer = XmlWriter.Create(output, settings); doc.WriteTo(writer); return(true); }
public static ThemeFile LoadTheme(string styleFilePath, bool isHighContrast, string muiFilePath) { SafeModuleHandle muiHandle = SafeModuleHandle.Zero; if (File.Exists(muiFilePath)) { muiHandle = SafeModuleHandle.LoadImageResource(muiFilePath); } var styleHandle = SafeModuleHandle.LoadImageResource(styleFilePath); return(new ThemeFileLoader(styleFilePath, styleHandle, muiHandle, isHighContrast).LoadTheme()); }
public void DumpWevtTemplateResource(string moduleFile) { var module = SafeModuleHandle.LoadImageResource(moduleFile); if (module.IsInvalid) { throw new Win32Exception(); } using (module) using (var stream = module.OpenResource("WEVT_TEMPLATE", 1)) DumpWevtTemplate(stream); }
public void DumpMessageTableResource(string moduleFile) { var module = SafeModuleHandle.LoadImageResource(moduleFile); if (module.IsInvalid) { throw new Win32Exception(); } using (module) using (var stream = module.OpenResource(UnsafeNativeMethods.RT_MESSAGETABLE, 1)) DumpMessageTable(stream); }