Error "Attempting to read or write protected memory" when Win7 control fails - ActiveX

We have a Windows application (.net, VS2010) that uses the old wrapped activeX control (VSPrinter 8 from ComponentOne, to be precise. Vsprint8.ocx). It handles all our print and print previews. When we deploy and run our application in a new instance of Win7 on a virtual machine (32 bit) and do what tries to call this control, we get the following error:

"Trying to read or write protected memory. This often indicates that the other memory is corrupt."

It works great on Windows XP. Interestingly, if we disable DEP on the target virtual machine (network-wide, install AlwaysOff), the application works. But if we disable DEP only for an executable that uses ocx, this will not work.

Any ideas? Thanks!

+4
source share
1 answer

Found a solution.

I could not effectively disable DEP for the executable, so I added the following lines to the command line of the post-build event in VS2010, and it fixed my problem:

call "$(DevEnvDir)\..\..\VC\bin\vcvars32.bat" call "$(DevEnvDir)\..\..\VC\bin\editbin.exe" /NXCOMPAT:NO "$(TargetPath)" 

In the VS Solution Explorer, right-click the project under the solution, select Properties, and click Build Events. You will see the text field "Post-build event: event command line", in which you paste the above material.

This effectively disables DEP for my application. Here's a blog post that helped me see the light. Thanks, random dude!

http://jtstroup.net/post/Attempted-to-read-or-write-protected-memory-This-is-often-an-indication-that-other-memory-is-corrupt.aspx

+5
source

Source: https://habr.com/ru/post/1335334/


All Articles