解读 AcquireTxnFunctions
返回两个函数的地址:
g_pfnGetCurrentTransaction
g_pfnSetCurrentTransaction
和这些地址是否存在的标志:
g_fTxnFunctionsAcquired
在 TxCaptureAndRelease::Set 中调用。
这两个函数来自 ntdll.dll,是干什么的呢?
RtlGetCurrentTransaction
RtlSetCurrentTransaction
void *__fastcall `anonymous namespace'::AcquireTxnFunctions(_DWORD *a1, _DWORD *a2)
{
_DWORD *v2;
const char *v3;
bool v4;
void *v5;
signed int v6;
NTSTATUS v7;
NTSTATUS v8;
_DWORD *v10;
char v11;
_DWORD *v12;
const char *v13;
const char *v14;
int v15;
const char *v16;
PVOID ProcedureAddress;
PVOID v18;
PVOID ModuleImageBase;
v2 = a1;
v3 = 0;
v12 = a2;
v4 = `anonymous namespace'::g_fTxnFunctionsAcquired == 0;
*a1 = 0;
*a2 = 0;
if ( v4 )
{
v5 = (void *)LdrGetDllHandle(0, 0, &g_UNICODE_STRING_ntdll_dot_dll, &ModuleImageBase);
if ( (signed int)v5 < 0 )
{
v6 = 258;
v3 = "LdrGetDllHandle( 0, 0, &g_UNICODE_STRING_ntdll_dot_dll, &Ntdll)";
LABEL_10:
ModuleImageBase = v5;
v15 = v6;
v13 = "base\\wcp\\sil\\merged\\ntu\\ntsystem.cpp";
v14 = "`anonymous-namespace'::AcquireTxnFunctions";
v16 = v3;
Windows::ErrorHandling::Rtl::CBaseFrame<Windows::ErrorHandling::Rtl::CVoidRaiseFrame>::ReportErrorOrigination(
(int *)&ModuleImageBase,
(int)&v13);
return v5;
}
v7 = LdrGetProcedureAddress(ModuleImageBase, &g_ANSI_STRING_RtlSetCurrentTransaction, 0, &ProcedureAddress);
v5 = (void *)v7;
if ( v7 < 0 && v7 != -1073741511 )
{
v6 = 267;
goto LABEL_10;
}
v8 = LdrGetProcedureAddress(ModuleImageBase, &g_ANSI_STRING_RtlGetCurrentTransaction, 0, &v18);
v5 = (void *)v8;
if ( v8 < 0 && v8 != -1073741511 )
{
v6 = 276;
goto LABEL_10;
}
if ( ProcedureAddress )
{
if ( v18 )
{
`anonymous namespace'::g_pfnSetCurrentTransaction = (int)ProcedureAddress;
`anonymous namespace'::g_pfnGetCurrentTransaction = (int)v18;
}
}
_InterlockedOr((volatile signed __int32 *)&v11, 0);
`anonymous namespace'::g_fTxnFunctionsAcquired = 1;
}
_InterlockedOr((volatile signed __int32 *)&v11, 0);
v10 = v12;
*v2 = `anonymous namespace'::g_pfnSetCurrentTransaction;
*v10 = `anonymous namespace'::g_pfnGetCurrentTransaction;
return 0;
}
__int64 __fastcall TxCaptureAndRelease::Set(TxCaptureAndRelease *this)
{
bool v1;
TxCaptureAndRelease *v2;
char *v3;
__int64 result;
int this + 8) == 0;
v2 = this;
v8 = -1073741595;
if ( !v1 || !*(_QWORD *)this )
goto LABEL_8;
v3 = (char *)this + 24;
if ( *((_QWORD *)this + 3)
|| (result = `anonymous namespace'::AcquireTxnFunctions((_QWORD *)this + 2, v3), (signed int)result >= 0) )
{
v5 = *(int (void))v3;
_guard_check_icall_fptr(v5);
LODWORD(v6) = v5();
if ( (unsigned __int64)(v6 - 1) <= 0xFFFFFFFFFFFFFFFDui64 )
{
Windows::ErrorHandling::CBaseFrame::BreakIn();
__debugbreak();
}
else
{
v7 = (int (__fastcall *)(_QWORD))*((_QWORD *)v2 + 2);
_guard_check_icall_fptrv2 + 2));
if ( v7v2) )
{
*((_BYTE *)v2 + 8) = 1;
LABEL_8:
Windows::ErrorHandling::COM::CBaseFrame<Windows::ErrorHandling::COM::CSimpleHResultCarryingFrame>::SetCanonicalSuccess(&v8);
return v8;
}
}
Windows::ErrorHandling::CBaseFrame::BreakIn();
JUMPOUT&byte_180071F8C);
}
return result;
}