• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

C# MEMORY_BASIC_INFORMATION类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C#中MEMORY_BASIC_INFORMATION的典型用法代码示例。如果您正苦于以下问题:C# MEMORY_BASIC_INFORMATION类的具体用法?C# MEMORY_BASIC_INFORMATION怎么用?C# MEMORY_BASIC_INFORMATION使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



MEMORY_BASIC_INFORMATION类属于命名空间,在下文中一共展示了MEMORY_BASIC_INFORMATION类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。

示例1: VirtualQueryEx

 private static MEMORY_BASIC_INFORMATION VirtualQueryEx(Process proc, long address)
 {
     var info = new MEMORY_BASIC_INFORMATION();
     var ptr = new IntPtr(address);
     VirtualQueryEx(proc.Handle, ptr, out info, Marshal.SizeOf(info));
     return info;
 }
开发者ID:pudwinkie,项目名称:neith,代码行数:7,代码来源:Memory.cs


示例2: GainMemoryAccess

        public static void GainMemoryAccess(IntPtr address, ulong len)
        {
            SYSTEM_INFO si = new SYSTEM_INFO();
            GetSystemInfo(out si);
            MEMORY_BASIC_INFORMATION mbi;
            ulong currentAddress = RoundUpToPageBoundary((ulong)address, si.pageSize);
            ulong endAddress = currentAddress + len;
            uint ret;
            uint oldProtect = 0;

            while (currentAddress < endAddress)
            {
                mbi = new MEMORY_BASIC_INFORMATION();
                ret = (uint)VirtualQuery((IntPtr)currentAddress, out mbi, (IntPtr)Marshal.SizeOf(mbi));
                if (ret != 0)
                {
                    if (mbi.state == MEM_COMMIT)
                    {
                        VirtualProtect(mbi.baseAddress, mbi.regionSize, PAGE_EXECUTE_READWRITE, out oldProtect);
                    }
                    if ((ulong)mbi.regionSize > 0) currentAddress += (ulong)mbi.regionSize;
                    else currentAddress += si.pageSize;
                }
                else currentAddress += si.pageSize;
            }
        }
开发者ID:nazariitashak,项目名称:UOMachine,代码行数:26,代码来源:GainMemoryAccess.cs


示例3: readNextMemoryRegion

        public int readNextMemoryRegion(byte[] buffer, uint maxSize)
        {
            MEMORY_BASIC_INFORMATION mbi = new MEMORY_BASIC_INFORMATION();
            int amtRead;
            while (true)
            {
                if (nextAddr_ <= pSize_ + baseAddr_)
                {
                    if (0 == VirtualQueryEx(pHandle_, new IntPtr(nextAddr_), out mbi, (uint)Marshal.SizeOf(mbi)))
                    {
                        Console.WriteLine("VirtualQueryEx failure");
                    }
                    int rgnSize = mbi.RegionSize.ToInt32();
                    if (rgnSize > maxSize)
                    {
                        nextAddr_ += rgnSize;
                        continue;
                    }

                    ReadProcessMemory(pHandle_, new IntPtr(nextAddr_), buffer, rgnSize, out amtRead);
                    nextAddr_ += rgnSize;

                    if (0 != amtRead)
                    {
                        return amtRead;
                    }
                }
                else
                {
                    return 0;
                }
            }
        }
开发者ID:gibybo,项目名称:S2GS-Extractor,代码行数:33,代码来源:MemoryReader.cs


示例4: GetManagedHeap

        /// <summary>
        /// Gets managed heap address
        /// </summary>
        private static unsafe void GetManagedHeap(IntPtr offset, out IntPtr heapsOffset, out IntPtr lastHeapByte)
        {
            var somePtr = EntityPtr.ToPointer("sample");
            var memoryBasicInformation = new MEMORY_BASIC_INFORMATION();

            heapsOffset = IntPtr.Zero;
            lastHeapByte = IntPtr.Zero;
            unsafe
            {
                while (VirtualQuery(offset, ref memoryBasicInformation, (IntPtr)Marshal.SizeOf(memoryBasicInformation)) !=
                       IntPtr.Zero)
                {
                    var isManagedHeap = (long)memoryBasicInformation.BaseAddress < (long)somePtr &&
                                        (long)somePtr <
                                        ((long)memoryBasicInformation.BaseAddress + (long)memoryBasicInformation.RegionSize);

                    if (isManagedHeap)
                    {
                        heapsOffset = offset;
                        lastHeapByte = (IntPtr)((long)offset + (long)memoryBasicInformation.RegionSize);
                    }

                    offset = (IntPtr)((long)offset + (long)memoryBasicInformation.RegionSize);
                }
            }
        }
