Skip to content

Commit

Permalink
Updated PR15 changes for support for #14
Browse files Browse the repository at this point in the history
Moved a bunch of blocking operations off the GUI thread
Revamped logging, will probably switch to a more lightweight logging
library later
Added -console command line argument to show output console
Switched to .net 4.0 as required version
  • Loading branch information
valarnin committed May 1, 2016
1 parent 051b23b commit 28ec51d
Show file tree
Hide file tree
Showing 20 changed files with 436 additions and 299 deletions.
7 changes: 4 additions & 3 deletions NTRDebuggerTool.sln
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio 14
VisualStudioVersion = 14.0.23107.0
MinimumVisualStudioVersion = 10.0.40219.1
# Visual Studio 2012
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "NTRDebuggerTool", "NTRDebuggerTool\NTRDebuggerTool.csproj", "{86AF1318-9584-4CDE-93BC-C2F0DCF958C5}"
EndProject
Global
Expand All @@ -19,4 +17,7 @@ Global
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(Performance) = preSolution
HasPerformanceSessions = true
EndGlobalSection
EndGlobal
30 changes: 25 additions & 5 deletions NTRDebuggerTool/App.config
Original file line number Diff line number Diff line change
@@ -1,6 +1,26 @@
<?xml version="1.0" encoding="utf-8" ?>
<?xml version="1.0"?>
<configuration>
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5" />
</startup>
</configuration>
<configSections>
<section name="log4net" type="System.Configuration.IgnoreSectionHandler"/>
</configSections>
<log4net>
<appender name="LogFileAppender" type="log4net.Appender.FileAppender">
<file value="${TMP}\NTRDebuggerTool-Log.txt"/>
<appendToFile value="true"/>
<layout type="log4net.Layout.XMLLayout"/>
</appender>
<appender name="ConsoleAppender" type="log4net.Appender.ConsoleAppender">
<layout type="log4net.Layout.PatternLayout">
<conversionPattern value="%date [%thread] %-5level %logger [%ndc] &lt;%property{auth}&gt; - %message%newline"/>
</layout>
</appender>
<root>
<level value="WARN"/>
<appender-ref ref="LogFileAppender"/>
<appender-ref ref="ConsoleAppender"/>
</root>
</log4net>
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.0"/>
</startup>
</configuration>
2 changes: 1 addition & 1 deletion NTRDebuggerTool/Config.cs
Original file line number Diff line number Diff line change
Expand Up @@ -233,7 +233,7 @@ private static void CreateConfigFile()

#region XML Stuff

private static string ConfigFileDirectory = Directory.GetParent(Application.UserAppDataPath).FullName;
public static string ConfigFileDirectory = Directory.GetParent(Application.UserAppDataPath).FullName;
private static string ConfigFilePath = ConfigFileDirectory + Path.DirectorySeparatorChar + "NTRDebuggerTool.config.xml";
private static XmlDocument ConfigFile;

Expand Down
33 changes: 33 additions & 0 deletions NTRDebuggerTool/ConsoleHelper.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
using System;
using System.Runtime.InteropServices;

namespace NTRDebuggerTool
{
class ConsoleHelper
{
[DllImport("kernel32.dll", SetLastError = true)]
static extern bool AllocConsole();

[DllImport("kernel32.dll")]
static extern IntPtr GetConsoleWindow();

[DllImport("user32.dll")]
static extern bool ShowWindow(IntPtr hWnd, int nCmdShow);

const int SW_HIDE = 0;
const int SW_SHOW = 5;

public static void EnableConsole()
{
IntPtr Handle = GetConsoleWindow();
if (Handle == IntPtr.Zero)
{
AllocConsole();
}
else
{
ShowWindow(Handle, SW_SHOW);
}
}
}
}
25 changes: 1 addition & 24 deletions NTRDebuggerTool/Debug.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,38 +3,15 @@
using NTRDebuggerTool.Remote;
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.IO;
using System.Runtime.InteropServices;
using System.Threading;

namespace NTRDebuggerTool
{
class Debug
{
[DllImport("kernel32.dll", SetLastError = true)]
static extern bool AllocConsole();

[DllImport("kernel32.dll")]
static extern IntPtr GetConsoleWindow();

[DllImport("user32.dll")]
static extern bool ShowWindow(IntPtr hWnd, int nCmdShow);

const int SW_HIDE = 0;
const int SW_SHOW = 5;

internal static void Execute()
{
IntPtr Handle = GetConsoleWindow();
if (Handle == IntPtr.Zero)
{
AllocConsole();
}
else
{
ShowWindow(Handle, SW_SHOW);
}
NTRRemoteConnection Conn = new NTRRemoteConnection();
Console.WriteLine("Connecting...");
Conn.IP = "192.168.1.29";
Expand All @@ -57,7 +34,7 @@ internal static void Execute()
{
Thread.Sleep(10);
}
Dictionary<string, ReadOnlyDictionary<uint, uint>> Procs = new Dictionary<string, ReadOnlyDictionary<uint, uint>>();
Dictionary<string, Dictionary<uint, uint>> Procs = new Dictionary<string, Dictionary<uint, uint>>();
foreach (string ProcFull in Conn.Processes)
{
string Proc = ProcFull.Split('|')[0];
Expand Down
12 changes: 12 additions & 0 deletions NTRDebuggerTool/Forms/FormEnums/DataType.cs
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,18 @@ public static DataTypeExact GetValue(string key)
{
return Mapping[key];
}

public static string GetKey(DataTypeExact value)
{
foreach (string key in Mapping.Keys)
{
if (Mapping[key] == value)
{
return key;
}
}
return null;
}
}

public enum DataTypeExact
Expand Down
Loading

0 comments on commit 28ec51d

Please sign in to comment.