Bump SourcePawn submodule (#2428)
This commit is contained in:
@@ -30,6 +30,7 @@
|
||||
*
|
||||
* Adopted to provide similar features to SourceHook by AlliedModders LLC.
|
||||
*/
|
||||
#include "bandaid.h"
|
||||
|
||||
// ============================================================================
|
||||
// >> INCLUDES
|
||||
@@ -642,8 +643,15 @@ void CHook::CreateBridge()
|
||||
// This will still call post hooks, but will skip the original function.
|
||||
masm.ret(m_pCallingConvention->GetPopSize());
|
||||
|
||||
void* base = smutils->GetScriptingEngine()->AllocatePageMemory(masm.length());
|
||||
masm.emitToExecutableMemory(base);
|
||||
void* base = smutils->GetScriptingEngine()->AllocatePageMemory(masm.total_size());
|
||||
DhookCodeChunk chunk((uint8_t*)base, masm.total_size());
|
||||
|
||||
// Can't let dtor call happen
|
||||
LinkedCode* code = (LinkedCode*)new uint8_t[sizeof(LinkedCode)];
|
||||
*((DhookCodeChunk*)&code->chunk) = chunk;
|
||||
masm.emitToExecutableMemory(code);
|
||||
|
||||
delete[] (uint8_t*)code;
|
||||
m_pBridge = base;
|
||||
}
|
||||
|
||||
@@ -728,8 +736,15 @@ void CHook::CreatePostCallback()
|
||||
masm.jmp(Operand(ExternalAddress(&pRetAddr)));
|
||||
|
||||
// Generate the code
|
||||
void* base = smutils->GetScriptingEngine()->AllocatePageMemory(masm.length());
|
||||
masm.emitToExecutableMemory(base);
|
||||
void* base = smutils->GetScriptingEngine()->AllocatePageMemory(masm.total_size());
|
||||
DhookCodeChunk chunk((uint8_t*)base, masm.total_size());
|
||||
|
||||
// Can't let dtor call happen
|
||||
LinkedCode* code = (LinkedCode*)new uint8_t[sizeof(LinkedCode)];
|
||||
*((DhookCodeChunk*)&code->chunk) = chunk;
|
||||
masm.emitToExecutableMemory(code);
|
||||
|
||||
delete[] (uint8_t*)code;
|
||||
m_pNewRetAddr = base;
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,23 @@
|
||||
#pragma once
|
||||
|
||||
// Yes this is bad, but whatever dhooks will be nuked soon
|
||||
#include <../vm/code-allocator.h>
|
||||
|
||||
class DhookCodePool : public ke::Refcounted<DhookCodePool> {
|
||||
public:
|
||||
uint8_t* start_;
|
||||
uint8_t* ptr_;
|
||||
uint8_t* end_;
|
||||
size_t size_;
|
||||
};
|
||||
|
||||
struct DhookCodeChunk {
|
||||
DhookCodeChunk(uint8_t* addr, size_t bytes)
|
||||
: address(addr)
|
||||
, bytes(bytes) {
|
||||
}
|
||||
|
||||
uint8_t pool[sizeof(ke::RefPtr<DhookCodePool>)];
|
||||
uint8_t* address;
|
||||
size_t bytes;
|
||||
};
|
||||
@@ -29,6 +29,8 @@
|
||||
* Version: $Id$
|
||||
*/
|
||||
|
||||
#include "bandaid.h"
|
||||
|
||||
#include "vhook.h"
|
||||
#include "vfunc_call.h"
|
||||
#include "util.h"
|
||||
@@ -175,8 +177,16 @@ void *GenerateThunk(HookSetup* hook)
|
||||
masm.pop(ebp); // restore ebp
|
||||
masm.ret();
|
||||
|
||||
void *base = g_pSM->GetScriptingEngine()->AllocatePageMemory(masm.length());
|
||||
masm.emitToExecutableMemory(base);
|
||||
void* base = smutils->GetScriptingEngine()->AllocatePageMemory(masm.total_size());
|
||||
DhookCodeChunk chunk((uint8_t*)base, masm.total_size());
|
||||
|
||||
// Can't let dtor call happen
|
||||
LinkedCode* code = (LinkedCode*)new uint8_t[sizeof(LinkedCode)];
|
||||
*((DhookCodeChunk*)&code->chunk) = chunk;
|
||||
masm.emitToExecutableMemory(code);
|
||||
|
||||
delete[] (uint8_t*)code;
|
||||
|
||||
return base;
|
||||
}
|
||||
#else
|
||||
@@ -215,8 +225,15 @@ void *GenerateThunk(HookSetup* hook)
|
||||
masm.addl(esp, ecx); // remove arguments
|
||||
masm.jmp(edx); // return to caller
|
||||
|
||||
void *base = g_pSM->GetScriptingEngine()->AllocatePageMemory(masm.length());
|
||||
masm.emitToExecutableMemory(base);
|
||||
void* base = smutils->GetScriptingEngine()->AllocatePageMemory(masm.total_size());
|
||||
DhookCodeChunk chunk((uint8_t*)base, masm.total_size());
|
||||
|
||||
// Can't let dtor call happen
|
||||
LinkedCode* code = (LinkedCode*)new uint8_t[sizeof(LinkedCode)];
|
||||
*((DhookCodeChunk*)&code->chunk) = chunk;
|
||||
masm.emitToExecutableMemory(code);
|
||||
|
||||
delete[] (uint8_t*)code;
|
||||
return base;
|
||||
}
|
||||
#endif
|
||||
|
||||
Reference in New Issue
Block a user