开发者ID:TBXin,项目名称:dotnetex,代码行数:29,代码来源:Program.cs


示例5: VirtualQueryEx

 public static extern UIntPtr VirtualQueryEx(
     IntPtr hProcess,                    // Дескриптора процесса
     IntPtr pvAddress,                   // адрес виртуальной памяти
     out MEMORY_BASIC_INFORMATION pmbi,  // это адрес структуры MEMORY_BASIC_INFORMATION,
     // которую надо создать перед вызовом функции
     int dwLength                        // задает размер структуры MEMORY_BASIC_INFORMATION
     );
开发者ID:TERAB1T,项目名称:rueso-helper,代码行数:7,代码来源:Program.cs


示例6: Main

        // finally...
        public static void Main()
        {
            // getting minimum & maximum address

            SYSTEM_INFO sys_info = new SYSTEM_INFO();
            GetSystemInfo(out sys_info);

            IntPtr proc_min_address = sys_info.minimumApplicationAddress;
            IntPtr proc_max_address = sys_info.maximumApplicationAddress;

            // saving the values as long ints so I won't have to do a lot of casts later
            long proc_min_address_l = (long)proc_min_address;
            long proc_max_address_l = (long)proc_max_address;

            // notepad better be runnin'
            Process process = Process.GetProcessesByName("tibia")[0];

            // opening the process with desired access level
            IntPtr processHandle = OpenProcess(PROCESS_QUERY_INFORMATION | PROCESS_WM_READ, false, process.Id);

            StreamWriter sw = new StreamWriter("dump.txt");

            // this will store any information we get from VirtualQueryEx()
            MEMORY_BASIC_INFORMATION mem_basic_info = new MEMORY_BASIC_INFORMATION();

            int bytesRead = 0;  // number of bytes read with ReadProcessMemory

            while (proc_min_address_l < proc_max_address_l)
            {
                // 28 = sizeof(MEMORY_BASIC_INFORMATION)
                VirtualQueryEx(processHandle, proc_min_address, out mem_basic_info, 28);

                // if this memory chunk is accessible
                if (mem_basic_info.Protect == PAGE_READWRITE && mem_basic_info.State == MEM_COMMIT)
                {
                    byte[] buffer = new byte[mem_basic_info.RegionSize];

                    // read everything in the buffer above
                    ReadProcessMemory((int)processHandle, mem_basic_info.BaseAddress, buffer, mem_basic_info.RegionSize, ref bytesRead);

                    // then output this in the file
                    for (int i = 0; i < mem_basic_info.RegionSize; i++)
                        sw.WriteLine("0x{0} : {1}", (mem_basic_info.BaseAddress + i).ToString("X"), (char)buffer[i]);
                }

                // move to the next memory chunk
                proc_min_address_l += mem_basic_info.RegionSize;
                proc_min_address = new IntPtr(proc_min_address_l);
            }

            sw.Flush();
            sw.Close();

            Console.ReadLine();
        }
开发者ID:Nimelo,项目名称:AdvencedMemory,代码行数:56,代码来源:Program.cs


示例7: MemInfo

 protected void MemInfo(IntPtr pHandle)
 {
     IntPtr Addy = new IntPtr();
     while (true)
     {
         MEMORY_BASIC_INFORMATION MemInfo = new MEMORY_BASIC_INFORMATION();
         int MemDump = VirtualQueryEx(pHandle, Addy, out  MemInfo, Marshal.SizeOf(MemInfo));
         if (MemDump == 0) break;
         if ((MemInfo.State & 0x1000) != 0 && (MemInfo.Protect & 0x100) == 0)
             MemoryRegion.Add(MemInfo);
         Addy = new IntPtr(MemInfo.BaseAddress.ToInt32() + (int)MemInfo.RegionSize);
     }
 }
