diff --git a/trunk/ProcessHacker/Forms/HackerWindow.cs b/trunk/ProcessHacker/Forms/HackerWindow.cs
index 49a65c16e..3be9f9db3 100644
--- a/trunk/ProcessHacker/Forms/HackerWindow.cs
+++ b/trunk/ProcessHacker/Forms/HackerWindow.cs
@@ -1357,6 +1357,20 @@ namespace ProcessHacker
startedSMenuItem.Click += new EventHandler(CheckedMenuItem_Click);
stoppedSMenuItem.Click += new EventHandler(CheckedMenuItem_Click);
DSMenuItem.Click += new EventHandler(CheckedMenuItem_Click);
+
+ try
+ {
+ if (System.IO.File.Exists(Application.StartupPath + "\\structs.txt"))
+ {
+ Structs.StructParser parser = new ProcessHacker.Structs.StructParser(Program.Structs);
+
+ parser.Parse(System.IO.File.ReadAllText(Application.StartupPath + "\\structs.txt"));
+ }
+ }
+ catch (Exception ex)
+ {
+ QueueMessage("Error loading structure definitions: " + ex.Message);
+ }
}
private void CheckedMenuItem_Click(object sender, EventArgs e)
diff --git a/trunk/ProcessHacker/ProcessHacker.csproj b/trunk/ProcessHacker/ProcessHacker.csproj
index 4d3498245..50cd66709 100644
--- a/trunk/ProcessHacker/ProcessHacker.csproj
+++ b/trunk/ProcessHacker/ProcessHacker.csproj
@@ -593,6 +593,9 @@
+
+ Always
+
diff --git a/trunk/ProcessHacker/Program.cs b/trunk/ProcessHacker/Program.cs
index 96bd69ec8..e099978e9 100644
--- a/trunk/ProcessHacker/Program.cs
+++ b/trunk/ProcessHacker/Program.cs
@@ -45,6 +45,8 @@ namespace ProcessHacker
///
public static IdGenerator ResultsIds = new IdGenerator();
+ public static Dictionary Structs = new Dictionary();
+
public static Dictionary MemoryEditors = new Dictionary();
public static Dictionary MemoryEditorsThreads = new Dictionary();
diff --git a/trunk/ProcessHacker/Structs/FieldType.cs b/trunk/ProcessHacker/Structs/FieldType.cs
index 007459512..5fd0323ae 100644
--- a/trunk/ProcessHacker/Structs/FieldType.cs
+++ b/trunk/ProcessHacker/Structs/FieldType.cs
@@ -23,7 +23,6 @@ using System.Text;
namespace ProcessHacker.Structs
{
- [Flags]
public enum FieldType : uint
{
Bool8 = 0x1,
diff --git a/trunk/ProcessHacker/Structs/StructParser.cs b/trunk/ProcessHacker/Structs/StructParser.cs
index 8786e1b6d..d5fdf9d7f 100644
--- a/trunk/ProcessHacker/Structs/StructParser.cs
+++ b/trunk/ProcessHacker/Structs/StructParser.cs
@@ -296,23 +296,27 @@ namespace ProcessHacker.Structs
if (inComment && text[i] == '*')
{
prePostComment = true;
+ i++;
continue;
}
else if (prePostComment && text[i] == '/')
{
prePostComment = false;
inComment = false;
+ i++;
continue;
}
else if (!inComment && text[i] == '/')
{
preComment = true;
+ i++;
continue;
}
else if (preComment && text[i] == '*')
{
preComment = false;
inComment = true;
+ i++;
continue;
}
else
@@ -324,7 +328,7 @@ namespace ProcessHacker.Structs
if (text[i] == '\n')
_lineNumber++;
- if (!Char.IsWhiteSpace(text[i]) && !inComment)
+ if (!(text[i] == '\r' || text[i] == '\n' || text[i] == ' ' || text[i] == '\t') && !inComment)
{
ranOut = false;
break;
@@ -345,12 +349,12 @@ namespace ProcessHacker.Structs
// identifiers can't start with a number-
if (sb.Length == 0)
{
- if (!char.IsLetter(text[i]))
+ if (!(char.IsLetter(text[i]) || text[i] == '_'))
break;
}
else
{
- if (!char.IsLetterOrDigit(text[i]))
+ if (!(char.IsLetterOrDigit(text[i]) || text[i] == '_'))
break;
}
@@ -390,9 +394,9 @@ namespace ProcessHacker.Structs
{
StringBuilder sb = new StringBuilder();
- while (i < text.Length)
+ while (i < text.Length && sb.Length < 1) // we need a proper parser to solve this
{
- if (!char.IsSymbol(text[i]))
+ if (!char.IsPunctuation(text[i]) && !char.IsSymbol(text[i]))
break;
sb.Append(text[i]);
diff --git a/trunk/structs.txt b/trunk/ProcessHacker/structs.txt
similarity index 86%
rename from trunk/structs.txt
rename to trunk/ProcessHacker/structs.txt
index f433d7671..cc0cc811f 100644
--- a/trunk/structs.txt
+++ b/trunk/ProcessHacker/structs.txt
@@ -1,7 +1,15 @@
+/*
+ * Process Hacker's Structs file - contains
+ * common structures used in Windows
+ *
+ * wj32.
+ */
+
typedef int handle;
typedef int pvoid;
typedef pvoid ppvoid;
+/* A counted UTF-16 string. Same as LSA_UNICODE_STRING. */
UNICODE_STRING
{
ushort Length;
@@ -17,6 +25,7 @@ RTL_DRIVE_LETTER_CURDIR
UNICODE_STRING DosPath;
}
+/* Lots of useful stuff like current directory and command line */
RTL_USER_PROCESS_PARAMETERS
{
ulong MaximumLength;
@@ -50,11 +59,13 @@ RTL_USER_PROCESS_PARAMETERS
RTL_DRIVE_LETTER_CURDIR DLCurrentDirectory[0x20];
}
+/* Contains the address of a fast-locking routine for the PEB */
PEBLOCKROUTINE
{
pvoid PebLock;
}
+/* Process Environment Block */
PEB
{
boolean InheritedAddressSpace;
@@ -111,4 +122,4 @@ PEB
ulong TlsExpansionBitmap;
byte TlsExpansionBitmapBits[0x80];
ulong SessionId;
-}
\ No newline at end of file
+}