Skip to content

Instantly share code, notes, and snippets.

@cw2k
Created November 11, 2021 04:44
Show Gist options
  • Save cw2k/73ac73dc88b7e18a80ee15a7ee3247d2 to your computer and use it in GitHub Desktop.
Save cw2k/73ac73dc88b7e18a80ee15a7ee3247d2 to your computer and use it in GitHub Desktop.
RecEnv.exe CRecoveryToolAction::NeedsAuthentication
Windows Registry Editor Version 5.00
[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\RecoveryEnvironment]
"WinREAuthenticationRequirement"=dword:00000002
@cw2k
Copy link
Author

cw2k commented Nov 12, 2021

So import that registry setting above to the target system.
It'll will avoid that start annoying admin password prompt when you use Windows startup recovery.

Here the decompiled source from RecEnv.exe

int CRecoveryToolAction::NeedsAuthentication(CRecoveryToolAction *this)
{
...
    Size = 4;
    if ( !Utils::GetRecoveryEnvironmentValue(L"WinREAuthenticationRequirement", RRF_RT_REG_DWORD, &OUTVal, &Size) )
    if ( OUTVal == 1 )
    {
      return 1;
    }
    else if ( OUTVal == 2 )
        return 0;

    }
}

LSTATUS     Utils::GetRecoveryEnvironmentValue(LPCWSTR lpValue, DWORD dwFlags, unsigned __int8 *OUTVal, unsigned int *Size)
{
  return RegGetValueW(
           HKEY_LOCAL_MACHINE,
           L"SOFTWARE\\Microsoft\\RecoveryEnvironment",
           lpValue,
           dwFlags,
           &dwFlags,
           OUTVal,
           Size);
}



WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nShowCmd)
    CImmersiveRecoveryUi::Run(CImmersiveRecoveryUi *this)
        StartPage = CImmersiveRecoveryUi::GetStartPage(this, &Block, v23);
        v46 = LaunchBootUx(8i64, StartPage, v44);
}

CImmersiveRecoveryUi::GetStartPage(CImmersiveRecoveryUi *this, int *a2, unsigned __int16 *a3)
{
    ...
    if ( CRecoveryEnvironment::IsAuthenticationRequired(*&this->CImmersiveRecoveryUi0)
      && CRecoveryToolAction::NeedsAuthentication(RecoveryToolAction) )
    {
      Retval = 11;
    }
    else
    {
      Retval = 0;
    }
    ...
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment