Windows 核心編程之14 探索虛擬記憶體

來源:互聯網
上載者:User
探索虛擬記憶體 1得到系統資訊 GetsystemInfo(LPSYSTEM_INFO os);
typedef struct _SYSTEM_INFO {
    union {
        DWORD dwOemId;          // Obsolete field...do not use
        struct {
            WORD wProcessorArchitecture;
            WORD wReserved;
        };
    };
    DWORD dwPageSize;
    LPVOID lpMinimumApplicationAddress;
    LPVOID lpMaximumApplicationAddress;
    DWORD_PTR dwActiveProcessorMask;
    DWORD dwNumberOfProcessors;
    DWORD dwProcessorType;
    DWORD dwAllocationGranularity;
    WORD wProcessorLevel;
    WORD wProcessorRevision;
} SYSTEM_INFO, *LPSYSTEM_INFO;

2 虛擬記憶體狀態 VOID
WINAPI
GlobalMemoryStatus(
    __out LPMEMORYSTATUS lpBuffer
    );

typedef struct _MEMORYSTATUS {
    DWORD dwLength; // 在使用前必須用結構體大小來初始化
    DWORD dwMemoryLoad; 記憶體使用量百分率
    SIZE_T dwTotalPhys; 實體記憶體總量
    SIZE_T dwAvailPhys; 還剩餘實體記憶體總量
    SIZE_T dwTotalPageFile; 分頁檔總量,包括虛擬記憶體和實體記憶體
    SIZE_T dwAvailPageFile; 頁面剩餘量
    SIZE_T dwTotalVirtual; 虛擬記憶體總量
    SIZE_T dwAvailVirtual; 剩餘虛擬記憶體量
} MEMORYSTATUS, *LPMEMORYSTATUS;

GetProcessMemoryInfo得到進程的資訊   PROCESS_MEMORY_COUNTERS_EX pmc = { sizeof(PROCESS_MEMORY_COUNTERS_EX) };
   GetProcessMemoryInfo(GetCurrentProcess(), (PPROCESS_MEMORY_COUNTERS)&pmc, sizeof(pmc));

struct _PROCESS_MEMORY_COUNTERS_EX {
    DWORD cb;  必須初始化為結構體大小
    DWORD PageFaultCount; 分頁錯誤
    SIZE_T PeakWorkingSetSize; 高峰工作集
    SIZE_T WorkingSetSize; 工作集
    SIZE_T QuotaPeakPagedPoolUsage; 高峰頁面池
    SIZE_T QuotaPagedPoolUsage; 頁面緩衝池
    SIZE_T QuotaPeakNonPagedPoolUsage;     高峰非頁面緩衝池
    SIZE_T QuotaNonPagedPoolUsage; 非頁面緩衝池
    SIZE_T PagefileUsage; 分頁檔大小
    SIZE_T PeakPagefileUsage; 高峰分頁檔大小
    SIZE_T PrivateUsage; 私人資料
} PROCESS_MEMORY_COUNTERS_EX;確定地址空間中的狀態

VirtualQuery

The VirtualQuery function provides information about a range of pages in the virtual address space of the calling process.這個函數為調用進程提供指定地區的虛擬記憶體資訊


相關文章

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.