开发者ID:Nummer,项目名称:CheatsLib,代码行数:13,代码来源:AOBScan.cs


示例8: scanJava

        public static bool scanJava(Process p)
        {
            p.Refresh();
            try
            {
                if (p.HasExited)
                {
                    return false;
                }
            }
            catch (Exception)
            {
                return false;
            }
            //Console.WriteLine("Scanning " + p.ProcessName);
            IntPtr Addy = new IntPtr();
            List<MEMORY_BASIC_INFORMATION> MemReg = new List<MEMORY_BASIC_INFORMATION>();
            while (true)
            {
                MEMORY_BASIC_INFORMATION MemInfo = new MEMORY_BASIC_INFORMATION();
                int MemDump = VirtualQueryEx(p.Handle, Addy, out  MemInfo, Marshal.SizeOf(MemInfo));
                if (MemDump == 0) break;
                if (0 != (MemInfo.State & MEM_COMMIT) && 0 != (MemInfo.Protect & WRITABLE) && 0 == (MemInfo.Protect & PAGE_GUARD))
                {
                    MemReg.Add(MemInfo);
                }
                Addy = new IntPtr(MemInfo.BaseAddress.ToInt64() + MemInfo.RegionSize.ToInt64());
            }

            for (int i = 0; i < MemReg.Count; i++)
            {
                byte[] buff = new byte[MemReg[i].RegionSize.ToInt32()];
                ReadProcessMemory(p.Handle, MemReg[i].BaseAddress, buff, MemReg[i].RegionSize.ToInt32(), IntPtr.Zero);

                long Result = IndexOf(buff, javameter);
                if (Result > 0)
                {
                    buff = null;
                    GC.Collect();
                    return true;
                }
                buff = null;
            }
            GC.Collect();
            return false;
        }
开发者ID:rvazarkar,项目名称:antipwny,代码行数:46,代码来源:Utilities.cs


示例9: HasSufficientStack

        public static unsafe bool HasSufficientStack(long bytes)
        {
            var stackInfo = new MEMORY_BASIC_INFORMATION();

            // We subtract one page for our request. VirtualQuery rounds UP to the next page.
            // Unfortunately, the stack grows down. If we're on the first page (last page in the
            // VirtualAlloc), we'll be moved to the next page, which is off the stack! Note this
            // doesn't work right for IA64 due to bigger pages.
            IntPtr currentAddr = new IntPtr((uint)&stackInfo - 4096);

            // Query for the current stack allocation information.
            VirtualQuery(currentAddr, ref stackInfo, sizeof(MEMORY_BASIC_INFORMATION));

            // If the current address minus the base (remember: the stack grows downward in the
            // address space) is greater than the number of bytes requested plus the reserved
            // space at the end, the request has succeeded.
            return ((uint)currentAddr.ToInt64() - stackInfo.AllocationBase) >
                   (bytes + STACK_RESERVED_SPACE);
        }
开发者ID:mikkoj,项目名称:LunchCrawler,代码行数:19,代码来源:StackChecker.cs


示例10: VirtualQueryEx

 public static extern IntPtr VirtualQueryEx(IntPtr hProcess, IntPtr lpAddress, ref MEMORY_BASIC_INFORMATION lpBuffer, IntPtr dwLength);
开发者ID:HenrikFrystykNielsen,项目名称:kudu,代码行数:1,代码来源:ProcessExtensions.cs


示例11: VirtualQuery

		public MEMORY_BASIC_INFORMATION VirtualQuery(Int32 address)
		{
			var info = new MEMORY_BASIC_INFORMATION();
			var ret = VirtualQueryEx(Handle, address, ref info, Marshal.SizeOf(typeof(MEMORY_BASIC_INFORMATION)));
			if (ret == 0)
				throw new Win32Exception();
			return info;
		}
