From 0f6c074a856804e1ad0558d472d327740c25d292 Mon Sep 17 00:00:00 2001 From: Dmitry Chapyshev Date: Thu, 30 Oct 2008 09:41:37 +0000 Subject: [PATCH 001/138] - Add getting system font and icon size settings - Other small changes svn path=/trunk/; revision=37085 --- reactos/base/applications/kbswitch/kbswitch.c | 52 ++++++++++++++----- 1 file changed, 38 insertions(+), 14 deletions(-) diff --git a/reactos/base/applications/kbswitch/kbswitch.c b/reactos/base/applications/kbswitch/kbswitch.c index b173e139bc3..5521b61a60a 100644 --- a/reactos/base/applications/kbswitch/kbswitch.c +++ b/reactos/base/applications/kbswitch/kbswitch.c @@ -24,6 +24,8 @@ HINSTANCE hInst; HANDLE hProcessHeap; HMODULE hDllLib; ULONG ulCurrentLayoutNum = 1; +UINT cxSmIcon, cySmIcon; + static HICON CreateTrayIcon(LPTSTR szLCID) @@ -49,18 +51,18 @@ CreateTrayIcon(LPTSTR szLCID) hdcsrc = GetDC(NULL); hdc = CreateCompatibleDC(hdcsrc); - hBitmap = CreateCompatibleBitmap(hdcsrc, 16, 16); + hBitmap = CreateCompatibleBitmap(hdcsrc, cxSmIcon, cySmIcon); ReleaseDC(NULL, hdcsrc); if (hdc && hBitmap) { - hBmpNew = CreateBitmap(16, 16, 1, 1, NULL); + hBmpNew = CreateBitmap(cxSmIcon, cySmIcon, 1, 1, NULL); if (hBmpNew) { hBmpOld = SelectObject(hdc, hBitmap); - rect.right = 16; + rect.right = cxSmIcon; rect.left = 0; - rect.bottom = 16; + rect.bottom = cySmIcon; rect.top = 0; bkColor = SetBkColor(hdc, GetSysColor(COLOR_HIGHLIGHT)); @@ -68,14 +70,14 @@ CreateTrayIcon(LPTSTR szLCID) ExtTextOut(hdc, rect.left, rect.top, ETO_OPAQUE, &rect, _T(""), 0, NULL); - hFont = CreateFont(-11, 0, 0, 0, FW_NORMAL, FALSE, FALSE, FALSE, ANSI_CHARSET, - OUT_DEFAULT_PRECIS, CLIP_DEFAULT_PRECIS, - DEFAULT_QUALITY, FF_DONTCARE, _T("Tahoma")); + hFont = (HFONT) GetStockObject(DEFAULT_GUI_FONT); + if (!hFont) + goto End; hFontOld = SelectObject(hdc, hFont); DrawText(hdc, _tcsupr(szBuf), 2, &rect, DT_SINGLELINE|DT_CENTER|DT_VCENTER); SelectObject(hdc, hBmpNew); - PatBlt(hdc, 0, 0, 16, 16, BLACKNESS); + PatBlt(hdc, 0, 0, cxSmIcon, cySmIcon, BLACKNESS); SelectObject(hdc, hBmpOld); SelectObject(hdc, hFontOld); @@ -84,15 +86,15 @@ CreateTrayIcon(LPTSTR szLCID) IconInfo.fIcon = TRUE; hIcon = CreateIconIndirect(&IconInfo); - - DeleteObject(hBmpNew); - DeleteObject(hBmpOld); - DeleteObject(hFont); +End: + if (hBmpNew) DeleteObject(hBmpNew); + if (hBmpOld) DeleteObject(hBmpOld); + if (hFont) DeleteObject(hFont); } } - DeleteDC(hdc); - DeleteObject(hBitmap); + if (hdc) DeleteDC(hdc); + if (hBitmap) DeleteObject(hBitmap); return hIcon; } @@ -384,6 +386,23 @@ GetNextLayout() return -1; } +static VOID +SettingsChanging(HWND hwnd) +{ + UINT cxSmIconCur = 0, cySmIconCur = 0; + + cxSmIconCur = GetSystemMetrics(SM_CXSMICON); + cySmIconCur = GetSystemMetrics(SM_CYSMICON); + + if ((cxSmIcon != cxSmIconCur) || (cySmIcon != cySmIconCur)) + { + cxSmIcon = cxSmIconCur; + cySmIcon = cySmIconCur; + } + + ActivateLayout(hwnd, ulCurrentLayoutNum); +} + LRESULT CALLBACK WndProc(HWND hwnd, UINT Message, WPARAM wParam, LPARAM lParam) { @@ -394,6 +413,9 @@ WndProc(HWND hwnd, UINT Message, WPARAM wParam, LPARAM lParam) { case WM_CREATE: { + cxSmIcon = GetSystemMetrics(SM_CXSMICON); + cySmIcon = GetSystemMetrics(SM_CYSMICON); + SetHooks(); AddTrayIcon(hwnd); hRightPopupMenu = GetSubMenu(LoadMenu(hInst, MAKEINTRESOURCE(IDR_POPUP)), 0); @@ -489,6 +511,8 @@ WndProc(HWND hwnd, UINT Message, WPARAM wParam, LPARAM lParam) case WM_SETTINGCHANGE: { + SettingsChanging(hwnd); + if (wParam == SPI_SETDEFAULTINPUTLANG) { //FIXME: Should detect default language changes by CPL applet or by other tools and update UI From bcbb4cf019024b4f0649131b882a3bb2d6b22b3a Mon Sep 17 00:00:00 2001 From: Christoph von Wittich Date: Thu, 30 Oct 2008 09:44:36 +0000 Subject: [PATCH 002/138] fix 'Cast from pointer to integer of different size' in PickIconProc() patch by hto See issue #3828 for more details. svn path=/trunk/; revision=37086 --- reactos/dll/win32/shell32/dialogs.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/reactos/dll/win32/shell32/dialogs.c b/reactos/dll/win32/shell32/dialogs.c index d2fcf062349..7641816c051 100644 --- a/reactos/dll/win32/shell32/dialogs.c +++ b/reactos/dll/win32/shell32/dialogs.c @@ -117,7 +117,7 @@ INT_PTR CALLBACK PickIconProc(HWND hwndDlg, pIconContext = (PPICK_ICON_CONTEXT)lParam; SetWindowLong(hwndDlg, DWLP_USER, (LONG)pIconContext); pIconContext->hDlgCtrl = GetDlgItem(hwndDlg, IDC_PICKICON_LIST); - EnumResourceNamesW(pIconContext->hLibrary, MAKEINTRESOURCEW(RT_ICON), EnumPickIconResourceProc, (LPARAM)pIconContext); + EnumResourceNamesW(pIconContext->hLibrary, RT_ICON, EnumPickIconResourceProc, (LPARAM)pIconContext); if (PathUnExpandEnvStringsW(pIconContext->szName, szText, MAX_PATH)) SendDlgItemMessageW(hwndDlg, IDC_EDIT_PATH, WM_SETTEXT, 0, (LPARAM)szText); else @@ -174,7 +174,7 @@ INT_PTR CALLBACK PickIconProc(HWND hwndDlg, FreeLibrary(pIconContext->hLibrary); pIconContext->hLibrary = hLibrary; wcscpy(pIconContext->szName, szText); - EnumResourceNamesW(pIconContext->hLibrary, MAKEINTRESOURCEW(RT_ICON), EnumPickIconResourceProc, (LPARAM)pIconContext); + EnumResourceNamesW(pIconContext->hLibrary, RT_ICON, EnumPickIconResourceProc, (LPARAM)pIconContext); if (PathUnExpandEnvStringsW(pIconContext->szName, szText, MAX_PATH)) SendDlgItemMessageW(hwndDlg, IDC_EDIT_PATH, WM_SETTEXT, 0, (LPARAM)szText); else From b645f2b87edd729d623e12c45e943fabb709e6c8 Mon Sep 17 00:00:00 2001 From: Johannes Anderwald Date: Thu, 30 Oct 2008 09:58:12 +0000 Subject: [PATCH 003/138] - Convert LoadSoundFiles to explictely to unicode - Fix 2 possible buffer overflows (CID 553) svn path=/trunk/; revision=37087 --- reactos/dll/cpl/mmsys/sounds.c | 34 +++++++++++++++++----------------- 1 file changed, 17 insertions(+), 17 deletions(-) diff --git a/reactos/dll/cpl/mmsys/sounds.c b/reactos/dll/cpl/mmsys/sounds.c index d30371bb87b..5f3596c2d96 100644 --- a/reactos/dll/cpl/mmsys/sounds.c +++ b/reactos/dll/cpl/mmsys/sounds.c @@ -648,35 +648,35 @@ LoadSoundProfiles(HWND hwndDlg) BOOL LoadSoundFiles(HWND hwndDlg) { - TCHAR szPath[MAX_PATH]; - TCHAR szNone[MAX_PATH]; - TCHAR * ptr; - WIN32_FIND_DATA FileData; + WCHAR szPath[MAX_PATH]; + WCHAR * ptr; + WIN32_FIND_DATAW FileData; HANDLE hFile; LRESULT lResult; UINT length; - length = GetWindowsDirectory(szPath, sizeof(szPath) / sizeof(TCHAR)); - if (length == 0 || length > (sizeof(szPath) / sizeof(TCHAR))) + length = GetWindowsDirectoryW(szPath, MAX_PATH); + if (length == 0 || length >= MAX_PATH - 9) { return FALSE; } - if (szPath[length-1] != _T('\\')) + if (szPath[length-1] != L'\\') { - szPath[length] = _T('\\'); + szPath[length] = L'\\'; length++; } - _tcscpy(&szPath[length], _T("media\\*")); + wcscpy(&szPath[length], L"media\\*"); length += 7; - hFile = FindFirstFile(szPath, &FileData); + hFile = FindFirstFileW(szPath, &FileData); if (hFile == INVALID_HANDLE_VALUE) { return FALSE; } - if (LoadString(hApplet, IDS_NO_SOUND, szNone, MAX_PATH)) + if (LoadString(hApplet, IDS_NO_SOUND, szPath, MAX_PATH)) { - SendDlgItemMessage(hwndDlg, IDC_SOUND_LIST, CB_ADDSTRING, (WPARAM)0, (LPARAM)szNone); + szPath[(sizeof(szPath)/sizeof(WCHAR))-1] = L'\0'; + SendDlgItemMessageW(hwndDlg, IDC_SOUND_LIST, CB_ADDSTRING, (WPARAM)0, (LPARAM)szPath); } do @@ -684,7 +684,7 @@ LoadSoundFiles(HWND hwndDlg) if (FileData.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) continue; - ptr = _tcsrchr(FileData.cFileName, _T('\\')); + ptr = wcsrchr(FileData.cFileName, L'\\'); if (ptr) { ptr++; @@ -693,13 +693,13 @@ LoadSoundFiles(HWND hwndDlg) { ptr = FileData.cFileName; } - lResult = SendDlgItemMessage(hwndDlg, IDC_SOUND_LIST, CB_ADDSTRING, (WPARAM)0, (LPARAM)ptr); + lResult = SendDlgItemMessageW(hwndDlg, IDC_SOUND_LIST, CB_ADDSTRING, (WPARAM)0, (LPARAM)ptr); if (lResult != CB_ERR) { - _tcscpy(&szPath[length-1], FileData.cFileName); - SendDlgItemMessage(hwndDlg, IDC_SOUND_LIST, CB_SETITEMDATA, (WPARAM)lResult, (LPARAM)_tcsdup(szPath)); + wcscpy(&szPath[length-1], FileData.cFileName); + SendDlgItemMessageW(hwndDlg, IDC_SOUND_LIST, CB_SETITEMDATA, (WPARAM)lResult, (LPARAM)wcsdup(szPath)); } - }while(FindNextFile(hFile, &FileData) != 0); + }while(FindNextFileW(hFile, &FileData) != 0); FindClose(hFile); return TRUE; From b70d5a56a4bebee8f54e9d0f48431e85efc76ce7 Mon Sep 17 00:00:00 2001 From: James Tabor Date: Thu, 30 Oct 2008 10:46:27 +0000 Subject: [PATCH 004/138] - Implemented: GetFontLanguageInfo based on wine. GetLanguageID, it reads the registry for default language type. - Move more function in and out of freetype.c. Minor code fixes too. svn path=/trunk/; revision=37090 --- reactos/subsystems/win32/win32k/eng/xlate.c | 2 + .../subsystems/win32/win32k/include/misc.h | 3 + .../subsystems/win32/win32k/include/text.h | 8 + .../subsystems/win32/win32k/main/dllmain.c | 18 +- reactos/subsystems/win32/win32k/ntuser/misc.c | 46 +++ .../subsystems/win32/win32k/ntuser/msgqueue.c | 5 +- reactos/subsystems/win32/win32k/objects/dc.c | 1 + .../subsystems/win32/win32k/objects/font.c | 125 +++++-- .../win32/win32k/objects/freetype.c | 306 ++++++------------ .../subsystems/win32/win32k/objects/text.c | 125 ++++++- 10 files changed, 381 insertions(+), 258 deletions(-) diff --git a/reactos/subsystems/win32/win32k/eng/xlate.c b/reactos/subsystems/win32/win32k/eng/xlate.c index 1b1265490c9..0095315b00c 100644 --- a/reactos/subsystems/win32/win32k/eng/xlate.c +++ b/reactos/subsystems/win32/win32k/eng/xlate.c @@ -518,6 +518,8 @@ EngDeleteXlate(XLATEOBJ *XlateObj) XlateGDI = ObjToGDI(XlateObj, XLATE); + if (!XlateGDI) return; + if ((XlateObj->flXlate & XO_TABLE) && XlateObj->pulXlate != NULL) { diff --git a/reactos/subsystems/win32/win32k/include/misc.h b/reactos/subsystems/win32/win32k/include/misc.h index 39d00cbd069..2007e8b9b95 100644 --- a/reactos/subsystems/win32/win32k/include/misc.h +++ b/reactos/subsystems/win32/win32k/include/misc.h @@ -31,6 +31,9 @@ #define W32PF_CREATEDWINORDC (0x04000000) +extern SHORT gusLanguageID; + +SHORT FASTCALL IntGdiGetLanguageID(); ULONG FASTCALL IntSystemParametersInfo(UINT uiAction, UINT uiParam, PVOID pvParam, UINT fWinIni); DWORD STDCALL IntGetQueueStatus(BOOL ClearChanges); VOID FASTCALL IntUserManualGuiCheck(LONG Check); diff --git a/reactos/subsystems/win32/win32k/include/text.h b/reactos/subsystems/win32/win32k/include/text.h index 1c9e7759912..0503c169546 100644 --- a/reactos/subsystems/win32/win32k/include/text.h +++ b/reactos/subsystems/win32/win32k/include/text.h @@ -84,6 +84,14 @@ VOID FASTCALL IntEnableFontRendering(BOOL Enable); INT FASTCALL FontGetObject(PTEXTOBJ TextObj, INT Count, PVOID Buffer); VOID FASTCALL IntLoadSystemFonts(VOID); INT FASTCALL IntGdiAddFontResource(PUNICODE_STRING FileName, DWORD Characteristics); +ULONG FASTCALL ftGdiGetGlyphOutline(PDC,WCHAR,UINT,LPGLYPHMETRICS,ULONG,PVOID,LPMAT2,BOOL); +INT FASTCALL IntGetOutlineTextMetrics(PFONTGDI,UINT,OUTLINETEXTMETRICW *); +BOOL FASTCALL ftGdiGetRasterizerCaps(LPRASTERIZER_STATUS); +BOOL FASTCALL TextIntGetTextExtentPoint(PDC,PTEXTOBJ,LPCWSTR,int,int,LPINT,LPINT,LPSIZE); +DWORD FASTCALL IntGdiGetCharSet(HDC); +BOOL FASTCALL ftGdiGetTextMetricsW(HDC,PTMW_INTERNAL); +DWORD FASTCALL ftGetFontLanguageInfo(PDC); +INT FASTCALL ftGdiGetTextCharsetInfo(PDC,PFONTSIGNATURE,DWORD); #define IntLockProcessPrivateFonts(W32Process) \ ExEnterCriticalRegionAndAcquireFastMutexUnsafe(&W32Process->PrivateFontListLock) diff --git a/reactos/subsystems/win32/win32k/main/dllmain.c b/reactos/subsystems/win32/win32k/main/dllmain.c index 2a907a85ef7..3dcbdd7e7d0 100644 --- a/reactos/subsystems/win32/win32k/main/dllmain.c +++ b/reactos/subsystems/win32/win32k/main/dllmain.c @@ -42,6 +42,8 @@ PSERVERINFO gpsi = NULL; // Global User Server Information. HSEMAPHORE hsemDriverMgmt = NULL; +SHORT gusLanguageID; + extern ULONG_PTR Win32kSSDT[]; extern UCHAR Win32kSSPT[]; extern ULONG Win32kNumberOfSysCalls; @@ -420,6 +422,13 @@ DriverEntry ( if(!hsemDriverMgmt) hsemDriverMgmt = EngCreateSemaphore(); + GdiHandleTable = GDIOBJ_iAllocHandleTable(&GdiTableSection); + if (GdiHandleTable == NULL) + { + DPRINT1("Failed to initialize the GDI handle table.\n"); + return STATUS_UNSUCCESSFUL; + } + Status = InitUserImpl(); if (!NT_SUCCESS(Status)) { @@ -511,13 +520,6 @@ DriverEntry ( return(Status); } - GdiHandleTable = GDIOBJ_iAllocHandleTable(&GdiTableSection); - if (GdiHandleTable == NULL) - { - DPRINT1("Failed to initialize the GDI handle table.\n"); - return STATUS_UNSUCCESSFUL; - } - Status = InitDcImpl(); if (!NT_SUCCESS(Status)) { @@ -537,6 +539,8 @@ DriverEntry ( CreateStockObjects(); CreateSysColorObjects(); + gusLanguageID = IntGdiGetLanguageID(); + return STATUS_SUCCESS; } diff --git a/reactos/subsystems/win32/win32k/ntuser/misc.c b/reactos/subsystems/win32/win32k/ntuser/misc.c index 1dd156b9c51..506def6fbd6 100644 --- a/reactos/subsystems/win32/win32k/ntuser/misc.c +++ b/reactos/subsystems/win32/win32k/ntuser/misc.c @@ -14,6 +14,52 @@ #include +SHORT +FASTCALL +IntGdiGetLanguageID() +{ + HANDLE KeyHandle; + ULONG Size = sizeof(WCHAR) * (MAX_PATH + 12); + OBJECT_ATTRIBUTES ObAttr; +// http://support.microsoft.com/kb/324097 + ULONG Ret = 0x409; // English + PVOID KeyInfo; + UNICODE_STRING Language; + + RtlInitUnicodeString( &Language, + L"\\Registry\\Machine\\System\\CurrentControlSet\\Control\\Nls\\Language"); + + InitializeObjectAttributes( &ObAttr, + &Language, + OBJ_CASE_INSENSITIVE, + NULL, + NULL); + + if ( NT_SUCCESS(ZwOpenKey(&KeyHandle, KEY_READ, &ObAttr))) + { + KeyInfo = ExAllocatePoolWithTag(PagedPool, Size, TAG_STRING); + if ( KeyInfo ) + { + RtlInitUnicodeString(&Language, L"Default"); + + if ( NT_SUCCESS(ZwQueryValueKey( KeyHandle, + &Language, + KeyValuePartialInformation, + KeyInfo, + Size, + &Size)) ) + { + RtlInitUnicodeString(&Language, (PVOID)((char *)KeyInfo + 12)); + RtlUnicodeStringToInteger(&Language, 16, &Ret); + } + ExFreePoolWithTag(KeyInfo, TAG_STRING); + } + ZwClose(KeyHandle); + } + DPRINT1("Language ID = %x\n",Ret); + return (SHORT) Ret; +} + /* * @unimplemented */ diff --git a/reactos/subsystems/win32/win32k/ntuser/msgqueue.c b/reactos/subsystems/win32/win32k/ntuser/msgqueue.c index 1b3b5778a60..f79c19315fe 100644 --- a/reactos/subsystems/win32/win32k/ntuser/msgqueue.c +++ b/reactos/subsystems/win32/win32k/ntuser/msgqueue.c @@ -16,12 +16,11 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ -/* $Id$ - * +/* * COPYRIGHT: See COPYING in the top level directory * PROJECT: ReactOS kernel * PURPOSE: Message queues - * FILE: subsys/win32k/ntuser/msgqueue.c + * FILE: subsystems/win32/win32k/ntuser/msgqueue.c * PROGRAMER: Casper S. Hornstrup (chorns@users.sourceforge.net) * REVISION HISTORY: * 06-06-2001 CSH Created diff --git a/reactos/subsystems/win32/win32k/objects/dc.c b/reactos/subsystems/win32/win32k/objects/dc.c index 81096bd59a3..6309dc8dec1 100644 --- a/reactos/subsystems/win32/win32k/objects/dc.c +++ b/reactos/subsystems/win32/win32k/objects/dc.c @@ -2411,6 +2411,7 @@ NtGdiGetDCDword( case GdiGetEMFRestorDc: break; case GdiGetFontLanguageInfo: + SafeResult = ftGetFontLanguageInfo(dc); break; case GdiGetIsMemDc: SafeResult = dc->DC_Type; diff --git a/reactos/subsystems/win32/win32k/objects/font.c b/reactos/subsystems/win32/win32k/objects/font.c index 1a838e8a51f..27d96514296 100644 --- a/reactos/subsystems/win32/win32k/objects/font.c +++ b/reactos/subsystems/win32/win32k/objects/font.c @@ -13,32 +13,54 @@ #define NDEBUG #include -// -// FIXME PLEASE!!!! -// Why are these here? Well there is a problem with drivers/directx. -// 1st: It does not belong there. -// 2nd: Due to being placed outside Win32k build environment, it creates -// compiling issues. -// Until svn mv drivers/directx subsystem/win32/win32k/drivers/directx, -// it will not get fixed. -// -ULONG -FASTCALL -ftGdiGetGlyphOutline( - IN PDC pdc, - IN WCHAR wch, - IN UINT iFormat, - OUT LPGLYPHMETRICS pgm, - IN ULONG cjBuf, - OUT OPTIONAL PVOID UnsafeBuf, - IN LPMAT2 pmat2, - IN BOOL bIgnoreRotation); +/** Functions ******************************************************************/ INT -FASTCALL -IntGetOutlineTextMetrics(PFONTGDI FontGDI, UINT Size, OUTLINETEXTMETRICW *Otm); +APIENTRY +NtGdiAddFontResourceW( + IN WCHAR *pwszFiles, + IN ULONG cwc, + IN ULONG cFiles, + IN FLONG fl, + IN DWORD dwPidTid, + IN OPTIONAL DESIGNVECTOR *pdv) +{ + UNICODE_STRING SafeFileName; + PWSTR src; + NTSTATUS Status; + int Ret; -/** Functions ******************************************************************/ + /* FIXME - Protect with SEH? */ + RtlInitUnicodeString(&SafeFileName, pwszFiles); + + /* Reserve for prepending '\??\' */ + SafeFileName.Length += 4 * sizeof(WCHAR); + SafeFileName.MaximumLength += 4 * sizeof(WCHAR); + + src = SafeFileName.Buffer; + SafeFileName.Buffer = (PWSTR)ExAllocatePoolWithTag(PagedPool, SafeFileName.MaximumLength, TAG_STRING); + if(!SafeFileName.Buffer) + { + SetLastWin32Error(ERROR_NOT_ENOUGH_MEMORY); + return 0; + } + + /* Prepend '\??\' */ + RtlCopyMemory(SafeFileName.Buffer, L"\\??\\", 4 * sizeof(WCHAR)); + + Status = MmCopyFromCaller(SafeFileName.Buffer + 4, src, SafeFileName.MaximumLength - (4 * sizeof(WCHAR))); + if(!NT_SUCCESS(Status)) + { + ExFreePool(SafeFileName.Buffer); + SetLastNtError(Status); + return 0; + } + + Ret = IntGdiAddFontResource(&SafeFileName, (DWORD)fl); + + ExFreePool(SafeFileName.Buffer); + return Ret; +} ULONG APIENTRY @@ -148,4 +170,61 @@ NtGdiGetOutlineTextMetricsInternalW (HDC hDC, return Size; } +HFONT +STDCALL +NtGdiHfontCreate( + IN PENUMLOGFONTEXDVW pelfw, + IN ULONG cjElfw, + IN LFTYPE lft, + IN FLONG fl, + IN PVOID pvCliData ) +{ + ENUMLOGFONTEXDVW SafeLogfont; + HFONT hNewFont; + PTEXTOBJ TextObj; + NTSTATUS Status = STATUS_SUCCESS; + + if (!pelfw) + { + return NULL; + } + + _SEH_TRY + { + ProbeForRead(pelfw, sizeof(ENUMLOGFONTEXDVW), 1); + RtlCopyMemory(&SafeLogfont, pelfw, sizeof(ENUMLOGFONTEXDVW)); + } + _SEH_HANDLE + { + Status = _SEH_GetExceptionCode(); + } + _SEH_END + + if (!NT_SUCCESS(Status)) + { + return NULL; + } + + TextObj = TEXTOBJ_AllocTextWithHandle(); + if (!TextObj) + { + return NULL; + } + hNewFont = TextObj->BaseObject.hHmgr; + + RtlCopyMemory (&TextObj->logfont, &SafeLogfont, sizeof(ENUMLOGFONTEXDVW)); + + if (SafeLogfont.elfEnumLogfontEx.elfLogFont.lfEscapement != + SafeLogfont.elfEnumLogfontEx.elfLogFont.lfOrientation) + { + /* this should really depend on whether GM_ADVANCED is set */ + TextObj->logfont.elfEnumLogfontEx.elfLogFont.lfOrientation = + TextObj->logfont.elfEnumLogfontEx.elfLogFont.lfEscapement; + } + TEXTOBJ_UnlockText(TextObj); + + return hNewFont; +} + + /* EOF */ diff --git a/reactos/subsystems/win32/win32k/objects/freetype.c b/reactos/subsystems/win32/win32k/objects/freetype.c index f3861691013..9c156e1fd46 100644 --- a/reactos/subsystems/win32/win32k/objects/freetype.c +++ b/reactos/subsystems/win32/win32k/objects/freetype.c @@ -22,7 +22,6 @@ #define NDEBUG #include - FT_Library library; typedef struct _FONT_ENTRY { @@ -44,8 +43,6 @@ static BOOL RenderingEnabled = TRUE; UINT Hits; UINT Misses; -SHORT ftLanguageID = 0; - typedef struct _FONT_CACHE_ENTRY { LIST_ENTRY ListEntry; int GlyphIndex; @@ -244,6 +241,7 @@ IntLoadSystemFonts(VOID) } } + /* * IntGdiAddFontResource * @@ -446,52 +444,6 @@ IntGetFontRenderMode(LOGFONTW *logfont) return FT_RENDER_MODE_NORMAL; } -INT -APIENTRY -NtGdiAddFontResourceW( - IN WCHAR *pwszFiles, - IN ULONG cwc, - IN ULONG cFiles, - IN FLONG fl, - IN DWORD dwPidTid, - IN OPTIONAL DESIGNVECTOR *pdv) -{ - UNICODE_STRING SafeFileName; - PWSTR src; - NTSTATUS Status; - int Ret; - - /* FIXME - Protect with SEH? */ - RtlInitUnicodeString(&SafeFileName, pwszFiles); - - /* Reserve for prepending '\??\' */ - SafeFileName.Length += 4 * sizeof(WCHAR); - SafeFileName.MaximumLength += 4 * sizeof(WCHAR); - - src = SafeFileName.Buffer; - SafeFileName.Buffer = (PWSTR)ExAllocatePoolWithTag(PagedPool, SafeFileName.MaximumLength, TAG_STRING); - if(!SafeFileName.Buffer) - { - SetLastWin32Error(ERROR_NOT_ENOUGH_MEMORY); - return 0; - } - - /* Prepend '\??\' */ - RtlCopyMemory(SafeFileName.Buffer, L"\\??\\", 4 * sizeof(WCHAR)); - - Status = MmCopyFromCaller(SafeFileName.Buffer + 4, src, SafeFileName.MaximumLength - (4 * sizeof(WCHAR))); - if(!NT_SUCCESS(Status)) - { - ExFreePool(SafeFileName.Buffer); - SetLastNtError(Status); - return 0; - } - - Ret = IntGdiAddFontResource(&SafeFileName, (DWORD)fl); - - ExFreePool(SafeFileName.Buffer); - return Ret; -} NTSTATUS FASTCALL TextIntCreateFontIndirect(CONST LPLOGFONTW lf, HFONT *NewFont) @@ -517,63 +469,6 @@ TextIntCreateFontIndirect(CONST LPLOGFONTW lf, HFONT *NewFont) return STATUS_SUCCESS; } -HFONT -STDCALL -NtGdiHfontCreate( - IN PENUMLOGFONTEXDVW pelfw, - IN ULONG cjElfw, - IN LFTYPE lft, - IN FLONG fl, - IN PVOID pvCliData ) -{ - ENUMLOGFONTEXDVW SafeLogfont; - HFONT hNewFont; - PTEXTOBJ TextObj; - NTSTATUS Status = STATUS_SUCCESS; - - if (!pelfw) - { - return NULL; - } - - _SEH_TRY - { - ProbeForRead(pelfw, sizeof(ENUMLOGFONTEXDVW), 1); - RtlCopyMemory(&SafeLogfont, pelfw, sizeof(ENUMLOGFONTEXDVW)); - } - _SEH_HANDLE - { - Status = _SEH_GetExceptionCode(); - } - _SEH_END - - if (!NT_SUCCESS(Status)) - { - return NULL; - } - - TextObj = TEXTOBJ_AllocTextWithHandle(); - if (!TextObj) - { - return NULL; - } - hNewFont = TextObj->BaseObject.hHmgr; - - RtlCopyMemory (&TextObj->logfont, &SafeLogfont, sizeof(ENUMLOGFONTEXDVW)); - - if (SafeLogfont.elfEnumLogfontEx.elfLogFont.lfEscapement != - SafeLogfont.elfEnumLogfontEx.elfLogFont.lfOrientation) - { - /* this should really depend on whether GM_ADVANCED is set */ - TextObj->logfont.elfEnumLogfontEx.elfLogFont.lfOrientation = - TextObj->logfont.elfEnumLogfontEx.elfLogFont.lfEscapement; - } - TEXTOBJ_UnlockText(TextObj); - - return hNewFont; - -} - /************************************************************************* * TranslateCharsetInfo * @@ -1329,7 +1224,7 @@ ftGdiGetRasterizerCaps(LPRASTERIZER_STATUS lprs) { lprs->nSize = sizeof(RASTERIZER_STATUS); lprs->wFlags = TT_AVAILABLE | TT_ENABLED; - lprs->nLanguageID = ftLanguageID; + lprs->nLanguageID = gusLanguageID; return TRUE; } SetLastWin32Error(ERROR_INVALID_PARAMETER); @@ -1413,7 +1308,7 @@ NtGdiGetFontFamilyInfo(HDC Dc, } FT_Glyph STDCALL -NtGdiGlyphCacheGet( +ftGdiGlyphCacheGet( FT_Face Face, INT GlyphIndex, INT Height) @@ -1462,7 +1357,7 @@ NtGdiGlyphCacheGet( } FT_Glyph STDCALL -NtGdiGlyphCacheSet( +ftGdiGlyphCacheSet( FT_Face Face, INT GlyphIndex, INT Height, @@ -1842,7 +1737,7 @@ NtGdiExtTextOutW( else glyph_index = FT_Get_Char_Index(face, *TempText); - if (!(realglyph = NtGdiGlyphCacheGet(face, glyph_index, + if (!(realglyph = ftGdiGlyphCacheGet(face, glyph_index, TextObj->logfont.elfEnumLogfontEx.elfLogFont.lfHeight))) { error = FT_Load_Glyph(face, glyph_index, FT_LOAD_DEFAULT); @@ -1852,7 +1747,7 @@ NtGdiExtTextOutW( } glyph = face->glyph; - realglyph = NtGdiGlyphCacheSet(face, glyph_index, + realglyph = ftGdiGlyphCacheSet(face, glyph_index, TextObj->logfont.elfEnumLogfontEx.elfLogFont.lfHeight, glyph, RenderMode); if (!realglyph) { @@ -1903,7 +1798,7 @@ NtGdiExtTextOutW( else glyph_index = FT_Get_Char_Index(face, *String); - if (!(realglyph = NtGdiGlyphCacheGet(face, glyph_index, + if (!(realglyph = ftGdiGlyphCacheGet(face, glyph_index, TextObj->logfont.elfEnumLogfontEx.elfLogFont.lfHeight))) { error = FT_Load_Glyph(face, glyph_index, FT_LOAD_DEFAULT); @@ -1914,7 +1809,7 @@ NtGdiExtTextOutW( goto fail; } glyph = face->glyph; - realglyph = NtGdiGlyphCacheSet(face, + realglyph = ftGdiGlyphCacheSet(face, glyph_index, TextObj->logfont.elfEnumLogfontEx.elfLogFont.lfHeight, glyph, @@ -2591,14 +2486,14 @@ static __inline FT_Fixed FT_FixedFromFIXED(FIXED f) ULONG FASTCALL ftGdiGetGlyphOutline( - IN PDC dc, - IN WCHAR wch, - IN UINT iFormat, - OUT LPGLYPHMETRICS pgm, - IN ULONG cjBuf, - OUT OPTIONAL PVOID UnsafeBuf, - IN LPMAT2 pmat2, - IN BOOL bIgnoreRotation) + PDC dc, + WCHAR wch, + UINT iFormat, + LPGLYPHMETRICS pgm, + ULONG cjBuf, + OPTIONAL PVOID UnsafeBuf, + LPMAT2 pmat2, + BOOL bIgnoreRotation) { static const FT_Matrix identityMat = {(1 << 16), 0, 0, (1 << 16)}; PDC_ATTR Dc_Attr; @@ -3313,7 +3208,7 @@ TextIntGetTextExtentPoint(PDC dc, for (i = 0; i < Count; i++) { glyph_index = FT_Get_Char_Index(face, *String); - if (!(realglyph = NtGdiGlyphCacheGet(face, glyph_index, + if (!(realglyph = ftGdiGlyphCacheGet(face, glyph_index, TextObj->logfont.elfEnumLogfontEx.elfLogFont.lfHeight))) { error = FT_Load_Glyph(face, glyph_index, FT_LOAD_DEFAULT); @@ -3324,7 +3219,7 @@ TextIntGetTextExtentPoint(PDC dc, } glyph = face->glyph; - realglyph = NtGdiGlyphCacheSet(face, glyph_index, + realglyph = ftGdiGlyphCacheSet(face, glyph_index, TextObj->logfont.elfEnumLogfontEx.elfLogFont.lfHeight, glyph, RenderMode); if (!realglyph) { @@ -3364,7 +3259,6 @@ TextIntGetTextExtentPoint(PDC dc, return TRUE; } - DWORD FASTCALL IntGdiGetCharSet(HDC hDC) @@ -3393,38 +3287,13 @@ IntGdiGetCharSet(HDC hDC) return (MAKELONG(cp, charset)); } - -DWORD -APIENTRY -NtGdiGetCharSet(HDC hDC) -{ - PDC Dc; - PDC_ATTR Dc_Attr; - DWORD cscp = IntGdiGetCharSet(hDC); - // If here, update everything! - Dc = DC_LockDc(hDC); - if (!Dc) - { - SetLastWin32Error(ERROR_INVALID_HANDLE); - return 0; - } - Dc_Attr = Dc->pDc_Attr; - if (!Dc_Attr) Dc_Attr = &Dc->Dc_Attr; - Dc_Attr->iCS_CP = cscp; - Dc_Attr->ulDirty_ &= ~DIRTY_CHARSET; - DC_UnlockDc( Dc ); - return cscp; -} - - INT -APIENTRY -NtGdiGetTextCharsetInfo( - IN HDC hdc, - OUT OPTIONAL LPFONTSIGNATURE lpSig, - IN DWORD dwFlags) +FASTCALL +ftGdiGetTextCharsetInfo( + PDC Dc, + LPFONTSIGNATURE lpSig, + DWORD dwFlags) { - PDC Dc; PDC_ATTR Dc_Attr; UINT Ret = DEFAULT_CHARSET, i = 0, fs_fsCsb0 = 0; HFONT hFont; @@ -3433,19 +3302,12 @@ NtGdiGetTextCharsetInfo( FONTSIGNATURE fs; TT_OS2 *pOS2; FT_Face Face; - NTSTATUS Status; - Dc = DC_LockDc(hdc); - if (!Dc) - { - SetLastWin32Error(ERROR_INVALID_HANDLE); - return Ret; - } Dc_Attr = Dc->pDc_Attr; if(!Dc_Attr) Dc_Attr = &Dc->Dc_Attr; hFont = Dc_Attr->hlfntNew; TextObj = TEXTOBJ_LockText(hFont); - DC_UnlockDc( Dc ); + if ( TextObj == NULL) { SetLastWin32Error(ERROR_INVALID_HANDLE); @@ -3479,14 +3341,9 @@ NtGdiGetTextCharsetInfo( } DPRINT("Csb 1=%x 0=%x\n", fs.fsCsb[1],fs.fsCsb[0]); if (lpSig) - { - Status = MmCopyToCaller(lpSig, &fs, sizeof(FONTSIGNATURE)); - if (! NT_SUCCESS(Status)) - { - SetLastWin32Error(ERROR_INVALID_PARAMETER); - return Ret; - } - } + { + RtlCopyMemory(lpSig, &fs, sizeof(FONTSIGNATURE)); + } if (0 == fs_fsCsb0) { /* let's see if we can find any interesting cmaps */ for (i = 0; i < Face->num_charmaps; i++) @@ -3514,34 +3371,81 @@ NtGdiGetTextCharsetInfo( return Ret; } -W32KAPI +DWORD +FASTCALL +ftGetFontLanguageInfo(PDC Dc) +{ + PDC_ATTR Dc_Attr; + FONTSIGNATURE fontsig; + static const DWORD GCP_DBCS_MASK=0x003F0000, + GCP_DIACRITIC_MASK=0x00000000, + FLI_GLYPHS_MASK=0x00000000, + GCP_GLYPHSHAPE_MASK=0x00000040, + GCP_KASHIDA_MASK=0x00000000, + GCP_LIGATE_MASK=0x00000000, + GCP_USEKERNING_MASK=0x00000000, + GCP_REORDER_MASK=0x00000060; + + DWORD result=0; + + ftGdiGetTextCharsetInfo( Dc, &fontsig, 0 ); + + /* We detect each flag we return using a bitmask on the Codepage Bitfields */ + if( (fontsig.fsCsb[0]&GCP_DBCS_MASK)!=0 ) + result|=GCP_DBCS; + + if( (fontsig.fsCsb[0]&GCP_DIACRITIC_MASK)!=0 ) + result|=GCP_DIACRITIC; + + if( (fontsig.fsCsb[0]&FLI_GLYPHS_MASK)!=0 ) + result|=FLI_GLYPHS; + + if( (fontsig.fsCsb[0]&GCP_GLYPHSHAPE_MASK)!=0 ) + result|=GCP_GLYPHSHAPE; + + if( (fontsig.fsCsb[0]&GCP_KASHIDA_MASK)!=0 ) + result|=GCP_KASHIDA; + + if( (fontsig.fsCsb[0]&GCP_LIGATE_MASK)!=0 ) + result|=GCP_LIGATE; + + if( (fontsig.fsCsb[0]&GCP_USEKERNING_MASK)!=0 ) + result|=GCP_USEKERNING; + + Dc_Attr = Dc->pDc_Attr; + if(!Dc_Attr) Dc_Attr = &Dc->Dc_Attr; + + /* this might need a test for a HEBREW- or ARABIC_CHARSET as well */ + if ( Dc_Attr->lTextAlign & TA_RTLREADING ) + if( (fontsig.fsCsb[0]&GCP_REORDER_MASK)!=0 ) + result|=GCP_REORDER; + + return result; +} + + BOOL -APIENTRY -NtGdiGetTextMetricsW( - IN HDC hDC, - OUT TMW_INTERNAL * pUnsafeTmwi, - IN ULONG cj -) +FASTCALL +ftGdiGetTextMetricsW( + HDC hDC, + PTMW_INTERNAL ptmwi) { PDC dc; PDC_ATTR Dc_Attr; PTEXTOBJ TextObj; PFONTGDI FontGDI; - NTSTATUS Status = STATUS_SUCCESS; - TMW_INTERNAL tmwi; FT_Face Face; TT_OS2 *pOS2; TT_HoriHeader *pHori; ULONG Error; + NTSTATUS Status = STATUS_SUCCESS; - if (NULL == pUnsafeTmwi) + if (!ptmwi) { SetLastWin32Error(STATUS_INVALID_PARAMETER); return FALSE; } - /* FIXME: check cj ? */ - if(!(dc = DC_LockDc(hDC))) { SetLastWin32Error(ERROR_INVALID_HANDLE); @@ -3570,9 +3474,9 @@ NtGdiGetTextMetricsW( } else { - memcpy(&tmwi.TextMetric, &FontGDI->TextMetric, sizeof(TEXTMETRICW)); + memcpy(&ptmwi->TextMetric, &FontGDI->TextMetric, sizeof(TEXTMETRICW)); /* FIXME: Fill Diff member */ - RtlZeroMemory(&tmwi.Diff, sizeof(tmwi.Diff)); + RtlZeroMemory(&ptmwi->Diff, sizeof(ptmwi->Diff)); Status = STATUS_SUCCESS; IntLockFreeType; @@ -3594,38 +3498,22 @@ NtGdiGetTextMetricsW( if (NT_SUCCESS(Status)) { - FillTM(&tmwi.TextMetric, FontGDI->face, pOS2, pHori); - - if (cj > sizeof(TMW_INTERNAL)) - cj = sizeof(TMW_INTERNAL); - - Status = STATUS_SUCCESS; - _SEH_TRY - { - ProbeForWrite(pUnsafeTmwi, cj, 1); - RtlCopyMemory(pUnsafeTmwi,&tmwi,cj); - } - _SEH_HANDLE - { - Status = _SEH_GetExceptionCode(); - } - _SEH_END + FillTM(&ptmwi->TextMetric, FontGDI->face, pOS2, pHori); } } TEXTOBJ_UnlockText(TextObj); } else - { - Status = STATUS_INVALID_HANDLE; - } + { + Status = STATUS_INVALID_HANDLE; + } DC_UnlockDc(dc); - if(!NT_SUCCESS(Status)) - { - SetLastNtError(Status); - return FALSE; - } - + if (!NT_SUCCESS(Status)) + { + SetLastNtError(Status); + return FALSE; + } return TRUE; } diff --git a/reactos/subsystems/win32/win32k/objects/text.c b/reactos/subsystems/win32/win32k/objects/text.c index e1c729b1229..a3e5373198d 100644 --- a/reactos/subsystems/win32/win32k/objects/text.c +++ b/reactos/subsystems/win32/win32k/objects/text.c @@ -13,24 +13,30 @@ #define NDEBUG #include -BOOL -FASTCALL -ftGdiGetRasterizerCaps(LPRASTERIZER_STATUS lprs); - -BOOL -FASTCALL -TextIntGetTextExtentPoint(PDC dc, - PTEXTOBJ TextObj, - LPCWSTR String, - int Count, - int MaxExtent, - LPINT Fit, - LPINT Dx, - LPSIZE Size); - - /** Functions ******************************************************************/ +DWORD +APIENTRY +NtGdiGetCharSet(HDC hDC) +{ + PDC Dc; + PDC_ATTR Dc_Attr; + DWORD cscp = IntGdiGetCharSet(hDC); + // If here, update everything! + Dc = DC_LockDc(hDC); + if (!Dc) + { + SetLastWin32Error(ERROR_INVALID_HANDLE); + return 0; + } + Dc_Attr = Dc->pDc_Attr; + if (!Dc_Attr) Dc_Attr = &Dc->Dc_Attr; + Dc_Attr->iCS_CP = cscp; + Dc_Attr->ulDirty_ &= ~DIRTY_CHARSET; + DC_UnlockDc( Dc ); + return cscp; +} + BOOL APIENTRY NtGdiGetRasterizerCaps( @@ -68,6 +74,55 @@ NtGdiGetRasterizerCaps( return FALSE; } +INT +APIENTRY +NtGdiGetTextCharsetInfo( + IN HDC hdc, + OUT OPTIONAL LPFONTSIGNATURE lpSig, + IN DWORD dwFlags) +{ + PDC Dc; + INT Ret; + FONTSIGNATURE fsSafe; + PFONTSIGNATURE pfsSafe = &fsSafe; + NTSTATUS Status = STATUS_SUCCESS; + + Dc = DC_LockDc(hdc); + if (!Dc) + { + SetLastWin32Error(ERROR_INVALID_HANDLE); + return DEFAULT_CHARSET; + } + + if (!lpSig) pfsSafe = NULL; + + Ret = ftGdiGetTextCharsetInfo( Dc, pfsSafe, dwFlags); + + if (lpSig) + { + _SEH_TRY + { + ProbeForWrite( lpSig, + sizeof(FONTSIGNATURE), + 1); + RtlCopyMemory(lpSig, pfsSafe, sizeof(FONTSIGNATURE)); + } + _SEH_HANDLE + { + Status = _SEH_GetExceptionCode(); + } + _SEH_END; + + if (!NT_SUCCESS(Status)) + { + SetLastNtError(Status); + return DEFAULT_CHARSET; + } + } + DC_UnlockDc(Dc); + return Ret; +} + W32KAPI BOOL APIENTRY @@ -298,4 +353,42 @@ NtGdiGetTextFaceW( return Count; } +W32KAPI +BOOL +APIENTRY +NtGdiGetTextMetricsW( + IN HDC hDC, + OUT TMW_INTERNAL * pUnsafeTmwi, + IN ULONG cj +) +{ + TMW_INTERNAL Tmwi; + NTSTATUS Status = STATUS_SUCCESS; + + if ( cj <= sizeof(TMW_INTERNAL) ) + { + if (ftGdiGetTextMetricsW(hDC,&Tmwi)) + { + _SEH_TRY + { + ProbeForWrite(pUnsafeTmwi, cj, 1); + RtlCopyMemory(pUnsafeTmwi,&Tmwi,cj); + } + _SEH_HANDLE + { + Status = _SEH_GetExceptionCode(); + } + _SEH_END + + if (!NT_SUCCESS(Status)) + { + SetLastNtError(Status); + return FALSE; + } + return TRUE; + } + } + return FALSE; +} + /* EOF */ From 693488f7ffaac93aabd324f165e8a1a12ffae090 Mon Sep 17 00:00:00 2001 From: Johannes Anderwald Date: Thu, 30 Oct 2008 10:46:55 +0000 Subject: [PATCH 005/138] - Convert recovery option dialog to unicode - Simply & optimize LoadRecoveryOptions function - CID 786 svn path=/trunk/; revision=37091 --- reactos/dll/cpl/sysdm/startrec.c | 375 ++++++++++++++----------------- 1 file changed, 171 insertions(+), 204 deletions(-) diff --git a/reactos/dll/cpl/sysdm/startrec.c b/reactos/dll/cpl/sysdm/startrec.c index 8c1dcf89825..fc03a3127ea 100644 --- a/reactos/dll/cpl/sysdm/startrec.c +++ b/reactos/dll/cpl/sysdm/startrec.c @@ -12,9 +12,9 @@ typedef struct _STARTINFO { - TCHAR szFreeldrIni[MAX_PATH + 15]; - TCHAR szDumpFile[MAX_PATH]; - TCHAR szMinidumpDir[MAX_PATH]; + WCHAR szFreeldrIni[MAX_PATH + 15]; + WCHAR szDumpFile[MAX_PATH]; + WCHAR szMinidumpDir[MAX_PATH]; DWORD dwCrashDumpEnabled; INT iFreeLdrIni; } STARTINFO, *PSTARTINFO; @@ -33,8 +33,8 @@ SetTimeout(HWND hwndDlg, INT Timeout) EnableWindow(GetDlgItem(hwndDlg, IDC_STRRECLISTUPDWN), TRUE); EnableWindow(GetDlgItem(hwndDlg, IDC_STRRECLISTEDIT), TRUE); } - SendDlgItemMessage(hwndDlg, IDC_STRRECLISTUPDWN, UDM_SETRANGE, (WPARAM) 0, (LPARAM) MAKELONG((short) 999, 0)); - SendDlgItemMessage(hwndDlg, IDC_STRRECLISTUPDWN, UDM_SETPOS, (WPARAM) 0, (LPARAM) MAKELONG((short) Timeout, 0)); + SendDlgItemMessageW(hwndDlg, IDC_STRRECLISTUPDWN, UDM_SETRANGE, (WPARAM) 0, (LPARAM) MAKELONG((short) 999, 0)); + SendDlgItemMessageW(hwndDlg, IDC_STRRECLISTUPDWN, UDM_SETPOS, (WPARAM) 0, (LPARAM) MAKELONG((short) Timeout, 0)); } static VOID @@ -50,33 +50,33 @@ SetRecoveryTimeout(HWND hwndDlg, INT Timeout) EnableWindow(GetDlgItem(hwndDlg, IDC_STRRECRECUPDWN), TRUE); EnableWindow(GetDlgItem(hwndDlg, IDC_STRRECRECEDIT), TRUE); } - SendDlgItemMessage(hwndDlg, IDC_STRRECRECUPDWN, UDM_SETRANGE, (WPARAM) 0, (LPARAM) MAKELONG((short) 999, 0)); - SendDlgItemMessage(hwndDlg, IDC_STRRECRECUPDWN, UDM_SETPOS, (WPARAM) 0, (LPARAM) MAKELONG((short) Timeout, 0)); + SendDlgItemMessageW(hwndDlg, IDC_STRRECRECUPDWN, UDM_SETRANGE, (WPARAM) 0, (LPARAM) MAKELONG((short) 999, 0)); + SendDlgItemMessageW(hwndDlg, IDC_STRRECRECUPDWN, UDM_SETPOS, (WPARAM) 0, (LPARAM) MAKELONG((short) Timeout, 0)); } static DWORD -GetSystemDrive(TCHAR **szSystemDrive) +GetSystemDrive(WCHAR **szSystemDrive) { DWORD dwBufSize; /* get Path to freeldr.ini or boot.ini */ - *szSystemDrive = HeapAlloc(GetProcessHeap(), 0, MAX_PATH * sizeof(TCHAR)); + *szSystemDrive = HeapAlloc(GetProcessHeap(), 0, MAX_PATH * sizeof(WCHAR)); if (szSystemDrive != NULL) { - dwBufSize = GetEnvironmentVariable(_T("SystemDrive"), *szSystemDrive, MAX_PATH); + dwBufSize = GetEnvironmentVariableW(L"SystemDrive", *szSystemDrive, MAX_PATH); if (dwBufSize > MAX_PATH) { - TCHAR *szTmp; + WCHAR *szTmp; DWORD dwBufSize2; - szTmp = HeapReAlloc(GetProcessHeap(), 0, *szSystemDrive, dwBufSize * sizeof(TCHAR)); + szTmp = HeapReAlloc(GetProcessHeap(), 0, *szSystemDrive, dwBufSize * sizeof(WCHAR)); if (szTmp == NULL) goto FailGetSysDrive; *szSystemDrive = szTmp; - dwBufSize2 = GetEnvironmentVariable(_T("SystemDrive"), *szSystemDrive, dwBufSize); + dwBufSize2 = GetEnvironmentVariableW(L"SystemDrive", *szSystemDrive, dwBufSize); if (dwBufSize2 > dwBufSize || dwBufSize2 == 0) goto FailGetSysDrive; } @@ -95,15 +95,15 @@ FailGetSysDrive: } static PBOOTRECORD -ReadFreeldrSection(HINF hInf, TCHAR *szSectionName) +ReadFreeldrSection(HINF hInf, WCHAR *szSectionName) { PBOOTRECORD pRecord; INFCONTEXT InfContext; - TCHAR szName[MAX_PATH]; - TCHAR szValue[MAX_PATH]; + WCHAR szName[MAX_PATH]; + WCHAR szValue[MAX_PATH]; DWORD LineLength; - if (!SetupFindFirstLine(hInf, + if (!SetupFindFirstLineW(hInf, szSectionName, NULL, &InfContext)) @@ -118,31 +118,31 @@ ReadFreeldrSection(HINF hInf, TCHAR *szSectionName) return NULL; } - _tcscpy(pRecord->szSectionName, szSectionName); + wcscpy(pRecord->szSectionName, szSectionName); do { - if (!SetupGetStringField(&InfContext, + if (!SetupGetStringFieldW(&InfContext, 0, szName, - sizeof(szName) / sizeof(TCHAR), + sizeof(szName) / sizeof(WCHAR), &LineLength)) { break; } - if (!SetupGetStringField(&InfContext, + if (!SetupGetStringFieldW(&InfContext, 1, szValue, - sizeof(szValue) / sizeof(TCHAR), + sizeof(szValue) / sizeof(WCHAR), &LineLength)) { break; } - if (!_tcsnicmp(szName, _T("BootType"), 8)) + if (!wcsnicmp(szName, L"BootType", 8)) { - if (!_tcsnicmp(szValue, _T("ReactOS"), 7)) + if (!wcsnicmp(szValue, L"ReactOS", 7)) { //FIXME store as enum pRecord->BootType = 1; @@ -152,14 +152,14 @@ ReadFreeldrSection(HINF hInf, TCHAR *szSectionName) pRecord->BootType = 0; } } - else if (!_tcsnicmp(szName, _T("SystemPath"), 10)) + else if (!wcsnicmp(szName, L"SystemPath", 10)) { - _tcscpy(pRecord->szBootPath, szValue); + wcscpy(pRecord->szBootPath, szValue); } - else if (!_tcsnicmp(szName, _T("Options"), 7)) + else if (!wcsnicmp(szName, L"Options", 7)) { //FIXME store flags as values - _tcscpy(pRecord->szOptions, szValue); + wcscpy(pRecord->szOptions, szValue); } } @@ -174,35 +174,35 @@ LoadFreeldrSettings(HINF hInf, HWND hwndDlg) { INFCONTEXT InfContext; PBOOTRECORD pRecord; - TCHAR szDefaultOs[MAX_PATH]; - TCHAR szName[MAX_PATH]; - TCHAR szValue[MAX_PATH]; + WCHAR szDefaultOs[MAX_PATH]; + WCHAR szName[MAX_PATH]; + WCHAR szValue[MAX_PATH]; DWORD LineLength; DWORD TimeOut; LRESULT lResult; - if (!SetupFindFirstLine(hInf, - _T("FREELOADER"), - _T("DefaultOS"), + if (!SetupFindFirstLineW(hInf, + L"FREELOADER", + L"DefaultOS", &InfContext)) { /* failed to find default os */ return FALSE; } - if (!SetupGetStringField(&InfContext, + if (!SetupGetStringFieldW(&InfContext, 1, szDefaultOs, - sizeof(szDefaultOs) / sizeof(TCHAR), + sizeof(szDefaultOs) / sizeof(WCHAR), &LineLength)) { /* no key */ return FALSE; } - if (!SetupFindFirstLine(hInf, - _T("FREELOADER"), - _T("TimeOut"), + if (!SetupFindFirstLineW(hInf, + L"FREELOADER", + L"TimeOut", &InfContext)) { /* expected to find timeout value */ @@ -218,8 +218,8 @@ LoadFreeldrSettings(HINF hInf, HWND hwndDlg) return FALSE; } - if (!SetupFindFirstLine(hInf, - _T("Operating Systems"), + if (!SetupFindFirstLineW(hInf, + L"Operating Systems", NULL, &InfContext)) { @@ -229,20 +229,20 @@ LoadFreeldrSettings(HINF hInf, HWND hwndDlg) do { - if (!SetupGetStringField(&InfContext, + if (!SetupGetStringFieldW(&InfContext, 0, szName, - sizeof(szName) / sizeof(TCHAR), + sizeof(szName) / sizeof(WCHAR), &LineLength)) { /* the ini file is messed up */ return FALSE; } - if (!SetupGetStringField(&InfContext, + if (!SetupGetStringFieldW(&InfContext, 1, szValue, - sizeof(szValue) / sizeof(TCHAR), + sizeof(szValue) / sizeof(WCHAR), &LineLength)) { /* the ini file is messed up */ @@ -252,14 +252,14 @@ LoadFreeldrSettings(HINF hInf, HWND hwndDlg) pRecord = ReadFreeldrSection(hInf, szName); if (pRecord) { - lResult = SendDlgItemMessage(hwndDlg, IDC_STRECOSCOMBO, CB_ADDSTRING, (WPARAM)0, (LPARAM)szValue); + lResult = SendDlgItemMessageW(hwndDlg, IDC_STRECOSCOMBO, CB_ADDSTRING, (WPARAM)0, (LPARAM)szValue); if (lResult != CB_ERR) { - SendDlgItemMessage(hwndDlg, IDC_STRECOSCOMBO, CB_SETITEMDATA, (WPARAM)lResult, (LPARAM)pRecord); - if (!_tcscmp(szDefaultOs, szName)) + SendDlgItemMessageW(hwndDlg, IDC_STRECOSCOMBO, CB_SETITEMDATA, (WPARAM)lResult, (LPARAM)pRecord); + if (!wcscmp(szDefaultOs, szName)) { /* we store the friendly name as key */ - _tcscpy(szDefaultOs, szValue); + wcscpy(szDefaultOs, szValue); } } else @@ -271,16 +271,16 @@ LoadFreeldrSettings(HINF hInf, HWND hwndDlg) while (SetupFindNextLine(&InfContext, &InfContext)); /* find default os in list */ - lResult = SendDlgItemMessage(hwndDlg, IDC_STRECOSCOMBO, CB_FINDSTRING, (WPARAM)-1, (LPARAM)szDefaultOs); + lResult = SendDlgItemMessageW(hwndDlg, IDC_STRECOSCOMBO, CB_FINDSTRING, (WPARAM)-1, (LPARAM)szDefaultOs); if (lResult != CB_ERR) { /* set cur sel */ - SendDlgItemMessage(hwndDlg, IDC_STRECOSCOMBO, CB_SETCURSEL, (WPARAM)lResult, (LPARAM)0); + SendDlgItemMessageW(hwndDlg, IDC_STRECOSCOMBO, CB_SETCURSEL, (WPARAM)lResult, (LPARAM)0); } if(TimeOut) { - SendDlgItemMessage(hwndDlg, IDC_STRECLIST, BM_SETCHECK, (WPARAM)BST_CHECKED, (LPARAM)0); + SendDlgItemMessageW(hwndDlg, IDC_STRECLIST, BM_SETCHECK, (WPARAM)BST_CHECKED, (LPARAM)0); } SetTimeout(hwndDlg, TimeOut); @@ -292,17 +292,17 @@ static INT LoadBootSettings(HINF hInf, HWND hwndDlg) { INFCONTEXT InfContext; - TCHAR szName[MAX_PATH]; - TCHAR szValue[MAX_PATH]; + WCHAR szName[MAX_PATH]; + WCHAR szValue[MAX_PATH]; DWORD LineLength; DWORD TimeOut = 0; - TCHAR szDefaultOS[MAX_PATH]; - TCHAR szOptions[MAX_PATH]; + WCHAR szDefaultOS[MAX_PATH]; + WCHAR szOptions[MAX_PATH]; PBOOTRECORD pRecord; LRESULT lResult; - if(!SetupFindFirstLine(hInf, - _T("boot loader"), + if(!SetupFindFirstLineW(hInf, + L"boot loader", NULL, &InfContext)) { @@ -311,39 +311,39 @@ LoadBootSettings(HINF hInf, HWND hwndDlg) do { - if (!SetupGetStringField(&InfContext, + if (!SetupGetStringFieldW(&InfContext, 0, szName, - sizeof(szName) / sizeof(TCHAR), + sizeof(szName) / sizeof(WCHAR), &LineLength)) { return FALSE; } - if (!SetupGetStringField(&InfContext, + if (!SetupGetStringFieldW(&InfContext, 1, szValue, - sizeof(szValue) / sizeof(TCHAR), + sizeof(szValue) / sizeof(WCHAR), &LineLength)) { return FALSE; } - if (!_tcsnicmp(szName, _T("timeout"), 7)) + if (!wcsnicmp(szName, L"timeout", 7)) { - TimeOut = _ttoi(szValue); + TimeOut = _wtoi(szValue); } - if (!_tcsnicmp(szName, _T("default"), 7)) + if (!wcsnicmp(szName, L"default", 7)) { - _tcscpy(szDefaultOS, szValue); + wcscpy(szDefaultOS, szValue); } } while (SetupFindNextLine(&InfContext, &InfContext)); - if (!SetupFindFirstLine(hInf, - _T("operating systems"), + if (!SetupFindFirstLineW(hInf, + L"operating systems", NULL, &InfContext)) { @@ -353,48 +353,48 @@ LoadBootSettings(HINF hInf, HWND hwndDlg) do { - if (!SetupGetStringField(&InfContext, + if (!SetupGetStringFieldW(&InfContext, 0, szName, - sizeof(szName) / sizeof(TCHAR), + sizeof(szName) / sizeof(WCHAR), &LineLength)) { return FALSE; } - if (!SetupGetStringField(&InfContext, + if (!SetupGetStringFieldW(&InfContext, 1, szValue, - sizeof(szValue) / sizeof(TCHAR), + sizeof(szValue) / sizeof(WCHAR), &LineLength)) { return FALSE; } - SetupGetStringField(&InfContext, + SetupGetStringFieldW(&InfContext, 2, szOptions, - sizeof(szOptions) / sizeof(TCHAR), + sizeof(szOptions) / sizeof(WCHAR), &LineLength); pRecord = (PBOOTRECORD) HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(BOOTRECORD)); if (pRecord) { pRecord->BootType = 0; - _tcscpy(pRecord->szBootPath, szName); - _tcscpy(pRecord->szSectionName, szValue); - _tcscpy(pRecord->szOptions, szOptions); + wcscpy(pRecord->szBootPath, szName); + wcscpy(pRecord->szSectionName, szValue); + wcscpy(pRecord->szOptions, szOptions); - if (!_tcscmp(szName, szDefaultOS)) + if (!wcscmp(szName, szDefaultOS)) { /* ms boot ini stores the path not the friendly name */ - _tcscpy(szDefaultOS, szValue); + wcscpy(szDefaultOS, szValue); } - lResult = SendDlgItemMessage(hwndDlg, IDC_STRECOSCOMBO, CB_ADDSTRING, (WPARAM)0, (LPARAM)szValue); + lResult = SendDlgItemMessageW(hwndDlg, IDC_STRECOSCOMBO, CB_ADDSTRING, (WPARAM)0, (LPARAM)szValue); if (lResult != CB_ERR) { - SendDlgItemMessage(hwndDlg, IDC_STRECOSCOMBO, CB_SETITEMDATA, (WPARAM)lResult, (LPARAM)pRecord); + SendDlgItemMessageW(hwndDlg, IDC_STRECOSCOMBO, CB_SETITEMDATA, (WPARAM)lResult, (LPARAM)pRecord); } else { @@ -406,16 +406,16 @@ LoadBootSettings(HINF hInf, HWND hwndDlg) while (SetupFindNextLine(&InfContext, &InfContext)); /* find default os in list */ - lResult = SendDlgItemMessage(hwndDlg, IDC_STRECOSCOMBO, CB_FINDSTRING, (WPARAM)0, (LPARAM)szDefaultOS); + lResult = SendDlgItemMessageW(hwndDlg, IDC_STRECOSCOMBO, CB_FINDSTRING, (WPARAM)0, (LPARAM)szDefaultOS); if (lResult != CB_ERR) { /* set cur sel */ - SendDlgItemMessage(hwndDlg, IDC_STRECOSCOMBO, CB_SETCURSEL, (WPARAM)lResult, (LPARAM)0); + SendDlgItemMessageW(hwndDlg, IDC_STRECOSCOMBO, CB_SETCURSEL, (WPARAM)lResult, (LPARAM)0); } if(TimeOut) { - SendDlgItemMessage(hwndDlg, IDC_STRECLIST, BM_SETCHECK, (WPARAM)BST_CHECKED, (LPARAM)0); + SendDlgItemMessageW(hwndDlg, IDC_STRECLIST, BM_SETCHECK, (WPARAM)BST_CHECKED, (LPARAM)0); } SetTimeout(hwndDlg, TimeOut); @@ -430,40 +430,40 @@ DeleteBootRecords(HWND hwndDlg) LONG index; PBOOTRECORD pRecord; - lIndex = SendDlgItemMessage(hwndDlg, IDC_STRECOSCOMBO, CB_GETCOUNT, (WPARAM)0, (LPARAM)0); + lIndex = SendDlgItemMessageW(hwndDlg, IDC_STRECOSCOMBO, CB_GETCOUNT, (WPARAM)0, (LPARAM)0); if (lIndex == CB_ERR) return; for (index = 0; index szFreeldrIni, szSystemDrive); - _tcscat(pStartInfo->szFreeldrIni, _T("\\freeldr.ini")); + wcscpy(pStartInfo->szFreeldrIni, szSystemDrive); + wcscat(pStartInfo->szFreeldrIni, L"\\freeldr.ini"); - if (PathFileExists(pStartInfo->szFreeldrIni)) + if (PathFileExistsW(pStartInfo->szFreeldrIni)) { /* freeldr.ini exists */ - hInf = SetupOpenInfFile(pStartInfo->szFreeldrIni, + hInf = SetupOpenInfFileW(pStartInfo->szFreeldrIni, NULL, INF_STYLE_OLDNT, NULL); @@ -479,13 +479,13 @@ LoadOSList(HWND hwndDlg, PSTARTINFO pStartInfo) } /* try load boot.ini settings */ - _tcscpy(pStartInfo->szFreeldrIni, szSystemDrive); - _tcscat(pStartInfo->szFreeldrIni, _T("\\boot.ini")); + wcscpy(pStartInfo->szFreeldrIni, szSystemDrive); + wcscat(pStartInfo->szFreeldrIni, L"\\boot.ini"); - if (PathFileExists(pStartInfo->szFreeldrIni)) + if (PathFileExistsW(pStartInfo->szFreeldrIni)) { /* load boot.ini settings */ - hInf = SetupOpenInfFile(pStartInfo->szFreeldrIni, + hInf = SetupOpenInfFileW(pStartInfo->szFreeldrIni, NULL, INF_STYLE_OLDNT, NULL); @@ -518,16 +518,16 @@ SetCrashDlgItems(HWND hwnd, PSTARTINFO pStartInfo) /* minidump type */ EnableWindow(GetDlgItem(hwnd, IDC_STRRECDUMPFILE), TRUE); EnableWindow(GetDlgItem(hwnd, IDC_STRRECOVERWRITE), FALSE); - SendMessage(GetDlgItem(hwnd, IDC_STRRECDUMPFILE), WM_SETTEXT, (WPARAM)0, (LPARAM)pStartInfo->szMinidumpDir); + SendMessageW(GetDlgItem(hwnd, IDC_STRRECDUMPFILE), WM_SETTEXT, (WPARAM)0, (LPARAM)pStartInfo->szMinidumpDir); } else if (pStartInfo->dwCrashDumpEnabled == 1 || pStartInfo->dwCrashDumpEnabled == 2) { /* kernel or complete dump */ EnableWindow(GetDlgItem(hwnd, IDC_STRRECDUMPFILE), TRUE); EnableWindow(GetDlgItem(hwnd, IDC_STRRECOVERWRITE), TRUE); - SendMessage(GetDlgItem(hwnd, IDC_STRRECDUMPFILE), WM_SETTEXT, (WPARAM)0, (LPARAM)pStartInfo->szDumpFile); + SendMessageW(GetDlgItem(hwnd, IDC_STRRECDUMPFILE), WM_SETTEXT, (WPARAM)0, (LPARAM)pStartInfo->szDumpFile); } - SendDlgItemMessage(hwnd, IDC_STRRECDEBUGCOMBO, CB_SETCURSEL, (WPARAM)pStartInfo->dwCrashDumpEnabled, (LPARAM)0); + SendDlgItemMessageW(hwnd, IDC_STRRECDEBUGCOMBO, CB_SETCURSEL, (WPARAM)pStartInfo->dwCrashDumpEnabled, (LPARAM)0); } static VOID @@ -536,8 +536,8 @@ WriteStartupRecoveryOptions(HWND hwndDlg, PSTARTINFO pStartInfo) HKEY hKey; DWORD lResult; - if (RegOpenKeyEx(HKEY_LOCAL_MACHINE, - _T("System\\CurrentControlSet\\Control\\CrashControl"), + if (RegOpenKeyExW(HKEY_LOCAL_MACHINE, + L"System\\CurrentControlSet\\Control\\CrashControl", 0, KEY_WRITE, &hKey) != ERROR_SUCCESS) @@ -547,30 +547,30 @@ WriteStartupRecoveryOptions(HWND hwndDlg, PSTARTINFO pStartInfo) } lResult = (DWORD) SendDlgItemMessage(hwndDlg, IDC_STRRECWRITEEVENT, BM_GETCHECK, (WPARAM)0, (LPARAM)0); - RegSetValueEx(hKey, _T("LogEvent"), 0, REG_DWORD, (LPBYTE)&lResult, sizeof(lResult)); + RegSetValueExW(hKey, L"LogEvent", 0, REG_DWORD, (LPBYTE)&lResult, sizeof(lResult)); lResult = (DWORD) SendDlgItemMessage(hwndDlg, IDC_STRRECSENDALERT, BM_GETCHECK, (WPARAM)0, (LPARAM)0); - RegSetValueEx(hKey, _T("SendAlert"), 0, REG_DWORD, (LPBYTE)&lResult, sizeof(lResult)); + RegSetValueExW(hKey, L"SendAlert", 0, REG_DWORD, (LPBYTE)&lResult, sizeof(lResult)); lResult = (DWORD) SendDlgItemMessage(hwndDlg, IDC_STRRECRESTART, BM_GETCHECK, (WPARAM)0, (LPARAM)0); - RegSetValueEx(hKey, _T("AutoReboot"), 0, REG_DWORD, (LPBYTE)&lResult, sizeof(lResult)); + RegSetValueExW(hKey, L"AutoReboot", 0, REG_DWORD, (LPBYTE)&lResult, sizeof(lResult)); lResult = (DWORD) SendDlgItemMessage(hwndDlg, IDC_STRRECOVERWRITE, BM_GETCHECK, (WPARAM)0, (LPARAM)0); - RegSetValueEx(hKey, _T("Overwrite"), 0, REG_DWORD, (LPBYTE)&lResult, sizeof(lResult)); + RegSetValueExW(hKey, L"Overwrite", 0, REG_DWORD, (LPBYTE)&lResult, sizeof(lResult)); if (pStartInfo->dwCrashDumpEnabled == 1 || pStartInfo->dwCrashDumpEnabled == 2) { - SendDlgItemMessage(hwndDlg, IDC_STRRECDUMPFILE, WM_GETTEXT, (WPARAM)sizeof(pStartInfo->szDumpFile) / sizeof(TCHAR), (LPARAM)pStartInfo->szDumpFile); - RegSetValueEx(hKey, _T("DumpFile"), 0, REG_EXPAND_SZ, (LPBYTE)pStartInfo->szDumpFile, (_tcslen(pStartInfo->szDumpFile) + 1) * sizeof(TCHAR)); + SendDlgItemMessage(hwndDlg, IDC_STRRECDUMPFILE, WM_GETTEXT, (WPARAM)sizeof(pStartInfo->szDumpFile) / sizeof(WCHAR), (LPARAM)pStartInfo->szDumpFile); + RegSetValueExW(hKey, L"DumpFile", 0, REG_EXPAND_SZ, (LPBYTE)pStartInfo->szDumpFile, (wcslen(pStartInfo->szDumpFile) + 1) * sizeof(WCHAR)); } else if (pStartInfo->dwCrashDumpEnabled == 3) { - SendDlgItemMessage(hwndDlg, IDC_STRRECDUMPFILE, WM_GETTEXT, (WPARAM)sizeof(pStartInfo->szDumpFile) / sizeof(TCHAR), (LPARAM)pStartInfo->szDumpFile); - RegSetValueEx(hKey, _T("MinidumpDir"), 0, REG_EXPAND_SZ, (LPBYTE)pStartInfo->szDumpFile, (_tcslen(pStartInfo->szDumpFile) + 1) * sizeof(TCHAR)); + SendDlgItemMessage(hwndDlg, IDC_STRRECDUMPFILE, WM_GETTEXT, (WPARAM)sizeof(pStartInfo->szDumpFile) / sizeof(WCHAR), (LPARAM)pStartInfo->szDumpFile); + RegSetValueExW(hKey, L"MinidumpDir", 0, REG_EXPAND_SZ, (LPBYTE)pStartInfo->szDumpFile, (wcslen(pStartInfo->szDumpFile) + 1) * sizeof(WCHAR)); } - RegSetValueEx(hKey, _T("CrashDumpEnabled"), 0, REG_DWORD, (LPBYTE)pStartInfo->dwCrashDumpEnabled, sizeof(pStartInfo->dwCrashDumpEnabled)); + RegSetValueExW(hKey, L"CrashDumpEnabled", 0, REG_DWORD, (LPBYTE)pStartInfo->dwCrashDumpEnabled, sizeof(pStartInfo->dwCrashDumpEnabled)); RegCloseKey(hKey); } @@ -578,13 +578,11 @@ static VOID LoadRecoveryOptions(HWND hwndDlg, PSTARTINFO pStartInfo) { HKEY hKey; - DWORD dwValues; - TCHAR szName[MAX_PATH]; - TCHAR szValue[MAX_PATH]; - DWORD i, dwName, dwValue, dwValueLength, dwType; + WCHAR szName[MAX_PATH]; + DWORD dwValue, dwValueLength, dwType; if (RegOpenKeyEx(HKEY_LOCAL_MACHINE, - _T("System\\CurrentControlSet\\Control\\CrashControl"), + L"System\\CurrentControlSet\\Control\\CrashControl", 0, KEY_READ, &hKey) != ERROR_SUCCESS) @@ -593,88 +591,57 @@ LoadRecoveryOptions(HWND hwndDlg, PSTARTINFO pStartInfo) return; } - if (RegQueryInfoKey(hKey, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - &dwValues, - NULL, - NULL, - NULL, - NULL) != ERROR_SUCCESS) + dwValueLength = sizeof(DWORD); + if (RegQueryValueExW(hKey, L"LogEvent", NULL, &dwType, (LPBYTE)&dwValue, &dwValueLength) == ERROR_SUCCESS && dwType == REG_DWORD && dwValue) + SendDlgItemMessageW(hwndDlg, IDC_STRRECWRITEEVENT, BM_SETCHECK, (WPARAM)BST_CHECKED, (LPARAM)0); + + dwValueLength = sizeof(DWORD); + if (RegQueryValueExW(hKey, L"SendAlert", NULL, &dwType, (LPBYTE)&dwValue, &dwValueLength) == ERROR_SUCCESS && dwType == REG_DWORD && dwValue) + SendDlgItemMessageW(hwndDlg, IDC_STRRECSENDALERT, BM_SETCHECK, (WPARAM)BST_CHECKED, (LPARAM)0); + + dwValueLength = sizeof(DWORD); + if (RegQueryValueExW(hKey, L"AutoReboot", NULL, &dwType, (LPBYTE)&dwValue, &dwValueLength) == ERROR_SUCCESS && dwType == REG_DWORD && dwValue) + SendDlgItemMessageW(hwndDlg, IDC_STRRECRESTART, BM_SETCHECK, (WPARAM)BST_CHECKED, (LPARAM)0); + + dwValueLength = sizeof(DWORD); + if (RegQueryValueExW(hKey, L"Overwrite", NULL, &dwType, (LPBYTE)&dwValue, &dwValueLength) == ERROR_SUCCESS && dwType == REG_DWORD && dwValue) + SendDlgItemMessageW(hwndDlg, IDC_STRRECOVERWRITE, BM_SETCHECK, (WPARAM)BST_CHECKED, (LPARAM)0); + + dwValueLength = sizeof(DWORD); + if (RegQueryValueExW(hKey, L"CrashDumpEnabled", NULL, &dwType, (LPBYTE)&dwValue, &dwValueLength) == ERROR_SUCCESS && dwType == REG_DWORD && dwValue) + pStartInfo->dwCrashDumpEnabled = dwValue; + + dwValueLength = sizeof(pStartInfo->szDumpFile); + if (RegQueryValueExW(hKey, L"DumpFile", NULL, &dwType, (LPBYTE)pStartInfo->szDumpFile, &dwValueLength) != ERROR_SUCCESS) + pStartInfo->szDumpFile[0] = L'\0'; + + dwValueLength = sizeof(pStartInfo->szMinidumpDir); + if (RegQueryValueExW(hKey, L"MinidumpDir", NULL, &dwType, (LPBYTE)pStartInfo->szMinidumpDir, &dwValueLength) != ERROR_SUCCESS) + pStartInfo->szMinidumpDir[0] = L'\0'; + + if (LoadStringW(hApplet, IDS_NO_DUMP, szName, sizeof(szName) / sizeof(WCHAR))) { - RegCloseKey(hKey); - return; + szName[(sizeof(szName)/sizeof(WCHAR))-1] = L'\0'; + SendDlgItemMessageW(hwndDlg, IDC_STRRECDEBUGCOMBO, CB_ADDSTRING, (WPARAM)0, (LPARAM) szName); } - for (i = 0; i < dwValues; i++) + if (LoadString(hApplet, IDS_FULL_DUMP, szName, sizeof(szName) / sizeof(WCHAR))) { - dwName = sizeof(szName) / sizeof(TCHAR); - - RegEnumValue(hKey, i, szName, &dwName, NULL, &dwType, NULL, NULL); - if (dwType == REG_DWORD) - { - dwValueLength = sizeof(dwValue); - dwName = sizeof(szName) / sizeof(TCHAR); - if (RegEnumValue(hKey, i, szName, &dwName, NULL, &dwType, (LPBYTE)&dwValue, &dwValueLength) != ERROR_SUCCESS) - continue; - } - else - { - dwValueLength = sizeof(szValue); - dwName = sizeof(szName) / sizeof(TCHAR); - if (RegEnumValue(hKey, i, szName, &dwName, NULL, &dwType, (LPBYTE)&szValue, &dwValueLength) != ERROR_SUCCESS) - continue; - } - - if (!_tcscmp(szName, _T("LogEvent"))) - { - if (dwValue) - SendDlgItemMessage(hwndDlg, IDC_STRRECWRITEEVENT, BM_SETCHECK, (WPARAM)BST_CHECKED, (LPARAM)0); - } - else if (!_tcscmp(szName, _T("SendAlert"))) - { - if (dwValue) - SendDlgItemMessage(hwndDlg, IDC_STRRECSENDALERT, BM_SETCHECK, (WPARAM)BST_CHECKED, (LPARAM)0); - } - else if (!_tcscmp(szName, _T("AutoReboot"))) - { - if (dwValue) - SendDlgItemMessage(hwndDlg, IDC_STRRECRESTART, BM_SETCHECK, (WPARAM)BST_CHECKED, (LPARAM)0); - } - else if (!_tcscmp(szName, _T("Overwrite"))) - { - if (dwValue) - SendDlgItemMessage(hwndDlg, IDC_STRRECOVERWRITE, BM_SETCHECK, (WPARAM)BST_CHECKED, (LPARAM)0); - } - else if (!_tcscmp(szName, _T("DumpFile"))) - { - _tcscpy(pStartInfo->szDumpFile, szValue); - } - else if (!_tcscmp(szName, _T("MinidumpDir"))) - { - _tcscpy(pStartInfo->szMinidumpDir, szValue); - } - else if (!_tcscmp(szName, _T("CrashDumpEnabled"))) - { - pStartInfo->dwCrashDumpEnabled = dwValue; - } + szName[(sizeof(szName)/sizeof(WCHAR))-1] = L'\0'; + SendDlgItemMessageW(hwndDlg, IDC_STRRECDEBUGCOMBO, CB_ADDSTRING, (WPARAM)0, (LPARAM) szName); } - if (LoadString(hApplet, IDS_NO_DUMP, szValue, sizeof(szValue) / sizeof(TCHAR)) < sizeof(szValue) / sizeof(TCHAR)) - SendDlgItemMessage(hwndDlg, IDC_STRRECDEBUGCOMBO, CB_ADDSTRING, (WPARAM)0, (LPARAM) szValue); + if (LoadStringW(hApplet, IDS_KERNEL_DUMP, szName, sizeof(szName) / sizeof(WCHAR))) + { + szName[(sizeof(szName)/sizeof(WCHAR))-1] = L'\0'; + SendDlgItemMessageW(hwndDlg, IDC_STRRECDEBUGCOMBO, CB_ADDSTRING, (WPARAM)0, (LPARAM) szName); + } - if (LoadString(hApplet, IDS_FULL_DUMP, szValue, sizeof(szValue) / sizeof(TCHAR)) < sizeof(szValue) / sizeof(TCHAR)) - SendDlgItemMessage(hwndDlg, IDC_STRRECDEBUGCOMBO, CB_ADDSTRING, (WPARAM)0, (LPARAM) szValue); - - if (LoadString(hApplet, IDS_KERNEL_DUMP, szValue, sizeof(szValue) / sizeof(TCHAR)) < sizeof(szValue) / sizeof(TCHAR)) - SendDlgItemMessage(hwndDlg, IDC_STRRECDEBUGCOMBO, CB_ADDSTRING, (WPARAM)0, (LPARAM) szValue); - - if (LoadString(hApplet, IDS_MINI_DUMP, szValue, sizeof(szValue) / sizeof(TCHAR)) < sizeof(szValue) / sizeof(TCHAR)) - SendDlgItemMessage(hwndDlg, IDC_STRRECDEBUGCOMBO, CB_ADDSTRING, (WPARAM)0, (LPARAM) szValue); + if (LoadStringW(hApplet, IDS_MINI_DUMP, szName, sizeof(szName) / sizeof(WCHAR))) + { + szName[(sizeof(szName)/sizeof(WCHAR))-1] = L'\0'; + SendDlgItemMessageW(hwndDlg, IDC_STRRECDEBUGCOMBO, CB_ADDSTRING, (WPARAM)0, (LPARAM) szName); + } SetCrashDlgItems(hwndDlg, pStartInfo); RegCloseKey(hKey); @@ -692,7 +659,7 @@ StartRecDlgProc(HWND hwndDlg, PBOOTRECORD pRecord; int iTimeout; LRESULT lResult; - TCHAR szTimeout[10]; + WCHAR szTimeout[10]; UNREFERENCED_PARAMETER(lParam); @@ -717,7 +684,7 @@ StartRecDlgProc(HWND hwndDlg, switch(LOWORD(wParam)) { case IDC_STRRECEDIT: - ShellExecute(0, _T("open"), _T("notepad"), pStartInfo->szFreeldrIni, NULL, SW_SHOWNORMAL); + ShellExecuteW(0, L"open", L"notepad", pStartInfo->szFreeldrIni, NULL, SW_SHOWNORMAL); // FIXME use CreateProcess and wait untill finished // DeleteBootRecords(hwndDlg); // LoadOSList(hwndDlg); @@ -729,9 +696,9 @@ StartRecDlgProc(HWND hwndDlg, iTimeout = SendDlgItemMessage(hwndDlg, IDC_STRRECLISTUPDWN, UDM_GETPOS, (WPARAM)0, (LPARAM)0); else iTimeout = 0; - _stprintf(szTimeout, _T("%i"), iTimeout); + swprintf(szTimeout, L"%i", iTimeout); - lResult = SendDlgItemMessage(hwndDlg, IDC_STRECOSCOMBO, CB_GETCURSEL, (WPARAM)0, (LPARAM)0); + lResult = SendDlgItemMessageW(hwndDlg, IDC_STRECOSCOMBO, CB_GETCURSEL, (WPARAM)0, (LPARAM)0); if (lResult == CB_ERR) { /* ? */ @@ -746,13 +713,13 @@ StartRecDlgProc(HWND hwndDlg, if (pStartInfo->iFreeLdrIni == 1) // FreeLdrIni style { /* set default timeout */ - WritePrivateProfileString(_T("FREELOADER"), - _T("TimeOut"), + WritePrivateProfileStringW(L"FREELOADER", + L"TimeOut", szTimeout, pStartInfo->szFreeldrIni); /* set default os */ - WritePrivateProfileString(_T("FREELOADER"), - _T("DefaultOS"), + WritePrivateProfileStringW(L"FREELOADER", + L"DefaultOS", pRecord->szSectionName, pStartInfo->szFreeldrIni); @@ -760,13 +727,13 @@ StartRecDlgProc(HWND hwndDlg, else if (pStartInfo->iFreeLdrIni == 2) // BootIni style { /* set default timeout */ - WritePrivateProfileString(_T("boot loader"), - _T("timeout"), + WritePrivateProfileStringW(L"boot loader", + L"timeout", szTimeout, pStartInfo->szFreeldrIni); /* set default os */ - WritePrivateProfileString(_T("boot loader"), - _T("default"), + WritePrivateProfileStringW(L"boot loader", + L"default", pRecord->szBootPath, pStartInfo->szFreeldrIni); @@ -807,11 +774,11 @@ StartRecDlgProc(HWND hwndDlg, { if (pStartInfo->dwCrashDumpEnabled == 1 || pStartInfo->dwCrashDumpEnabled == 2) { - SendDlgItemMessage(hwndDlg, IDC_STRRECDUMPFILE, WM_GETTEXT, (WPARAM)sizeof(pStartInfo->szDumpFile) / sizeof(TCHAR), (LPARAM)pStartInfo->szDumpFile); + SendDlgItemMessageW(hwndDlg, IDC_STRRECDUMPFILE, WM_GETTEXT, (WPARAM)sizeof(pStartInfo->szDumpFile) / sizeof(WCHAR), (LPARAM)pStartInfo->szDumpFile); } else if (pStartInfo->dwCrashDumpEnabled == 3) { - SendDlgItemMessage(hwndDlg, IDC_STRRECDUMPFILE, WM_GETTEXT, (WPARAM)sizeof(pStartInfo->szMinidumpDir) / sizeof(TCHAR), (LPARAM)pStartInfo->szMinidumpDir); + SendDlgItemMessageW(hwndDlg, IDC_STRRECDUMPFILE, WM_GETTEXT, (WPARAM)sizeof(pStartInfo->szMinidumpDir) / sizeof(WCHAR), (LPARAM)pStartInfo->szMinidumpDir); } pStartInfo->dwCrashDumpEnabled = lResult; From f5883c94d4d58fe5ed538db2c26ec8686bff7e93 Mon Sep 17 00:00:00 2001 From: James Tabor Date: Thu, 30 Oct 2008 10:48:49 +0000 Subject: [PATCH 006/138] - Update Gdi GetFontLanguageInfo. svn path=/trunk/; revision=37092 --- reactos/dll/win32/gdi32/misc/stubs.c | 15 --------------- reactos/dll/win32/gdi32/objects/font.c | 12 ++++++++++++ 2 files changed, 12 insertions(+), 15 deletions(-) diff --git a/reactos/dll/win32/gdi32/misc/stubs.c b/reactos/dll/win32/gdi32/misc/stubs.c index 3d2f8441682..fd2ec1f177e 100644 --- a/reactos/dll/win32/gdi32/misc/stubs.c +++ b/reactos/dll/win32/gdi32/misc/stubs.c @@ -173,21 +173,6 @@ GetMetaFileBitsEx( return 0; } - -/* - * @unimplemented - */ -DWORD -STDCALL -GetFontLanguageInfo( - HDC hDc - ) -{ - UNIMPLEMENTED; - SetLastError(ERROR_CALL_NOT_IMPLEMENTED); - return 0; -} - /* * @unimplemented */ diff --git a/reactos/dll/win32/gdi32/objects/font.c b/reactos/dll/win32/gdi32/objects/font.c index faf74891296..42dc263c21e 100644 --- a/reactos/dll/win32/gdi32/objects/font.c +++ b/reactos/dll/win32/gdi32/objects/font.c @@ -904,6 +904,18 @@ GetCharWidthI(HDC hdc, (PVOID) lpBuffer ); } +/* + * @implemented + */ +DWORD +STDCALL +GetFontLanguageInfo( + HDC hDc + ) +{ + return GetDCDWord(hDc, GdiGetFontLanguageInfo, GCP_ERROR); +} + /* * @implemented */ From d0418e71235bd82b1d170881263dcc6741cf0b17 Mon Sep 17 00:00:00 2001 From: Dmitry Chapyshev Date: Thu, 30 Oct 2008 11:14:40 +0000 Subject: [PATCH 007/138] - Attempt to fix a bug 3255. By means of Christoph_vW. Not tested. svn path=/trunk/; revision=37093 --- .../rbuild/backend/codeblocks/codeblocks.cpp | 44 +++++++++---------- 1 file changed, 22 insertions(+), 22 deletions(-) diff --git a/reactos/tools/rbuild/backend/codeblocks/codeblocks.cpp b/reactos/tools/rbuild/backend/codeblocks/codeblocks.cpp index 73502e8fdb5..9648bc421e8 100644 --- a/reactos/tools/rbuild/backend/codeblocks/codeblocks.cpp +++ b/reactos/tools/rbuild/backend/codeblocks/codeblocks.cpp @@ -211,7 +211,7 @@ std::string CBBackend::CbpFileName ( const Module& module ) const { return DosSeparator( - ReplaceExtension ( module.output->relative_path + "\\" + module.output->name, "_auto.cbp" ) + ReplaceExtension ( module.output->relative_path + sSep + module.output->name, "_auto.cbp" ) ); } @@ -219,7 +219,7 @@ std::string CBBackend::LayoutFileName ( const Module& module ) const { return DosSeparator( - ReplaceExtension ( module.output->relative_path + "\\" + module.output->name, "_auto.layout" ) + ReplaceExtension ( module.output->relative_path + sSep + module.output->name, "_auto.layout" ) ); } @@ -227,7 +227,7 @@ std::string CBBackend::DependFileName ( const Module& module ) const { return DosSeparator( - ReplaceExtension ( module.output->relative_path + "\\" + module.output->name, "_auto.depend" ) + ReplaceExtension ( module.output->relative_path + sSep + module.output->name, "_auto.depend" ) ); } @@ -236,8 +236,8 @@ CBBackend::_get_object_files ( const Module& module, vector& out) const { string basepath = module.output->relative_path; size_t i; - string intenv = Environment::GetIntermediatePath () + "\\" + basepath + "\\"; - string outenv = Environment::GetOutputPath () + "\\" + basepath + "\\"; + string intenv = Environment::GetIntermediatePath () + sSep + basepath + sSep; + string outenv = Environment::GetOutputPath () + sSep + basepath + sSep; vector cfgs; @@ -265,7 +265,7 @@ CBBackend::_get_object_files ( const Module& module, vector& out) const for ( i = 0; i < files.size (); i++ ) { string file = files[i]->file.relative_path + sSep + files[i]->file.name; - string::size_type pos = file.find_last_of ("\\"); + string::size_type pos = file.find_last_of (sSep); if ( pos != string::npos ) file.erase ( 0, pos+1 ); if ( !stricmp ( Right(file,3).c_str(), ".rc" ) ) @@ -273,7 +273,7 @@ CBBackend::_get_object_files ( const Module& module, vector& out) const else file = ReplaceExtension ( file, ".obj" ); for ( size_t j = 0; j < cfgs.size () / 2; j++ ) - out.push_back ( cfgs[j] + "\\" + file ); + out.push_back ( cfgs[j] + sSep + file ); } } @@ -334,7 +334,7 @@ CBBackend::_generate_workspace ( FILE* OUT ) ifs_list.pop_back(); const vector& libs = data.libraries; for ( size_t j = 0; j < libs.size(); j++ ) - fprintf ( OUT, "\t\t\t\r\n", libs[j]->importedModule->output->relative_path.c_str(), libs[j]->name.c_str() ); + fprintf ( OUT, "\t\t\t\r\n", libs[j]->importedModule->output->relative_path.c_str(), sSep.c_str(), libs[j]->name.c_str() ); } fprintf ( OUT, "\t\t\r\n" ); } @@ -447,7 +447,7 @@ CBBackend::_generate_cbproj ( const Module& module ) const vector& libs = data.libraries; for ( i = 0; i < libs.size(); i++ ) { - string libpath = intdir + "\\" + libs[i]->importedModule->output->relative_path; + string libpath = intdir + sSep + libs[i]->importedModule->output->relative_path; libraries.push_back ( libs[i]->name ); libpaths.push_back ( libpath ); } @@ -516,18 +516,18 @@ CBBackend::_generate_cbproj ( const Module& module ) if ( configuration.UseConfigurationInPath ) { if ( IsStaticLibrary ( module ) ||module.type == ObjectLibrary ) - fprintf ( OUT, "\t\t\t\t