小弟最近在做一个加密有关的项目。涉及到密码之类的东西。一旦密码所在的内存处于虚拟内存,而此时机器又突然断电的话,那么密码将会存储在硬盘上。请问如何组织某块内存被系统交换到虚拟内存种?
解决方案 »
- mcisendstring
- 用OpenGL如何实现一本书在翻页的情景?????????????????拜托了,急啊,谢谢!
- 用vc 做一个人通讯录,选什么数据库?
- richedit 的BUG吗
- 请帮忙看看WSARecvFrom的错误
- 高分求助MPEG1的解码算法
- 用拉橡皮筋的方法在MemDC上划线,如果划的第二根线和前一条刚好重合时会发现屏幕上的线没有了,如何解决
- winsock 的问题
- Softspites大哥:然后我想把用LoadResource读出的文件的前n位存入一个string中,该怎末办?
- MFC 绘制动态的三维坐标系,通过坐标,将点显示出来?
- VC中用如何用openGL实现鼠标拖出一个矩形区域?
- 语音卡坏了
摘录了一些,看LZ有用没有。
VirtualLock
The VirtualLock function locks the specified region of the process's virtual address space into physical memory, ensuring that subsequent access to the region will not incur a page fault. BOOL VirtualLock(
LPVOID lpAddress, // first byte in range
SIZE_T dwSize // number of bytes in range
);
Parameters
lpAddress
[in] Pointer to the base address of the region of pages to be locked.
dwSize
[in] Specifies the size, in bytes, of the region to be locked. The region of affected pages includes all pages that contain one or more bytes in the range from the lpAddress parameter to (lpAddress+dwSize). This means that a 2-byte range straddling a page boundary causes both pages to be locked.
Return Values
If the function succeeds, the return value is nonzero.If the function fails, the return value is zero. To get extended error information, call GetLastError. Res
All pages in the specified region must be committed. Memory protected with PAGE_NOACCESS cannot be locked. Locking pages into memory may degrade the performance of the system by reducing the available RAM and forcing the system to swap out other critical pages to the paging file. Each version of Windows has a limit on the maximum number of pages a process can lock. This limit is intentionally small to avoid severe performance degradation. Applications that need to lock larger numbers of pages must first call the SetProcessWorkingSetSize function to increase their minimum and maximum working set sizes. The maximum number of pages that a process can lock is equal to the number of pages in its minimum working set minus a small overhead.Pages that a process has locked remain in physical memory until the process unlocks them or terminates.To unlock a region of locked pages, use the VirtualUnlock function. Locked pages are automatically unlocked when the process terminates. This function is not like the GlobalLock or LocalLock function in that it does not increment a lock count and translate a handle into a pointer. There is no lock count for virtual pages, so multiple calls to the VirtualUnlock function are never required to unlock a region of pages. Windows 95/98/Me: The VirtualLock function is implemented as a stub that has no effect and always returns a nonzero value.