Module: wine Branch: master Commit: cb2fb8c25eb641f96e0b5d84f8049d67f50c0f30 URL: https://source.winehq.org/git/wine.git/?a=commit;h=cb2fb8c25eb641f96e0b5d84f...
Author: Alexandre Julliard julliard@winehq.org Date: Tue Feb 22 12:35:18 2022 +0100
ntdll: Implement ApiSetQueryApiSetPresence/Ex().
Signed-off-by: Alexandre Julliard julliard@winehq.org
---
dlls/kernel32/tests/module.c | 3 --- dlls/ntdll/loader.c | 45 ++++++++++++++++++++++++++++++++++++++++++++ dlls/ntdll/misc.c | 12 ------------ dlls/ntdll/ntdll.spec | 1 + include/winternl.h | 2 ++ 5 files changed, 48 insertions(+), 15 deletions(-)
diff --git a/dlls/kernel32/tests/module.c b/dlls/kernel32/tests/module.c index bd151708220..58dcfaaec99 100644 --- a/dlls/kernel32/tests/module.c +++ b/dlls/kernel32/tests/module.c @@ -1468,7 +1468,6 @@ static void test_apisets(void) win_skip( "ApiSetQueryApiSetPresence not implemented\n" ); return; } - todo_wine if (!pApiSetQueryApiSetPresenceEx) win_skip( "ApiSetQueryApiSetPresenceEx not implemented\n" ); todo_wine if (!pIsApiSetImplemented) win_skip( "IsApiSetImplemented not implemented\n" ); @@ -1480,9 +1479,7 @@ static void test_apisets(void) winetest_push_context( "%u:%s", i, tests[i].name ); present = 0xff; status = pApiSetQueryApiSetPresence( &name, &present ); - todo_wine ok( status == STATUS_SUCCESS, "wrong ret %x\n", status ); - todo_wine_if( !tests[i].present ) ok( present == tests[i].present || broken(!present && tests[i].broken) /* win8 */, "wrong present %u\n", present ); if (pApiSetQueryApiSetPresenceEx) diff --git a/dlls/ntdll/loader.c b/dlls/ntdll/loader.c index 49911d6c707..d3b63dc7ada 100644 --- a/dlls/ntdll/loader.c +++ b/dlls/ntdll/loader.c @@ -4526,6 +4526,51 @@ void WINAPI RtlReleasePath( PWSTR path ) }
+/********************************************************************* + * ApiSetQueryApiSetPresence (NTDLL.@) + */ +NTSTATUS WINAPI ApiSetQueryApiSetPresence( const UNICODE_STRING *name, BOOLEAN *present ) +{ + const API_SET_NAMESPACE *map = NtCurrentTeb()->Peb->ApiSetMap; + const API_SET_NAMESPACE_ENTRY *entry; + UNICODE_STRING str; + + *present = (!get_apiset_entry( map, name->Buffer, name->Length / sizeof(WCHAR), &entry ) && + !get_apiset_target( map, entry, NULL, &str )); + return STATUS_SUCCESS; +} + + +/********************************************************************* + * ApiSetQueryApiSetPresenceEx (NTDLL.@) + */ +NTSTATUS WINAPI ApiSetQueryApiSetPresenceEx( const UNICODE_STRING *name, BOOLEAN *in_schema, BOOLEAN *present ) +{ + const API_SET_NAMESPACE *map = NtCurrentTeb()->Peb->ApiSetMap; + const API_SET_NAMESPACE_ENTRY *entry; + NTSTATUS status; + UNICODE_STRING str; + ULONG i, len = name->Length / sizeof(WCHAR); + + /* extension not allowed */ + for (i = 0; i < len; i++) if (name->Buffer[i] == '.') return STATUS_INVALID_PARAMETER; + + status = get_apiset_entry( map, name->Buffer, len, &entry ); + if (status == STATUS_APISET_NOT_PRESENT) + { + *in_schema = *present = FALSE; + return STATUS_SUCCESS; + } + if (status) return status; + + /* the name must match exactly */ + *in_schema = (entry->NameLength == name->Length && + !wcsnicmp( (WCHAR *)((char *)map + entry->NameOffset), name->Buffer, len )); + *present = *in_schema && !get_apiset_target( map, entry, NULL, &str ); + return STATUS_SUCCESS; +} + + /****************************************************************** * DllMain (NTDLL.@) */ diff --git a/dlls/ntdll/misc.c b/dlls/ntdll/misc.c index 3bef5a561c8..bce8d7db54e 100644 --- a/dlls/ntdll/misc.c +++ b/dlls/ntdll/misc.c @@ -381,15 +381,3 @@ ULONG WINAPIV EtwTraceMessage( TRACEHANDLE handle, ULONG flags, LPGUID guid, /*U va_end( valist ); return ret; } - -/********************************************************************* - * ApiSetQueryApiSetPresence (NTDLL.@) - */ -BOOL WINAPI ApiSetQueryApiSetPresence(const UNICODE_STRING *namespace, BOOLEAN *present) -{ - FIXME("(%s, %p) stub!\n", debugstr_us(namespace), present); - - if(present) - *present = TRUE; - return TRUE; -} diff --git a/dlls/ntdll/ntdll.spec b/dlls/ntdll/ntdll.spec index 29174965394..d514bca5e11 100644 --- a/dlls/ntdll/ntdll.spec +++ b/dlls/ntdll/ntdll.spec @@ -7,6 +7,7 @@ @ stdcall A_SHAInit(ptr) @ stdcall A_SHAUpdate(ptr ptr long) @ stdcall ApiSetQueryApiSetPresence(ptr ptr) +@ stdcall ApiSetQueryApiSetPresenceEx(ptr ptr ptr) @ stub CsrAllocateCaptureBuffer @ stub CsrAllocateCapturePointer @ stub CsrAllocateMessagePointer diff --git a/include/winternl.h b/include/winternl.h index ae331562026..6a95c4e0fdc 100644 --- a/include/winternl.h +++ b/include/winternl.h @@ -3866,6 +3866,8 @@ typedef struct _API_SET_VALUE_ENTRY * Function declarations */
+NTSYSAPI NTSTATUS WINAPI ApiSetQueryApiSetPresence(const UNICODE_STRING*,BOOLEAN*); +NTSYSAPI NTSTATUS WINAPI ApiSetQueryApiSetPresenceEx(const UNICODE_STRING*,BOOLEAN*,BOOLEAN*); NTSYSAPI void WINAPI DbgBreakPoint(void); NTSYSAPI NTSTATUS WINAPIV DbgPrint(LPCSTR fmt, ...); NTSYSAPI NTSTATUS WINAPIV DbgPrintEx(ULONG iComponentId, ULONG Level, LPCSTR fmt, ...);