首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 开发语言 > VC/MFC >

GetWriteWatch如何用?希望详细点

2012-02-29 
GetWriteWatch怎么用?希望详细点VirtualAlloc配合MEM_WRITE_WATCH标志申请完内存怎么监视和用GetWriteWatc

GetWriteWatch怎么用?希望详细点
VirtualAlloc配合MEM_WRITE_WATCH标志申请完内存怎么监视和用GetWriteWatch函数得到信息

[解决办法]
GetWriteWatch函数只能用在64位的系统上,32位的不支持啊
[解决办法]
MSDN:

GetWriteWatch

The GetWriteWatch function retrieves the addresses of the pages that are written to in a region of virtual memory.

64-bit Windows on Itanium-based systems: Due to the difference in page sizes, GetWriteWatch is not supported for 32-bit applications.

UINT GetWriteWatch(
DWORD dwFlags,
PVOID lpBaseAddress,
SIZE_T dwRegionSize,
PVOID* lpAddresses,
PULONG_PTR lpdwCount,
PULONG lpdwGranularity
);

Parameters
dwFlags
[in] Indicates whether the function resets the write-tracking state.
To reset the write-tracking state, set this parameter to WRITE_WATCH_FLAG_RESET. If this parameter is 0 (zero), GetWriteWatch does not reset the write-tracking state. For more information, see the Remarks section of this topic.

lpBaseAddress
[in] The base address of the memory region for which to retrieve write-tracking information.
This address must be in a memory region that is allocated by the VirtualAlloc function using MEM_WRITE_WATCH.

dwRegionSize
[in] The size of the memory region for which to retrieve write-tracking information, in bytes.
lpAddresses
[out] A pointer to a buffer that receives an array of page addresses in the memory region.
The addresses indicate the pages that have been written to since the region has been allocated or the write-tracking state has been reset.

lpdwCount
[in, out] On input, this variable indicates the size of the lpAddresses array, in array elements.
On output, the variable receives the number of page addresses that are returned in the array.

lpdwGranularity
[out] A pointer to a variable that receives the page size, in bytes.
Return Values
If the function succeeds, the return value is 0 (zero).

If the function fails, the return value is a nonzero value.

Remarks
When you call the VirtualAlloc function to reserve or commit memory, you can specify MEM_WRITE_WATCH. This value causes the system to keep track of the pages that are written to in the committed memory region. You can call the GetWriteWatch function to retrieve the addresses of the pages that have been written to since the region has been allocated or the write-tracking state has been reset.

To reset the write-tracking state, set the WRITE_WATCH_FLAG_RESET value in the dwFlags parameter. Alternatively, you can call the ResetWriteWatch function to reset the write-tracking state. However, if you use ResetWriteWatch, you must ensure that no threads write to the region during the interval between the GetWriteWatch and ResetWriteWatch calls. Otherwise, there may be written pages that you do not detect.

The GetWriteWatch function can be useful to profilers, debugging tools, or garbage collectors.

热点排行