Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
################################################################################
# This .gitignore file was automatically created by Microsoft(R) Visual Studio.
################################################################################

/source/bin
/source/obj
/source/.vs/wmi-parser/v16/Server/sqlite3
/source/wmi-parser.csproj.user
/source/.vs/wmi-parser/v16/.suo
40 changes: 33 additions & 7 deletions source/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ static void Main(string[] args)

foreach (var b in bindings)
{
Regex regexEventConsumer = new Regex(@"\x00CommandLineEventConsumer\x00\x00(.*?)\x00.*?" + b.Name + "\x00\x00?([^\x00]*)?", RegexOptions.Multiline);
Regex regexEventConsumer = new Regex(@"\x00CommandLineEventConsumer\x00\x00([^\x00]*).*?" + b.Name + @"\x00", RegexOptions.Multiline | RegexOptions.Compiled);

var matches = regexEventConsumer.Matches(data);
foreach (Match m in matches)
Expand All @@ -64,15 +64,35 @@ static void Main(string[] args)
b.Arguments = m.Groups[1].Value;
}

regexEventConsumer = new Regex(@"(\w*EventConsumer)(.*?)(" + b.Name + @")(\x00\x00)([^\x00]*)(\x00\x00)([^\x00]*)", RegexOptions.Multiline);
regexEventConsumer = new Regex(@"(\w*EventConsumer)(.*?)(" + b.Name + @")(\x00\x00)([^\x00]*)(\x00\x00)([^\x00]*)", RegexOptions.Multiline | RegexOptions.Compiled);
matches = regexEventConsumer.Matches(data);
foreach (Match m in matches)
{
b.Other = string.Format("{0} ~ {1} ~ {2} ~ {3}", m.Groups[1], m.Groups[3], m.Groups[5], m.Groups[7]);
if (m.Groups[1].Value == "ActiveScriptEventConsumer")
{
b.Type = "ActiveScriptEventConsumer";
b.Name = m.Groups[3].Value;
if ((m.Groups[5].Value.ToLower() == "jscript") || (m.Groups[5].Value.ToLower() == "vbscript"))
{
b.Arguments = string.Format("ScriptLanguage= {0}" + Environment.NewLine + " Script= {1}", m.Groups[5], m.Groups[7]);
}
else b.Arguments = string.Format("ScriptLanguage= {0}" + Environment.NewLine + " ScriptFile= {1}", m.Groups[7], m.Groups[5]);
}
else
{
b.Other = string.Format("{0} ~ {1} ~ {2} ~ {3}", m.Groups[1], m.Groups[3], m.Groups[5], m.Groups[7]);
}
}

regexEventConsumer = new Regex(@"(" + b.Filter + ")(\x00\x00)([^\x00]*)(\x00\x00)", RegexOptions.Multiline);
matches = regexEventConsumer.Matches(data);
//regexEventConsumer = new Regex(@"(\w*EventConsumer)(.*?)(" + b.Name + @")(\x00\x00)([^\x00]*)(\x00\x00)([^\x00]*)", RegexOptions.Multiline | RegexOptions.Compiled);
//matches = regexEventConsumer.Matches(data);
//foreach (Match m in matches)
//{
// b.Other = string.Format("{0} ~ {1} ~ {2} ~ {3}", m.Groups[1], m.Groups[3], m.Groups[5], m.Groups[7]);
//}

Regex regexEventFilter = new Regex(@"(" + b.Filter + ")(\x00\x00)([^{\x00}2]*)(\x00\x00)", RegexOptions.Multiline | RegexOptions.Compiled);
matches = regexEventFilter.Matches(data);
foreach (Match m in matches)
{
b.Query = m.Groups[3].Value;
Expand Down Expand Up @@ -197,6 +217,12 @@ private static void OutputToConsole(List<Binding> bindings)
Console.WriteLine(" Type: {0}", "CommandLineEventConsumer");
Console.WriteLine(" Arguments: {0}", b.Arguments);
}
else if (b.Type == "ActiveScriptEventConsumer")
{
Console.WriteLine(" Name: {0}", b.Name);
Console.WriteLine(" Type: {0}", "ActiveScriptEventConsumer");
Console.WriteLine(" Script data: {0}", b.Arguments);
}
else
{
Console.WriteLine(" Consumer: {0}", b.Other);
Expand Down Expand Up @@ -232,9 +258,9 @@ private static void OutputToFile(List<Binding> bindings)
{
cw.WriteField(b.Name);
cw.WriteField(b.Type);
cw.WriteField(b.Arguments);
cw.WriteField(String.IsNullOrEmpty(b.Arguments)? b.Arguments : Regex.Replace(b.Arguments, @"\p{C}+", "."));
cw.WriteField(b.Filter);
cw.WriteField(b.Query);
cw.WriteField(String.IsNullOrEmpty(b.Query)? b.Query : Regex.Replace(b.Query, @"\p{C}+", "."));
cw.NextRecord(); ;
}
}
Expand Down