ReactOS  0.4.15-dev-1207-g698a8e6
userprofile.c
Go to the documentation of this file.
1 /*
2  * PROJECT: ReactOS System Control Panel Applet
3  * LICENSE: GPL - See COPYING in the top level directory
4  * FILE: dll/cpl/sysdm/userprofile.c
5  * PURPOSE: Computer settings for networking
6  * COPYRIGHT: Copyright Thomas Weidenmueller <w3seek@reactos.org>
7  * Copyright 2006 Ged Murphy <gedmurphy@gmail.com>
8  *
9  */
10 
11 #include "precomp.h"
12 #include <sddl.h>
13 #include <winnls.h>
14 
15 #include <debug.h>
16 
17 typedef struct _PROFILEDATA
18 {
25 
26 
27 static
28 BOOL
30  _In_ HWND hwndDlg,
31  _In_ PPROFILEDATA pProfileData)
32 {
33  PWSTR pszRawBuffer = NULL, pszCookedBuffer = NULL;
34  INT nLength;
35 
37  pszRawBuffer = NULL;
38  if (nLength == 0)
39  return FALSE;
40 
41  pszRawBuffer = HeapAlloc(GetProcessHeap(), 0, (nLength + 1) * sizeof(WCHAR));
42  if (pszRawBuffer == NULL)
43  return FALSE;
44 
46 
47  pszCookedBuffer = HeapAlloc(GetProcessHeap(), 0, (nLength + wcslen(pProfileData->pszFullName) + 1) * sizeof(WCHAR));
48  if (pszCookedBuffer == NULL)
49  goto done;
50 
51  swprintf(pszCookedBuffer, pszRawBuffer, pProfileData->pszFullName);
52 
53  /* Set the full text */
54  SetDlgItemText(hwndDlg, IDC_USERPROFILE_TYPE_TEXT, pszCookedBuffer);
55 
56  /* FIXME: Right now, we support local user profiles only! */
59  EnableWindow(GetDlgItem(hwndDlg, IDOK), FALSE);
60 
61 done:
62  if (pszCookedBuffer != NULL)
63  HeapFree(GetProcessHeap(), 0, pszCookedBuffer);
64 
65  if (pszRawBuffer != NULL)
66  HeapFree(GetProcessHeap(), 0, pszRawBuffer);
67 
68  return TRUE;
69 }
70 
71 
72 static
73 INT_PTR
76  _In_ HWND hwndDlg,
77  _In_ UINT uMsg,
80 {
81  switch (uMsg)
82  {
83  case WM_INITDIALOG:
85  return TRUE;
86 
87  case WM_DESTROY:
88  break;
89 
90  case WM_COMMAND:
91  switch (LOWORD(wParam))
92  {
93  case IDOK:
94  case IDCANCEL:
95  EndDialog(hwndDlg,
96  LOWORD(wParam));
97  return TRUE;
98  }
99  break;
100  }
101 
102  return FALSE;
103 }
104 
105 
106 static
107 BOOL
109  _In_ HWND hwndDlg)
110 {
112  LVITEM Item;
113  INT iSelected;
114 
115  DPRINT("ChangeUserProfileType(%p)\n", hwndDlg);
116 
118  if (hwndListView == NULL)
119  return FALSE;
120 
122  if (iSelected == -1)
123  return FALSE;
124 
125  ZeroMemory(&Item, sizeof(LVITEM));
126  Item.mask = LVIF_PARAM;
127  Item.iItem = iSelected;
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 }
146 
147 
148 static
149 BOOL
151  _In_ HWND hwndDlg)
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  if (!ListView_GetItem(hwndListView, &Item))
173  return FALSE;
174 
175  if (Item.lParam == 0)
176  return FALSE;
177 
178  pProfileData = (PPROFILEDATA)Item.lParam;
179  if (pProfileData->dwRefCount != 0)
180  return FALSE;
181 
184  swprintf(szCookedText, szRawText, pProfileData->pszFullName);
185 
186  if (MessageBoxW(hwndDlg,
187  szCookedText,
188  szTitle,
190  {
191  /* FIXME: Delete the profile here! */
192  return TRUE;
193  }
194 
195  return FALSE;
196 }
197 
198 
199 static
200 INT_PTR
201 CALLBACK
203  _In_ HWND hwndDlg,
204  _In_ UINT uMsg,
207 {
208  switch (uMsg)
209  {
210  case WM_INITDIALOG:
211  return TRUE;
212 
213  case WM_DESTROY:
214  break;
215 
216  case WM_COMMAND:
217  switch (LOWORD(wParam))
218  {
219  case IDOK:
220  case IDCANCEL:
221  EndDialog(hwndDlg,
222  LOWORD(wParam));
223  return TRUE;
224  }
225  break;
226  }
227 
228  return FALSE;
229 }
230 
231 
232 static
233 BOOL
235  _In_ HWND hwndDlg)
236 {
238  LVITEM Item;
239  INT iSelected;
240 
241  DPRINT("CopyUserProfile()\n");
242 
244  if (hwndListView == NULL)
245  return FALSE;
246 
248  if (iSelected == -1)
249  return FALSE;
250 
251  ZeroMemory(&Item, sizeof(LVITEM));
252  Item.mask = LVIF_PARAM;
253  Item.iItem = iSelected;
254  if (!ListView_GetItem(hwndListView, &Item))
255  return FALSE;
256 
257  if (Item.lParam == 0)
258  return FALSE;
259 
262  hwndDlg,
264  (LPARAM)Item.lParam) == IDOK)
265  {
266  /* FIXME: Update the profile list view */
267  return TRUE;
268  }
269 
270  return FALSE;
271 }
272 
273 
274 static VOID
277 {
279  RECT rect;
280  TCHAR szStr[32];
281 
283 
285 
286  memset(&column, 0x00, sizeof(column));
288  column.fmt = LVCFMT_LEFT;
289  column.cx = (INT)((rect.right - rect.left) * 0.40);
290  column.iSubItem = 0;
292  column.pszText = szStr;
294 
295  column.fmt = LVCFMT_RIGHT;
296  column.cx = (INT)((rect.right - rect.left) * 0.15);
297  column.iSubItem = 1;
299  column.pszText = szStr;
301 
302  column.fmt = LVCFMT_LEFT;
303  column.cx = (INT)((rect.right - rect.left) * 0.15);
304  column.iSubItem = 2;
306  column.pszText = szStr;
308 
309  column.fmt = LVCFMT_LEFT;
310  column.cx = (INT)((rect.right - rect.left) * 0.15);
311  column.iSubItem = 3;
313  column.pszText = szStr;
315 
316  column.fmt = LVCFMT_LEFT;
317  column.cx = (INT)((rect.right - rect.left) * 0.15) - GetSystemMetrics(SM_CYHSCROLL);
318  column.iSubItem = 4;
320  column.pszText = szStr;
322 }
323 
324 
325 static
326 BOOL
328  _In_ PWSTR pszProfilePath,
329  _Inout_ PULONGLONG pullProfileSize)
330 {
332  WIN32_FIND_DATA FindData;
333  DWORD dwProfilePathLength;
335  BOOL bResult = TRUE;
336 
337  dwProfilePathLength = wcslen(pszProfilePath);
338 
339  wcscat(pszProfilePath, L"\\*.*");
340 
341  hFile = FindFirstFileW(pszProfilePath, &FindData);
343  {
344  if ((GetLastError() != ERROR_FILE_NOT_FOUND) &&
346  bResult = FALSE;
347 
348  goto done;
349  }
350 
351  do
352  {
353  if (FindData.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY)
354  {
355  if ((_wcsicmp(FindData.cFileName, L".") == 0) ||
356  (_wcsicmp(FindData.cFileName, L"..") == 0))
357  continue;
358 
359  pszProfilePath[dwProfilePathLength + 1] = UNICODE_NULL;
360  wcscat(pszProfilePath, FindData.cFileName);
361 
362  if (!GetProfileSize(pszProfilePath, pullProfileSize))
363  {
364  bResult = FALSE;
365  goto done;
366  }
367  }
368  else
369  {
370  Size.u.LowPart = FindData.nFileSizeLow;
371  Size.u.HighPart = FindData.nFileSizeHigh;
372  *pullProfileSize += Size.QuadPart;
373  }
374  }
375  while (FindNextFile(hFile, &FindData));
376 
377 done:
378  pszProfilePath[dwProfilePathLength] = UNICODE_NULL;
379 
381  FindClose(hFile);
382 
383  return bResult;
384 }
385 
386 
387 static
388 BOOL
390  _In_ PSID pProfileSid,
391  _In_ DWORD dwNameBufferSize,
392  _Out_ PWSTR pszNameBuffer,
393  _Out_ PBOOL pbUnknownProfile)
394 {
395  WCHAR szAccountName[128], szDomainName[128];
396  DWORD dwAccountNameSize, dwDomainNameSize;
397  SID_NAME_USE Use;
398 
399  dwAccountNameSize = ARRAYSIZE(szAccountName);
400  dwDomainNameSize = ARRAYSIZE(szDomainName);
401  if (!LookupAccountSidW(NULL,
402  pProfileSid,
403  szAccountName,
404  &dwAccountNameSize,
405  szDomainName,
406  &dwDomainNameSize,
407  &Use))
408  {
409  /* Unknown account */
410  LoadStringW(hApplet, IDS_USERPROFILE_ACCOUNT_UNKNOWN, pszNameBuffer, dwNameBufferSize);
411  *pbUnknownProfile = TRUE;
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  *pbUnknownProfile = FALSE;
430  }
431 
432  return TRUE;
433 }
434 
435 
436 static VOID
439  _In_ PSID pProfileSid,
440  _In_ HKEY hProfileKey)
441 {
442  WCHAR szTempProfilePath[MAX_PATH], szProfilePath[MAX_PATH];
443  WCHAR szNameBuffer[256];
444  PPROFILEDATA pProfileData = NULL;
445  DWORD dwProfileData, dwSize, dwType, dwState = 0, dwRefCount = 0;
446  DWORD dwProfilePathLength;
447  PWSTR ptr;
448  INT nId, iItem;
449  LV_ITEM lvi;
450  WIN32_FIND_DATA FindData;
451  HANDLE hFile;
452  SYSTEMTIME SystemTime;
453  ULONGLONG ullProfileSize;
454  BOOL bUnknownProfile;
455  DWORD dwError;
456 
457  /* Get the profile path */
458  dwSize = MAX_PATH * sizeof(WCHAR);
459  dwError = RegQueryValueExW(hProfileKey,
460  L"ProfileImagePath",
461  NULL,
462  &dwType,
463  (LPBYTE)szTempProfilePath,
464  &dwSize);
465  if (dwError != ERROR_SUCCESS)
466  return;
467 
468  /* Expand it */
469  ExpandEnvironmentStringsW(szTempProfilePath,
470  szProfilePath,
471  MAX_PATH);
472 
473  /* Check if the profile path exists */
474  hFile = FindFirstFileW(szProfilePath, &FindData);
476  return;
477 
478  FindClose(hFile);
479 
480  /* Get the length of the profile path */
481  dwProfilePathLength = wcslen(szProfilePath);
482 
483  /* Check for the ntuser.dat file */
484  wcscat(szProfilePath, L"\\ntuser.dat");
485  hFile = FindFirstFileW(szProfilePath, &FindData);
487  return;
488 
489  FindClose(hFile);
490  szProfilePath[dwProfilePathLength] = UNICODE_NULL;
491 
492  /* Get the profile size */
493  ullProfileSize = 0ULL;
494  GetProfileSize(szProfilePath, &ullProfileSize);
495 
496  /* Get the profile name */
497  if (!GetProfileName(pProfileSid,
498  ARRAYSIZE(szNameBuffer),
499  szNameBuffer,
500  &bUnknownProfile))
501  return;
502 
503  /* Get the profile state value */
504  dwSize = sizeof(dwState);
505  if (RegQueryValueExW(hProfileKey,
506  L"State",
507  NULL,
508  &dwType,
509  (LPBYTE)&dwState,
510  &dwSize) != ERROR_SUCCESS)
511  {
512  dwState = 0;
513  }
514 
515  /* Get the profile reference counter */
516  dwSize = sizeof(dwRefCount);
517  if (RegQueryValueExW(hProfileKey,
518  L"RefCount",
519  NULL,
520  &dwType,
521  (LPBYTE)&dwRefCount,
522  &dwSize) != ERROR_SUCCESS)
523  {
524  dwRefCount = 0;
525  }
526 
527  /* Create and fill the profile data entry */
528  dwProfileData = sizeof(PROFILEDATA) +
529  ((wcslen(szNameBuffer) + 1) * sizeof(WCHAR)) +
530  ((wcslen(szProfilePath) + 1) * sizeof(WCHAR));
531  pProfileData = HeapAlloc(GetProcessHeap(),
533  dwProfileData);
534  if (pProfileData == NULL)
535  return;
536 
537  pProfileData->dwRefCount = dwRefCount;
538  pProfileData->dwState = dwState;
539  pProfileData->bUnknownProfile = bUnknownProfile;
540 
541  ptr = (PWSTR)((ULONG_PTR)pProfileData + sizeof(PROFILEDATA));
542  pProfileData->pszFullName = ptr;
543 
544  wcscpy(pProfileData->pszFullName, szNameBuffer);
545 
546  ptr = (PWSTR)((ULONG_PTR)ptr + ((wcslen(pProfileData->pszFullName) + 1) * sizeof(WCHAR)));
547  pProfileData->pszProfilePath = ptr;
548  wcscpy(pProfileData->pszProfilePath, szProfilePath);
549 
550  /* Add the profile and set its name */
551  memset(&lvi, 0x00, sizeof(lvi));
552  lvi.mask = LVIF_TEXT | LVIF_STATE | LVIF_PARAM;
553  lvi.pszText = pProfileData->pszFullName;
554  lvi.state = 0;
555  lvi.lParam = (LPARAM)pProfileData;
556  iItem = ListView_InsertItem(hwndListView, &lvi);
557 
558  /* Set the profile size */
559  StrFormatByteSizeW(ullProfileSize, szNameBuffer, ARRAYSIZE(szNameBuffer) - 1);
560  ListView_SetItemText(hwndListView, iItem, 1, szNameBuffer);
561 
562  /* Set the profile type */
563  if (dwState & 0x0010) // PROFILE_UPDATE_CENTRAL
565  else
566  nId = IDS_USERPROFILE_LOCAL;
567 
568  LoadStringW(hApplet, nId, szNameBuffer, ARRAYSIZE(szNameBuffer));
569 
570  ListView_SetItemText(hwndListView, iItem, 2, szNameBuffer);
571 
572  /* FIXME: Set the profile status */
573  if (dwState & 0x0001) // PROFILE_MANDATORY
575  else if (dwState & 0x0010) // PROFILE_UPDATE_CENTRAL
577  else
578  nId = IDS_USERPROFILE_LOCAL;
579 
580  LoadStringW(hApplet, nId, szNameBuffer, ARRAYSIZE(szNameBuffer));
581 
582  ListView_SetItemText(hwndListView, iItem, 3, szNameBuffer);
583 
584  /* Set the profile modified time */
585  FileTimeToSystemTime(&FindData.ftLastWriteTime,
586  &SystemTime);
587 
590  &SystemTime,
591  NULL,
592  szNameBuffer,
593  ARRAYSIZE(szNameBuffer));
594 
595  ListView_SetItemText(hwndListView, iItem, 4, szNameBuffer);
596 }
597 
598 
599 static VOID
601  _In_ HWND hwndDlg,
603 {
604  LVITEM Item;
605  INT iSelected;
606  BOOL bChange = FALSE;
607  BOOL bCopy = FALSE;
608  BOOL bDelete = FALSE;
609  PPROFILEDATA pProfileData;
610 
612  {
614  if (iSelected != -1)
615  {
616  ZeroMemory(&Item, sizeof(LVITEM));
617  Item.mask = LVIF_PARAM;
618  Item.iItem = iSelected;
619  if (ListView_GetItem(hwndListView, &Item))
620  {
621  if (Item.lParam != 0)
622  {
623  pProfileData = (PPROFILEDATA)Item.lParam;
624 
625  if (pProfileData->bUnknownProfile)
626  {
627  bDelete = TRUE;
628  bCopy = FALSE;
629  }
630  else
631  {
632  bDelete = (pProfileData->dwRefCount == 0);
633  bCopy = (pProfileData->dwRefCount == 0);
634  }
635  }
636  }
637 
638  bChange = TRUE;
639  }
640  }
641 
642  EnableWindow(GetDlgItem(hwndDlg, IDC_USERPROFILE_CHANGE), bChange);
643  EnableWindow(GetDlgItem(hwndDlg, IDC_USERPROFILE_DELETE), bDelete);
644  EnableWindow(GetDlgItem(hwndDlg, IDC_USERPROFILE_COPY), bCopy);
645 }
646 
647 
648 static VOID
650  _In_ HWND hwndDlg,
652  _In_ BOOL bAdmin)
653 {
654  HKEY hKeyUserProfiles = INVALID_HANDLE_VALUE;
655  HKEY hProfileKey;
656  DWORD dwIndex;
657  WCHAR szProfileSid[64];
658  DWORD dwSidLength;
659  FILETIME ftLastWrite;
660  DWORD dwSize;
661  HANDLE hToken = NULL;
662  PTOKEN_USER pTokenUser = NULL;
663  PSID pProfileSid;
664  PWSTR pszProfileSid;
665 
667  return;
668 
669  if (GetTokenInformation(hToken, TokenUser, NULL, 0, &dwSize) ||
671  {
672  goto done;
673  }
674 
675  pTokenUser = HeapAlloc(GetProcessHeap(), 0, dwSize);
676  if (pTokenUser == NULL)
677  goto done;
678 
679  if (!GetTokenInformation(hToken, TokenUser, pTokenUser, dwSize, &dwSize))
680  goto done;
681 
683  L"Software\\Microsoft\\Windows NT\\CurrentVersion\\ProfileList",
684  0,
685  KEY_READ,
686  &hKeyUserProfiles))
687  goto done;
688 
689  if (bAdmin)
690  {
691  for (dwIndex = 0; ; dwIndex++)
692  {
693  dwSidLength = ARRAYSIZE(szProfileSid);
694  if (RegEnumKeyExW(hKeyUserProfiles,
695  dwIndex,
696  szProfileSid,
697  &dwSidLength,
698  NULL,
699  NULL,
700  NULL,
701  &ftLastWrite))
702  break;
703 
704  if (RegOpenKeyExW(hKeyUserProfiles,
705  szProfileSid,
706  0,
707  KEY_READ,
708  &hProfileKey) == ERROR_SUCCESS)
709  {
710  if (ConvertStringSidToSid(szProfileSid, &pProfileSid))
711  {
713  pProfileSid,
714  hProfileKey);
715  LocalFree(pProfileSid);
716  }
717 
718  RegCloseKey(hProfileKey);
719  }
720  }
721  }
722  else
723  {
724  if (ConvertSidToStringSidW(pTokenUser->User.Sid, &pszProfileSid))
725  {
726  if (RegOpenKeyExW(hKeyUserProfiles,
727  pszProfileSid,
728  0,
729  KEY_READ,
730  &hProfileKey) == ERROR_SUCCESS)
731  {
733  pTokenUser->User.Sid,
734  hProfileKey);
735  RegCloseKey(hProfileKey);
736  }
737 
738  LocalFree(pszProfileSid);
739  }
740  }
741 
744 
746 
747 done:
748  if (hKeyUserProfiles != INVALID_HANDLE_VALUE)
749  RegCloseKey(hKeyUserProfiles);
750 
751  if (pTokenUser != NULL)
752  HeapFree(GetProcessHeap(), 0, pTokenUser);
753 
754  if (hToken != NULL)
755  CloseHandle(hToken);
756 }
757 
758 
759 static VOID
761 {
762  BOOL bAdmin;
763 
764  bAdmin = IsUserAdmin();
765 
766  /* Initialize the list view control */
768 
769  /* Hide the delete and copy buttons for non-admins */
772 
773  /* Add the profiles to the list view */
774  AddUserProfiles(hwndDlg, GetDlgItem(hwndDlg, IDC_USERPROFILE_LIST), bAdmin);
775 }
776 
777 static
778 VOID
780  _In_ HWND hwndDlg,
781  _In_ NMHDR *nmhdr)
782 {
783  LPNMLISTVIEW pNMLV;
784 
785  if (nmhdr->idFrom == IDC_USERACCOUNT_LINK && nmhdr->code == NM_CLICK)
786  {
787  ShellExecuteW(hwndDlg, NULL, L"usrmgr.cpl", NULL, NULL, 0);
788  }
789  else if (nmhdr->idFrom == IDC_USERPROFILE_LIST)
790  {
791  switch(nmhdr->code)
792  {
793  case LVN_ITEMCHANGED:
794  UpdateButtonState(hwndDlg, nmhdr->hwndFrom);
795  break;
796 
797  case NM_DBLCLK:
798  ChangeUserProfileType(hwndDlg);
799  break;
800 
801  case LVN_DELETEITEM:
802  pNMLV = (LPNMLISTVIEW)nmhdr;
803  if (pNMLV->lParam != 0)
804  HeapFree(GetProcessHeap(), 0, (LPVOID)pNMLV->lParam);
805  break;
806  }
807  }
808 }
809 
810 
811 /* Property page dialog callback */
814  UINT uMsg,
815  WPARAM wParam,
816  LPARAM lParam)
817 {
818  switch (uMsg)
819  {
820  case WM_INITDIALOG:
821  OnInitUserProfileDialog(hwndDlg);
822  return TRUE;
823 
824  case WM_COMMAND:
825  switch (LOWORD(wParam))
826  {
827  case IDOK:
828  case IDCANCEL:
829  EndDialog(hwndDlg,
830  LOWORD(wParam));
831  return TRUE;
832 
834  ChangeUserProfileType(hwndDlg);
835  break;
836 
838  DeleteUserProfile(hwndDlg);
839  break;
840 
842  CopyUserProfile(hwndDlg);
843  break;
844  }
845  break;
846 
847  case WM_NOTIFY:
848  OnNotify(hwndDlg, (NMHDR *)lParam);
849  break;
850  }
851 
852  return FALSE;
853 }
#define IDS_USERPROFILE_MODIFIED
Definition: resource.h:35
#define LV_ITEM
Definition: commctrl.h:2333
LPWSTR WINAPI StrFormatByteSizeW(LONGLONG llBytes, LPWSTR lpszDest, UINT cchMax)
Definition: string.c:2380
#define MAKEINTRESOURCE
Definition: winuser.h:591
#define ListView_GetNextItem(hwnd, i, flags)
Definition: commctrl.h:2430
#define SM_CYHSCROLL
Definition: winuser.h:952
#define IDOK
Definition: winuser.h:824
#define CloseHandle
Definition: compat.h:598
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:2583
enum _SID_NAME_USE SID_NAME_USE
#define ERROR_SUCCESS
Definition: deptool.c:10
#define IDYES
Definition: winuser.h:829
#define LVCF_TEXT
Definition: commctrl.h:2584
static INT_PTR CALLBACK UserProfileTypeDlgProc(_In_ HWND hwndDlg, _In_ UINT uMsg, _In_ WPARAM wParam, _In_ LPARAM lParam)
Definition: userprofile.c:75
#define KEY_READ
Definition: nt_native.h:1023
#define TRUE
Definition: types.h:120
#define SW_HIDE
Definition: winuser.h:762
uint16_t * PWSTR
Definition: typedefs.h:56
#define ConvertStringSidToSid
Definition: sddl.h:161
#define LOCALE_USER_DEFAULT
#define IDC_USERPROFILE_TYPE_TEXT
Definition: resource.h:110
#define DATE_SHORTDATE
Definition: winnls.h:193
#define IDC_USERPROFILE_TYPE_LOCAL
Definition: resource.h:112
#define LV_COLUMN
Definition: commctrl.h:2543
#define LVN_ITEMCHANGED
Definition: commctrl.h:3127
#define INT
Definition: polytest.cpp:20
#define LVCFMT_RIGHT
Definition: commctrl.h:2595
#define CALLBACK
Definition: compat.h:35
_In_ DWORD nLength
Definition: wincon.h:476
#define LVS_EX_FULLROWSELECT
Definition: commctrl.h:2730
#define IDS_USERPROFILE_TYPE_TEXT
Definition: resource.h:43
#define IDC_USERPROFILE_LIST
Definition: resource.h:102
#define LVCFMT_LEFT
Definition: commctrl.h:2594
#define ARRAYSIZE(array)
Definition: filtermapper.c:47
#define INVALID_HANDLE_VALUE
Definition: compat.h:590
DWORD WINAPI GetLastError(VOID)
Definition: except.c:1044
#define ZeroMemory
Definition: winbase.h:1648
HINSTANCE hApplet
Definition: access.c:17
#define LVNI_SELECTED
Definition: commctrl.h:2420
UINT_PTR WPARAM
Definition: windef.h:207
#define ListView_InsertItem(hwnd, pitem)
Definition: commctrl.h:2404
BOOL WINAPI ShowWindow(_In_ HWND, _In_ int)
int32_t INT_PTR
Definition: typedefs.h:64
static VOID AddUserProfile(_In_ HWND hwndListView, _In_ PSID pProfileSid, _In_ HKEY hProfileKey)
Definition: userprofile.c:437
DWORD dwRefCount
Definition: userprofile.c:19
BOOL WINAPI ConvertSidToStringSidW(PSID Sid, LPWSTR *StringSid)
Definition: security.c:3259
static VOID OnInitUserProfileDialog(HWND hwndDlg)
Definition: userprofile.c:760
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:58
#define IDC_USERPROFILE_CHANGE
Definition: resource.h:103
& rect
Definition: startmenu.cpp:1413
BOOL WINAPI EndDialog(_In_ HWND, _In_ INT_PTR)
WPARAM wParam
Definition: combotst.c:138
#define IDS_USERPROFILE_MANDATORY
Definition: resource.h:38
static BOOL OnProfileTypeInit(_In_ HWND hwndDlg, _In_ PPROFILEDATA pProfileData)
Definition: userprofile.c:29
uint32_t ULONG_PTR
Definition: typedefs.h:65
#define LVIF_TEXT
Definition: commctrl.h:2305
#define LVCF_SUBITEM
Definition: commctrl.h:2585
BOOL bUnknownProfile
Definition: userprofile.c:21
#define ListView_InsertColumn(hwnd, iCol, pcol)
Definition: commctrl.h:2632
LONG WINAPI RegCloseKey(HKEY hKey)
Definition: reg.c:423
unsigned char * LPBYTE
Definition: typedefs.h:53
static BOOL CopyUserProfile(_In_ HWND hwndDlg)
Definition: userprofile.c:234
#define ListView_GetSelectedCount(hwndLV)
Definition: commctrl.h:2705
#define FALSE
Definition: types.h:117
#define MB_YESNO
Definition: winuser.h:811
#define UNICODE_NULL
#define ListView_SetItemState(hwndLV, i, data, mask)
Definition: commctrl.h:2669
unsigned int BOOL
Definition: ntddk_ex.h:94
#define IDS_USERPROFILE_ROAMING
Definition: resource.h:37
#define IDD_USERPROFILE_COPY
Definition: resource.h:115
static BOOL IsUserAdmin(VOID)
Definition: netid.c:163
INT_PTR CALLBACK UserProfileDlgProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
Definition: userprofile.c:813
#define IDS_USERPROFILE_CONFIRM_DELETE
Definition: resource.h:39
static PVOID ptr
Definition: dispmode.c:27
HWND hwndListView
Definition: eventvwr.c:83
smooth NULL
Definition: ftsmooth.c:416
#define LVIS_SELECTED
Definition: commctrl.h:2315
#define IDD_USERPROFILE_TYPE
Definition: resource.h:109
#define MB_ICONQUESTION
Definition: winuser.h:783
#define IDC_USERPROFILE_DELETE
Definition: resource.h:104
#define _Out_
Definition: no_sal2.h:160
static BOOL ChangeUserProfileType(_In_ HWND hwndDlg)
Definition: userprofile.c:108
LONG_PTR LPARAM
Definition: windef.h:208
void DPRINT(...)
Definition: polytest.cpp:61
#define ListView_GetItemCount(hwnd)
Definition: commctrl.h:2303
#define SW_SHOW
Definition: winuser.h:769
BOOL * PBOOL
Definition: windef.h:161
#define ERROR_FILE_NOT_FOUND
Definition: disk.h:79
#define ULL(a, b)
Definition: format_msg.c:27
#define WM_DESTROY
Definition: winuser.h:1591
#define FILE_ATTRIBUTE_DIRECTORY
Definition: nt_native.h:705
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
#define ListView_SetItemText(hwndLV, i, iSubItem_, pszText_)
Definition: commctrl.h:2687
char TCHAR
Definition: xmlstorage.h:189
#define IDC_USERPROFILE_TYPE_ROAMING
Definition: resource.h:111
BOOL WINAPI FileTimeToSystemTime(IN CONST FILETIME *lpFileTime, OUT LPSYSTEMTIME lpSystemTime)
Definition: time.c:188
#define GetProcessHeap()
Definition: compat.h:595
PVOID WINAPI HeapAlloc(HANDLE, DWORD, SIZE_T)
#define TOKEN_QUERY
Definition: setypes.h:874
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
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
#define IDS_USERPROFILE_ACCOUNT_UNKNOWN
Definition: resource.h:41
#define FindNextFile
Definition: winbase.h:3628
uint64_t ULONGLONG
Definition: typedefs.h:67
struct _PROFILEDATA * PPROFILEDATA
#define MAX_PATH
Definition: compat.h:34
#define swprintf(buf, format,...)
Definition: sprintf.c:56
struct _PROFILEDATA PROFILEDATA
int WINAPI GetSystemMetrics(_In_ int)
#define LVN_DELETEITEM
Definition: commctrl.h:3129
unsigned long DWORD
Definition: ntddk_ex.h:95
#define LVM_SETEXTENDEDLISTVIEWSTYLE
Definition: commctrl.h:2720
#define IDC_USERACCOUNT_LINK
Definition: resource.h:106
#define _Inout_
Definition: no_sal2.h:162
#define SetDlgItemText
Definition: winuser.h:5824
TCHAR szTitle[MAX_LOADSTRING]
Definition: magnifier.c:35
#define DialogBoxParam
Definition: winuser.h:5739
_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
#define GetCurrentProcess()
Definition: compat.h:618
#define IDS_USERPROFILE_SIZE
Definition: resource.h:32
#define WM_COMMAND
Definition: winuser.h:1722
IN PVOID IN PVOID IN USHORT IN USHORT Size
Definition: pci.h:361
_In_ HANDLE hFile
Definition: mswsock.h:90
#define NM_CLICK
Definition: commctrl.h:130
INT WINAPI GetDateFormatW(LCID lcid, DWORD dwFlags, const SYSTEMTIME *lpTime, LPCWSTR lpFormat, LPWSTR lpDateStr, INT cchOut)
Definition: lcformat.c:979
BOOL WINAPI EnableWindow(_In_ HWND, _In_ BOOL)
#define _In_
Definition: no_sal2.h:158
BOOL WINAPI GetClientRect(_In_ HWND, _Out_ LPRECT)
#define LVCF_FMT
Definition: commctrl.h:2582
static VOID AddUserProfiles(_In_ HWND hwndDlg, _In_ HWND hwndListView, _In_ BOOL bAdmin)
Definition: userprofile.c:649
#define IDS_USERPROFILE_CONFIRM_DELETE_TITLE
Definition: resource.h:40
#define NM_DBLCLK
Definition: commctrl.h:131
#define IDC_USERPROFILE_COPY
Definition: resource.h:105
struct tagNMLISTVIEW * LPNMLISTVIEW
HLOCAL NTAPI LocalFree(HLOCAL hMem)
Definition: heapmem.c:1577
#define IDS_USERPROFILE_STATUS
Definition: resource.h:34
PWSTR pszFullName
Definition: userprofile.c:22
_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 VOID OnNotify(_In_ HWND hwndDlg, _In_ NMHDR *nmhdr)
Definition: userprofile.c:779
static BOOL GetProfileName(_In_ PSID pProfileSid, _In_ DWORD dwNameBufferSize, _Out_ PWSTR pszNameBuffer, _Out_ PBOOL pbUnknownProfile)
Definition: userprofile.c:389
unsigned int UINT
Definition: ndis.h:50
BOOL WINAPI OpenProcessToken(HANDLE ProcessHandle, DWORD DesiredAccess, PHANDLE TokenHandle)
Definition: security.c:296
DWORD WINAPI ExpandEnvironmentStringsW(IN LPCWSTR lpSrc, IN LPWSTR lpDst, IN DWORD nSize)
Definition: environ.c:519
#define HEAP_ZERO_MEMORY
Definition: compat.h:134
static BOOL DeleteUserProfile(_In_ HWND hwndDlg)
Definition: userprofile.c:150
#define BST_CHECKED
Definition: winuser.h:197
DWORD dwState
Definition: userprofile.c:20
#define Button_SetCheck(hwndCtl, check)
Definition: windowsx.h:10
static BOOL GetProfileSize(_In_ PWSTR pszProfilePath, _Inout_ PULONGLONG pullProfileSize)
Definition: userprofile.c:327
#define ListView_GetItem(hwnd, pitem)
Definition: commctrl.h:2390
#define SendMessage
Definition: winuser.h:5818
#define LVIF_PARAM
Definition: commctrl.h:2307
__GNU_EXTENSION typedef unsigned __int64 * PULONGLONG
Definition: ntbasedef.h:384
HINSTANCE WINAPI ShellExecuteW(HWND hwnd, LPCWSTR lpVerb, LPCWSTR lpFile, LPCWSTR lpParameters, LPCWSTR lpDirectory, INT nShowCmd)
Definition: shlexec.cpp:2274
static VOID SetListViewColumns(_In_ HWND hwndListView)
Definition: userprofile.c:275
#define LVITEM
Definition: commctrl.h:2371
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
#define ERROR_PATH_NOT_FOUND
Definition: winerror.h:106
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
GLenum GLenum GLvoid GLvoid * column
Definition: glext.h:5664
LPARAM lParam
Definition: commctrl.h:3036
#define IDCANCEL
Definition: winuser.h:825
#define LVIF_STATE
Definition: commctrl.h:2308
#define wsprintf
Definition: winuser.h:5840
#define memset(x, y, z)
Definition: compat.h:39
#define WM_INITDIALOG
Definition: winuser.h:1721
LPARAM lParam
Definition: combotst.c:139
#define IDS_USERPROFILE_LOCAL
Definition: resource.h:36
#define LOWORD(l)
Definition: pedump.c:82
#define IDS_USERPROFILE_TYPE
Definition: resource.h:33
size_t __cdecl wcslen(_In_z_ const wchar_t *_Str)
#define HeapFree(x, y, z)
Definition: compat.h:594
PSDBQUERYRESULT_VISTA PVOID DWORD * dwSize
Definition: env.c:54
#define LoadString
Definition: winuser.h:5794
#define IDS_USERPROFILE_NAME
Definition: resource.h:31
_Check_return_ _CRTIMP int __cdecl _wcsicmp(_In_z_ const wchar_t *_Str1, _In_z_ const wchar_t *_Str2)
#define LVIS_FOCUSED
Definition: commctrl.h:2314
#define WM_NOTIFY
Definition: richedit.h:61
static VOID UpdateButtonState(_In_ HWND hwndDlg, _In_ HWND hwndListView)
Definition: userprofile.c:600
PWSTR pszProfilePath
Definition: userprofile.c:23
HANDLE WINAPI FindFirstFileW(IN LPCWSTR lpFileName, OUT LPWIN32_FIND_DATAW lpFindFileData)
Definition: find.c:320
static INT_PTR CALLBACK CopyUserProfileDlgProc(_In_ HWND hwndDlg, _In_ UINT uMsg, _In_ WPARAM wParam, _In_ LPARAM lParam)
Definition: userprofile.c:202
#define HKEY_LOCAL_MACHINE
Definition: winreg.h:12
#define ERROR_INSUFFICIENT_BUFFER
Definition: dderror.h:10
BOOL WINAPI FindClose(HANDLE hFindFile)
Definition: find.c:502