ReactOS  0.4.14-dev-50-g13bb5e2
userprofile.c File Reference
#include "precomp.h"
#include <sddl.h>
#include <winnls.h>
#include <debug.h>
Include dependency graph for userprofile.c:

Go to the source code of this file.

Classes

struct  _PROFILEDATA
 

Typedefs

typedef struct _PROFILEDATA PROFILEDATA
 
typedef struct _PROFILEDATAPPROFILEDATA
 

Functions

static BOOL OnProfileTypeInit (_In_ HWND hwndDlg, _In_ PPROFILEDATA pProfileData)
 
static INT_PTR CALLBACK UserProfileTypeDlgProc (_In_ HWND hwndDlg, _In_ UINT uMsg, _In_ WPARAM wParam, _In_ LPARAM lParam)
 
static BOOL ChangeUserProfileType (_In_ HWND hwndDlg)
 
static BOOL DeleteUserProfile (_In_ HWND hwndDlg)
 
static INT_PTR CALLBACK CopyUserProfileDlgProc (_In_ HWND hwndDlg, _In_ UINT uMsg, _In_ WPARAM wParam, _In_ LPARAM lParam)
 
static BOOL CopyUserProfile (_In_ HWND hwndDlg)
 
static VOID SetListViewColumns (_In_ HWND hwndListView)
 
static BOOL GetProfileSize (_In_ PWSTR pszProfilePath, _Inout_ PULONGLONG pullProfileSize)
 
static BOOL GetProfileName (_In_ PSID pProfileSid, _In_ DWORD dwNameBufferSize, _Out_ PWSTR pszNameBuffer)
 
static VOID FormatProfileSize (_Out_ LPWSTR Buffer, _In_ double size)
 
static VOID AddUserProfile (_In_ HWND hwndListView, _In_ PSID pProfileSid, _In_ HKEY hProfileKey)
 
static VOID UpdateButtonState (_In_ HWND hwndDlg, _In_ HWND hwndListView)
 
static VOID AddUserProfiles (_In_ HWND hwndDlg, _In_ HWND hwndListView, _In_ BOOL bAdmin)
 
static VOID OnInitUserProfileDialog (HWND hwndDlg)
 
static VOID OnDestroy (_In_ HWND hwndDlg)
 
static VOID OnNotify (_In_ HWND hwndDlg, _In_ NMHDR *nmhdr)
 
