ReactOS  0.4.13-dev-479-gec9c8fd
userprofile.c File Reference
#include "precomp.h"
#include <sddl.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 (HWND hwndDlg, 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 VOID AddUserProfile (_In_ HWND hwndListView, _In_ LPTSTR lpProfileSid, _In_ PSID pMySid, _In_ HKEY hProfileKey)
 
static VOID UpdateButtonState (_In_ HWND hwndDlg, _In_ HWND hwndListView)
 
static VOID AddUserProfiles (_In_ HWND hwndDlg, _In_ HWND hwndListView)
 
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_ LPTSTR  lpProfileSid,
_In_ PSID  pMySid,
_In_ HKEY  hProfileKey 
)
static

Definition at line 326 of file userprofile.c.

331 {
332  PPROFILEDATA pProfileData = NULL;
333  WCHAR szAccountName[128], szDomainName[128];
334  WCHAR szNameBuffer[256];
335  SID_NAME_USE Use;
336  DWORD dwAccountNameSize, dwDomainNameSize;
337  DWORD dwProfileData, dwSize, dwType, dwState = 0;
338  PWSTR ptr;
339  PSID pSid = NULL;
340  INT nId, iItem;
341  LV_ITEM lvi;
342 
343  if (!ConvertStringSidToSid(lpProfileSid,
344  &pSid))
345  return;
346 
347  dwAccountNameSize = ARRAYSIZE(szAccountName);
348  dwDomainNameSize = ARRAYSIZE(szDomainName);
349  if (!LookupAccountSidW(NULL,
350  pSid,
351  szAccountName,
352  &dwAccountNameSize,
353  szDomainName,
354  &dwDomainNameSize,
355  &Use))
356  {
357  /* Unknown account */
358  LoadStringW(hApplet, IDS_USERPROFILE_ACCOUNT_UNKNOWN, szNameBuffer, ARRAYSIZE(szNameBuffer));
359  }
360  else
361  {
362  /* Show only the user accounts */
363  if (Use != SidTypeUser)
364  goto done;
365 
366  if (szAccountName[0] == UNICODE_NULL)
367  {
368  /* Deleted account */
369  LoadStringW(hApplet, IDS_USERPROFILE_ACCOUNT_DELETED, szNameBuffer, ARRAYSIZE(szNameBuffer));
370  }
371  else
372  {
373  /* Normal account */
374  wsprintf(szNameBuffer, L"%s\\%s", szDomainName, szAccountName);
375  }
376  }
377 
378  /* Get the profile state value */
379  dwSize = sizeof(dwState);
380  if (RegQueryValueExW(hProfileKey,
381  L"State",
382  NULL,
383  &dwType,
384  (LPBYTE)&dwState,
385  &dwSize) != ERROR_SUCCESS)
386  {
387  dwState = 0;
388  }
389 
390  /* Create and fill the profile data entry */
391  dwProfileData = sizeof(PROFILEDATA) +
392  ((wcslen(szNameBuffer) + 1) * sizeof(WCHAR));
393  pProfileData = HeapAlloc(GetProcessHeap(),
394  0,
395  dwProfileData);
396  if (pProfileData == NULL)
397  goto done;
398 
399  pProfileData->bMyProfile = EqualSid(pMySid, pSid);
400  pProfileData->dwState = dwState;
401 
402  ptr = (PWSTR)((ULONG_PTR)pProfileData + sizeof(PROFILEDATA));
403  pProfileData->pszFullName = ptr;
404 
405  wcscpy(pProfileData->pszFullName, szNameBuffer);
406 
407  /* Add the profile and set its name */
408  memset(&lvi, 0x00, sizeof(lvi));
409  lvi.mask = LVIF_TEXT | LVIF_STATE | LVIF_PARAM;
410  lvi.pszText = pProfileData->pszFullName;
411  lvi.state = 0;
412  lvi.lParam = (LPARAM)pProfileData;
413  iItem = ListView_InsertItem(hwndListView, &lvi);
414 
415  /* Set the profile type */
416  if (dwState & 0x0001) // PROFILE_MANDATORY
418  else if (dwState & 0x0010) // PROFILE_UPDATE_CENTRAL
420  else
421  nId = IDS_USERPROFILE_LOCAL;
422 
423  LoadStringW(hApplet, nId, szAccountName, ARRAYSIZE(szAccountName));
424 
425  ListView_SetItemText(hwndListView, iItem, 2, szAccountName);
426 
427 done:
428  if (pSid != NULL)
429  LocalFree(pSid);
430 }
#define LV_ITEM
Definition: commctrl.h:2309
enum _SID_NAME_USE SID_NAME_USE
#define ERROR_SUCCESS
Definition: deptool.c:10
uint16_t * PWSTR
Definition: typedefs.h:54
#define ConvertStringSidToSid
Definition: sddl.h:161
BOOL WINAPI EqualSid(PSID pSid1, PSID pSid2)
Definition: security.c:708
#define ARRAYSIZE(array)
Definition: filtermapper.c:47
HINSTANCE hApplet
Definition: access.c:17
#define ListView_InsertItem(hwnd, pitem)
Definition: commctrl.h:2380
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
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
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:2663
#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
#define IDS_USERPROFILE_ACCOUNT_UNKNOWN
Definition: resource.h:41
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
BOOL bMyProfile
Definition: userprofile.c:18
HLOCAL NTAPI LocalFree(HLOCAL hMem)
Definition: heapmem.c:1577
PWSTR pszFullName
Definition: userprofile.c:20
static PSID pSid
Definition: security.c:74
DWORD dwState
Definition: userprofile.c:19
#define LVIF_PARAM
Definition: commctrl.h:2283
#define LVIF_STATE
Definition: commctrl.h:2284
#define wsprintf
Definition: winuser.h:5731
#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

