diff --git a/dlls/ntdll/actctx.c b/dlls/ntdll/actctx.c index f8dd3fc3c68..4dc0c9878df 100644 --- a/dlls/ntdll/actctx.c +++ b/dlls/ntdll/actctx.c @@ -4891,6 +4891,24 @@ static NTSTATUS find_guid(ACTIVATION_CONTEXT* actctx, ULONG section_kind, return STATUS_SUCCESS; } +static const WCHAR *find_app_settings( ACTIVATION_CONTEXT *actctx, const WCHAR *settings ) +{ + unsigned int i, j; + + for (i = 0; i < actctx->num_assemblies; i++) + { + struct assembly *assembly = &actctx->assemblies[i]; + for (j = 0; j < assembly->entities.num; j++) + { + struct entity *entity = &assembly->entities.base[j]; + if (entity->kind == ACTIVATION_CONTEXT_SECTION_APPLICATION_SETTINGS && + !strcmpW( entity->u.settings.name, settings )) + return entity->u.settings.value; + } + } + return NULL; +} + /* initialize the activation context for the current process */ void actctx_init(void) { @@ -5524,3 +5542,38 @@ NTSTATUS WINAPI RtlFindActivationContextSectionGuid( ULONG flags, const GUID *ex return status; } + + +/*********************************************************************** + * RtlQueryActivationContextApplicationSettings (NTDLL.@) + */ +NTSTATUS WINAPI RtlQueryActivationContextApplicationSettings( DWORD flags, HANDLE handle, const WCHAR *ns, + const WCHAR *settings, WCHAR *buffer, + SIZE_T size, SIZE_T *written ) +{ + static const WCHAR namespaceW[] = {'h','t','t','p',':','/','/','s','c','h','e','m','a','s','.','m','i','c','r','o','s','o','f','t','.','c','o','m','/','S','M','I','/','2','0',0}; + ACTIVATION_CONTEXT *actctx = check_actctx( handle ); + const WCHAR *res; + + if (flags) + { + WARN( "unknown flags %08x\n", flags ); + return STATUS_INVALID_PARAMETER; + } + + if (ns && strncmpW( ns, namespaceW, strlenW(namespaceW) )) + { + WARN( "unknown namespace %s\n", debugstr_w(ns) ); + return STATUS_INVALID_PARAMETER; + } + + if (!handle) handle = process_actctx; + if (!(actctx = check_actctx( handle ))) return STATUS_INVALID_PARAMETER; + + if (!(res = find_app_settings( actctx, settings ))) return STATUS_SXS_KEY_NOT_FOUND; + + if (written) *written = strlenW(res) + 1; + if (size < strlenW(res)) return STATUS_BUFFER_TOO_SMALL; + strcpyW( buffer, res ); + return STATUS_SUCCESS; +} diff --git a/dlls/ntdll/ntdll.spec b/dlls/ntdll/ntdll.spec index 04e108c4f0b..010793245b3 100644 --- a/dlls/ntdll/ntdll.spec +++ b/dlls/ntdll/ntdll.spec @@ -803,6 +803,7 @@ @ stub RtlPropertySetNameToGuid @ stub RtlProtectHeap @ stdcall RtlPushFrame(ptr) +@ stdcall RtlQueryActivationContextApplicationSettings(long ptr wstr wstr ptr long ptr) @ stdcall RtlQueryAtomInAtomTable(ptr long ptr ptr ptr ptr) @ stdcall RtlQueryDepthSList(ptr) @ stdcall RtlQueryDynamicTimeZoneInformation(ptr) diff --git a/include/winternl.h b/include/winternl.h index f01344c9043..ed542292832 100644 --- a/include/winternl.h +++ b/include/winternl.h @@ -2694,6 +2694,7 @@ NTSYSAPI void WINAPI RtlPopFrame(TEB_ACTIVE_FRAME*); NTSYSAPI BOOLEAN WINAPI RtlPrefixString(const STRING*,const STRING*,BOOLEAN); NTSYSAPI BOOLEAN WINAPI RtlPrefixUnicodeString(const UNICODE_STRING*,const UNICODE_STRING*,BOOLEAN); NTSYSAPI void WINAPI RtlPushFrame(TEB_ACTIVE_FRAME*); +NTSYSAPI NTSTATUS WINAPI RtlQueryActivationContextApplicationSettings(DWORD,HANDLE,const WCHAR*,const WCHAR*,WCHAR*,SIZE_T,SIZE_T*); NTSYSAPI NTSTATUS WINAPI RtlQueryAtomInAtomTable(RTL_ATOM_TABLE,RTL_ATOM,ULONG*,ULONG*,WCHAR*,ULONG*); NTSYSAPI NTSTATUS WINAPI RtlQueryDynamicTimeZoneInformation(RTL_DYNAMIC_TIME_ZONE_INFORMATION*); NTSYSAPI NTSTATUS WINAPI RtlQueryEnvironmentVariable_U(PWSTR,PUNICODE_STRING,PUNICODE_STRING);