Skip to content
This repository has been archived by the owner on Apr 16, 2022. It is now read-only.

Commit

Permalink
Small Changes
Browse files Browse the repository at this point in the history
  • Loading branch information
sunnamed434 committed May 10, 2021
1 parent 2af2203 commit 4d6cf1a
Show file tree
Hide file tree
Showing 7 changed files with 167 additions and 189 deletions.
2 changes: 1 addition & 1 deletion CGWH/Core/Features/ESP.cs
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ private void enable()
{
int playerTeamNum = Cheat.Memory.Read<int>(Player.Local + Offsets.m_iTeamNum);

for (int i = 0; i < 10; i++)
for (int i = 0; i < 64; i++)
{
int enemyNum = Cheat.Memory.Read<int>(Cheat.ModuleAddress + Offsets.dwEntityList + i * 16);
int enemyTeamNum = Cheat.Memory.Read<int>(enemyNum + Offsets.m_iTeamNum);
Expand Down
2 changes: 1 addition & 1 deletion CGWH/Core/Features/Radar.cs
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ private void enable()
{
if (WindowHandler.TryGetCSGOWindow())
{
for (int i = 0; i < 10; i++)
for (int i = 0; i < 64; i++)
{
int enemy = Cheat.Memory.Read<int>(Cheat.ModuleAddress + Offsets.dwEntityList + (i * 0x10));

Expand Down
2 changes: 0 additions & 2 deletions CGWH/Core/Handlers/InitializeHandler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,6 @@ protected InitializeHandler()

protected abstract void OnEnable();



protected abstract void OnDisable();


Expand Down
7 changes: 2 additions & 5 deletions CGWH/Core/Handlers/WindowHandler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,14 +19,11 @@ internal static string GetActiveWindowTitle()
{
byte value = byte.MaxValue;

StringBuilder Buff = new StringBuilder(value);
StringBuilder builder = new StringBuilder(value);

IntPtr handle = GetForegroundWindow();

if (GetWindowText(handle, Buff, value) > 0)
{
return Buff.ToString();
}
if (GetWindowText(handle, builder, value) > 0) return builder.ToString();

return null;
}
Expand Down
41 changes: 12 additions & 29 deletions CGWH/Core/KeyboardListener/LowLevelKeyboardListener.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,41 +5,41 @@

namespace CGWH.Core.Input
{
public class LowLevelKeyboardListener
public class SimpleKeyboardListener
{
private const int WH_KEYBOARD_LL = 13;

private const int WM_KEYDOWN = 0x0100;

private const int WM_SYSKEYDOWN = 0x0104;

private IntPtr hookId = IntPtr.Zero;


private IntPtr hookId = IntPtr.Zero;

private LowLevelKeyboardProc keyboardProc { get; }
private Handle handle { get; }



internal delegate IntPtr LowLevelKeyboardProc(int nCode, IntPtr wParam, IntPtr lParam);
internal delegate IntPtr Handle(int nCode, IntPtr wParam, IntPtr lParam);

internal event Action<Key> OnKeyPressed;



internal LowLevelKeyboardListener()
internal SimpleKeyboardListener()
{
keyboardProc = hookCallback;
handle = hookCallback;

HookKeyboard();
Hook();
}



#region DLL-Import`s

[DllImport("user32.dll", CharSet = CharSet.Auto, SetLastError = true)]
private static extern IntPtr SetWindowsHookEx(int idHook, LowLevelKeyboardProc lpfn, IntPtr hMod, uint dwThreadId);
private static extern IntPtr SetWindowsHookEx(int idHook, Handle lpfn, IntPtr hMod, uint dwThreadId);


[DllImport("user32.dll", CharSet = CharSet.Auto, SetLastError = true)]
Expand All @@ -58,35 +58,18 @@ internal LowLevelKeyboardListener()



internal void HookKeyboard()
{
hookId = setHook(keyboardProc);
}
internal void Hook() => hookId = setHook(handle);

internal void UnHookKeyboard()
{
UnhookWindowsHookEx(hookId);
}
internal void UnHook() => UnhookWindowsHookEx(hookId);



private IntPtr setHook(LowLevelKeyboardProc proc)
{
using (Process curProcess = Process.GetCurrentProcess())
using (ProcessModule curModule = curProcess.MainModule)
{
return SetWindowsHookEx(WH_KEYBOARD_LL, proc, GetModuleHandle(curModule.ModuleName), 0);
}
}
private IntPtr setHook(Handle handle) => SetWindowsHookEx(WH_KEYBOARD_LL, handle, GetModuleHandle(Process.GetCurrentProcess().MainModule.ModuleName), 0);

private IntPtr hookCallback(int nCode, IntPtr wParam, IntPtr lParam)
{
if (nCode >= 0 && wParam == (IntPtr)WM_KEYDOWN || wParam == (IntPtr)WM_SYSKEYDOWN)
{
int vkCode = Marshal.ReadInt32(lParam);

OnKeyPressed?.Invoke(KeyInterop.KeyFromVirtualKey(vkCode));
}
OnKeyPressed?.Invoke(KeyInterop.KeyFromVirtualKey(Marshal.ReadInt32(lParam)));

return CallNextHookEx(hookId, nCode, wParam, lParam);
}
Expand Down
Loading

0 comments on commit 4d6cf1a

Please sign in to comment.