搜尋

生死僵局

返回清單
切換到指定樓層
通知這文章過時或找檔案 發表主題

《生死僵局》v1.0 偏移量自動獲取工具 - C#/C++雙版本支援 實時更新dwEntityList等關鍵數據

[複製連結]
1
yk81078 ( Lv.70 熾天使 ) 發表於 昨天 21:21 | 只看該作者 回覆獎勵 |降序瀏覽 |閱讀模式


《生死僵局》(Deadlock)偏移量獲取教學

☑️ 生死僵局偏移量獲取指南

本教學將介紹如何獲取生死僵局(Deadlock)遊戲中的重要偏移量,包括:

- dwEntityList
- ViewMatrix  
- LocalPlayerController (LocalPlayer)
- CCameraManager
- SchemaSystemInterface

請注意,由於遊戲經常更新,這些偏移量可能會在幾小時後失效。以下提供C#和C++兩種程式碼,可以運行其中之一來獲取最新偏移量。

☑️ C#程式碼
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Diagnostics;
  4. using System.Linq;
  5. using System.Runtime.InteropServices;
  6. using System.Text;

  7. class Program
  8. {
  9.     [StructLayout(LayoutKind.Sequential)]
  10.     public struct MODULEINFO
  11.     {
  12.         public IntPtr lpBaseOfDll;
  13.         public uint SizeOfImage;
  14.         public IntPtr EntryPoint;
  15.     }

  16.     class Signature
  17.     {
  18.         public string Pattern { get; }
  19.         public uint Offset { get; }
  20.         public uint Extra { get; }

  21.         public Signature(string pattern, uint offset, uint extra)
  22.         {
  23.             Pattern = pattern;
  24.             Offset = offset;
  25.             Extra = extra;
  26.         }

  27.         public List<byte> ParsePattern()
  28.         {
  29.             var bytes = new List<byte>();
  30.             var patternParts = Pattern.Split(' ');

  31.             foreach (var byteStr in patternParts)
  32.             {
  33.                 if (byteStr == "?" || byteStr == "??")
  34.                 {
  35.                     bytes.Add(0);
  36.                 }
  37.                 else
  38.                 {
  39.                     bytes.Add(Convert.ToByte(byteStr, 16));
  40.                 }
  41.             }

  42.             return bytes;
  43.         }

  44.         static T ReadMemory<T>(IntPtr processHandle, IntPtr address) where T : struct
  45.         {
  46.             var size = Marshal.SizeOf(typeof(T));
  47.             var buffer = new byte[size];
  48.             int bytesRead;

  49.             if (ReadProcessMemory(processHandle, address, buffer, size, out bytesRead) && bytesRead == size)
  50.             {
  51.                 GCHandle handle = GCHandle.Alloc(buffer, GCHandleType.Pinned);
  52.                 T result = (T)Marshal.PtrToStructure(handle.AddrOfPinnedObject(), typeof(T));
  53.                 handle.Free();
  54.                 return result;
  55.             }
  56.             throw new InvalidOperationException("Failed to read memory.");
  57.         }


  58.         public void Find(IEnumerable<byte> memory, IntPtr processHandle, IntPtr moduleBase)
  59.         {
  60.             var pattern = ParsePattern();
  61.             var printedAddresses = new HashSet<UIntPtr>();

  62.             for (int i = 0; i < memory.Count() - pattern.Count(); i++)
  63.             {
  64.                 bool patternMatch = true;
  65.                 for (int j = 0; j < pattern.Count(); j++)
  66.                 {
  67.                     if (pattern[j] != 0 && memory.ElementAt(i + j) != pattern[j])
  68.                     {
  69.                         patternMatch = false;
  70.                         break;
  71.                     }
  72.                 }

  73.                 if (patternMatch)
  74.                 {
  75.                     var patternAddress = (UIntPtr)(moduleBase.ToInt64() + i);
  76.                     int of = ReadMemory<int>(processHandle, (IntPtr)(patternAddress.ToUInt64() + Offset));
  77.                     var result = patternAddress.ToUInt64() + (UInt64)of + Extra;

  78.                     var resultPtr = new UIntPtr((UInt64)result - (UInt64)moduleBase.ToInt64());

  79.                     // Print the address only if it's not already printed
  80.                     if (printedAddresses.Add(resultPtr))
  81.                     {
  82.                         Console.WriteLine($"> 0x{resultPtr.ToUInt64():X}");
  83.                     }
  84.                 }
  85.             }
  86.         }
  87.     }

  88.     static void Main()
  89.     {
  90.         Console.WriteLine("By 5komar (Catrine)\n");
  91.         Console.WriteLine("My Discord Username > catrine\n");

  92.         var localPlayerSig = new Signature("48 8B 0D ? ? ? ? 48 85 C9 74 65 83 FF FF", 3, 7);
  93.         var viewMatrixSig = new Signature("48 8D ? ? ? ? ? 48 C1 E0 06 48 03 C1 C3", 3, 7);
  94.         var entityListSig = new Signature("48 8B 0D ? ? ? ? 8B C5 48 C1 E8", 3, 7);
  95.         var CCameraManagerSig = new Signature("48 8D 3D ? ? ? ? 8B D9", 3, 7);
  96.         var chemas_sig = new Signature("48 89 05 ? ? ? ? 4C 8D 0D ? ? ? ? 0F B6 45 E8 4C 8D 45 E0 33 F6", 3, 7);


  97.         string processName = "project8.exe";
  98.         var processHandle = GetProcessHandle(processName);

  99.         if (processHandle == IntPtr.Zero)
  100.         {
  101.             Console.WriteLine("Game process not found!");
  102.             return;
  103.         }

  104.         var moduleInfo = GetModuleInfo(processHandle, "client.dll");
  105.         var moduleInfo2 = GetModuleInfo(processHandle, "schemasystem.dll");
  106.         if (moduleInfo.lpBaseOfDll == IntPtr.Zero)
  107.         {
  108.             Console.WriteLine("client.dll not found!");
  109.             return;
  110.         }
  111.         if (moduleInfo2.lpBaseOfDll == IntPtr.Zero)
  112.         {
  113.             Console.WriteLine("schemasystem.dll not found!");
  114.             return;
  115.         }

  116.         var memory = ReadMemoryBytes(processHandle, moduleInfo.lpBaseOfDll, (int)moduleInfo.SizeOfImage);
  117.         var memory2 = ReadMemoryBytes(processHandle, moduleInfo2.lpBaseOfDll, (int)moduleInfo.SizeOfImage);

  118.         Console.WriteLine("LocalPlayerController:");
  119.         localPlayerSig.Find(memory, processHandle, moduleInfo.lpBaseOfDll);
  120.         Console.WriteLine("ViewMatrix:");
  121.         viewMatrixSig.Find(memory, processHandle, moduleInfo.lpBaseOfDll);
  122.         Console.WriteLine("EntityList:");
  123.         entityListSig.Find(memory, processHandle, moduleInfo.lpBaseOfDll);
  124.         Console.WriteLine("CCameraManager:");
  125.         CCameraManagerSig.Find(memory, processHandle, moduleInfo.lpBaseOfDll);
  126.         Console.WriteLine("SchemaSystemInterface:");
  127.         chemas_sig.Find(memory2, processHandle, moduleInfo2.lpBaseOfDll);

  128.         CloseHandle(processHandle);
  129.     }

  130.     static List<byte> ReadMemoryBytes(IntPtr processHandle, IntPtr address, int size)
  131.     {
  132.         var buffer = new byte[size];
  133.         ReadProcessMemory(processHandle, address, buffer, size, out _);
  134.         return buffer.ToList();
  135.     }

  136.     static IntPtr GetProcessHandle(string processName)
  137.     {
  138.         processName = processName.EndsWith(".exe") ? processName.Substring(0, processName.Length - 4) : processName;

  139.         var processes = Process.GetProcessesByName(processName);
  140.         if (processes.Length > 0)
  141.         {
  142.             IntPtr processHandle = OpenProcess(0x0010 | 0x0400, false, processes[0].Id);

  143.             if (processHandle != IntPtr.Zero)
  144.             {
  145.                 return processHandle;
  146.             }
  147.             else
  148.             {
  149.                 Console.WriteLine($"Failed to open process handle. Error code: {Marshal.GetLastWin32Error()}");
  150.             }
  151.         }
  152.         else
  153.         {
  154.             Console.WriteLine($"No process found with name '{processName}'");
  155.         }

  156.         return IntPtr.Zero;
  157.     }

  158.     static MODULEINFO GetModuleInfo(IntPtr processHandle, string moduleName)
  159.     {
  160.         MODULEINFO modInfo = new MODULEINFO();
  161.         IntPtr[] hMods = new IntPtr[1024];
  162.         GCHandle gch = GCHandle.Alloc(hMods, GCHandleType.Pinned);
  163.         if (EnumProcessModules(processHandle, gch.AddrOfPinnedObject(), (uint)(hMods.Length * IntPtr.Size), out uint cbNeeded))
  164.         {
  165.             for (int i = 0; i < (cbNeeded / IntPtr.Size); i++)
  166.             {
  167.                 StringBuilder szModName = new StringBuilder(1024);
  168.                 if (GetModuleBaseName(processHandle, hMods[i], szModName, szModName.Capacity) > 0)
  169.                 {
  170.                     if (moduleName == szModName.ToString())
  171.                     {
  172.                         GetModuleInformation(processHandle, hMods[i], out modInfo, (uint)Marshal.SizeOf(typeof(MODULEINFO)));
  173.                         break;
  174.                     }
  175.                 }
  176.             }
  177.         }
  178.         gch.Free();
  179.         return modInfo;
  180.     }

  181.     [DllImport("psapi.dll", SetLastError = true)]
  182.     static extern bool EnumProcessModules(IntPtr hProcess, IntPtr lphModule, uint cb, out uint lpcbNeeded);

  183.     [DllImport("psapi.dll", SetLastError = true)]
  184.     static extern uint GetModuleBaseName(IntPtr hProcess, IntPtr hModule, StringBuilder lpBaseName, int nSize);

  185.     [DllImport("psapi.dll", SetLastError = true)]
  186.     static extern bool GetModuleInformation(IntPtr hProcess, IntPtr hModule, out MODULEINFO lpmodinfo, uint cb);

  187.     [DllImport("kernel32.dll", SetLastError = true)]
  188.     static extern bool ReadProcessMemory(IntPtr hProcess, IntPtr lpBaseAddress, [Out] byte[] lpBuffer, int dwSize, out int lpNumberOfBytesRead);

  189.     [DllImport("kernel32.dll", SetLastError = true)]
  190.     static extern bool ReadProcessMemory(IntPtr hProcess, IntPtr lpBaseAddress, out int lpBuffer, int dwSize, out int lpNumberOfBytesRead);

  191.     [DllImport("kernel32.dll", SetLastError = true)]
  192.     static extern IntPtr OpenProcess(int dwDesiredAccess, bool bInheritHandle, int dwProcessId);

  193.     [DllImport("kernel32.dll", SetLastError = true)]
  194.     static extern bool CloseHandle(IntPtr hObject);
  195. }
