NtSetBootOptions
INT64 __fastcall NtSetBootOptions(_BOOT_OPTIONS *BootOptions, UINT64 FieldsToChange){
char v2;
INT8 v5;
unsigned __int64 p_Length;
unsigned int v7;
char *v8;
ULONG NextBootEntryId;
_ETHREAD *v10;
int v11;
ULONG v12;
UINT64 Attributes;
ULONG Value;
int v15[2];
ULONG Version;
_ETHREAD *CurrentThread;
v2 = FieldsToChange;
Value = 0;
v15[0] = 0;
if( dword_140C19650 != 2 )
return 3221225474i64;
CurrentThread = (_ETHREAD *)KeGetCurrentThread();
v5 = *((_BYTE *)CurrentThread + 562);
p_Length = (unsigned __int64)&BootOptions->Length;
if( v5 )
{
if( p_Length >= 0x7FFFFFFF0000i64 )
p_Length = 0x7FFFFFFF0000i64;
v7 = *(_DWORD *)p_Length;
}
else
{
v7 = *(_DWORD *)p_Length;
}
v15[1] = v7;
if( v7 < 0x14 )
return 3221225485i64;
if( v5 )
{
if( ((unsigned __int8)BootOptions & 3) != 0 )
ExRaiseDatatypeMisalignment();
v8 = (char *)BootOptions + v7;
if( (unsigned __int64)v8 > 0x7FFFFFFF0000i64 || v8 < (char *)BootOptions )
MEMORY[0x7FFFFFFF0000] = 0;
if( !SeSinglePrivilegeCheck(*(_QWORD *)&SeSystemEnvironmentPrivilege, v5) )
return 3221225569i64;
}
Version = BootOptions->Version;
if( Version != 1 )
return 3221225485i64;
Value = BootOptions->Timeout;
NextBootEntryId = BootOptions->NextBootEntryId;
v15[0] = NextBootEntryId;
if( (v2 & 2) != 0 && NextBootEntryId > 0xFFFF )
return 3221225485i64;
v10 = (_ETHREAD *)KeGetCurrentThread();
--*((_WORD *)v10 + 242);
ExAcquireFastMutexUnsafe(&ExpEnvironmentLock);
v11 = 0;
if( (v2 & 1) != 0 )
{
v12 = Value;
if( Value == -1 )
{
Value = 0xFFFF;
}
else
{
if( Value > 0xFFFE )
v12 = 65534;
Value = v12;
}
LODWORD(Attributes) = 1;
v11 = IoSetEnvironmentVariableEx((WCHAR *)L"Timeout", (GUID *)&EfiBootVariablesGuid, &Value, 2ui64, Attributes);
}
if( v11 >= 0 && (v2 & 2) != 0 )
{
LODWORD(Attributes) = 1;
v11 = IoSetEnvironmentVariableEx((WCHAR *)L"BootNext", (GUID *)&EfiBootVariablesGuid, v15, 2ui64, Attributes);
}
ExReleaseFastMutexUnsafe(&ExpEnvironmentLock);
KeLeaveCriticalRegionThread((__int64)KeGetCurrentThread());
return(unsigned int)v11;
}Referenced by:
No references.