Skip to content

Commit 27a9591

Browse files
authored
Merge pull request #7 from jesterret/master
Added a null check for a case where all processes got filtered out of…
2 parents d09d208 + fcf2305 commit 27a9591

File tree

4 files changed

+42
-24
lines changed

4 files changed

+42
-24
lines changed

Forms/MainForm.cs

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -159,16 +159,19 @@ private void attachToProcessToolStripMenuItem_Click(object sender, EventArgs e)
159159
{
160160
if (pb.ShowDialog() == DialogResult.OK)
161161
{
162-
DetachFromCurrentProcess();
163-
164-
remoteProcess.Process = pb.SelectedProcess;
165-
remoteProcess.UpdateProcessInformations();
166-
if (pb.LoadSymbols)
162+
if (pb.SelectedProcess != null)
167163
{
168-
LoadAllSymbolsForCurrentProcess();
169-
}
164+
DetachFromCurrentProcess();
170165

171-
Program.Settings.LastProcess = remoteProcess.Process.Name;
166+
remoteProcess.Process = pb.SelectedProcess;
167+
remoteProcess.UpdateProcessInformations();
168+
if (pb.LoadSymbols)
169+
{
170+
LoadAllSymbolsForCurrentProcess();
171+
}
172+
173+
Program.Settings.LastProcess = remoteProcess.Process.Name;
174+
}
172175
}
173176
}
174177
}
@@ -180,7 +183,8 @@ private void detachToolStripMenuItem_Click(object sender, EventArgs e)
180183

181184
private void newClassToolStripButton_Click(object sender, EventArgs e)
182185
{
183-
var node = ClassNode.Create();
186+
var address = remoteProcess.GetModuleByName(remoteProcess.Process?.Name)?.Start ?? IntPtr.Zero;
187+
var node = ClassNode.Create(address);
184188
node.AddBytes(64);
185189

186190
classesView.SelectedClass = node;

NativeHelper/NativeHelper.vcxproj

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -72,25 +72,25 @@
7272
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
7373
<LinkIncremental>true</LinkIncremental>
7474
<TargetName>$(ProjectName)</TargetName>
75-
<OutDir>$(SolutionDir)bin\$(Configuration)\</OutDir>
75+
<OutDir>$(SolutionDir)bin\$(PlatformTarget)\$(Configuration)\</OutDir>
7676
<IncludePath>.\beaengine\include;$(IncludePath)</IncludePath>
7777
</PropertyGroup>
7878
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
7979
<LinkIncremental>true</LinkIncremental>
8080
<TargetName>$(ProjectName)</TargetName>
81-
<OutDir>$(SolutionDir)\bin\$(Configuration)\x64\</OutDir>
81+
<OutDir>$(SolutionDir)bin\$(PlatformTarget)\$(Configuration)\</OutDir>
8282
<IncludePath>.\beaengine\include;$(IncludePath)</IncludePath>
8383
</PropertyGroup>
8484
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
8585
<LinkIncremental>false</LinkIncremental>
8686
<TargetName>$(ProjectName)</TargetName>
87-
<OutDir>$(SolutionDir)bin\$(Configuration)\</OutDir>
87+
<OutDir>$(SolutionDir)bin\$(PlatformTarget)\$(Configuration)\</OutDir>
8888
<IncludePath>.\beaengine\include;$(IncludePath)</IncludePath>
8989
</PropertyGroup>
9090
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
9191
<LinkIncremental>false</LinkIncremental>
9292
<TargetName>$(ProjectName)</TargetName>
93-
<OutDir>$(SolutionDir)bin\$(Configuration)\x64\</OutDir>
93+
<OutDir>$(SolutionDir)bin\$(PlatformTarget)\$(Configuration)\</OutDir>
9494
<IncludePath>.\beaengine\include;$(IncludePath)</IncludePath>
9595
</PropertyGroup>
9696
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">

Nodes/ClassNode.cs

Lines changed: 21 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -44,30 +44,44 @@ public IntPtr Address
4444
public string AddressFormula { get; set; }
4545

4646
public event NodeEventHandler NodesChanged;
47-
48-
internal ClassNode(bool notifyClassCreated)
47+
48+
internal ClassNode(bool notifyClassCreated, IntPtr address)
4949
{
5050
Contract.Ensures(AddressFormula != null);
5151

5252
Uuid = new NodeUuid(true);
5353

54+
if (address == IntPtr.Zero)
55+
{
5456
#if WIN64
55-
Address = (IntPtr)0x140000000;
57+
Address = (IntPtr)0x140000000;
5658
#else
57-
Address = (IntPtr)0x400000;
59+
Address = (IntPtr)0x400000;
5860
#endif
59-
61+
}
62+
else
63+
Address = address;
6064
if (notifyClassCreated)
6165
{
6266
ClassCreated?.Invoke(this);
6367
}
6468
}
6569

66-
public static ClassNode Create()
70+
internal ClassNode(bool notifyClassCreated) : this(notifyClassCreated, IntPtr.Zero)
71+
{
72+
73+
}
74+
75+
public static ClassNode Create(IntPtr address)
6776
{
6877
Contract.Ensures(Contract.Result<ClassNode>() != null);
6978

70-
return new ClassNode(true);
79+
return new ClassNode(true, address);
80+
}
81+
82+
public static ClassNode Create()
83+
{
84+
return Create(IntPtr.Zero);
7185
}
7286

7387
public override void Intialize()

ReClass.NET.csproj

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
<DebugSymbols>true</DebugSymbols>
2222
<DebugType>full</DebugType>
2323
<Optimize>false</Optimize>
24-
<OutputPath>bin\Debug\</OutputPath>
24+
<OutputPath>bin\x86\Debug\</OutputPath>
2525
<DefineConstants>TRACE;DEBUG;WIN32</DefineConstants>
2626
<ErrorReport>prompt</ErrorReport>
2727
<WarningLevel>4</WarningLevel>
@@ -74,7 +74,7 @@
7474
<PlatformTarget>x86</PlatformTarget>
7575
<DebugType>pdbonly</DebugType>
7676
<Optimize>true</Optimize>
77-
<OutputPath>bin\Release\</OutputPath>
77+
<OutputPath>bin\x86\Release\</OutputPath>
7878
<DefineConstants>TRACE;WIN32;RELEASE</DefineConstants>
7979
<ErrorReport>prompt</ErrorReport>
8080
<WarningLevel>4</WarningLevel>
@@ -84,7 +84,7 @@
8484
<DebugSymbols>true</DebugSymbols>
8585
<DebugType>full</DebugType>
8686
<Optimize>false</Optimize>
87-
<OutputPath>bin\Debug\x64\</OutputPath>
87+
<OutputPath>bin\x64\Debug\</OutputPath>
8888
<DefineConstants>TRACE;DEBUG;WIN64</DefineConstants>
8989
<ErrorReport>prompt</ErrorReport>
9090
<WarningLevel>4</WarningLevel>
@@ -94,7 +94,7 @@
9494
<PlatformTarget>x64</PlatformTarget>
9595
<DebugType>pdbonly</DebugType>
9696
<Optimize>true</Optimize>
97-
<OutputPath>bin\Release\x64\</OutputPath>
97+
<OutputPath>bin\x64\Release\</OutputPath>
9898
<DefineConstants>TRACE;WIN64;RELEASE</DefineConstants>
9999
<ErrorReport>prompt</ErrorReport>
100100
<WarningLevel>4</WarningLevel>

0 commit comments

Comments
 (0)