複製代碼
☑️ C++程式碼
  1. #include <Windows.h>
  2. #include <TlHelp32.h>
  3. #include <IOStream>
  4. #include <vector>
  5. #include <string>
  6. #include <Psapi.h>
  7. #include <sstream>

  8. struct Signature {
  9.     std::string pattern;
  10.     uint32_t offset;
  11.     uint32_t extra;

  12.     Signature(const std::string& pat, uint32_t off, uint32_t ext)
  13.         : pattern(pat), offset(off), extra(ext) {}

  14.     std::vector<uint8_t> parse_pattern() const {
  15.         std::vector<uint8_t> bytes;
  16.         std::istringstream patternStream(pattern);
  17.         std::string byteStr;

  18.         while (patternStream >> byteStr) {
  19.             if (byteStr == "?" || byteStr == "??") {
  20.                 bytes.push_back(0);
  21.             }
  22.             else {
  23.                 bytes.push_back(static_cast<uint8_t>(strtol(byteStr.c_str(), nullptr, 16)));
  24.             }
  25.         }
  26.         return bytes;
  27.     }

  28.     void find(const std::vector<uint8_t>& memory, HANDLE processHandle, uintptr_t moduleBase) const {
  29.         std::vector<uint8_t> pattern = parse_pattern();
  30.         for (size_t i = 1000000; i < memory.size(); ++i) {
  31.             bool patternMatch = true;
  32.             for (size_t j = 0; j < pattern.size(); ++j) {
  33.                 if (pattern[j] != 0 && memory[i + j] != pattern[j]) {
  34.                     patternMatch = false;
  35.                     break;
  36.                 }
  37.             }
  38.             if (patternMatch) {
  39.                 uintptr_t patternAddress = moduleBase + i;
  40.                 int32_t of;
  41.                 ReadProcessMemory(processHandle, reinterpret_cast<LPCVOID>(patternAddress + offset), &of, sizeof(of), nullptr);
  42.                 uintptr_t result = patternAddress + of + extra;
  43.                 std::cout << "+ 0x" << std::hex << (result - moduleBase) << std::endl;
  44.             }
  45.         }
  46.     }
  47. };

  48. // Helper function to convert TCHAR to std::string or std::wstring
  49. #ifdef UNICODE
  50. std::wstring toString(const TCHAR* tcharArray) {
  51.     return std::wstring(tcharArray);
  52. }
  53. #else
  54. std::string toString(const TCHAR* tcharArray) {
  55.     return std::string(tcharArray);
  56. }
  57. #endif

  58. std::string wstringToString(const std::wstring& wstr) {
  59.     std::string str(wstr.begin(), wstr.end());
  60.     return str;
  61. }

  62. HANDLE getProcessHandle(const std::string& processName) {
  63.     PROCESSENTRY32 processEntry;
  64.     processEntry.dwSize = sizeof(PROCESSENTRY32);
  65.     HANDLE snapshot = CreateToolhelp32Snapshot(TH32CS_SNAPPROCESS, 0);

  66.     if (Process32First(snapshot, &processEntry)) {
  67.         do {
  68.             std::string exeFileName = wstringToString(processEntry.szExeFile);
  69.             if (processName == exeFileName) {
  70.                 CloseHandle(snapshot);
  71.                 return OpenProcess(PROCESS_VM_READ | PROCESS_QUERY_INFORMATION, FALSE, processEntry.th32ProcessID);
  72.             }
  73.         } while (Process32Next(snapshot, &processEntry));
  74.     }
  75.     CloseHandle(snapshot);
  76.     return nullptr;
  77. }


  78. MODULEINFO getModuleInfo(HANDLE processHandle, const std::string& moduleName) {
  79.     HMODULE hMods[1024];
  80.     DWORD cbNeeded;
  81.     MODULEINFO modInfo = { 0 };

  82.     if (EnumProcessModules(processHandle, hMods, sizeof(hMods), &cbNeeded)) {
  83.         for (unsigned int i = 0; i < (cbNeeded / sizeof(HMODULE)); i++) {
  84.             char szModName[MAX_PATH];
  85.             if (GetModuleBaseNameA(processHandle, hMods[i], szModName, sizeof(szModName) / sizeof(char))) {
  86.                 if (moduleName == szModName) {
  87.                     GetModuleInformation(processHandle, hMods[i], &modInfo, sizeof(modInfo));
  88.                     break;
  89.                 }
  90.             }
  91.         }
  92.     }
  93.     return modInfo;
  94. }

  95. std::vector<uint8_t> readMemoryBytes(HANDLE processHandle, uintptr_t address, size_t size) {
  96.     std::vector<uint8_t> buffer(size);
  97.     ReadProcessMemory(processHandle, reinterpret_cast<LPCVOID>(address), buffer.data(), size, nullptr);
  98.     return buffer;
  99. }

  100. int main() {
  101.     std::cerr << "By 5komar (Catrine)\n" << std::endl;

  102.     Signature localPlayerSig("48 8B 0D ? ? ? ? 48 85 C9 74 65 83 FF FF", 3, 7);
  103.     Signature viewMatrixSig("48 8D ? ? ? ? ? 48 C1 E0 06 48 03 C1 C3", 3, 7);
  104.     Signature entityListSig("48 8B 0D ? ? ? ? 8B C5 48 C1 E8", 3, 7);
  105.     Signature CCameraManagerSig("48 8D 3D ? ? ? ? 8B D9", 3, 7);


  106.     std::string processName = "project8.exe";
  107.     HANDLE processHandle = getProcessHandle(processName);
  108.     if (!processHandle) {
  109.         std::cerr << "Game process not found!" << std::endl;
  110.         return 1;
  111.     }

  112.     MODULEINFO moduleInfo = getModuleInfo(processHandle, "client.dll");

  113.     if (!moduleInfo.lpBaseOfDll) {
  114.         std::cerr << "client.dll not found!" << std::endl;
  115.         return 1;
  116.     }

  117.     std::vector<uint8_t> memory = readMemoryBytes(processHandle, reinterpret_cast<uintptr_t>(moduleInfo.lpBaseOfDll), moduleInfo.SizeOfImage);

  118.     std::cout << "LocalPlayerController:" << std::endl;
  119.     localPlayerSig.find(memory, processHandle, reinterpret_cast<uintptr_t>(moduleInfo.lpBaseOfDll));
  120.     std::cout << "ViewMatrix:" << std::endl;
  121.     viewMatrixSig.find(memory, processHandle, reinterpret_cast<uintptr_t>(moduleInfo.lpBaseOfDll));
  122.     std::cout << "EntityList:" << std::endl;
  123.     entityListSig.find(memory, processHandle, reinterpret_cast<uintptr_t>(moduleInfo.lpBaseOfDll));
  124.     std::cout << "CCameraManager:" << std::endl;
  125.     CCameraManagerSig.find(memory, processHandle, reinterpret_cast<uintptr_t>(moduleInfo.lpBaseOfDll));

  126.     CloseHandle(processHandle);
  127.     return 0;
  128. }
