C 写入具有受保护内存的过程
C++ Write to a process with protected memory
因此,我决定开始进入内存编辑,以便能够为游戏制作更多工具。看到游戏已经通过使用作弊引擎和或其他任何其他内存编辑软件修补了作弊的网络版本,我决定自己制作一种内存编辑工具,但使用NoxPlayer,它是Android模拟器,没有在移动设备上修补该方法,但没有其他人知道该方法。
无论如何,我之前遇到了这种类型的问题。但是,随着作弊引擎的一些设置更改,我就可以在模拟器上编辑游戏内部的内存。
是我的C 应用程序,它可以从抓取的地址读取内存,但无法将内存写入地址。
所以我想知道是否有人可以帮助我找到一个解决方案,以使模拟器中的受保护内存能够更改值?
(即使可能不需要它,也将提供我当前代码的一部分)。
private: System::Void backgroundWorker3_DoWork(System::Object^ sender, System::ComponentModel::DoWorkEventArgs^ e) {
button1->Text = "Stop Spoofing";
string ac;
MarshalString(sid->Text, ac); // made a function to convert system string to std string
stringstream stream(ac);
stream >> value; // setting value to write to memory
HANDLE handle = OpenProcess(PROCESS_ALL_ACCESS, FALSE, processID);
while (true)
{
if (backgroundWorker3->CancellationPending == true)
{
e->Cancel = true;
break;
}
else
{
if (DoesTxtExist())
{
for (int i(0); i < address.size(); ++i)
{
WriteProcessMemory(handle, (LPVOID)address[i], &value, sizeof(value), 0);
ReadProcessMemory(handle, (PBYTE*)address[i], &readTest, sizeof(int), 0);
}
label1->Text = L"Spoofing ID: "+readTest.ToString()+" "+value.ToString();
// was doing something like this to check if the values changed, but of course they didn't.
}
}
}
}
在写attemps之前,请使用VirtualProtectEx()
将内存保护更改为可写的。使用Process_all_access打开手柄不会自动渲染整个过程内存。
您必须作为管理员运行。您可能还需要Sedebugprivilege令牌特权。
您可以通过使用清单文件设置应用程序来要求管理员模式。
您可以通过pinvoke.net
设置此功能的SedebugprivilegePublic Class AdjPriv()
{
[DllImport("advapi32.dll", ExactSpelling = true, SetLastError = true)]
internal static extern bool AdjustTokenPrivileges(IntPtr htok, bool disall,
ref TokPriv1Luid newst, int len, IntPtr prev, IntPtr relen);
[DllImport("kernel32.dll", ExactSpelling = true)]
internal static extern IntPtr GetCurrentProcess();
[DllImport("advapi32.dll", ExactSpelling = true, SetLastError = true)]
internal static extern bool OpenProcessToken(IntPtr h, int acc, ref IntPtr
phtok);
[DllImport("advapi32.dll", SetLastError = true)]
internal static extern bool LookupPrivilegeValue(string host, string name,
ref long pluid);
[StructLayout(LayoutKind.Sequential, Pack = 1)]
internal struct TokPriv1Luid
{
public int Count;
public long Luid;
public int Attr;
}
internal const int SE_PRIVILEGE_ENABLED = 0x00000002;
internal const int TOKEN_QUERY = 0x00000008;
internal const int TOKEN_ADJUST_PRIVILEGES = 0x00000020;
internal const string SE_TIME_ZONE_NAMETEXT = "SeTimeZonePrivilege"; //http://msdn.microsoft.com/en-us/library/bb530716(VS.85).aspx
private bool SetPriv()
{
try
{
bool retVal;
TokPriv1Luid tp;
IntPtr hproc = GetCurrentProcess();
IntPtr htok = IntPtr.Zero;
retVal = OpenProcessToken(hproc, TOKEN_ADJUST_PRIVILEGES | TOKEN_QUERY, ref htok);
tp.Count = 1;
tp.Luid = 0;
tp.Attr = SE_PRIVILEGE_ENABLED;
retVal = LookupPrivilegeValue(null, SE_TIME_ZONE_NAMETEXT, ref tp.Luid);
retVal = AdjustTokenPrivileges(htok, false, ref tp, 0, IntPtr.Zero, IntPtr.Zero);
return retVal;
}
catch (Exception ex)
{
throw;
return false;
}
}
}
一旦这两件事不开,如果您试图覆盖任何代码的内容,它将位于模块的一个代码部分中,该部分将执行权限但不编写权限。
要获得写入权限,您必须在要修改的内存位置上调用VirtualProtectex()。我没有c#摘要,但是我基本上有一个用于writeProcessMemory的包装器,该包装在此之前和之后都称为virtualProtectex()
void PatchEx(HANDLE hProc, char* dst, char* src, const intptr_t size)
{
DWORD oldprotect;
VirtualProtectEx(hProc, dst, size, PAGE_EXECUTE_READWRITE, &oldprotect);
WriteProcessMemory(hProc, dst, src, size, nullptr);
VirtualProtectEx(hProc, dst, size, oldprotect, &oldprotect);
}
我可以想象,您可以轻松地重新创建A C#。然后,每当您要写入内存时,请使用此功能来确保正确设置页面内存保护常数。
- 将字符串存储在c++中的稳定内存中
- 如何将矩阵的行随机复制到内存中的另一个矩阵的过程并行化?
- 在序列化过程中删除不必要的内存分配
- 如果在执行过程中替换二进制文件,"const"数组是否驻留在内存中?
- 在过程堆内存中找到模式
- 列出当前过程并使用未记录的当前功能编写内存的软件技巧
- 如何在另一个过程内存中扫描INT值
- 如何从32位流程中获取可靠的内存使用信息以进行64位过程
- C 写入具有受保护内存的过程
- 如果我想在执行过程中将其内存减少一半,我可以使用哪种数据结构
- 使用nodejs在Windows中读取过程的内存值
- Linux如何知道过程使用了多少物理内存
- 通过共享内存IPC在过程之间共享指针
- C 可以在程序执行过程中移动内存映射的文件(boost :: intercecess)移动
- 指针的C 内存分配过程
- C中的内存分配过程?它是向下还是自下而上的方法
- 如何在C++过程中计算内存
- c++中向下转换过程中的内存布局
- 类初始化过程中的内存重叠
- Windows线程创建过程中的内存管理