Skip to content

Commit b82300c

Browse files
committed
Small changes.
1 parent ac48f42 commit b82300c

File tree

13 files changed

+43
-62
lines changed

13 files changed

+43
-62
lines changed

AddressParser/AstBuilder.cs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -89,12 +89,11 @@ public Operation Build(IEnumerable<Token> tokens)
8989

9090
private void PopOperations(bool untillLeftBracket)
9191
{
92-
Operation lastOperation = null;
9392
while (operatorStack.Count > 0 && operatorStack.Peek().TokenType != TokenType.LeftBracket)
9493
{
9594
var token = operatorStack.Pop();
9695

97-
lastOperation = ConvertOperation(token);
96+
var lastOperation = ConvertOperation(token);
9897

9998
resultStack.Push(lastOperation);
10099
}

CodeGenerator/CppCodeGenerator.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ public string GenerateCode(IEnumerable<ClassNode> classes, ILogger logger)
7676
string.Join(
7777
"\n",
7878
YieldMemberDefinitions(c.Nodes.Skip(skipFirstMember ? 1 : 0).WhereNot(n => n is FunctionNode), logger)
79-
.Select(m => MemberDefinitionToString(m))
79+
.Select(MemberDefinitionToString)
8080
.Select(s => "\t" + s)
8181
)
8282
);

