Hi there,
While finally hooking EndScene, I was constantly getting some kind of uncatchable (from .Net perspective) error, which resulted in the ICLRRuntimeHost::ExecuteInDefaultAppDomain Method to return with E_POINTER, indicating that I accessed an invalid address.
I tracked down the problem and located it in the actual access in my Memory class while writing the 6 magic bytes to the EndScene address. Regardless if I do the writing with Marshal.Copy or with pure unsafe arithmetic, the managed dll returns immediately without a chance to catch an Exception. I opened OllyDbg and queried the protection attributes for the .text section of d3d9.dll, which suprised me:
WoW changed them from RWE Copy on Write to RE, explaining my errors.
Since I'm using Apoc's WhiteMagic (kind of, the Manager<> stuff), I edited the protection attributes for test purposes and my EndScene-handler was called correctly.
Now my questions are:
1.) Why does the access violation pass through my .Net Exception handlers?
2.) The main reason for this post, did you have the same issue? It's not much of a problem because it's easy to fix, but I like to know if I did some kind of n00b mistake and there's an even easier solution.