开发者ID:wzpyh,项目名称:Client,代码行数:8,代码来源:ProcessMemory.cs


示例12: VirtualQuery

        public bool VirtualQuery(ulong addr, out VirtualQueryData vq)
        {
            vq = new VirtualQueryData();

            MEMORY_BASIC_INFORMATION mem = new MEMORY_BASIC_INFORMATION();
            IntPtr ptr = new IntPtr((long)addr);

            int res = VirtualQueryEx(_process, ptr, ref mem, new IntPtr(Marshal.SizeOf(mem)));
            if (res == 0)
                return false;

            vq.BaseAddress = mem.BaseAddress;
            vq.Size = mem.Size;
            return true;
        }
开发者ID:tomasr,项目名称:clrmd,代码行数:15,代码来源:livedatatarget.cs


示例13: MapView

        /// <summary>
        /// Maps the view.
        /// </summary>
        private void MapView()
        {
            IntPtr ptr = MapViewOfFile(_sharedMemoryHandle.GetHandle(),
                                    FileMapAccess.FileMapRead | FileMapAccess.FileMapWrite,
                                    (uint)0,
                                    0,
                                    Size);
            if (ptr == IntPtr.Zero)
            {
                throw new InvalidOperationException("Invalid Handle. Filed to map view");
            }
            if (Size == 0)
            {
                MEMORY_BASIC_INFORMATION info = new MEMORY_BASIC_INFORMATION();

                VirtualQuery(ref ptr, ref info, (int)System.Runtime.InteropServices.Marshal.SizeOf(info));
                Size = info.RegionSize;
            }

            _stream = new SharedMemoryStream(ptr, Size);
        }
开发者ID:UAV,项目名称:SharedMemory,代码行数:24,代码来源:SharedMemory.cs


示例14: VirtualQueryEx

		static extern Int32 VirtualQueryEx(IntPtr handle, Int32 address, ref MEMORY_BASIC_INFORMATION buffer, Int32 sizeOfBuffer);
开发者ID:wzpyh,项目名称:Client,代码行数:1,代码来源:ProcessMemory.cs


示例15: MemoryRegions

        public IEnumerable<MEMORY_BASIC_INFORMATION> MemoryRegions()
        {
            // getting minimum & maximum address

            SYSTEM_INFO sys_info = new SYSTEM_INFO();
            GetSystemInfo(out sys_info);

            IntPtr proc_min_address = sys_info.minimumApplicationAddress;
            IntPtr proc_max_address = sys_info.maximumApplicationAddress;

            // saving the values as long ints so I won't have to do a lot of casts later
            long proc_min_address_l = (long)proc_min_address;
            long proc_max_address_l = (long)proc_max_address;

            MEMORY_BASIC_INFORMATION mem_basic_info = new MEMORY_BASIC_INFORMATION();

            long current = proc_min_address_l;
            while (current < proc_max_address_l)
            {
                var informationSize = VirtualQueryEx(processHandle, (IntPtr)current, out mem_basic_info, (uint)Marshal.SizeOf(mem_basic_info));
                if (informationSize == 0)
                    throw new Win32Exception();

                yield return mem_basic_info;

                // move to the next memory chunk
                current += mem_basic_info.RegionSize;
            }
        }
开发者ID:gothos-folly,项目名称:TeraDataTools,代码行数:29,代码来源:MemoryScanner.cs


示例16: VirtualQuery

 internal static extern int VirtualQuery(ref IntPtr lpAddress,
     ref MEMORY_BASIC_INFORMATION lpBuffer,
     int dwLength
     );
开发者ID:UAV,项目名称:SharedMemory,代码行数:4,代码来源:SharedMemory.cs


示例17: VirtualQuery

 public static extern IntPtr VirtualQuery(IntPtr lpAddress, out MEMORY_BASIC_INFORMATION lpBuffer, IntPtr dwLength);
开发者ID:FreeReign,项目名称:UOMachine,代码行数:1,代码来源:NativeMethods.cs


