static INT_PTR CALLBACK CopyProfileDlgProc( HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam) { PPROFILENAMES pProfileNames; pProfileNames = (PPROFILENAMES)GetWindowLongPtr(hwndDlg, DWLP_USER); switch (uMsg) { case WM_INITDIALOG: SetWindowLongPtr(hwndDlg, DWLP_USER, lParam); pProfileNames = (PPROFILENAMES)lParam; /* Set the old name */ SetDlgItemText(hwndDlg, IDC_COPYPROFILEFROM, pProfileNames->szSourceName); /* Set the new name */ SendDlgItemMessageW(hwndDlg, IDC_COPYPROFILETO, EM_SETLIMITTEXT, PROFILE_NAME_LENGTH - 1, 0); SetDlgItemText(hwndDlg, IDC_COPYPROFILETO, pProfileNames->szDestinationName); break; case WM_COMMAND: switch (LOWORD(wParam)) { case IDOK: GetDlgItemText(hwndDlg, IDC_COPYPROFILETO, pProfileNames->szDestinationName, PROFILE_NAME_LENGTH); if (IsProfileNameInUse(pProfileNames, FALSE)) ResourceMessageBox(hApplet, NULL, MB_OK | MB_ICONERROR, IDS_HWPROFILE_WARNING, IDS_HWPROFILE_ALREADY_IN_USE); else EndDialog(hwndDlg, IDOK); return TRUE; case IDCANCEL: EndDialog(hwndDlg, IDCANCEL); return TRUE; } break; } return FALSE; }
static VOID OnOk(PVIRTMEM pVirtMem) { if (pVirtMem->bModified == TRUE) { ResourceMessageBox(hApplet, NULL, MB_ICONINFORMATION | MB_OK, IDS_MESSAGEBOXTITLE, IDS_INFOREBOOT); WritePageFileSettings(pVirtMem); } }
/* Property page dialog callback */ INT_PTR CALLBACK AdvancedPageProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam) { PGLOBALDATA pGlobalData; pGlobalData = (PGLOBALDATA)GetWindowLongPtr(hwndDlg, DWLP_USER); switch (uMsg) { case WM_INITDIALOG: pGlobalData = (PGLOBALDATA)((LPPROPSHEETPAGE)lParam)->lParam; SetWindowLongPtr(hwndDlg, DWLP_USER, (LONG_PTR)pGlobalData); InitLanguagesList(hwndDlg, pGlobalData); InitCodePagesList(hwndDlg); break; case WM_COMMAND: switch (LOWORD(wParam)) { case IDC_LANGUAGE_COMBO: if (HIWORD(wParam) == CBN_SELCHANGE) { LCID lcid; INT iIndex; iIndex = SendMessage(hLangList, CB_GETCURSEL, 0, 0); if (iIndex == CB_ERR) break; lcid = SendMessage(hLangList, CB_GETITEMDATA, iIndex, 0); if (lcid == (LCID)CB_ERR) break; pGlobalData->SystemLCID = lcid; PropSheet_Changed(GetParent(hwndDlg), hwndDlg); } break; case IDC_APPLY_CUR_USER_DEF_PROFILE: if (HIWORD(wParam) == BN_CLICKED) { if (SendDlgItemMessageW(hwndDlg, IDC_APPLY_CUR_USER_DEF_PROFILE, BM_GETCHECK, 0, 0)) { ResourceMessageBox(hwndDlg, MB_OK | MB_ICONWARNING, IDS_APPLY_DEFAULT_TITLE, IDS_APPLY_DEFAULT_TEXT); pGlobalData->bApplyToDefaultUser = TRUE; } else { pGlobalData->bApplyToDefaultUser = FALSE; } PropSheet_Changed(GetParent(hwndDlg), hwndDlg); } break; } break; case WM_NOTIFY: { LPNMHDR lpnm = (LPNMHDR)lParam; if (lpnm->code == (UINT)PSN_APPLY) { PropSheet_UnChanged(GetParent(hwndDlg), hwndDlg); SaveSystemSettings(pGlobalData); SaveFontSubstitutionSettings(hwndDlg, pGlobalData); SaveFontLinkingSettings(hwndDlg, pGlobalData); } } break; } return FALSE; }
static VOID OnSet(PVIRTMEM pVirtMem) { INT Index; UINT MinSize = -1; UINT MaxSize = -1; BOOL bTranslated; INT DriveIndex = 0; Index = (INT)SendDlgItemMessage(pVirtMem->hSelf, IDC_PAGEFILELIST, LB_GETCURSEL, 0, 0); if (Index >= 0 && Index < pVirtMem->Count) { DriveIndex = SendDlgItemMessage(pVirtMem->hSelf, IDC_PAGEFILELIST, LB_GETITEMDATA, 0, 0); /* Check if custom settings are checked */ if (IsDlgButtonChecked(pVirtMem->hSelf, IDC_CUSTOM) == BST_CHECKED) { MinSize = GetDlgItemInt(pVirtMem->hSelf, IDC_INITIALSIZE, &bTranslated, FALSE); if (!bTranslated) { ResourceMessageBox(hApplet, NULL, MB_ICONWARNING | MB_OK, IDS_MESSAGEBOXTITLE, IDS_WARNINITIALSIZE); return; } MaxSize = GetDlgItemInt(pVirtMem->hSelf, IDC_MAXSIZE, &bTranslated, FALSE); if (!bTranslated) { ResourceMessageBox(hApplet, NULL, MB_ICONWARNING | MB_OK, IDS_MESSAGEBOXTITLE, IDS_WARNMAXIMUMSIZE); return; } /* Check the valid range of the minimum size */ if (MinSize < 16 || MinSize > pVirtMem->Pagefile[DriveIndex].FreeSize) { ResourceMessageBox(hApplet, NULL, MB_ICONWARNING | MB_OK, IDS_MESSAGEBOXTITLE, IDS_WARNINITIALRANGE); return; } /* Check the valid range of the maximum size */ if (MaxSize < MinSize || MaxSize > pVirtMem->Pagefile[DriveIndex].FreeSize || MaxSize > 4095) { ResourceMessageBox(hApplet, NULL, MB_ICONWARNING | MB_OK, IDS_MESSAGEBOXTITLE, IDS_WARNMAXIMUMRANGE); return; } pVirtMem->Pagefile[DriveIndex].NewMinSize = MinSize; pVirtMem->Pagefile[DriveIndex].NewMaxSize = MaxSize; pVirtMem->Pagefile[DriveIndex].bUsed = TRUE; } else if (IsDlgButtonChecked(pVirtMem->hSelf, IDC_NOPAGEFILE) == BST_CHECKED) { /* No pagefile */ pVirtMem->Pagefile[DriveIndex].NewMinSize = -1; pVirtMem->Pagefile[DriveIndex].NewMaxSize = -1; pVirtMem->Pagefile[DriveIndex].bUsed = TRUE; } else { /* System managed size*/ pVirtMem->Pagefile[DriveIndex].NewMinSize = 0; pVirtMem->Pagefile[DriveIndex].NewMaxSize = 0; pVirtMem->Pagefile[DriveIndex].bUsed = TRUE; } /* Set the modified flag if min or max size has changed */ if ((pVirtMem->Pagefile[DriveIndex].OldMinSize != pVirtMem->Pagefile[DriveIndex].NewMinSize) || (pVirtMem->Pagefile[DriveIndex].OldMaxSize != pVirtMem->Pagefile[DriveIndex].NewMaxSize)) pVirtMem->bModified = TRUE; UpdatePagefileEntry(pVirtMem, Index, DriveIndex); } }
static BOOL DoChangePassword( IN PGINA_CONTEXT pgContext, IN HWND hwndDlg) { WCHAR UserName[256]; WCHAR Domain[256]; WCHAR OldPassword[256]; WCHAR NewPassword1[256]; WCHAR NewPassword2[256]; PMSV1_0_CHANGEPASSWORD_REQUEST RequestBuffer = NULL; PMSV1_0_CHANGEPASSWORD_RESPONSE ResponseBuffer = NULL; ULONG RequestBufferSize; ULONG ResponseBufferSize = 0; LPWSTR Ptr; BOOL res = FALSE; NTSTATUS ProtocolStatus; NTSTATUS Status; GetDlgItemTextW(hwndDlg, IDC_CHANGEPWD_USERNAME, UserName, 256); GetDlgItemTextW(hwndDlg, IDC_CHANGEPWD_DOMAIN, Domain, 256); GetDlgItemTextW(hwndDlg, IDC_CHANGEPWD_OLDPWD, OldPassword, 256); GetDlgItemTextW(hwndDlg, IDC_CHANGEPWD_NEWPWD1, NewPassword1, 256); GetDlgItemTextW(hwndDlg, IDC_CHANGEPWD_NEWPWD2, NewPassword2, 256); /* Compare the two passwords and fail if they do not match */ if (wcscmp(NewPassword1, NewPassword2) != 0) { ResourceMessageBox(pgContext, hwndDlg, MB_OK | MB_ICONEXCLAMATION, IDS_CHANGEPWDTITLE, IDS_NONMATCHINGPASSWORDS); return FALSE; } /* Calculate the request buffer size */ RequestBufferSize = sizeof(MSV1_0_CHANGEPASSWORD_REQUEST) + ((wcslen(Domain) + 1) * sizeof(WCHAR)) + ((wcslen(UserName) + 1) * sizeof(WCHAR)) + ((wcslen(OldPassword) + 1) * sizeof(WCHAR)) + ((wcslen(NewPassword1) + 1) * sizeof(WCHAR)); /* Allocate the request buffer */ RequestBuffer = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, RequestBufferSize); if (RequestBuffer == NULL) { ERR("HeapAlloc failed\n"); return FALSE; } /* Initialize the request buffer */ RequestBuffer->MessageType = MsV1_0ChangePassword; RequestBuffer->Impersonating = TRUE; Ptr = (LPWSTR)((ULONG_PTR)RequestBuffer + sizeof(MSV1_0_CHANGEPASSWORD_REQUEST)); /* Pack the domain name */ RequestBuffer->DomainName.Length = wcslen(Domain) * sizeof(WCHAR); RequestBuffer->DomainName.MaximumLength = RequestBuffer->DomainName.Length + sizeof(WCHAR); RequestBuffer->DomainName.Buffer = Ptr; RtlCopyMemory(RequestBuffer->DomainName.Buffer, Domain, RequestBuffer->DomainName.MaximumLength); Ptr = (LPWSTR)((ULONG_PTR)Ptr + RequestBuffer->DomainName.MaximumLength); /* Pack the user name */ RequestBuffer->AccountName.Length = wcslen(UserName) * sizeof(WCHAR); RequestBuffer->AccountName.MaximumLength = RequestBuffer->AccountName.Length + sizeof(WCHAR); RequestBuffer->AccountName.Buffer = Ptr; RtlCopyMemory(RequestBuffer->AccountName.Buffer, UserName, RequestBuffer->AccountName.MaximumLength); Ptr = (LPWSTR)((ULONG_PTR)Ptr + RequestBuffer->AccountName.MaximumLength); /* Pack the old password */ RequestBuffer->OldPassword.Length = wcslen(OldPassword) * sizeof(WCHAR); RequestBuffer->OldPassword.MaximumLength = RequestBuffer->OldPassword.Length + sizeof(WCHAR); RequestBuffer->OldPassword.Buffer = Ptr; RtlCopyMemory(RequestBuffer->OldPassword.Buffer, OldPassword, RequestBuffer->OldPassword.MaximumLength); Ptr = (LPWSTR)((ULONG_PTR)Ptr + RequestBuffer->OldPassword.MaximumLength); /* Pack the new password */ RequestBuffer->NewPassword.Length = wcslen(NewPassword1) * sizeof(WCHAR); RequestBuffer->NewPassword.MaximumLength = RequestBuffer->NewPassword.Length + sizeof(WCHAR); RequestBuffer->NewPassword.Buffer = Ptr; RtlCopyMemory(RequestBuffer->NewPassword.Buffer, NewPassword1, RequestBuffer->NewPassword.MaximumLength); /* Connect to the LSA server */ if (!ConnectToLsa(pgContext)) { ERR("ConnectToLsa() failed\n"); goto done; } /* Call the authentication package */ Status = LsaCallAuthenticationPackage(pgContext->LsaHandle, pgContext->AuthenticationPackage, RequestBuffer, RequestBufferSize, (PVOID*)&ResponseBuffer, &ResponseBufferSize, &ProtocolStatus); if (!NT_SUCCESS(Status)) { ERR("LsaCallAuthenticationPackage failed (Status 0x%08lx)\n", Status); goto done; } if (!NT_SUCCESS(ProtocolStatus)) { TRACE("LsaCallAuthenticationPackage failed (ProtocolStatus 0x%08lx)\n", ProtocolStatus); goto done; } res = TRUE; ResourceMessageBox(pgContext, hwndDlg, MB_OK | MB_ICONINFORMATION, IDS_CHANGEPWDTITLE, IDS_PASSWORDCHANGED); if ((wcscmp(UserName, pgContext->UserName) == 0) && (wcscmp(Domain, pgContext->Domain) == 0) && (wcscmp(OldPassword, pgContext->Password) == 0)) { ZeroMemory(pgContext->Password, 256 * sizeof(WCHAR)); wcscpy(pgContext->Password, NewPassword1); } done: if (RequestBuffer != NULL) HeapFree(GetProcessHeap(), 0, RequestBuffer); if (ResponseBuffer != NULL) LsaFreeReturnBuffer(ResponseBuffer); return res; }
static BOOL DoLogon( IN HWND hwndDlg, IN OUT PGINA_CONTEXT pgContext) { LPWSTR UserName = NULL; LPWSTR Password = NULL; LPWSTR Domain = NULL; BOOL result = FALSE; NTSTATUS Status, SubStatus = STATUS_SUCCESS; if (GetTextboxText(hwndDlg, IDC_USERNAME, &UserName) && *UserName == '\0') goto done; if (GetTextboxText(hwndDlg, IDC_LOGON_TO, &Domain) && *Domain == '\0') goto done; if (!GetTextboxText(hwndDlg, IDC_PASSWORD, &Password)) goto done; Status = DoLoginTasks(pgContext, UserName, Domain, Password, &SubStatus); if (Status == STATUS_LOGON_FAILURE) { ResourceMessageBox(pgContext, hwndDlg, MB_OK | MB_ICONEXCLAMATION, IDS_LOGONTITLE, IDS_LOGONWRONGUSERORPWD); goto done; } else if (Status == STATUS_ACCOUNT_RESTRICTION) { TRACE("DoLoginTasks failed! Status 0x%08lx SubStatus 0x%08lx\n", Status, SubStatus); if (SubStatus == STATUS_ACCOUNT_DISABLED) { ResourceMessageBox(pgContext, hwndDlg, MB_OK | MB_ICONEXCLAMATION, IDS_LOGONTITLE, IDS_LOGONUSERDISABLED); goto done; } else if (SubStatus == STATUS_ACCOUNT_LOCKED_OUT) { TRACE("Account locked!\n"); pgContext->pWlxFuncs->WlxMessageBox(pgContext->hWlx, hwndDlg, L"Account locked!", L"Logon error", MB_OK | MB_ICONERROR); goto done; } else if ((SubStatus == STATUS_PASSWORD_MUST_CHANGE) || (SubStatus == STATUS_PASSWORD_EXPIRED)) { if (SubStatus == STATUS_PASSWORD_MUST_CHANGE) ResourceMessageBox(pgContext, hwndDlg, MB_OK | MB_ICONSTOP, IDS_LOGONTITLE, IDS_PASSWORDMUSTCHANGE); else ResourceMessageBox(pgContext, hwndDlg, MB_OK | MB_ICONSTOP, IDS_LOGONTITLE, IDS_PASSWORDEXPIRED); if (!OnChangePassword(hwndDlg, pgContext)) goto done; Status = DoLoginTasks(pgContext, pgContext->UserName, pgContext->Domain, pgContext->Password, &SubStatus); if (!NT_SUCCESS(Status)) { TRACE("Login after password change failed! (Status 0x%08lx)\n", Status); goto done; } } else { TRACE("Other error!\n"); pgContext->pWlxFuncs->WlxMessageBox(pgContext->hWlx, hwndDlg, L"Other error!", L"Logon error", MB_OK | MB_ICONERROR); goto done; } } else if (!NT_SUCCESS(Status)) { TRACE("DoLoginTasks failed! Status 0x%08lx\n", Status); goto done; } if (!CreateProfile(pgContext, UserName, Domain, Password)) { ERR("Failed to create the profile!\n"); goto done; } ZeroMemory(pgContext->Password, 256 * sizeof(WCHAR)); wcscpy(pgContext->Password, Password); result = TRUE; done: if (UserName != NULL) HeapFree(GetProcessHeap(), 0, UserName); if (Password != NULL) HeapFree(GetProcessHeap(), 0, Password); if (Domain != NULL) HeapFree(GetProcessHeap(), 0, Domain); return result; }