What to do when things go wrong?

一秒扫雷

可以直接用CE进行雷总数修改,下面是通过C#直接修改雷总数内存地址

 /// PROCESS_ALL_ACCESS -> (STANDARD_RIGHTS_REQUIRED | SYNCHRONIZE | 0xFFF)
 public const int PROCESS_ALL_ACCESS = (STANDARD_RIGHTS_REQUIRED| (SYNCHRONIZE | 4095));

 /// STANDARD_RIGHTS_REQUIRED -> (0x000F0000L)
 public const int STANDARD_RIGHTS_REQUIRED = 983040;

 /// SYNCHRONIZE -> (0x00100000L)
 public const int SYNCHRONIZE = 1048576;

 /// https://docs.microsoft.com/zh-cn/windows/win32/api/processthreadsapi/nf-processthreadsapi-openprocess
 /// Return Type: HANDLE->void*
 ///dwDesiredAccess: DWORD->unsigned int
 ///bInheritHandle: BOOL->int
 ///dwProcessId: DWORD->unsigned int
 [System.Runtime.InteropServices.DllImportAttribute("kernel32.dll", EntryPoint = "OpenProcess")]
 public static extern System.IntPtr OpenProcess(uint dwDesiredAccess, [System.Runtime.InteropServices.MarshalAsAttribute(System.Runtime.InteropServices.UnmanagedType.Bool)] bool bInheritHandle, uint dwProcessId);

 /// https://docs.microsoft.com/en-us/windows/win32/api/memoryapi/nf-memoryapi-writeprocessmemory
 /// Return Type: BOOL->int
 ///hProcess: HANDLE->void*
 ///lpBaseAddress: LPVOID->void*
 ///lpBuffer: LPCVOID->void*
 ///nSize: SIZE_T->ULONG_PTR->unsigned int
 ///lpNumberOfBytesWritten: SIZE_T*
 [System.Runtime.InteropServices.DllImportAttribute("kernel32.dll", EntryPoint = "WriteProcessMemory")]
 [return: System.Runtime.InteropServices.MarshalAsAttribute(System.Runtime.InteropServices.UnmanagedType.Bool)]
 public static extern bool WriteProcessMemory(System.IntPtr hProcess, System.IntPtr lpBaseAddress, System.IntPtr lpBuffer, uint nSize, ref uint lpNumberOfBytesWritten);
private int GetProcessId(string name)
{
    var process = Process.GetProcesses().ToList().FirstOrDefault(f => f.ProcessName == name);
    return process.Id;
}

 private void button1_Click(object sender, EventArgs e)
 {
     var pid = GetProcessId("MineSweeper");
     var hProcess = NativeApiCall.OpenProcess(NativeApiCall.PROCESS_ALL_ACCESS, false, (uint)pid);

     int address = 0x06241858;// 类总数内存地址
 
     byte[] rBytes = new byte[] { 0x00, 0x00, 0x00, 0x00 };
     uint lpNumberOfBytesWrite = 0;
     var lpBuffer = Marshal.UnsafeAddrOfPinnedArrayElement(rBytes, 0);
     NativeApiCall.WriteProcessMemory(hProcess, (IntPtr)address, lpBuffer, 4, ref lpNumberOfBytesWrite);
 }

posted on 2020-07-19 13:13  zhuanghamiao  阅读(159)  评论(4编辑  收藏

导航

统计