mirror of
https://github.com/reactos/reactos.git
synced 2025-06-10 04:14:53 +00:00
[SYSDM] Allow deleting and copying of user profiles only for profiles that are currently not in use
This commit is contained in:
parent
20b4f0a231
commit
05f0b08085
1 changed files with 30 additions and 18 deletions
|
@ -16,7 +16,7 @@
|
||||||
|
|
||||||
typedef struct _PROFILEDATA
|
typedef struct _PROFILEDATA
|
||||||
{
|
{
|
||||||
BOOL bMyProfile;
|
DWORD dwRefCount;
|
||||||
DWORD dwState;
|
DWORD dwState;
|
||||||
PWSTR pszFullName;
|
PWSTR pszFullName;
|
||||||
} PROFILEDATA, *PPROFILEDATA;
|
} PROFILEDATA, *PPROFILEDATA;
|
||||||
|
@ -176,7 +176,7 @@ DeleteUserProfile(
|
||||||
return FALSE;
|
return FALSE;
|
||||||
|
|
||||||
pProfileData = (PPROFILEDATA)Item.lParam;
|
pProfileData = (PPROFILEDATA)Item.lParam;
|
||||||
if (pProfileData->bMyProfile)
|
if (pProfileData->dwRefCount != 0)
|
||||||
return FALSE;
|
return FALSE;
|
||||||
|
|
||||||
LoadStringW(hApplet, IDS_USERPROFILE_CONFIRM_DELETE_TITLE, szTitle, ARRAYSIZE(szTitle));
|
LoadStringW(hApplet, IDS_USERPROFILE_CONFIRM_DELETE_TITLE, szTitle, ARRAYSIZE(szTitle));
|
||||||
|
@ -462,13 +462,12 @@ static VOID
|
||||||
AddUserProfile(
|
AddUserProfile(
|
||||||
_In_ HWND hwndListView,
|
_In_ HWND hwndListView,
|
||||||
_In_ PSID pProfileSid,
|
_In_ PSID pProfileSid,
|
||||||
_In_ BOOL bMyProfile,
|
|
||||||
_In_ HKEY hProfileKey)
|
_In_ HKEY hProfileKey)
|
||||||
{
|
{
|
||||||
WCHAR szTempProfilePath[MAX_PATH], szProfilePath[MAX_PATH];
|
WCHAR szTempProfilePath[MAX_PATH], szProfilePath[MAX_PATH];
|
||||||
WCHAR szNameBuffer[256];
|
WCHAR szNameBuffer[256];
|
||||||
PPROFILEDATA pProfileData = NULL;
|
PPROFILEDATA pProfileData = NULL;
|
||||||
DWORD dwProfileData, dwSize, dwType, dwState = 0;
|
DWORD dwProfileData, dwSize, dwType, dwState = 0, dwRefCount = 0;
|
||||||
DWORD dwProfilePathLength;
|
DWORD dwProfilePathLength;
|
||||||
PWSTR ptr;
|
PWSTR ptr;
|
||||||
INT nId, iItem;
|
INT nId, iItem;
|
||||||
|
@ -534,6 +533,18 @@ AddUserProfile(
|
||||||
dwState = 0;
|
dwState = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Get the profile reference counter */
|
||||||
|
dwSize = sizeof(dwRefCount);
|
||||||
|
if (RegQueryValueExW(hProfileKey,
|
||||||
|
L"RefCount",
|
||||||
|
NULL,
|
||||||
|
&dwType,
|
||||||
|
(LPBYTE)&dwRefCount,
|
||||||
|
&dwSize) != ERROR_SUCCESS)
|
||||||
|
{
|
||||||
|
dwRefCount = 0;
|
||||||
|
}
|
||||||
|
|
||||||
/* Create and fill the profile data entry */
|
/* Create and fill the profile data entry */
|
||||||
dwProfileData = sizeof(PROFILEDATA) +
|
dwProfileData = sizeof(PROFILEDATA) +
|
||||||
((wcslen(szNameBuffer) + 1) * sizeof(WCHAR));
|
((wcslen(szNameBuffer) + 1) * sizeof(WCHAR));
|
||||||
|
@ -543,7 +554,7 @@ AddUserProfile(
|
||||||
if (pProfileData == NULL)
|
if (pProfileData == NULL)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
pProfileData->bMyProfile = bMyProfile;
|
pProfileData->dwRefCount = dwRefCount;
|
||||||
pProfileData->dwState = dwState;
|
pProfileData->dwState = dwState;
|
||||||
|
|
||||||
ptr = (PWSTR)((ULONG_PTR)pProfileData + sizeof(PROFILEDATA));
|
ptr = (PWSTR)((ULONG_PTR)pProfileData + sizeof(PROFILEDATA));
|
||||||
|
@ -607,7 +618,9 @@ UpdateButtonState(
|
||||||
{
|
{
|
||||||
LVITEM Item;
|
LVITEM Item;
|
||||||
INT iSelected;
|
INT iSelected;
|
||||||
BOOL bMyProfile;
|
BOOL bChange = FALSE;
|
||||||
|
BOOL bCopy = FALSE;
|
||||||
|
BOOL bDelete = FALSE;
|
||||||
|
|
||||||
iSelected = ListView_GetNextItem(hwndListView, -1, LVNI_SELECTED);
|
iSelected = ListView_GetNextItem(hwndListView, -1, LVNI_SELECTED);
|
||||||
if (iSelected != -1)
|
if (iSelected != -1)
|
||||||
|
@ -619,22 +632,23 @@ UpdateButtonState(
|
||||||
{
|
{
|
||||||
if (Item.lParam != 0)
|
if (Item.lParam != 0)
|
||||||
{
|
{
|
||||||
bMyProfile = ((PPROFILEDATA)Item.lParam)->bMyProfile;
|
bCopy = (((PPROFILEDATA)Item.lParam)->dwRefCount == 0);
|
||||||
if (!bMyProfile)
|
bDelete = (((PPROFILEDATA)Item.lParam)->dwRefCount == 0);
|
||||||
{
|
|
||||||
EnableWindow(GetDlgItem(hwndDlg, IDC_USERPROFILE_DELETE), TRUE);
|
|
||||||
EnableWindow(GetDlgItem(hwndDlg, IDC_USERPROFILE_COPY), TRUE);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
EnableWindow(GetDlgItem(hwndDlg, IDC_USERPROFILE_CHANGE), TRUE);
|
|
||||||
|
bChange = TRUE;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
EnableWindow(GetDlgItem(hwndDlg, IDC_USERPROFILE_CHANGE), FALSE);
|
bChange = FALSE;
|
||||||
EnableWindow(GetDlgItem(hwndDlg, IDC_USERPROFILE_DELETE), FALSE);
|
bCopy = FALSE;
|
||||||
EnableWindow(GetDlgItem(hwndDlg, IDC_USERPROFILE_COPY), FALSE);
|
bDelete = FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
EnableWindow(GetDlgItem(hwndDlg, IDC_USERPROFILE_CHANGE), bChange);
|
||||||
|
EnableWindow(GetDlgItem(hwndDlg, IDC_USERPROFILE_DELETE), bDelete);
|
||||||
|
EnableWindow(GetDlgItem(hwndDlg, IDC_USERPROFILE_COPY), bCopy);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -702,7 +716,6 @@ AddUserProfiles(
|
||||||
{
|
{
|
||||||
AddUserProfile(hwndListView,
|
AddUserProfile(hwndListView,
|
||||||
pProfileSid,
|
pProfileSid,
|
||||||
EqualSid(pProfileSid, pTokenUser->User.Sid),
|
|
||||||
hProfileKey);
|
hProfileKey);
|
||||||
LocalFree(pProfileSid);
|
LocalFree(pProfileSid);
|
||||||
}
|
}
|
||||||
|
@ -723,7 +736,6 @@ AddUserProfiles(
|
||||||
{
|
{
|
||||||
AddUserProfile(hwndListView,
|
AddUserProfile(hwndListView,
|
||||||
pTokenUser->User.Sid,
|
pTokenUser->User.Sid,
|
||||||
TRUE,
|
|
||||||
hProfileKey);
|
hProfileKey);
|
||||||
RegCloseKey(hProfileKey);
|
RegCloseKey(hProfileKey);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue