You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
177 lines
2.8 KiB
177 lines
2.8 KiB
// Copyright (C) 1997-2000 Microsoft Corporation
|
|
//
|
|
// get syskey on diskette for replica from media page
|
|
//
|
|
// 25 Apr 2000 sburns
|
|
|
|
|
|
|
|
#include "headers.hxx"
|
|
#include "resource.h"
|
|
#include "page.hpp"
|
|
#include "SyskeyDiskDialog.hpp"
|
|
#include "state.hpp"
|
|
|
|
|
|
|
|
static const DWORD HELP_MAP[] =
|
|
{
|
|
0, 0
|
|
};
|
|
|
|
|
|
|
|
SyskeyDiskDialog::SyskeyDiskDialog()
|
|
:
|
|
Dialog(IDD_SYSKEY_DISK, HELP_MAP)
|
|
{
|
|
LOG_CTOR(SyskeyDiskDialog);
|
|
}
|
|
|
|
|
|
|
|
SyskeyDiskDialog::~SyskeyDiskDialog()
|
|
{
|
|
LOG_DTOR(SyskeyDiskDialog);
|
|
}
|
|
|
|
|
|
|
|
void
|
|
SyskeyDiskDialog::OnInit()
|
|
{
|
|
LOG_FUNCTION(SyskeyDiskDialog::OnInit);
|
|
|
|
State& state = State::GetInstance();
|
|
if (state.RunHiddenUnattended())
|
|
{
|
|
if (Validate())
|
|
{
|
|
Win::EndDialog(hwnd, IDOK);
|
|
}
|
|
else
|
|
{
|
|
state.ClearHiddenWhileUnattended();
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
|
|
bool
|
|
SyskeyDiskDialog::OnCommand(
|
|
HWND /* windowFrom */ ,
|
|
unsigned controlIdFrom,
|
|
unsigned code)
|
|
{
|
|
// LOG_FUNCTION(SyskeyDiskDialog::OnCommand);
|
|
|
|
switch (controlIdFrom)
|
|
{
|
|
case IDOK:
|
|
{
|
|
if (code == BN_CLICKED)
|
|
{
|
|
if (Validate())
|
|
{
|
|
Win::EndDialog(hwnd, controlIdFrom);
|
|
}
|
|
}
|
|
break;
|
|
}
|
|
case IDCANCEL:
|
|
{
|
|
if (code == BN_CLICKED)
|
|
{
|
|
Win::EndDialog(hwnd, controlIdFrom);
|
|
}
|
|
break;
|
|
}
|
|
default:
|
|
{
|
|
// do nothing
|
|
|
|
break;
|
|
}
|
|
}
|
|
|
|
return false;
|
|
}
|
|
|
|
|
|
|
|
HRESULT
|
|
SyskeyDiskDialog::LocateSyskey(HWND hwnd)
|
|
{
|
|
LOG_FUNCTION(LocateSyskey);
|
|
|
|
HRESULT hr = S_OK;
|
|
|
|
do
|
|
{
|
|
if (FS::PathExists(L"A:\\StartKey.Key"))
|
|
{
|
|
LOG(L"syskey found on a:");
|
|
|
|
// The only drive the syskey may be present on is A:. Winlogon
|
|
// also hardcodes A:, which they may change someday, but not today.
|
|
// NTRAID#NTBUG9-522068-2002/01/23-sburns
|
|
|
|
EncryptedString es;
|
|
es.Encrypt(L"A:");
|
|
State::GetInstance().SetSyskey(es);
|
|
break;
|
|
}
|
|
|
|
hr = E_FAIL;
|
|
|
|
if (hwnd)
|
|
{
|
|
popup.Error(hwnd, IDS_SYSKEY_NOT_FOUND);
|
|
}
|
|
}
|
|
while (0);
|
|
|
|
LOG_HRESULT(hr);
|
|
|
|
return hr;
|
|
}
|
|
|
|
|
|
|
|
bool
|
|
SyskeyDiskDialog::Validate()
|
|
{
|
|
LOG_FUNCTION(SyskeyDiskDialog::Validate);
|
|
|
|
bool result = false;
|
|
|
|
do
|
|
{
|
|
// look for the syskey
|
|
|
|
HRESULT hr = LocateSyskey(hwnd);
|
|
|
|
if (FAILED(hr))
|
|
{
|
|
// LocateSyskey will take care of emitting error messages, so
|
|
// we just need to bail out here
|
|
|
|
break;
|
|
}
|
|
|
|
result = true;
|
|
}
|
|
while (0);
|
|
|
|
LOG(result ? L"true" : L"false");
|
|
|
|
return result;
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|