locked
Data Execution Prevention, IE add-ins and DOM RRS feed

  • Question

  • Hi - I'm developing an add-in for Internet Explorer in .net and running it on Vista, developing with VS2008

    I tried to use the Document.selection to identify the parent node that completely encloses the current user-selection and I hit the following exception "Attempted to read or write protected memory. This is often an indication that other memory is corrupt."

    This is a pretty unhelpful, so I reimplemented the .net function by navigating the DOM myself and hit the same error again - simply by moving from a leaf node in the dom towards the root. The error occurred when I tried to clone a node:

    System.AccessViolationException occurred
      Message="Attempted to read or write protected memory. This is often an indication that other memory is corrupt."
      Source="Microsoft.mshtml"
      StackTrace:
           at mshtml.IHTMLDOMNode.cloneNode(Boolean fDeep)
           at MVCModel.Digest.Item.StoreOriginalNode()
      InnerException: 

    here is the code line:

            private void StoreOriginalNode() {
                // cache the original outer element
        >>        OriginalElement = (IHTMLElement)(((IHTMLDOMNode)Element).cloneNode( true ));   <<
            }

    I tried to catch the exception and handle it, to use as a kludge test and stop at that point, in an attempt to avoid this problem whilst traversing the DOM. Unfortunately the exception appears to wipe-out the contents of the browser, even if it is handled.

    From reading online, I suspect is that this exception is related to DES. I tried turning off DES for IE but the problem remained.

    If this is the cause, how can I circumvent DES, either by having a non-destructive test (e.g. to discover when I am passing an iFrame or as it appear in this case, hitting a node containing javascript (a guess??)) or by turning it off?

     Tony

    Wednesday, February 11, 2009 1:07 AM