Skip to content

Commit

Permalink
Adding scope to EV tracking
Browse files Browse the repository at this point in the history
  • Loading branch information
dhoehna committed Mar 10, 2022
1 parent cdb343a commit 1981e80
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,26 @@ namespace winrt::Microsoft::Windows::System::implementation
void AddExecutableFileExtension(hstring const& pathExt);
void RemoveExecutableFileExtension(hstring const& pathExt);

static std::wstring ScopeToString(Scope scope)
{
if (scope == Scope::Process)
{
return L"process";
}
else if (scope == Scope::User)
{
return L"user";
}
else if (scope == Scope::Machine)
{
return L"machine";
}
else
{
THROW_HR_MSG(E_INVALIDARG, "Scope is not either process, user, or machine");
}
}

private:
Scope m_Scope{};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,12 +50,15 @@ namespace winrt::Microsoft::Windows::System::implementation
topLevelKey = HKEY_LOCAL_MACHINE;
}

auto subKey{ wil::str_printf<wil::unique_cotaskmem_string>(
L"Software\\ChangeTracker\\%ws\\%ws\\%ws\\", KeyName(), m_PackageFullName.c_str(), m_Key.c_str()) };
std::filesystem::path subKey{ L"Software\\ChangeTracker"};
subKey /= KeyName();
subKey /= m_PackageFullName;
subKey /= EnvironmentManager::ScopeToString(m_Scope);
subKey /= m_Key;

wil::unique_hkey keyToTrackChanges{};
THROW_IF_WIN32_ERROR(RegCreateKeyEx(HKEY_CURRENT_USER,
subKey.get(), 0, nullptr, REG_OPTION_NON_VOLATILE,
subKey.c_str(), 0, nullptr, REG_OPTION_NON_VOLATILE,
KEY_ALL_ACCESS | KEY_WOW64_64KEY, nullptr, keyToTrackChanges.put(), disposition));

return keyToTrackChanges;
Expand Down

0 comments on commit 1981e80

Please sign in to comment.