INT_PTR CALLBACK UserProfileDlgProc (HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
 

Typedef Documentation

◆ PPROFILEDATA

◆ PROFILEDATA

Function Documentation

◆ AddUserProfile()

static VOID AddUserProfile ( _In_ HWND  hwndListView,
_In_ PSID  pProfileSid,
_In_ HKEY  hProfileKey 
)
static

Definition at line 465 of file userprofile.c.

469 {
470  WCHAR szTempProfilePath[MAX_PATH], szProfilePath[MAX_PATH];
471  WCHAR szNameBuffer[256];
472  PPROFILEDATA pProfileData = NULL;
473  DWORD dwProfileData, dwSize, dwType, dwState = 0, dwRefCount = 0;
474  DWORD dwProfilePathLength;
475  PWSTR ptr;
476  INT nId, iItem;
477  LV_ITEM lvi;
478  WIN32_FIND_DATA FindData;
479  HANDLE hFile;
480  SYSTEMTIME SystemTime;
481  ULONGLONG ullProfileSize;
482  DWORD dwError;
483 
484  /* Get the profile path */
485  dwSize = MAX_PATH * sizeof(WCHAR);
486  dwError = RegQueryValueExW(hProfileKey,
487  L"ProfileImagePath",
488  NULL,
489  &dwType,
490  (LPBYTE)szTempProfilePath,
491  &dwSize);
492  if (dwError != ERROR_SUCCESS)
493  return;
494 
495  /* Expand it */
496  ExpandEnvironmentStringsW(szTempProfilePath,
497  szProfilePath,
498  MAX_PATH);
499 
500  /* Check if the profile path exists */
501  hFile = FindFirstFileW(szProfilePath, &FindData);
503  return;
504 
505  FindClose(hFile);
506 
507  /* Get the length of the profile path */
508  dwProfilePathLength = wcslen(szProfilePath);
509 
510  /* Check for the ntuser.dat file */
511  wcscat(szProfilePath, L"\\ntuser.dat");
512  hFile = FindFirstFileW(szProfilePath, &FindData);
514  return;
515 
516  FindClose(hFile);
517  szProfilePath[dwProfilePathLength] = UNICODE_NULL;
518 
519  /* Get the profile size */
520  ullProfileSize = 0ULL;
521  GetProfileSize(szProfilePath, &ullProfileSize);
522 
523  /* Get the profile name */
524  if (!GetProfileName(pProfileSid, ARRAYSIZE(szNameBuffer), szNameBuffer))
525  return;
526 
527  /* Get the profile state value */
528  dwSize = sizeof(dwState);
529  if (RegQueryValueExW(hProfileKey,
530  L"State",
531  NULL,
532  &dwType,
533  (LPBYTE)&dwState,
534  &dwSize) != ERROR_SUCCESS)
535  {
536  dwState = 0;
537  }
538 
539  /* Get the profile reference counter */
540  dwSize = sizeof(dwRefCount);
541  if (RegQueryValueExW(hProfileKey,
542  L"RefCount",
543  NULL,
544  &dwType,
545  (LPBYTE)&dwRefCount,
546  &dwSize) != ERROR_SUCCESS)
547  {
548  dwRefCount = 0;
549  }
550 
551  /* Create and fill the profile data entry */
552  dwProfileData = sizeof(PROFILEDATA) +
553  ((wcslen(szNameBuffer) + 1) * sizeof(WCHAR)) +
554  ((wcslen(szProfilePath) + 1) * sizeof(WCHAR));
555  pProfileData = HeapAlloc(GetProcessHeap(),
557  dwProfileData);
558  if (pProfileData == NULL)
559  return;
560 
561  pProfileData->dwRefCount = dwRefCount;
562  pProfileData->dwState = dwState;
563 
564  ptr = (PWSTR)((ULONG_PTR)pProfileData + sizeof(PROFILEDATA));
565  pProfileData->pszFullName = ptr;
566 
567  wcscpy(pProfileData->pszFullName, szNameBuffer);
568 
569  ptr = (PWSTR)((ULONG_PTR)ptr + ((wcslen(pProfileData->pszFullName) + 1) * sizeof(WCHAR)));
570  pProfileData->pszProfilePath = ptr;
571  wcscpy(pProfileData->pszProfilePath, szProfilePath);
572 
573  /* Add the profile and set its name */
574  memset(&lvi, 0x00, sizeof(lvi));
575  lvi.mask = LVIF_TEXT | LVIF_STATE | LVIF_PARAM;
576  lvi.pszText = pProfileData->pszFullName;
577  lvi.state = 0;
578  lvi.lParam = (LPARAM)pProfileData;
579  iItem = ListView_InsertItem(hwndListView, &lvi);
580 
581  /* Set the profile size */
582  FormatProfileSize(szNameBuffer, (double)ullProfileSize);
583  ListView_SetItemText(hwndListView, iItem, 1, szNameBuffer);
584 
585  /* Set the profile type */
586  if (dwState & 0x0010) // PROFILE_UPDATE_CENTRAL
588  else
589  nId = IDS_USERPROFILE_LOCAL;
590 
591  LoadStringW(hApplet, nId, szNameBuffer, ARRAYSIZE(szNameBuffer));
592 
593  ListView_SetItemText(hwndListView, iItem, 2, szNameBuffer);
594 
595  /* FIXME: Set the profile status */
596  if (dwState & 0x0001) // PROFILE_MANDATORY
598  else if (dwState & 0x0010) // PROFILE_UPDATE_CENTRAL
600  else
601  nId = IDS_USERPROFILE_LOCAL;
602 
603  LoadStringW(hApplet, nId, szNameBuffer, ARRAYSIZE(szNameBuffer));
604 
605  ListView_SetItemText(hwndListView, iItem, 3, szNameBuffer);
606 
607  /* Set the profile modified time */
608  FileTimeToSystemTime(&FindData.ftLastWriteTime,
609  &SystemTime);
610 
613  &SystemTime,
614  NULL,
615  szNameBuffer,
616  ARRAYSIZE(szNameBuffer));
617 
618  ListView_SetItemText(hwndListView, iItem, 4, szNameBuffer);
619 }
#define LV_ITEM
Definition: commctrl.h:2309
static BOOL GetProfileName(_In_ PSID pProfileSid, _In_ DWORD dwNameBufferSize, _Out_ PWSTR pszNameBuffer)
Definition: userprofile.c:391
#define ERROR_SUCCESS
Definition: deptool.c:10
uint16_t * PWSTR
Definition: typedefs.h:54
#define LOCALE_USER_DEFAULT
#define DATE_SHORTDATE
Definition: winnls.h:193
#define ARRAYSIZE(array)
Definition: filtermapper.c:47
#define INVALID_HANDLE_VALUE
Definition: compat.h:391
HINSTANCE hApplet
Definition: access.c:17
#define ListView_InsertItem(hwnd, pitem)
Definition: commctrl.h:2380
DWORD dwRefCount
Definition: userprofile.c:19
int WINAPI LoadStringW(_In_opt_ HINSTANCE hInstance, _In_ UINT uID, _Out_writes_to_(cchBufferMax, return+1) LPWSTR lpBuffer, _In_ int cchBufferMax)
int32_t INT
Definition: typedefs.h:56
#define IDS_USERPROFILE_MANDATORY
Definition: resource.h:38
uint32_t ULONG_PTR
Definition: typedefs.h:63
#define LVIF_TEXT
Definition: commctrl.h:2281
static VOID FormatProfileSize(_Out_ LPWSTR Buffer, _In_ double size)
Definition: userprofile.c:437
unsigned char * LPBYTE
Definition: typedefs.h:52
#define UNICODE_NULL
#define IDS_USERPROFILE_ROAMING
Definition: resource.h:37
static PVOID ptr
Definition: dispmode.c:27
HWND hwndListView
Definition: eventvwr.c:83
smooth NULL
Definition: ftsmooth.c:416
LONG_PTR LPARAM
Definition: windef.h:208
#define ULL(a, b)
Definition: format_msg.c:27
#define ListView_SetItemText(hwndLV, i, iSubItem_, pszText_)
Definition: commctrl.h:2663
BOOL WINAPI FileTimeToSystemTime(IN CONST FILETIME *lpFileTime, OUT LPSYSTEMTIME lpSystemTime)
Definition: time.c:178
#define GetProcessHeap()
Definition: compat.h:395
PVOID WINAPI HeapAlloc(HANDLE, DWORD, SIZE_T)
LONG WINAPI RegQueryValueExW(_In_ HKEY hkeyorg, _In_ LPCWSTR name, _In_ LPDWORD reserved, _In_ LPDWORD type, _In_ LPBYTE data, _In_ LPDWORD count)
Definition: reg.c:4116
__wchar_t WCHAR
Definition: xmlstorage.h:180
uint64_t ULONGLONG
Definition: typedefs.h:65
#define MAX_PATH
Definition: compat.h:26
struct _PROFILEDATA PROFILEDATA
unsigned long DWORD
Definition: ntddk_ex.h:95
_CRTIMP wchar_t *__cdecl wcscpy(_Out_writes_z_(_String_length_(_Source)+1) wchar_t *_Dest, _In_z_ const wchar_t *_Source)
static const WCHAR L[]
Definition: oid.c:1250
_In_ HANDLE hFile
Definition: mswsock.h:90
INT WINAPI GetDateFormatW(LCID lcid, DWORD dwFlags, const SYSTEMTIME *lpTime, LPCWSTR lpFormat, LPWSTR lpDateStr, INT cchOut)
Definition: lcformat.c:979
PWSTR pszFullName
Definition: userprofile.c:21
_CRTIMP wchar_t *__cdecl wcscat(_Inout_updates_z_(_String_length_(_Dest)+_String_length_(_Source)+1) wchar_t *_Dest, _In_z_ const wchar_t *_Source)
DWORD WINAPI ExpandEnvironmentStringsW(IN LPCWSTR lpSrc, IN LPWSTR lpDst, IN DWORD nSize)
Definition: environ.c:519
#define HEAP_ZERO_MEMORY
Definition: compat.h:123
DWORD dwState
Definition: userprofile.c:20
static BOOL GetProfileSize(_In_ PWSTR pszProfilePath, _Inout_ PULONGLONG pullProfileSize)
Definition: userprofile.c:329
#define LVIF_PARAM
Definition: commctrl.h:2283
#define LVIF_STATE
Definition: commctrl.h:2284
#define memset(x, y, z)
Definition: compat.h:39
#define IDS_USERPROFILE_LOCAL
Definition: resource.h:36
size_t __cdecl wcslen(_In_z_ const wchar_t *_Str)
PSDBQUERYRESULT_VISTA PVOID DWORD * dwSize
Definition: env.c:54
PWSTR pszProfilePath
Definition: userprofile.c:22
HANDLE WINAPI FindFirstFileW(IN LPCWSTR lpFileName, OUT LPWIN32_FIND_DATAW lpFindFileData)
Definition: find.c:320
BOOL WINAPI FindClose(HANDLE hFindFile)
Definition: find.c:502

Referenced by AddUserProfiles().

◆ AddUserProfiles()

static VOID AddUserProfiles ( _In_ HWND  hwndDlg,
_In_ HWND  hwndListView,
_In_ BOOL  bAdmin 
)
static

Definition at line 664 of file userprofile.c.

