简体   繁体   English

尝试读取过程内存时出现错误299

[英]Error 299 when trying to read process memory

i'm having some problem with reading process's memory, all i get is error 299, sometimes error 5/6, i'm new to memory reading / writing and can use any help. 我在读取进程的内存时遇到问题,我得到的只是错误299,有时错误5/6,我是内存读取/写入的新手,可以使用任何帮助。

This is what i have so far : 这是我到目前为止所拥有的:

    private void ScanMemory()
    {
        uint PID;
        GetWindowThreadProcessId(GetWindowHandle(), out PID);
        label3.Text = "" + (int)PID;
        int valueToSearch = 4;
        List<int> matchAddresses = new List<int>();
        long MaxAddress = 0x7fffffff;
        long address = 0;
        do
        {
            MEMORY_BASIC_INFORMATION32 m;
            IntPtr Handle = OpenProcess((int)ProcessAccessFlags.All, false, (int)PID);
            uint result = VirtualQueryEx((int)Handle, (int)address, out m, (int)Marshal.SizeOf(typeof(MEMORY_BASIC_INFORMATION32)));
            if (address == (long)m.BaseAddress + (long)m.RegionSize)
                break;
            address = (long)m.BaseAddress + (long)m.RegionSize;
            SearchIntSizeValue(Handle, (int)m.BaseAddress, (int)m.RegionSize, valueToSearch, matchAddresses);
        } while (address <= MaxAddress);

        foreach (int res in matchAddresses)
        {
            listBox1.Items.Add(res);
        }
    }
    public void SearchIntSizeValue(IntPtr hProcess, int startAddress, int endAddress, int valueToSearch, List<int> addresses)
    {
        byte[] buffer = new byte[4];
        IntPtr bytesread;
        while (startAddress < endAddress)
        {
            ReadProcessMemory(hProcess, (IntPtr)startAddress, buffer, 4, out bytesread);
            int res = BitConverter.ToInt32(buffer, 0);
            if (res == valueToSearch)
            {
                addresses.Add(startAddress);
            }
            else
            {
                int le;
                if ((le = Marshal.GetLastWin32Error()) != 0)
                {

                }
            }
            startAddress += 4;
        }
    }

[StructLayout(LayoutKind.Sequential)]
 struct MEMORY_BASIC_INFORMATION32
{
    public uint BaseAddress;
    public uint AllocationBase;
    public int AllocationProtect;
    public uint RegionSize;
    public int State;
    public int Protect;
    public int lType;
}

i'm reading size of int at the moment, not really working :|, from reading in google, i saw there is this thing with privilege , though, i run vs2010 with Admin rights on windows 7, i hope it's enough information for you to spot my problme, thanks in advance! 我目前正在读取int的大小,但实际上不能正常工作:|,从google中读取内容,我看到有特权的东西,但是,我在Windows 7上以管理员权限运行vs2010,希望对您有足够的信息预先发现我的问题,谢谢!

Me helped solution on www.codeproject.com : Solving-Problems-of-Monitoring-Standard-Output . 我在www.codeproject.com上提供了帮助解决方案: 监控问题-标准输出-解决问题

Solution protect application from additional deadlocks that Microsoft does not mention in their documentation. 解决方案保护应用程序免受Microsoft在其文档中未提及的其他死锁的影响。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 C# ReadProcessMemory 错误 299 - C# ReadProcessMemory error 299 我正在尝试读取进程的内存,但是由于某种原因,我没有获得正确的进程内存大小-怎么了? - I'm trying to read memory of a process but for some reason I'm not getting the right size of the process memory - what's wrong? 尝试从数组中读取时出错 - error when trying to read from an array Xamarin - 尝试读取JSon时出错 - Xamarin - Error when trying to read JSon 读取进程内存不工作给出错误尝试读取或写入受保护的内存 - reading a process memory not working giving error Attempted to read or write protected memory 尝试使用记事本++和csscript调试外部进程时发生错误 - error when trying to debug an external process using notepad++ and csscript HTTP错误502.5 - 尝试运行项目时出现进程失败 - HTTP Error 502.5 - Process Failure when trying to run my project 将结构封送到指针时“尝试读取写保护的内存...”错误 - “Attempted to read of write protected memory…” error when marshaling a structure to a pointer 从另一个进程读取字符串 memory 地址 - Read string from another process memory address 从C#中的dll进程读取内存 - Read memory from process at dll in C#
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM