From f304814ab0def6992bca6933db1174ea2daa62e3 Mon Sep 17 00:00:00 2001 From: "raidmax@live.com" Date: Wed, 15 Jul 2015 17:10:07 -0500 Subject: [PATCH] MOAR CHANGES!! --- Admin/Server.cs | 4 +++- Admin/Utilities.cs | 32 ++++++++++++++++++++++++-------- 2 files changed, 27 insertions(+), 9 deletions(-) diff --git a/Admin/Server.cs b/Admin/Server.cs index a441e24d4..f74dd3a5c 100644 --- a/Admin/Server.cs +++ b/Admin/Server.cs @@ -236,6 +236,8 @@ namespace IW4MAdmin aliasDB.updatePlayer(NewPlayer.Alias); clientDB.updatePlayer(NewPlayer); + Utilities.Wait(10); // they're loading in. + if (NewPlayer.getLevel() == Player.Permission.Banned) // their guid is already banned so no need to check aliases { String Message; @@ -538,7 +540,7 @@ namespace IW4MAdmin private void setDvar(String Dvar, String Value) { - //Utilities.setDvar(PID, Dvar, Value); + // Utilities.setDvar(PID, Dvar, Value); } [DllImport("kernel32.dll")] diff --git a/Admin/Utilities.cs b/Admin/Utilities.cs index 92c1a4fc0..3f17bdb6a 100644 --- a/Admin/Utilities.cs +++ b/Admin/Utilities.cs @@ -457,8 +457,8 @@ namespace IW4MAdmin public static void setDvar(int Location, int Handle, String Value) { - //UIntPtr bytesWritten = UIntPtr.Zero; - //WriteProcessMemory((IntPtr)Handle, (IntPtr)Location, Encoding.ASCII.GetBytes(Value), (uint)Value.Length, out bytesWritten); + UIntPtr bytesWritten = UIntPtr.Zero; + WriteProcessMemory((IntPtr)Handle, (IntPtr)Location, Encoding.ASCII.GetBytes(Value), (uint)Value.Length, out bytesWritten); } public static String getStringFromPointer(int Location, int Handle) @@ -539,6 +539,22 @@ namespace IW4MAdmin if (!VirtualFreeEx(ProcessHandle, memoryForCMDName, 0, AllocationType.Release)) Console.WriteLine(Marshal.GetLastWin32Error());*/ + IntPtr ProcessHandle = OpenProcess(ProcessAccessFlags.All, false, pID); + IntPtr memoryForDvarName = allocateAndWrite(Encoding.ASCII.GetBytes(Command + "\0"), ProcessHandle); + + if (memoryForDvarName == IntPtr.Zero) + { + Console.WriteLine("UNABLE TO ALLOCATE MEMORY FOR DVAR NAME"); + return; + } + + setDvarCurrentPtr(0x2098D9C, memoryForDvarName, ProcessHandle); + + // if (!VirtualFreeEx(ProcessHandle, memoryForDvarName, 0, AllocationType.Release)) + // Console.WriteLine("Virtual Free Failed -- Error #" + Marshal.GetLastWin32Error()); + + CloseHandle(ProcessHandle); + } public static IntPtr allocateAndWrite(Byte[] Data, IntPtr ProcessHandle) @@ -557,9 +573,9 @@ namespace IW4MAdmin return AllocatedMemory; } - public static bool setDvarCurrentPtr(IntPtr DvarAddress, IntPtr ValueAddress, IntPtr ProcessHandle) + public static bool setDvarCurrentPtr(int DvarAddress, IntPtr ValueAddress, IntPtr ProcessHandle) { - int locationOfCurrentPtr = getIntFromPointer((int)DvarAddress, (int)ProcessHandle) + 0x10; + int locationOfCurrentPtr = getIntFromPointer(DvarAddress, (int)ProcessHandle) + 0x10; Byte[] newTextPtr = BitConverter.GetBytes((int)ValueAddress); UIntPtr bytesWritten; if (!WriteProcessMemory(ProcessHandle, (IntPtr)locationOfCurrentPtr, newTextPtr, (uint)newTextPtr.Length, out bytesWritten)) @@ -608,7 +624,7 @@ namespace IW4MAdmin public static void setDvar(int pID, String Name, String Value) { - IntPtr ProcessHandle = OpenProcess(ProcessAccessFlags.All, false, pID); + /* IntPtr ProcessHandle = OpenProcess(ProcessAccessFlags.All, false, pID); IntPtr memoryForDvarName = allocateAndWrite(Encoding.ASCII.GetBytes(Name + " " + Value + "\0"), ProcessHandle); if (memoryForDvarName == IntPtr.Zero) @@ -617,12 +633,12 @@ namespace IW4MAdmin return; } - setDvarCurrentPtr((IntPtr)0x2098D9C, memoryForDvarName, ProcessHandle); + setDvarCurrentPtr(0x2098D9C, memoryForDvarName, ProcessHandle); if (!VirtualFreeEx(ProcessHandle, memoryForDvarName, 0, AllocationType.Release)) Console.WriteLine("Virtual Free Failed -- Error #" + Marshal.GetLastWin32Error()); - CloseHandle(ProcessHandle); + CloseHandle(ProcessHandle);*/ } public static dvar getDvar(int pID, String DVAR) @@ -637,7 +653,7 @@ namespace IW4MAdmin return requestedDvar; } - setDvarCurrentPtr((IntPtr)0x2089E04, memoryForDvarName, ProcessHandle); // sv_debugRate + setDvarCurrentPtr(0x2089E04, memoryForDvarName, ProcessHandle); // sv_debugRate #if ASD /* byte[] copyDvarValue = { 0x55, 0x8B, 0xEC, 0x83, 0xEC, 0x08, // -----------------------------------------------