LdrpSearchResourceSection_U
NTSTATUS __stdcall LdrpSearchResourceSection_U(
PVOID DllHandle,
UINT64 *ResourceIdPath,
UINT64 ResourceIdPathInputLength,
UINT64 Flags,
PVOID *ResourceDirectoryOrData){
unsigned int v5;
unsigned int v6;
__int64 *v7;
int v8;
UINT16 v9;
unsigned __int16 *v10;
NTSTATUS result;
unsigned __int16 *v12;
void *v13;
INT64 v14;
UINT64 v15;
int v16;
char v17;
char v18;
unsigned int v19;
UINT64 v20;
int v21;
int v22;
UINT64 v23;
__int64 v24;
char v25;
int v26;
int v27;
int v28;
int v29;
int v30;
int v31;
int v32;
__int16 v33;
__int16 v34;
__int64 v35;
UINT64 *v36;
INT64 v37;
unsigned __int64 v38;
unsigned __int16 v39;
__int64 v40;
char v41;
__int64 v42;
const WCHAR *v43;
NTSTATUS v44;
__int64 v45;
INT64 v46;
const WCHAR *v47;
__int16 ParentLangId[2];
char v49;
char v50;
char v51;
NTSTATUS v52;
char v53;
unsigned int v54;
char v55;
char v56;
unsigned int v57;
int v58;
UINT64 Size;
PVOID *v60;
__int64 v61;
void *v62;
VOID *Module;
unsigned int v64;
char v65;
char v66;
__int16 v67;
int v68;
unsigned __int16 *v69;
unsigned __int16 *v70;
INT64 v71;
void *v72;
UINT64 *v73;
unsigned __int16 *v74;
__int64 v75;
int v76;
__int64 v77;
UINT64 *v78;
__int64 *v79;
UINT64 ResourceIdPatha[2];
__int64 v81;
__int64 v82;
v5 = Flags;
HIDWORD(Size) = Flags;
v6 = ResourceIdPathInputLength;
v64 = ResourceIdPathInputLength;
v7 = (__int64 *)ResourceIdPath;
Module = DllHandle;
v60 = ResourceDirectoryOrData;
v61 = 0i64;
v78 = ResourceIdPath;
v50 = 0;
v53 = 1;
v51 = 1;
if( (unsigned int)ResourceIdPathInputLength < 3 && (Flags & 2) == 0
|| (unsigned int)ResourceIdPathInputLength > 4
|| (Flags & 0x41) != 0 && (_DWORD)ResourceIdPathInputLength != 4
|| (_DWORD)ResourceIdPathInputLength == 4 && (Flags & 0x41) == 0 )
{
return -1073741583;
}
v8 = ResourceIdPathInputLength;
if( (_DWORD)ResourceIdPathInputLength == 4 )
v8 = 3;
v57 = v8;
v58 = v8;
LOWORD(v54) = 0;
v9 = 0;
ParentLangId[0] = 0;
if( (unsigned __int64)ResourceIdPath - 1 > 0xFFFFFFFFFFFFFFFDui64
|| (char *)DllHandle - 1 > (char *)0xFFFFFFFFFFFFFFFDi64
|| (unsigned __int64)ResourceDirectoryOrData - 1 > 0xFFFFFFFFFFFFFFFDui64 )
{
return -1073741811;
}
v10 = (unsigned __int16 *)RtlImageDirectoryEntryToData(DllHandle, 1u, 2u, &Size);
v71 = (INT64)v10;
if( !v10 )
return -1073741687;
v12 = v10;
v69 = v10;
v61 = 61166i64;
v68 = 0;
v13 = 0i64;
v62 = 0i64;
v72 = 0i64;
v70 = 0i64;
v77 = 0i64;
if( (~(_BYTE)v5 & 0x10) == 0 || v57 - 1 > 2 || *(&PnpReplaceEvent + 6682) != 1 )
goto LABEL_30;
if( v57 == 3 )
v14 = *((unsigned __int16 *)v7 + 8);
else
v14 = 0i64;
v54 = v14;
v67 = v14;
v15 = *v7;
if( ((*v7 - 16) & 0xFFFFFFFFFFFFFFF7ui64) == 0 )
goto LABEL_25;
if( (v15 & 0xFFFFFFFFFFFF0000ui64) != 0 && !wcsicmp((const wchar_t *)v15, L"MUI") )
{
v14 = v54;
LABEL_25:
if( (~(_BYTE)v5 & 8) != 0 && (v14 & 0xF3FF) == 0 && (_WORD)v14 != 3072 )
{
v5 |= 0x10u;
HIDWORD(Size) = v5;
goto LABEL_31;
}
}
v5 |= LdrIsResItemExist(Module, (UINT64 *)v7);
HIDWORD(Size) = v5;
LABEL_30:
v14 = v54;
LABEL_31:
if( *(&PnpReplaceEvent + 6682) == 1 && (v16 = ~v5, (~v5 & 0x80000) != 0) && (v16 & 0x20000) != 0 && (v16 & 0x10) != 0 )
{
v17 = 1;
v49 = 1;
}
else
{
v17 = 0;
v49 = 0;
}
if( *(&PnpReplaceEvent + 6682) && (v5 & 0x2040000) == 0 )
{
v18 = v51;
}
else
{
v18 = 0;
v51 = 0;
}
if( !v17 && !v18 )
goto LABEL_48;
ResourceIdPatha[0] = *v7;
v19 = v57;
if( v57 < 2 )
v20 = 0i64;
else
v20 = v7[1];
ResourceIdPatha[1] = v20;
if( v6 == 4 )
v82 = v7[3];
LABEL_49:
v21 = v58;
if( !v12 || (v22 = v58, v21 = v58 - 1, v58 = v21, v76 = v21, !v22) )
{
v24 = (__int64)v70;
LABEL_63:
if( !v13 || (v5 & 2) != 0 )
{
if( !v12 || (v5 & 2) == 0 )
{
LABEL_70:
switch( v19 - v21 )
{
case 1u:
result = -1073741686;
goto LABEL_77;
case 2u:
result = -1073741685;
break;
case 3u:
result = -1073741308;
v52 = -1073741308;
if( !v24 )
return result;
v62 = 0i64;
v72 = 0i64;
if( v53 )
{
v25 = v50;
LABEL_81:
v26 = v68;
while( 1 )
{
v27 = v26++;
v68 = v26;
if( v27 )
{
v28 = v27 - 1;
if( v28 )
{
v29 = v28 - 1;
if( v29 )
{
v30 = v29 - 1;
if( !v30 )
{
if( PsInstallUILanguageId != PsMachineUILanguageId )
{
if( v17 )
{
v81 = (unsigned __int16)PsInstallUILanguageId;
result = LdrpLoadResourceFromAlternativeModule(Module, ResourceIdPatha, v6, v5, v60);
v52 = result;
if( result >= 0 )
return result;
}
v33 = PsInstallUILanguageId;
goto LABEL_106;
}
LABEL_102:
v9 = v61;
ParentLangId[0] = v61;
goto LABEL_129;
}
v31 = v30 - 1;
if( v31 )
{
v32 = v31 - 1;
if( v32 )
{
if( v32 != 1 )
break;
v5 |= 0x20u;
HIDWORD(Size) = v5;
}
else
{
v9 = 1033;
ParentLangId[0] = 1033;
if( PsDefaultSystemLocaleId == 1033
|| PsInstallUILanguageId == 1033
|| PsMachineUILanguageId == 1033 )
{
goto LABEL_102;
}
if( v17 )
{
v81 = 1033i64;
result = LdrpLoadResourceFromAlternativeModule(Module, ResourceIdPatha, v6, v5, v60);
v52 = result;
if( result >= 0 )
return result;
}
}
}
else
{
v9 = PsDefaultSystemLocaleId;
ParentLangId[0] = PsDefaultSystemLocaleId;
if( (_WORD)PsDefaultSystemLocaleId == PsInstallUILanguageId
|| (_WORD)PsDefaultSystemLocaleId == PsMachineUILanguageId )
{
goto LABEL_102;
}
if( v17 )
{
v81 = (unsigned __int16)PsDefaultSystemLocaleId;
result = LdrpLoadResourceFromAlternativeModule(Module, ResourceIdPatha, v6, v5, v60);
v52 = result;
if( result >= 0 )
return result;
}
}
}
else
{
if( !v25 )
break;
if( v17 && PsMachineUILanguageId )
{
v81 = (unsigned __int16)PsMachineUILanguageId;
result = LdrpLoadResourceFromAlternativeModule(Module, ResourceIdPatha, v6, v5, v60);
v52 = result;
if( result >= 0 )
return result;
v33 = PsMachineUILanguageId;
LABEL_106:
v9 = v33;
ParentLangId[0] = v33;
goto LABEL_129;
}
v34 = v61;
if( PsMachineUILanguageId )
v34 = PsMachineUILanguageId;
v9 = v34;
ParentLangId[0] = v34;
}
}
else
{
if( v9 )
{
if( LdrpGetParentLangId(v9, (UINT16 *)ParentLangId) >= 0 )
{
v9 = ParentLangId[0];
}
else
{
v9 = 0;
ParentLangId[0] = 0;
}
}
if( v17 )
{
if( !v9 )
goto LABEL_129;
v81 = v9;
result = LdrpLoadResourceFromAlternativeModule(Module, ResourceIdPatha, v6, v5, v60);
v52 = result;
if( result >= 0 )
return result;
}
if( v9 )
v68 = --v26;
}
}
else
{
if( v17 && (_WORD)v14 )
{
v81 = (unsigned __int16)v14;
result = LdrpLoadResourceFromAlternativeModule(Module, ResourceIdPatha, v6, v5, v60);
v52 = result;
if( result >= 0 )
return result;
v14 = v54;
}
v9 = v14;
ParentLangId[0] = v14;
}
LABEL_129:
if( (~(_BYTE)v5 & 0x20) == 0 || v9 != v61 )
{
v61 = v9;
v7 = &v61;
v79 = &v61;
v24 = (__int64)v70;
v12 = v70;
v69 = v70;
v13 = v62;
v21 = v58;
LABEL_133:
v35 = v12[6];
LOWORD(Size) = v35;
v36 = (UINT64 *)(v12 + 8);
v74 = v12 + 8;
v37 = (unsigned __int16)v35;
if( (*v7 & 0xFFFFFFFFFFFF0000ui64) == 0 )
{
v36 += v35;
v74 = (unsigned __int16 *)v36;
LOWORD(v35) = v12[7];
LOWORD(Size) = v35;
v37 = (unsigned __int16)v35;
}
if( !(_WORD)v37 )
{
v69 = 0i64;
v53 = 0;
v66 = 0;
v6 = v64;
v17 = v49;
v14 = v54;
v19 = v57;
goto LABEL_70;
}
if( v24 && (v5 & 0x20) != 0 )
{
v12 = 0i64;
v69 = 0i64;
v61 = *(unsigned int *)v36;
v13 = (void *)(v71 + *((unsigned int *)v36 + 1));
v72 = v13;
v6 = v64;
v17 = v49;
v14 = v54;
v19 = v57;
goto LABEL_63;
}
v12 = 0i64;
v69 = 0i64;
v38 = (unsigned __int64)&v36[(unsigned __int16)v37 - 1];
v75 = v38;
while( 2 )
{
if( (unsigned __int64)v36 > v38 )
goto LABEL_151;
v39 = (unsigned __int16)v37 >> 1;
if( !((unsigned __int16)v37 >> 1) )
{
if( (_WORD)v37 )
{
v47 = (const WCHAR *)*v7;
v56 = 0;
v46 = v71;
if( !LdrpCompareResourceNamesWithValidation(v37, v14, v47, v71, v36, &v56) )
{
v45 = *((unsigned int *)v36 + 1);
if( (int)v45 >= 0 )
{
v13 = (void *)(v45 + v46);
goto LABEL_153;
}
LABEL_149:
v12 = (unsigned __int16 *)(v46 + (v45 & 0xFFFFFFFF7FFFFFFFui64));
v69 = v12;
}
}
v13 = v62;
goto LABEL_151;
}
v73 = v36;
v40 = v39;
v41 = v35 & 1;
if( v41 )
v42 = (__int64)&v36[v40];
else
v42 = (__int64)&v36[v40 - 1];
v73 = (UINT64 *)v42;
v43 = (const WCHAR *)*v7;
v55 = 0;
v44 = LdrpCompareResourceNamesWithValidation(v37, v14, v43, v71, (UINT64 *)v42, &v55);
if( !v44 )
{
v45 = *(unsigned int *)(v42 + 4);
if( (int)v45 < 0 )
{
v46 = v71;
goto LABEL_149;
}
v12 = 0i64;
v69 = 0i64;
v13 = (void *)(v45 + v71);
LABEL_153:
v62 = v13;
v72 = v13;
LABEL_151:
v79 = ++v7;
v5 = HIDWORD(Size);
v6 = v64;
v17 = v49;
v14 = v54;
v18 = v51;
LABEL_48:
v19 = v57;
goto LABEL_49;
}
if( v44 >= 0 )
{
v36 = (UINT64 *)(v42 + 8);
v74 = (unsigned __int16 *)(v42 + 8);
LOWORD(Size) = v39;
v38 = v75;
LABEL_159:
v37 = v39;
LOBYTE(v35) = v39;
}
else
{
v38 = v42 - 8;
v75 = v42 - 8;
if( v41 )
{
LOWORD(Size) = v39;
goto LABEL_159;
}
LOBYTE(v35) = v39 - 1;
LOWORD(Size) = v39 - 1;
v37 = (unsigned __int16)(v39 - 1);
}
v13 = v62;
continue;
}
}
v14 = v54;
v25 = v50;
}
}
result = -1073741308;
break;
default:
result = -1073741811;
goto LABEL_77;
}
v52 = result;
return result;
}
*v60 = v12;
}
else
{
*v60 = v13;
}
result = 0;
LABEL_77:
v52 = result;
return result;
}
if( v21 )
goto LABEL_59;
if( !v18 )
{
LABEL_55:
if( !v21 )
{
v24 = (__int64)v70;
if( v57 == 3 )
v24 = (__int64)v12;
v70 = (unsigned __int16 *)v24;
v77 = v24;
goto LABEL_60;
}
LABEL_59:
v24 = (__int64)v70;
LABEL_60:
if( !v24 )
goto LABEL_133;
v14 = *((unsigned __int16 *)v78 + 8);
v54 = v14;
v67 = v14;
v25 = (v14 & 0x3FF) == 0;
v50 = v25;
v65 = v25;
goto LABEL_81;
}
v23 = v5;
LODWORD(v23) = v5 | 0x1000000;
result = LdrpLoadResourceFromAlternativeModule(Module, ResourceIdPatha, v6, v23, v60);
v52 = result;
if( result < 0 )
{
v21 = v58;
goto LABEL_55;
}
return result;
}Referenced by:
LdrFindResourceDirectory_U
LdrFindResourceEx_U
LdrFindResource_U
LdrpGetRcConfig
LdrpLoadResourceFromAlternativeModule
RtlFindMessage
RtlLoadString