处理 ProductKey 的函数在 TransmogProvider 中
signed __int64 __fastcall CTransmogManager::InitializeProductKey(CTransmogManager *this, const unsigned __int16 *a2, const unsigned __int16 *a3, const unsigned __int16 *a4)
{
v61 = a4;
v59 = -2i64;
v4 = a3;
v5 = a2;
v6 = this;
v7 = 0i64;
lpLibFileName = 0i64;
lpMem = 0i64;
if ( !a2 || !a4 )
return 0x80070057i64;
memset_0((char *)this + 156, 0, 0x30ui64);
memset_0((char *)v6 + 204, 0, 0xA4ui64);
memset_0((char *)v6 + 368, 0, 0x4F8ui64);
*((_DWORD *)v6 + 51) = 164;
*((_DWORD *)v6 + 92) = 1272;
v8 = SkuGetEditionPKeyConfigFilePath(v5, v4, (unsigned __int16 **)&lpMem);
if ( v8 < 0 )
goto LABEL_30;
if ( !&lpLibFileName )
{
v8 = 0x80070057;
goto LABEL_30;
}
v8 = BuildPathHr((__int64)v5, L"System32\\pidgenx.dll", (wchar_t **)&lpLibFileName);
if ( v8 < 0 )
goto LABEL_30;
v9 = LoadLibraryW(0i64);
if ( !v9 )
{
v10 = GetLastError();
v8 = (unsigned __int16)v10 | 0x80070000;
if ( (signed int)v10 <= 0 )
v8 = v10;
v11 = ATL::g_strmgr[3];
_guard_check_icall_fptr(ATL::g_strmgr[3]);
LODWORD(v12) = ((int (__fastcall *)(struct ATL::CStringData *(__fastcall ***)(ATL::CAtlStringMgr *__hidden, int, int)))v11)(&ATL::g_strmgr);
v54 = v12 + 24;
ATL::CStringT<unsigned short,ATL::StrTraitATL<unsigned short,ATL::ChTraitsCRT<unsigned short>>>::Format(
(const void **)&v54,
L"Unable to load [%s]; hr = 0x%X",
0i64,
(unsigned int)v8);
v13 = GetCurrentThreadId();
v14 = GetCurrentProcessId();
v15 = v54;
WriteLogEntry(1u, L"PID=%d TID=%d %s - %s", v14, v13);
v16 = v15 - 24;
v58 = v15 - 24;
if ( _InterlockedExchangeAdd((volatile signed __int32 *)(v15 - 24 + 16), 0xFFFFFFFF) <= 1 )
{
v17 = *(_QWORD *)v16;
v18 = *(void (__fastcall **)(__int64, __int64))(**(_QWORD **)v16 + 8i64);
_guard_check_icall_fptr(v18);
v18(v17, v58);
}
}
if ( v8 == 0x800700C1 )
{
v8 = BuildPathHr((__int64)v5, L"SysWow64\\pidgenx.dll", (wchar_t **)&lpLibFileName);
if ( v8 < 0 )
goto LABEL_30;
v19 = lpLibFileName;
v9 = LoadLibraryW(lpLibFileName);
if ( !v9 )
{
v20 = GetLastError();
v8 = (unsigned __int16)v20 | 0x80070000;
if ( (signed int)v20 <= 0 )
v8 = v20;
v21 = ATL::g_strmgr[3];
_guard_check_icall_fptr(ATL::g_strmgr[3]);
LODWORD(v22) = ((int (__fastcall *)(struct ATL::CStringData *(__fastcall ***)(ATL::CAtlStringMgr *__hidden, int, int)))v21)(&ATL::g_strmgr);
v55 = v22 + 24;
ATL::CStringT<unsigned short,ATL::StrTraitATL<unsigned short,ATL::ChTraitsCRT<unsigned short>>>::Format(
(const void **)&v55,
L"Unable to load [%s]; hr = 0x%X",
(__int64)v19,
(unsigned int)v8);
v23 = GetCurrentThreadId();
v24 = GetCurrentProcessId();
v25 = v55;
WriteLogEntry(1u, L"PID=%d TID=%d %s - %s", v24, v23);
v26 = v25 - 24;
if ( _InterlockedExchangeAdd((volatile signed __int32 *)(v25 - 24 + 16), 0xFFFFFFFF) <= 1 )
{
v27 = *(_QWORD *)v26;
v28 = *(void (__fastcall **)(__int64, signed __int64))(**(_QWORD **)v26 + 8i64);
_guard_check_icall_fptr(v28);
v28(v27, v26);
}
}
}
if ( v8 < 0 )
goto LABEL_30;
if ( v9 )
{
v7 = GetProcAddress(v9, "PidGenX");
if ( !v7 )
{
v29 = GetLastError();
v8 = (unsigned __int16)v29 | 0x80070000;
if ( (signed int)v29 <= 0 )
v8 = v29;
v30 = ATL::g_strmgr[3];
_guard_check_icall_fptr(ATL::g_strmgr[3]);
LODWORD(v31) = ((int (__fastcall *)(struct ATL::CStringData *(__fastcall ***)(ATL::CAtlStringMgr *__hidden, int, int)))v30)(&ATL::g_strmgr);
v56 = v31 + 24;
ATL::CStringT<unsigned short,ATL::StrTraitATL<unsigned short,ATL::ChTraitsCRT<unsigned short>>>::Format(
(const void **)&v56,
L"Unable to obtain pkey interface; hr = 0x%X",
(unsigned int)v8,
v32);
v33 = GetCurrentThreadId();
v34 = GetCurrentProcessId();
v35 = v56;
WriteLogEntry(1u, L"PID=%d TID=%d %s - %s", v34, v33);
v36 = v35 - 24;
if ( _InterlockedExchangeAdd((volatile signed __int32 *)(v35 - 24 + 16), 0xFFFFFFFF) <= 1 )
{
v37 = *(_QWORD *)v36;
v38 = *(void (__fastcall **)(__int64, signed __int64))(**(_QWORD **)v36 + 8i64);
_guard_check_icall_fptr(v38);
v38(v37, v36);
}
}
}
if ( v8 < 0 )
goto LABEL_30;
if ( v7 )
{
_guard_check_icall_fptr(v7);
v8 = ((int (__fastcall *)(const unsigned __int16 *, LPVOID, const wchar_t *, _QWORD))v7)(v61, lpMem, L"55041", 0i64);
if ( v8 >= 0 )
{
*((_DWORD *)v6 + 33) = 1;
goto LABEL_32;
}
LABEL_30:
v39 = ATL::g_strmgr[3];
_guard_check_icall_fptr(ATL::g_strmgr[3]);
LODWORD(v40) = ((int (__fastcall *)(struct ATL::CStringData *(__fastcall ***)(ATL::CAtlStringMgr *__hidden, int, int)))v39)(&ATL::g_strmgr);
v57 = v40 + 24;
ATL::CStringT<unsigned short,ATL::StrTraitATL<unsigned short,ATL::ChTraitsCRT<unsigned short>>>::Format(
(const void **)&v57,
L"Unable to retrieve pkey info; hr = 0x%X",
(unsigned int)v8,
v41);
v42 = GetCurrentThreadId();
v43 = GetCurrentProcessId();
v44 = v57;
WriteLogEntry(1u, L"PID=%d TID=%d %s - %s", v43, v42);
v45 = v44 - 24;
if ( _InterlockedExchangeAdd((volatile signed __int32 *)(v44 - 24 + 16), 0xFFFFFFFF) <= 1 )
{
v46 = *(_QWORD *)v45;
v47 = *(void (__fastcall **)(__int64, signed __int64))(**(_QWORD **)v45 + 8i64);
_guard_check_icall_fptr(v47);
v47(v46, v45);
}
}
LABEL_32:
v48 = lpMem;
if ( lpMem )
{
v49 = GetProcessHeap();
HeapFree(v49, 0, v48);
}
v50 = lpLibFileName;
if ( lpLibFileName )
{
v51 = GetProcessHeap();
HeapFree(v51, 0, (LPVOID)v50);
}
return (unsigned int)v8;
}
__int64 __fastcall CTransmogManager::GetPendingPackageCount(CTransmogManager *this, unsigned __int32 *a2)
{
v17 = -2i64;
v2 = a2;
v3 = 0i64;
v16 = 0i64;
v18 = 0;
v4 = 0;
if ( a2 )
{
v6 = *((_QWORD *)this + 11);
v7 = *(int (__fastcall **)(__int64, __int64 *))(*(_QWORD *)v6 + 112i64);
_guard_check_icall_fptr(*(_QWORD *)(*(_QWORD *)v6 + 112i64));
v5 = v7(v6, &v16);
if ( v5 >= 0 )
{
v8 = v16;
v9 = *(int (__fastcall **)(__int64, int *))(*(_QWORD *)v16 + 56i64);
_guard_check_icall_fptr(*(_QWORD *)(*(_QWORD *)v16 + 56i64));
v5 = v9(v8, &v18);
}
v10 = 1;
if ( v5 >= 0 )
{
do
{
if ( v10 > 0 )
break;
v20 = 0i64;
v19 = 0;
if ( v5 >= 0 )
{
v11 = v16;
v12 = *(int (__fastcall **)(__int64, _QWORD, __int64 *))(*(_QWORD *)v16 + 64i64);
_guard_check_icall_fptr(*(_QWORD *)(*(_QWORD *)v16 + 64i64));
v5 = v12(v11, (unsigned int)v10, &v20);
if ( v5 >= 0 )
{
v13 = *(int (__fastcall **)(_QWORD, int *))(v0 + 72i64);
_guard_check_icall_fptr(*(_QWORD *)(v0 + 72i64));
v5 = v13(0i64, &v19);
if ( v5 >= 0 )
continue;
}
}
++v4;
++v10;
}
while ( v5 >= 0 );
if ( v5 >= 0 )
*v2 = v4;
}
v3 = v16;
}
else
{
v5 = -2147024809;
}
if ( v3 )
{
v14 = *(void (__fastcall **)(__int64))(*(_QWORD *)v3 + 16i64);
_guard_check_icall_fptr(*(_QWORD *)(*(_QWORD *)v3 + 16i64));
v14(v3);
}
return (unsigned int)v5;
}
signed __int64 __fastcall CTransmogManager::ProjectEditionOverrideFile(CTransmogManager *this, const unsigned __int16 *a2, const unsigned __int16 *a3)
{
v32 = -2i64;
v3 = a3;
v4 = a2;
lpExistingFileName = 0i64;
lpNewFileName = 0i64;
if ( a2 && a3 )
{
v5 = SkuGetEditionOverridesFilePath(a2, a3, (unsigned __int16 **)&lpExistingFileName);
if ( v5 < 0 )
goto LABEL_28;
lpMem = 0i64;
if ( &lpNewFileName )
{
v5 = StrAllocatingPrintf((wchar_t **)&lpMem, L"%s.%s", (__int64)v3, (__int64)L"xml");
v6 = lpMem;
if ( v5 >= 0 )
v5 = BuildPathHr((__int64)v4, lpMem, (wchar_t **)&lpNewFileName);
if ( v6 )
{
v7 = GetProcessHeap();
HeapFree(v7, 0, v6);
}
}
else
{
v5 = -2147024809;
}
if ( v5 < 0 )
goto LABEL_28;
v8 = ATL::g_strmgr[3];
_guard_check_icall_fptr(ATL::g_strmgr[3]);
LODWORD(v9) = ((int (__fastcall *)(struct ATL::CStringData *(__fastcall ***)(ATL::CAtlStringMgr *__hidden, int, int)))v8)(&ATL::g_strmgr);
v30 = v9 + 24;
ATL::CStringT<unsigned short,ATL::StrTraitATL<unsigned short,ATL::ChTraitsCRT<unsigned short>>>::Format(
(const void **)&v30,
L"Copying edition override file from [%s] to [%s] ",
0i64,
0i64);
v10 = GetCurrentThreadId();
v11 = GetCurrentProcessId();
v12 = v30;
WriteLogEntry(3u, L"PID=%d TID=%d %s - %s", v11, v10);
v13 = v12 - 24;
if ( _InterlockedExchangeAdd((volatile signed __int32 *)(v12 - 24 + 16), 0xFFFFFFFF) <= 1 )
{
v14 = *(_QWORD *)v13;
v15 = *(void (__fastcall **)(__int64, signed __int64))(**(_QWORD **)v13 + 8i64);
_guard_check_icall_fptr(v15);
v15(v14, v13);
}
if ( !CopyFileW(0i64, 0i64, 0) )
{
v16 = GetLastError();
v17 = (unsigned __int16)v16 | 0x80070000;
if ( (signed int)v16 <= 0 )
v17 = v16;
if ( (v17 & 0x80000000) == 0 )
{
v5 = -2147467259;
}
else
{
v18 = GetLastError();
v5 = (unsigned __int16)v18 | 0x80070000;
if ( (signed int)v18 <= 0 )
v5 = v18;
}
}
if ( v5 < 0 )
{
LABEL_28:
v19 = ATL::g_strmgr[3];
_guard_check_icall_fptr(ATL::g_strmgr[3]);
LODWORD(v20) = ((int (__fastcall *)(struct ATL::CStringData *(__fastcall ***)(ATL::CAtlStringMgr *__hidden, int, int)))v19)(&ATL::g_strmgr);
v31 = v20 + 24;
ATL::CStringT<unsigned short,ATL::StrTraitATL<unsigned short,ATL::ChTraitsCRT<unsigned short>>>::Format(
(const void **)&v31,
L"Failed to copy edition override file.",
v21,
v22);
v23 = GetCurrentThreadId();
v24 = GetCurrentProcessId();
v25 = v31;
WriteLogEntry(1u, L"PID=%d TID=%d %s - %s(hr:0x%x)", v24, v23);
v26 = v25 - 24;
if ( _InterlockedExchangeAdd((volatile signed __int32 *)(v25 - 24 + 16), 0xFFFFFFFF) <= 1 )
{
v27 = *(_QWORD *)v26;
v28 = *(void (__fastcall **)(__int64, signed __int64))(**(_QWORD **)v26 + 8i64);
_guard_check_icall_fptr(v28);
v28(v27, v26);
}
}
result = (unsigned int)v5;
}
else
{
result = 2147942487i64;
}
return result;
}
signed __int64 __fastcall CTransmogManager::ProjectEditionLicenseFile(CTransmogManager *this, const unsigned __int16 *a2, const unsigned __int16 *a3)
{
v43 = this;
v3 = a3;
v4 = a2;
if ( a2 && a3 )
{
v5 = ATL::g_strmgr[3];
_guard_check_icall_fptr(ATL::g_strmgr[3]);
LODWORD(v6) = ((int (__fastcall *)(struct ATL::CStringData *(__fastcall ***)(ATL::CAtlStringMgr *__hidden, int, int)))v5)(&ATL::g_strmgr);
v43 = (CTransmogManager *)(v6 + 24);
ATL::CStringT<unsigned short,ATL::StrTraitATL<unsigned short,ATL::ChTraitsCRT<unsigned short>>>::Format(
(const void **)&v43,
L"Installing edition license file for edition [%s]",
(__int64)v3,
v7);
v8 = GetCurrentThreadId();
v9 = GetCurrentProcessId();
v10 = (__int64)v43;
WriteLogEntry(3u, L"PID=%d TID=%d %s - %s", v9, v8);
v11 = v10 - 24;
if ( _InterlockedExchangeAdd((volatile signed __int32 *)(v10 - 24 + 16), 0xFFFFFFFF) <= 1 )
{
v12 = *(_QWORD *)v11;
v13 = *(void (__fastcall **)(__int64, signed __int64))(**(_QWORD **)v11 + 8i64);
_guard_check_icall_fptr(v13);
v13(v12, v11);
}
Parameter = v3;
v42 = v4;
v14 = CreateThread(0i64, 0i64, (LPTHREAD_START_ROUTINE)StartAddress, &Parameter, 0, 0i64);
v15 = v14;
if ( v14 == (HANDLE)-1 )
{
v27 = GetLastError();
v28 = (unsigned __int16)v27 | 0x80070000;
if ( (signed int)v27 <= 0 )
v28 = v27;
if ( (v28 & 0x80000000) == 0 )
{
v16 = -2147467259;
}
else
{
v29 = GetLastError();
v16 = (unsigned __int16)v29 | 0x80070000;
if ( (signed int)v29 <= 0 )
v16 = v29;
}
if ( v16 < 0 )
{
v30 = ATL::g_strmgr[3];
_guard_check_icall_fptr(ATL::g_strmgr[3]);
LODWORD(v31) = ((int (__fastcall *)(struct ATL::CStringData *(__fastcall ***)(ATL::CAtlStringMgr *__hidden, int, int)))v30)(&ATL::g_strmgr);
v45 = v31 + 24;
ATL::CStringT<unsigned short,ATL::StrTraitATL<unsigned short,ATL::ChTraitsCRT<unsigned short>>>::Format(
(const void **)&v45,
L"Unable to Create Thread to Install EULA.",
v32,
v33);
v34 = GetCurrentThreadId();
v35 = GetCurrentProcessId();
v36 = v45;
WriteLogEntry(1u, L"PID=%d TID=%d %s - %s(hr:0x%x)", v35, v34);
v37 = v36 - 24;
if ( _InterlockedExchangeAdd((volatile signed __int32 *)(v36 - 24 + 16), 0xFFFFFFFF) <= 1 )
{
v38 = *(_QWORD *)v37;
v39 = *(void (__fastcall **)(__int64, signed __int64))(**(_QWORD **)v37 + 8i64);
_guard_check_icall_fptr(v39);
v39(v38, v37);
}
}
}
else
{
v16 = WaitForThreadComplete(v14);
if ( v16 < 0 )
{
v17 = ATL::g_strmgr[3];
_guard_check_icall_fptr(ATL::g_strmgr[3]);
LODWORD(v18) = ((int (__fastcall *)(struct ATL::CStringData *(__fastcall ***)(ATL::CAtlStringMgr *__hidden, int, int)))v17)(&ATL::g_strmgr);
v44 = v18 + 24;
ATL::CStringT<unsigned short,ATL::StrTraitATL<unsigned short,ATL::ChTraitsCRT<unsigned short>>>::Format(
(const void **)&v44,
L"Thread for Installing EULA Failed.",
v19,
v20);
v21 = GetCurrentThreadId();
v22 = GetCurrentProcessId();
v23 = v44;
WriteLogEntry(1u, L"PID=%d TID=%d %s - %s(hr:0x%x)", v22, v21);
v24 = v23 - 24;
if ( _InterlockedExchangeAdd((volatile signed __int32 *)(v23 - 24 + 16), 0xFFFFFFFF) <= 1 )
{
v25 = *(_QWORD *)v24;
v26 = *(void (__fastcall **)(__int64, signed __int64))(**(_QWORD **)v24 + 8i64);
_guard_check_icall_fptr(v26);
v26(v25, v24);
}
}
CloseHandle(v15);
}
result = (unsigned int)v16;
}
else
{
result = 2147942487i64;
}
return result;
}
__int64 __fastcall CTransmogManager::GetEula(CTransmogManager *this, unsigned __int16 *a2, unsigned __int16 *a3, unsigned __int16 *a4)
{
v51 = -2i64;
v4 = a4;
v5 = a3;
v6 = a2;
v7 = this;
lpMem = 0i64;
v8 = *(int (__fastcall **)(char *, unsigned __int16 *, unsigned __int16 *))(*((_QWORD *)this + 1) + 56i64);
_guard_check_icall_fptr(v8);
v9 = v8((char *)v7 + 8, v6, v5);
v10 = ATL::g_strmgr[3];
_guard_check_icall_fptr(ATL::g_strmgr[3]);
LODWORD(v11) = ((int (__fastcall *)(struct ATL::CStringData *(__fastcall ***)(ATL::CAtlStringMgr *__hidden, int, int)))v10)(&ATL::g_strmgr);
*(_QWORD *)v48 = v11 + 24;
ATL::CStringT<unsigned short,ATL::StrTraitATL<unsigned short,ATL::ChTraitsCRT<unsigned short>>>::Format(
(const void **)v48,
L"Installing edition license file for edition [%s]",
(__int64)v6,
v12);
v13 = GetCurrentThreadId();
v14 = GetCurrentProcessId();
v15 = *(_QWORD *)v48;
WriteLogEntry(3u, L"PID=%d TID=%d %s - %s", v14, v13);
v16 = v15 - 24;
if ( _InterlockedExchangeAdd((volatile signed __int32 *)(v15 - 24 + 16), 0xFFFFFFFF) <= 1 )
{
v17 = *(_QWORD *)v16;
v18 = *(void (__fastcall **)(__int64, signed __int64))(**(_QWORD **)v16 + 8i64);
_guard_check_icall_fptr(v18);
v18(v17, v16);
}
if ( v9 >= 0 )
{
v9 = CTransmogManager::GetWinDirPath(v7, (unsigned __int16 **)&lpMem);
if ( v9 >= 0 )
{
Parameter = v6;
v53 = v4;
v54 = lpMem;
v19 = CreateThread(0i64, 0i64, (LPTHREAD_START_ROUTINE)sub_180016740, &Parameter, 0, 0i64);
v20 = v19;
if ( v19 == (HANDLE)-1 )
{
v31 = GetLastError();
v32 = (unsigned __int16)v31 | 0x80070000;
if ( (signed int)v31 <= 0 )
v32 = v31;
if ( (v32 & 0x80000000) == 0 )
{
v9 = -2147467259;
}
else
{
v33 = GetLastError();
v9 = (unsigned __int16)v33 | 0x80070000;
if ( (signed int)v33 <= 0 )
v9 = v33;
}
if ( v9 < 0 )
{
v34 = ATL::g_strmgr[3];
_guard_check_icall_fptr(ATL::g_strmgr[3]);
LODWORD(v35) = ((int (__fastcall *)(struct ATL::CStringData *(__fastcall ***)(ATL::CAtlStringMgr *__hidden, int, int)))v34)(&ATL::g_strmgr);
v50 = v35 + 24;
ATL::CStringT<unsigned short,ATL::StrTraitATL<unsigned short,ATL::ChTraitsCRT<unsigned short>>>::Format(
(const void **)&v50,
L"Unable to Create Thread to Get EULA.",
v36,
v37);
v38 = GetCurrentThreadId();
v39 = GetCurrentProcessId();
v40 = v50;
WriteLogEntry(1u, L"PID=%d TID=%d %s - %s(hr:0x%x)", v39, v38);
v41 = v40 - 24;
if ( _InterlockedExchangeAdd((volatile signed __int32 *)(v40 - 24 + 16), 0xFFFFFFFF) <= 1 )
{
v42 = *(_QWORD *)v41;
v43 = *(void (__fastcall **)(__int64, signed __int64))(**(_QWORD **)v41 + 8i64);
_guard_check_icall_fptr(v43);
v43(v42, v41);
}
}
}
else
{
v9 = WaitForThreadComplete(v19);
if ( v9 < 0 )
{
v21 = ATL::g_strmgr[3];
_guard_check_icall_fptr(ATL::g_strmgr[3]);
LODWORD(v22) = ((int (__fastcall *)(struct ATL::CStringData *(__fastcall ***)(ATL::CAtlStringMgr *__hidden, int, int)))v21)(&ATL::g_strmgr);
v49 = v22 + 24;
ATL::CStringT<unsigned short,ATL::StrTraitATL<unsigned short,ATL::ChTraitsCRT<unsigned short>>>::Format(
(const void **)&v49,
L"Thread for getting EULA Failed.",
v23,
v24);
v25 = GetCurrentThreadId();
v26 = GetCurrentProcessId();
v27 = v49;
WriteLogEntry(1u, L"PID=%d TID=%d %s - %s(hr:0x%x)", v26, v25);
v28 = v27 - 24;
if ( _InterlockedExchangeAdd((volatile signed __int32 *)(v27 - 24 + 16), 0xFFFFFFFF) <= 1 )
{
v29 = *(_QWORD *)v28;
v30 = *(void (__fastcall **)(__int64, signed __int64))(**(_QWORD **)v28 + 8i64);
_guard_check_icall_fptr(v30);
v30(v29, v28);
}
}
CloseHandle(v20);
}
}
v44 = lpMem;
if ( lpMem )
{
v45 = GetProcessHeap();
HeapFree(v45, 0, v44);
}
}
return (unsigned int)v9;
}