GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — MemHack/MemHackGUI/Game1.cs at main · prespik/MemHack

Expand file tree

/

Game1.cs

Copy path
More file actions
More file actions

Latest commit

 

History

History
History
218 lines (163 loc) · 7.63 KB
/

Game1.cs

Copy path

File metadata and controls

218 lines (163 loc) · 7.63 KB
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
using ImGuiNET;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework.Input;
using MonoGame.ImGuiNet;
using System;
using System.Collections.Generic;
namespace MemHackGUI;
public class Game1 : Game
{
private GraphicsDeviceManager _graphics;
private SpriteBatch _spriteBatch;
private static ImGuiRenderer GuiRenderer;
bool _toolActive = true;
List<(nint hWnd, string title, uint processId)> windows = [];
int selectedWindowIndex = 0;
int searchedValue = 0;
int newValue = 0;
int selectedPointerIndex = -1;
List<IntPtr> foundPointers = [];
int itemsPerPage = 20; // Number of items to display per page
int currentPage = 0; // Track the current page (starting at 0)
string writeValueResult = "";
public Game1()
{
_graphics = new GraphicsDeviceManager(this);
Content.RootDirectory = "Content";
IsMouseVisible = true;
// set window size
_graphics.PreferredBackBufferWidth = 500;
_graphics.PreferredBackBufferHeight = 600;
_graphics.ApplyChanges();
// allow window resize
Window.AllowUserResizing = true;
// set window title
Window.Title = "MemHack";
// Get all opened windows
windows = MemHack.Program.GetAllWindows();
}
protected override void Initialize()
{
GuiRenderer = new ImGuiRenderer(this);
GuiRenderer.RebuildFontAtlas();
base.Initialize();
}
protected override void LoadContent()
{
_spriteBatch = new SpriteBatch(GraphicsDevice);
}
protected override void Update(GameTime gameTime)
{
if (GamePad.GetState(PlayerIndex.One).Buttons.Back == ButtonState.Pressed || Keyboard.GetState().IsKeyDown(Keys.Escape))
Exit();
base.Update(gameTime);
}
protected override void Draw(GameTime gameTime)
{
GraphicsDevice.Clear(Color.Black);
base.Draw(gameTime);
GuiRenderer.BeginLayout(gameTime);
// Get the application window size
var viewport = GraphicsDevice.Viewport;
var windowSize = new System.Numerics.Vector2(viewport.Width, viewport.Height);
// Get ImGui IO for configuration
var io = ImGui.GetIO();
// Enable docking
io.ConfigFlags |= ImGuiConfigFlags.DockingEnable;
// Create a root dockspace that occupies the entire game window
ImGui.SetNextWindowPos(System.Numerics.Vector2.Zero); // Position at the top-left corner
ImGui.SetNextWindowSize(windowSize); // Match the size of the game window
ImGui.SetNextWindowViewport(ImGui.GetMainViewport().ID);
// Set window flags to disable resizing, moving, and closing
var windowFlags = ImGuiWindowFlags.NoTitleBar | ImGuiWindowFlags.NoCollapse | ImGuiWindowFlags.NoResize | ImGuiWindowFlags.NoMove;
windowFlags |= ImGuiWindowFlags.NoBringToFrontOnFocus | ImGuiWindowFlags.NoDocking;
// Begin the main docking window
ImGui.Begin("DockSpace Window", windowFlags);
// Create the dockspace
var dockspaceId = ImGui.GetID("MyDockspace");
ImGui.DockSpace(dockspaceId, System.Numerics.Vector2.Zero, ImGuiDockNodeFlags.AutoHideTabBar);
// Ensure dockable windows are placed inside the dockspace
ImGui.SetNextWindowDockID(dockspaceId, ImGuiCond.Always);
// Add content to the docked window
var dockedWindowFlags = ImGuiWindowFlags.NoTitleBar | ImGuiWindowFlags.NoResize | ImGuiWindowFlags.NoCollapse | ImGuiWindowFlags.NoMove;
if (ImGui.Begin("MemHack", dockedWindowFlags))
{
if (ImGui.BeginCombo("Select Window", windows[selectedWindowIndex].title))
{
for (int i = 0; i < windows.Count; i++)
{
bool isSelected = (selectedWindowIndex == i);
if (ImGui.Selectable(windows[i].title, isSelected))
selectedWindowIndex = i;
// Highlight the selected item
if (isSelected)
ImGui.SetItemDefaultFocus();
}
ImGui.EndCombo();
}
ImGui.InputInt("Scan value", ref searchedValue);
if (ImGui.Button("New Scan"))
{
selectedPointerIndex = -1;
foundPointers = MemHack.Program.MemorySearch(windows[selectedWindowIndex].processId, searchedValue);
}
ImGui.SameLine();
if (foundPointers.Count == 0)
ImGui.BeginDisabled(); // Disable "Next Scan" button until the condition is met
if (ImGui.Button("Next Scan"))
{
selectedPointerIndex = -1;
foundPointers = MemHack.Program.FilterPointers(windows[selectedWindowIndex].processId, foundPointers, searchedValue);
}
if (foundPointers.Count == 0)
ImGui.EndDisabled(); // End the disabled block
ImGui.Text($"Found Addresses: {foundPointers.Count}");
// Pagination settings
int totalItems = foundPointers.Count;
int totalPages = (int)Math.Ceiling((float)totalItems / itemsPerPage);
// Calculate the range of items to display based on the current page
int startIndex = currentPage * itemsPerPage;
int endIndex = Math.Min(startIndex + itemsPerPage, totalItems);
// Begin scrollable area (child window)
ImGui.BeginChild("Scrollable List", new System.Numerics.Vector2(0, 200), ImGuiChildFlags.None, ImGuiWindowFlags.AlwaysVerticalScrollbar);
// Render the items for the current page
for (int i = startIndex; i < endIndex; i++)
{
bool isSelected = (selectedPointerIndex == i);
if (ImGui.Selectable($"0x{foundPointers[i]:X}", isSelected)) // Use item index or other string representation
selectedPointerIndex = i; // Update selected item index
if (isSelected)
ImGui.SetItemDefaultFocus(); // Focus the selected item
}
// End child window
ImGui.EndChild();
// Pagination Controls
ImGui.Spacing(); // Adds some space between the list and the pagination buttons
// Previous Page Button
if (currentPage > 0 && ImGui.Button("Previous Page"))
currentPage--; // Go to the previous page
if(currentPage > 0)
ImGui.SameLine(); // Place the next button on the same line
// Next Page Button
if (currentPage < totalPages - 1 && ImGui.Button("Next Page"))
currentPage++; // Go to the next page
// Display Page Info (e.g., "Page 1 of 10")
if(currentPage < totalPages)
ImGui.SameLine();
ImGui.Text($"Page {currentPage + 1} of {totalPages}");
ImGui.InputInt("New value", ref newValue);
if(selectedPointerIndex == -1)
ImGui.BeginDisabled(); // Disable "Write Value" button until the condition is met
if (ImGui.Button("Write Value"))
writeValueResult = MemHack.Program.WriteAddressValue(windows[selectedWindowIndex].processId, foundPointers[selectedPointerIndex], newValue);
if(selectedPointerIndex == -1)
ImGui.EndDisabled(); // Disable "Write Value" button until the condition is met
ImGui.Text(writeValueResult);
ImGui.End();
}
// End the main docking window
ImGui.End();
GuiRenderer.EndLayout();
}
}
You are visitor 01402792 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.