Referenced by AddUserProfiles().

◆ AddUserProfiles()

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

Definition at line 472 of file userprofile.c.

475 {
476  HKEY hKeyUserProfiles = INVALID_HANDLE_VALUE;
477  HKEY hProfileKey;
478  DWORD dwIndex;
479  WCHAR szProfileSid[64];
480  DWORD dwSidLength;
481  FILETIME ftLastWrite;
482  DWORD dwSize;
483  HANDLE hToken = NULL;
484  PTOKEN_USER pTokenUser = NULL;
485 
487  return;
488 
489  GetTokenInformation(hToken, TokenUser, NULL, 0, &dwSize);
490  if (dwSize == 0)
491  goto done;
492 
493  pTokenUser = HeapAlloc(GetProcessHeap(), 0, dwSize);
494  if (pTokenUser == NULL)
495  goto done;
496 
497  if (!GetTokenInformation(hToken, TokenUser, pTokenUser, dwSize, &dwSize))
498  goto done;
499 
501  L"Software\\Microsoft\\Windows NT\\CurrentVersion\\ProfileList",
502  0,
503  KEY_READ,
504  &hKeyUserProfiles))
505  goto done;
506 
507  for (dwIndex = 0; ; dwIndex++)
508  {
509  dwSidLength = ARRAYSIZE(szProfileSid);
510  if (RegEnumKeyExW(hKeyUserProfiles,
511  dwIndex,
512  szProfileSid,
513  &dwSidLength,
514  NULL,
515  NULL,
516  NULL,
517  &ftLastWrite))
518  break;
519 
520  if (RegOpenKeyExW(hKeyUserProfiles,
521  szProfileSid,
522  0,
523  KEY_READ,
524  &hProfileKey) == ERROR_SUCCESS)
525  {
526  AddUserProfile(hwndListView, szProfileSid, pTokenUser->User.Sid, hProfileKey);
527  RegCloseKey(hProfileKey);
528  }
529  }
530 
533 
535 
536 done:
537  if (hKeyUserProfiles != INVALID_HANDLE_VALUE)
538  RegCloseKey(hKeyUserProfiles);
539 
540  if (pTokenUser != NULL)
541  HeapFree(GetProcessHeap(), 0, pTokenUser);
542 
543  if (hToken != NULL)
544  CloseHandle(hToken);
545 }
#define CloseHandle
Definition: compat.h:398
#define ERROR_SUCCESS
Definition: deptool.c:10
#define KEY_READ
Definition: nt_native.h:1023
#define ARRAYSIZE(array)
Definition: filtermapper.c:47
#define INVALID_HANDLE_VALUE
Definition: compat.h:391
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:1168
unsigned long DWORD
Definition: ntddk_ex.h:95
static const WCHAR L[]
Definition: oid.c:1250
static VOID AddUserProfile(_In_ HWND hwndListView, _In_ LPTSTR lpProfileSid, _In_ PSID pMySid, _In_ HKEY hProfileKey)
Definition: userprofile.c:326
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
static VOID UpdateButtonState(_In_ HWND hwndDlg, _In_ HWND hwndListView)
Definition: userprofile.c:434
#define HKEY_LOCAL_MACHINE
Definition: winreg.h:12

