MCPcopy Create free account
hub / github.com/DarthTon/Xenos / InjectDefault

Method InjectDefault

src/InjectionCore.cpp:649–691  ·  view source on GitHub ↗

Default injection method Injection context Context thread of execution Resulting module Error code

Source from the content-addressed store, hash-verified

647/// <param name="mod">Resulting module</param>
648/// <returns>Error code</returns>
649blackbone::call_result_t<blackbone::ModuleDataPtr> InjectionCore::InjectDefault(
650 InjectContext& context,
651 const blackbone::pe::PEImage& img,
652 blackbone::ThreadPtr pThread /*= nullptr*/
653 )
654{
655 using namespace blackbone;
656
657 NTSTATUS status = STATUS_SUCCESS;
658
659 // Pure IL image
660 if (img.pureIL())
661 {
662 DWORD code = 0;
663
664 xlog::Normal( "Image '%ls' is pure IL", img.path().c_str() );
665
666 if (!_process.modules().InjectPureIL(
667 ImageNET::GetImageRuntimeVer( img.path().c_str() ),
668 img.path(),
669 context.cfg.initRoutine,
670 context.cfg.initArgs,
671 code ))
672 {
673 xlog::Error( "Failed to inject pure IL image, status: %d", code );
674 if (NT_SUCCESS( code ))
675 code = STATUS_DLL_NOT_FOUND;
676
677 return code;
678 }
679
680 auto mod = _process.modules().GetModule( img.name(), Sections );
681 return mod ? call_result_t<ModuleDataPtr>( mod ) : call_result_t<ModuleDataPtr>( STATUS_NOT_FOUND );
682 }
683 else
684 {
685 auto injectedMod = _process.modules().Inject( img.path(), pThread );
686 if (!injectedMod)
687 xlog::Error( "Failed to inject image using default injection, status: 0x%X", injectedMod.status );
688
689 return injectedMod;
690 }
691}
692
693/// <summary>
694/// Kernel-mode injection

Callers

nothing calls this directly

Calls 4

NormalFunction · 0.85
ErrorFunction · 0.85
InjectMethod · 0.80
nameMethod · 0.45

Tested by

no test coverage detected