668 {
669  HKEY hKeyUserProfiles = INVALID_HANDLE_VALUE;
670  HKEY hProfileKey;
671  DWORD dwIndex;
672  WCHAR szProfileSid[64];
673  DWORD dwSidLength;
674  FILETIME ftLastWrite;
675  DWORD dwSize;
676  HANDLE hToken = NULL;
677  PTOKEN_USER pTokenUser = NULL;
678  PSID pProfileSid;
679  PWSTR pszProfileSid;
680 
682  return;
683 
684  GetTokenInformation(hToken, TokenUser, NULL, 0, &dwSize);
685  if (dwSize == 0)
686  goto done;
687 
688  pTokenUser = HeapAlloc(GetProcessHeap(), 0, dwSize);
689  if (pTokenUser == NULL)
690  goto done;
691 
692  if (!GetTokenInformation(hToken, TokenUser, pTokenUser, dwSize, &dwSize))
693  goto done;
694 
696  L"Software\\Microsoft\\Windows NT\\CurrentVersion\\ProfileList",
697  0,
698  KEY_READ,
699  &hKeyUserProfiles))
700  goto done;
701 
702  if (bAdmin)
703  {
704  for (dwIndex = 0; ; dwIndex++)
705  {
706  dwSidLength = ARRAYSIZE(szProfileSid);
707  if (RegEnumKeyExW(hKeyUserProfiles,
708  dwIndex,
709  szProfileSid,
710  &dwSidLength,
711  NULL,
712  NULL,
713  NULL,
714  &ftLastWrite))
715  break;
716 
717  if (RegOpenKeyExW(hKeyUserProfiles,
718  szProfileSid,
719  0,
720  KEY_READ,
721  &hProfileKey) == ERROR_SUCCESS)
722  {
723  if (ConvertStringSidToSid(szProfileSid, &pProfileSid))
724  {
726  pProfileSid,
727  hProfileKey);
728  LocalFree(pProfileSid);
729  }
730 
731  RegCloseKey(hProfileKey);
732  }
733  }
734  }
735  else
736  {
737  if (ConvertSidToStringSidW(pTokenUser->User.Sid, &pszProfileSid))
738  {
739  if (RegOpenKeyExW(hKeyUserProfiles,
740  pszProfileSid,
741  0,
742  KEY_READ,
743  &hProfileKey) == ERROR_SUCCESS)
744  {
746  pTokenUser->User.Sid,
747  hProfileKey);
748  RegCloseKey(hProfileKey);
749  }
750 
751  LocalFree(pszProfileSid);
752  }
753  }
754 
757 
759 
760 done:
761  if (hKeyUserProfiles != INVALID_HANDLE_VALUE)
762  RegCloseKey(hKeyUserProfiles);
763 
764  if (pTokenUser != NULL)
765  HeapFree(GetProcessHeap(), 0, pTokenUser);
766 
767  if (hToken != NULL)
768  CloseHandle(hToken);
769 }
#define CloseHandle
Definition: compat.h:398
#define ERROR_SUCCESS
Definition: deptool.c:10
#define KEY_READ
Definition: nt_native.h:1023
uint16_t * PWSTR
Definition: typedefs.h:54
#define ConvertStringSidToSid
Definition: sddl.h:161
#define ARRAYSIZE(array)
Definition: filtermapper.c:47
#define INVALID_HANDLE_VALUE
Definition: compat.h:391
static VOID AddUserProfile(_In_ HWND hwndListView, _In_ PSID pProfileSid, _In_ HKEY hProfileKey)
Definition: userprofile.c:465
BOOL WINAPI ConvertSidToStringSidW(PSID Sid, LPWSTR *StringSid)
Definition: security.c:3259
LONG WINAPI RegCloseKey(HKEY hKey)
Definition: reg.c:423
#define ListView_SetItemState(hwndLV, i, data, mask)
Definition: commctrl.h:2645
HWND hwndListView
Definition: eventvwr.c:83
smooth NULL
Definition: ftsmooth.c:416
#define LVIS_SELECTED
Definition: commctrl.h:2291
#define ListView_GetItemCount(hwnd)
Definition: commctrl.h:2279
#define GetProcessHeap()
Definition: compat.h:395
PVOID WINAPI HeapAlloc(HANDLE, DWORD, SIZE_T)
#define TOKEN_QUERY
Definition: setypes.h:874
__wchar_t WCHAR
Definition: xmlstorage.h:180
HANDLE WINAPI GetCurrentProcess(VOID)
Definition: proc.c:1138
unsigned long DWORD
Definition: ntddk_ex.h:95
static const WCHAR L[]
Definition: oid.c:1250
HLOCAL NTAPI LocalFree(HLOCAL hMem)
Definition: heapmem.c:1577
BOOL WINAPI OpenProcessToken(HANDLE ProcessHandle, DWORD DesiredAccess, PHANDLE TokenHandle)
Definition: security.c:296
BOOL WINAPI GetTokenInformation(HANDLE TokenHandle, TOKEN_INFORMATION_CLASS TokenInformationClass, LPVOID TokenInformation, DWORD TokenInformationLength, PDWORD ReturnLength)
Definition: security.c:413
LONG WINAPI RegOpenKeyExW(HKEY hKey, LPCWSTR lpSubKey, DWORD ulOptions, REGSAM samDesired, PHKEY phkResult)
Definition: reg.c:3366
SID_AND_ATTRIBUTES User
Definition: setypes.h:956
LONG WINAPI RegEnumKeyExW(_In_ HKEY hKey, _In_ DWORD dwIndex, _Out_ LPWSTR lpName, _Inout_ LPDWORD lpcbName, _Reserved_ LPDWORD lpReserved, _Out_opt_ LPWSTR lpClass, _Inout_opt_ LPDWORD lpcbClass, _Out_opt_ PFILETIME lpftLastWriteTime)
Definition: reg.c:2527
#define HeapFree(x, y, z)
Definition: compat.h:394
PSDBQUERYRESULT_VISTA PVOID DWORD * dwSize
Definition: env.c:54
#define LVIS_FOCUSED
Definition: commctrl.h:2290
static VOID UpdateButtonState(_In_ HWND hwndDlg, _In_ HWND hwndListView)
Definition: userprofile.c:623
#define HKEY_LOCAL_MACHINE
Definition: winreg.h:12

Referenced by OnInitUserProfileDialog().

◆ ChangeUserProfileType()

static BOOL ChangeUserProfileType ( _In_ HWND  hwndDlg)
static

Definition at line 107 of file userprofile.c.