Referenced by OnInitUserProfileDialog().

◆ ChangeUserProfileType()

static BOOL ChangeUserProfileType ( _In_ HWND  hwndDlg)
static

Definition at line 105 of file userprofile.c.

107 {
109  LVITEM Item;
110  INT iSelected;
111 
112  DPRINT("ChangeUserProfileType(%p)\n", hwndDlg);
113 
115  if (hwndListView == NULL)
116  return FALSE;
117 
119  if (iSelected == -1)
120  return FALSE;
121 
122  ZeroMemory(&Item, sizeof(LVITEM));
123  Item.mask = LVIF_PARAM;
124  Item.iItem = iSelected;
125  Item.iSubItem = 0;
126  if (!ListView_GetItem(hwndListView, &Item))
127  return FALSE;
128 
129  if (Item.lParam == 0)
130  return FALSE;
131 
134  hwndDlg,
136  (LPARAM)Item.lParam) == IDOK)
137  {
138  /* FIXME: Update the profile list view */
139  return TRUE;
140  }
141 
142  return FALSE;
143 }
#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:72
#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:5630
#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 233 of file userprofile.c.

235 {
237  LVITEM Item;
238  INT iSelected;
239 
240  DPRINT("CopyUserProfile()\n");
241 
243  if (hwndListView == NULL)
244  return FALSE;
245 
247  if (iSelected == -1)
248  return FALSE;
249 
250  ZeroMemory(&Item, sizeof(LVITEM));
251  Item.mask = LVIF_PARAM;
252  Item.iItem = iSelected;
253  Item.iSubItem = 0;
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 }
#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:5630
#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:201

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 201 of file userprofile.c.

206 {
207  switch (uMsg)
208  {
209  case WM_INITDIALOG:
210  return TRUE;
211 
212  case WM_DESTROY:
213  break;
214 
215  case WM_COMMAND:
216  switch (LOWORD(wParam))
217  {
218  case IDOK:
219  case IDCANCEL:
220  EndDialog(hwndDlg,
221  LOWORD(wParam));
222  return TRUE;
223  }
224  break;
225  }
226 
227  return FALSE;
228 }
#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:1716
#define IDCANCEL
Definition: winuser.h:825
#define WM_INITDIALOG
Definition: winuser.h:1715
#define LOWORD(l)
Definition: pedump.c:82

Referenced by CopyUserProfile().

◆ DeleteUserProfile()

static BOOL DeleteUserProfile ( _In_ HWND  hwndDlg)
static

Definition at line 148 of file userprofile.c.

