Just skip GL function calls if we don't have function pointers

* This is completely invalid but better than crashing. This can happen as a
  race-condition if the user injects into a running program that's already using
  GL on one thread, before we've completed installing our hooks.
This commit is contained in:
baldurk
2019-03-26 14:09:18 +00:00
parent 39cfdf5ad7
commit 6e3ebcb483
+14
View File
@@ -116,12 +116,26 @@ void DisableGLHooks()
glhook.enabled = false;
}
template <typename ret_type>
ret_type default_ret()
{
return (ret_type)0;
}
template <>
void default_ret()
{
}
// if we were injected and aren't ready to capture, skip out and call the real function
#define UNINIT_CALL(function, ...) \
if(!glhook.enabled) \
{ \
if(GL.function == NULL) \
{ \
RDCERR("No function pointer for '%s' while uninitialised!", STRINGIZE(function)); \
return default_ret<decltype(GL.function(__VA_ARGS__))>(); \
} \
return GL.function(__VA_ARGS__); \
}