First of all, this is an issue that is caused by my own code, not WoW doing something strange or anything.
For my bot I have taken the following path:
a) Manually Map the bot DLL into the WoW process - this is done through my own memory allocation and fixing imports and relocations. This is in essence, my own DLL injector, except that doing it this way prevents it being found using VADs. (Technically, VMMap will still see it as a block of allocated memory with RWX flag, but that's it... and I could fix that with PageGuards but that's a completely different topic).
b) the bot DLL file creates its own thread in WoW's process space
c) my created thread hooks DirectD3D's EndScene and Reset functions
d) most of my logic is executed in through calls inside EndScene hook
Now, my problem is that ever since I started Manually Mapping my bot DLL it seems that I loose floating-point support. For example something as simple as:
Code:
float curFacing = self->GetFacing();
char szBuf[128];
sprintf(szBuf, "CurFacing: %f\n", curFacing);
MessageBoxA(0, szBuf, "Rotation Info", 0);
The code above will crash WoW with a:
Code:
Runtime Error!
R6002
- floating point support not loaded
Now, to be specific, the crash occurs on the sprintf(), not on creating or setting the float (or double) variables.
This is true regardless if I run that code inside EndScene or my injected bot DLL thread.
Any ideas for how I can force floating-point support to be loaded?
MSDN (Floating-Point Support (CRT)) states that floating-point support is loaded at run-time when it is found to be required. Some other suggestions I've read was to simply instantiate a double/float and set it to a value inside the DllMain load routine to force compiler/linker to set the __floatused variable to true so the library is included. I've done that, but the issue still remains.
I compile/link with:
RuntimeLibrary set to Multi-threaded (/MT)
No Common Language Runtime Support
This really might be something dumb on my part, but not sure.