DataExchange/ReClassFile.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -169,7 +169,7 @@ private IEnumerable<BaseNode> ReadNodeElements(IEnumerable<XElement> elements, C
169169

170170
while (size != 0)
171171
{
172-
BaseNode paddingNode = null;
172+
BaseNode paddingNode;
173173
#if WIN64
174174
if (size >= 8)
175175
{
@@ -203,7 +203,7 @@ private IEnumerable<BaseNode> ReadNodeElements(IEnumerable<XElement> elements, C
203203
var referenceNode = node as BaseReferenceNode;
204204
if (referenceNode != null)
205205
{
206-
string reference = null;
206+
string reference;
207207
if (referenceNode is ClassInstanceArrayNode)
208208
{
209209
reference = element.Element("Array")?.Attribute("Name")?.Value;

Forms/LogForm.cs

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -73,10 +73,7 @@ private void showDetailsToolStripMenuItem_Click(object sender, EventArgs e)
7373
private void RefreshDataBinding()
7474
{
7575
var cm = entriesDataGridView.BindingContext[items] as CurrencyManager;
76-
if (cm != null)
77-
{
78-
cm.Refresh();
79-
}
76+
cm?.Refresh();
8077
}
8178

8279
public void Clear()
@@ -115,12 +112,9 @@ public void Add(LogLevel level, string message, Exception ex)
115112
private void ShowDetailsForm()
116113
{
117114
var item = entriesDataGridView.SelectedRows.Cast<DataGridViewRow>().FirstOrDefault()?.DataBoundItem as LogItem;
118-
if (item != null)
115+
if (item?.Exception != null)
119116
{
120-
if (item.Exception != null)
121-
{
122-
Program.ShowException(item.Exception);
123-
}
117+
Program.ShowException(item.Exception);
124118
}
125119
}
126120
}

Forms/ProcessBrowserForm.cs

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -25,15 +25,9 @@ public partial class ProcessBrowserForm : IconForm
2525
private readonly CoreFunctionsManager coreFunctions;
2626

2727
/// <summary>Gets the selected process.</summary>
28-
public ProcessInfo SelectedProcess
29-
{
30-
get
31-
{
32-
return (processDataGridView.SelectedRows.Cast<DataGridViewRow>().FirstOrDefault()?.DataBoundItem as DataRowView)
33-
?.Row
34-
?.Field<ProcessInfo>("info");
35-
}
36-
}
28+
public ProcessInfo SelectedProcess => (processDataGridView.SelectedRows.Cast<DataGridViewRow>().FirstOrDefault()?.DataBoundItem as DataRowView)
29+
?.Row
30+
?.Field<ProcessInfo>("info");
3731

3832
/// <summary>Gets if symbols should get loaded.</summary>
3933
public bool LoadSymbols => loadSymbolsCheckBox.Checked;

Forms/ProcessInfoForm.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -170,8 +170,8 @@ private void createClassAtAddressToolStripMenuItem_Click(object sender, EventArg
170170
private void dumpToolStripMenuItem_Click(object sender, EventArgs e)
171171
{
172172
bool isModule;
173-
string fileName = string.Empty;
174-
string initialDirectory = string.Empty;
173+
string fileName;
174+
var initialDirectory = string.Empty;
175175
IntPtr address;
176176
int size;
177177

Memory/Disassembler.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ public IEnumerable<DisassembledInstruction> DisassembleCode(IntPtr address, int
5757
var eip = address;
5858
var end = address + length;
5959

60-
var instruction = new InstructionData();
60+
InstructionData instruction;
6161
while (eip.CompareTo(end) == -1)
6262
{
6363
var res = coreFunctions.DisassembleCode(eip, end.Sub(eip).ToInt32() + 1, virtualAddress, out instruction);

Memory/RemoteProcess.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,7 @@ public void Close()
118118

119119
/// <summary>Reads remote memory from the address into the buffer.</summary>
120120
/// <param name="address">The address to read from.</param>
121-
/// <param name="data">[out] The data buffer to fill. If the remote process is not valid, the buffer will get filled with zeros.</param>
121+
/// <param name="buffer">[out] The data buffer to fill. If the remote process is not valid, the buffer will get filled with zeros.</param>
122122
public bool ReadRemoteMemoryIntoBuffer(IntPtr address, ref byte[] buffer)
123123
{
124124
Contract.Requires(buffer != null);
@@ -129,7 +129,7 @@ public bool ReadRemoteMemoryIntoBuffer(IntPtr address, ref byte[] buffer)
129129

130130
/// <summary>Reads remote memory from the address into the buffer.</summary>
131131
/// <param name="address">The address to read from.</param>
132-
/// <param name="data">[out] The data buffer to fill. If the remote process is not valid, the buffer will get filled with zeros.</param>
132+
/// <param name="buffer">[out] The data buffer to fill. If the remote process is not valid, the buffer will get filled with zeros.</param>
133133
/// <param name="offset">The offset in the data.</param>
134134
/// <param name="length">The number of bytes to read.</param>
135135
public bool ReadRemoteMemoryIntoBuffer(IntPtr address, ref byte[] buffer, int offset, int length)
@@ -255,7 +255,7 @@ public string ReadRemoteRuntimeTypeInformation(IntPtr address)
255255
{
256256
if (address.MayBeValid())
257257
{
258-
string rtti = null;
258+
string rtti;
259259
if (!rttiCache.TryGetValue(address, out rtti))
260260
{
261261
var objectLocatorPtr = ReadRemoteObject<IntPtr>(address - IntPtr.Size);

Plugins/PluginManager.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ private void LoadPlugins(IEnumerable<FileInfo> files, ILogger logger)
6969

7070
foreach (var fi in files)
7171
{
72-
FileVersionInfo fvi = null;
72+
FileVersionInfo fvi;
7373
try
7474
{
7575
fvi = FileVersionInfo.GetVersionInfo(fi.FullName);

Program.cs

Lines changed: 16 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -12,26 +12,20 @@ namespace ReClassNET
1212
{
1313
static class Program
1414
{
15-
private static Settings settings;
16-
private static ILogger logger;
17-
private static Random random = new Random();
18-
private static MainForm mainForm;
19-
private static bool designMode = true;
15+
public static Settings Settings { get; private set; }
2016

21-
public static Settings Settings => settings;
17+
public static ILogger Logger { get; private set; }
2218

23-
public static ILogger Logger => logger;
19+
public static Random GlobalRandom { get; } = new Random();
2420

25-
public static Random GlobalRandom => random;
21+
public static MainForm MainForm { get; private set; }
2622

27-
public static MainForm MainForm => mainForm;
28-
29-
public static bool DesignMode => designMode;
23+
public static bool DesignMode { get; private set; } = true;
3024

3125
[STAThread]
3226
static void Main()
3327
{
34-
designMode = false; // The designer doesn't call Main()
28+
DesignMode = false; // The designer doesn't call Main()
3529

3630
DpiUtil.ConfigureProcess();
3731

@@ -42,14 +36,14 @@ static void Main()
4236

4337
CultureInfo.DefaultThreadCurrentCulture = CultureInfo.InvariantCulture;
4438

45-
settings = Settings.Load(Constants.SettingsFile);
46-
logger = new GuiLogger();
39+
Settings = Settings.Load(Constants.SettingsFile);
40+
Logger = new GuiLogger();
4741
#if DEBUG
4842
using (var coreFunctions = new CoreFunctionsManager())
4943
{
50-
mainForm = new MainForm(coreFunctions);
44+
MainForm = new MainForm(coreFunctions);
5145

52-
Application.Run(mainForm);
46+
Application.Run(MainForm);
5347
}
5448
#else
5549
try
@@ -67,7 +61,7 @@ static void Main()
6761
}
6862
#endif
6963

70-
Settings.Save(settings, Constants.SettingsFile);
64+
Settings.Save(Settings, Constants.SettingsFile);
7165
}
7266

7367
/// <summary>Shows the exception in a special form.</summary>
@@ -76,9 +70,11 @@ public static void ShowException(Exception ex)
7670
{
7771
ex.HelpLink = Constants.HelpUrl;
7872

79-
var msg = new ExceptionMessageBox(ex);
80-
msg.ShowToolBar = true;
81-
msg.Symbol = ExceptionMessageBoxSymbol.Error;
73+
var msg = new ExceptionMessageBox(ex)
74+
{
75+
ShowToolBar = true,
76+
Symbol = ExceptionMessageBoxSymbol.Error
77+
};
8278
msg.Show(null);
8379
}
8480
}

0 commit comments

Comments
 (0)