I stopped writing my wow bot project in order to focus more on uni work. A few days ago I decided to return to it to try to implement some design patterns and clean it up..
My problem:
It's been about 4 months since I last tested this project and it seems that the endscene hook that I previously never had a problem with, is causing a major spanner in the works.
Notes:
- I'm using visual studio 2010, the original source was written in visual studio 2008. I opened the project in VS2010 and let it do it's conversion thing.
- The Wow version used for testing is Version 3.3.5(12340).
- The assembly is loaded from a native bootstrap which is injected using Cypher's Loader_IA32.exe.
- All code in the function posted below can be debugged.
Below is a heavily commented test version of the endscene hook.
Code:
public static void DetourEndscene()
{
//Offsets posted by JuJuBoSc
//http://www.mmowned.com/forums/world-of-warcraft/bots-programs/memory-editing/300463-wow-3-3-5-12340-info-dump-thread.html
//public enum Direct3D9
//{
// pDevicePtr_1 = 0x00C5DF88, // 3.3.5a 12340
// pDevicePtr_2 = 0x397C, // 3.3.5a 12340
// oBeginScene = 0xA4, // 3.3.5a 12340
// oEndScene = 0xA8, // 3.3.5a 12340
// oClear = 0xAC, // 3.3.5a 12340
//}
//Careful reads aren't working.
//uint pDevicePtr = Magic.Instance.Read<uint>(0x00C5DF88);
//pDevicePtr = Magic.Instance.Read<uint>(pDevicePtr + 0x397C); //<-- returns 0 here No exception thrown.
//uint endSceneAddr = Magic.Instance.Read<uint>(pDevicePtr); // <-- The previous 0 makes this line angry.
//endSceneAddr = Magic.Instance.Read<uint>(endSceneAddr + 0xA8);
//My original code isn't working.
//IntPtr endSceneAddr = Magic.Instance.GetObjectVtableFunction
//(Magic.Instance.Read<IntPtr>(0x0C5DF88, 0x397C), 42); <-- This fails, Hence the above tests
//The code below doesn't install the detour, or detours something
//that isn't endscene.
//In case the addresses were wrong, I implemented this DirectX class by Apoc / Onyx team.
//http://www.mmowned.com/forums/world-of-warcraft/bots-programs/memory-editing/299688-finding-direct3d-vmt-table-hook-endscene.html
IntPtr endSceneAddr = DirectX.GetEndScenePointer();
//WhiteMagic Detour.
Magic.Instance.Detours.CreateAndApply(Magic.Instance.RegisterDelegate<EndSceneDelegate>(endSceneAddr), EndSceneHandler, "EndScene");
}
I hate to post for help, I've been staring at this for hours and I can't see the solution, Any help would be greatly appreciated.