MCPcopy Create free account
hub / github.com/BeneficialCode/WinArk / OnKeyPermissions

Method OnKeyPermissions

WinArk/View.cpp:1331–1357  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1329}
1330
1331LRESULT CRegistryManagerView::OnKeyPermissions(WORD, WORD, HWND, BOOL&){
1332 auto path = GetFullNodePath(m_Tree.GetSelectedItem());
1333 SecurityHelper::EnablePrivilege(SE_TAKE_OWNERSHIP_NAME, true);
1334 if (::GetFocus() == m_List) {
1335 auto& item = m_Items[m_List.GetSelectionMark()];
1336 ATLASSERT(item.Key);
1337 path += L"\\" + item.Name;
1338 }
1339 auto readonly = m_ReadOnly;
1340 auto key = Registry::OpenKey(path, READ_CONTROL | (readonly ? 0 : (WRITE_DAC | WRITE_OWNER)));
1341 if (!key && ::GetLastError() == ERROR_ACCESS_DENIED) {
1342 key = Registry::OpenKey(path, READ_CONTROL);
1343 readonly = true;
1344 }
1345 if (!key && ::GetLastError() == ERROR_ACCESS_DENIED) {
1346 key = Registry::OpenKey(path, MAXIMUM_ALLOWED);
1347 }
1348 if (!key) {
1349 DisplayError(L"Failed to open key");
1350 }
1351 else {
1352 CSecurityInformation si(key, path, readonly);
1353 ::EditSecurity(m_hWnd, &si);
1354 }
1355 SecurityHelper::EnablePrivilege(SE_TAKE_OWNERSHIP_NAME, false);
1356 return 0;
1357}
1358
1359LRESULT CRegistryManagerView::OnProperties(WORD, WORD, HWND, BOOL&){
1360 if (::GetFocus() == m_List) {

Callers

nothing calls this directly

Calls 1

EnablePrivilegeFunction · 0.85

Tested by

no test coverage detected