mirror of
https://github.com/shadps4-emu/shadPS4.git
synced 2025-07-29 21:44:50 +00:00
Clear stack before executing guest code
This commit is contained in:
parent
d542d952f4
commit
3f9f7adae4
@ -5,6 +5,8 @@
|
||||
|
||||
#include "common/types.h"
|
||||
|
||||
void* memset(void* ptr, int value, size_t num);
|
||||
|
||||
namespace Xbyak {
|
||||
class CodeGenerator;
|
||||
}
|
||||
@ -41,9 +43,18 @@ Tcb* GetTcbBase();
|
||||
/// Makes sure TLS is initialized for the thread before entering guest.
|
||||
void EnsureThreadInitialized();
|
||||
|
||||
template <size_t size>
|
||||
void ClearStack() {
|
||||
void* buf = alloca(size);
|
||||
memset(buf, 0, size);
|
||||
buf = nullptr;
|
||||
}
|
||||
|
||||
template <class ReturnType, class... FuncArgs, class... CallArgs>
|
||||
ReturnType ExecuteGuest(PS4_SYSV_ABI ReturnType (*func)(FuncArgs...), CallArgs&&... args) {
|
||||
EnsureThreadInitialized();
|
||||
// clear stack to avoid trash from EnsureThreadInitialized
|
||||
ClearStack<13_KB>();
|
||||
return func(std::forward<CallArgs>(args)...);
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user