GitHub PullRequestReviewCommentEvent at 2014-05-13 15:01:40
Repository: mpc-hc
Actor: alexmarsev
Payload: {"comment":{"url":"https://api.github.com/repos/mpc-hc/mpc-hc/pulls/comments/12587863","id":12587863,"diff_hunk":"@@ -20,136 +20,108 @@\n  */\r\n \r\n #include \"stdafx.h\"\r\n-#include \"mplayerc.h\"\r\n #include \"AuthDlg.h\"\r\n-#include \"SettingsDefines.h\"\r\n+#include \"SysVersion.h\"\r\n+#include \"version.h\"\r\n \r\n+// We need to dynamically link to the functions provided by CredUI.lib in order\r\n+// to be able to use the features available to the OS.\r\n+#include <WinCred.h>\r\n+#include \"WinApiFunc.h\"\r\n \r\n-// CAuthDlg dialog\r\n-\r\n-IMPLEMENT_DYNAMIC(CAuthDlg, CDialog)\r\n-CAuthDlg::CAuthDlg(CWnd* pParent /*=nullptr*/)\r\n-    : CDialog(CAuthDlg::IDD, pParent)\r\n-    , m_username(_T(\"\"))\r\n-    , m_password(_T(\"\"))\r\n-    , m_remember(FALSE)\r\n-{\r\n-}\r\n-\r\n-CAuthDlg::~CAuthDlg()\r\n-{\r\n-}\r\n-\r\n-void CAuthDlg::DoDataExchange(CDataExchange* pDX)\r\n-{\r\n-    CDialog::DoDataExchange(pDX);\r\n-    DDX_Control(pDX, IDC_COMBO1, m_usernamectrl);\r\n-    DDX_Text(pDX, IDC_COMBO1, m_username);\r\n-    DDX_Text(pDX, IDC_EDIT3, m_password);\r\n-    DDX_Check(pDX, IDC_CHECK1, m_remember);\r\n-}\r\n-\r\n-CString CAuthDlg::DEncrypt(CString str)\r\n+HRESULT PromptForCredentials(HWND hWnd, CString strCaptionText, CString strMessageText, CString& strDomain, CString& strUsername, CString& strPassword, BOOL* bSave)\r\n {\r\n-    for (int i = 0; i < str.GetLength(); i++) {\r\n-        str.SetAt(i, str[i] ^ 5);\r\n-    }\r\n-    return str;\r\n-}\r\n-\r\n-\r\n-BEGIN_MESSAGE_MAP(CAuthDlg, CDialog)\r\n-    ON_BN_CLICKED(IDOK, OnBnClickedOk)\r\n-    ON_CBN_SELCHANGE(IDC_COMBO1, OnCbnSelchangeCombo1)\r\n-    ON_EN_SETFOCUS(IDC_EDIT3, OnEnSetfocusEdit3)\r\n-END_MESSAGE_MAP()\r\n-\r\n-\r\n-// CAuthDlg message handlers\r\n-\r\n-BOOL CAuthDlg::OnInitDialog()\r\n-{\r\n-    CDialog::OnInitDialog();\r\n-\r\n-    CWinApp* pApp = AfxGetApp();\r\n-\r\n-    if (pApp->m_pszRegistryKey) {\r\n-        CRegKey hSecKey(pApp->GetSectionKey(IDS_R_LOGINS));\r\n-        if (hSecKey) {\r\n-            int i = 0;\r\n-            TCHAR username[256], password[256];\r\n-            for (;;) {\r\n-                DWORD unlen = _countof(username);\r\n-                DWORD pwlen = sizeof(password);\r\n-                DWORD type = REG_SZ;\r\n-                if (ERROR_SUCCESS == RegEnumValue(\r\n-                            hSecKey, i++, username, &unlen, 0, &type, (BYTE*)password, &pwlen)) {\r\n-                    m_logins[username] = DEncrypt(password);\r\n-                    m_usernamectrl.AddString(username);\r\n-                } else {\r\n-                    break;\r\n+    CREDUI_INFO info = { sizeof(info) };\r\n+    info.hwndParent = hWnd;\r\n+    info.pszCaptionText = strCaptionText.Left(CREDUI_MAX_CAPTION_LENGTH);\r\n+    info.pszMessageText = strMessageText.Left(CREDUI_MAX_MESSAGE_LENGTH);\r\n+\r\n+    DWORD dwUsername = CREDUI_MAX_USERNAME_LENGTH + 1;\r\n+    DWORD dwPassword = CREDUI_MAX_PASSWORD_LENGTH + 1;\r\n+    DWORD dwDomain = CREDUI_MAX_GENERIC_TARGET_LENGTH + 1;\r\n+\r\n+    if (SysVersion::IsVistaOrLater()) {\r\n+        // Define CredUI.dll functions for Windows Vista+\r\n+        const WinApiFunc<BOOL(DWORD, LPWSTR, LPWSTR, PBYTE, DWORD*)>\r\n+            pCredPackAuthenticationBufferW = { \"CREDUI.DLL\", \"CredPackAuthenticationBufferW\" };\r","path":"src/mpc-hc/AuthDlg.cpp","position":99,"original_position":99,"commit_id":"8071761a5bb0554cd1093443c14bf42d09f50ad2","original_commit_id":"8071761a5bb0554cd1093443c14bf42d09f50ad2","user":{"login":"alexmarsev","id":2756009,"avatar_url":"https://avatars.githubusercontent.com/u/2756009?","gravatar_id":"2b2c40cebf0e1da618a00556acbbc06d","url":"https://api.github.com/users/alexmarsev","html_url":"https://github.com/alexmarsev","followers_url":"https://api.github.com/users/alexmarsev/followers","following_url":"https://api.github.com/users/alexmarsev/following{/other_user}","gists_url":"https://api.github.com/users/alexmarsev/gists{/gist_id}","starred_url":"https://api.github.com/users/alexmarsev/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/alexmarsev/subscriptions","organizations_url":"https://api.github.com/users/alexmarsev/orgs","repos_url":"https://api.github.com/users/alexmarsev/repos","events_url":"https://api.github.com/users/alexmarsev/events{/privacy}","received_events_url":"https://api.github.com/users/alexmarsev/received_events","type":"User","site_admin":false},"body":"It's no longer a pointer to use 'p' prefix. Either use 'fn' or nothing at all. I wouldn't also use 'const', but it's up to you.","created_at":"2014-05-13T15:01:40Z","updated_at":"2014-05-13T15:01:40Z","html_url":"https://github.com/mpc-hc/mpc-hc/pull/130#discussion_r12587863","pull_request_url":"https://api.github.com/repos/mpc-hc/mpc-hc/pulls/130","_links":{"self":{"href":"https://api.github.com/repos/mpc-hc/mpc-hc/pulls/comments/12587863"},"html":{"href":"https://github.com/mpc-hc/mpc-hc/pull/130#discussion_r12587863"},"pull_request":{"href":"https://api.github.com/repos/mpc-hc/mpc-hc/pulls/130"}}}}