Skip to content

Commit

Permalink
Merge remote-tracking branch 'blattersturm/fix/client-rpc-seh' into m…
Browse files Browse the repository at this point in the history
…aster-pub
  • Loading branch information
blattersturm committed Aug 15, 2021
2 parents b909e91 + e6e627e commit 503f215
Showing 1 changed file with 28 additions and 1 deletion.
29 changes: 28 additions & 1 deletion code/components/gta-net-five/src/ClientRPC.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,33 @@ extern NetLibrary* g_netLibrary;

#include <concurrentqueue.h>

static LONG ShouldHandleUnwind(DWORD exceptionCode, uint64_t identifier)
{
// C++ exceptions?
if (exceptionCode == 0xE06D7363)
{
return EXCEPTION_CONTINUE_SEARCH;
}

return EXCEPTION_EXECUTE_HANDLER;
}

template<typename THandler, typename TContext>
static inline void CallHandler(const THandler& handler, uint64_t nativeIdentifier, TContext& context)
{
// call the original function
static void* exceptionAddress;

__try
{
handler(context);
}
__except (exceptionAddress = (GetExceptionInformation())->ExceptionRecord->ExceptionAddress, ShouldHandleUnwind((GetExceptionInformation())->ExceptionRecord->ExceptionCode, nativeIdentifier))
{
throw std::exception(va("Error executing native 0x%016llx at address %p.", nativeIdentifier, exceptionAddress));
}
}

class FxNativeInvoke
{
private:
Expand Down Expand Up @@ -539,7 +566,7 @@ static InitFunction initFunction([]()
{
try
{
(*n)(*executionCtx);
CallHandler(*n, nativeHash, *executionCtx);
}
catch (std::exception& e)
{
Expand Down

0 comments on commit 503f215

Please sign in to comment.