109 {
111  LVITEM Item;
112  INT iSelected;
113 
114  DPRINT("ChangeUserProfileType(%p)\n", hwndDlg);
115 
117  if (hwndListView == NULL)
118  return FALSE;
119 
121  if (iSelected == -1)
122  return FALSE;
123 
124  ZeroMemory(&Item, sizeof(LVITEM));
125  Item.mask = LVIF_PARAM;
126  Item.iItem = iSelected;
127  Item.iSubItem = 0;
128  if (!ListView_GetItem(hwndListView, &Item))
129  return FALSE;
130 
131  if (Item.lParam == 0)
132  return FALSE;
133 
136  hwndDlg,
138  (LPARAM)Item.lParam) == IDOK)
139  {
140  /* FIXME: Update the profile list view */
141  return TRUE;
142  }
143 
144  return FALSE;
145 }
#define MAKEINTRESOURCE
Definition: winuser.h:591
#define ListView_GetNextItem(hwnd, i, flags)
Definition: commctrl.h:2406
#define TRUE
Definition: types.h:120
#define IDOK
Definition: winuser.h:824
static INT_PTR CALLBACK UserProfileTypeDlgProc(_In_ HWND hwndDlg, _In_ UINT uMsg, _In_ WPARAM wParam, _In_ LPARAM lParam)
Definition: userprofile.c:74
#define IDC_USERPROFILE_LIST
Definition: resource.h:101
#define ZeroMemory
Definition: winbase.h:1635
HINSTANCE hApplet
Definition: access.c:17
#define LVNI_SELECTED
Definition: commctrl.h:2396
int32_t INT
Definition: typedefs.h:56
HWND hwndListView
Definition: eventvwr.c:83
smooth NULL
Definition: ftsmooth.c:416
#define IDD_USERPROFILE_TYPE
Definition: resource.h:108
LONG_PTR LPARAM
Definition: windef.h:208
void DPRINT(...)
Definition: polytest.cpp:61
HWND WINAPI GetDlgItem(_In_opt_ HWND, _In_ int)
#define DialogBoxParam
Definition: winuser.h:5665
#define ListView_GetItem(hwnd, pitem)
Definition: commctrl.h:2366
#define LVIF_PARAM
Definition: commctrl.h:2283
#define LVITEM
Definition: commctrl.h:2347

Referenced by UserProfileDlgProc().

◆ CopyUserProfile()

static BOOL CopyUserProfile ( _In_ HWND  hwndDlg)
static

Definition at line 235 of file userprofile.c.

237 {
239  LVITEM Item;
240  INT iSelected;
241 
242  DPRINT("CopyUserProfile()\n");
243 
245  if (hwndListView == NULL)
246  return FALSE;
247 
249  if (iSelected == -1)
250  return FALSE;
251 
252  ZeroMemory(&Item, sizeof(LVITEM));
253  Item.mask = LVIF_PARAM;
254  Item.iItem = iSelected;
255  Item.iSubItem = 0;
256  if (!ListView_GetItem(hwndListView, &Item))
257  return FALSE;
258 
259  if (Item.lParam == 0)
260  return FALSE;
261 
264  hwndDlg,
266  (LPARAM)Item.lParam) == IDOK)
267  {
268  /* FIXME: Update the profile list view */
269  return TRUE;
270  }
271 
272  return FALSE;
273 }
#define MAKEINTRESOURCE
Definition: winuser.h:591
#define ListView_GetNextItem(hwnd, i, flags)
Definition: commctrl.h:2406
#define TRUE
Definition: types.h:120
#define IDOK
Definition: winuser.h:824
#define IDC_USERPROFILE_LIST
Definition: resource.h:101
#define ZeroMemory
Definition: winbase.h:1635
HINSTANCE hApplet
Definition: access.c:17
#define LVNI_SELECTED
Definition: commctrl.h:2396
int32_t INT
Definition: typedefs.h:56
#define IDD_USERPROFILE_COPY
Definition: resource.h:114
HWND hwndListView
Definition: eventvwr.c:83
smooth NULL
Definition: ftsmooth.c:416
LONG_PTR LPARAM
Definition: windef.h:208
void DPRINT(...)
Definition: polytest.cpp:61
HWND WINAPI GetDlgItem(_In_opt_ HWND, _In_ int)
#define DialogBoxParam
Definition: winuser.h:5665
#define ListView_GetItem(hwnd, pitem)
Definition: commctrl.h:2366
#define LVIF_PARAM
Definition: commctrl.h:2283
#define LVITEM
Definition: commctrl.h:2347
static INT_PTR CALLBACK CopyUserProfileDlgProc(_In_ HWND hwndDlg, _In_ UINT uMsg, _In_ WPARAM wParam, _In_ LPARAM lParam)
Definition: userprofile.c:203

Referenced by UserProfileDlgProc().

◆ CopyUserProfileDlgProc()

static INT_PTR CALLBACK CopyUserProfileDlgProc ( _In_ HWND  hwndDlg,
_In_ UINT  uMsg,
_In_ WPARAM  wParam,
_In_ LPARAM  lParam 
)
static

Definition at line 203 of file userprofile.c.

208 {
209  switch (uMsg)
210  {
211  case WM_INITDIALOG:
212  return TRUE;
213 
214  case WM_DESTROY:
215  break;
216 
217  case WM_COMMAND:
218  switch (LOWORD(wParam))
219  {
220  case IDOK:
221  case IDCANCEL:
222  EndDialog(hwndDlg,
223  LOWORD(wParam));
224  return TRUE;
225  }
226  break;
227  }
228 
229  return FALSE;
230 }
#define TRUE
Definition: types.h:120
#define IDOK
Definition: winuser.h:824
BOOL WINAPI EndDialog(_In_ HWND, _In_ INT_PTR)
WPARAM wParam
Definition: combotst.c:138
#define WM_DESTROY
Definition: winuser.h:1591
#define WM_COMMAND
Definition: winuser.h:1722
#define IDCANCEL
Definition: winuser.h:825
#define WM_INITDIALOG
Definition: winuser.h:1721
#define LOWORD(l)
Definition: pedump.c:82

Referenced by CopyUserProfile().

◆ DeleteUserProfile()

static BOOL DeleteUserProfile ( _In_ HWND  hwndDlg)
static

Definition at line 150 of file userprofile.c.

