可能重复:
如何从C#中的byte []获取IntPtr
我正在从记忆中读取字符串
byte[] array =
reader.ReadProcessMemory((IntPtr)address, (uint)255, out bytesReadSize);
Run Code Online (Sandbox Code Playgroud)
然后我将这个数组转换为字符串.
我现在遇到一个问题,因为程序内存中的地址003A53D4有一个指向字符串的指针.我怎样才能得到字符串的地址?谢谢 :)
那是我做了什么:
IntPtr pointers_address = new IntPtr(module_base_address + 3822548);
byte[] pointer_arrays =
reader.ReadProcessMemory(pointers_address, (uint)16, out bytesReadSize2);
IntPtr pointer_for_string = new IntPtr();
Marshal.Copy(pointers_array, 0, pointer_for_string, 16);
Run Code Online (Sandbox Code Playgroud)
它说(约4行):
值不能为空.参数名称:destination
当我将新的IntPtr()更改 为新的IntPtr(1)时, 它说
尝试读取或写入受保护的内存.这通常表明其他内存已损坏.
我正在尝试制作一个程序来读取Minesweeper的计时器值.(操作系统是Windows 7 64位)
使用作弊引擎我找到了变量的基地址,但每次运行扫雷时它都会改变.
我需要做什么才能自动找到基地址?
它与可执行基地址有关吗?
这是我的代码:
#include <windows.h>
#include <iostream>
using namespace std;
int main()
{
DWORD baseAddress = 0xFF1DAA38;//always changing
DWORD offset1 = 0x18;
DWORD offset2 = 0x20;
DWORD pAddress1;
DWORD pAddress2;
float value = 0;
DWORD pid;
HWND hwnd;
hwnd = FindWindow(NULL,"Minesweeper");
if(!hwnd)//didn't find the window
{
cout <<"Window not found!\n";
cin.get();
}
else
{
GetWindowThreadProcessId(hwnd,&pid);
HANDLE phandle = OpenProcess(PROCESS_VM_READ,0,pid);//get permission to read
if(!phandle)//failed to get permission
{
cout <<"Could not get handle!\n";
cin.get();
}
else
{ …Run Code Online (Sandbox Code Playgroud) 我尝试读取进程的所有提交页面(Win7-64).在大多数页面上它可以工作,但几页失败.我无法解释原因.这是我的测试程序(编译x32,在Win7-64中测试):
#include <windows.h>
void main()
{
HANDLE hProc = OpenProcess(PROCESS_VM_READ | PROCESS_QUERY_INFORMATION,FALSE,GetCurrentProcessId());
SYSTEM_INFO si;
ZeroMemory(&si,sizeof(SYSTEM_INFO));
GetSystemInfo(&si);
char* buf = new char[si.dwPageSize];
for (unsigned i = 0; i < 0x7fff0; i++)
{
void* baseOffs = (void*) (i * si.dwPageSize);
MEMORY_BASIC_INFORMATION mbi;
ZeroMemory(&mbi,sizeof(MEMORY_BASIC_INFORMATION));
if (VirtualQueryEx(hProc, baseOffs, &mbi, sizeof(MEMORY_BASIC_INFORMATION)) == 0)
{
MessageBox(NULL, TEXT("VirtualQueryEx failed"),TEXT(""),MB_OK);
}
if (mbi.State == MEM_COMMIT)
{
SIZE_T numByteWritten = 0;
if(ReadProcessMemory(hProc, baseOffs,buf,si.dwPageSize,&numByteWritten) == FALSE)
OutputDebugString(TEXT("bad\n")); //GetLastError()==ERROR_PARTIALLY_READ; numByteWritten == 0;
else
OutputDebugString(TEXT("good\n"));
}
}
delete[] buf;
}
Run Code Online (Sandbox Code Playgroud)
我厌倦了查看失败页面的MEMORY_BASIC_INFORMATION,但我没有发现任何奇怪的东西.失败页面的数量也因运行而异(平均约为5).什么阻止我阅读这些页面?我是否需要调整进程令牌中的某些权限?
你知道如何在delphi中读取另一个进程堆栈吗?
我使用ReadProcessMemory函数从地址空间读取数据.我尝试从所有具有MEM_PRIVATE类型的块读取.但是当该块具有PAGE_GUARD保护时,我得到错误(函数返回0),为什么?
谢谢大家.
windows operating-system readprocessmemory virtualquery virtual-address-space
我试图检索某个字符串的每次出现,例如“ExampleString”。我目前所拥有的将在进程内存中找到该字符串的第一次出现,但不会找到后续字符串。我尝试使用 avector来存储所有结果,但它仍然只找到一个结果。
下面是我用来获取内存位置向量的函数。同样,它适用于第一个位置。
std::vector<char*> GetAddressOfData(DWORD pid, const char *data, size_t len) {
HANDLE process = OpenProcess(PROCESS_VM_READ | PROCESS_QUERY_INFORMATION, FALSE, pid);
std::vector<char*> locations;
int cur = 0;
if(process){
SYSTEM_INFO si;
GetSystemInfo(&si);
MEMORY_BASIC_INFORMATION info;
std::vector<char> chunk;
char* p = 0;
while(p < si.lpMaximumApplicationAddress){
if(VirtualQueryEx(process, p, &info, sizeof(info)) == sizeof(info)){
p = (char*)info.BaseAddress;
chunk.resize(info.RegionSize);
SIZE_T bytesRead;
if(ReadProcessMemory(process, p, &chunk[0], info.RegionSize, &bytesRead)){
for(size_t i = 0; i < (bytesRead - len); ++i){
if(memcmp(data, &chunk[i], len) == 0) {
cur++;
locations.resize(cur);
locations[cur-1] = …Run Code Online (Sandbox Code Playgroud) 我找到了一个完美适用于静态地址的代码。
但是,我将如何更改此代码以使其适用于指针?我需要从这个指针获得价值:
0x1002CAA70 + 0x10 + 0x18 + 0x0 + 0x18。
它适用于 64 位应用程序。
public class Program
{
private const int PROCESS_WM_READ = 0x0010;
[DllImport("kernel32.dll")]
public static extern IntPtr OpenProcess(int dwDesiredAccess, bool bInheritHandle, int dwProcessId);
[DllImport("kernel32.dll")]
public static extern bool ReadProcessMemory(int hProcess,
Int64 lpBaseAddress, byte[] lpBuffer, int dwSize, ref int lpNumberOfBytesRead);
static void Main(string[] args)
{
Process process = Process.GetProcessesByName("Tutorial-x86_64")[0];
IntPtr processHandle = OpenProcess(PROCESS_WM_READ, false, process.Id);
int bytesRead = 0;
var buffer = new byte[4];
ReadProcessMemory((int)processHandle, 0x0011D598, buffer, buffer.Length, …Run Code Online (Sandbox Code Playgroud) ReadProcessMemory(hProc,(LPCVOID)(7845CDDC),&PHP,4,NULL);
Run Code Online (Sandbox Code Playgroud)
当我输入,我在Dev-C++ Win32中得到此错误:
C:\ Dev-Cpp\main.cpp对整数常量无效后缀"CDDC"
任何想法为什么?
winapi ×3
c# ×2
c++ ×2
base-address ×1
byte ×1
cheat-engine ×1
debugging ×1
delphi ×1
intptr ×1
kernel32 ×1
memory ×1
minesweeper ×1
pointers ×1
virtualquery ×1
windows ×1
windows-7 ×1