Some experiments
This commit is contained in:
parent
a343c5ac5b
commit
3c448f173f
@ -9,6 +9,26 @@
|
||||
|
||||
namespace Components
|
||||
{
|
||||
void Exception::UploadMinidump(std::string filename)
|
||||
{
|
||||
// Utils::WebIO webio("Firefucks", UPLOAD_URL);
|
||||
//
|
||||
// if (Utils::IO::FileExists(filename))
|
||||
// {
|
||||
// std::string buffer = Utils::IO::ReadFile(filename);
|
||||
// std::string result = webio.PostFile(buffer);
|
||||
//
|
||||
// MessageBoxA(0, result.data(), "Minidump", 0);
|
||||
// }
|
||||
|
||||
// mg_mgr mgr;
|
||||
// mg_mgr_init(&mgr, NULL);
|
||||
//
|
||||
// mg_connect_http
|
||||
//
|
||||
// mg_mgr_free(&mgr);
|
||||
}
|
||||
|
||||
LONG WINAPI Exception::ExceptionFilter(LPEXCEPTION_POINTERS ExceptionInfo)
|
||||
{
|
||||
char filename[MAX_PATH];
|
||||
@ -28,6 +48,8 @@ namespace Components
|
||||
CloseHandle(hFile);
|
||||
}
|
||||
|
||||
Exception::UploadMinidump(filename);
|
||||
|
||||
if (ExceptionInfo->ExceptionRecord->ExceptionCode == EXCEPTION_STACK_OVERFLOW)
|
||||
{
|
||||
Logger::Error("Termination because of a stack overflow.\n");
|
||||
@ -35,7 +57,7 @@ namespace Components
|
||||
}
|
||||
else
|
||||
{
|
||||
Logger::Error("Fatal error (0x%08x) at 0x%08x.", ExceptionInfo->ExceptionRecord->ExceptionCode, ExceptionInfo->ExceptionRecord->ExceptionAddress);
|
||||
Logger::Error("Fatal error (0x%08X) at 0x%08X.", ExceptionInfo->ExceptionRecord->ExceptionCode, ExceptionInfo->ExceptionRecord->ExceptionAddress);
|
||||
}
|
||||
|
||||
return EXCEPTION_CONTINUE_SEARCH;
|
||||
|
@ -1,3 +1,5 @@
|
||||
#define UPLOAD_URL "https://momo5502.com/test/upload.php"
|
||||
|
||||
namespace Components
|
||||
{
|
||||
class Exception : public Component
|
||||
@ -9,5 +11,7 @@ namespace Components
|
||||
private:
|
||||
static LONG WINAPI ExceptionFilter(LPEXCEPTION_POINTERS ExceptionInfo);
|
||||
static LPTOP_LEVEL_EXCEPTION_FILTER WINAPI SetUnhandledExceptionFilterStub(LPTOP_LEVEL_EXCEPTION_FILTER lpTopLevelExceptionFilter);
|
||||
|
||||
static void UploadMinidump(std::string filename);
|
||||
};
|
||||
}
|
||||
|
@ -331,6 +331,11 @@ namespace Components
|
||||
QuickPatch::UnlockStats();
|
||||
});
|
||||
|
||||
Command::Add("crash", [] (Command::Params params)
|
||||
{
|
||||
throw new std::exception();
|
||||
});
|
||||
|
||||
|
||||
// Debug patches
|
||||
#ifdef DEBUG
|
||||
|
@ -5,8 +5,9 @@ namespace Components
|
||||
Utils::Hook Renderer::DrawFrameHook;
|
||||
wink::signal<wink::slot<Renderer::Callback>> Renderer::FrameSignal;
|
||||
wink::signal<wink::slot<Renderer::Callback>> Renderer::FrameOnceSignal;
|
||||
wink::signal<wink::slot<Renderer::BackendCallback>> Renderer::BackendFrameSignal;
|
||||
|
||||
void __declspec(naked) Renderer::FrameHook()
|
||||
void __declspec(naked) Renderer::FrameStub()
|
||||
{
|
||||
__asm
|
||||
{
|
||||
@ -22,6 +23,30 @@ namespace Components
|
||||
Renderer::FrameOnceSignal.clear();
|
||||
}
|
||||
|
||||
void __declspec(naked) Renderer::BackendFrameStub()
|
||||
{
|
||||
__asm
|
||||
{
|
||||
call Renderer::BackendFrameHandler
|
||||
|
||||
mov eax, ds:66E1BF0h
|
||||
mov ecx, 536A85h
|
||||
jmp ecx
|
||||
}
|
||||
}
|
||||
|
||||
void Renderer::BackendFrameHandler()
|
||||
{
|
||||
IDirect3DDevice9* device = *Game::dx_ptr;
|
||||
|
||||
if (device)
|
||||
{
|
||||
device->AddRef();
|
||||
Renderer::BackendFrameSignal(device);
|
||||
device->Release();
|
||||
}
|
||||
}
|
||||
|
||||
void Renderer::Once(Renderer::Callback* callback)
|
||||
{
|
||||
Renderer::FrameOnceSignal.connect(callback);
|
||||
@ -32,6 +57,11 @@ namespace Components
|
||||
Renderer::FrameSignal.connect(callback);
|
||||
}
|
||||
|
||||
void Renderer::OnBackendFrame(Renderer::BackendCallback* callback)
|
||||
{
|
||||
Renderer::BackendFrameSignal.connect(callback);
|
||||
}
|
||||
|
||||
int Renderer::Width()
|
||||
{
|
||||
return Utils::Hook::Get<int>(0x66E1C68);
|
||||
@ -44,13 +74,44 @@ namespace Components
|
||||
|
||||
Renderer::Renderer()
|
||||
{
|
||||
// Renderer::OnBackendFrame([] (IDirect3DDevice9* device)
|
||||
// {
|
||||
// if (Game::Sys_Milliseconds() % 2)
|
||||
// {
|
||||
// device->Clear(0, NULL, D3DCLEAR_TARGET | D3DCLEAR_ZBUFFER | D3DCLEAR_STENCIL, 0, 0, 0);
|
||||
// }
|
||||
//
|
||||
// return;
|
||||
//
|
||||
// IDirect3DSurface9* buffer = nullptr;
|
||||
//
|
||||
// device->CreateOffscreenPlainSurface(Renderer::Width(), Renderer::Height(), D3DFMT_A8R8G8B8, D3DPOOL_SYSTEMMEM, &buffer, nullptr);
|
||||
// device->GetFrontBufferData(0, buffer);
|
||||
//
|
||||
// if (buffer)
|
||||
// {
|
||||
// D3DSURFACE_DESC desc;
|
||||
// D3DLOCKED_RECT lockedRect;
|
||||
//
|
||||
// buffer->GetDesc(&desc);
|
||||
//
|
||||
// HRESULT res = buffer->LockRect(&lockedRect, NULL, D3DLOCK_READONLY);
|
||||
//
|
||||
//
|
||||
// buffer->UnlockRect();
|
||||
// }
|
||||
// });
|
||||
|
||||
// Frame hook
|
||||
Renderer::DrawFrameHook.Initialize(0x5ACB99, Renderer::FrameHook, HOOK_CALL)->Install();
|
||||
Renderer::DrawFrameHook.Initialize(0x5ACB99, Renderer::FrameStub, HOOK_CALL)->Install();
|
||||
|
||||
Utils::Hook(0x536A80, Renderer::BackendFrameStub, HOOK_JUMP).Install()->Quick();
|
||||
}
|
||||
|
||||
Renderer::~Renderer()
|
||||
{
|
||||
Renderer::DrawFrameHook.Uninstall();
|
||||
Renderer::BackendFrameSignal.clear();
|
||||
Renderer::FrameOnceSignal.clear();
|
||||
Renderer::FrameSignal.clear();
|
||||
}
|
||||
|
@ -4,6 +4,7 @@ namespace Components
|
||||
{
|
||||
public:
|
||||
typedef void(Callback)();
|
||||
typedef void(BackendCallback)(IDirect3DDevice9*);
|
||||
|
||||
Renderer();
|
||||
~Renderer();
|
||||
@ -14,13 +15,18 @@ namespace Components
|
||||
|
||||
static void Once(Callback* callback);
|
||||
static void OnFrame(Callback* callback);
|
||||
static void OnBackendFrame(BackendCallback* callback);
|
||||
|
||||
private:
|
||||
static void FrameHook();
|
||||
static void FrameStub();
|
||||
static void FrameHandler();
|
||||
|
||||
static void BackendFrameStub();
|
||||
static void BackendFrameHandler();
|
||||
|
||||
static wink::signal<wink::slot<Callback>> FrameSignal;
|
||||
static wink::signal<wink::slot<Callback>> FrameOnceSignal;
|
||||
static wink::signal<wink::slot<BackendCallback>> BackendFrameSignal;
|
||||
static Utils::Hook DrawFrameHook;
|
||||
};
|
||||
}
|
||||
|
@ -230,6 +230,9 @@ namespace Game
|
||||
SpawnVar* spawnVars = (SpawnVar*)0x1A83DE8;
|
||||
MapEnts** marMapEntsPtr = (MapEnts**)0x112AD34;
|
||||
|
||||
IDirect3D9** d3d9 = (IDirect3D9**)0x66DEF84;
|
||||
IDirect3DDevice9** dx_ptr = (IDirect3DDevice9**)0x66DEF88;
|
||||
|
||||
XAssetHeader ReallocateAssetPool(XAssetType type, unsigned int newSize)
|
||||
{
|
||||
int elSize = DB_GetXAssetSizeHandlers[type]();
|
||||
|
@ -459,6 +459,9 @@ namespace Game
|
||||
extern SpawnVar* spawnVars;
|
||||
extern MapEnts** marMapEntsPtr;
|
||||
|
||||
extern IDirect3D9** d3d9;
|
||||
extern IDirect3DDevice9** dx_ptr;
|
||||
|
||||
XAssetHeader ReallocateAssetPool(XAssetType type, unsigned int newSize);
|
||||
void Menu_FreeItemMemory(Game::itemDef_t* item);
|
||||
const char* TableLookup(StringTable* stringtable, int row, int column);
|
||||
|
@ -134,6 +134,29 @@ namespace Utils
|
||||
return body;
|
||||
}
|
||||
|
||||
std::string WebIO::PostFile(std::string url, std::string data)
|
||||
{
|
||||
WebIO::SetURL(url);
|
||||
return WebIO::PostFile(data);
|
||||
}
|
||||
|
||||
std::string WebIO::PostFile(std::string data)
|
||||
{
|
||||
WebIO::Params headers;
|
||||
|
||||
std::string boundary = "xxxxxxxxx";
|
||||
headers["Content-Type"] = "multipart/form-data, boundary=" + boundary;
|
||||
headers["Content-Length"] = fmt::sprintf("%u", data.size());
|
||||
|
||||
std::string body = "--" + boundary + "\r\n";
|
||||
body += "Content-Disposition: form-data; name=\"contents\"; filename=\"minidump.dmp\"\r\n";
|
||||
body += "Content-Type: application/octet-stream\r\n\r\n";
|
||||
body += data + "\r\n";
|
||||
body += "--" + boundary + "--";
|
||||
|
||||
return WebIO::Execute("POST", body, headers);
|
||||
}
|
||||
|
||||
std::string WebIO::Post(std::string url, std::string body)
|
||||
{
|
||||
WebIO::SetURL(url);
|
||||
@ -203,7 +226,7 @@ namespace Utils
|
||||
return this;
|
||||
}
|
||||
|
||||
std::string WebIO::Execute(const char* command, std::string body)
|
||||
std::string WebIO::Execute(const char* command, std::string body, WebIO::Params headers)
|
||||
{
|
||||
if (!WebIO::OpenConnection()) return "";
|
||||
|
||||
@ -225,8 +248,22 @@ namespace Utils
|
||||
return "";
|
||||
}
|
||||
|
||||
const char* headers = "Content-type: application/x-www-form-urlencoded";
|
||||
HttpSendRequestA(WebIO::m_hFile, headers, strlen(headers), const_cast<char*>(body.data()), body.size() + 1);
|
||||
if (headers.find("Content-type") == headers.end())
|
||||
{
|
||||
headers["Content-type"] = "application/x-www-form-urlencoded";
|
||||
}
|
||||
|
||||
std::string finalHeaders;
|
||||
|
||||
for (auto i = headers.begin(); i != headers.end(); ++i)
|
||||
{
|
||||
finalHeaders.append(i->first);
|
||||
finalHeaders.append(": ");
|
||||
finalHeaders.append(i->second);
|
||||
finalHeaders.append("\r\n");
|
||||
}
|
||||
|
||||
HttpSendRequestA(WebIO::m_hFile, finalHeaders.data(), finalHeaders.size(), const_cast<char*>(body.data()), body.size() + 1);
|
||||
|
||||
std::string returnBuffer;
|
||||
|
||||
|
@ -26,6 +26,9 @@ namespace Utils
|
||||
void SetURL(std::string url);
|
||||
void SetCredentials(std::string username, std::string password);
|
||||
|
||||
std::string PostFile(std::string url, std::string data);
|
||||
std::string PostFile(std::string data);
|
||||
|
||||
std::string Post(std::string url, WebIO::Params params);
|
||||
std::string Post(std::string url, std::string body);
|
||||
std::string Post(WebIO::Params params);
|
||||
@ -90,7 +93,7 @@ namespace Utils
|
||||
|
||||
bool IsSecuredConnection();
|
||||
|
||||
std::string Execute(const char* command, std::string body);
|
||||
std::string Execute(const char* command, std::string body, WebIO::Params headers = WebIO::Params());
|
||||
|
||||
bool ListElements(std::string directory, std::vector<std::string> &list, bool files);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user