152 {
153  WCHAR szTitle[64], szRawText[128], szCookedText[256];
155  LVITEM Item;
156  INT iSelected;
157  PPROFILEDATA pProfileData;
158 
159  DPRINT("DeleteUserProfile()\n");
160 
162  if (hwndListView == NULL)
163  return FALSE;
164 
166  if (iSelected == -1)
167  return FALSE;
168 
169  ZeroMemory(&Item, sizeof(LVITEM));
170  Item.mask = LVIF_PARAM;
171  Item.iItem = iSelected;
172  Item.iSubItem = 0;
173  if (!ListView_GetItem(hwndListView, &Item))
174  return FALSE;
175 
176  if (Item.lParam == 0)
177  return FALSE;
178 
179  pProfileData = (PPROFILEDATA)Item.lParam;
180  if (pProfileData->dwRefCount != 0)
181  return FALSE;
182 
185  swprintf(szCookedText, szRawText, pProfileData->pszFullName);
186 
187  if (MessageBoxW(hwndDlg,
188  szCookedText,
189  szTitle,
191  {
192  /* FIXME: Delete the profile here! */
193  return TRUE;
194  }
195 
196  return FALSE;
197 }
#define ListView_GetNextItem(hwnd, i, flags)
Definition: commctrl.h:2406
#define TRUE
Definition: types.h:120
#define IDYES
Definition: winuser.h:829
#define IDC_USERPROFILE_LIST
Definition: resource.h:101
#define ARRAYSIZE(array)
Definition: filtermapper.c:47
#define ZeroMemory
Definition: winbase.h:1635
HINSTANCE hApplet
Definition: access.c:17
#define LVNI_SELECTED
Definition: commctrl.h:2396
DWORD dwRefCount
Definition: userprofile.c:19
int WINAPI LoadStringW(_In_opt_ HINSTANCE hInstance, _In_ UINT uID, _Out_writes_to_(cchBufferMax, return+1) LPWSTR lpBuffer, _In_ int cchBufferMax)
int32_t INT
Definition: typedefs.h:56
#define MB_YESNO
Definition: winuser.h:811
#define IDS_USERPROFILE_CONFIRM_DELETE
Definition: resource.h:39
HWND hwndListView
Definition: eventvwr.c:83
smooth NULL
Definition: ftsmooth.c:416
#define MB_ICONQUESTION
Definition: winuser.h:783
void DPRINT(...)
Definition: polytest.cpp:61
int WINAPI MessageBoxW(_In_opt_ HWND, _In_opt_ LPCWSTR, _In_opt_ LPCWSTR, _In_ UINT)
if(!(yy_init))
Definition: macro.lex.yy.c:714
HWND WINAPI GetDlgItem(_In_opt_ HWND, _In_ int)
__wchar_t WCHAR
Definition: xmlstorage.h:180
struct _PROFILEDATA * PPROFILEDATA
#define swprintf(buf, format,...)
Definition: sprintf.c:56
TCHAR szTitle[MAX_LOADSTRING]
Definition: magnifier.c:35
#define IDS_USERPROFILE_CONFIRM_DELETE_TITLE
Definition: resource.h:40
PWSTR pszFullName
Definition: userprofile.c:21
#define ListView_GetItem(hwnd, pitem)
Definition: commctrl.h:2366
#define LVIF_PARAM
Definition: commctrl.h:2283
#define LVITEM
Definition: commctrl.h:2347

Referenced by UserProfileDlgProc().

◆ FormatProfileSize()

static VOID FormatProfileSize ( _Out_ LPWSTR  Buffer,
_In_ double  size 
)
static

Definition at line 437 of file userprofile.c.

440 {
441  const LPWSTR units[] = {L"MB", L"GB", L"TB"};
442  int i = 0, j;
443 
444  size /= 1024;
445  size /= 1024;
446 
447  while (size >= 1024 && i < 3)
448  {
449  size /= 1024;
450  i++;
451  }
452 
453  if (size < 10)
454  j = 2;
455  else if (size < 100)
456  j = 1;
457  else
458  j = 0;
459 
460  swprintf(Buffer, L"%.*f %s", j, size, units[i]);
461 }
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
Definition: bufpool.h:45
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint GLint GLint j
Definition: glfuncs.h:250
GLsizeiptr size
Definition: glext.h:5919
#define swprintf(buf, format,...)
Definition: sprintf.c:56
static const WCHAR L[]
Definition: oid.c:1250
WCHAR * LPWSTR
Definition: xmlstorage.h:184
GLfloat units
Definition: glext.h:11727

Referenced by AddUserProfile().

◆ GetProfileName()

static BOOL GetProfileName ( _In_ PSID  pProfileSid,
_In_ DWORD  dwNameBufferSize,
_Out_ PWSTR  pszNameBuffer 
)
static

Definition at line 391 of file userprofile.c.

395 {
396  WCHAR szAccountName[128], szDomainName[128];
397  DWORD dwAccountNameSize, dwDomainNameSize;
398  SID_NAME_USE Use;
399 
400  dwAccountNameSize = ARRAYSIZE(szAccountName);
401  dwDomainNameSize = ARRAYSIZE(szDomainName);
402  if (!LookupAccountSidW(NULL,
403  pProfileSid,
404  szAccountName,
405  &dwAccountNameSize,
406  szDomainName,
407  &dwDomainNameSize,
408  &Use))
409  {
410  /* Unknown account */
411  LoadStringW(hApplet, IDS_USERPROFILE_ACCOUNT_UNKNOWN, pszNameBuffer, dwNameBufferSize);
412  }
413  else
414  {
415  /* Show only the user accounts */
416  if (Use != SidTypeUser)
417  return FALSE;
418 
419  if (szAccountName[0] == UNICODE_NULL)
420  {
421  /* Deleted account */
422  LoadStringW(hApplet, IDS_USERPROFILE_ACCOUNT_DELETED, pszNameBuffer, dwNameBufferSize);
423  }
424  else
425  {
426  /* Normal account */
427  wsprintf(pszNameBuffer, L"%s\\%s", szDomainName, szAccountName);
428  }
429  }
430 
431  return TRUE;
432 }
#define TRUE
Definition: types.h:120
enum _SID_NAME_USE SID_NAME_USE
#define ARRAYSIZE(array)
Definition: filtermapper.c:47
HINSTANCE hApplet
Definition: access.c:17
int WINAPI LoadStringW(_In_opt_ HINSTANCE hInstance, _In_ UINT uID, _Out_writes_to_(cchBufferMax, return+1) LPWSTR lpBuffer, _In_ int cchBufferMax)
#define UNICODE_NULL
smooth NULL
Definition: ftsmooth.c:416
BOOL WINAPI LookupAccountSidW(LPCWSTR pSystemName, PSID pSid, LPWSTR pAccountName, LPDWORD pdwAccountName, LPWSTR pDomainName, LPDWORD pdwDomainName, PSID_NAME_USE peUse)
Definition: misc.c:537
#define IDS_USERPROFILE_ACCOUNT_DELETED
Definition: resource.h:42
__wchar_t WCHAR
Definition: xmlstorage.h:180
#define IDS_USERPROFILE_ACCOUNT_UNKNOWN
Definition: resource.h:41
unsigned long DWORD
Definition: ntddk_ex.h:95
static const WCHAR L[]
Definition: oid.c:1250
#define wsprintf
Definition: winuser.h:5766

Referenced by AddUserProfile().

◆ GetProfileSize()

static BOOL GetProfileSize ( _In_ PWSTR  pszProfilePath,
_Inout_ PULONGLONG  pullProfileSize 
)
static

Definition at line 329 of file userprofile.c.

332 {
334  WIN32_FIND_DATA FindData;
335  DWORD dwProfilePathLength;
337  BOOL bResult = TRUE;
338 
339  dwProfilePathLength = wcslen(pszProfilePath);
340 
341  wcscat(pszProfilePath, L"\\*.*");
342 
343  hFile = FindFirstFileW(pszProfilePath, &FindData);
345  {
346  if ((GetLastError() != ERROR_FILE_NOT_FOUND) &&
348  bResult = FALSE;
349 
350  goto done;
351  }
352 
353  do
354  {
355  if (FindData.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY)
356  {
357  if ((_wcsicmp(FindData.cFileName, L".") == 0) ||
358  (_wcsicmp(FindData.cFileName, L"..") == 0))
359  continue;
360 
361  pszProfilePath[dwProfilePathLength + 1] = UNICODE_NULL;
362  wcscat(pszProfilePath, FindData.cFileName);
363 
364  if (!GetProfileSize(pszProfilePath, pullProfileSize))
365  {
366  bResult = FALSE;
367  goto done;
368  }
369  }
370  else
371  {
372  Size.u.LowPart = FindData.nFileSizeLow;
373  Size.u.HighPart = FindData.nFileSizeHigh;
374  *pullProfileSize += Size.QuadPart;
375  }
376  }
377  while (FindNextFile(hFile, &FindData));
378 
379 done:
380  pszProfilePath[dwProfilePathLength] = UNICODE_NULL;
381 
383  FindClose(hFile);
384 
385  return bResult;
386 }
#define TRUE
Definition: types.h:120
#define INVALID_HANDLE_VALUE
Definition: compat.h:391
DWORD WINAPI GetLastError(VOID)
Definition: except.c:1059
#define UNICODE_NULL
unsigned int BOOL
Definition: ntddk_ex.h:94
#define ERROR_FILE_NOT_FOUND
Definition: disk.h:79
#define FILE_ATTRIBUTE_DIRECTORY
Definition: nt_native.h:705
#define FindNextFile
Definition: winbase.h:3605
unsigned long DWORD
Definition: ntddk_ex.h:95
static const WCHAR L[]
Definition: oid.c:1250
IN PVOID IN PVOID IN USHORT IN USHORT Size
Definition: pci.h:359
_In_ HANDLE hFile
Definition: mswsock.h:90
_CRTIMP wchar_t *__cdecl wcscat(_Inout_updates_z_(_String_length_(_Dest)+_String_length_(_Source)+1) wchar_t *_Dest, _In_z_ const wchar_t *_Source)
static BOOL GetProfileSize(_In_ PWSTR pszProfilePath, _Inout_ PULONGLONG pullProfileSize)
Definition: userprofile.c:329
#define ERROR_PATH_NOT_FOUND
Definition: winerror.h:106
size_t __cdecl wcslen(_In_z_ const wchar_t *_Str)
_Check_return_ _CRTIMP int __cdecl _wcsicmp(_In_z_ const wchar_t *_Str1, _In_z_ const wchar_t *_Str2)
HANDLE WINAPI FindFirstFileW(IN LPCWSTR lpFileName, OUT LPWIN32_FIND_DATAW lpFindFileData)
Definition: find.c:320
BOOL WINAPI FindClose(HANDLE hFindFile)
Definition: find.c:502

Referenced by AddUserProfile().

◆ OnDestroy()

static VOID OnDestroy ( _In_ HWND  hwndDlg)
static

Definition at line 793 of file userprofile.c.

795 {
796  HWND hwndList;
797  INT nItems, i;
798  LVITEM Item;
799 
800  hwndList = GetDlgItem(hwndDlg, IDC_USERPROFILE_LIST);
801 
802  nItems = ListView_GetItemCount(hwndList);
803  for (i = 0; i < nItems; i++)
804  {
805  Item.iItem = i;
806  Item.iSubItem = 0;
807  if (ListView_GetItem(hwndList, &Item))
808  {
809  if (Item.lParam != 0)
810  HeapFree(GetProcessHeap(), 0, (PVOID)Item.lParam);
811  }
812  }
813 }
#define IDC_USERPROFILE_LIST
Definition: resource.h:101
int32_t INT
Definition: typedefs.h:56
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
int nItems
Definition: appswitch.c:56
#define ListView_GetItemCount(hwnd)
Definition: commctrl.h:2279
#define GetProcessHeap()
Definition: compat.h:395
HWND WINAPI GetDlgItem(_In_opt_ HWND, _In_ int)
#define ListView_GetItem(hwnd, pitem)
Definition: commctrl.h:2366
#define LVITEM
Definition: commctrl.h:2347
#define HeapFree(x, y, z)
Definition: compat.h:394

Referenced by UserProfileDlgProc().

◆ OnInitUserProfileDialog()

static VOID OnInitUserProfileDialog ( HWND  hwndDlg)
static

Definition at line 773 of file userprofile.c.

774 {
775  BOOL bAdmin;
776 
777  bAdmin = IsUserAdmin();
778 
779  /* Initialize the list view control */
781 
782  /* Hide the delete and copy buttons for non-admins */
785 
786  /* Add the profiles to the list view */
787  AddUserProfiles(hwndDlg, GetDlgItem(hwndDlg, IDC_USERPROFILE_LIST), bAdmin);
788 }
BOOL WINAPI IsUserAdmin(VOID)
#define SW_HIDE
Definition: winuser.h:762
#define IDC_USERPROFILE_LIST
Definition: resource.h:101
BOOL WINAPI ShowWindow(_In_ HWND, _In_ int)
unsigned int BOOL
Definition: ntddk_ex.h:94
#define IDC_USERPROFILE_DELETE
Definition: resource.h:103
#define SW_SHOW
Definition: winuser.h:769
HWND WINAPI GetDlgItem(_In_opt_ HWND, _In_ int)
static VOID AddUserProfiles(_In_ HWND hwndDlg, _In_ HWND hwndListView, _In_ BOOL bAdmin)
Definition: userprofile.c:664
#define IDC_USERPROFILE_COPY
Definition: resource.h:104
static VOID SetListViewColumns(_In_ HWND hwndListView)
Definition: userprofile.c:277

Referenced by UserProfileDlgProc().

◆ OnNotify()

static VOID OnNotify ( _In_ HWND  hwndDlg,
_In_ NMHDR nmhdr 
)
static

Definition at line 818 of file userprofile.c.

821 {
822  if (nmhdr->idFrom == IDC_USERACCOUNT_LINK && nmhdr->code == NM_CLICK)
823  {
824  ShellExecuteW(hwndDlg, NULL, L"usrmgr.cpl", NULL, NULL, 0);
825  }
826  else if (nmhdr->idFrom == IDC_USERPROFILE_LIST && nmhdr->code == LVN_ITEMCHANGED)
827  {
828  UpdateButtonState(hwndDlg, nmhdr->hwndFrom);
829  }
830 }
#define LVN_ITEMCHANGED
Definition: commctrl.h:3103
#define IDC_USERPROFILE_LIST
Definition: resource.h:101
smooth NULL
Definition: ftsmooth.c:416
#define IDC_USERACCOUNT_LINK
Definition: resource.h:105
static const WCHAR L[]
Definition: oid.c:1250
#define NM_CLICK
Definition: commctrl.h:130
HINSTANCE WINAPI ShellExecuteW(HWND hwnd, LPCWSTR lpVerb, LPCWSTR lpFile, LPCWSTR lpParameters, LPCWSTR lpDirectory, INT nShowCmd)
Definition: shlexec.cpp:2208
static VOID UpdateButtonState(_In_ HWND hwndDlg, _In_ HWND hwndListView)
Definition: userprofile.c:623

Referenced by UserProfileDlgProc().

◆ OnProfileTypeInit()

static BOOL OnProfileTypeInit ( _In_ HWND  hwndDlg,
_In_ PPROFILEDATA  pProfileData 
)
static

Definition at line 28 of file userprofile.c.

31 {
32  PWSTR pszRawBuffer = NULL, pszCookedBuffer = NULL;
33  INT nLength;
34 
36  pszRawBuffer = NULL;
37  if (nLength == 0)
38  return FALSE;
39 
40  pszRawBuffer = HeapAlloc(GetProcessHeap(), 0, (nLength + 1) * sizeof(WCHAR));
41  if (pszRawBuffer == NULL)
42  return FALSE;
43 
45 
46  pszCookedBuffer = HeapAlloc(GetProcessHeap(), 0, (nLength + wcslen(pProfileData->pszFullName) + 1) * sizeof(WCHAR));
47  if (pszCookedBuffer == NULL)
48  goto done;
49 
50  swprintf(pszCookedBuffer, pszRawBuffer, pProfileData->pszFullName);
51 
52  /* Set the full text */
53  SetDlgItemText(hwndDlg, IDC_USERPROFILE_TYPE_TEXT, pszCookedBuffer);
54 
55  /* FIXME: Right now, we support local user profiles only! */
58  EnableWindow(GetDlgItem(hwndDlg, IDOK), FALSE);
59 
60 done:
61  if (pszCookedBuffer != NULL)
62  HeapFree(GetProcessHeap(), 0, pszCookedBuffer);
63 
64  if (pszRawBuffer != NULL)
65  HeapFree(GetProcessHeap(), 0, pszRawBuffer);
66 
67  return TRUE;
68 }
#define TRUE
Definition: types.h:120
#define IDOK
Definition: winuser.h:824
uint16_t * PWSTR
Definition: typedefs.h:54
#define IDC_USERPROFILE_TYPE_TEXT
Definition: resource.h:109
#define IDC_USERPROFILE_TYPE_LOCAL
Definition: resource.h:111
_In_ DWORD nLength
Definition: wincon.h:461
#define IDS_USERPROFILE_TYPE_TEXT
Definition: resource.h:43
HINSTANCE hApplet
Definition: access.c:17
int WINAPI LoadStringW(_In_opt_ HINSTANCE hInstance, _In_ UINT uID, _Out_writes_to_(cchBufferMax, return+1) LPWSTR lpBuffer, _In_ int cchBufferMax)
int32_t INT
Definition: typedefs.h:56
smooth NULL
Definition: ftsmooth.c:416
#define IDC_USERPROFILE_TYPE_ROAMING
Definition: resource.h:110
#define GetProcessHeap()
Definition: compat.h:395
PVOID WINAPI HeapAlloc(HANDLE, DWORD, SIZE_T)
HWND WINAPI GetDlgItem(_In_opt_ HWND, _In_ int)
__wchar_t WCHAR
Definition: xmlstorage.h:180
#define swprintf(buf, format,...)
Definition: sprintf.c:56
#define SetDlgItemText
Definition: winuser.h:5750
BOOL WINAPI EnableWindow(_In_ HWND, _In_ BOOL)
#define BST_CHECKED
Definition: winuser.h:197
#define Button_SetCheck(hwndCtl, check)
Definition: windowsx.h:10
size_t __cdecl wcslen(_In_z_ const wchar_t *_Str)
#define HeapFree(x, y, z)
Definition: compat.h:394

Referenced by UserProfileTypeDlgProc().

◆ SetListViewColumns()

static VOID SetListViewColumns ( _In_ HWND  hwndListView)
static

Definition at line 277 of file userprofile.c.

279 {
281  RECT rect;
282  TCHAR szStr[32];
283 
285 
287 
288  memset(&column, 0x00, sizeof(column));
290  column.fmt = LVCFMT_LEFT;
291  column.cx = (INT)((rect.right - rect.left) * 0.40);
292  column.iSubItem = 0;
294  column.pszText = szStr;
296 
297  column.fmt = LVCFMT_RIGHT;
298  column.cx = (INT)((rect.right - rect.left) * 0.15);
299  column.iSubItem = 1;
301  column.pszText = szStr;
303 
304  column.fmt = LVCFMT_LEFT;
305  column.cx = (INT)((rect.right - rect.left) * 0.15);
306  column.iSubItem = 2;
308  column.pszText = szStr;
310 
311  column.fmt = LVCFMT_LEFT;
312  column.cx = (INT)((rect.right - rect.left) * 0.15);
313  column.iSubItem = 3;
315  column.pszText = szStr;
317 
318  column.fmt = LVCFMT_LEFT;
319  column.cx = (INT)((rect.right - rect.left) * 0.15) - GetSystemMetrics(SM_CYHSCROLL);
320  column.iSubItem = 4;
322  column.pszText = szStr;
324 }
#define IDS_USERPROFILE_MODIFIED
Definition: resource.h:35
#define SM_CYHSCROLL
Definition: winuser.h:952
struct png_info_def **typedef void(__cdecl typeof(png_destroy_read_struct))(struct png_struct_def **
Definition: typeof.h:49
#define LVCF_WIDTH
Definition: commctrl.h:2559
#define LVCF_TEXT
Definition: commctrl.h:2560
#define LV_COLUMN
Definition: commctrl.h:2519
#define INT
Definition: polytest.cpp:20
#define LVCFMT_RIGHT
Definition: commctrl.h:2571
#define LVS_EX_FULLROWSELECT
Definition: commctrl.h:2706
#define LVCFMT_LEFT
Definition: commctrl.h:2570
#define ARRAYSIZE(array)
Definition: filtermapper.c:47
HINSTANCE hApplet
Definition: access.c:17
& rect
Definition: startmenu.cpp:1413
#define LVCF_SUBITEM
Definition: commctrl.h:2561
#define ListView_InsertColumn(hwnd, iCol, pcol)
Definition: commctrl.h:2608
HWND hwndListView
Definition: eventvwr.c:83
char TCHAR
Definition: xmlstorage.h:189
int WINAPI GetSystemMetrics(_In_ int)
#define LVM_SETEXTENDEDLISTVIEWSTYLE
Definition: commctrl.h:2696
#define IDS_USERPROFILE_SIZE
Definition: resource.h:32
BOOL WINAPI GetClientRect(_In_ HWND, _Out_ LPRECT)
#define LVCF_FMT
Definition: commctrl.h:2558
#define IDS_USERPROFILE_STATUS
Definition: resource.h:34
#define SendMessage
Definition: winuser.h:5744
GLenum GLenum GLvoid GLvoid * column
Definition: glext.h:5664
#define memset(x, y, z)
Definition: compat.h:39
#define IDS_USERPROFILE_TYPE
Definition: resource.h:33
#define LoadString
Definition: winuser.h:5720
#define IDS_USERPROFILE_NAME
Definition: resource.h:31

Referenced by OnInitUserProfileDialog().

◆ UpdateButtonState()

static VOID UpdateButtonState ( _In_ HWND  hwndDlg,
_In_ HWND  hwndListView 
)
static

Definition at line 623 of file userprofile.c.

626 {
627  LVITEM Item;
628  INT iSelected;
629  BOOL bChange = FALSE;
630  BOOL bCopy = FALSE;
631  BOOL bDelete = FALSE;
632 
634  if (iSelected != -1)
635  {
636  Item.mask = LVIF_PARAM;
637  Item.iItem = iSelected;
638  Item.iSubItem = 0;
639  if (ListView_GetItem(hwndListView, &Item))
640  {
641  if (Item.lParam != 0)
642  {
643  bCopy = (((PPROFILEDATA)Item.lParam)->dwRefCount == 0);
644  bDelete = (((PPROFILEDATA)Item.lParam)->dwRefCount == 0);
645  }
646  }
647 
648  bChange = TRUE;
649  }
650  else
651  {
652  bChange = FALSE;
653  bCopy = FALSE;
654  bDelete = FALSE;
655  }
656 
657  EnableWindow(GetDlgItem(hwndDlg, IDC_USERPROFILE_CHANGE), bChange);
658  EnableWindow(GetDlgItem(hwndDlg, IDC_USERPROFILE_DELETE), bDelete);
659  EnableWindow(GetDlgItem(hwndDlg, IDC_USERPROFILE_COPY), bCopy);
660 }
#define ListView_GetNextItem(hwnd, i, flags)
Definition: commctrl.h:2406
#define TRUE
Definition: types.h:120
#define LVNI_SELECTED
Definition: commctrl.h:2396
int32_t INT
Definition: typedefs.h:56
#define IDC_USERPROFILE_CHANGE
Definition: resource.h:102
unsigned int BOOL
Definition: ntddk_ex.h:94
HWND hwndListView
Definition: eventvwr.c:83
#define IDC_USERPROFILE_DELETE
Definition: resource.h:103
HWND WINAPI GetDlgItem(_In_opt_ HWND, _In_ int)
struct _PROFILEDATA * PPROFILEDATA
BOOL WINAPI EnableWindow(_In_ HWND, _In_ BOOL)
#define IDC_USERPROFILE_COPY
Definition: resource.h:104
#define ListView_GetItem(hwnd, pitem)
Definition: commctrl.h:2366
#define LVIF_PARAM
Definition: commctrl.h:2283
#define LVITEM
Definition: commctrl.h:2347

Referenced by AddUserProfiles(), and OnNotify().

◆ UserProfileDlgProc()

INT_PTR CALLBACK UserProfileDlgProc ( HWND  hwndDlg,
UINT  uMsg,
WPARAM  wParam,
LPARAM  lParam 
)

Definition at line 835 of file userprofile.c.

839 {
840  switch (uMsg)
841  {
842  case WM_INITDIALOG:
843  OnInitUserProfileDialog(hwndDlg);
844  return TRUE;
845 
846  case WM_DESTROY:
847  OnDestroy(hwndDlg);
848  break;
849 
850  case WM_COMMAND:
851  switch (LOWORD(wParam))
852  {
853  case IDOK:
854  case IDCANCEL:
855  EndDialog(hwndDlg,
856  LOWORD(wParam));
857  return TRUE;
858 
860  ChangeUserProfileType(hwndDlg);
861  break;
862 
864  DeleteUserProfile(hwndDlg);
865  break;
866 
868  CopyUserProfile(hwndDlg);
869  break;
870  }
871  break;
872 
873  case WM_NOTIFY:
874  OnNotify(hwndDlg, (NMHDR *)lParam);
875  break;
876  }
877 
878  return FALSE;
879 }
#define TRUE
Definition: types.h:120
#define IDOK
Definition: winuser.h:824
static VOID OnInitUserProfileDialog(HWND hwndDlg)
Definition: userprofile.c:773
#define IDC_USERPROFILE_CHANGE
Definition: resource.h:102
BOOL WINAPI EndDialog(_In_ HWND, _In_ INT_PTR)
WPARAM wParam
Definition: combotst.c:138
static BOOL CopyUserProfile(_In_ HWND hwndDlg)
Definition: userprofile.c:235
#define IDC_USERPROFILE_DELETE
Definition: resource.h:103
static BOOL ChangeUserProfileType(_In_ HWND hwndDlg)
Definition: userprofile.c:107
#define WM_DESTROY
Definition: winuser.h:1591
#define WM_COMMAND
Definition: winuser.h:1722
static VOID OnDestroy(_In_ HWND hwndDlg)
Definition: userprofile.c:793
#define IDC_USERPROFILE_COPY
Definition: resource.h:104
static VOID OnNotify(_In_ HWND hwndDlg, _In_ NMHDR *nmhdr)
Definition: userprofile.c:818
static BOOL DeleteUserProfile(_In_ HWND hwndDlg)
Definition: userprofile.c:150
#define IDCANCEL
Definition: winuser.h:825
#define WM_INITDIALOG
Definition: winuser.h:1721
LPARAM lParam
Definition: combotst.c:139
#define LOWORD(l)
Definition: pedump.c:82
#define WM_NOTIFY
Definition: richedit.h:61

Referenced by AdvancedPageProc().

◆ UserProfileTypeDlgProc()

static INT_PTR CALLBACK UserProfileTypeDlgProc ( _In_ HWND  hwndDlg,
_In_ UINT  uMsg,
_In_ WPARAM  wParam,
_In_ LPARAM  lParam 
)
static

Definition at line 74 of file userprofile.c.

79 {
80  switch (uMsg)
81  {
82  case WM_INITDIALOG:
84  return TRUE;
85 
86  case WM_DESTROY:
87  break;
88 
89  case WM_COMMAND:
90  switch (LOWORD(wParam))
91  {
92  case IDOK:
93  case IDCANCEL:
94  EndDialog(hwndDlg,
95  LOWORD(wParam));
96  return TRUE;
97  }
98  break;
99  }
100 
101  return FALSE;
102 }
#define TRUE
Definition: types.h:120
#define IDOK
Definition: winuser.h:824
BOOL WINAPI EndDialog(_In_ HWND, _In_ INT_PTR)
WPARAM wParam
Definition: combotst.c:138
static BOOL OnProfileTypeInit(_In_ HWND hwndDlg, _In_ PPROFILEDATA pProfileData)
Definition: userprofile.c:28
#define WM_DESTROY
Definition: winuser.h:1591
#define WM_COMMAND
Definition: winuser.h:1722
#define IDCANCEL
Definition: winuser.h:825
#define WM_INITDIALOG
Definition: winuser.h:1721
LPARAM lParam
Definition: combotst.c:139
#define LOWORD(l)
Definition: pedump.c:82

Referenced by ChangeUserProfileType().