mirror of
https://github.com/mirror/processhacker
synced 2026-06-08 16:03:24 +00:00
fixed parser bugs
git-svn-id: svn://svn.code.sf.net/p/processhacker/code@418 21ef857c-d57f-4fe0-8362-d861dc6d29cd
This commit is contained in:
@@ -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)
|
||||
|
||||
@@ -593,6 +593,9 @@
|
||||
<None Include="Icons\Process_small.ico" />
|
||||
<None Include="Icons\Process.ico" />
|
||||
<Content Include="ProcessHacker.ico" />
|
||||
<Content Include="structs.txt">
|
||||
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
|
||||
</Content>
|
||||
<None Include="Resources\cog_edit.png" />
|
||||
<None Include="Resources\folder_go.png" />
|
||||
<None Include="Resources\report_user.png" />
|
||||
|
||||
@@ -45,6 +45,8 @@ namespace ProcessHacker
|
||||
/// </summary>
|
||||
public static IdGenerator ResultsIds = new IdGenerator();
|
||||
|
||||
public static Dictionary<string, Structs.StructDef> Structs = new Dictionary<string, ProcessHacker.Structs.StructDef>();
|
||||
|
||||
public static Dictionary<string, MemoryEditor> MemoryEditors = new Dictionary<string, MemoryEditor>();
|
||||
public static Dictionary<string, Thread> MemoryEditorsThreads = new Dictionary<string, Thread>();
|
||||
|
||||
|
||||
@@ -23,7 +23,6 @@ using System.Text;
|
||||
|
||||
namespace ProcessHacker.Structs
|
||||
{
|
||||
[Flags]
|
||||
public enum FieldType : uint
|
||||
{
|
||||
Bool8 = 0x1,
|
||||
|
||||
@@ -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]);
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user