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
November 2023
----- 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
20 participants
274 discussions
Start a n
N
ew thread
[reactos] 01/01: [NTOS:KE] Remove KiMask32Array
by Timo Kreuzer
https://git.reactos.org/?p=reactos.git;a=commitdiff;h=f92c44b21761ca4f23dac…
commit f92c44b21761ca4f23dac20bde3b9afe40a7210f Author: Timo Kreuzer <timo.kreuzer(a)reactos.org> AuthorDate: Sat Nov 25 14:52:05 2023 +0200 Commit: Timo Kreuzer <timo.kreuzer(a)reactos.org> CommitDate: Thu Nov 30 13:03:52 2023 +0200 [NTOS:KE] Remove KiMask32Array It's useless and also broken in the way it is used. Replace it with a simple shift and make it correct for 64 bit. --- ntoskrnl/include/internal/ke.h | 5 ++--- ntoskrnl/ke/thrdobj.c | 10 ---------- 2 files changed, 2 insertions(+), 13 deletions(-) diff --git a/ntoskrnl/include/internal/ke.h b/ntoskrnl/include/internal/ke.h index 10a352a0981..fbd3660553e 100644 --- a/ntoskrnl/include/internal/ke.h +++ b/ntoskrnl/include/internal/ke.h @@ -137,7 +137,6 @@ extern LIST_ENTRY KiProcessInSwapListHead, KiProcessOutSwapListHead; extern LIST_ENTRY KiStackInSwapListHead; extern KEVENT KiSwapEvent; extern PKPRCB KiProcessorBlock[]; -extern ULONG KiMask32Array[MAXIMUM_PRIORITY]; extern ULONG_PTR KiIdleSummary; extern PVOID KeUserApcDispatcher; extern PVOID KeUserCallbackDispatcher; @@ -156,8 +155,8 @@ extern VOID __cdecl KiInterruptTemplate(VOID); /* MACROS *************************************************************************/ -#define AFFINITY_MASK(Id) KiMask32Array[Id] -#define PRIORITY_MASK(Id) KiMask32Array[Id] +#define AFFINITY_MASK(ProcessorIndex) ((KAFFINITY)1 << (ProcessorIndex)) +#define PRIORITY_MASK(Priority) (1UL << (Priority)) /* Tells us if the Timer or Event is a Syncronization or Notification Object */ #define TIMER_OR_EVENT_TYPE 0x7L diff --git a/ntoskrnl/ke/thrdobj.c b/ntoskrnl/ke/thrdobj.c index 627f42c7395..1fc58b99c9e 100644 --- a/ntoskrnl/ke/thrdobj.c +++ b/ntoskrnl/ke/thrdobj.c @@ -15,16 +15,6 @@ extern EX_WORK_QUEUE ExWorkerQueue[MaximumWorkQueue]; extern LIST_ENTRY PspReaperListHead; -ULONG KiMask32Array[MAXIMUM_PRIORITY] = -{ - 0x1, 0x2, 0x4, 0x8, 0x10, 0x20, - 0x40, 0x80, 0x100, 0x200, 0x400, 0x800, - 0x1000, 0x2000, 0x4000, 0x8000, 0x10000, 0x20000, - 0x40000, 0x80000, 0x100000, 0x200000, 0x400000, 0x800000, - 0x1000000, 0x2000000, 0x4000000, 0x8000000, 0x10000000, 0x20000000, - 0x40000000, 0x80000000 -}; - /* FUNCTIONS *****************************************************************/ UCHAR
1 year
1
0
0
0
[reactos] 01/01: [KERNEL32] Fix 64-bit bug in SetProcessAffinityMask
by Timo Kreuzer
https://git.reactos.org/?p=reactos.git;a=commitdiff;h=642c795531c33885701ef…
commit 642c795531c33885701ef56d1f6b2066384131fb Author: Timo Kreuzer <timo.kreuzer(a)reactos.org> AuthorDate: Sun Nov 26 11:31:43 2023 +0200 Commit: Timo Kreuzer <timo.kreuzer(a)reactos.org> CommitDate: Thu Nov 30 13:01:14 2023 +0200 [KERNEL32] Fix 64-bit bug in SetProcessAffinityMask --- dll/win32/kernel32/client/proc.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/dll/win32/kernel32/client/proc.c b/dll/win32/kernel32/client/proc.c index 9f1f1c1a4a0..b88212b3c59 100644 --- a/dll/win32/kernel32/client/proc.c +++ b/dll/win32/kernel32/client/proc.c @@ -900,7 +900,7 @@ SetProcessAffinityMask(IN HANDLE hProcess, Status = NtSetInformationProcess(hProcess, ProcessAffinityMask, (PVOID)&dwProcessAffinityMask, - sizeof(DWORD)); + sizeof(dwProcessAffinityMask)); if (!NT_SUCCESS(Status)) { /* Handle failure */
1 year
1
0
0
0
[reactos] 01/01: [IMM32][SDK][NTUSER] Implement CtfImmTIMActivate (#6041)
by Katayama Hirofumi MZ
https://git.reactos.org/?p=reactos.git;a=commitdiff;h=931224fbe12c682bfb5c7…
commit 931224fbe12c682bfb5c736528836c9793be453b Author: Katayama Hirofumi MZ <katayama.hirofumi.mz(a)gmail.com> AuthorDate: Thu Nov 30 17:22:50 2023 +0900 Commit: GitHub <noreply(a)github.com> CommitDate: Thu Nov 30 17:22:50 2023 +0900 [IMM32][SDK][NTUSER] Implement CtfImmTIMActivate (#6041) - Add Imm32InitTLS, Imm32AllocateTLS, Imm32GetTLS, Imm32GetCoInitCountSkip, Imm32IncCoInitCountSkip, and Imm32DecCoInitCountSkip helper functions to control the TLS data. - Introduce "CoInitialize Spy" (ISPY) to manage COM initialization status. - Implement CtfImmCoInitialize and CtfImmCoUninitialize. - Implement CtfImmEnterCoInitCountSkipMode and CtfImmLeaveCoInitCountSkipMode. - Implement CtfImmLastEnabledWndDestroy, ImmDisableTextFrameService, and CtfImmTIMActivate. CORE-19268 --- dll/win32/imm32/CMakeLists.txt | 2 +- dll/win32/imm32/ctf.c | 695 ++++++++++++++++++++++++++++++++++++-- dll/win32/imm32/imm.c | 9 - dll/win32/imm32/imm32.spec | 4 + dll/win32/imm32/precomp.h | 9 + sdk/include/ddk/immdev.h | 4 +- sdk/include/reactos/imm32_undoc.h | 4 + win32ss/include/ntuser.h | 2 + 8 files changed, 683 insertions(+), 46 deletions(-) diff --git a/dll/win32/imm32/CMakeLists.txt b/dll/win32/imm32/CMakeLists.txt index b765ec172ab..60b146b10fa 100644 --- a/dll/win32/imm32/CMakeLists.txt +++ b/dll/win32/imm32/CMakeLists.txt @@ -45,6 +45,6 @@ list(APPEND imm32_rc_deps add_library(imm32 MODULE ${SOURCE} imm32.rc) set_module_type(imm32 win32dll UNICODE ENTRYPOINT ImmDllInitialize 12) set_source_files_properties(imm32.rc PROPERTIES OBJECT_DEPENDS "${imm32_rc_deps}") -target_link_libraries(imm32 wine win32ksys) +target_link_libraries(imm32 wine win32ksys uuid) add_importlibs(imm32 advapi32 user32 gdi32 kernel32 ntdll) add_cd_file(TARGET imm32 DESTINATION reactos/system32 FOR all) diff --git a/dll/win32/imm32/ctf.c b/dll/win32/imm32/ctf.c index dd325d472f7..be1853f02c3 100644 --- a/dll/win32/imm32/ctf.c +++ b/dll/win32/imm32/ctf.c @@ -6,11 +6,83 @@ */ #include "precomp.h" -#include <msctf.h> -#include <ctfutb.h> +#include <msctf.h> /* for ITfLangBarMgr */ +#include <objidl.h> /* for IInitializeSpy */ WINE_DEFAULT_DEBUG_CHANNEL(imm); +/* FIXME: Use RTL */ +static BOOL WINAPI RtlDllShutdownInProgress(VOID) +{ + return FALSE; +} + +static BOOL Imm32InsideLoaderLock(VOID) +{ + return NtCurrentTeb()->ProcessEnvironmentBlock->LoaderLock->OwningThread == + NtCurrentTeb()->ClientId.UniqueThread; +} + +static BOOL +Imm32IsInteractiveUserLogon(VOID) +{ + BOOL bOK, IsMember = FALSE; + PSID pSid; + SID_IDENTIFIER_AUTHORITY IdentAuth = { SECURITY_NT_AUTHORITY }; + + if (!AllocateAndInitializeSid(&IdentAuth, 1, SECURITY_INTERACTIVE_RID, + 0, 0, 0, 0, 0, 0, 0, &pSid)) + { + ERR("Error: %ld\n", GetLastError()); + return FALSE; + } + + bOK = CheckTokenMembership(NULL, pSid, &IsMember); + + if (pSid) + FreeSid(pSid); + + return bOK && IsMember; +} + +static BOOL +Imm32IsRunningInMsoobe(VOID) +{ + LPWSTR pchFilePart = NULL; + WCHAR Buffer[MAX_PATH], FileName[MAX_PATH]; + + if (!GetModuleFileNameW(NULL, FileName, _countof(FileName))) + return FALSE; + + GetFullPathNameW(FileName, _countof(Buffer), Buffer, &pchFilePart); + if (!pchFilePart) + return FALSE; + + return lstrcmpiW(pchFilePart, L"msoobe.exe") == 0; +} + +static BOOL +Imm32IsCUASEnabledInRegistry(VOID) +{ + HKEY hKey; + LSTATUS error; + DWORD dwType, dwData, cbData; + + error = RegOpenKeyW(HKEY_LOCAL_MACHINE, L"Software\\Microsoft\\CTF\\SystemShared", &hKey); + if (error != ERROR_SUCCESS) + return FALSE; + + dwData = 0; + cbData = sizeof(dwData); + error = RegQueryValueExW(hKey, L"CUAS", NULL, &dwType, (LPBYTE)&dwData, &cbData); + RegCloseKey(hKey); + + if (error != ERROR_SUCCESS || dwType != REG_DWORD) + return FALSE; + + return !!dwData; +} + BOOL Imm32GetFn( _Inout_opt_ FARPROC *ppfn, @@ -110,6 +182,8 @@ FN_TF_InvalidAssemblyListCacheIfExist MSCTF_FN(TF_InvalidAssemblyListCacheIfExis HRESULT Imm32TF_CreateLangBarMgr(_Inout_ ITfLangBarMgr **ppBarMgr) { + TRACE("TF_CreateLangBarMgr(%p)\n", ppBarMgr); + if (!Imm32GetMsctfFn(TF_CreateLangBarMgr)) return E_FAIL; @@ -118,6 +192,8 @@ HRESULT Imm32TF_CreateLangBarMgr(_Inout_ ITfLangBarMgr **ppBarMgr) VOID Imm32TF_InvalidAssemblyListCacheIfExist(VOID) { + TRACE("TF_InvalidAssemblyListCacheIfExist()\n"); + if (!Imm32GetMsctfFn(TF_InvalidAssemblyListCacheIfExist)) return; @@ -141,6 +217,9 @@ VOID Imm32TF_InvalidAssemblyListCacheIfExist(VOID) /* "Active IMM" compatibility flags */ DWORD g_aimm_compat_flags = 0; +/* Disable CUAS? */ +BOOL g_disable_CUAS_flag = FALSE; + /* The instance of the CTF IME file */ HINSTANCE g_hCtfIme = NULL; @@ -203,6 +282,384 @@ Imm32CheckAndApplyAppCompat( return pApphelpCheckIME(pszAppName); } +/*********************************************************************** + * TLS (Thread-Local Storage) + * + * See: TlsAlloc + */ + +DWORD g_dwTLSIndex = -1; + +/* IMM Thread-Local Storage (TLS) data */ +typedef struct IMMTLSDATA +{ + IInitializeSpy *pSpy; /* CoInitialize Spy */ + DWORD dwUnknown1; + ULARGE_INTEGER uliCookie; /* Spy requires a cookie for revoking */ + BOOL bDoCount; /* Is it counting? */ + DWORD dwSkipCount; /* The skipped count */ + BOOL bUninitializing; /* Is it uninitializing? */ + DWORD dwUnknown2; +} IMMTLSDATA, *PIMMTLSDATA; + +static VOID +Imm32InitTLS(VOID) +{ + RtlEnterCriticalSection(&gcsImeDpi); + + if (g_dwTLSIndex == -1) + g_dwTLSIndex = TlsAlloc(); + + RtlLeaveCriticalSection(&gcsImeDpi); +} + +static IMMTLSDATA* +Imm32AllocateTLS(VOID) +{ + IMMTLSDATA *pData; + + if (g_dwTLSIndex == -1) + return NULL; + + pData = (IMMTLSDATA*)TlsGetValue(g_dwTLSIndex); + if (pData) + return pData; + + pData = (IMMTLSDATA*)ImmLocalAlloc(HEAP_ZERO_MEMORY, sizeof(IMMTLSDATA)); + if (IS_NULL_UNEXPECTEDLY(pData)) + return NULL; + + if (IS_FALSE_UNEXPECTEDLY(TlsSetValue(g_dwTLSIndex, pData))) + { + ImmLocalFree(pData); + return NULL; + } + + return pData; +} + +static IMMTLSDATA* +Imm32GetTLS(VOID) +{ + if (g_dwTLSIndex == -1) + return NULL; + + return (IMMTLSDATA*)TlsGetValue(g_dwTLSIndex); +} + +/* Get */ +static DWORD +Imm32GetCoInitCountSkip(VOID) +{ + IMMTLSDATA *pData = Imm32GetTLS(); + if (!pData) + return 0; + return pData->dwSkipCount; +} + +/* Increment */ +static DWORD +Imm32IncCoInitCountSkip(VOID) +{ + IMMTLSDATA *pData; + DWORD dwOldSkipCount; + + pData = Imm32GetTLS(); + if (!pData) + return 0; + + dwOldSkipCount = pData->dwSkipCount; + if (pData->bDoCount) + pData->dwSkipCount = dwOldSkipCount + 1; + + return dwOldSkipCount; +} + +/* Decrement */ +static DWORD +Imm32DecCoInitCountSkip(VOID) +{ + DWORD dwSkipCount; + IMMTLSDATA *pData; + + pData = Imm32GetTLS();; + if (!pData) + return 0; + + dwSkipCount = pData->dwSkipCount; + if (pData->bDoCount) + { + if (dwSkipCount) + pData->dwSkipCount = dwSkipCount - 1; + } + + return dwSkipCount; +} + +/*********************************************************************** + * CtfImmEnterCoInitCountSkipMode (IMM32.@) + */ +VOID WINAPI CtfImmEnterCoInitCountSkipMode(VOID) +{ + IMMTLSDATA *pData; + + TRACE("()\n"); + + pData = Imm32GetTLS(); + if (pData) + ++(pData->bDoCount); +} + +/*********************************************************************** + * CtfImmLeaveCoInitCountSkipMode (IMM32.@) + */ +BOOL WINAPI CtfImmLeaveCoInitCountSkipMode(VOID) +{ + IMMTLSDATA *pData; + + TRACE("()\n"); + + pData = Imm32GetTLS(); + if (!pData || !pData->bDoCount) + return FALSE; + + --(pData->bDoCount); + return TRUE; +} + +/*********************************************************************** + * ISPY (I am not spy!) + * + * ISPY watches CoInitialize[Ex] / CoUninitialize to manage COM initialization status. + */ + +typedef struct ISPY +{ + const IInitializeSpyVtbl *m_pSpyVtbl; + LONG m_cRefs; +} ISPY, *PISPY; + +static STDMETHODIMP +ISPY_QueryInterface( + _Inout_ IInitializeSpy *pThis, + _In_ REFIID riid, + _Inout_ LPVOID *ppvObj) +{ + ISPY *pSpy = (ISPY*)pThis; + + if (!ppvObj) + return E_INVALIDARG; + + *ppvObj = NULL; + + if (!IsEqualIID(riid, &IID_IUnknown) && !IsEqualIID(riid, &IID_IInitializeSpy)) + return E_NOINTERFACE; + + ++(pSpy->m_cRefs); + *ppvObj = pSpy; + return S_OK; +} + +static STDMETHODIMP_(ULONG) +ISPY_AddRef( + _Inout_ IInitializeSpy *pThis) +{ + ISPY *pSpy = (ISPY*)pThis; + return ++pSpy->m_cRefs; +} + +static STDMETHODIMP_(ULONG) +ISPY_Release( + _Inout_ IInitializeSpy *pThis) +{ + ISPY *pSpy = (ISPY*)pThis; + if (--pSpy->m_cRefs == 0) + { + ImmLocalFree(pSpy); + return 0; + } + return pSpy->m_cRefs; +} + +/* + * (Pre/Post)(Initialize/Uninitialize) will be automatically called from OLE32 + * as the results of watching. + */ + +static STDMETHODIMP +ISPY_PreInitialize( + _Inout_ IInitializeSpy *pThis, + _In_ DWORD dwCoInit, + _In_ DWORD dwCurThreadAptRefs) +{ + DWORD cCount; + + UNREFERENCED_PARAMETER(pThis); + + cCount = Imm32IncCoInitCountSkip(); + if (!dwCoInit && + (dwCurThreadAptRefs == cCount + 1) && + (GetWin32ClientInfo()->CI_flags & CI_CTFCOINIT)) + { + Imm32ActivateOrDeactivateTIM(FALSE); + CtfImmCoUninitialize(); + } + + return S_OK; +} + +static STDMETHODIMP +ISPY_PostInitialize( + _Inout_ IInitializeSpy *pThis, + _In_ HRESULT hrCoInit, + _In_ DWORD dwCoInit, + _In_ DWORD dwNewThreadAptRefs) +{ + DWORD CoInitCountSkip; + + UNREFERENCED_PARAMETER(pThis); + UNREFERENCED_PARAMETER(dwCoInit); + + CoInitCountSkip = Imm32GetCoInitCountSkip(); + + if ((hrCoInit != S_FALSE) || + (dwNewThreadAptRefs != CoInitCountSkip + 2) || + !(GetWin32ClientInfo()->CI_flags & CI_CTFCOINIT)) + { + return hrCoInit; + } + + return S_OK; +} + +static STDMETHODIMP +ISPY_PreUninitialize( + _Inout_ IInitializeSpy *pThis, + _In_ DWORD dwCurThreadAptRefs) +{ + UNREFERENCED_PARAMETER(pThis); + + if (dwCurThreadAptRefs == 1 && + !RtlDllShutdownInProgress() && + !Imm32InsideLoaderLock() && + (GetWin32ClientInfo()->CI_flags & CI_CTFCOINIT)) + { + IMMTLSDATA *pData = Imm32GetTLS(); + if (pData && !pData->bUninitializing) + Imm32CoInitializeEx(); + } + + return S_OK; +} + +static STDMETHODIMP +ISPY_PostUninitialize( + _In_ IInitializeSpy *pThis, + _In_ DWORD dwNewThreadAptRefs) +{ + UNREFERENCED_PARAMETER(pThis); + UNREFERENCED_PARAMETER(dwNewThreadAptRefs); + Imm32DecCoInitCountSkip(); + return S_OK; +} + +static const IInitializeSpyVtbl g_vtblISPY = +{ + ISPY_QueryInterface, + ISPY_AddRef, + ISPY_Release, + ISPY_PreInitialize, + ISPY_PostInitialize, + ISPY_PreUninitialize, + ISPY_PostUninitialize, +}; + +static ISPY* +Imm32AllocIMMISPY(VOID) +{ + ISPY *pSpy = (ISPY*)ImmLocalAlloc(0, sizeof(ISPY)); + if (!pSpy) + return NULL; + + pSpy->m_pSpyVtbl = &g_vtblISPY; + pSpy->m_cRefs = 1; + return pSpy; +} + +#define Imm32DeleteIMMISPY(pSpy) ImmLocalFree(pSpy) + +/*********************************************************************** + * CtfImmCoInitialize (Not exported) + */ +HRESULT +CtfImmCoInitialize(VOID) +{ + HRESULT hr; + IMMTLSDATA *pData; + ISPY *pSpy; + + if (GetWin32ClientInfo()->CI_flags & CI_CTFCOINIT) + return S_OK; /* Already initialized */ + + hr = Imm32CoInitializeEx(); + if (FAILED_UNEXPECTEDLY(hr)) + return hr; /* CoInitializeEx failed */ + + GetWin32ClientInfo()->CI_flags |= CI_CTFCOINIT; + Imm32InitTLS(); + + pData = Imm32AllocateTLS(); + if (!pData || pData->pSpy) + return S_OK; /* Cannot allocate or already it has a spy */ + + pSpy = Imm32AllocIMMISPY(); + pData->pSpy = (IInitializeSpy*)pSpy; + if (IS_NULL_UNEXPECTEDLY(pSpy)) + return S_OK; /* Cannot allocate a spy */ + + if (FAILED_UNEXPECTEDLY(Imm32CoRegisterInitializeSpy(pData->pSpy, &pData->uliCookie))) + { + /* Failed to register the spy */ + Imm32DeleteIMMISPY(pData->pSpy); + pData->pSpy = NULL; + pData->uliCookie.QuadPart = 0; + } + + return S_OK; +} + +/*********************************************************************** + * CtfImmCoUninitialize (IMM32.@) + */ +VOID WINAPI +CtfImmCoUninitialize(VOID) +{ + IMMTLSDATA *pData; + + if (!(GetWin32ClientInfo()->CI_flags & CI_CTFCOINIT)) + return; /* Not CoInitialize'd */ + + pData = Imm32GetTLS(); + if (pData) + { + pData->bUninitializing = TRUE; + Imm32CoUninitialize(); /* Do CoUninitialize */ + pData->bUninitializing = FALSE; + + GetWin32ClientInfo()->CI_flags &= ~CI_CTFCOINIT; + } + + pData = Imm32AllocateTLS(); + if (!pData || !pData->pSpy) + return; /* There were no spy */ + + /* Our work is done. We don't need spies like you anymore. */ + Imm32CoRevokeInitializeSpy(pData->uliCookie); + ISPY_Release(pData->pSpy); + pData->pSpy = NULL; + pData->uliCookie.QuadPart = 0; +} + /*********************************************************************** * This function loads the CTF IME file if necessary and establishes * communication with the CTF IME. @@ -286,6 +743,8 @@ Imm32LoadCtfIme(VOID) HRESULT CtfImeCreateThreadMgr(VOID) { + TRACE("()\n"); + if (!Imm32LoadCtfIme()) return E_FAIL; @@ -298,6 +757,8 @@ CtfImeCreateThreadMgr(VOID) HRESULT CtfImeDestroyThreadMgr(VOID) { + TRACE("()\n"); + if (!Imm32LoadCtfIme()) return E_FAIL; @@ -362,6 +823,8 @@ HRESULT CtfImeCreateInputContext( _In_ HIMC hIMC) { + TRACE("(%p)\n", hIMC); + if (!Imm32LoadCtfIme()) return E_FAIL; @@ -374,6 +837,8 @@ CtfImeCreateInputContext( HRESULT CtfImeDestroyInputContext(_In_ HIMC hIMC) { + TRACE("(%p)\n", hIMC); + if (!Imm32LoadCtfIme()) return E_FAIL; @@ -394,8 +859,61 @@ Imm32EnumCreateCtfICProc( } /*********************************************************************** - * This function calls CtfImeDestroyInputContext if possible. + * Thread Input Manager (TIM) */ + +static BOOL +Imm32IsTIMDisabledInRegistry(VOID) +{ + DWORD dwData, cbData; + HKEY hKey; + LSTATUS error; + + error = RegOpenKeyW(HKEY_CURRENT_USER, L"SOFTWARE\\Microsoft\\CTF", &hKey); + if (error != ERROR_SUCCESS) + return FALSE; + + dwData = 0; + cbData = sizeof(dwData); + RegQueryValueExW(hKey, L"Disable Thread Input Manager", NULL, NULL, (LPBYTE)&dwData, &cbData); + RegCloseKey(hKey); + return !!dwData; +} + +HRESULT +Imm32ActivateOrDeactivateTIM( + _In_ BOOL bCreate) +{ + HRESULT hr = S_OK; + + if (!IS_CICERO_MODE() || IS_16BIT_MODE() || + !(GetWin32ClientInfo()->CI_flags & CI_CTFCOINIT)) + { + return S_OK; /* No need to activate/de-activate TIM */ + } + + if (bCreate) + { + if (!(GetWin32ClientInfo()->CI_flags & CI_CTFTIM)) + { + hr = CtfImeCreateThreadMgr(); + if (SUCCEEDED(hr)) + GetWin32ClientInfo()->CI_flags |= CI_CTFTIM; + } + } + else /* Destroy */ + { + if (GetWin32ClientInfo()->CI_flags & CI_CTFTIM) + { + hr = CtfImeDestroyThreadMgr(); + if (SUCCEEDED(hr)) + GetWin32ClientInfo()->CI_flags &= ~CI_CTFTIM; + } + } + + return hr; +} + HRESULT CtfImmTIMDestroyInputContext( _In_ HIMC hIMC) @@ -422,34 +940,34 @@ CtfImmTIMCreateInputContext( if (GetWin32ClientInfo()->CI_flags & CI_AIMMACTIVATED) { - if (!pClientImc->bUnknown4) + if (!pClientImc->bCtfIme) { dwImeThreadId = NtUserQueryInputContext(hIMC, QIC_INPUTTHREADID); dwCurrentThreadId = GetCurrentThreadId(); if (dwImeThreadId == dwCurrentThreadId) { - pClientImc->bUnknown4 = 1; + pClientImc->bCtfIme = TRUE; hr = CtfImeCreateInputContext(hIMC); - if (FAILED(hr)) - pClientImc->bUnknown4 = 0; + if (FAILED_UNEXPECTEDLY(hr)) + pClientImc->bCtfIme = FALSE; } } } else { - if (!(GetWin32ClientInfo()->CI_flags & 0x100)) + if (!(GetWin32ClientInfo()->CI_flags & CI_CTFTIM)) return S_OK; - if (!pClientImc->bUnknown4) + if (!pClientImc->bCtfIme) { dwImeThreadId = NtUserQueryInputContext(hIMC, QIC_INPUTTHREADID); dwCurrentThreadId = GetCurrentThreadId(); if ((dwImeThreadId == dwCurrentThreadId) && IS_CICERO_MODE() && !IS_16BIT_MODE()) { - pClientImc->bUnknown4 = 1; + pClientImc->bCtfIme = TRUE; hr = CtfImeCreateInputContext(hIMC); - if (FAILED(hr)) - pClientImc->bUnknown4 = 0; + if (FAILED_UNEXPECTEDLY(hr)) + pClientImc->bCtfIme = FALSE; } } } @@ -458,6 +976,19 @@ CtfImmTIMCreateInputContext( return hr; } +/*********************************************************************** + * CtfImmLastEnabledWndDestroy (IMM32.@) + * + * Same as Imm32ActivateOrDeactivateTIM but its naming is improper. + */ +HRESULT WINAPI +CtfImmLastEnabledWndDestroy( + _In_ BOOL bCreate) +{ + TRACE("(%d)\n", bCreate); + return Imm32ActivateOrDeactivateTIM(bCreate); +} + /*********************************************************************** * CtfAImmActivate (IMM32.@) * @@ -529,7 +1060,7 @@ CtfImmIsCiceroEnabled(VOID) } /*********************************************************************** - * CtfImmIsTextFrameServiceDisabled(IMM32.@) + * CtfImmIsTextFrameServiceDisabled (IMM32.@) * * @return TRUE if TSF is disabled. */ @@ -540,17 +1071,123 @@ CtfImmIsTextFrameServiceDisabled(VOID) } /*********************************************************************** - * CtfImmTIMActivate(IMM32.@) + * ImmDisableTextFrameService (IMM32.@) + */ +BOOL WINAPI +ImmDisableTextFrameService(_In_ DWORD dwThreadId) +{ + HRESULT hr = S_OK; + + TRACE("(0x%lX)\n", dwThreadId); + + if (dwThreadId == -1) + g_disable_CUAS_flag = TRUE; + + if ((dwThreadId && !g_disable_CUAS_flag) || (GetWin32ClientInfo()->CI_flags & CI_TSFDISABLED)) + return TRUE; + + GetWin32ClientInfo()->CI_flags |= CI_TSFDISABLED; + + if (IS_CICERO_MODE() && !IS_16BIT_MODE() && + (GetWin32ClientInfo()->CI_flags & CI_CTFCOINIT) && + (GetWin32ClientInfo()->CI_flags & CI_CTFTIM)) + { + hr = CtfImeDestroyThreadMgr(); + if (SUCCEEDED(hr)) + { + GetWin32ClientInfo()->CI_flags &= ~CI_CTFTIM; + CtfImmCoUninitialize(); + } + } + + return hr == S_OK; +} + +/*********************************************************************** + * CtfImmTIMActivate (IMM32.@) + * + * Activates Thread Input Manager (TIM) in the thread. */ HRESULT WINAPI CtfImmTIMActivate(_In_ HKL hKL) { - FIXME("(%p)\n", hKL); - return E_NOTIMPL; + HRESULT hr = S_OK; + + TRACE("(%p)\n", hKL); + + if (g_disable_CUAS_flag) + { + TRACE("g_disable_CUAS_flag\n"); + GetWin32ClientInfo()->CI_flags |= CI_TSFDISABLED; + return FALSE; + } + + if (GetWin32ClientInfo()->CI_flags & CI_TSFDISABLED) + { + TRACE("CI_TSFDISABLED\n"); + return FALSE; + } + + if (Imm32IsTIMDisabledInRegistry()) + { + TRACE("TIM is disabled in registry\n"); + GetWin32ClientInfo()->CI_flags |= CI_TSFDISABLED; + return FALSE; + } + + if (!Imm32IsInteractiveUserLogon() || Imm32IsRunningInMsoobe()) + { + TRACE("TIM is disabled due to LOGON or MSOBE\n"); + return FALSE; + } + + if (!Imm32IsCUASEnabledInRegistry()) + { + TRACE("CUAS is disabled in registry\n"); + GetWin32ClientInfo()->CI_flags |= CI_TSFDISABLED; + return FALSE; + } + + if (NtCurrentTeb()->ProcessEnvironmentBlock->AppCompatFlags.LowPart & 0x100) + { + TRACE("CUAS is disabled by AppCompatFlags\n"); + GetWin32ClientInfo()->CI_flags |= CI_TSFDISABLED; + return FALSE; + } + + if (RtlIsThreadWithinLoaderCallout() || Imm32InsideLoaderLock()) + { + TRACE("TIM is disabled by Loader\n"); + return FALSE; + } + + if (!IS_CICERO_MODE() || IS_16BIT_MODE()) + { + TRACE("TIM is disabled because CICERO mode is unset\n"); + return FALSE; + } + + if (IS_IME_HKL(hKL)) + hKL = (HKL)UlongToHandle(MAKELONG(LOWORD(hKL), LOWORD(hKL))); + + if (!ImmLoadIME(hKL)) + Imm32TF_InvalidAssemblyListCacheIfExist(); + + CtfImmCoInitialize(); + + if ((GetWin32ClientInfo()->CI_flags & CI_CTFCOINIT) && + !(GetWin32ClientInfo()->CI_flags & CI_CTFTIM)) + { + hr = CtfImeCreateThreadMgr(); + if (SUCCEEDED(hr)) + GetWin32ClientInfo()->CI_flags |= CI_CTFTIM; + } + + return hr; } /*********************************************************************** - * CtfImmGenerateMessage(IMM32.@) + * CtfImmGenerateMessage (IMM32.@) */ BOOL WINAPI CtfImmGenerateMessage( @@ -638,7 +1275,7 @@ CtfImmGenerateMessage( } /*********************************************************************** - * CtfImmHideToolbarWnd(IMM32.@) + * CtfImmHideToolbarWnd (IMM32.@) * * Used with CtfImmRestoreToolbarWnd. */ @@ -667,7 +1304,7 @@ CtfImmHideToolbarWnd(VOID) } /*********************************************************************** - * CtfImmRestoreToolbarWnd(IMM32.@) + * CtfImmRestoreToolbarWnd (IMM32.@) * * Used with CtfImmHideToolbarWnd. */ @@ -684,7 +1321,7 @@ CtfImmRestoreToolbarWnd( TRACE("(%p, 0x%X)\n", pUnused, dwShowFlags); hr = Imm32TF_CreateLangBarMgr(&pBarMgr); - if (FAILED(hr)) + if (FAILED_UNEXPECTEDLY(hr)) return; if (dwShowFlags) @@ -693,20 +1330,8 @@ CtfImmRestoreToolbarWnd( pBarMgr->lpVtbl->Release(pBarMgr); } -BOOL Imm32InsideLoaderLock(VOID) -{ - return (NtCurrentTeb()->ProcessEnvironmentBlock->LoaderLock->OwningThread == - NtCurrentTeb()->ClientId.UniqueThread); -} - -/* FIXME: Use RTL */ -BOOL WINAPI RtlDllShutdownInProgress(VOID) -{ - return FALSE; -} - /*********************************************************************** - * CtfImmDispatchDefImeMessage(IMM32.@) + * CtfImmDispatchDefImeMessage (IMM32.@) */ LRESULT WINAPI CtfImmDispatchDefImeMessage( @@ -724,7 +1349,7 @@ CtfImmDispatchDefImeMessage( } /*********************************************************************** - * CtfImmIsGuidMapEnable(IMM32.@) + * CtfImmIsGuidMapEnable (IMM32.@) */ BOOL WINAPI CtfImmIsGuidMapEnable( @@ -757,7 +1382,7 @@ CtfImmIsGuidMapEnable( } /*********************************************************************** - * CtfImmGetGuidAtom(IMM32.@) + * CtfImmGetGuidAtom (IMM32.@) */ HRESULT WINAPI CtfImmGetGuidAtom( diff --git a/dll/win32/imm32/imm.c b/dll/win32/imm32/imm.c index 39d4cd3b1ef..5723fde1a59 100644 --- a/dll/win32/imm32/imm.c +++ b/dll/win32/imm32/imm.c @@ -1103,15 +1103,6 @@ BOOL WINAPI ImmReleaseContext(HWND hWnd, HIMC hIMC) return TRUE; // Do nothing. This is correct. } -/*********************************************************************** -* ImmDisableTextFrameService(IMM32.@) -*/ -BOOL WINAPI ImmDisableTextFrameService(DWORD dwThreadId) -{ - FIXME("Stub\n"); - return FALSE; -} - /*********************************************************************** * ImmEnumInputContext(IMM32.@) */ diff --git a/dll/win32/imm32/imm32.spec b/dll/win32/imm32/imm32.spec index 14044ca710b..2e84d6a143c 100644 --- a/dll/win32/imm32/imm32.spec +++ b/dll/win32/imm32/imm32.spec @@ -1,7 +1,9 @@ @ stdcall CtfAImmActivate(ptr) @ stdcall CtfAImmDeactivate(long) @ stdcall CtfAImmIsIME(ptr) +@ stdcall CtfImmCoUninitialize() @ stdcall CtfImmDispatchDefImeMessage(ptr long ptr ptr) +@ stdcall CtfImmEnterCoInitCountSkipMode() @ stdcall CtfImmGenerateMessage(ptr long) @ stdcall CtfImmGetGuidAtom(ptr long ptr) @ stdcall CtfImmHideToolbarWnd() @@ -9,6 +11,8 @@ @ stdcall CtfImmIsCiceroStartedInThread() @ stdcall CtfImmIsGuidMapEnable(ptr) @ stdcall CtfImmIsTextFrameServiceDisabled() +@ stdcall CtfImmLastEnabledWndDestroy(long) +@ stdcall CtfImmLeaveCoInitCountSkipMode() @ stdcall CtfImmRestoreToolbarWnd(ptr long) @ stdcall CtfImmSetAppCompatFlags(long) @ stdcall CtfImmSetCiceroStartInThread(long) diff --git a/dll/win32/imm32/precomp.h b/dll/win32/imm32/precomp.h index 8fc4b27d4b7..3f667d1d6f5 100644 --- a/dll/win32/imm32/precomp.h +++ b/dll/win32/imm32/precomp.h @@ -112,12 +112,17 @@ BOOL WINAPI Imm32IsImcAnsi(HIMC hIMC); * --- Examine the condition, and then generate trace log if necessary. */ #ifdef NDEBUG /* on Release */ +#define FAILED_UNEXPECTEDLY(hr) (FAILED(hr)) #define IS_NULL_UNEXPECTEDLY(p) (!(p)) #define IS_ZERO_UNEXPECTEDLY(p) (!(p)) #define IS_TRUE_UNEXPECTEDLY(x) (x) #define IS_FALSE_UNEXPECTEDLY(x) (!(x)) #define IS_ERROR_UNEXPECTEDLY(x) (!(x)) #else /* on Debug */ +#define FAILED_UNEXPECTEDLY(hr) \ + (FAILED(hr) ? (ros_dbg_log(__WINE_DBCL_ERR, __wine_dbch___default, \ + __FILE__, __FUNCTION__, __LINE__, "FAILED(%s)\n", #hr), UNEXPECTED(), TRUE) \ + : FALSE) #define IS_NULL_UNEXPECTEDLY(p) \ (!(p) ? (ros_dbg_log(__WINE_DBCL_ERR, __wine_dbch___default, \ __FILE__, __FUNCTION__, __LINE__, "%s was NULL\n", #p), UNEXPECTED(), TRUE) \ @@ -192,3 +197,7 @@ BOOL Imm32StoreBitmapToBytes(HBITMAP hbm, LPBYTE pbData, DWORD cbDataMax); HRESULT CtfImmTIMCreateInputContext(_In_ HIMC hIMC); HRESULT CtfImmTIMDestroyInputContext(_In_ HIMC hIMC); +HRESULT CtfImmCoInitialize(VOID); +HRESULT CtfImeCreateThreadMgr(VOID); +HRESULT CtfImeDestroyThreadMgr(VOID); +HRESULT Imm32ActivateOrDeactivateTIM(_In_ BOOL bCreate); diff --git a/sdk/include/ddk/immdev.h b/sdk/include/ddk/immdev.h index b553838888f..e36ff688666 100644 --- a/sdk/include/ddk/immdev.h +++ b/sdk/include/ddk/immdev.h @@ -17,6 +17,8 @@ extern "C" { #endif +BOOL WINAPI ImmDisableTextFrameService(_In_ DWORD dwThreadId); + typedef struct tagSOFTKBDDATA { UINT uCount; @@ -317,7 +319,7 @@ typedef struct tagCLIENTIMC RTL_CRITICAL_SECTION cs; UINT uCodePage; HKL hKL; - BOOL bUnknown4; + BOOL bCtfIme; } CLIENTIMC, *PCLIENTIMC; #ifndef _WIN64 diff --git a/sdk/include/reactos/imm32_undoc.h b/sdk/include/reactos/imm32_undoc.h index 28039bcb857..08be32a2dcd 100644 --- a/sdk/include/reactos/imm32_undoc.h +++ b/sdk/include/reactos/imm32_undoc.h @@ -31,6 +31,10 @@ VOID WINAPI CtfImmSetAppCompatFlags(_In_ DWORD dwFlags); DWORD WINAPI CtfImmHideToolbarWnd(VOID); VOID WINAPI CtfImmRestoreToolbarWnd(_In_ LPVOID pUnused, _In_ DWORD dwShowFlags); BOOL WINAPI CtfImmGenerateMessage(_In_ HIMC hIMC, _In_ BOOL bSend); +VOID WINAPI CtfImmCoUninitialize(VOID); +VOID WINAPI CtfImmEnterCoInitCountSkipMode(VOID); +BOOL WINAPI CtfImmLeaveCoInitCountSkipMode(VOID); +HRESULT WINAPI CtfImmLastEnabledWndDestroy(_In_ BOOL bCreate); LRESULT WINAPI CtfImmDispatchDefImeMessage( diff --git a/win32ss/include/ntuser.h b/win32ss/include/ntuser.h index f501babb00a..2763b4b24cc 100644 --- a/win32ss/include/ntuser.h +++ b/win32ss/include/ntuser.h @@ -303,6 +303,8 @@ typedef struct _CALLBACKWND #define CI_CURTHPRHOOK 0x00000010 #define CI_CLASSESREGISTERED 0x00000020 #define CI_IMMACTIVATE 0x00000040 /* IMM/IME (Asian input) */ +#define CI_CTFCOINIT 0x00000080 /* Did CTF CoInitialize? */ +#define CI_CTFTIM 0x00000100 /* CTF Thread Input Manager (TIM) */ #define CI_TSFDISABLED 0x00000400 /* TSF (Text Services Framework a.k.a. Cicero) */ #define CI_AIMMACTIVATED 0x00000800 /* Active IMM (AIMM) */
1 year
1
0
0
0
[reactos] 01/01: [UMPNPMGR] Move the pnp event thread to a separate file
by Eric Kohl
https://git.reactos.org/?p=reactos.git;a=commitdiff;h=01a8288d2819b0ed92f13…
commit 01a8288d2819b0ed92f13d1aec7a962bcdcdc079 Author: Eric Kohl <eric.kohl(a)reactos.org> AuthorDate: Wed Nov 29 23:03:00 2023 +0100 Commit: Eric Kohl <eric.kohl(a)reactos.org> CommitDate: Wed Nov 29 23:03:00 2023 +0100 [UMPNPMGR] Move the pnp event thread to a separate file --- base/services/umpnpmgr/CMakeLists.txt | 1 + base/services/umpnpmgr/event.c | 194 ++++++++++++++++++++++++++++++++++ base/services/umpnpmgr/precomp.h | 10 ++ base/services/umpnpmgr/umpnpmgr.c | 157 --------------------------- 4 files changed, 205 insertions(+), 157 deletions(-) diff --git a/base/services/umpnpmgr/CMakeLists.txt b/base/services/umpnpmgr/CMakeLists.txt index 7c344f9914c..bf1142ca173 100644 --- a/base/services/umpnpmgr/CMakeLists.txt +++ b/base/services/umpnpmgr/CMakeLists.txt @@ -4,6 +4,7 @@ add_rpc_files(server ${REACTOS_SOURCE_DIR}/sdk/include/reactos/idl/pnp.idl) spec2def(umpnpmgr.dll umpnpmgr.spec ADD_IMPORTLIB) add_library(umpnpmgr MODULE + event.c install.c rpcserver.c umpnpmgr.c diff --git a/base/services/umpnpmgr/event.c b/base/services/umpnpmgr/event.c new file mode 100644 index 00000000000..678022de61b --- /dev/null +++ b/base/services/umpnpmgr/event.c @@ -0,0 +1,194 @@ +/* + * ReactOS kernel + * Copyright (C) 2005 ReactOS Team + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + */ +/* + * COPYRIGHT: See COPYING in the top level directory + * PROJECT: ReactOS kernel + * FILE: base/services/umpnpmgr/event.c + * PURPOSE: PNP Event thread + * PROGRAMMER: Eric Kohl (eric.kohl(a)reactos.org) + * Hervé Poussineau (hpoussin(a)reactos.org) + * Colin Finck (colin(a)reactos.org) + */ + +/* INCLUDES *****************************************************************/ + +#include "precomp.h" + +#define NDEBUG +#include <debug.h> + +/* FUNCTIONS *****************************************************************/ + +DWORD WINAPI +PnpEventThread(LPVOID lpParameter) +{ + PLUGPLAY_CONTROL_USER_RESPONSE_DATA ResponseData = {0, 0, 0, 0}; + DWORD dwRet = ERROR_SUCCESS; + NTSTATUS Status; + RPC_STATUS RpcStatus; + PPLUGPLAY_EVENT_BLOCK PnpEvent, NewPnpEvent; + ULONG PnpEventSize; + + UNREFERENCED_PARAMETER(lpParameter); + + PnpEventSize = 0x1000; + PnpEvent = HeapAlloc(GetProcessHeap(), 0, PnpEventSize); + if (PnpEvent == NULL) + return ERROR_OUTOFMEMORY; + + for (;;) + { + DPRINT("Calling NtGetPlugPlayEvent()\n"); + + /* Wait for the next PnP event */ + Status = NtGetPlugPlayEvent(0, 0, PnpEvent, PnpEventSize); + + /* Resize the buffer for the PnP event if it's too small */ + if (Status == STATUS_BUFFER_TOO_SMALL) + { + PnpEventSize += 0x400; + NewPnpEvent = HeapReAlloc(GetProcessHeap(), 0, PnpEvent, PnpEventSize); + if (NewPnpEvent == NULL) + { + dwRet = ERROR_OUTOFMEMORY; + break; + } + PnpEvent = NewPnpEvent; + continue; + } + + if (!NT_SUCCESS(Status)) + { + DPRINT1("NtGetPlugPlayEvent() failed (Status 0x%08lx)\n", Status); + break; + } + + /* Process the PnP event */ + DPRINT("Received PnP Event\n"); + if (UuidEqual(&PnpEvent->EventGuid, (UUID*)&GUID_DEVICE_ENUMERATED, &RpcStatus)) + { + DeviceInstallParams* Params; + DWORD len; + DWORD DeviceIdLength; + + DPRINT("Device enumerated: %S\n", PnpEvent->TargetDevice.DeviceIds); + + DeviceIdLength = lstrlenW(PnpEvent->TargetDevice.DeviceIds); + if (DeviceIdLength) + { + /* Allocate a new device-install event */ + len = FIELD_OFFSET(DeviceInstallParams, DeviceIds) + (DeviceIdLength + 1) * sizeof(WCHAR); + Params = HeapAlloc(GetProcessHeap(), 0, len); + if (Params) + { + wcscpy(Params->DeviceIds, PnpEvent->TargetDevice.DeviceIds); + + /* Queue the event (will be dequeued by DeviceInstallThread) */ + WaitForSingleObject(hDeviceInstallListMutex, INFINITE); + InsertTailList(&DeviceInstallListHead, &Params->ListEntry); + ReleaseMutex(hDeviceInstallListMutex); + + SetEvent(hDeviceInstallListNotEmpty); + } + } + } + else if (UuidEqual(&PnpEvent->EventGuid, (UUID*)&GUID_DEVICE_ARRIVAL, &RpcStatus)) + { +// DWORD dwRecipient; + + DPRINT("Device arrival: %S\n", PnpEvent->TargetDevice.DeviceIds); + +// dwRecipient = BSM_ALLDESKTOPS | BSM_APPLICATIONS; +// BroadcastSystemMessageW(BSF_POSTMESSAGE, +// &dwRecipient, +// WM_DEVICECHANGE, +// DBT_DEVNODES_CHANGED, +// 0); + SendMessageW(HWND_BROADCAST, WM_DEVICECHANGE, DBT_DEVNODES_CHANGED, 0); + } + else if (UuidEqual(&PnpEvent->EventGuid, (UUID*)&GUID_DEVICE_EJECT_VETOED, &RpcStatus)) + { + DPRINT1("Eject vetoed: %S\n", PnpEvent->TargetDevice.DeviceIds); + } + else if (UuidEqual(&PnpEvent->EventGuid, (UUID*)&GUID_DEVICE_KERNEL_INITIATED_EJECT, &RpcStatus)) + { + DPRINT1("Kernel initiated eject: %S\n", PnpEvent->TargetDevice.DeviceIds); + } + else if (UuidEqual(&PnpEvent->EventGuid, (UUID*)&GUID_DEVICE_SAFE_REMOVAL, &RpcStatus)) + { +// DWORD dwRecipient; + + DPRINT1("Safe removal: %S\n", PnpEvent->TargetDevice.DeviceIds); + +// dwRecipient = BSM_ALLDESKTOPS | BSM_APPLICATIONS; +// BroadcastSystemMessageW(BSF_POSTMESSAGE, +// &dwRecipient, +// WM_DEVICECHANGE, +// DBT_DEVNODES_CHANGED, +// 0); + SendMessageW(HWND_BROADCAST, WM_DEVICECHANGE, DBT_DEVNODES_CHANGED, 0); + } + else if (UuidEqual(&PnpEvent->EventGuid, (UUID*)&GUID_DEVICE_SURPRISE_REMOVAL, &RpcStatus)) + { +// DWORD dwRecipient; + + DPRINT1("Surprise removal: %S\n", PnpEvent->TargetDevice.DeviceIds); + +// dwRecipient = BSM_ALLDESKTOPS | BSM_APPLICATIONS; +// BroadcastSystemMessageW(BSF_POSTMESSAGE, +// &dwRecipient, +// WM_DEVICECHANGE, +// DBT_DEVNODES_CHANGED, +// 0); + SendMessageW(HWND_BROADCAST, WM_DEVICECHANGE, DBT_DEVNODES_CHANGED, 0); + } + else if (UuidEqual(&PnpEvent->EventGuid, (UUID*)&GUID_DEVICE_REMOVAL_VETOED, &RpcStatus)) + { + DPRINT1("Removal vetoed: %S\n", PnpEvent->TargetDevice.DeviceIds); + } + else if (UuidEqual(&PnpEvent->EventGuid, (UUID*)&GUID_DEVICE_REMOVE_PENDING, &RpcStatus)) + { + DPRINT1("Removal pending: %S\n", PnpEvent->TargetDevice.DeviceIds); + } + else + { + DPRINT1("Unknown event, GUID {%08X-%04X-%04X-%02X%02X-%02X%02X%02X%02X%02X%02X}\n", + PnpEvent->EventGuid.Data1, PnpEvent->EventGuid.Data2, PnpEvent->EventGuid.Data3, + PnpEvent->EventGuid.Data4[0], PnpEvent->EventGuid.Data4[1], PnpEvent->EventGuid.Data4[2], + PnpEvent->EventGuid.Data4[3], PnpEvent->EventGuid.Data4[4], PnpEvent->EventGuid.Data4[5], + PnpEvent->EventGuid.Data4[6], PnpEvent->EventGuid.Data4[7]); + } + + /* Dequeue the current PnP event and signal the next one */ + Status = NtPlugPlayControl(PlugPlayControlUserResponse, + &ResponseData, + sizeof(ResponseData)); + if (!NT_SUCCESS(Status)) + { + DPRINT1("NtPlugPlayControl(PlugPlayControlUserResponse) failed (Status 0x%08lx)\n", Status); + break; + } + } + + HeapFree(GetProcessHeap(), 0, PnpEvent); + + return dwRet; +} + +/* EOF */ diff --git a/base/services/umpnpmgr/precomp.h b/base/services/umpnpmgr/precomp.h index 7977db7b568..0720b177c87 100644 --- a/base/services/umpnpmgr/precomp.h +++ b/base/services/umpnpmgr/precomp.h @@ -45,6 +45,14 @@ typedef struct PWSTR pszName; } NOTIFY_ENTRY, *PNOTIFY_ENTRY; +/* event.c */ + +DWORD +WINAPI +PnpEventThread( + LPVOID lpParameter); + + /* install.c */ extern HANDLE hUserToken; @@ -67,6 +75,8 @@ DeviceInstallThread( /* rpcserver.c */ +extern LIST_ENTRY NotificationListHead; + DWORD WINAPI RpcServerThread( diff --git a/base/services/umpnpmgr/umpnpmgr.c b/base/services/umpnpmgr/umpnpmgr.c index 67ba42fe82d..14b7c1a9e6f 100644 --- a/base/services/umpnpmgr/umpnpmgr.c +++ b/base/services/umpnpmgr/umpnpmgr.c @@ -47,163 +47,6 @@ BOOL g_IsUISuppressed = FALSE; /* FUNCTIONS *****************************************************************/ -static DWORD WINAPI -PnpEventThread(LPVOID lpParameter) -{ - PLUGPLAY_CONTROL_USER_RESPONSE_DATA ResponseData = {0, 0, 0, 0}; - DWORD dwRet = ERROR_SUCCESS; - NTSTATUS Status; - RPC_STATUS RpcStatus; - PPLUGPLAY_EVENT_BLOCK PnpEvent, NewPnpEvent; - ULONG PnpEventSize; - - UNREFERENCED_PARAMETER(lpParameter); - - PnpEventSize = 0x1000; - PnpEvent = HeapAlloc(GetProcessHeap(), 0, PnpEventSize); - if (PnpEvent == NULL) - return ERROR_OUTOFMEMORY; - - for (;;) - { - DPRINT("Calling NtGetPlugPlayEvent()\n"); - - /* Wait for the next PnP event */ - Status = NtGetPlugPlayEvent(0, 0, PnpEvent, PnpEventSize); - - /* Resize the buffer for the PnP event if it's too small */ - if (Status == STATUS_BUFFER_TOO_SMALL) - { - PnpEventSize += 0x400; - NewPnpEvent = HeapReAlloc(GetProcessHeap(), 0, PnpEvent, PnpEventSize); - if (NewPnpEvent == NULL) - { - dwRet = ERROR_OUTOFMEMORY; - break; - } - PnpEvent = NewPnpEvent; - continue; - } - - if (!NT_SUCCESS(Status)) - { - DPRINT1("NtGetPlugPlayEvent() failed (Status 0x%08lx)\n", Status); - break; - } - - /* Process the PnP event */ - DPRINT("Received PnP Event\n"); - if (UuidEqual(&PnpEvent->EventGuid, (UUID*)&GUID_DEVICE_ENUMERATED, &RpcStatus)) - { - DeviceInstallParams* Params; - DWORD len; - DWORD DeviceIdLength; - - DPRINT("Device enumerated: %S\n", PnpEvent->TargetDevice.DeviceIds); - - DeviceIdLength = lstrlenW(PnpEvent->TargetDevice.DeviceIds); - if (DeviceIdLength) - { - /* Allocate a new device-install event */ - len = FIELD_OFFSET(DeviceInstallParams, DeviceIds) + (DeviceIdLength + 1) * sizeof(WCHAR); - Params = HeapAlloc(GetProcessHeap(), 0, len); - if (Params) - { - wcscpy(Params->DeviceIds, PnpEvent->TargetDevice.DeviceIds); - - /* Queue the event (will be dequeued by DeviceInstallThread) */ - WaitForSingleObject(hDeviceInstallListMutex, INFINITE); - InsertTailList(&DeviceInstallListHead, &Params->ListEntry); - ReleaseMutex(hDeviceInstallListMutex); - - SetEvent(hDeviceInstallListNotEmpty); - } - } - } - else if (UuidEqual(&PnpEvent->EventGuid, (UUID*)&GUID_DEVICE_ARRIVAL, &RpcStatus)) - { -// DWORD dwRecipient; - - DPRINT("Device arrival: %S\n", PnpEvent->TargetDevice.DeviceIds); - -// dwRecipient = BSM_ALLDESKTOPS | BSM_APPLICATIONS; -// BroadcastSystemMessageW(BSF_POSTMESSAGE, -// &dwRecipient, -// WM_DEVICECHANGE, -// DBT_DEVNODES_CHANGED, -// 0); - SendMessageW(HWND_BROADCAST, WM_DEVICECHANGE, DBT_DEVNODES_CHANGED, 0); - } - else if (UuidEqual(&PnpEvent->EventGuid, (UUID*)&GUID_DEVICE_EJECT_VETOED, &RpcStatus)) - { - DPRINT1("Eject vetoed: %S\n", PnpEvent->TargetDevice.DeviceIds); - } - else if (UuidEqual(&PnpEvent->EventGuid, (UUID*)&GUID_DEVICE_KERNEL_INITIATED_EJECT, &RpcStatus)) - { - DPRINT1("Kernel initiated eject: %S\n", PnpEvent->TargetDevice.DeviceIds); - } - else if (UuidEqual(&PnpEvent->EventGuid, (UUID*)&GUID_DEVICE_SAFE_REMOVAL, &RpcStatus)) - { -// DWORD dwRecipient; - - DPRINT1("Safe removal: %S\n", PnpEvent->TargetDevice.DeviceIds); - -// dwRecipient = BSM_ALLDESKTOPS | BSM_APPLICATIONS; -// BroadcastSystemMessageW(BSF_POSTMESSAGE, -// &dwRecipient, -// WM_DEVICECHANGE, -// DBT_DEVNODES_CHANGED, -// 0); - SendMessageW(HWND_BROADCAST, WM_DEVICECHANGE, DBT_DEVNODES_CHANGED, 0); - } - else if (UuidEqual(&PnpEvent->EventGuid, (UUID*)&GUID_DEVICE_SURPRISE_REMOVAL, &RpcStatus)) - { -// DWORD dwRecipient; - - DPRINT1("Surprise removal: %S\n", PnpEvent->TargetDevice.DeviceIds); - -// dwRecipient = BSM_ALLDESKTOPS | BSM_APPLICATIONS; -// BroadcastSystemMessageW(BSF_POSTMESSAGE, -// &dwRecipient, -// WM_DEVICECHANGE, -// DBT_DEVNODES_CHANGED, -// 0); - SendMessageW(HWND_BROADCAST, WM_DEVICECHANGE, DBT_DEVNODES_CHANGED, 0); - } - else if (UuidEqual(&PnpEvent->EventGuid, (UUID*)&GUID_DEVICE_REMOVAL_VETOED, &RpcStatus)) - { - DPRINT1("Removal vetoed: %S\n", PnpEvent->TargetDevice.DeviceIds); - } - else if (UuidEqual(&PnpEvent->EventGuid, (UUID*)&GUID_DEVICE_REMOVE_PENDING, &RpcStatus)) - { - DPRINT1("Removal pending: %S\n", PnpEvent->TargetDevice.DeviceIds); - } - else - { - DPRINT1("Unknown event, GUID {%08X-%04X-%04X-%02X%02X-%02X%02X%02X%02X%02X%02X}\n", - PnpEvent->EventGuid.Data1, PnpEvent->EventGuid.Data2, PnpEvent->EventGuid.Data3, - PnpEvent->EventGuid.Data4[0], PnpEvent->EventGuid.Data4[1], PnpEvent->EventGuid.Data4[2], - PnpEvent->EventGuid.Data4[3], PnpEvent->EventGuid.Data4[4], PnpEvent->EventGuid.Data4[5], - PnpEvent->EventGuid.Data4[6], PnpEvent->EventGuid.Data4[7]); - } - - /* Dequeue the current PnP event and signal the next one */ - Status = NtPlugPlayControl(PlugPlayControlUserResponse, - &ResponseData, - sizeof(ResponseData)); - if (!NT_SUCCESS(Status)) - { - DPRINT1("NtPlugPlayControl(PlugPlayControlUserResponse) failed (Status 0x%08lx)\n", Status); - break; - } - } - - HeapFree(GetProcessHeap(), 0, PnpEvent); - - return dwRet; -} - - static VOID UpdateServiceStatus( _In_ DWORD dwState,
1 year
1
0
0
0
[reactos] 01/01: [BOOTDATA] Add explicit value types as we do for the others.
by Hermès Bélusca-Maïto
https://git.reactos.org/?p=reactos.git;a=commitdiff;h=8ed5151d337367d65a394…
commit 8ed5151d337367d65a39483124d0db5d23445013 Author: Hermès Bélusca-Maïto <hermes.belusca-maito(a)reactos.org> AuthorDate: Wed Nov 29 19:02:28 2023 +0100 Commit: Hermès Bélusca-Maïto <hermes.belusca-maito(a)reactos.org> CommitDate: Wed Nov 29 19:02:38 2023 +0100 [BOOTDATA] Add explicit value types as we do for the others. Addendum to commit fce106ab2. --- boot/bootdata/hivesft.inf | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/boot/bootdata/hivesft.inf b/boot/bootdata/hivesft.inf index 1a468d375a0..2d4854ea0cd 100644 --- a/boot/bootdata/hivesft.inf +++ b/boot/bootdata/hivesft.inf @@ -103,12 +103,12 @@ HKLM,"SOFTWARE\Classes\Applications\mplay32.exe\SupportedTypes",".avi",0x0000000 HKLM,"SOFTWARE\Classes\ftp","",0x00000000,"URL:File Transfer Protocol" HKLM,"SOFTWARE\Classes\ftp\Source Filter","",0x00000000,"{E436EBB6-524F-11CE-9F53-0020AF0BA770}" -HKLM,"SOFTWARE\Classes\ftp","URL Protocol",,"" +HKLM,"SOFTWARE\Classes\ftp","URL Protocol",0x00000000,"" HKLM,"SOFTWARE\Classes\ftp\shell\open\command","",0x00000000,"""%programfiles%\Internet Explorer\iexplore.exe"" ""%1""" HKLM,"SOFTWARE\Classes\gopher","",0x00000000,"URL:Gopher Protocol" HKLM,"SOFTWARE\Classes\gopher\Source Filter","",0x00000000,"{E436EBB6-524F-11CE-9F53-0020AF0BA770}" -HKLM,"SOFTWARE\Classes\gopher","URL Protocol",,"" +HKLM,"SOFTWARE\Classes\gopher","URL Protocol",0x00000000,"" ;see http ;HKLM,"SOFTWARE\Classes\gopher\shell\open\command","",0x00000000,"""%programfiles%\Internet Explorer\iexplore.exe"" -nohome" HKLM,"SOFTWARE\Classes\gopher\shell\open\command","",0x00000000,"""%programfiles%\Internet Explorer\iexplore.exe"" ""%1""" @@ -116,7 +116,7 @@ HKLM,"SOFTWARE\Classes\gopher\shell\open\command","",0x00000000,"""%programfiles HKLM,"SOFTWARE\Classes\http","",0x00000000,"URL:HyperText Transfer Protocol" HKLM,"SOFTWARE\Classes\http\DefaultIcon","",0x00000000,"%SystemRoot%\system32\url.dll,0" HKLM,"SOFTWARE\Classes\http\Source Filter","",0x00000000,"{E436EBB6-524F-11CE-9F53-0020AF0BA770}" -HKLM,"SOFTWARE\Classes\http","URL Protocol",,"" +HKLM,"SOFTWARE\Classes\http","URL Protocol",0x00000000,"" HKLM,"SOFTWARE\Classes\http\shell\open\command","",0x00000000,"""%programfiles%\Internet Explorer\iexplore.exe"" ""%1""" ;TODO : iexplore should use DDE ;HKLM,"SOFTWARE\Classes\http\shell\open\ddeexec","",0x00000000,"""%1"",,-1,0,,,," @@ -127,7 +127,7 @@ HKLM,"SOFTWARE\Classes\http\shell\open\command","",0x00000000,"""%programfiles%\ HKLM,"SOFTWARE\Classes\https","",0x00000000,"URL:HyperText Transfer Protocol with Privacy" HKLM,"SOFTWARE\Classes\https\DefaultIcon","",0x00000000,"%SystemRoot%\system32\url.dll,0" HKLM,"SOFTWARE\Classes\https\Source Filter","",0x00000000,"{E436EBB6-524F-11CE-9F53-0020AF0BA770}" -HKLM,"SOFTWARE\Classes\https","URL Protocol",,"" +HKLM,"SOFTWARE\Classes\https","URL Protocol",0x00000000,"" ;see http ;HKLM,"SOFTWARE\Classes\https\shell\open\command","",0x00000000,"""%programfiles%\Internet Explorer\iexplore.exe"" -nohome" HKLM,"SOFTWARE\Classes\https\shell\open\command","",0x00000000,"""%programfiles%\Internet Explorer\iexplore.exe"" ""%1"""
1 year
1
0
0
0
[reactos] 01/01: [BOOTDATA] hivesft: Fix URL Protocol registry value (#6058)
by Whindmar Saksit
https://git.reactos.org/?p=reactos.git;a=commitdiff;h=fce106ab2595884a3e63f…
commit fce106ab2595884a3e63f5f24ac526ffe73d419c Author: Whindmar Saksit <whindsaks(a)proton.me> AuthorDate: Wed Nov 29 18:40:19 2023 +0100 Commit: GitHub <noreply(a)github.com> CommitDate: Wed Nov 29 20:40:19 2023 +0300 [BOOTDATA] hivesft: Fix URL Protocol registry value (#6058) "URL Protocol" is a registry value, not a key! IEFrame later comes along and adds the value covering up the issue for everyone except poor gopher. --- boot/bootdata/hivesft.inf | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/boot/bootdata/hivesft.inf b/boot/bootdata/hivesft.inf index e45880375de..1a468d375a0 100644 --- a/boot/bootdata/hivesft.inf +++ b/boot/bootdata/hivesft.inf @@ -103,12 +103,12 @@ HKLM,"SOFTWARE\Classes\Applications\mplay32.exe\SupportedTypes",".avi",0x0000000 HKLM,"SOFTWARE\Classes\ftp","",0x00000000,"URL:File Transfer Protocol" HKLM,"SOFTWARE\Classes\ftp\Source Filter","",0x00000000,"{E436EBB6-524F-11CE-9F53-0020AF0BA770}" -HKLM,"SOFTWARE\Classes\ftp\URL Protocol","",0x00000000,"" +HKLM,"SOFTWARE\Classes\ftp","URL Protocol",,"" HKLM,"SOFTWARE\Classes\ftp\shell\open\command","",0x00000000,"""%programfiles%\Internet Explorer\iexplore.exe"" ""%1""" HKLM,"SOFTWARE\Classes\gopher","",0x00000000,"URL:Gopher Protocol" HKLM,"SOFTWARE\Classes\gopher\Source Filter","",0x00000000,"{E436EBB6-524F-11CE-9F53-0020AF0BA770}" -HKLM,"SOFTWARE\Classes\gopher\URL Protocol","",0x00000000,"" +HKLM,"SOFTWARE\Classes\gopher","URL Protocol",,"" ;see http ;HKLM,"SOFTWARE\Classes\gopher\shell\open\command","",0x00000000,"""%programfiles%\Internet Explorer\iexplore.exe"" -nohome" HKLM,"SOFTWARE\Classes\gopher\shell\open\command","",0x00000000,"""%programfiles%\Internet Explorer\iexplore.exe"" ""%1""" @@ -116,7 +116,7 @@ HKLM,"SOFTWARE\Classes\gopher\shell\open\command","",0x00000000,"""%programfiles HKLM,"SOFTWARE\Classes\http","",0x00000000,"URL:HyperText Transfer Protocol" HKLM,"SOFTWARE\Classes\http\DefaultIcon","",0x00000000,"%SystemRoot%\system32\url.dll,0" HKLM,"SOFTWARE\Classes\http\Source Filter","",0x00000000,"{E436EBB6-524F-11CE-9F53-0020AF0BA770}" -HKLM,"SOFTWARE\Classes\http\URL Protocol","",0x00000000,"" +HKLM,"SOFTWARE\Classes\http","URL Protocol",,"" HKLM,"SOFTWARE\Classes\http\shell\open\command","",0x00000000,"""%programfiles%\Internet Explorer\iexplore.exe"" ""%1""" ;TODO : iexplore should use DDE ;HKLM,"SOFTWARE\Classes\http\shell\open\ddeexec","",0x00000000,"""%1"",,-1,0,,,," @@ -127,7 +127,7 @@ HKLM,"SOFTWARE\Classes\http\shell\open\command","",0x00000000,"""%programfiles%\ HKLM,"SOFTWARE\Classes\https","",0x00000000,"URL:HyperText Transfer Protocol with Privacy" HKLM,"SOFTWARE\Classes\https\DefaultIcon","",0x00000000,"%SystemRoot%\system32\url.dll,0" HKLM,"SOFTWARE\Classes\https\Source Filter","",0x00000000,"{E436EBB6-524F-11CE-9F53-0020AF0BA770}" -HKLM,"SOFTWARE\Classes\https\URL Protocol","",0x00000000,"" +HKLM,"SOFTWARE\Classes\https","URL Protocol",,"" ;see http ;HKLM,"SOFTWARE\Classes\https\shell\open\command","",0x00000000,"""%programfiles%\Internet Explorer\iexplore.exe"" -nohome" HKLM,"SOFTWARE\Classes\https\shell\open\command","",0x00000000,"""%programfiles%\Internet Explorer\iexplore.exe"" ""%1"""
1 year
1
0
0
0
[reactos] 01/01: [SHELL32][SHELL32_APITEST][SDK] Implement PathIsEqualOrSubFolder (#5714)
by Katayama Hirofumi MZ
https://git.reactos.org/?p=reactos.git;a=commitdiff;h=2aeda3dc159a1b175a488…
commit 2aeda3dc159a1b175a48876c0aee8a8a5b2c9574 Author: Katayama Hirofumi MZ <katayama.hirofumi.mz(a)gmail.com> AuthorDate: Wed Nov 29 22:50:01 2023 +0900 Commit: GitHub <noreply(a)github.com> CommitDate: Wed Nov 29 22:50:01 2023 +0900 [SHELL32][SHELL32_APITEST][SDK] Implement PathIsEqualOrSubFolder (#5714) Implement PathIsEqualOrSubFolder function. - Add it to <undocshell.h>. - Add PathIsEqualOrSubFolder testcase. - Add SHGetPathCchFromIDListW as an extension of SHGetPathFromIDListW. CORE-19278 --- dll/win32/shell32/stubs.cpp | 8 -- dll/win32/shell32/utils.cpp | 116 +++++++++++++++++++++ dll/win32/shell32/wine/pidl.c | 31 ++++-- modules/rostests/apitests/shell32/CMakeLists.txt | 1 + .../apitests/shell32/PathIsEqualOrSubFolder.cpp | 41 ++++++++ modules/rostests/apitests/shell32/testlist.c | 2 + sdk/include/reactos/undocshell.h | 2 + 7 files changed, 183 insertions(+), 18 deletions(-) diff --git a/dll/win32/shell32/stubs.cpp b/dll/win32/shell32/stubs.cpp index 91e8ae00beb..118e1c1f670 100644 --- a/dll/win32/shell32/stubs.cpp +++ b/dll/win32/shell32/stubs.cpp @@ -17,14 +17,6 @@ WINE_DEFAULT_DEBUG_CHANNEL(shell); /* * Unimplemented */ -EXTERN_C BOOL -WINAPI -PathIsEqualOrSubFolder(LPWSTR lpFolder, LPWSTR lpSubFolder) -{ - FIXME("PathIsEqualOrSubFolder() stub\n"); - return FALSE; -} - EXTERN_C HRESULT WINAPI SHGetUnreadMailCountW(HKEY hKeyUser, diff --git a/dll/win32/shell32/utils.cpp b/dll/win32/shell32/utils.cpp index 1e7cfbe28ac..9f9309b645c 100644 --- a/dll/win32/shell32/utils.cpp +++ b/dll/win32/shell32/utils.cpp @@ -747,3 +747,119 @@ SHStartNetConnectionDialogA( return SHStartNetConnectionDialogW(hwnd, pszRemoteNameW, dwType); } + +/************************************************************************* + * Helper functions for PathIsEqualOrSubFolder + */ + +static INT +DynamicPathCommonPrefixW( + _In_ LPCWSTR lpszPath1, + _In_ LPCWSTR lpszPath2, + _Out_ CStringW& strPath) +{ + SIZE_T cchPath1 = wcslen(lpszPath1); + SIZE_T cchPath2 = wcslen(lpszPath2); + LPWSTR lpszPath = strPath.GetBuffer((INT)max(cchPath1, cchPath2) + 16); + INT ret = PathCommonPrefixW(lpszPath1, lpszPath2, lpszPath); + strPath.ReleaseBuffer(); + return ret; +} + +EXTERN_C HRESULT WINAPI +SHGetPathCchFromIDListW(LPCITEMIDLIST pidl, LPWSTR pszPath, SIZE_T cchPathMax); + +static HRESULT +DynamicSHGetPathFromIDListW( + _In_ LPCITEMIDLIST pidl, + _Out_ CStringW& strPath) +{ + HRESULT hr; + + for (UINT cchPath = MAX_PATH;; cchPath *= 2) + { + LPWSTR lpszPath = strPath.GetBuffer(cchPath); + if (!lpszPath) + return E_OUTOFMEMORY; + + hr = SHGetPathCchFromIDListW(pidl, lpszPath, cchPath); + strPath.ReleaseBuffer(); + + if (hr != E_NOT_SUFFICIENT_BUFFER) + break; + + if (cchPath >= MAXUINT / 2) + { + hr = E_FAIL; + break; + } + } + + if (FAILED(hr)) + strPath.Empty(); + + return hr; +} + +static HRESULT +DynamicSHGetSpecialFolderPathW( + _In_ HWND hwndOwner, + _Out_ CStringW& strPath, + _In_ INT nCSIDL, + _In_ BOOL bCreate) +{ + LPITEMIDLIST pidl; + HRESULT hr = SHGetSpecialFolderLocation(hwndOwner, nCSIDL, &pidl); + if (SUCCEEDED(hr)) + { + hr = DynamicSHGetPathFromIDListW(pidl, strPath); + CoTaskMemFree(pidl); + } + + if (FAILED(hr)) + strPath.Empty(); + else if (bCreate) + CreateDirectoryW(strPath, NULL); + + return hr; +} + +static VOID +DynamicPathRemoveBackslashW( + _Out_ CStringW& strPath) +{ + INT nLength = strPath.GetLength(); + if (nLength > 0 && strPath[nLength - 1] == L'\\') + strPath = strPath.Left(nLength - 1); +} + +/************************************************************************* + * PathIsEqualOrSubFolder (SHELL32.755) + */ +EXTERN_C +BOOL WINAPI +PathIsEqualOrSubFolder( + _In_ LPCWSTR pszPath1OrCSIDL, + _In_ LPCWSTR pszPath2) +{ + CStringW strCommon, strPath1; + + TRACE("(%s %s)\n", debugstr_w(pszPath1OrCSIDL), debugstr_w(pszPath2)); + + if (IS_INTRESOURCE(pszPath1OrCSIDL)) + { + DynamicSHGetSpecialFolderPathW( + NULL, strPath1, LOWORD(pszPath1OrCSIDL) | CSIDL_FLAG_DONT_VERIFY, FALSE); + } + else + { + strPath1 = pszPath1OrCSIDL; + } + + DynamicPathRemoveBackslashW(strPath1); + + if (!DynamicPathCommonPrefixW(strPath1, pszPath2, strCommon)) + return FALSE; + + return strPath1.CompareNoCase(strCommon) == 0; +} diff --git a/dll/win32/shell32/wine/pidl.c b/dll/win32/shell32/wine/pidl.c index 9ade43d1956..7279737c8eb 100644 --- a/dll/win32/shell32/wine/pidl.c +++ b/dll/win32/shell32/wine/pidl.c @@ -1295,7 +1295,11 @@ BOOL WINAPI SHGetPathFromIDListA(LPCITEMIDLIST pidl, LPSTR pszPath) * * See SHGetPathFromIDListA. */ -BOOL WINAPI SHGetPathFromIDListW(LPCITEMIDLIST pidl, LPWSTR pszPath) +HRESULT WINAPI +SHGetPathCchFromIDListW( + _In_ LPCITEMIDLIST pidl, + _Out_writes_(cchPathMax) LPWSTR pszPath, + _In_ SIZE_T cchPathMax) { HRESULT hr; LPCITEMIDLIST pidlLast; @@ -1306,33 +1310,40 @@ BOOL WINAPI SHGetPathFromIDListW(LPCITEMIDLIST pidl, LPWSTR pszPath) TRACE_(shell)("(pidl=%p,%p)\n", pidl, pszPath); pdump(pidl); - *pszPath = '\0'; + *pszPath = UNICODE_NULL; if (!pidl) - return FALSE; + return E_FAIL; hr = SHBindToParent(pidl, &IID_IShellFolder, (VOID**)&psfFolder, &pidlLast); if (FAILED(hr)) { ERR("SHBindToParent failed: %x\n", hr); - return FALSE; + return hr; } dwAttributes = SFGAO_FILESYSTEM; hr = IShellFolder_GetAttributesOf(psfFolder, 1, &pidlLast, &dwAttributes); - if (FAILED(hr) || !(dwAttributes & SFGAO_FILESYSTEM)) { + if (FAILED(hr) || !(dwAttributes & SFGAO_FILESYSTEM)) + { WARN("Wrong dwAttributes or GetAttributesOf failed: %x\n", hr); IShellFolder_Release(psfFolder); - return FALSE; + return E_FAIL; } - + hr = IShellFolder_GetDisplayNameOf(psfFolder, pidlLast, SHGDN_FORPARSING, &strret); IShellFolder_Release(psfFolder); - if (FAILED(hr)) return FALSE; + if (FAILED(hr)) + return hr; - hr = StrRetToBufW(&strret, pidlLast, pszPath, MAX_PATH); + hr = StrRetToBufW(&strret, pidlLast, pszPath, cchPathMax); TRACE_(shell)("-- %s, 0x%08x\n",debugstr_w(pszPath), hr); - return SUCCEEDED(hr); + return hr; +} + +BOOL WINAPI SHGetPathFromIDListW(LPCITEMIDLIST pidl, LPWSTR pszPath) +{ + return SUCCEEDED(SHGetPathCchFromIDListW(pidl, pszPath, MAX_PATH)); } /************************************************************************* diff --git a/modules/rostests/apitests/shell32/CMakeLists.txt b/modules/rostests/apitests/shell32/CMakeLists.txt index 07ba4a96ca6..82c1eeea279 100644 --- a/modules/rostests/apitests/shell32/CMakeLists.txt +++ b/modules/rostests/apitests/shell32/CMakeLists.txt @@ -19,6 +19,7 @@ list(APPEND SOURCE Int64ToString.cpp IShellFolderViewCB.cpp OpenAs_RunDLL.cpp + PathIsEqualOrSubFolder.cpp PathResolve.cpp SHAppBarMessage.cpp SHChangeNotify.cpp diff --git a/modules/rostests/apitests/shell32/PathIsEqualOrSubFolder.cpp b/modules/rostests/apitests/shell32/PathIsEqualOrSubFolder.cpp new file mode 100644 index 00000000000..59701738e3e --- /dev/null +++ b/modules/rostests/apitests/shell32/PathIsEqualOrSubFolder.cpp @@ -0,0 +1,41 @@ +/* + * PROJECT: ReactOS API Tests + * LICENSE: GPL-2.0-or-later (
https://spdx.org/licenses/GPL-2.0-or-later
) + * PURPOSE: Tests for PathIsEqualOrSubFolder + * COPYRIGHT: Copyright 2023 Katayama Hirofumi MZ <katayama.hirofumi.mz(a)gmail.com> + */ + +#include "shelltest.h" +#include <undocshell.h> + +START_TEST(PathIsEqualOrSubFolder) +{ + ok_int(PathIsEqualOrSubFolder(L"C:", L"C:"), TRUE); + ok_int(PathIsEqualOrSubFolder(L"C:", L"C:\\"), TRUE); + ok_int(PathIsEqualOrSubFolder(L"C:\\", L"C:"), TRUE); + ok_int(PathIsEqualOrSubFolder(L"C:\\", L"C:\\"), TRUE); + ok_int(PathIsEqualOrSubFolder(L"C:\\", L"C:\\TestTestTest"), TRUE); + ok_int(PathIsEqualOrSubFolder(L"C:\\TestTestTest", L"C:\\"), FALSE); + ok_int(PathIsEqualOrSubFolder(L"C:\\TestTestTest", L"C:\\TestTestTest"), TRUE); + ok_int(PathIsEqualOrSubFolder(L"C:\\TestTestTest", L"C:\\TestTestTest\\"), TRUE); + + WCHAR szPath1[MAX_PATH], szPath2[MAX_PATH]; + + GetWindowsDirectoryW(szPath1, _countof(szPath1)); + ok_int(PathIsEqualOrSubFolder(szPath1, szPath1), TRUE); + + GetWindowsDirectoryW(szPath2, _countof(szPath2)); + PathAppendW(szPath2, L"TestTestTest"); + + ok_int(PathIsEqualOrSubFolder(szPath1, szPath2), TRUE); + ok_int(PathIsEqualOrSubFolder(szPath2, szPath1), FALSE); + ok_int(PathIsEqualOrSubFolder(szPath2, szPath2), TRUE); + + GetTempPathW(_countof(szPath1), szPath1); + GetTempPathW(_countof(szPath2), szPath2); + PathAppendW(szPath2, L"TestTestTest"); + + ok_int(PathIsEqualOrSubFolder(szPath1, szPath2), TRUE); + ok_int(PathIsEqualOrSubFolder(szPath2, szPath1), FALSE); + ok_int(PathIsEqualOrSubFolder(szPath2, szPath2), TRUE); +} diff --git a/modules/rostests/apitests/shell32/testlist.c b/modules/rostests/apitests/shell32/testlist.c index 424e878d3b9..1a4952cfc17 100644 --- a/modules/rostests/apitests/shell32/testlist.c +++ b/modules/rostests/apitests/shell32/testlist.c @@ -21,6 +21,7 @@ extern void func_Int64ToString(void); extern void func_IShellFolderViewCB(void); extern void func_menu(void); extern void func_OpenAs_RunDLL(void); +extern void func_PathIsEqualOrSubFolder(void); extern void func_PathResolve(void); extern void func_SHAppBarMessage(void); extern void func_SHChangeNotify(void); @@ -57,6 +58,7 @@ const struct test winetest_testlist[] = { "IShellFolderViewCB", func_IShellFolderViewCB }, { "menu", func_menu }, { "OpenAs_RunDLL", func_OpenAs_RunDLL }, + { "PathIsEqualOrSubFolder", func_PathIsEqualOrSubFolder }, { "PathResolve", func_PathResolve }, { "SHAppBarMessage", func_SHAppBarMessage }, { "SHChangeNotify", func_SHChangeNotify }, diff --git a/sdk/include/reactos/undocshell.h b/sdk/include/reactos/undocshell.h index 8fad6faa6a8..b768552f708 100644 --- a/sdk/include/reactos/undocshell.h +++ b/sdk/include/reactos/undocshell.h @@ -498,6 +498,8 @@ BOOL WINAPI PathIsSameRootAW(LPCVOID lpszPath1, LPCVOID lpszPath2); BOOL WINAPI PathFindOnPathAW(LPVOID sFile, LPCVOID *sOtherDirs); +BOOL WINAPI PathIsEqualOrSubFolder(_In_ LPCWSTR pszFile1OrCSIDL, _In_ LPCWSTR pszFile2); + /**************************************************************************** * Shell File Operations error codes - SHFileOperationA/W */
1 year
1
0
0
0
[reactos] 01/01: [PORTCLS] Don't repeat "PORTCLS" module name in version info
by Thamatip Chitpong
https://git.reactos.org/?p=reactos.git;a=commitdiff;h=ea8a49d81fe6ee8f86fc8…
commit ea8a49d81fe6ee8f86fc82dd2b430ac7a2ab0f1c Author: Thamatip Chitpong <thamatip.chitpong(a)reactos.org> AuthorDate: Wed Nov 29 10:31:14 2023 +0700 Commit: GitHub <noreply(a)github.com> CommitDate: Wed Nov 29 10:31:14 2023 +0700 [PORTCLS] Don't repeat "PORTCLS" module name in version info --- drivers/wdm/audio/backpln/portcls/portcls.rc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/wdm/audio/backpln/portcls/portcls.rc b/drivers/wdm/audio/backpln/portcls/portcls.rc index be7c8530968..34e51fd5792 100644 --- a/drivers/wdm/audio/backpln/portcls/portcls.rc +++ b/drivers/wdm/audio/backpln/portcls/portcls.rc @@ -1,5 +1,5 @@ #define REACTOS_VERSION_DLL -#define REACTOS_STR_FILE_DESCRIPTION "PORTCLS Port Class Driver API" +#define REACTOS_STR_FILE_DESCRIPTION "Port Class Driver API" #define REACTOS_STR_INTERNAL_NAME "portcls" #define REACTOS_STR_ORIGINAL_FILENAME "portcls.sys" #include <reactos/version.rc>
1 year
1
0
0
0
[reactos] 01/01: [WS2HELP] Add ws2help.rc to CMakeLists (#6055)
by Thamatip Chitpong
https://git.reactos.org/?p=reactos.git;a=commitdiff;h=82e81b23428854356f1d6…
commit 82e81b23428854356f1d60e142fc22e633801f7a Author: Thamatip Chitpong <thamatip.chitpong(a)reactos.org> AuthorDate: Wed Nov 29 07:03:28 2023 +0700 Commit: GitHub <noreply(a)github.com> CommitDate: Wed Nov 29 07:03:28 2023 +0700 [WS2HELP] Add ws2help.rc to CMakeLists (#6055) Fix missing dll version info --- dll/win32/ws2help/CMakeLists.txt | 1 + 1 file changed, 1 insertion(+) diff --git a/dll/win32/ws2help/CMakeLists.txt b/dll/win32/ws2help/CMakeLists.txt index 00c8ad02b05..15450e7c056 100644 --- a/dll/win32/ws2help/CMakeLists.txt +++ b/dll/win32/ws2help/CMakeLists.txt @@ -12,6 +12,7 @@ list(APPEND SOURCE add_library(ws2help MODULE ${SOURCE} + ws2help.rc ${CMAKE_CURRENT_BINARY_DIR}/ws2help.def) set_module_type(ws2help win32dll)
1 year
1
0
0
0
[reactos] 01/01: [SETUPAPI] Add dll version info (#6050)
by Thamatip Chitpong
https://git.reactos.org/?p=reactos.git;a=commitdiff;h=a79bd4d0cca7a37715300…
commit a79bd4d0cca7a377153007085cb661edc95306ef Author: Thamatip Chitpong <thamatip.chitpong(a)reactos.org> AuthorDate: Tue Nov 28 19:30:34 2023 +0700 Commit: GitHub <noreply(a)github.com> CommitDate: Tue Nov 28 19:30:34 2023 +0700 [SETUPAPI] Add dll version info (#6050) --- dll/win32/setupapi/setupapi.rc | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/dll/win32/setupapi/setupapi.rc b/dll/win32/setupapi/setupapi.rc index 3df83a456d5..b0c40394257 100644 --- a/dll/win32/setupapi/setupapi.rc +++ b/dll/win32/setupapi/setupapi.rc @@ -23,6 +23,12 @@ #include "resource.h" +#define REACTOS_VERSION_DLL +#define REACTOS_STR_FILE_DESCRIPTION "ReactOS Setup API" +#define REACTOS_STR_INTERNAL_NAME "setupapi" +#define REACTOS_STR_ORIGINAL_FILENAME "setupapi.dll" +#include <reactos/version.rc> + #include "res/icons_res.rc" #include <reactos/manifest_dll.rc>
1 year
1
0
0
0
← Newer
1
2
3
4
...
28
Older →
Jump to page:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
Results per page:
10
25
50
100
200