问题描述
我正在尝试检测应用程序何时写入内存.因此,我将VirtualAlloc与MEM_COMMIT一起使用. MEM_RESERVE | MEM_WRITE_WATCH标志,ResetWriteWatch和GetWriteWatch.对于x86应用程序,它的效果非常好.但是我对x64应用有问题:成功执行VirtualAlloc和ResetWriteWatch时,GetWriteWatch返回错误. GetLastError返回对内存位置的无效访问"代码.有谁知道为什么会发生吗?
我在DX9上安装了挂钩.因此,在Idirect3DIndexBuffer :: Lock和IDirect3DVertexBuffer :: Lock上,我由VirtualAlloc使用MEM_COMMIT分配了新缓冲区| MEM_RESERVE | MEM_WRITE_WATCH标志,通过ResetWriteWatch重置内存.然后淘汰它,而不是由Lock返回的那个.在解锁(在实际发生之前)上,我想获取由GetWriteWatch执行写入操作的页面数组.结果:对于x86应用程序来说是好的,对于x64应用程序来说是失败的.我想知道在x64平台上使用该API是否有任何限制?
总结一下:X64 paltform->
I''m trying to detect when application writes to the memory. For that reason I''m using VirtualAlloc with MEM_COMMIT | MEM_RESERVE | MEM_WRITE_WATCH flags, ResetWriteWatch and GetWriteWatch. For x86 applications this works excellent. But I have problem with x64 apps: While VirtualAlloc and ResetWriteWatch are successfully executed, GetWriteWatch returns error. GetLastError returns "Invalid access to memory location" code. Does anyone know why it happens?
I installed hooks on DX9. So on Idirect3DIndexBuffer::Lock and IDirect3DVertexBuffer::Lock I allocate new buffer by VirtualAlloc with MEM_COMMIT | MEM_RESERVE | MEM_WRITE_WATCH flags, reset memory by ResetWriteWatch. And outout it instead the one which is returned by Lock. On Unlock (before it actually happens) I want to get the array of pages where write was performed by GetWriteWatch. Result: ok for x86 application and fail for x64. I wonder if there any limitations for using that API on x64 platform?
So to summarize: X64 paltform -> on x86 application GetWriteWatch succeeded, on x64 failed.
推荐答案
这篇关于GetWriteWatch不适用于x64应用程序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!