[SYSDM] Store the profile path in the PROFILEDATA struct for deleting and copying the profiles

This commit is contained in:
Eric Kohl 2019-09-16 08:51:08 +02:00
parent 9b75b67e9d
commit 95dd1c6705

View file

@ -19,14 +19,15 @@ typedef struct _PROFILEDATA
DWORD dwRefCount; DWORD dwRefCount;
DWORD dwState; DWORD dwState;
PWSTR pszFullName; PWSTR pszFullName;
PWSTR pszProfilePath;
} PROFILEDATA, *PPROFILEDATA; } PROFILEDATA, *PPROFILEDATA;
static static
BOOL BOOL
OnProfileTypeInit( OnProfileTypeInit(
HWND hwndDlg, _In_ HWND hwndDlg,
PPROFILEDATA pProfileData) _In_ PPROFILEDATA pProfileData)
{ {
PWSTR pszRawBuffer = NULL, pszCookedBuffer = NULL; PWSTR pszRawBuffer = NULL, pszCookedBuffer = NULL;
INT nLength; INT nLength;
@ -326,8 +327,8 @@ SetListViewColumns(
static static
BOOL BOOL
GetProfileSize( GetProfileSize(
PWSTR pszProfilePath, _In_ PWSTR pszProfilePath,
PULONGLONG pullProfileSize) _Inout_ PULONGLONG pullProfileSize)
{ {
HANDLE hFile = INVALID_HANDLE_VALUE; HANDLE hFile = INVALID_HANDLE_VALUE;
WIN32_FIND_DATA FindData; WIN32_FIND_DATA FindData;
@ -433,7 +434,9 @@ GetProfileName(
static static
VOID VOID
FormatProfileSize(LPWSTR Buffer, double size) FormatProfileSize(
_Out_ LPWSTR Buffer,
_In_ double size)
{ {
const LPWSTR units[] = {L"MB", L"GB", L"TB"}; const LPWSTR units[] = {L"MB", L"GB", L"TB"};
int i = 0, j; int i = 0, j;
@ -547,7 +550,8 @@ AddUserProfile(
/* 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)) +
((wcslen(szProfilePath) + 1) * sizeof(WCHAR));
pProfileData = HeapAlloc(GetProcessHeap(), pProfileData = HeapAlloc(GetProcessHeap(),
HEAP_ZERO_MEMORY, HEAP_ZERO_MEMORY,
dwProfileData); dwProfileData);
@ -562,6 +566,10 @@ AddUserProfile(
wcscpy(pProfileData->pszFullName, szNameBuffer); wcscpy(pProfileData->pszFullName, szNameBuffer);
ptr = (PWSTR)((ULONG_PTR)ptr + ((wcslen(pProfileData->pszFullName) + 1) * sizeof(WCHAR)));
pProfileData->pszProfilePath = ptr;
wcscpy(pProfileData->pszProfilePath, szProfilePath);
/* Add the profile and set its name */ /* Add the profile and set its name */
memset(&lvi, 0x00, sizeof(lvi)); memset(&lvi, 0x00, sizeof(lvi));
lvi.mask = LVIF_TEXT | LVIF_STATE | LVIF_PARAM; lvi.mask = LVIF_TEXT | LVIF_STATE | LVIF_PARAM;