Author: dreimer Date: Sun Oct 21 16:23:13 2007 New Revision: 29731
URL: http://svn.reactos.org/svn/reactos?rev=29731&view=rev Log: Updates to Config by Pierre Schweitzer. Changes: - Continue dralnix code cleanup. - Added checks to avoid buffers overflow. - Updated french translation.
Modified: trunk/tools/RosBE-Windows/Tools/config/lang/fr-FR.rc trunk/tools/RosBE-Windows/Tools/config/options.c trunk/tools/RosBE-Windows/Tools/config/resources.h
Modified: trunk/tools/RosBE-Windows/Tools/config/lang/fr-FR.rc URL: http://svn.reactos.org/svn/reactos/trunk/tools/RosBE-Windows/Tools/config/la... ============================================================================== --- trunk/tools/RosBE-Windows/Tools/config/lang/fr-FR.rc (original) +++ trunk/tools/RosBE-Windows/Tools/config/lang/fr-FR.rc Sun Oct 21 16:23:13 2007 @@ -13,8 +13,8 @@ CONTROL "Texte d'exemple", ID_EXAMPLE, "static", WS_CHILD | WS_VISIBLE | WS_TABSTOP | SS_CENTER, 10, 85, 235, 15 CONTROL "Montrer le temps de compilation", ID_SHOWBUILDTIME, "button", BS_AUTOCHECKBOX | WS_CHILD | WS_VISIBLE | WS_TABSTOP, 10, 100, 110, 21 CONTROL "Sauvegarder le journal", ID_SAVELOGS, "button", BS_AUTOCHECKBOX | WS_CHILD | WS_VISIBLE | WS_TABSTOP, 135, 100, 85, 21 - CONTROL "Use CCache", ID_USECCACHE, "button", BS_AUTOCHECKBOX | WS_CHILD | WS_VISIBLE | WS_TABSTOP, 10, 120, 90, 21 - CONTROL "Strip Output", ID_STRIP, "button", BS_AUTOCHECKBOX | WS_CHILD | WS_VISIBLE | WS_TABSTOP, 135, 120, 60, 21 + CONTROL "Utiliser CCache", ID_USECCACHE, "button", BS_AUTOCHECKBOX | WS_CHILD | WS_VISIBLE | WS_TABSTOP, 10, 120, 90, 21 + CONTROL "Optimiser les fichiers", ID_STRIP, "button", BS_AUTOCHECKBOX | WS_CHILD | WS_VISIBLE | WS_TABSTOP, 135, 120, 90, 21 EDITTEXT ID_LOGDIR, 10, 160, 200, 13, WS_TABSTOP | WS_DISABLED PUSHBUTTON "...", ID_BROWSE, 215, 160, 30, 13, WS_TABSTOP | WS_DISABLED EDITTEXT ID_MGWDIR, 10, 178, 200, 13, WS_TABSTOP
Modified: trunk/tools/RosBE-Windows/Tools/config/options.c URL: http://svn.reactos.org/svn/reactos/trunk/tools/RosBE-Windows/Tools/config/op... ============================================================================== --- trunk/tools/RosBE-Windows/Tools/config/options.c (original) +++ trunk/tools/RosBE-Windows/Tools/config/options.c Sun Oct 21 16:23:13 2007 @@ -81,7 +81,8 @@ }
wcscpy(checkmgw, mingwpath); - wcscat(checkmgw, L"\bin\gcc.exe"); + if ((wcslen(checkmgw) + wcslen(L"\bin\gcc.exe")) < MAX_PATH) + wcscat(checkmgw, L"\bin\gcc.exe"); hFile = CreateFile(checkmgw, (INT)NULL, (INT)NULL, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL); if (hFile == INVALID_HANDLE_VALUE) { @@ -146,7 +147,8 @@ SendMessage(GetDlgItem(Dlg, IDC_FONT), CB_SETCURSEL, 0xA, 0); SendMessage(GetDlgItem(Dlg, IDC_BACK), CB_SETCURSEL, 0, 0); GetCurrentDirectory(MAX_PATH, defaultmingwpath); - wcscat(defaultmingwpath, MINGWVERSION); + if ((wcslen(defaultmingwpath) + wcslen(MINGWVERSION)) < MAX_PATH) + wcscat(defaultmingwpath, MINGWVERSION); SetDlgItemText(Dlg, ID_MGWDIR, defaultmingwpath);
return TRUE; @@ -154,72 +156,8 @@
case WM_COMMAND: { - if (wParam == ID_CANCEL) - { - PostMessage(Dlg, WM_CLOSE, 0, 0); - } - else if (wParam == ID_OK) - { - if (WriteSettings(Dlg)) - PostMessage(Dlg, WM_CLOSE, 0, 0); - } - else if (wParam == ID_BROWSE) - { - WCHAR Path[MAX_PATH]; - BROWSEINFO PathInfo; - ZeroMemory(&PathInfo, sizeof(BROWSEINFO)); - PathInfo.hwndOwner = Dlg; - PathInfo.lpszTitle = L"Please choose a directory where the the logs should be stored:"; - LPITEMIDLIST pidl = SHBrowseForFolder(&PathInfo); - if (pidl && SHGetPathFromIDList(pidl, Path)) - { - SetDlgItemText(Dlg, ID_LOGDIR, Path); - EnableWindow(GetDlgItem(Dlg, ID_OK), TRUE); - } - } - else if (wParam == ID_BROWSEMGW) - { - WCHAR MGWPath[MAX_PATH]; - BROWSEINFO PathInfo; - HINSTANCE hDLL; - ILCREATEFROMPATHW ILCreateFromPathW; - ZeroMemory(&PathInfo, sizeof(BROWSEINFO)); - hDLL = LoadLibrary(L"shell32.dll"); - if (hDLL) - { - ILCreateFromPathW = (ILCREATEFROMPATHW)GetProcAddress(hDLL, "ILCreateFromPathW"); - if (ILCreateFromPathW) - { - GetDlgItemText(Dlg, ID_MGWDIR, MGWPath, MAX_PATH); - PathInfo.pidlRoot = ILCreateFromPathW(MGWPath); - } - FreeLibrary(hDLL); - } - PathInfo.hwndOwner = Dlg; - PathInfo.lpszTitle = L"Please choose the directory where MingW is located:"; - LPITEMIDLIST pidl = SHBrowseForFolder(&PathInfo); - if (pidl && SHGetPathFromIDList(pidl, MGWPath)) - { - SetDlgItemText(Dlg, ID_MGWDIR, MGWPath); - EnableWindow(GetDlgItem(Dlg, ID_OK), TRUE); - } - } - else if (wParam == ID_SAVELOGS) - { - BOOL WriteLogSet = SendMessage(GetDlgItem(Dlg, ID_SAVELOGS), BM_GETCHECK, 0, - 0) == BST_CHECKED; - EnableWindow(GetDlgItem(Dlg, ID_BROWSE), WriteLogSet); - EnableWindow(GetDlgItem(Dlg, ID_LOGDIR), WriteLogSet); - } - else if (wParam == ID_STRIP) - { - EnableWindow(GetDlgItem(Dlg, ID_OK), TRUE); - } - else if (wParam == ID_USECCACHE) - { - EnableWindow(GetDlgItem(Dlg, ID_OK), TRUE); - } - else if ((wParam == ID_SHOWBUILDTIME) || ((LOWORD(wParam) == IDC_FONT) && (HIWORD(wParam) == CBN_SELCHANGE)) || ((LOWORD(wParam) == IDC_BACK) && (HIWORD(wParam) == CBN_SELCHANGE))) + if (((LOWORD(wParam) == IDC_FONT) && (HIWORD(wParam) == CBN_SELCHANGE)) || + ((LOWORD(wParam) == IDC_BACK) && (HIWORD(wParam) == CBN_SELCHANGE))) { RECT rcWnd; GetClientRect(GetDlgItem(Dlg, ID_EXAMPLE), &rcWnd); @@ -227,6 +165,74 @@ UpdateWindow(GetDlgItem(Dlg, ID_EXAMPLE)); EnableWindow(GetDlgItem(Dlg, ID_OK), TRUE); } + else + { + switch (wParam) + { + case ID_OK: + { + if (!WriteSettings(Dlg)) + break; + } + case ID_CANCEL: + { + PostMessage(Dlg, WM_CLOSE, 0, 0); + break; + } + case ID_BROWSE: + case ID_BROWSEMGW: + { + WCHAR Path[MAX_PATH]; + BROWSEINFO PathInfo; + LPITEMIDLIST pidl; + INT Control = ID_LOGDIR; + ZeroMemory(&PathInfo, sizeof(BROWSEINFO)); + PathInfo.hwndOwner = Dlg; + PathInfo.lpszTitle = L"Please choose a directory where the the logs should be stored:"; + if (wParam == ID_BROWSEMGW) + { + HINSTANCE hDLL; + ILCREATEFROMPATHW ILCreateFromPathW; + Control = ID_MGWDIR; + PathInfo.lpszTitle = L"Please choose the directory where MingW is located:"; + hDLL = LoadLibrary(L"shell32.dll"); + if (hDLL) + { + ILCreateFromPathW = (ILCREATEFROMPATHW)GetProcAddress(hDLL, "ILCreateFromPathW"); + if (ILCreateFromPathW) + { + GetDlgItemText(Dlg, ID_MGWDIR, Path, MAX_PATH); + PathInfo.pidlRoot = ILCreateFromPathW(Path); + } + FreeLibrary(hDLL); + } + } + pidl = SHBrowseForFolder(&PathInfo); + if (pidl && SHGetPathFromIDList(pidl, Path)) + { + SetDlgItemText(Dlg, Control, Path); + EnableWindow(GetDlgItem(Dlg, ID_OK), TRUE); + } + break; + } + case ID_SAVELOGS: + { + BOOL WriteLogSet = SendMessage(GetDlgItem(Dlg, ID_SAVELOGS), BM_GETCHECK, 0, + 0) == BST_CHECKED; + EnableWindow(GetDlgItem(Dlg, ID_BROWSE), WriteLogSet); + EnableWindow(GetDlgItem(Dlg, ID_LOGDIR), WriteLogSet); + break; + } + case ID_STRIP: + case ID_USECCACHE: + case ID_SHOWBUILDTIME: + { + EnableWindow(GetDlgItem(Dlg, ID_OK), TRUE); + break; + } + } + + } return FALSE; }
Modified: trunk/tools/RosBE-Windows/Tools/config/resources.h URL: http://svn.reactos.org/svn/reactos/trunk/tools/RosBE-Windows/Tools/config/re... ============================================================================== --- trunk/tools/RosBE-Windows/Tools/config/resources.h (original) +++ trunk/tools/RosBE-Windows/Tools/config/resources.h Sun Oct 21 16:23:13 2007 @@ -10,14 +10,12 @@ #define ID_BROWSEMGW 0x9 #define ID_DIALOG 0xa #define ID_EXAMPLE 0xb -#define IDC_FONT 0xc -#define IDC_BACK 0xd -#define ID_USECCACHE 0xe -#define ID_STRIP 0xf +#define ID_USECCACHE 0xc +#define ID_STRIP 0xd +#define IDC_FONT 0xe +#define IDC_BACK 0xf
/* Strings */ #define MSG_NOGCCFOUND 0x50 #define MSG_FILEFAILED 0x51 #define MSG_DIREFAILED 0x52 - -