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:
wj32
2008-12-25 06:12:43 +00:00
parent f8bd67e5a7
commit 56dd7ed3f3
6 changed files with 40 additions and 7 deletions
+14
View File
@@ -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)
+3
View File
@@ -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" />
+2
View File
@@ -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>();
-1
View File
@@ -23,7 +23,6 @@ using System.Text;
namespace ProcessHacker.Structs
{
[Flags]
public enum FieldType : uint
{
Bool8 = 0x1,
+9 -5
View File
@@ -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]);
+125
View File
@@ -0,0 +1,125 @@
/*
* 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;
ushort MaximumLength;
wstr* Buffer[Length];
}
RTL_DRIVE_LETTER_CURDIR
{
ushort Flags;
ushort Length;
ulong TimeStamp;
UNICODE_STRING DosPath;
}
/* Lots of useful stuff like current directory and command line */
RTL_USER_PROCESS_PARAMETERS
{
ulong MaximumLength;
ulong Length;
ulong Flags;
ulong DebugFlags;
pvoid ConsoleHandle;
ulong ConsoleFlags;
handle StdInputHandle;
handle StdOutputHandle;
handle StdErrorHandle;
UNICODE_STRING CurrentDirectoryPath;
handle CurrentDirectoryHandle;
UNICODE_STRING DllPath;
UNICODE_STRING ImagePathName;
UNICODE_STRING CommandLine;
pvoid Environment;
ulong StartingPositionLeft;
ulong StartingPositionTop;
ulong Width;
ulong Height;
ulong CharWidth;
ulong CharHeight;
ulong ConsoleTextAttributes;
ulong WindowFlags;
ulong ShowWindowFlags;
UNICODE_STRING WindowTitle;
UNICODE_STRING DesktopName;
UNICODE_STRING ShellInfo;
UNICODE_STRING RuntimeData;
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;
boolean ReadImageFileExecOptions;
boolean BeingDebugged;
boolean Spare;
handle Mutant;
pvoid ImageBaseAddress;
pvoid LoaderData; /* should be PEB_LDR_DATA* */
RTL_USER_PROCESS_PARAMETERS* ProcessParameters;
pvoid SubSystemData;
pvoid ProcessHeap;
pvoid FastPebLock;
PEBLOCKROUTINE* FastPebLockRoutine;
PEBLOCKROUTINE* FastPebUnlockRoutine;
ulong EnvironmentUpdateCount;
ppvoid KernelCallbackTable;
pvoid EventLogSection;
pvoid EventLog;
pvoid FreeList; /* should be PEB_FREE_BLOCK* */
ulong TlsExpansionCounter;
pvoid TlsBitmap;
ulong TlsBitmapBits[0x2];
pvoid ReadOnlySharedMemoryBase;
pvoid ReadOnlySharedMemoryHeap;
ppvoid ReadOnlyStaticServerData;
pvoid AnsiCodePageData;
pvoid OemCodePageData;
pvoid UnicodeCaseTableData;
ulong NumberOfProcessors;
ulong NtGlobalFlag;
byte Spare2[0x4];
large_integer CriticalSectionTimeout;
ulong HeapSegmentReserve;
ulong HeapSegmentCommit;
ulong HeapDeCommitTotalFreeThreshold;
ulong HeapDeCommitFreeBlockThreshold;
ulong NumberOfHeaps;
ulong MaximumNumberOfHeaps;
ppvoid ProcessHeaps;
pvoid GdiSharedHandleTable;
pvoid ProcessStarterHelper;
pvoid GdiDCAttributeList;
pvoid LoaderLock;
ulong OSMajorVersion;
ulong OSMinorVersion;
ulong OSBuildNumber;
ulong OSPlatformId;
ulong ImageSubSystem;
ulong ImageSubSystemMajorVersion;
ulong ImageSubSystemMinorVersion;
ulong GdiHandleBuffer[0x22];
ulong PostProcessInitRoutine;
ulong TlsExpansionBitmap;
byte TlsExpansionBitmapBits[0x80];
ulong SessionId;
}