示例18: ReadMemory

        private ReadMemoryResults ReadMemory()
        {
            ReadMemoryResults results = null;
            SYSTEM_INFO sys_info = new SYSTEM_INFO();
            GetSystemInfo(out sys_info);

            IntPtr proc_min_address = sys_info.minimumApplicationAddress;
            IntPtr proc_max_address = sys_info.maximumApplicationAddress;

            long proc_min_address_l = (long)proc_min_address;
            long proc_max_address_l = (long)proc_max_address;
            Process process = GetTibiaProcess();
            if (process == null) {
                // Tibia process could not be found, wait for a bit and return
                Thread.Sleep(250);
                return null;
            }
            flashClient = TibiaClientName.ToLower().Contains("flash") || TibiaClientName.ToLower().Contains("chrome");
            IntPtr processHandle = OpenProcess(PROCESS_QUERY_INFORMATION | PROCESS_WM_READ, false, process.Id);
            MEMORY_BASIC_INFORMATION mem_basic_info = new MEMORY_BASIC_INFORMATION();
            int bytesRead = 0;  // number of bytes read with ReadProcessMemory
            int scanSpeed = SettingsManager.getSettingInt("ScanSpeed");
            try {
                results = new ReadMemoryResults();
                while (proc_min_address_l < proc_max_address_l) {
                    proc_min_address = new IntPtr(proc_min_address_l);
                    // 28 = sizeof(MEMORY_BASIC_INFORMATION)
                    VirtualQueryEx(processHandle, proc_min_address, out mem_basic_info, 28);

                    // check if this memory chunk is accessible
                    if (mem_basic_info.Protect == PAGE_READWRITE && mem_basic_info.State == MEM_COMMIT) {
                        if (!memorySegments.Contains(mem_basic_info.BaseAddress)) {
                            byte[] buffer = new byte[mem_basic_info.RegionSize];

                            // read everything in the buffer above
                            ReadProcessMemory((int)processHandle, mem_basic_info.BaseAddress, buffer, mem_basic_info.RegionSize, ref bytesRead);
                            // scan the memory for strings that start with timestamps and end with the null terminator ('\0')
                            List<string> strings;
                            if (!flashClient) {
                                strings = FindTimestamps(buffer);
                            } else {
                                strings = FindTimestampsFlash(buffer);
                            }
                            if (strings.Count > 0) {
                                // if any timestamp strings were found, scan the chunk for any messages
                                SearchChunk(strings, results);
                            } else {
                                memorySegments.Add(mem_basic_info.BaseAddress);
                            }
                            // performance throttling sleep after every scan (depending on scanSpeed setting)
                            if (scanSpeed > 0) {
                                Thread.Sleep(scanSpeed);
                            }
                        }
                    }

                    // move to the next memory chunk
                    proc_min_address_l += mem_basic_info.RegionSize;
                }
            } catch {
                return null;
            }
            if (memorySegments.Count > 10) {
                memorySegments.RemoveRange(0, 10);
            } else {
                memorySegments.Clear();
            }
            process.Dispose();
            FinalCleanup(results);
            return results;
        }
开发者ID:DavidNyqvist,项目名称:Tibialyzer,代码行数:71,代码来源:MainFormReadMemory.cs


示例19: VirtualQuery

 internal static extern UIntPtr VirtualQuery(UIntPtr lpAddress, ref MEMORY_BASIC_INFORMATION lpBuffer, UIntPtr dwLength);
开发者ID:nickchal,项目名称:pash,代码行数:1,代码来源:Win32Native.cs


示例20: VirtualQuery

 internal extern static UIntPtr VirtualQuery(SafeMemoryMappedViewHandle lpAddress, ref MEMORY_BASIC_INFORMATION lpBuffer, UIntPtr dwLength);
开发者ID:noahfalk,项目名称:corefx,代码行数:1,代码来源:Interop.VirtualQuery.cs



注:本文中的MEMORY_BASIC_INFORMATION类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C# MIXERCONTROL类代码示例发布时间:2022-05-24
下一篇:
C# MDataSet类代码示例发布时间:2022-05-24
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap