Well... I was looking through the WoW Widget API (Widget API - WoWWiki - Your guide to the World of Warcraft) trying to find out if frames have an event/function that is called when the frame is removed (forcefully or otherwise). And I came across a nice bit of info.
Basically; it requires 2 things. A working Lua class, and a single registered Lua callback. (I'll use HandleOnUpdate for this post)
Anyhow, here's the link in question; UIHANDLER OnUpdate - WoWWiki - Your guide to the World of Warcraft
As per the info provided, myFrame:OnUpdate will be called BEFORE the game is actually rendered, and any UI stuff is painted. (Effectively in WoW's own Render function) This is basically an EndScene hook... but earlier. (Meaning; you can do any nifty UI magic you want... I think)
A little background info:
I did some research (thanks to kynox for the original Render function address), and I figured out that WoW does all of it's logic, BEFORE calling the frame:OnUpdate functions (or any other render specific stuff). In laymans terms, it's safe to use this as an EndScene hook, and do all the stuff you need. (At least, I hope so, I haven't tested it yet)
Anyhow, lets get on with the methods...
I posted a Lua class, which I'll use the API from for this setup. Feel free to use whatever you want, so long as it is able to register a callback, which you can hook into.
Register a Lua callback. (We'll use OnUpdateHandler for brevity)
Call FrameScript::Execute (Lua_DoString) with the following code;
Now, OnUpdateHandler will be called each time f:OnUpdate is called. (Each frame, before EndScene is actually called) This is called in the main thread context, so it is safe to do whatever you want with WoW at this point.Code:Lua.DoString("local f = CreateFrame(\"Frame\"); f:RegisterAllEvents(); f:SetScript(\"OnUpdate\", OnUpdateHandler);");
There you go, a working (detour-less) EndScene-esque hook.
Keep in mind; I haven't tested this, and I don't plan to in the near future. I figured it would help those of you with out of process bots who are smart enough to figure out how to register callbacks that work.
Enjoy folks.
P.S; don't get pissy if it doesn't work. It just popped in my head.