Skip to content

Commit 3ef7afb

Browse files
committed
LoadLibrary returns not NTSTATUS but HMODULE so it needs to be checked against 0
fix return value of ExecInNewThread code
1 parent d771377 commit 3ef7afb

File tree

2 files changed

+9
-6
lines changed

2 files changed

+9
-6
lines changed

src/BlackBone/Process/ProcessModules.cpp

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -498,11 +498,14 @@ call_result_t<ModuleDataPtr> ProcessModules::Inject( const std::wstring& path, T
498498
}
499499

500500
// Retry with LoadLibrary if possible
501-
if (!NT_SUCCESS( status ) && pLoadLibrary && sameArch)
502-
status = _proc.remote().ExecDirect( pLoadLibrary->procAddress, modName->ptr() + ustrSize );
503-
504-
if (!NT_SUCCESS( status ))
505-
return status;
501+
if (!NT_SUCCESS(status) && pLoadLibrary && sameArch)
502+
{
503+
auto result = _proc.remote().ExecDirect( pLoadLibrary->procAddress, modName->ptr() + ustrSize );
504+
if (result == 0)
505+
{
506+
return status;
507+
}
508+
}
506509

507510
return GetModule( path, LdrList, img.mType() );
508511
}

src/BlackBone/Process/RPC/RemoteExec.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ NTSTATUS RemoteExec::ExecInNewThread(
8282

8383
a->GenCall( _userCode.ptr(), { } );
8484
(*a)->mov( (*a)->zdx, _userData.ptr() + INTRET_OFFSET );
85-
(*a)->mov( (*a)->zdx, (*a)->zax );
85+
(*a)->mov( asmjit::host::dword_ptr( (*a)->zdx ), (*a)->zax );
8686
a->GenEpilogue( switchMode, 4 );
8787

8888
// Execute code in newly created thread

0 commit comments

Comments
 (0)