Skip to content

Commit 04808dc

Browse files
committed
MMap: APC SxS fix
1 parent e59f720 commit 04808dc

File tree

4 files changed

+14
-3
lines changed

4 files changed

+14
-3
lines changed

src/BlackBone/Asm/AsmHelper32.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ void AsmHelper32::GenPrologue( bool switchMode /*= false*/ )
3737
/// </summary>
3838
/// <param name="switchMode">Unused</param>
3939
/// <param name="retSize">Stack change value</param>
40-
void AsmHelper32::GenEpilogue( bool switchMode /*= false*/ , int retSize /*= WordSize */ )
40+
void AsmHelper32::GenEpilogue( bool switchMode /*= false*/ , int retSize /*= 0xC */ )
4141
{
4242
if (retSize == -1)
4343
retSize = WordSize;

src/BlackBone/Asm/AsmHelper32.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ class AsmHelper32 : public AsmHelperBase
2525
/// </summary>
2626
/// <param name="switchMode">Unused</param>
2727
/// <param name="retSize">Stack change value</param>
28-
virtual void GenEpilogue( bool switchMode = false, int retSize = 4 );
28+
virtual void GenEpilogue( bool switchMode = false, int retSize = 0xC );
2929

3030
/// <summary>
3131
/// Generate function call

src/BlackBone/Include/FunctionTypes.h

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -218,6 +218,14 @@ typedef NTSTATUS( NTAPI *fnRtlCreateActivationContext )(
218218
OUT PVOID* ActCtx
219219
);
220220

221+
typedef NTSTATUS( NTAPI* fnNtQueueApcThread )(
222+
IN HANDLE ThreadHandle,
223+
IN PVOID ApcRoutine, /*PKNORMAL_ROUTINE*/
224+
IN PVOID NormalContext,
225+
IN PVOID SystemArgument1,
226+
IN PVOID SystemArgument2
227+
);
228+
221229
// RtlImageNtHeader
222230
typedef PIMAGE_NT_HEADERS( NTAPI* fnRtlImageNtHeader )(
223231
IN PVOID ModuleAddress

src/BlackBone/Process/RPC/RemoteExec.cpp

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ RemoteExec::RemoteExec( Process& proc )
2121
{
2222
LOAD_IMPORT( "NtOpenEvent", L"ntdll.dll" );
2323
LOAD_IMPORT( "NtCreateEvent", L"ntdll.dll" );
24+
LOAD_IMPORT( "NtQueueApcThread", L"ntdll.dll" );
2425
}
2526

2627
RemoteExec::~RemoteExec()
@@ -137,7 +138,9 @@ NTSTATUS RemoteExec::ExecInWorkerThread( PVOID pCode, size_t size, uint64_t& cal
137138
#endif
138139

139140
// Execute code in thread context
140-
if (QueueUserAPC( _userCode.ptr<PAPCFUNC>(), _hWorkThd.handle(), _userCode.ptr<ULONG_PTR>() ))
141+
// TODO: Find out why am I passing pRemoteCode as an argument???
142+
auto pRemoteCode = _userCode.ptr<PVOID>();
143+
if (NT_SUCCESS( SAFE_NATIVE_CALL( NtQueueApcThread, _hWorkThd.handle(), pRemoteCode, pRemoteCode, nullptr, nullptr ) ))
141144
{
142145
dwResult = WaitForSingleObject( _hWaitEvent, 30 * 1000 /*wait 30s*/ );
143146
callResult = _userData.Read<uint64_t>( RET_OFFSET, 0 );

0 commit comments

Comments
 (0)