Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/windows/16.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/image-processing/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
.net C#中的GetWriteWatch()?_.net_Windows_Winapi_Memory Management_Heap - Fatal编程技术网

.net C#中的GetWriteWatch()?

.net C#中的GetWriteWatch()?,.net,windows,winapi,memory-management,heap,.net,Windows,Winapi,Memory Management,Heap,我正试图用一个计时器来监控一个进程的内存变化。因此,我看到GetWriteWatchAPI为我提供了更改过的页面。但是我在.NET中找不到一个例子。是否有人可以帮助您始终可以通过调用,该调用允许您调用COM组件以及从DLL导出的函数,例如 包含在C#中预定义的Windows API p/Invoke签名列表,因此您无需自己解决。对于GetWriteWatch函数: [DllImport("kernel32.dll")] static extern uint GetWriteWatch(uint

我正试图用一个计时器来监控一个进程的内存变化。因此,我看到
GetWriteWatch
API为我提供了更改过的页面。但是我在.NET中找不到一个例子。是否有人可以帮助

您始终可以通过调用,该调用允许您调用COM组件以及从DLL导出的函数,例如

包含在C#中预定义的Windows API p/Invoke签名列表,因此您无需自己解决。对于
GetWriteWatch
函数:

[DllImport("kernel32.dll")]
static extern uint GetWriteWatch(uint dwFlags, IntPtr lpBaseAddress,
   UIntPtr dwRegionSize, out IntPtr lpAddresses, ref UIntPtr lpdwCount,
   out uint lpdwGranularity);

我看到了这个,但是我被lpaddress指针绊住了。因为它需要数组而不仅仅是IntPtr。@blez:我现在正在研究它,因为没有明确的指标表明谁负责分配/解除分配它。正如lpAddress的文档所示,应用程序负责通过
VirtualAlloc
分配它,并通过
VirtualFree
@Raymond释放它:这只是针对
lpBaseAddress
参数,它特别声明该参数的“此地址”;对于
lpAddress
参数,没有提到
VirtualAlloc
VirtualFree
。很抱歉,误读了
lpAddress
只是一个输出缓冲区。调用者提供内存,函数用数据填充内存。在这种情况下,需要传递一个intptr数组。pinvpke让我们走捷径,假设你只需要一个地址。