Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
358 changes: 170 additions & 188 deletions CodeFunctions.cpp

Large diffs are not rendered by default.

3 changes: 0 additions & 3 deletions CodeFunctions.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
#include <sstream>
#include <iostream>
#include "AOB.h"
#include "UtilityFunctions.h"
#include "Memory.h"

extern HANDLE codeHeap;
Expand All @@ -29,5 +28,3 @@ int luaExposeCode(lua_State* L);
int luaHookCode(lua_State* L);

int luaCallMachineCode(lua_State* L);

int convertTableToByteStream(lua_State* L, std::stringstream* s);
23 changes: 23 additions & 0 deletions Exceptions.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
#include "Exceptions.h"


char errorReport[1000] = {};
char intHex[4 + 1] = {};
static const char* const errorReportTooLong = "error report is too longer, longer than 1000 characters";

int errorFilterAndReporter(unsigned int code, struct _EXCEPTION_POINTERS* ep)
{
std::stringstream errorReportBuilder;
errorReportBuilder << "Exception occurred: code: 0x" << std::hex << code << " at 0x" << std::hex << ep->ExceptionRecord->ExceptionAddress;
std::string r = errorReportBuilder.str();
const char* data = r.c_str();
size_t size = strnlen_s(data, 1000);
if (size < 1000) {
// memset((void*)errorReport, 0, 1000);
memcpy((void*)errorReport, data, size + 1);
}
else {
memcpy((void*)errorReport, (void*)errorReportTooLong, strnlen_s(errorReportTooLong, 1000));
}
return EXCEPTION_EXECUTE_HANDLER;
}
14 changes: 14 additions & 0 deletions Exceptions.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
#pragma once

#include "framework.h"
#include <string>
#include <sstream>

#define RPS_HANDLE_SEH errorFilterAndReporter(GetExceptionCode(), GetExceptionInformation())
#define RPS_LUA_SEH luaL_error(L, "%s", errorReport);
#define RPS_LUA_SEH_X(x) (sprintf_s(intHex, "%X", x), luaL_error(L, "%s address: 0x%s", errorReport, intHex));
#define RPS_LUA_SEH_ADDRESS (sprintf_s(intHex, "%X", address), luaL_error(L, "%s address: 0x%s", errorReport, intHex));

extern char intHex[4 + 1];
extern char errorReport[1000];
int errorFilterAndReporter(unsigned int code, struct _EXCEPTION_POINTERS* ep);
Loading
Loading