150 {
151  WCHAR szTitle[64], szRawText[128], szCookedText[256];
153  LVITEM Item;
154  INT iSelected;
155  PPROFILEDATA pProfileData;
156 
157  DPRINT("DeleteUserProfile()\n");
158 
160  if (hwndListView == NULL)
161  return FALSE;
162 
164  if (iSelected == -1)
165  return FALSE;
166 
167  ZeroMemory(&Item, sizeof(LVITEM));
168  Item.mask = LVIF_PARAM;
169  Item.iItem = iSelected;
170  Item.iSubItem = 0;
171  if (!ListView_GetItem(hwndListView, &Item))
172  return FALSE;
173 
174  if (Item.lParam == 0)
175  return FALSE;
176 
177  pProfileData = (PPROFILEDATA)Item.lParam;
178  if (pProfileData->bMyProfile)
179  return FALSE;
180 
183  swprintf(szCookedText, szRawText, pProfileData->pszFullName);
184 
185  if (MessageBoxW(hwndDlg,
186  szCookedText,
187  szTitle,
189  {
190  /* FIXME: Delete the profile here! */
191  return TRUE;
192  }
193 
194  return FALSE;
195 }
#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
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
BOOL bMyProfile
Definition: userprofile.c:18
#define IDS_USERPROFILE_CONFIRM_DELETE_TITLE
Definition: resource.h:40
PWSTR pszFullName
Definition: userprofile.c:20
#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().

◆ OnDestroy()

static VOID OnDestroy ( _In_ HWND  hwndDlg)
static

Definition at line 560 of file userprofile.c.

562 {
563  HWND hwndList;
564  INT nItems, i;
565  LVITEM Item;
566 
567  hwndList = GetDlgItem(hwndDlg, IDC_USERPROFILE_LIST);
568 
569  nItems = ListView_GetItemCount(hwndList);
570  for (i = 0; i < nItems; i++)
571  {
572  Item.iItem = i;
573  Item.iSubItem = 0;
574  if (ListView_GetItem(hwndList, &Item))
575  {
576  if (Item.lParam != 0)
577  HeapFree(GetProcessHeap(), 0, (PVOID)Item.lParam);
578  }
579  }
580 }
#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 549 of file userprofile.c.

550 {
551  /* Initialize the list view control */
553 
554  AddUserProfiles(hwndDlg, GetDlgItem(hwndDlg, IDC_USERPROFILE_LIST));
555 }
#define IDC_USERPROFILE_LIST
Definition: resource.h:101
HWND WINAPI GetDlgItem(_In_opt_ HWND, _In_ int)
static VOID AddUserProfiles(_In_ HWND hwndDlg, _In_ HWND hwndListView)
Definition: userprofile.c:472
static VOID SetListViewColumns(_In_ HWND hwndListView)
Definition: userprofile.c:275

Referenced by UserProfileDlgProc().

◆ OnNotify()

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

Definition at line 585 of file userprofile.c.

588 {
589  if (nmhdr->idFrom == IDC_USERACCOUNT_LINK && nmhdr->code == NM_CLICK)
590  {
591  ShellExecuteW(hwndDlg, NULL, L"usrmgr.cpl", NULL, NULL, 0);
592  }
593  else if (nmhdr->idFrom == IDC_USERPROFILE_LIST && nmhdr->code == LVN_ITEMCHANGED)
594  {
595  UpdateButtonState(hwndDlg, nmhdr->hwndFrom);
596  }
597 }
#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:2236
static VOID UpdateButtonState(_In_ HWND hwndDlg, _In_ HWND hwndListView)
Definition: userprofile.c:434

Referenced by UserProfileDlgProc().

◆ OnProfileTypeInit()

static BOOL OnProfileTypeInit ( HWND  hwndDlg,
PPROFILEDATA  pProfileData 
)
static

Definition at line 26 of file userprofile.c.

29 {
30  PWSTR pszRawBuffer = NULL, pszCookedBuffer = NULL;
31  INT nLength;
32 
34  pszRawBuffer = NULL;
35  if (nLength == 0)
36  return FALSE;
37 
38  pszRawBuffer = HeapAlloc(GetProcessHeap(), 0, (nLength + 1) * sizeof(WCHAR));
39  if (pszRawBuffer == NULL)
40  return FALSE;
41 
43 
44  pszCookedBuffer = HeapAlloc(GetProcessHeap(), 0, (nLength + wcslen(pProfileData->pszFullName) + 1) * sizeof(WCHAR));
45  if (pszCookedBuffer == NULL)
46  goto done;
47 
48  swprintf(pszCookedBuffer, pszRawBuffer, pProfileData->pszFullName);
49 
50  /* Set the full text */
51  SetDlgItemText(hwndDlg, IDC_USERPROFILE_TYPE_TEXT, pszCookedBuffer);
52 
53  /* FIXME: Right now, we support local user profiles only! */
56  EnableWindow(GetDlgItem(hwndDlg, IDOK), FALSE);
57 
58 done:
59  if (pszCookedBuffer != NULL)
60  HeapFree(GetProcessHeap(), 0, pszCookedBuffer);
61 
62  if (pszRawBuffer != NULL)
63  HeapFree(GetProcessHeap(), 0, pszRawBuffer);
64 
65  return TRUE;
66 }
#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:5715
BOOL WINAPI EnableWindow(_In_ HWND, _In_ BOOL)
PWSTR pszFullName
Definition: userprofile.c:20
#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 275 of file userprofile.c.

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 }
#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:5709
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:5685
#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 434 of file userprofile.c.

437 {
438  LVITEM Item;
439  INT iSelected;
440  BOOL bMyProfile;
441 
443  if (iSelected != -1)
444  {
445  Item.mask = LVIF_PARAM;
446  Item.iItem = iSelected;
447  Item.iSubItem = 0;
448  if (ListView_GetItem(hwndListView, &Item))
449  {
450  if (Item.lParam != 0)
451  {
452  bMyProfile = ((PPROFILEDATA)Item.lParam)->bMyProfile;
453  if (/*IsUserAnAdmin() &&*/ !bMyProfile)
454  {
457  }
458  }
459  }
461  }
462  else
463  {
467  }
468 }
#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 602 of file userprofile.c.

606 {
607  switch (uMsg)
608  {
609  case WM_INITDIALOG:
610  OnInitUserProfileDialog(hwndDlg);
611  return TRUE;
612 
613  case WM_DESTROY:
614  OnDestroy(hwndDlg);
615  break;
616 
617  case WM_COMMAND:
618  switch (LOWORD(wParam))
619  {
620  case IDOK:
621  case IDCANCEL:
622  EndDialog(hwndDlg,
623  LOWORD(wParam));
624  return TRUE;
625 
627  ChangeUserProfileType(hwndDlg);
628  break;
629 
631  DeleteUserProfile(hwndDlg);
632  break;
633 
635  CopyUserProfile(hwndDlg);
636  break;
637  }
638  break;
639 
640  case WM_NOTIFY:
641  OnNotify(hwndDlg, (NMHDR *)lParam);
642  break;
643  }
644 
645  return FALSE;
646 }
#define TRUE
Definition: types.h:120
#define IDOK
Definition: winuser.h:824
static VOID OnInitUserProfileDialog(HWND hwndDlg)
Definition: userprofile.c:549
#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:233
#define IDC_USERPROFILE_DELETE
Definition: resource.h:103
static BOOL ChangeUserProfileType(_In_ HWND hwndDlg)
Definition: userprofile.c:105
#define WM_DESTROY
Definition: winuser.h:1591
#define WM_COMMAND
Definition: winuser.h:1716
static VOID OnDestroy(_In_ HWND hwndDlg)
Definition: userprofile.c:560
#define IDC_USERPROFILE_COPY
Definition: resource.h:104
static VOID OnNotify(_In_ HWND hwndDlg, _In_ NMHDR *nmhdr)
Definition: userprofile.c:585
static BOOL DeleteUserProfile(_In_ HWND hwndDlg)
Definition: userprofile.c:148
#define IDCANCEL
Definition: winuser.h:825
#define WM_INITDIALOG
Definition: winuser.h:1715
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 72 of file userprofile.c.

77 {
78  switch (uMsg)
79  {
80  case WM_INITDIALOG:
82  return TRUE;
83 
84  case WM_DESTROY:
85  break;
86 
87  case WM_COMMAND:
88  switch (LOWORD(wParam))
89  {
90  case IDOK:
91  case IDCANCEL:
92  EndDialog(hwndDlg,
93  LOWORD(wParam));
94  return TRUE;
95  }
96  break;
97  }
98 
99  return FALSE;
100 }
#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(HWND hwndDlg, PPROFILEDATA pProfileData)
Definition: userprofile.c:26
#define WM_DESTROY
Definition: winuser.h:1591
#define WM_COMMAND
Definition: winuser.h:1716
#define IDCANCEL
Definition: winuser.h:825
#define WM_INITDIALOG
Definition: winuser.h:1715
LPARAM lParam
Definition: combotst.c:139
#define LOWORD(l)
Definition: pedump.c:82

Referenced by ChangeUserProfileType().