From e137e3711ebefdc98285a050ad2bdd0e06275158 Mon Sep 17 00:00:00 2001 From: comex Date: Tue, 1 Oct 2013 22:37:17 -0400 Subject: [PATCH] Fix ThunkManager::ProtectFunction on x86. --- Source/Core/Common/Src/x64Thunk.cpp | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/Source/Core/Common/Src/x64Thunk.cpp b/Source/Core/Common/Src/x64Thunk.cpp index a9c19060de..3d72ec68f6 100644 --- a/Source/Core/Common/Src/x64Thunk.cpp +++ b/Source/Core/Common/Src/x64Thunk.cpp @@ -105,9 +105,12 @@ void *ThunkManager::ProtectFunction(void *function, int num_params) // trickery : we simply re-push the parameters. might not be optimal, but that doesn't really // matter. ABI_AlignStack(num_params * 4, true); - unsigned int alignedSize = ABI_GetAlignedFrameSize(num_params * 4); + unsigned int alignedSize = ABI_GetAlignedFrameSize(num_params * 4, true); for (int i = 0; i < num_params; i++) { - // ESP is changing, so we do not need i + // dst-arg1 dst-arg2 | dst-arg3 padding return-addr orig-arg1 | orig-arg2 orig-arg3 + // ^ ESP ^ target + // The offset is just alignedSize (return address makes up for the + // missing argument). PUSH(32, MDisp(ESP, alignedSize)); } CALL(function);