MCPcopy Create free account
hub / github.com/BeneficialCode/WinArk / DetourTransactionCommitEx

Function DetourTransactionCommitEx

KernelLibrary/detours.cpp:673–796  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

671}
672
673NTSTATUS NTAPI DetourTransactionCommitEx() {
674 // Common variables
675 DetourOperation* o;
676 bool freed = false;
677
678 // Insert or remove each of the detours
679 for (o = s_pPendingOperations; o != nullptr; o = o->pNext) {
680 if (o->fIsRemove) {
681 MapLockedCopyMemory(o->pTarget, o->pTrampoline->rbRestore,
682 o->pTrampoline->cbRestore);
683#ifdef DETOURS_IA64
684 * o->ppbPointer = (PBYTE)o->pTrampoline->ppldTarget;
685#endif // DETOURS_IA64
686
687#ifdef DETOURS_X86
688 * o->ppPointer = o->pTarget;
689#endif // DETOURS_X86
690
691#ifdef DETOURS_X64
692 * o->ppPointer = o->pTarget;
693#endif // DETOURS_X64
694
695#ifdef DETOURS_ARM
696 * o->ppbPointer = DETOURS_PBYTE_TO_PFUNC(o->pbTarget);
697#endif // DETOURS_ARM
698
699#ifdef DETOURS_ARM64
700 * o->ppbPointer = o->pbTarget;
701#endif // DETOURS_ARM
702
703 }
704 else {
705 LogDebug("detours: pbTramp =%p, pbRemain=%p, pbDetour=%p, cbRestore=%u\n",
706 o->pTrampoline,
707 o->pTrampoline->pRemain,
708 o->pTrampoline->pDetour,
709 o->pTrampoline->cbRestore);
710
711 LogDebug("detours: pbTarget=%p: "
712 "%02x %02x %02x %02x "
713 "%02x %02x %02x %02x "
714 "%02x %02x %02x %02x [before]\n",
715 o->pTarget,
716 o->pTarget[0], o->pTarget[1], o->pTarget[2], o->pTarget[3],
717 o->pTarget[4], o->pTarget[5], o->pTarget[6], o->pTarget[7],
718 o->pTarget[8], o->pTarget[9], o->pTarget[10], o->pTarget[11]);
719
720#ifdef DETOURS_IA64
721 ((DETOUR_IA64_BUNDLE*)o->pbTarget)
722 ->SetBrl((UINT64)&o->pTrampoline->bAllocFrame);
723 *o->ppbPointer = (PBYTE)&o->pTrampoline->pldTrampoline;
724#endif // DETOURS_IA64
725
726#ifdef DETOURS_X64
727 DetourGenJmpIndirect(o->pTrampoline->rbCodeIn, &o->pTrampoline->pDetour);
728 PUCHAR pCode = DetourGenJmpAddress(o->pTarget, o->pTrampoline->rbCodeIn);
729 pCode = DetourGenBrk(pCode, o->pTrampoline->pRemain);
730 *o->ppPointer = o->pTrampoline->rbCode;

Callers 1

DetourTransactionCommitFunction · 0.85

Calls 7

MapLockedCopyMemoryFunction · 0.85
LogDebugFunction · 0.85
DetourGenJmpIndirectFunction · 0.85
DetourGenJmpAddressFunction · 0.85
DetourGenBrkFunction · 0.85
DetourGenJmpImmediateFunction · 0.85

Tested by

no test coverage detected