https://git.reactos.org/?p=reactos.git;a=commitdiff;h=6e449d47e83051692edde…
commit 6e449d47e83051692edde58b830f4510fb77cb7d
Author: Katayama Hirofumi MZ <katayama.hirofumi.mz(a)gmail.com>
AuthorDate: Sun Dec 3 23:40:49 2023 +0900
Commit: GitHub <noreply(a)github.com>
CommitDate: Sun Dec 3 23:40:49 2023 +0900
[IMM32][KERNEL32][SDK] Half-implement BaseCheckAppcompatCache (#6069)
- And add it to <compat_undoc.h>.
- Use <compat_undoc.h> in IMM32.
- Modify kernel32.spec.
CORE-19268
---
dll/win32/imm32/ctf.c | 8 +--
dll/win32/kernel32/client/appcache.c | 118 ++++++++++++++++++++++++++++++++---
dll/win32/kernel32/kernel32.spec | 2 +-
sdk/include/reactos/compat_undoc.h | 8 +++
4 files changed, 120 insertions(+), 16 deletions(-)
diff --git a/dll/win32/imm32/ctf.c b/dll/win32/imm32/ctf.c
index f4463cc67f1..1a0e26788ed 100644
--- a/dll/win32/imm32/ctf.c
+++ b/dll/win32/imm32/ctf.c
@@ -8,6 +8,7 @@
#include "precomp.h"
#include <msctf.h> /* for ITfLangBarMgr */
#include <objidl.h> /* for IInitializeSpy */
+#include <compat_undoc.h> /* for BaseCheckAppcompatCache */
WINE_DEFAULT_DEBUG_CHANNEL(imm);
@@ -228,13 +229,6 @@ HINSTANCE g_hCtfIme = NULL;
/* The type of ApphelpCheckIME function in apphelp.dll */
typedef BOOL (WINAPI *FN_ApphelpCheckIME)(_In_z_ LPCWSTR AppName);
-/* FIXME: This is kernel32 function. We have to declare this in some header. */
-BOOL WINAPI
-BaseCheckAppcompatCache(_In_z_ LPCWSTR ApplicationName,
- _In_ HANDLE FileHandle,
- _In_opt_z_ LPCWSTR Environment,
- _Out_ PULONG pdwReason);
-
/***********************************************************************
* This function checks whether the app's IME is disabled by application
* compatibility patcher.
diff --git a/dll/win32/kernel32/client/appcache.c b/dll/win32/kernel32/client/appcache.c
index 0b2ebec1afe..fae424c106a 100644
--- a/dll/win32/kernel32/client/appcache.c
+++ b/dll/win32/kernel32/client/appcache.c
@@ -139,20 +139,122 @@ IsShimInfrastructureDisabled(VOID)
* @unimplemented
*/
BOOL
-WINAPI
-BaseCheckAppcompatCache(IN PWCHAR ApplicationName,
- IN HANDLE FileHandle,
- IN PWCHAR Environment,
- OUT PULONG Reason)
+BasepShimCacheCheckBypass(
+ _In_ PCWSTR ApplicationName,
+ _In_ HANDLE FileHandle,
+ _In_opt_ PCWSTR Environment,
+ _In_ BOOL bUnknown,
+ _Out_opt_ PULONG pdwReason)
{
- DPRINT("BaseCheckAppcompatCache is UNIMPLEMENTED\n");
+ DPRINT("fixme:(%S, %p, %S, %d, %p)\n", ApplicationName, FileHandle,
Environment, bUnknown,
+ pdwReason);
+ return FALSE;
+}
- if (Reason) *Reason = 0;
+/*
+ * @implemented
+ */
+BOOL
+BasepShimCacheSearch(
+ _In_ PCWSTR ApplicationName,
+ _In_ HANDLE FileHandle)
+{
+ APPHELP_CACHE_SERVICE_LOOKUP Lookup;
+ RtlInitUnicodeString(&Lookup.ImageName, ApplicationName);
+ Lookup.ImageHandle = FileHandle;
+ return NT_SUCCESS(NtApphelpCacheControl(ApphelpCacheServiceLookup, &Lookup));
+}
- // We don't know this app.
+/*
+ * @unimplemented
+ */
+BOOL
+BasepCheckCacheExcludeList(
+ _In_ PCWSTR ApplicationName)
+{
return FALSE;
}
+/*
+ * @unimplemented
+ */
+BOOL
+BasepCheckCacheExcludeCustom(
+ _In_ PCWSTR ApplicationName)
+{
+ return FALSE;
+}
+
+/*
+ * @implemented
+ */
+VOID
+BasepShimCacheRemoveEntry(
+ _In_ PCWSTR ApplicationName)
+{
+ APPHELP_CACHE_SERVICE_LOOKUP Lookup;
+ RtlInitUnicodeString(&Lookup.ImageName, ApplicationName);
+ Lookup.ImageHandle = INVALID_HANDLE_VALUE;
+ NtApphelpCacheControl(ApphelpCacheServiceRemove, &Lookup);
+}
+
+/*
+ * @unimplemented
+ */
+BOOL
+BasepShimCacheLookup(
+ _In_ PCWSTR ApplicationName,
+ _In_ HANDLE FileHandle)
+{
+ DPRINT("fixme:(%S, %p)\n", ApplicationName, FileHandle);
+
+ if (!BasepShimCacheSearch(ApplicationName, FileHandle))
+ return FALSE;
+
+ if (!BasepCheckCacheExcludeList(ApplicationName) ||
+ !BasepCheckCacheExcludeCustom(ApplicationName))
+ {
+ BasepShimCacheRemoveEntry(ApplicationName);
+ return FALSE;
+ }
+
+ return TRUE;
+}
+
+/*
+ * @implemented
+ */
+BOOL
+WINAPI
+BaseCheckAppcompatCache(
+ _In_ PCWSTR ApplicationName,
+ _In_ HANDLE FileHandle,
+ _In_opt_ PCWSTR Environment,
+ _Out_opt_ PULONG pdwReason)
+{
+ BOOL ret = FALSE;
+ ULONG dwReason;
+
+ DPRINT("(%S, %p, %S, %p)\n", ApplicationName, FileHandle, Environment,
pdwReason);
+
+ dwReason = 0;
+ if (BasepShimCacheCheckBypass(ApplicationName, FileHandle, Environment, TRUE,
&dwReason))
+ {
+ dwReason |= 2;
+ }
+ else
+ {
+ ret = BasepShimCacheLookup(ApplicationName, FileHandle);
+ if (!ret)
+ dwReason |= 1;
+ }
+
+ if (pdwReason)
+ *pdwReason = dwReason;
+
+ return ret;
+}
+
static
VOID
BaseInitApphelp(VOID)
diff --git a/dll/win32/kernel32/kernel32.spec b/dll/win32/kernel32/kernel32.spec
index 3b41edde6d8..5fe3047cb42 100644
--- a/dll/win32/kernel32/kernel32.spec
+++ b/dll/win32/kernel32/kernel32.spec
@@ -24,7 +24,7 @@
@ stdcall BackupRead(ptr ptr long ptr long long ptr)
@ stdcall BackupSeek(ptr long long ptr ptr ptr)
@ stdcall BackupWrite(ptr ptr long ptr long long ptr)
-@ stdcall BaseCheckAppcompatCache(long long long ptr)
+@ stdcall BaseCheckAppcompatCache(wstr ptr wstr ptr)
@ stdcall BaseCheckRunApp(long ptr long long long long long long long long)
@ stdcall BaseCleanupAppcompatCacheSupport(ptr)
@ stdcall BaseDumpAppcompatCache()
diff --git a/sdk/include/reactos/compat_undoc.h b/sdk/include/reactos/compat_undoc.h
index b0516322a37..cea9930e648 100644
--- a/sdk/include/reactos/compat_undoc.h
+++ b/sdk/include/reactos/compat_undoc.h
@@ -46,4 +46,12 @@ UINT RosGetProcessEffectiveVersion(VOID)
return (peb->OSMajorVersion << 8) | (peb->OSMinorVersion);
}
+BOOL
+WINAPI
+BaseCheckAppcompatCache(
+ _In_ PCWSTR ApplicationName,
+ _In_ HANDLE FileHandle,
+ _In_opt_ PCWSTR Environment,
+ _Out_opt_ PULONG pdwReason);
+
#endif // COMPAT_UNDOC_H