How to get user mode total virtual memory?

时间:2018-03-09 19:23:17

标签: c# virtual-address-space bcdedit bcdstore

Asking for Win 7/Win 10 (BIOS/EFI). Ive been researching this and havent been able to find a way, heres the story:

In a program I am using bcdedit /set IncreaseUserVa 3872 to set the user-mode virtual address space to 3872MB, then I restart.

For a unit test I need to check that the change went through using C#. After much research I've tried the following methods:

  • This similar solution here. I am getting an exception: System.AccessViolationException HResult=0x80004003 Message=Attempted to read or write protected memory. This is often an indication that other memory is corrupt. I am running VS as admin in the admin account.
  • Using Process.GetCurrentProcess().X(theres a few memory properties) but those arent for the whole system.
  • The BCD reg file in [systemdrive]:/boot contains this data. In regedit HKLM/BCD000000 i cant find anywhere on the web for which reg key to look at
  • Importing Microsoft.VisualBasic and use the ComputerInfo class, this one was promising but im setting to 3872MB (3.78GB) and its coming back as ~3GB

Can anyone help? either find the right reg key in BCD000000 or another way?

1 个答案:

答案 0 :(得分:0)

想出来。

ComputerInfo myCompInfo = new ComputerInfo(); myCompInfo.TotalVirtualMemory();

BCDEdit不允许将虚拟地址空间设置为超过3GB。