複製代碼
☑️ 使用說明

1. 選擇C#或C++程式碼,複製到您的開發環境中。
2. 確保您已安裝必要的開發工具和相關函式庫。
3. 編譯並運行程式。
4. 程式會自動搜索生死僵局遊戲進程並獲取所需的偏移量。
5. 獲取到的偏移量將顯示在控制台輸出中。





☑️ 常見問題

Q1: 為什麼我無法獲取偏移量?
A1: 請確保遊戲正在運行,且您擁有足夠的權限訪問遊戲進程。

Q2: 獲取到的偏移量多久更新一次?
A2: 建議每次遊戲更新後重新運行程式獲取最新偏移量。

Q3: 使用這些偏移量是否安全?
A3: 使用任何非官方工具都有風險,請謹慎使用並自行承擔後果。









大家正在看啥


收藏收藏 分享文章到FB上分享
回覆 使用道具 檢舉
複製專屬你的推廣連結:發至FB與各論壇宣傳:累積點數換GP商品 & 藍鑽
每五點閱率就可以兌換藍鑽積分或遊戲點卡 夢遊推廣文章換GP商品

你需要登入後才可以回覆 登入 | 加入會員

本版積分規則

Copyright (C) 2010-2020 夢遊電玩論壇

廣告合作:請直接聯繫我們,並附上您預刊登位置的預算。  

快速回覆 返回頂端 返回清單