ReactOS.org
Sign In
Sign Up
Sign In
Sign Up
Manage this list
×
Keyboard Shortcuts
Thread View
j
: Next unread message
k
: Previous unread message
j a
: Jump to all threads
j l
: Jump to MailingList overview
2024
December
November
October
September
August
July
June
May
April
March
February
January
2023
December
November
October
September
August
July
June
May
April
March
February
January
2022
December
November
October
September
August
July
June
May
April
March
February
January
2021
December
November
October
September
August
July
June
May
April
March
February
January
2020
December
November
October
September
August
July
June
May
April
March
February
January
2019
December
November
October
September
August
July
June
May
April
March
February
January
2018
December
November
October
September
August
July
June
May
April
March
February
January
2017
December
November
October
September
August
July
June
May
April
March
February
January
2016
December
November
October
September
August
July
June
May
April
March
February
January
2015
December
November
October
September
August
July
June
May
April
March
February
January
2014
December
November
October
September
August
July
June
May
April
March
February
January
2013
December
November
October
September
August
July
June
May
April
March
February
January
2012
December
November
October
September
August
July
June
May
April
March
February
January
2011
December
November
October
September
August
July
June
May
April
March
February
January
2010
December
November
October
September
August
July
June
May
April
March
February
January
2009
December
November
October
September
August
July
June
May
April
March
February
January
2008
December
November
October
September
August
July
June
May
April
March
February
January
2007
December
November
October
September
August
July
June
May
April
March
February
January
2006
December
November
October
September
August
July
June
May
April
March
February
January
2005
December
November
October
September
August
July
June
May
April
March
February
January
2004
December
November
October
September
August
July
June
May
April
March
February
List overview
Download
Ros-diffs
September 2021
----- 2024 -----
December 2024
November 2024
October 2024
September 2024
August 2024
July 2024
June 2024
May 2024
April 2024
March 2024
February 2024
January 2024
----- 2023 -----
December 2023
November 2023
October 2023
September 2023
August 2023
July 2023
June 2023
May 2023
April 2023
March 2023
February 2023
January 2023
----- 2022 -----
December 2022
November 2022
October 2022
September 2022
August 2022
July 2022
June 2022
May 2022
April 2022
March 2022
February 2022
January 2022
----- 2021 -----
December 2021
November 2021
October 2021
September 2021
August 2021
July 2021
June 2021
May 2021
April 2021
March 2021
February 2021
January 2021
----- 2020 -----
December 2020
November 2020
October 2020
September 2020
August 2020
July 2020
June 2020
May 2020
April 2020
March 2020
February 2020
January 2020
----- 2019 -----
December 2019
November 2019
October 2019
September 2019
August 2019
July 2019
June 2019
May 2019
April 2019
March 2019
February 2019
January 2019
----- 2018 -----
December 2018
November 2018
October 2018
September 2018
August 2018
July 2018
June 2018
May 2018
April 2018
March 2018
February 2018
January 2018
----- 2017 -----
December 2017
November 2017
October 2017
September 2017
August 2017
July 2017
June 2017
May 2017
April 2017
March 2017
February 2017
January 2017
----- 2016 -----
December 2016
November 2016
October 2016
September 2016
August 2016
July 2016
June 2016
May 2016
April 2016
March 2016
February 2016
January 2016
----- 2015 -----
December 2015
November 2015
October 2015
September 2015
August 2015
July 2015
June 2015
May 2015
April 2015
March 2015
February 2015
January 2015
----- 2014 -----
December 2014
November 2014
October 2014
September 2014
August 2014
July 2014
June 2014
May 2014
April 2014
March 2014
February 2014
January 2014
----- 2013 -----
December 2013
November 2013
October 2013
September 2013
August 2013
July 2013
June 2013
May 2013
April 2013
March 2013
February 2013
January 2013
----- 2012 -----
December 2012
November 2012
October 2012
September 2012
August 2012
July 2012
June 2012
May 2012
April 2012
March 2012
February 2012
January 2012
----- 2011 -----
December 2011
November 2011
October 2011
September 2011
August 2011
July 2011
June 2011
May 2011
April 2011
March 2011
February 2011
January 2011
----- 2010 -----
December 2010
November 2010
October 2010
September 2010
August 2010
July 2010
June 2010
May 2010
April 2010
March 2010
February 2010
January 2010
----- 2009 -----
December 2009
November 2009
October 2009
September 2009
August 2009
July 2009
June 2009
May 2009
April 2009
March 2009
February 2009
January 2009
----- 2008 -----
December 2008
November 2008
October 2008
September 2008
August 2008
July 2008
June 2008
May 2008
April 2008
March 2008
February 2008
January 2008
----- 2007 -----
December 2007
November 2007
October 2007
September 2007
August 2007
July 2007
June 2007
May 2007
April 2007
March 2007
February 2007
January 2007
----- 2006 -----
December 2006
November 2006
October 2006
September 2006
August 2006
July 2006
June 2006
May 2006
April 2006
March 2006
February 2006
January 2006
----- 2005 -----
December 2005
November 2005
October 2005
September 2005
August 2005
July 2005
June 2005
May 2005
April 2005
March 2005
February 2005
January 2005
----- 2004 -----
December 2004
November 2004
October 2004
September 2004
August 2004
July 2004
June 2004
May 2004
April 2004
March 2004
February 2004
ros-diffs@reactos.org
25 participants
144 discussions
Start a n
N
ew thread
[reactos] 01/01: [IMM32] GetKeyboardLayout's parameter is a thread id
by Katayama Hirofumi MZ
https://git.reactos.org/?p=reactos.git;a=commitdiff;h=f5bbd57d7329136d97d84…
commit f5bbd57d7329136d97d8431a23b5eb9add5fb5d4 Author: Katayama Hirofumi MZ <katayama.hirofumi.mz(a)gmail.com> AuthorDate: Fri Oct 1 03:13:52 2021 +0900 Commit: Katayama Hirofumi MZ <katayama.hirofumi.mz(a)gmail.com> CommitDate: Fri Oct 1 03:13:52 2021 +0900 [IMM32] GetKeyboardLayout's parameter is a thread id s/dwLayout/dwThreadId/ CORE-11700 --- dll/win32/imm32/utils.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/dll/win32/imm32/utils.c b/dll/win32/imm32/utils.c index cda20efc884..40512338d22 100644 --- a/dll/win32/imm32/utils.c +++ b/dll/win32/imm32/utils.c @@ -147,17 +147,17 @@ BOOL APIENTRY Imm32NotifyAction(HIMC hIMC, HWND hwnd, DWORD dwAction, DWORD_PTR dwIndex, DWORD_PTR dwValue, DWORD_PTR dwCommand, DWORD_PTR dwData) { - DWORD dwLayout; + DWORD dwThreadId; HKL hKL; PIMEDPI pImeDpi; if (dwAction) { - dwLayout = NtUserQueryInputContext(hIMC, 1); - if (dwLayout) + dwThreadId = NtUserQueryInputContext(hIMC, 1); + if (dwThreadId) { /* find keyboard layout and lock it */ - hKL = GetKeyboardLayout(dwLayout); + hKL = GetKeyboardLayout(dwThreadId); pImeDpi = ImmLockImeDpi(hKL); if (pImeDpi) {
3 years, 2 months
1
0
0
0
[reactos] 01/01: [IMM32] Move ImmFreeLayout from ime.c to imm.c
by Katayama Hirofumi MZ
https://git.reactos.org/?p=reactos.git;a=commitdiff;h=e6a51b54c4cb74d8cf502…
commit e6a51b54c4cb74d8cf5021519b671fab4af129b1 Author: Katayama Hirofumi MZ <katayama.hirofumi.mz(a)gmail.com> AuthorDate: Fri Oct 1 03:10:26 2021 +0900 Commit: Katayama Hirofumi MZ <katayama.hirofumi.mz(a)gmail.com> CommitDate: Fri Oct 1 03:10:26 2021 +0900 [IMM32] Move ImmFreeLayout from ime.c to imm.c CORE-11700 --- dll/win32/imm32/ime.c | 67 ----------------------------------------------- dll/win32/imm32/imm.c | 67 +++++++++++++++++++++++++++++++++++++++++++++++ dll/win32/imm32/precomp.h | 1 + 3 files changed, 68 insertions(+), 67 deletions(-) diff --git a/dll/win32/imm32/ime.c b/dll/win32/imm32/ime.c index 7ae3325f323..e831a81fcee 100644 --- a/dll/win32/imm32/ime.c +++ b/dll/win32/imm32/ime.c @@ -1677,70 +1677,3 @@ ImmGetImeMenuItemsW(HIMC hIMC, DWORD dwFlags, DWORD dwType, return Imm32GetImeMenuItemsAW(hIMC, dwFlags, dwType, lpImeParentMenu, lpImeMenu, dwSize, FALSE); } - -/*********************************************************************** - * ImmFreeLayout (IMM32.@) - */ -BOOL WINAPI ImmFreeLayout(DWORD dwUnknown) -{ - WCHAR szKBD[9]; - UINT iKL, cKLs; - HKL hOldKL, hNewKL, *pList; - PIMEDPI pImeDpi; - LANGID LangID; - - TRACE("(0x%lX)\n", dwUnknown); - - hOldKL = GetKeyboardLayout(0); - - if (dwUnknown == 1) - { - if (!IS_IME_HKL(hOldKL)) - return TRUE; - - LangID = LANGIDFROMLCID(GetSystemDefaultLCID()); - - cKLs = GetKeyboardLayoutList(0, NULL); - if (cKLs) - { - pList = Imm32HeapAlloc(0, cKLs * sizeof(HKL)); - if (pList == NULL) - return FALSE; - - cKLs = GetKeyboardLayoutList(cKLs, pList); - for (iKL = 0; iKL < cKLs; ++iKL) - { - if (!IS_IME_HKL(pList[iKL])) - { - LangID = LOWORD(pList[iKL]); - break; - } - } - - Imm32HeapFree(pList); - } - - StringCchPrintfW(szKBD, _countof(szKBD), L"%08X", LangID); - if (!LoadKeyboardLayoutW(szKBD, KLF_ACTIVATE)) - LoadKeyboardLayoutW(L"00000409", KLF_ACTIVATE | 0x200); - } - else if (dwUnknown == 2) - { - RtlEnterCriticalSection(&g_csImeDpi); -Retry: - for (pImeDpi = g_pImeDpiList; pImeDpi; pImeDpi = pImeDpi->pNext) - { - if (Imm32ReleaseIME(pImeDpi->hKL)) - goto Retry; - } - RtlLeaveCriticalSection(&g_csImeDpi); - } - else - { - hNewKL = (HKL)(DWORD_PTR)dwUnknown; - if (IS_IME_HKL(hNewKL) && hNewKL != hOldKL) - Imm32ReleaseIME(hNewKL); - } - - return TRUE; -} diff --git a/dll/win32/imm32/imm.c b/dll/win32/imm32/imm.c index 5cb72db884c..f458685e0ec 100644 --- a/dll/win32/imm32/imm.c +++ b/dll/win32/imm32/imm.c @@ -101,6 +101,73 @@ HKL WINAPI ImmLoadLayout(HKL hKL, PIMEINFOEX pImeInfoEx) return hKL; } +/*********************************************************************** + * ImmFreeLayout (IMM32.@) + */ +BOOL WINAPI ImmFreeLayout(DWORD dwUnknown) +{ + WCHAR szKBD[9]; + UINT iKL, cKLs; + HKL hOldKL, hNewKL, *pList; + PIMEDPI pImeDpi; + LANGID LangID; + + TRACE("(0x%lX)\n", dwUnknown); + + hOldKL = GetKeyboardLayout(0); + + if (dwUnknown == 1) + { + if (!IS_IME_HKL(hOldKL)) + return TRUE; + + LangID = LANGIDFROMLCID(GetSystemDefaultLCID()); + + cKLs = GetKeyboardLayoutList(0, NULL); + if (cKLs) + { + pList = Imm32HeapAlloc(0, cKLs * sizeof(HKL)); + if (pList == NULL) + return FALSE; + + cKLs = GetKeyboardLayoutList(cKLs, pList); + for (iKL = 0; iKL < cKLs; ++iKL) + { + if (!IS_IME_HKL(pList[iKL])) + { + LangID = LOWORD(pList[iKL]); + break; + } + } + + Imm32HeapFree(pList); + } + + StringCchPrintfW(szKBD, _countof(szKBD), L"%08X", LangID); + if (!LoadKeyboardLayoutW(szKBD, KLF_ACTIVATE)) + LoadKeyboardLayoutW(L"00000409", KLF_ACTIVATE | 0x200); + } + else if (dwUnknown == 2) + { + RtlEnterCriticalSection(&g_csImeDpi); +Retry: + for (pImeDpi = g_pImeDpiList; pImeDpi; pImeDpi = pImeDpi->pNext) + { + if (Imm32ReleaseIME(pImeDpi->hKL)) + goto Retry; + } + RtlLeaveCriticalSection(&g_csImeDpi); + } + else + { + hNewKL = (HKL)(DWORD_PTR)dwUnknown; + if (IS_IME_HKL(hNewKL) && hNewKL != hOldKL) + Imm32ReleaseIME(hNewKL); + } + + return TRUE; +} + typedef struct _tagImmHkl { struct list entry; diff --git a/dll/win32/imm32/precomp.h b/dll/win32/imm32/precomp.h index 1bcc18bbb30..c5522127cc3 100644 --- a/dll/win32/imm32/precomp.h +++ b/dll/win32/imm32/precomp.h @@ -81,6 +81,7 @@ LPVOID APIENTRY Imm32HeapAlloc(DWORD dwFlags, DWORD dwBytes); LPWSTR APIENTRY Imm32WideFromAnsi(LPCSTR pszA); LPSTR APIENTRY Imm32AnsiFromWide(LPCWSTR pszW); PIMEDPI APIENTRY ImmLockOrLoadImeDpi(HKL hKL); +BOOL APIENTRY Imm32ReleaseIME(HKL hKL); static inline BOOL Imm32IsCrossThreadAccess(HIMC hIMC) {
3 years, 2 months
1
0
0
0
[reactos] 01/01: [IMM32] Rewrite ImmGetImeMenuItemsA/W (#3983)
by Katayama Hirofumi MZ
https://git.reactos.org/?p=reactos.git;a=commitdiff;h=33affbfecbc8a3a4c5c20…
commit 33affbfecbc8a3a4c5c20a8776e46f34da898f40 Author: Katayama Hirofumi MZ <katayama.hirofumi.mz(a)gmail.com> AuthorDate: Fri Oct 1 03:04:00 2021 +0900 Commit: GitHub <noreply(a)github.com> CommitDate: Fri Oct 1 03:04:00 2021 +0900 [IMM32] Rewrite ImmGetImeMenuItemsA/W (#3983) - Rewrite ImmGetImeMenuItemsA and ImmGetImeMenuItemsW functions. - Add Imm32GetImeMenuItemsAW, Imm32IsImcAnsi, Imm32ImeMenuAnsiToWide and Imm32ImeMenuWideToAnsi helper functions. - Make IME module's ImeGetImeMenuItems function optional. CORE-11700 --- dll/win32/imm32/ime.c | 177 ++++++++++++++++++++++++++++++++++++++++++++- dll/win32/imm32/imm.c | 142 ------------------------------------ dll/win32/imm32/precomp.h | 9 +++ dll/win32/imm32/utils.c | 60 +++++++++++++++ win32ss/include/imetable.h | 4 +- 5 files changed, 246 insertions(+), 146 deletions(-) diff --git a/dll/win32/imm32/ime.c b/dll/win32/imm32/ime.c index b1b31ce9eeb..7ae3325f323 100644 --- a/dll/win32/imm32/ime.c +++ b/dll/win32/imm32/ime.c @@ -168,11 +168,11 @@ BOOL APIENTRY Imm32LoadImeInfo(PIMEINFOEX pImeInfoEx, PIMEDPI pImeDpi) } pImeDpi->hInst = hIME; -#define DEFINE_IME_ENTRY(type, name, params, extended) \ +#define DEFINE_IME_ENTRY(type, name, params, optional) \ do { \ fn = GetProcAddress(hIME, #name); \ if (fn) pImeDpi->name = (FN_##name)fn; \ - else if (!(extended)) goto Failed; \ + else if (!(optional)) goto Failed; \ } while (0); #include "imetable.h" #undef DEFINE_IME_ENTRY @@ -330,6 +330,151 @@ Quit: return ret; } +DWORD APIENTRY +Imm32GetImeMenuItemWCrossProcess(HIMC hIMC, DWORD dwFlags, DWORD dwType, LPVOID lpImeParentMenu, + LPVOID lpImeMenu, DWORD dwSize) +{ + FIXME("We have to do something\n"); + return 0; +} + +DWORD APIENTRY +Imm32GetImeMenuItemsAW(HIMC hIMC, DWORD dwFlags, DWORD dwType, LPVOID lpImeParentMenu, + LPVOID lpImeMenu, DWORD dwSize, BOOL bTargetIsAnsi) +{ + DWORD ret = 0, cbTotal, dwProcessId, dwThreadId, iItem; + LPINPUTCONTEXT pIC; + PIMEDPI pImeDpi = NULL; + IMEMENUITEMINFOA ParentA; + IMEMENUITEMINFOW ParentW; + LPIMEMENUITEMINFOA pItemA; + LPIMEMENUITEMINFOW pItemW; + LPVOID pNewItems = NULL, pNewParent = NULL; + BOOL bImcIsAnsi; + HKL hKL; + + if (!hIMC) + return 0; + + dwProcessId = NtUserQueryInputContext(hIMC, 0); + if (dwProcessId == 0) + return 0; + + if (dwProcessId != GetCurrentProcessId()) + { + if (bTargetIsAnsi) + return 0; + return Imm32GetImeMenuItemWCrossProcess(hIMC, dwFlags, dwType, lpImeParentMenu, + lpImeMenu, dwSize); + } + + pIC = ImmLockIMC(hIMC); + if (pIC == NULL) + return 0; + + dwThreadId = NtUserQueryInputContext(hIMC, 1); + if (dwThreadId == 0) + { + ImmUnlockIMC(hIMC); + return 0; + } + + hKL = GetKeyboardLayout(dwThreadId); + pImeDpi = ImmLockImeDpi(hKL); + if (!pImeDpi) + { + ImmUnlockIMC(hIMC); + return 0; + } + + if (pImeDpi->ImeGetImeMenuItems == NULL) + goto Quit; + + bImcIsAnsi = Imm32IsImcAnsi(hIMC); + + if (bImcIsAnsi != bTargetIsAnsi) + { + if (bTargetIsAnsi) + { + if (lpImeParentMenu) + pNewParent = &ParentW; + + if (lpImeMenu) + { + cbTotal = ((dwSize / sizeof(IMEMENUITEMINFOA)) * sizeof(IMEMENUITEMINFOW)); + pNewItems = Imm32HeapAlloc(0, cbTotal); + if (!pNewItems) + goto Quit; + } + } + else + { + if (lpImeParentMenu) + pNewParent = &ParentA; + + if (lpImeMenu) + { + cbTotal = ((dwSize / sizeof(IMEMENUITEMINFOW)) * sizeof(IMEMENUITEMINFOA)); + pNewItems = Imm32HeapAlloc(0, cbTotal); + if (!pNewItems) + goto Quit; + } + } + } + else + { + pNewItems = lpImeMenu; + pNewParent = lpImeParentMenu; + } + + ret = pImeDpi->ImeGetImeMenuItems(hIMC, dwFlags, dwType, pNewParent, pNewItems, dwSize); + if (!ret || !lpImeMenu) + goto Quit; + + if (bImcIsAnsi != bTargetIsAnsi) + { + if (bTargetIsAnsi) + { + if (pNewParent) + Imm32ImeMenuWideToAnsi(pNewParent, lpImeParentMenu, CP_ACP); + + pItemW = pNewItems; + pItemA = lpImeMenu; + for (iItem = 0; iItem < ret; ++iItem, ++pItemW, ++pItemA) + { + if (!Imm32ImeMenuWideToAnsi(pItemW, pItemA, CP_ACP)) + { + ret = 0; + break; + } + } + } + else + { + if (pNewParent) + Imm32ImeMenuAnsiToWide(pNewParent, lpImeParentMenu, pImeDpi->uCodePage, TRUE); + + pItemA = pNewItems; + pItemW = lpImeMenu; + for (iItem = 0; iItem < dwSize; ++iItem, ++pItemA, ++pItemW) + { + if (!Imm32ImeMenuAnsiToWide(pItemA, pItemW, pImeDpi->uCodePage, TRUE)) + { + ret = 0; + break; + } + } + } + } + +Quit: + if (pNewItems != lpImeMenu) + Imm32HeapFree(pNewItems); + ImmUnlockImeDpi(pImeDpi); + ImmUnlockIMC(hIMC); + return ret; +} + /*********************************************************************** * ImmIsIME (IMM32.@) */ @@ -1505,6 +1650,34 @@ Quit: return ret; } +/*********************************************************************** + * ImmGetImeMenuItemsA (IMM32.@) + */ +DWORD WINAPI +ImmGetImeMenuItemsA(HIMC hIMC, DWORD dwFlags, DWORD dwType, + LPIMEMENUITEMINFOA lpImeParentMenu, + LPIMEMENUITEMINFOA lpImeMenu, DWORD dwSize) +{ + TRACE("(%p, 0x%lX, 0x%lX, %p, %p, 0x%lX)\n", + hIMC, dwFlags, dwType, lpImeParentMenu, lpImeMenu, dwSize); + return Imm32GetImeMenuItemsAW(hIMC, dwFlags, dwType, lpImeParentMenu, lpImeMenu, + dwSize, TRUE); +} + +/*********************************************************************** + * ImmGetImeMenuItemsW (IMM32.@) + */ +DWORD WINAPI +ImmGetImeMenuItemsW(HIMC hIMC, DWORD dwFlags, DWORD dwType, + LPIMEMENUITEMINFOW lpImeParentMenu, + LPIMEMENUITEMINFOW lpImeMenu, DWORD dwSize) +{ + TRACE("(%p, 0x%lX, 0x%lX, %p, %p, 0x%lX)\n", + hIMC, dwFlags, dwType, lpImeParentMenu, lpImeMenu, dwSize); + return Imm32GetImeMenuItemsAW(hIMC, dwFlags, dwType, lpImeParentMenu, lpImeMenu, + dwSize, FALSE); +} + /*********************************************************************** * ImmFreeLayout (IMM32.@) */ diff --git a/dll/win32/imm32/imm.c b/dll/win32/imm32/imm.c index 07eb129bffc..5cb72db884c 100644 --- a/dll/win32/imm32/imm.c +++ b/dll/win32/imm32/imm.c @@ -1425,148 +1425,6 @@ BOOL WINAPI ImmSetActiveContextConsoleIME(HWND hwnd, BOOL fFlag) return FALSE; } -/*********************************************************************** - * ImmGetImeMenuItemsA (IMM32.@) - */ -DWORD WINAPI -ImmGetImeMenuItemsA(HIMC hIMC, DWORD dwFlags, DWORD dwType, - LPIMEMENUITEMINFOA lpImeParentMenu, - LPIMEMENUITEMINFOA lpImeMenu, DWORD dwSize) -{ - InputContextData *data = get_imc_data(hIMC); - TRACE("(%p, %i, %i, %p, %p, %i):\n", hIMC, dwFlags, dwType, - lpImeParentMenu, lpImeMenu, dwSize); - - if (!data) - { - SetLastError(ERROR_INVALID_HANDLE); - return 0; - } - - if (data->immKbd->hIME && data->immKbd->pImeGetImeMenuItems) - { - if (!is_himc_ime_unicode(data) || (!lpImeParentMenu && !lpImeMenu)) - return data->immKbd->pImeGetImeMenuItems(hIMC, dwFlags, dwType, - (IMEMENUITEMINFOW*)lpImeParentMenu, - (IMEMENUITEMINFOW*)lpImeMenu, dwSize); - else - { - IMEMENUITEMINFOW lpImeParentMenuW; - IMEMENUITEMINFOW *lpImeMenuW, *parent = NULL; - DWORD rc; - - if (lpImeParentMenu) - parent = &lpImeParentMenuW; - if (lpImeMenu) - { - int count = dwSize / sizeof(LPIMEMENUITEMINFOA); - dwSize = count * sizeof(IMEMENUITEMINFOW); - lpImeMenuW = HeapAlloc(GetProcessHeap(), 0, dwSize); - } - else - lpImeMenuW = NULL; - - rc = data->immKbd->pImeGetImeMenuItems(hIMC, dwFlags, dwType, - parent, lpImeMenuW, dwSize); - - if (lpImeParentMenu) - { - memcpy(lpImeParentMenu,&lpImeParentMenuW,sizeof(IMEMENUITEMINFOA)); - lpImeParentMenu->hbmpItem = lpImeParentMenuW.hbmpItem; - WideCharToMultiByte(CP_ACP, 0, lpImeParentMenuW.szString, - -1, lpImeParentMenu->szString, IMEMENUITEM_STRING_SIZE, - NULL, NULL); - } - if (lpImeMenu && rc) - { - unsigned int i; - for (i = 0; i < rc; i++) - { - memcpy(&lpImeMenu[i],&lpImeMenuW[1],sizeof(IMEMENUITEMINFOA)); - lpImeMenu[i].hbmpItem = lpImeMenuW[i].hbmpItem; - WideCharToMultiByte(CP_ACP, 0, lpImeMenuW[i].szString, - -1, lpImeMenu[i].szString, IMEMENUITEM_STRING_SIZE, - NULL, NULL); - } - } - HeapFree(GetProcessHeap(),0,lpImeMenuW); - return rc; - } - } - else - return 0; -} - -/*********************************************************************** - * ImmGetImeMenuItemsW (IMM32.@) - */ -DWORD WINAPI -ImmGetImeMenuItemsW(HIMC hIMC, DWORD dwFlags, DWORD dwType, - LPIMEMENUITEMINFOW lpImeParentMenu, - LPIMEMENUITEMINFOW lpImeMenu, DWORD dwSize) -{ - InputContextData *data = get_imc_data(hIMC); - TRACE("(%p, %i, %i, %p, %p, %i):\n", hIMC, dwFlags, dwType, - lpImeParentMenu, lpImeMenu, dwSize); - - if (!data) - { - SetLastError(ERROR_INVALID_HANDLE); - return 0; - } - - if (data->immKbd->hIME && data->immKbd->pImeGetImeMenuItems) - { - if (is_himc_ime_unicode(data) || (!lpImeParentMenu && !lpImeMenu)) - return data->immKbd->pImeGetImeMenuItems(hIMC, dwFlags, dwType, - lpImeParentMenu, lpImeMenu, dwSize); - else - { - IMEMENUITEMINFOA lpImeParentMenuA; - IMEMENUITEMINFOA *lpImeMenuA, *parent = NULL; - DWORD rc; - - if (lpImeParentMenu) - parent = &lpImeParentMenuA; - if (lpImeMenu) - { - int count = dwSize / sizeof(LPIMEMENUITEMINFOW); - dwSize = count * sizeof(IMEMENUITEMINFOA); - lpImeMenuA = HeapAlloc(GetProcessHeap(), 0, dwSize); - } - else - lpImeMenuA = NULL; - - rc = data->immKbd->pImeGetImeMenuItems(hIMC, dwFlags, dwType, - (IMEMENUITEMINFOW*)parent, - (IMEMENUITEMINFOW*)lpImeMenuA, dwSize); - - if (lpImeParentMenu) - { - memcpy(lpImeParentMenu,&lpImeParentMenuA,sizeof(IMEMENUITEMINFOA)); - lpImeParentMenu->hbmpItem = lpImeParentMenuA.hbmpItem; - MultiByteToWideChar(CP_ACP, 0, lpImeParentMenuA.szString, - -1, lpImeParentMenu->szString, IMEMENUITEM_STRING_SIZE); - } - if (lpImeMenu && rc) - { - unsigned int i; - for (i = 0; i < rc; i++) - { - memcpy(&lpImeMenu[i],&lpImeMenuA[1],sizeof(IMEMENUITEMINFOA)); - lpImeMenu[i].hbmpItem = lpImeMenuA[i].hbmpItem; - MultiByteToWideChar(CP_ACP, 0, lpImeMenuA[i].szString, - -1, lpImeMenu[i].szString, IMEMENUITEM_STRING_SIZE); - } - } - HeapFree(GetProcessHeap(),0,lpImeMenuA); - return rc; - } - } - else - return 0; -} - BOOL WINAPI User32InitializeImmEntryTable(DWORD); BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpReserved) diff --git a/dll/win32/imm32/precomp.h b/dll/win32/imm32/precomp.h index 7bab3b95031..1bcc18bbb30 100644 --- a/dll/win32/imm32/precomp.h +++ b/dll/win32/imm32/precomp.h @@ -95,6 +95,8 @@ static inline BOOL Imm32IsCrossProcessAccess(HWND hWnd) (DWORD_PTR)NtCurrentTeb()->ClientId.UniqueProcess); } +BOOL WINAPI Imm32IsImcAnsi(HIMC hIMC); + #define ImeDpi_IsUnicode(pImeDpi) ((pImeDpi)->ImeInfo.fdwProperty & IME_PROP_UNICODE) #define Imm32IsImmMode() (g_psi && (g_psi->dwSRVIFlags & SRVINFO_IMM32)) #define Imm32IsCiceroMode() (g_psi && (g_psi->dwSRVIFlags & SRVINFO_CICERO_ENABLED)) @@ -112,3 +114,10 @@ Imm32NotifyAction(HIMC hIMC, HWND hwnd, DWORD dwAction, DWORD_PTR dwIndex, DWORD DWORD_PTR dwCommand, DWORD_PTR dwData); DWORD APIENTRY Imm32AllocAndBuildHimcList(DWORD dwThreadId, HIMC **pphList); + +INT APIENTRY +Imm32ImeMenuAnsiToWide(const IMEMENUITEMINFOA *pItemA, LPIMEMENUITEMINFOW pItemW, + UINT uCodePage, BOOL bBitmap); +INT APIENTRY +Imm32ImeMenuWideToAnsi(const IMEMENUITEMINFOW *pItemW, LPIMEMENUITEMINFOA pItemA, + UINT uCodePage); diff --git a/dll/win32/imm32/utils.c b/dll/win32/imm32/utils.c index 64bd3d158be..cda20efc884 100644 --- a/dll/win32/imm32/utils.c +++ b/dll/win32/imm32/utils.c @@ -16,6 +16,17 @@ WINE_DEFAULT_DEBUG_CHANNEL(imm); HANDLE g_hImm32Heap = NULL; +BOOL WINAPI Imm32IsImcAnsi(HIMC hIMC) +{ + BOOL ret; + PCLIENTIMC pClientImc = ImmLockClientImc(hIMC); + if (!pClientImc) + return -1; + ret = !(pClientImc->dwFlags & CLIENTIMC_WIDE); + ImmUnlockClientImc(pClientImc); + return ret; +} + LPWSTR APIENTRY Imm32WideFromAnsi(LPCSTR pszA) { INT cch = lstrlenA(pszA); @@ -202,6 +213,55 @@ DWORD APIENTRY Imm32AllocAndBuildHimcList(DWORD dwThreadId, HIMC **pphList) #undef MAX_RETRY } +INT APIENTRY +Imm32ImeMenuAnsiToWide(const IMEMENUITEMINFOA *pItemA, LPIMEMENUITEMINFOW pItemW, + UINT uCodePage, BOOL bBitmap) +{ + INT ret; + pItemW->cbSize = pItemA->cbSize; + pItemW->fType = pItemA->fType; + pItemW->fState = pItemA->fState; + pItemW->wID = pItemA->wID; + if (bBitmap) + { + pItemW->hbmpChecked = pItemA->hbmpChecked; + pItemW->hbmpUnchecked = pItemA->hbmpUnchecked; + pItemW->hbmpItem = pItemA->hbmpItem; + } + pItemW->dwItemData = pItemA->dwItemData; + ret = MultiByteToWideChar(uCodePage, 0, pItemA->szString, -1, + pItemW->szString, _countof(pItemW->szString)); + if (ret >= _countof(pItemW->szString)) + { + ret = 0; + pItemW->szString[0] = 0; + } + return ret; +} + +INT APIENTRY +Imm32ImeMenuWideToAnsi(const IMEMENUITEMINFOW *pItemW, LPIMEMENUITEMINFOA pItemA, + UINT uCodePage) +{ + INT ret; + pItemA->cbSize = pItemW->cbSize; + pItemA->fType = pItemW->fType; + pItemA->fState = pItemW->fState; + pItemA->wID = pItemW->wID; + pItemA->hbmpChecked = pItemW->hbmpChecked; + pItemA->hbmpUnchecked = pItemW->hbmpUnchecked; + pItemA->dwItemData = pItemW->dwItemData; + pItemA->hbmpItem = pItemW->hbmpItem; + ret = WideCharToMultiByte(uCodePage, 0, pItemW->szString, -1, + pItemA->szString, _countof(pItemA->szString), NULL, NULL); + if (ret >= _countof(pItemA->szString)) + { + ret = 0; + pItemA->szString[0] = 0; + } + return ret; +} + /*********************************************************************** * ImmCreateIMCC(IMM32.@) */ diff --git a/win32ss/include/imetable.h b/win32ss/include/imetable.h index 09580a4ac95..70bc982a6dc 100644 --- a/win32ss/include/imetable.h +++ b/win32ss/include/imetable.h @@ -1,4 +1,4 @@ -/* DEFINE_IME_ENTRY(type, name, params, extended) */ +/* DEFINE_IME_ENTRY(type, name, params, optional) */ DEFINE_IME_ENTRY(BOOL, ImeInquire, (LPIMEINFO lpIMEInfo, LPVOID lpszWndClass, DWORD dwSystemInfoFlags), FALSE) DEFINE_IME_ENTRY(DWORD, ImeConversionList, (HIMC hIMC, LPCVOID lpSrc, LPCANDIDATELIST lpDst, DWORD dwBufLen, UINT uFlag), FALSE) DEFINE_IME_ENTRY(BOOL, ImeRegisterWord, (LPCVOID lpszReading, DWORD dwStyle, LPCVOID lpszString), FALSE) @@ -14,7 +14,7 @@ DEFINE_IME_ENTRY(BOOL, ImeSetActiveContext, (HIMC hIMC, BOOL fFlag), FALSE) DEFINE_IME_ENTRY(UINT, ImeToAsciiEx, (UINT uVirKey, UINT uScanCode, CONST LPBYTE lpbKeyState, LPTRANSMSGLIST lpTransMsgList, UINT fuState, HIMC hIMC), FALSE) DEFINE_IME_ENTRY(BOOL, NotifyIME, (HIMC hIMC, DWORD dwAction, DWORD dwIndex, DWORD dwValue), FALSE) DEFINE_IME_ENTRY(BOOL, ImeSetCompositionString, (HIMC hIMC, DWORD dwIndex, LPCVOID lpComp, DWORD dwCompLen, LPCVOID lpRead, DWORD dwReadLen), FALSE) -DEFINE_IME_ENTRY(DWORD, ImeGetImeMenuItems, (HIMC hIMC, DWORD dwFlags, DWORD dwType, LPIMEMENUITEMINFOW lpImeParentMenu, LPIMEMENUITEMINFOW lpImeMenu, DWORD dwSize), FALSE) +DEFINE_IME_ENTRY(DWORD, ImeGetImeMenuItems, (HIMC hIMC, DWORD dwFlags, DWORD dwType, LPIMEMENUITEMINFOW lpImeParentMenu, LPIMEMENUITEMINFOW lpImeMenu, DWORD dwSize), TRUE) DEFINE_IME_ENTRY(BOOL, CtfImeInquireExW, (LPIMEINFO lpIMEInfo, LPVOID lpszWndClass, DWORD dwSystemInfoFlags, HKL hKL), TRUE) DEFINE_IME_ENTRY(BOOL, CtfImeSelectEx, (HIMC hIMC, BOOL fSelect, HKL hKL), TRUE) DEFINE_IME_ENTRY(LRESULT, CtfImeEscapeEx, (HIMC hIMC, UINT uSubFunc, LPVOID lpData, HKL hKL), TRUE)
3 years, 2 months
1
0
0
0
[reactos] 01/01: [IMM32] Rewrite ImmSetActiveContext (#3982)
by Katayama Hirofumi MZ
https://git.reactos.org/?p=reactos.git;a=commitdiff;h=9adc538c9c79ef735a75f…
commit 9adc538c9c79ef735a75f76f3c02d8830fcd3cd7 Author: Katayama Hirofumi MZ <katayama.hirofumi.mz(a)gmail.com> AuthorDate: Fri Oct 1 03:02:56 2021 +0900 Commit: GitHub <noreply(a)github.com> CommitDate: Fri Oct 1 03:02:56 2021 +0900 [IMM32] Rewrite ImmSetActiveContext (#3982) - Re-implement ImmSetActiveContext function. - Modify NtUserNotifyIMEStatus prototype. - Improve ImmSetConversionStatus and ImmSetOpenStatus functions. CORE-11700 --- dll/win32/imm32/ime.c | 7 ++-- dll/win32/imm32/imm.c | 97 +++++++++++++++++++++++++++++++++++++++++++++-- win32ss/include/ntuser.h | 7 ++-- win32ss/user/ntuser/ime.c | 8 +--- 4 files changed, 103 insertions(+), 16 deletions(-) diff --git a/dll/win32/imm32/ime.c b/dll/win32/imm32/ime.c index 3eeb7169b22..b1b31ce9eeb 100644 --- a/dll/win32/imm32/ime.c +++ b/dll/win32/imm32/ime.c @@ -911,7 +911,7 @@ BOOL WINAPI ImmSetOpenStatus(HIMC hIMC, BOOL fOpen) { Imm32NotifyAction(hIMC, hWnd, NI_CONTEXTUPDATED, 0, IMC_SETOPENSTATUS, IMN_SETOPENSTATUS, 0); - NtUserNotifyIMEStatus(hWnd, hIMC, dwConversion); + NtUserNotifyIMEStatus(hWnd, fOpen, dwConversion); } return TRUE; @@ -1346,7 +1346,7 @@ BOOL WINAPI ImmSetConversionStatus(HIMC hIMC, DWORD fdwConversion, DWORD fdwSent HKL hKL; LPINPUTCONTEXT pIC; DWORD dwOldConversion, dwOldSentence; - BOOL fConversionChange = FALSE, fSentenceChange = FALSE, fUseCicero = FALSE; + BOOL fOpen = FALSE, fConversionChange = FALSE, fSentenceChange = FALSE, fUseCicero = FALSE; HWND hWnd; TRACE("(%p, 0x%lX, 0x%lX)\n", hIMC, fdwConversion, fdwSentence); @@ -1377,6 +1377,7 @@ BOOL WINAPI ImmSetConversionStatus(HIMC hIMC, DWORD fdwConversion, DWORD fdwSent } hWnd = pIC->hWnd; + fOpen = pIC->fOpen; ImmUnlockIMC(hIMC); if (fConversionChange || fUseCicero) @@ -1384,7 +1385,7 @@ BOOL WINAPI ImmSetConversionStatus(HIMC hIMC, DWORD fdwConversion, DWORD fdwSent Imm32NotifyAction(hIMC, hWnd, NI_CONTEXTUPDATED, dwOldConversion, IMC_SETCONVERSIONMODE, IMN_SETCONVERSIONMODE, 0); if (fConversionChange) - NtUserNotifyIMEStatus(hWnd, hIMC, fdwConversion); + NtUserNotifyIMEStatus(hWnd, fOpen, fdwConversion); } if (fSentenceChange || fUseCicero) diff --git a/dll/win32/imm32/imm.c b/dll/win32/imm32/imm.c index ab97e052c9a..07eb129bffc 100644 --- a/dll/win32/imm32/imm.c +++ b/dll/win32/imm32/imm.c @@ -169,6 +169,11 @@ static InputContextData* get_imc_data(HIMC hIMC) return data; } +static VOID APIENTRY Imm32CiceroSetActiveContext(HIMC hIMC, BOOL fActive, HWND hWnd, HKL hKL) +{ + FIXME("We have to do something\n"); +} + /*********************************************************************** * ImmAssociateContext (IMM32.@) */ @@ -1314,10 +1319,96 @@ BOOL WINAPI ImmEnumInputContext(DWORD dwThreadId, IMCENUMPROC lpfn, LPARAM lPara /*********************************************************************** * ImmSetActiveContext(IMM32.@) */ -BOOL WINAPI ImmSetActiveContext(HWND hwnd, HIMC hIMC, BOOL fFlag) +BOOL WINAPI ImmSetActiveContext(HWND hWnd, HIMC hIMC, BOOL fActive) { - FIXME("(%p, %p, %d): stub\n", hwnd, hIMC, fFlag); - return FALSE; + PCLIENTIMC pClientImc; + LPINPUTCONTEXTDX pIC; + PIMEDPI pImeDpi; + HKL hKL; + BOOL fOpen = FALSE; + DWORD dwConversion = 0, iShow = ISC_SHOWUIALL; + HWND hwndDefIME; + + TRACE("(%p, %p, %d)\n", hWnd, hIMC, fActive); + + if (!Imm32IsImmMode()) + return FALSE; + + pClientImc = ImmLockClientImc(hIMC); + + if (!fActive) + { + if (pClientImc) + pClientImc->dwFlags &= ~CLIENTIMC_UNKNOWN4; + } + else if (hIMC) + { + if (!pClientImc) + return FALSE; + + pIC = (LPINPUTCONTEXTDX)ImmLockIMC(hIMC); + if (!pIC) + { + ImmUnlockClientImc(pClientImc); + return FALSE; + } + + pIC->hWnd = hWnd; + pClientImc->dwFlags |= CLIENTIMC_UNKNOWN5; + + if (pIC->dwUIFlags & 2) + iShow = (ISC_SHOWUIGUIDELINE | ISC_SHOWUIALLCANDIDATEWINDOW); + + fOpen = pIC->fOpen; + dwConversion = pIC->fdwConversion; + + ImmUnlockIMC(hIMC); + } + else + { + hIMC = Imm32GetContextEx(hWnd, TRUE); + pIC = (LPINPUTCONTEXTDX)ImmLockIMC(hIMC); + if (pIC) + { + pIC->hWnd = hWnd; + ImmUnlockIMC(hIMC); + } + hIMC = NULL; + } + + hKL = GetKeyboardLayout(0); + + if (Imm32IsCiceroMode() && !Imm32Is16BitMode()) + { + Imm32CiceroSetActiveContext(hIMC, fActive, hWnd, hKL); + hKL = GetKeyboardLayout(0); + } + + pImeDpi = ImmLockImeDpi(hKL); + if (pImeDpi) + { + if (IS_IME_HKL(hKL)) + pImeDpi->ImeSetActiveContext(hIMC, fActive); + ImmUnlockImeDpi(pImeDpi); + } + + if (IsWindow(hWnd)) + { + SendMessageW(hWnd, WM_IME_SETCONTEXT, fActive, iShow); + if (fActive) + NtUserNotifyIMEStatus(hWnd, fOpen, dwConversion); + } + else if (!fActive) + { + hwndDefIME = ImmGetDefaultIMEWnd(NULL); + if (hwndDefIME) + SendMessageW(hwndDefIME, WM_IME_SETCONTEXT, 0, iShow); + } + + if (pClientImc) + ImmUnlockClientImc(pClientImc); + + return TRUE; } /*********************************************************************** diff --git a/win32ss/include/ntuser.h b/win32ss/include/ntuser.h index 7afe6906fba..a6a45af167b 100644 --- a/win32ss/include/ntuser.h +++ b/win32ss/include/ntuser.h @@ -1312,6 +1312,8 @@ C_ASSERT(sizeof(CLIENTIMC) == 0x34); /* flags for CLIENTIMC */ #define CLIENTIMC_WIDE 0x1 +#define CLIENTIMC_UNKNOWN5 0x2 +#define CLIENTIMC_UNKNOWN4 0x20 #define CLIENTIMC_UNKNOWN1 0x40 #define CLIENTIMC_UNKNOWN3 0x80 #define CLIENTIMC_UNKNOWN2 0x100 @@ -2769,10 +2771,7 @@ NtUserMoveWindow( DWORD NTAPI -NtUserNotifyIMEStatus( - HWND hwnd, - HIMC hIMC, - DWORD dwConversion); +NtUserNotifyIMEStatus(HWND hwnd, BOOL fOpen, DWORD dwConversion); BOOL NTAPI diff --git a/win32ss/user/ntuser/ime.c b/win32ss/user/ntuser/ime.c index 031dc09ec64..1d84609186c 100644 --- a/win32ss/user/ntuser/ime.c +++ b/win32ss/user/ntuser/ime.c @@ -49,16 +49,12 @@ NtUserGetImeHotKey(IN DWORD dwHotKey, DWORD APIENTRY -NtUserNotifyIMEStatus( - HWND hwnd, - HIMC hIMC, - DWORD dwConversion) +NtUserNotifyIMEStatus(HWND hwnd, BOOL fOpen, DWORD dwConversion) { - TRACE("NtUserNotifyIMEStatus(%p, %p, 0x%lX)\n", hwnd, hIMC, dwConversion); + TRACE("NtUserNotifyIMEStatus(%p, %d, 0x%lX)\n", hwnd, fOpen, dwConversion); return 0; } - DWORD APIENTRY NtUserSetImeHotKey(
3 years, 2 months
1
0
0
0
[reactos] 01/01: Revert "Disable some C++ code, which doesn't compile for me"
by Hervé Poussineau
https://git.reactos.org/?p=reactos.git;a=commitdiff;h=fc5d8e466febafa906110…
commit fc5d8e466febafa906110b5cb027bba591bda177 Author: Hervé Poussineau <hpoussin(a)reactos.org> AuthorDate: Wed Sep 29 22:58:31 2021 +0200 Commit: Hervé Poussineau <hpoussin(a)reactos.org> CommitDate: Wed Sep 29 22:58:31 2021 +0200 Revert "Disable some C++ code, which doesn't compile for me" This reverts commit d8b1ff9056d869d512da88b9c9cc9301535f5a06. --- base/applications/CMakeLists.txt | 2 +- base/applications/network/CMakeLists.txt | 2 +- dll/shellext/CMakeLists.txt | 2 +- dll/win32/CMakeLists.txt | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/base/applications/CMakeLists.txt b/base/applications/CMakeLists.txt index 0212378100e..7c18212ed4f 100644 --- a/base/applications/CMakeLists.txt +++ b/base/applications/CMakeLists.txt @@ -6,7 +6,7 @@ add_subdirectory(charmap) add_subdirectory(clipbrd) add_subdirectory(cmdutils) add_subdirectory(control) -#add_subdirectory(drwtsn32) +add_subdirectory(drwtsn32) add_subdirectory(dxdiag) add_subdirectory(extrac32) add_subdirectory(findstr) diff --git a/base/applications/network/CMakeLists.txt b/base/applications/network/CMakeLists.txt index eca45a3e316..46246108408 100644 --- a/base/applications/network/CMakeLists.txt +++ b/base/applications/network/CMakeLists.txt @@ -11,7 +11,7 @@ add_subdirectory(nslookup) add_subdirectory(ping) add_subdirectory(route) if(NOT USE_CLANG_CL) - #add_subdirectory(telnet) + add_subdirectory(telnet) endif() add_subdirectory(tracert) add_subdirectory(whois) diff --git a/dll/shellext/CMakeLists.txt b/dll/shellext/CMakeLists.txt index 6eb0717474d..8d005319c4c 100644 --- a/dll/shellext/CMakeLists.txt +++ b/dll/shellext/CMakeLists.txt @@ -10,6 +10,6 @@ add_subdirectory(netplwiz) add_subdirectory(netshell) add_subdirectory(ntobjshex) add_subdirectory(sendmail) -#add_subdirectory(shellbtrfs) +add_subdirectory(shellbtrfs) add_subdirectory(stobject) add_subdirectory(zipfldr) diff --git a/dll/win32/CMakeLists.txt b/dll/win32/CMakeLists.txt index 555172cdcd0..c0238ebeea5 100644 --- a/dll/win32/CMakeLists.txt +++ b/dll/win32/CMakeLists.txt @@ -56,7 +56,7 @@ add_subdirectory(httpapi) add_subdirectory(iccvid) add_subdirectory(icmp) add_subdirectory(ieframe) -#add_subdirectory(iernonce) +add_subdirectory(iernonce) add_subdirectory(imaadp32.acm) add_subdirectory(imagehlp) add_subdirectory(imm32)
3 years, 2 months
1
0
0
0
[reactos] 02/02: Disable some C++ code, which doesn't compile for me
by Hervé Poussineau
https://git.reactos.org/?p=reactos.git;a=commitdiff;h=d8b1ff9056d869d512da8…
commit d8b1ff9056d869d512da88b9c9cc9301535f5a06 Author: Hervé Poussineau <hpoussin(a)reactos.org> AuthorDate: Wed Jun 3 21:46:52 2020 +0200 Commit: Hervé Poussineau <hpoussin(a)reactos.org> CommitDate: Wed Sep 29 22:56:35 2021 +0200 Disable some C++ code, which doesn't compile for me --- base/applications/CMakeLists.txt | 2 +- base/applications/network/CMakeLists.txt | 2 +- dll/shellext/CMakeLists.txt | 2 +- dll/win32/CMakeLists.txt | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/base/applications/CMakeLists.txt b/base/applications/CMakeLists.txt index 7c18212ed4f..0212378100e 100644 --- a/base/applications/CMakeLists.txt +++ b/base/applications/CMakeLists.txt @@ -6,7 +6,7 @@ add_subdirectory(charmap) add_subdirectory(clipbrd) add_subdirectory(cmdutils) add_subdirectory(control) -add_subdirectory(drwtsn32) +#add_subdirectory(drwtsn32) add_subdirectory(dxdiag) add_subdirectory(extrac32) add_subdirectory(findstr) diff --git a/base/applications/network/CMakeLists.txt b/base/applications/network/CMakeLists.txt index 46246108408..eca45a3e316 100644 --- a/base/applications/network/CMakeLists.txt +++ b/base/applications/network/CMakeLists.txt @@ -11,7 +11,7 @@ add_subdirectory(nslookup) add_subdirectory(ping) add_subdirectory(route) if(NOT USE_CLANG_CL) - add_subdirectory(telnet) + #add_subdirectory(telnet) endif() add_subdirectory(tracert) add_subdirectory(whois) diff --git a/dll/shellext/CMakeLists.txt b/dll/shellext/CMakeLists.txt index 8d005319c4c..6eb0717474d 100644 --- a/dll/shellext/CMakeLists.txt +++ b/dll/shellext/CMakeLists.txt @@ -10,6 +10,6 @@ add_subdirectory(netplwiz) add_subdirectory(netshell) add_subdirectory(ntobjshex) add_subdirectory(sendmail) -add_subdirectory(shellbtrfs) +#add_subdirectory(shellbtrfs) add_subdirectory(stobject) add_subdirectory(zipfldr) diff --git a/dll/win32/CMakeLists.txt b/dll/win32/CMakeLists.txt index c0238ebeea5..555172cdcd0 100644 --- a/dll/win32/CMakeLists.txt +++ b/dll/win32/CMakeLists.txt @@ -56,7 +56,7 @@ add_subdirectory(httpapi) add_subdirectory(iccvid) add_subdirectory(icmp) add_subdirectory(ieframe) -add_subdirectory(iernonce) +#add_subdirectory(iernonce) add_subdirectory(imaadp32.acm) add_subdirectory(imagehlp) add_subdirectory(imm32)
3 years, 2 months
1
0
0
0
[reactos] 01/02: [VIDEOPRT] Create and setup new registry key only for non-legacy drivers
by Hervé Poussineau
https://git.reactos.org/?p=reactos.git;a=commitdiff;h=92d0dd363346e7106a44a…
commit 92d0dd363346e7106a44a52fd96a5c263e2fc495 Author: Hervé Poussineau <hpoussin(a)reactos.org> AuthorDate: Wed Aug 18 19:27:33 2021 +0200 Commit: Hervé Poussineau <hpoussin(a)reactos.org> CommitDate: Wed Sep 29 22:56:35 2021 +0200 [VIDEOPRT] Create and setup new registry key only for non-legacy drivers CORE-17734 --- win32ss/drivers/videoprt/registry.c | 59 +++++++++++++++++++++++++++++++++++++ 1 file changed, 59 insertions(+) diff --git a/win32ss/drivers/videoprt/registry.c b/win32ss/drivers/videoprt/registry.c index 5a0f96c719f..4fed31e451d 100644 --- a/win32ss/drivers/videoprt/registry.c +++ b/win32ss/drivers/videoprt/registry.c @@ -302,6 +302,9 @@ IntSetupDeviceSettingsKey( OBJECT_ATTRIBUTES ObjectAttributes; NTSTATUS Status; + if (!DeviceExtension->PhysicalDeviceObject) + return STATUS_SUCCESS; + /* Open the software key: HKLM\System\CurrentControlSet\Control\Class\<ClassGUID>\<n> */ Status = IoOpenDeviceRegistryKey(DeviceExtension->PhysicalDeviceObject, PLUGPLAY_REGKEY_DRIVER, @@ -353,6 +356,52 @@ IntSetupDeviceSettingsKey( return STATUS_SUCCESS; } +NTSTATUS +IntDuplicateUnicodeString( + IN ULONG Flags, + IN PCUNICODE_STRING SourceString, + OUT PUNICODE_STRING DestinationString) +{ + if (SourceString == NULL || + DestinationString == NULL || + SourceString->Length > SourceString->MaximumLength || + (SourceString->Length == 0 && SourceString->MaximumLength > 0 && SourceString->Buffer == NULL) || + Flags == RTL_DUPLICATE_UNICODE_STRING_ALLOCATE_NULL_STRING || + Flags >= 4) + { + return STATUS_INVALID_PARAMETER; + } + + if ((SourceString->Length == 0) && + (Flags != (RTL_DUPLICATE_UNICODE_STRING_NULL_TERMINATE | + RTL_DUPLICATE_UNICODE_STRING_ALLOCATE_NULL_STRING))) + { + DestinationString->Length = 0; + DestinationString->MaximumLength = 0; + DestinationString->Buffer = NULL; + } + else + { + USHORT DestMaxLength = SourceString->Length; + + if (Flags & RTL_DUPLICATE_UNICODE_STRING_NULL_TERMINATE) + DestMaxLength += sizeof(UNICODE_NULL); + + DestinationString->Buffer = ExAllocatePoolWithTag(PagedPool, DestMaxLength, TAG_VIDEO_PORT); + if (DestinationString->Buffer == NULL) + return STATUS_NO_MEMORY; + + RtlCopyMemory(DestinationString->Buffer, SourceString->Buffer, SourceString->Length); + DestinationString->Length = SourceString->Length; + DestinationString->MaximumLength = DestMaxLength; + + if (Flags & RTL_DUPLICATE_UNICODE_STRING_NULL_TERMINATE) + DestinationString->Buffer[DestinationString->Length / sizeof(WCHAR)] = 0; + } + + return STATUS_SUCCESS; +} + NTSTATUS NTAPI IntCreateNewRegistryPath( @@ -372,6 +421,16 @@ IntCreateNewRegistryPath( OBJECT_ATTRIBUTES ObjectAttributes; PWCHAR InstanceIdBuffer; + if (!DeviceExtension->PhysicalDeviceObject) + { + Status = IntDuplicateUnicodeString(RTL_DUPLICATE_UNICODE_STRING_NULL_TERMINATE, + &DeviceExtension->RegistryPath, + &DeviceExtension->NewRegistryPath); + if (!NT_SUCCESS(Status)) + ERR_(VIDEOPRT, "IntDuplicateUnicodeString() failed with status 0x%lx\n", Status); + return Status; + } + /* Open the hardware key: HKLM\System\CurrentControlSet\Enum\... */ Status = IoOpenDeviceRegistryKey(DeviceExtension->PhysicalDeviceObject, PLUGPLAY_REGKEY_DEVICE,
3 years, 2 months
1
0
0
0
[reactos] 01/01: [IERNONCE] [RUNONCEEX] Add RunOnceEx functionality for ReactOS (#3926)
by He Yang
https://git.reactos.org/?p=reactos.git;a=commitdiff;h=4d0cc20681dff4b15e7b1…
commit 4d0cc20681dff4b15e7b1c950a35952af67346d9 Author: He Yang <1160386205(a)qq.com> AuthorDate: Wed Sep 29 17:30:32 2021 +0800 Commit: GitHub <noreply(a)github.com> CommitDate: Wed Sep 29 11:30:32 2021 +0200 [IERNONCE] [RUNONCEEX] Add RunOnceEx functionality for ReactOS (#3926) * [IERNONCE] Implement the registry management code. * [EXPLORER] handle RunOnceEx by invoking RunOnceEx in iernonce.dll * [IERNONCE] Display a dialog to show progress, and execute entries. * [IERNONCE] Add `InitCallback` function --- base/shell/explorer/startup.cpp | 71 ++++++- dll/win32/iernonce/CMakeLists.txt | 16 +- dll/win32/iernonce/dialog.cpp | 237 ++++++++++++++++++++++ dll/win32/iernonce/dialog.h | 46 +++++ dll/win32/iernonce/iernonce.c | 40 ---- dll/win32/iernonce/iernonce.cpp | 61 ++++++ dll/win32/iernonce/iernonce.h | 24 +++ dll/win32/iernonce/iernonce.spec | 3 +- dll/win32/iernonce/include/registry.h | 107 ++++++++++ dll/win32/iernonce/registry.cpp | 360 ++++++++++++++++++++++++++++++++++ sdk/include/reactos/iernonce_undoc.h | 30 +++ 11 files changed, 949 insertions(+), 46 deletions(-) diff --git a/base/shell/explorer/startup.cpp b/base/shell/explorer/startup.cpp index 9e6f60705c6..e76a9cd6e35 100644 --- a/base/shell/explorer/startup.cpp +++ b/base/shell/explorer/startup.cpp @@ -3,6 +3,7 @@ * Copyright (C) 2002 Shachar Shemesh * Copyright (C) 2013 Edijs Kolesnikovics * Copyright (C) 2018 Katayama Hirofumi MZ + * Copyright (C) 2021 He Yang * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public @@ -28,7 +29,7 @@ * The operations performed are (by order of execution): * * After log in - * - HKEY_LOCAL_MACHINE\Software\Microsoft\Windows\CurrentVersion\RunOnceEx (synch, no imp) + * - HKEY_LOCAL_MACHINE\Software\Microsoft\Windows\CurrentVersion\RunOnceEx (synch) * - HKEY_LOCAL_MACHINE\Software\Microsoft\Windows\CurrentVersion\RunOnce (synch) * - HKEY_LOCAL_MACHINE\Software\Microsoft\Windows\CurrentVersion\Run (asynch) * - HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Run (asynch) @@ -36,7 +37,7 @@ * - Current user Startup folder "%USERPROFILE%\Start Menu\Programs\Startup" (asynch, no imp) * - HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\RunOnce (asynch) * - * None is processed in Safe Mode // FIXME: Check RunOnceEx in Safe Mode + * None is processed in Safe Mode */ #include "precomp.h" @@ -317,6 +318,68 @@ end: return res == ERROR_SUCCESS ? TRUE : FALSE; } +/** + * Process "RunOnceEx" type registry key. + * rundll32.exe will be invoked if the corresponding key has items inside, and wait for it. + * hkRoot is the HKEY from which + * "Software\Microsoft\Windows\CurrentVersion\RunOnceEx" + * is opened. + */ +static BOOL ProcessRunOnceEx(HKEY hkRoot) +{ + HKEY hkRunOnceEx = NULL; + LONG res = ERROR_SUCCESS; + WCHAR cmdLine[] = L"rundll32 iernonce.dll RunOnceExProcess"; + DWORD dwSubKeyCnt; + + res = RegOpenKeyExW(hkRoot, + L"Software\\Microsoft\\Windows\\CurrentVersion\\RunOnceEx", + 0, + KEY_READ, + &hkRunOnceEx); + if (res != ERROR_SUCCESS) + { + TRACE("RegOpenKeyW failed on Software\\Microsoft\\Windows\\CurrentVersion\\RunOnceEx (%ld)\n", res); + goto end; + } + + res = RegQueryInfoKeyW(hkRunOnceEx, + NULL, + NULL, + NULL, + &dwSubKeyCnt, + NULL, + NULL, + NULL, + NULL, + NULL, + NULL, + NULL); + + if (res != ERROR_SUCCESS) + { + TRACE("RegQueryInfoKeyW failed on Software\\Microsoft\\Windows\\CurrentVersion\\RunOnceEx (%ld)\n", res); + goto end; + } + + if (dwSubKeyCnt != 0) + { + if (runCmd(cmdLine, NULL, TRUE, TRUE) == INVALID_RUNCMD_RETURN) + { + TRACE("runCmd failed (%ld)\n", res = GetLastError()); + goto end; + } + } + +end: + if (hkRunOnceEx != NULL) + RegCloseKey(hkRunOnceEx); + + TRACE("done\n"); + + return res == ERROR_SUCCESS ? TRUE : FALSE; +} + static BOOL AutoStartupApplications(INT nCSIDL_Folder) { @@ -414,7 +477,9 @@ INT ProcessStartupItems(VOID) * stopping if one fails, skipping if necessary. */ res = TRUE; - /* TODO: RunOnceEx */ + + if (res && bNormalBoot) + ProcessRunOnceEx(HKEY_LOCAL_MACHINE); if (res && (SHRestricted(REST_NOLOCALMACHINERUNONCE) == 0)) res = ProcessRunKeys(HKEY_LOCAL_MACHINE, L"RunOnce", TRUE, TRUE); diff --git a/dll/win32/iernonce/CMakeLists.txt b/dll/win32/iernonce/CMakeLists.txt index 85b73cdf6e8..78d7143c049 100644 --- a/dll/win32/iernonce/CMakeLists.txt +++ b/dll/win32/iernonce/CMakeLists.txt @@ -1,11 +1,23 @@ +project(iernonce) + +include_directories(include) spec2def(iernonce.dll iernonce.spec) +list(APPEND SOURCE + dialog.cpp + iernonce.cpp + registry.cpp + iernonce.h) + add_library(iernonce MODULE - iernonce.c + ${SOURCE} iernonce.rc ${CMAKE_CURRENT_BINARY_DIR}/iernonce.def) set_module_type(iernonce win32dll UNICODE) -add_importlibs(iernonce msvcrt kernel32 ntdll) +target_link_libraries(iernonce cppstl atl_classes) +set_target_cpp_properties(iernonce WITH_EXCEPTIONS) +add_importlibs(iernonce advapi32 msvcrt gdi32 ole32 shell32 shlwapi kernel32 user32 ntdll) +add_pch(iernonce iernonce.h SOURCE) add_cd_file(TARGET iernonce DESTINATION reactos/system32 FOR all) diff --git a/dll/win32/iernonce/dialog.cpp b/dll/win32/iernonce/dialog.cpp new file mode 100644 index 00000000000..1f3756a2745 --- /dev/null +++ b/dll/win32/iernonce/dialog.cpp @@ -0,0 +1,237 @@ +/* + * PROJECT: ReactOS system libraries + * LICENSE: GPL-2.0-or-later (
https://spdx.org/licenses/GPL-2.0-or-later
) + * PURPOSE: Classes for displaying progress dialog. + * COPYRIGHT: Copyright 2021 He Yang <1160386205(a)qq.com> + */ + +#include "iernonce.h" +#include <process.h> + +#define ITEM_VPADDING 3 +#define ITEM_LEFTPADDING 22 + +HFONT CreateBoldFont(_In_ HFONT hOrigFont) +{ + LOGFONTW fontAttributes = { 0 }; + GetObjectW(hOrigFont, sizeof(fontAttributes), &fontAttributes); + fontAttributes.lfWeight = FW_BOLD; + + return CreateFontIndirectW(&fontAttributes); +} + +ProgressDlg::ProgressDlg(_In_ RunOnceExInstance &RunOnceExInst) : + m_hListBox(NULL), + m_hBoldFont(NULL), + m_PointedItem(0), + m_RunOnceExInst(RunOnceExInst) +{ ; } + +BOOL ProgressDlg::RunDialogBox() +{ + // Show the dialog and run the items only when the list is not empty. + if (m_RunOnceExInst.m_SectionList.GetSize() != 0) + { + return (DoModal() == 1); + } + return TRUE; +} + +void ProgressDlg::CalcTextRect( + _In_ LPCWSTR lpText, + _Inout_ PRECT pRect) +{ + HDC hdc = ::GetDC(m_hListBox); + ::GetClientRect(m_hListBox, pRect); + + pRect->bottom = pRect->top; + pRect->left += ITEM_LEFTPADDING; + + HFONT OldFont = SelectFont(hdc, GetFont()); + DrawTextW(hdc, lpText, -1, pRect, DT_CALCRECT | DT_WORDBREAK); + SelectFont(hdc, OldFont); + ::ReleaseDC(m_hListBox, hdc); + + pRect->bottom -= pRect->top; + pRect->bottom += ITEM_VPADDING * 2; + pRect->top = 0; + pRect->right -= pRect->left; + pRect->left = 0; +} + +void ProgressDlg::ResizeListBoxAndDialog(_In_ int NewHeight) +{ + RECT ListBoxRect; + RECT DlgRect; + ::GetWindowRect(m_hListBox, &ListBoxRect); + GetWindowRect(&DlgRect); + + int HeightDiff = NewHeight - (ListBoxRect.bottom - ListBoxRect.top); + + ::SetWindowPos(m_hListBox, NULL, 0, 0, + ListBoxRect.right - ListBoxRect.left, NewHeight, + SWP_NOMOVE | SWP_NOZORDER | SWP_SHOWWINDOW); + + SetWindowPos(HWND_TOP, 0, 0, + DlgRect.right - DlgRect.left, + DlgRect.bottom - DlgRect.top + HeightDiff, + SWP_NOMOVE | SWP_NOZORDER | SWP_SHOWWINDOW); +} + +unsigned int __stdcall +RunOnceExExecThread(_In_ void *Param) +{ + ProgressDlg *pProgressDlg = (ProgressDlg *)Param; + + pProgressDlg->m_RunOnceExInst.Exec(pProgressDlg->m_hWnd); + return 0; +} + +BOOL +ProgressDlg::ProcessWindowMessage( + _In_ HWND hwnd, + _In_ UINT message, + _In_ WPARAM wParam, + _In_ LPARAM lParam, + _Out_ LRESULT& lResult, + _In_ DWORD dwMsgMapID) +{ + lResult = 0; + switch (message) + { + case WM_INITDIALOG: + { + if (!m_RunOnceExInst.m_Title.IsEmpty()) + { + SetWindowTextW(m_RunOnceExInst.m_Title); + } + + m_hListBox = GetDlgItem(IDC_LB_ITEMS); + + m_hBoldFont = CreateBoldFont(GetFont()); + + m_hArrowBmp = LoadBitmapW(NULL, MAKEINTRESOURCE(OBM_MNARROW)); + GetObjectW(m_hArrowBmp, sizeof(BITMAP), &m_ArrowBmp); + + // Add all sections with non-empty title into listbox + int TotalHeight = 0; + for (int i = 0; i < m_RunOnceExInst.m_SectionList.GetSize(); i++) + { + RunOnceExSection &Section = m_RunOnceExInst.m_SectionList[i]; + + if (!Section.m_SectionTitle.IsEmpty()) + { + INT Index = ListBox_AddString(m_hListBox, Section.m_SectionTitle); + TotalHeight += ListBox_GetItemHeight(m_hListBox, Index); + ListBox_SetItemData(m_hListBox, Index, i); + } + } + + // Remove the sunken-edged border from the listbox. + ::SetWindowLongPtr(m_hListBox, GWL_EXSTYLE, ::GetWindowLongPtr(m_hListBox, GWL_EXSTYLE) & ~WS_EX_CLIENTEDGE); + + ResizeListBoxAndDialog(TotalHeight); + + // Launch a thread to execute tasks. + HANDLE hThread = (HANDLE)_beginthreadex(NULL, 0, RunOnceExExecThread, (void *)this, 0, NULL); + if (hThread == INVALID_HANDLE_VALUE) + { + EndDialog(0); + return TRUE; + } + CloseHandle(hThread); + + lResult = TRUE; // set keyboard focus to the dialog box control. + break; + } + + case WM_MEASUREITEM: + { + PMEASUREITEMSTRUCT pMeasureItem = (PMEASUREITEMSTRUCT)lParam; + RECT TextRect = { 0 }; + + CStringW ItemText; + ListBox_GetText(m_hListBox, pMeasureItem->itemID, + ItemText.GetBuffer(ListBox_GetTextLen(m_hListBox, + pMeasureItem->itemID) + 1)); + + CalcTextRect(ItemText, &TextRect); + + ItemText.ReleaseBuffer(); + + pMeasureItem->itemHeight = TextRect.bottom - TextRect.top; + pMeasureItem->itemWidth = TextRect.right - TextRect.left; + + break; + } + + case WM_DRAWITEM: + { + LPDRAWITEMSTRUCT pDrawItem = (PDRAWITEMSTRUCT)lParam; + CStringW ItemText; + + ListBox_GetText(m_hListBox, pDrawItem->itemID, + ItemText.GetBuffer(ListBox_GetTextLen(m_hListBox, + pDrawItem->itemID) + 1)); + + SetBkMode(pDrawItem->hDC, TRANSPARENT); + + HFONT hOldFont = NULL; + if (m_PointedItem == (INT)pDrawItem->itemData) + { + HDC hCompDC = CreateCompatibleDC(pDrawItem->hDC); + + SelectBitmap(hCompDC, m_hArrowBmp); + + int IconLeftPadding = (ITEM_LEFTPADDING - m_ArrowBmp.bmWidth) / 2; + int IconTopPadding = (pDrawItem->rcItem.bottom - pDrawItem->rcItem.top - m_ArrowBmp.bmHeight) / 2; + + BitBlt(pDrawItem->hDC, IconLeftPadding, pDrawItem->rcItem.top + IconTopPadding, + m_ArrowBmp.bmWidth, m_ArrowBmp.bmHeight, hCompDC, 0, 0, SRCAND); + + DeleteDC(hCompDC); + + hOldFont = SelectFont(pDrawItem->hDC, m_hBoldFont); + } + + pDrawItem->rcItem.left += ITEM_LEFTPADDING; + pDrawItem->rcItem.top += ITEM_VPADDING; + DrawTextW(pDrawItem->hDC, ItemText, -1, + &(pDrawItem->rcItem), DT_WORDBREAK); + + if (hOldFont) + { + SelectFont(pDrawItem->hDC, hOldFont); + } + ItemText.ReleaseBuffer(); + + break; + } + + case WM_SETINDEX: + { + if ((int)wParam == m_RunOnceExInst.m_SectionList.GetSize()) + { + // All sections are handled, lParam is bSuccess. + EndDialog(lParam); + } + m_PointedItem = wParam; + InvalidateRect(NULL); + break; + } + + case WM_CTLCOLORLISTBOX: + { + lResult = (LRESULT)GetStockBrush(NULL_BRUSH); + break; + } + + case WM_DESTROY: + { + DeleteObject(m_hArrowBmp); + DeleteFont(m_hBoldFont); + break; + } + } + return TRUE; +} diff --git a/dll/win32/iernonce/dialog.h b/dll/win32/iernonce/dialog.h new file mode 100644 index 00000000000..e459c9b09bd --- /dev/null +++ b/dll/win32/iernonce/dialog.h @@ -0,0 +1,46 @@ +/* + * PROJECT: ReactOS system libraries + * LICENSE: GPL-2.0-or-later (
https://spdx.org/licenses/GPL-2.0-or-later
) + * PURPOSE: Classes for displaying progress dialog. + * COPYRIGHT: Copyright 2021 He Yang <1160386205(a)qq.com> + */ + +#pragma once + +#include <atlbase.h> +#include <atlwin.h> + +#include "resource.h" +#include "registry.h" + +// When wParam < item count ==> wParam is item index (0 based) +// wParam = item count ==> all finished, lParam = bSuccess +#define WM_SETINDEX (WM_USER + 1) + +class ProgressDlg : public CDialogImpl<ProgressDlg> +{ +private: + INT_PTR m_DialogID; + HWND m_hListBox; + HFONT m_hBoldFont; + HBITMAP m_hArrowBmp; + BITMAP m_ArrowBmp; + INT m_PointedItem; + +public: + enum { IDD = IDD_DIALOG }; + + RunOnceExInstance &m_RunOnceExInst; + + ProgressDlg(_In_ RunOnceExInstance &RunOnceExInst); + + BOOL RunDialogBox(); + + void CalcTextRect(_In_ LPCWSTR lpText, _Inout_ RECT *pRect); + + void ResizeListBoxAndDialog(_In_ int NewHeight); + + BOOL ProcessWindowMessage(_In_ HWND hwnd, _In_ UINT message, _In_ WPARAM wParam, + _In_ LPARAM lParam, _Out_ LRESULT& lResult, + _In_ DWORD dwMsgMapID); +}; diff --git a/dll/win32/iernonce/iernonce.c b/dll/win32/iernonce/iernonce.c deleted file mode 100644 index c5314c3f7c7..00000000000 --- a/dll/win32/iernonce/iernonce.c +++ /dev/null @@ -1,40 +0,0 @@ -/* - * PROJECT: ReactOS system libraries - * LICENSE: GPL - See COPYING in the top level directory - * FILE: dll\win32\iernonce\iernonce.c - * PURPOSE: ReactOS Extended RunOnce processing with UI - * PROGRAMMERS: Copyright 2013-2016 Robert Naumann - */ - - -#define WIN32_NO_STATUS -#include <windef.h> -#include <winbase.h> - -#define NDEBUG -#include <debug.h> - -HINSTANCE hInstance; - -BOOL -WINAPI -DllMain(HINSTANCE hinstDLL, - DWORD dwReason, - LPVOID reserved) -{ - switch (dwReason) - { - case DLL_PROCESS_ATTACH: - break; - case DLL_PROCESS_DETACH: - hInstance = hinstDLL; - break; - } - - return TRUE; -} - -VOID WINAPI RunOnceExProcess(HWND hwnd, HINSTANCE hInst, LPCSTR path, int nShow) -{ - DPRINT1("RunOnceExProcess() not implemented\n"); -} diff --git a/dll/win32/iernonce/iernonce.cpp b/dll/win32/iernonce/iernonce.cpp new file mode 100644 index 00000000000..2569c9e164c --- /dev/null +++ b/dll/win32/iernonce/iernonce.cpp @@ -0,0 +1,61 @@ +/* + * PROJECT: ReactOS system libraries + * LICENSE: GPL-2.0-or-later (
https://spdx.org/licenses/GPL-2.0-or-later
) + * PURPOSE: ReactOS Extended RunOnce processing with UI. + * COPYRIGHT: Copyright 2013-2016 Robert Naumann + * Copyright 2021 He Yang <1160386205(a)qq.com> + */ + +#include "iernonce.h" + +RUNONCEEX_CALLBACK g_Callback = NULL; +BOOL g_bSilence = FALSE; + +BOOL +WINAPI +DllMain(_In_ HINSTANCE hinstDLL, + _In_ DWORD dwReason, + _In_ LPVOID reserved) +{ + switch (dwReason) + { + case DLL_PROCESS_ATTACH: + DisableThreadLibraryCalls(hinstDLL); + break; + case DLL_PROCESS_DETACH: + break; + } + + return TRUE; +} + +extern "C" VOID WINAPI +RunOnceExProcess(_In_ HWND hwnd, + _In_ HINSTANCE hInst, + _In_ LPCSTR pszCmdLine, + _In_ int nCmdShow) +{ + // iernonce may use shell32 API. + HRESULT Result = CoInitialize(NULL); + if (Result != S_OK && Result != S_FALSE) + { + return; + } + + HKEY RootKeys[] = { HKEY_LOCAL_MACHINE, HKEY_CURRENT_USER }; + for (UINT i = 0; i < _countof(RootKeys); ++i) + { + RunOnceExInstance Instance(RootKeys[i]); + Instance.Run(g_bSilence); + } + + CoUninitialize(); +} + +extern "C" VOID WINAPI +InitCallback(_In_ RUNONCEEX_CALLBACK Callback, + _In_ BOOL bSilence) +{ + g_Callback = Callback; + g_bSilence = bSilence; +} diff --git a/dll/win32/iernonce/iernonce.h b/dll/win32/iernonce/iernonce.h new file mode 100644 index 00000000000..5c46ed85cc5 --- /dev/null +++ b/dll/win32/iernonce/iernonce.h @@ -0,0 +1,24 @@ +/* + * PROJECT: ReactOS system libraries + * LICENSE: GPL-2.0-or-later (
https://spdx.org/licenses/GPL-2.0-or-later
) + * PURPOSE: ReactOS Extended RunOnce processing with UI. + * COPYRIGHT: Copyright 2021 He Yang <1160386205(a)qq.com> + */ + +#pragma once + +#include <cassert> +#include <cstdlib> + +#define WIN32_NO_STATUS +#include <windef.h> +#include <winbase.h> +#include <windowsx.h> +#include <shlwapi.h> +#include <iernonce_undoc.h> + +#include <atlbase.h> +#include <atlwin.h> + +#include "registry.h" +#include "dialog.h" diff --git a/dll/win32/iernonce/iernonce.spec b/dll/win32/iernonce/iernonce.spec index 808989a74af..23898e470b1 100644 --- a/dll/win32/iernonce/iernonce.spec +++ b/dll/win32/iernonce/iernonce.spec @@ -1 +1,2 @@ -@ stdcall RunOnceExProcess(ptr ptr str long) \ No newline at end of file +@ stdcall RunOnceExProcess(ptr ptr str long) +@ stdcall InitCallback(ptr long) diff --git a/dll/win32/iernonce/include/registry.h b/dll/win32/iernonce/include/registry.h new file mode 100644 index 00000000000..39cdeeb77f7 --- /dev/null +++ b/dll/win32/iernonce/include/registry.h @@ -0,0 +1,107 @@ +/* + * PROJECT: ReactOS system libraries + * LICENSE: GPL-2.0-or-later (
https://spdx.org/licenses/GPL-2.0-or-later
) + * PURPOSE: Functions to read RunOnceEx registry. + * COPYRIGHT: Copyright 2021 He Yang <1160386205(a)qq.com> + */ + +#pragma once + +#include <windows.h> +#include <atlbase.h> +#include <atlstr.h> +#include <atlcoll.h> +#include <atlsimpcoll.h> + +#define FLAGS_NO_STAT_DIALOG 0x00000080 + +#ifndef UNICODE +#error This project must be compiled with UNICODE! +#endif + +class CRegKeyEx : public CRegKey +{ +public: + LONG EnumValueName( + _In_ DWORD iIndex, + _Out_ LPTSTR pszName, + _Inout_ LPDWORD pnNameLength); +}; + +class RunOnceExEntry +{ +private: + ATL::CStringW m_Value; + ATL::CStringW m_Name; + +public: + + RunOnceExEntry( + _In_ const ATL::CStringW &Name, + _In_ const ATL::CStringW &Value); + + BOOL Delete(_In_ CRegKeyEx &hParentKey); + BOOL Exec() const; + + friend int RunOnceExEntryCmp( + _In_ const void *a, + _In_ const void *b); +}; + +class RunOnceExSection +{ +private: + ATL::CStringW m_SectionName; + CRegKeyEx m_RegKey; + + BOOL HandleValue( + _In_ CRegKeyEx &hKey, + _In_ const CStringW &ValueName); + +public: + BOOL m_bSuccess; + ATL::CStringW m_SectionTitle; + CSimpleArray<RunOnceExEntry> m_EntryList; + + RunOnceExSection( + _In_ CRegKeyEx &hParentKey, + _In_ const CStringW &lpSubKeyName); + + RunOnceExSection(_In_ const RunOnceExSection &Section); + + BOOL CloseAndDelete(_In_ CRegKeyEx &hParentKey); + + UINT GetEntryCnt() const; + + BOOL Exec( + _Inout_ UINT& iCompleteCnt, + _In_ const UINT iTotalCnt); + + friend int RunOnceExSectionCmp( + _In_ const void *a, + _In_ const void *b); + + friend class RunOnceExInstance; +}; + +class RunOnceExInstance +{ +private: + CRegKeyEx m_RegKey; + + BOOL HandleSubKey( + _In_ CRegKeyEx &hKey, + _In_ const CStringW &SubKeyName); + +public: + BOOL m_bSuccess; + CSimpleArray<RunOnceExSection> m_SectionList; + CStringW m_Title; + DWORD m_dwFlags; + BOOL m_bShowDialog; + + RunOnceExInstance(_In_ HKEY BaseKey); + + BOOL Exec(_In_opt_ HWND hwnd); + BOOL Run(_In_ BOOL bSilence); +}; diff --git a/dll/win32/iernonce/registry.cpp b/dll/win32/iernonce/registry.cpp new file mode 100644 index 00000000000..a5c764b6c58 --- /dev/null +++ b/dll/win32/iernonce/registry.cpp @@ -0,0 +1,360 @@ +/* + * PROJECT: ReactOS system libraries + * LICENSE: GPL-2.0-or-later (
https://spdx.org/licenses/GPL-2.0-or-later
) + * PURPOSE: Functions to read RunOnceEx registry. + * COPYRIGHT: Copyright 2021 He Yang <1160386205(a)qq.com> + */ + +#include "iernonce.h" + +extern RUNONCEEX_CALLBACK g_Callback; + +LONG CRegKeyEx::EnumValueName( + _In_ DWORD iIndex, + _Out_ LPTSTR pszName, + _Inout_ LPDWORD pnNameLength) +{ + return RegEnumValueW(m_hKey, iIndex, pszName, pnNameLength, + NULL, NULL, NULL, NULL); +} + +RunOnceExEntry::RunOnceExEntry( + _In_ const ATL::CStringW &Name, + _In_ const ATL::CStringW &Value) : + m_Value(Value), m_Name(Name) +{ ; } + +BOOL RunOnceExEntry::Delete( + _In_ CRegKeyEx &hParentKey) +{ + return hParentKey.DeleteValue(m_Name) == ERROR_SUCCESS; +} + +BOOL RunOnceExEntry::Exec() const +{ + CStringW CommandLine; + if (wcsncmp(m_Value, L"||", 2) == 0) + { + // Remove the prefix. + CommandLine = (LPCWSTR)m_Value + 2; + } + else + { + CommandLine = m_Value; + } + + // FIXME: SHEvaluateSystemCommandTemplate is not implemented + // using PathGetArgsW, PathRemoveArgsW as a workaround. + LPWSTR szCommandLine = CommandLine.GetBuffer(); + LPCWSTR szParam = PathGetArgsW(szCommandLine); + PathRemoveArgsW(szCommandLine); + + SHELLEXECUTEINFOW Info = { 0 }; + Info.cbSize = sizeof(Info); + Info.fMask = SEE_MASK_NOCLOSEPROCESS; + Info.lpFile = szCommandLine; + Info.lpParameters = szParam; + Info.nShow = SW_SHOWNORMAL; + + BOOL bSuccess = ShellExecuteExW(&Info); + + CommandLine.ReleaseBuffer(); + + if (!bSuccess) + { + return FALSE; + } + + if (Info.hProcess) + { + WaitForSingleObject(Info.hProcess, INFINITE); + CloseHandle(Info.hProcess); + } + + return TRUE; +} + +int RunOnceExEntryCmp( + _In_ const void *a, + _In_ const void *b) +{ + return lstrcmpW(((RunOnceExEntry *)a)->m_Name, + ((RunOnceExEntry *)b)->m_Name); +} + +BOOL RunOnceExSection::HandleValue( + _In_ CRegKeyEx &hKey, + _In_ const CStringW &ValueName) +{ + DWORD dwType; + DWORD cbData; + + // Query data size + if (hKey.QueryValue(ValueName, &dwType, NULL, &cbData) != ERROR_SUCCESS) + return FALSE; + + // Validate its format and size. + if (dwType != REG_SZ) + return TRUE; + + if (cbData % sizeof(WCHAR) != 0) + return FALSE; + + CStringW Buffer; + LPWSTR szBuffer = Buffer.GetBuffer((cbData / sizeof(WCHAR)) + 1); + + if (hKey.QueryValue(ValueName, &dwType, szBuffer, &cbData) != ERROR_SUCCESS) + { + Buffer.ReleaseBuffer(); + return FALSE; + } + szBuffer[cbData / sizeof(WCHAR)] = L'\0'; + Buffer.ReleaseBuffer(); + + CStringW ExpandStr; + DWORD dwcchExpand = ExpandEnvironmentStringsW(Buffer, NULL, 0); + ExpandEnvironmentStringsW(Buffer, ExpandStr.GetBuffer(dwcchExpand + 1), dwcchExpand); + ExpandStr.ReleaseBuffer(); + + if (ValueName.IsEmpty()) + { + // The default value specifies the section title. + m_SectionTitle = Buffer; + } + else + { + m_EntryList.Add(RunOnceExEntry(ValueName, ExpandStr)); + } + + return TRUE; +} + +RunOnceExSection::RunOnceExSection( + _In_ CRegKeyEx &hParentKey, + _In_ const CStringW &lpSubKeyName) : + m_SectionName(lpSubKeyName) +{ + m_bSuccess = FALSE; + DWORD dwValueNum; + DWORD dwMaxValueNameLen; + LSTATUS Error; + CStringW ValueName; + + if (m_RegKey.Open(hParentKey, lpSubKeyName) != ERROR_SUCCESS) + return; + + Error = RegQueryInfoKeyW(m_RegKey, NULL, 0, NULL, NULL, NULL, NULL, + &dwValueNum, &dwMaxValueNameLen, + NULL, NULL, NULL); + if (Error != ERROR_SUCCESS) + return; + + for (DWORD i = 0; i < dwValueNum; i++) + { + LPWSTR szValueName; + DWORD dwcchName = dwMaxValueNameLen + 1; + + szValueName = ValueName.GetBuffer(dwMaxValueNameLen + 1); + Error = m_RegKey.EnumValueName(i, szValueName, &dwcchName); + ValueName.ReleaseBuffer(); + + if (Error != ERROR_SUCCESS) + { + // TODO: error handling + return; + } + + if (!HandleValue(m_RegKey, ValueName)) + return; + } + + // Sort entries by name in string order. + qsort(m_EntryList.GetData(), m_EntryList.GetSize(), + sizeof(RunOnceExEntry), RunOnceExEntryCmp); + + m_bSuccess = TRUE; + return; +} + +// Copy constructor, CSimpleArray needs it. +RunOnceExSection::RunOnceExSection(_In_ const RunOnceExSection& Section) : + m_SectionName(Section.m_SectionName), + m_bSuccess(Section.m_bSuccess), + m_SectionTitle(Section.m_SectionTitle), + m_EntryList(Section.m_EntryList) +{ + m_RegKey.Attach(Section.m_RegKey); +} + +BOOL RunOnceExSection::CloseAndDelete( + _In_ CRegKeyEx &hParentKey) +{ + m_RegKey.Close(); + return hParentKey.RecurseDeleteKey(m_SectionName) == ERROR_SUCCESS; +} + +UINT RunOnceExSection::GetEntryCnt() const +{ + return m_EntryList.GetSize(); +} + +BOOL RunOnceExSection::Exec( + _Inout_ UINT& iCompleteCnt, + _In_ const UINT iTotalCnt) +{ + BOOL bSuccess = TRUE; + + for (int i = 0; i < m_EntryList.GetSize(); i++) + { + m_EntryList[i].Delete(m_RegKey); + bSuccess &= m_EntryList[i].Exec(); + iCompleteCnt++; + // TODO: the meaning of the third param is still unknown, seems it's always 0. + if (g_Callback) + g_Callback(iCompleteCnt, iTotalCnt, NULL); + } + return bSuccess; +} + +int RunOnceExSectionCmp( + _In_ const void *a, + _In_ const void *b) +{ + return lstrcmpW(((RunOnceExSection *)a)->m_SectionName, + ((RunOnceExSection *)b)->m_SectionName); +} + +RunOnceExInstance::RunOnceExInstance(_In_ HKEY BaseKey) +{ + m_bSuccess = FALSE; + DWORD dwSubKeyNum; + DWORD dwMaxSubKeyNameLen; + LSTATUS Error; + CStringW SubKeyName; + + Error = m_RegKey.Open(BaseKey, + L"Software\\Microsoft\\Windows\\CurrentVersion\\RunOnceEx\\"); + if (Error != ERROR_SUCCESS) + { + return; + } + + ULONG cchTitle; + Error = m_RegKey.QueryStringValue(L"Title", NULL, &cchTitle); + if (Error == ERROR_SUCCESS) + { + Error = m_RegKey.QueryStringValue(L"Title", m_Title.GetBuffer(cchTitle + 1), &cchTitle); + m_Title.ReleaseBuffer(); + if (Error != ERROR_SUCCESS) + return; + } + + Error = m_RegKey.QueryDWORDValue(L"Flags", m_dwFlags); + if (Error != ERROR_SUCCESS) + { + m_dwFlags = 0; + } + + Error = RegQueryInfoKeyW(m_RegKey, NULL, 0, NULL, + &dwSubKeyNum, &dwMaxSubKeyNameLen, + NULL, NULL, NULL, NULL, NULL, NULL); + if (Error != ERROR_SUCCESS) + return; + + m_bShowDialog = FALSE; + + for (DWORD i = 0; i < dwSubKeyNum; i++) + { + LPWSTR szSubKeyName; + DWORD dwcchName = dwMaxSubKeyNameLen + 1; + + szSubKeyName = SubKeyName.GetBuffer(dwMaxSubKeyNameLen + 1); + Error = m_RegKey.EnumKey(i, szSubKeyName, &dwcchName); + SubKeyName.ReleaseBuffer(); + + if (Error != ERROR_SUCCESS) + { + // TODO: error handling + return; + } + + if (!HandleSubKey(m_RegKey, SubKeyName)) + return; + } + + // Sort sections by name in string order. + qsort(m_SectionList.GetData(), m_SectionList.GetSize(), + sizeof(RunOnceExSection), RunOnceExSectionCmp); + + m_bSuccess = TRUE; + return; +} + +BOOL RunOnceExInstance::Exec(_In_opt_ HWND hwnd) +{ + BOOL bSuccess = TRUE; + + UINT TotalCnt = 0; + UINT CompleteCnt = 0; + for (int i = 0; i < m_SectionList.GetSize(); i++) + { + TotalCnt += m_SectionList[i].GetEntryCnt(); + } + + // Execute items from registry one by one, and remove them. + for (int i = 0; i < m_SectionList.GetSize(); i++) + { + if (hwnd) + SendMessageW(hwnd, WM_SETINDEX, i, 0); + + bSuccess &= m_SectionList[i].Exec(CompleteCnt, TotalCnt); + m_SectionList[i].CloseAndDelete(m_RegKey); + } + + m_RegKey.DeleteValue(L"Title"); + m_RegKey.DeleteValue(L"Flags"); + + // Notify the dialog all sections are handled. + if (hwnd) + SendMessageW(hwnd, WM_SETINDEX, m_SectionList.GetSize(), bSuccess); + return bSuccess; +} + +BOOL RunOnceExInstance::Run(_In_ BOOL bSilence) +{ + if (bSilence || + (m_dwFlags & FLAGS_NO_STAT_DIALOG) || + !m_bShowDialog) + { + return Exec(NULL); + } + else + { + // The dialog is responsible to create a thread and execute. + ProgressDlg dlg(*this); + return dlg.RunDialogBox(); + } +} + +BOOL RunOnceExInstance::HandleSubKey( + _In_ CRegKeyEx &hKey, + _In_ const CStringW& SubKeyName) +{ + RunOnceExSection Section(hKey, SubKeyName); + if (!Section.m_bSuccess) + { + return FALSE; + } + + if (!Section.m_SectionTitle.IsEmpty()) + { + m_bShowDialog = TRUE; + } + m_SectionList.Add(Section); + + // The copy constructor of RunOnceExSection didn't detach + // the m_RegKey while it's attached to the one in the array. + // So we have to detach it manually. + Section.m_RegKey.Detach(); + return TRUE; +} diff --git a/sdk/include/reactos/iernonce_undoc.h b/sdk/include/reactos/iernonce_undoc.h new file mode 100644 index 00000000000..530f10f0dd0 --- /dev/null +++ b/sdk/include/reactos/iernonce_undoc.h @@ -0,0 +1,30 @@ +#ifndef _IERNONCE_UNDOC_H_ +#define _IERNONCE_UNDOC_H_ + +#ifdef __cplusplus +extern "C" { +#endif + +typedef VOID +(CALLBACK *RUNONCEEX_CALLBACK)( + _In_ UINT CompleteCnt, + _In_ UINT TotalCnt, + _In_ DWORD_PTR dwReserved); + +VOID WINAPI +InitCallback( + _In_ RUNONCEEX_CALLBACK Callback, + _In_ BOOL bSilence); + +VOID WINAPI +RunOnceExProcess( + _In_ HWND hwnd, + _In_ HINSTANCE hInst, + _In_ LPCSTR pszCmdLine, + _In_ int nCmdShow); + +#ifdef __cplusplus +} +#endif + +#endif /* _IERNONCE_UNDOC_H_ */
3 years, 2 months
1
0
0
0
[reactos] 01/01: [NtGDI] Fix brush attribute transfer.
by James Tabor
https://git.reactos.org/?p=reactos.git;a=commitdiff;h=b5fae844de5877d2c9c95…
commit b5fae844de5877d2c9c955d6e04222580a03581c Author: James Tabor <james.tabor(a)reactos.org> AuthorDate: Tue Sep 28 19:08:45 2021 -0500 Commit: James Tabor <james.tabor(a)reactos.org> CommitDate: Tue Sep 28 19:08:45 2021 -0500 [NtGDI] Fix brush attribute transfer. --- win32ss/gdi/ntgdi/brush.cpp | 32 ++++++++++++++++++++++++++++++++ win32ss/gdi/ntgdi/brush.hpp | 2 ++ 2 files changed, 34 insertions(+) diff --git a/win32ss/gdi/ntgdi/brush.cpp b/win32ss/gdi/ntgdi/brush.cpp index 2c18e25b307..f98b233234e 100644 --- a/win32ss/gdi/ntgdi/brush.cpp +++ b/win32ss/gdi/ntgdi/brush.cpp @@ -76,6 +76,17 @@ BRUSH::~BRUSH( } } +VOID +BRUSH::vReleaseAttribute(VOID) +{ + if (this->pBrushAttr != &this->BrushAttr) + { + this->BrushAttr = *this->pBrushAttr; + GdiPoolFree(GetBrushAttrPool(), this->pBrushAttr); + this->pBrushAttr = &this->BrushAttr; + } +} + VOID BRUSH::vDeleteObject( _In_ PVOID pvObject) @@ -543,10 +554,19 @@ NtGdiSetBrushAttributes( _In_ HBRUSH hbr, _In_ DWORD dwFlags) { + PBRUSH pbr; if ( dwFlags & SC_BB_STOCKOBJ ) { if (GDIOBJ_ConvertToStockObj((HGDIOBJ*)&hbr)) { + pbr = BRUSH::LockAny(hbr); + if (pbr == NULL) + { + ERR("Failed to lock brush %p\n", hbr); + return NULL; + } + pbr->vReleaseAttribute(); + pbr->vUnlock(); return hbr; } } @@ -560,10 +580,22 @@ NtGdiClearBrushAttributes( _In_ HBRUSH hbr, _In_ DWORD dwFlags) { + PBRUSH pbr; if ( dwFlags & SC_BB_STOCKOBJ ) { if (GDIOBJ_ConvertFromStockObj((HGDIOBJ*)&hbr)) { + pbr = BRUSH::LockAny(hbr); + if (pbr == NULL) + { + ERR("Failed to lock brush %p\n", hbr); + return NULL; + } + if (!pbr->bAllocateBrushAttr()) + { + ERR("Failed to allocate brush attribute\n"); + } + pbr->vUnlock(); return hbr; } } diff --git a/win32ss/gdi/ntgdi/brush.hpp b/win32ss/gdi/ntgdi/brush.hpp index 4fea65ea3c2..027db2490d0 100644 --- a/win32ss/gdi/ntgdi/brush.hpp +++ b/win32ss/gdi/ntgdi/brush.hpp @@ -113,6 +113,8 @@ public: VOID vSetSolidColor( _In_ COLORREF crColor); + + VOID vReleaseAttribute(VOID); }; /* HACK! */
3 years, 2 months
1
0
0
0
[reactos] 01/01: [IMM32] Rewrite ImmAssociateContext (#3979)
by Katayama Hirofumi MZ
https://git.reactos.org/?p=reactos.git;a=commitdiff;h=ef003fa47d2d7bdb70ce2…
commit ef003fa47d2d7bdb70ce26dd2b08160f0143125e Author: Katayama Hirofumi MZ <katayama.hirofumi.mz(a)gmail.com> AuthorDate: Tue Sep 28 22:03:25 2021 +0900 Commit: GitHub <noreply(a)github.com> CommitDate: Tue Sep 28 22:03:25 2021 +0900 [IMM32] Rewrite ImmAssociateContext (#3979) CORE-11700 --- dll/win32/imm32/imm.c | 87 ++++++++++++++------------------------------------- 1 file changed, 23 insertions(+), 64 deletions(-) diff --git a/dll/win32/imm32/imm.c b/dll/win32/imm32/imm.c index 135b7afc6ee..ab97e052c9a 100644 --- a/dll/win32/imm32/imm.c +++ b/dll/win32/imm32/imm.c @@ -169,87 +169,46 @@ static InputContextData* get_imc_data(HIMC hIMC) return data; } -static HIMC get_default_context( HWND hwnd ) -{ - FIXME("Don't use this function\n"); - return FALSE; -} - -static BOOL IMM_IsCrossThreadAccess(HWND hWnd, HIMC hIMC) -{ - InputContextData *data; - - if (hWnd) - { - DWORD thread = GetWindowThreadProcessId(hWnd, NULL); - if (thread != GetCurrentThreadId()) return TRUE; - } - data = get_imc_data(hIMC); - if (data && data->threadID != GetCurrentThreadId()) - return TRUE; - - return FALSE; -} - /*********************************************************************** * ImmAssociateContext (IMM32.@) */ HIMC WINAPI ImmAssociateContext(HWND hWnd, HIMC hIMC) { - HIMC old = NULL; - InputContextData *data = get_imc_data(hIMC); + PWND pWnd; + HWND hwndFocus; + DWORD dwValue; + HIMC hOldIMC; - TRACE("(%p, %p):\n", hWnd, hIMC); + TRACE("(%p, %p)\n", hWnd, hIMC); - if(hIMC && !data) + if (!Imm32IsImmMode()) return NULL; - /* - * If already associated just return - */ - if (hIMC && data->IMC.hWnd == hWnd) - return hIMC; - - if (hIMC && IMM_IsCrossThreadAccess(hWnd, hIMC)) + pWnd = ValidateHwndNoErr(hWnd); + if (!pWnd) return NULL; - if (hWnd) - { - HIMC defaultContext = get_default_context( hWnd ); - old = RemovePropW(hWnd,szwWineIMCProperty); - - if (old == NULL) - old = defaultContext; - else if (old == (HIMC)-1) - old = NULL; - - if (hIMC != defaultContext) - { - if (hIMC == NULL) /* Meaning disable imm for that window*/ - SetPropW(hWnd,szwWineIMCProperty,(HANDLE)-1); - else - SetPropW(hWnd,szwWineIMCProperty,hIMC); - } + if (hIMC && Imm32IsCrossThreadAccess(hIMC)) + return NULL; - if (old) - { - InputContextData *old_data = (InputContextData *)old; - if (old_data->IMC.hWnd == hWnd) - old_data->IMC.hWnd = NULL; - } - } + hOldIMC = pWnd->hImc; + if (hOldIMC == hIMC) + return hIMC; - if (!hIMC) - return old; + dwValue = NtUserAssociateInputContext(hWnd, hIMC, 0); + if (dwValue == 0) + return hOldIMC; + if (dwValue != 1) + return NULL; - if(GetActiveWindow() == data->IMC.hWnd) + hwndFocus = (HWND)NtUserQueryWindow(hWnd, QUERY_WINDOW_FOCUS); + if (hwndFocus == hWnd) { - SendMessageW(data->IMC.hWnd, WM_IME_SETCONTEXT, FALSE, ISC_SHOWUIALL); - data->IMC.hWnd = hWnd; - SendMessageW(data->IMC.hWnd, WM_IME_SETCONTEXT, TRUE, ISC_SHOWUIALL); + ImmSetActiveContext(hWnd, hOldIMC, FALSE); + ImmSetActiveContext(hWnd, hIMC, TRUE); } - return old; + return hOldIMC; } /***********************************************************************
3 years, 2 months
1
0
0
0
← Newer
1
2
3
4
...
15
Older →
Jump to page:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
Results per page:
10
25
50
100
200