window 核心编程 14.4 查看虚拟地址 比较全的用户自定义函数

本文详细介绍了在Windows环境中如何查看和理解虚拟地址。通过深入探讨用户自定义函数,揭示了虚拟地址在进程内存管理中的作用,为学习者提供了一个全面的理解窗口。
摘要由CSDN通过智能技术生成
#include <windows.h>
#include <stdio.h>
#include<iostream>
#include <string.h>
#include "strsafe.h"
#include <WinInet.h>
#include<tchar.h>
#include<StrSafe.h>
using namespace std;

typedef struct {
    //region information
    PVOID pvRgnBaseAddress;
    DWORD dwRgnProtection;
    SIZE_T RgnSize;
    DWORD dwRgnStorage;
    DWORD dwRgnBlocks;
    DWORD dwRgnGuardBlks;//if > 0 ,region contains thread stack
    BOOL bRgnIsAStack;//True if region contains thread stack

    //BLOCK Information
    PVOID pvBlkBaseAddress;
    DWORD dwBlkProtection;
    SIZE_T BlkSize;
    DWORD dwBlkStorage;
}VMQUERY, *PVMQUERY;
typedef struct {
    SIZE_T RgnSize;
    DWORD dwRgnStorage;
    DWORD dwRgnBlock;
    DWORD dwRgnGuardBlks;
    BOOL bRgnIsAStack;
}VMQUERY_HELP;
static DWORD gs_dwAllocGran = 0;
static BOOL VMQueryHelp(HANDLE hProcess, LPCVOID pvAddress, VMQUERY_HELP *pVMQHelp)
{
    ZeroMemory(pVMQHelp, sizeof(*pVMQHelp));
    //get address of region containing passed memory address
    MEMORY_BASIC_INFORMATION mbi;
    BOOL bOk = (VirtualQueryEx(hProcess, pvAddress, &mbi, sizeof(mbi)) == sizeof(mbi));
    if (!bOk)
    {
        return (bOk);
    }
    //walk starting at the region's base address(which never changes)
    PV
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值