Reactos

[RTL] Sync actctx.c to wine-5.18 (#6848)

* [WINESYNC] ntdll: Add support for parsing application settings in manifests.

Signed-off-by: Alexandre Julliard <julliard@winehq.org>

wine commit id fc14442970dc6b97032c3cdd76cab33d774dc1a2 by Alexandre Julliard <julliard@winehq.org>

* [WINESYNC] ntdll: Implement RtlQueryActivationContextApplicationSettings.

Signed-off-by: Alexandre Julliard <julliard@winehq.org>

wine commit id 14b9a5af0b44d7e2ca5232ad810c77e561d5d30c by Alexandre Julliard <julliard@winehq.org>

* [WINESYNC] ntdll: Propagate the error through the XML buffer in manifest parser.

Signed-off-by: Alexandre Julliard <julliard@winehq.org>

wine commit id 7b871727e5cbb8581167acbaae2f4e34dc4ee59e by Alexandre Julliard <julliard@winehq.org>

* [WINESYNC] ntdll: Check the namespace in RtlQueryActivationContextApplicationSettings.

Signed-off-by: Alexandre Julliard <julliard@winehq.org>

wine commit id e46259fb823f55aa331381fe56916d20049d52f2 by Alexandre Julliard <julliard@winehq.org>

* [WINESYNC] ntdll: Use the ARRAY_SIZE() macro.

Signed-off-by: Michael Stefaniuc <mstefani@winehq.org>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>

wine commit id 10f23ddb58b0583c8bce99e59d879c653b389363 by Michael Stefaniuc <mstefani@winehq.org>

* [WINESYNC] ntdll/actctx: Don't stop looking for manifest if dll without manifest is found.

Signed-off-by: Fabian Maurer <dark.shadow4@web.de>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>

wine commit id 56b3304a019486b52681a05d4b5454b475275e51 by Fabian Maurer <dark.shadow4@web.de>

* [WINESYNC] ntdll: Use the current platform as processorArchitecture instead of a wildcard.

Signed-off-by: Alexandre Julliard <julliard@winehq.org>

wine commit id 6abf99b4803003812d4fcf7bf9effc99030cbec9 by Alexandre Julliard <julliard@winehq.org>

* [WINESYNC] ntdll: Use strncmpiW instead of memicmpW for strings without embedded nulls.

Signed-off-by: Alexandre Julliard <julliard@winehq.org>

wine commit id 6fc259a57dafab9e72af13980c021e2a59257935 by Alexandre Julliard <julliard@winehq.org>

* [WINESYNC] ntdll: Avoid dead initialization (scan-build).

Signed-off-by: Alex Henrie <alexhenrie24@gmail.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>

wine commit id 6ea282c7e1abd7ab09a5f0a18a437e63f909da96 by Alex Henrie <alexhenrie24@gmail.com>

* [NDK] Add RtlUTF8ToUnicodeN for user mode

* [WINESYNC] ntdll: Use the Rtl UTF8 conversion functions.

Signed-off-by: Alexandre Julliard <julliard@winehq.org>

wine commit id f46fa9c92d08c6e656bc22b94e09aa9dbe7d3be9 by Alexandre Julliard <julliard@winehq.org>

* [WINESYNC] ntdll: Use module path as assembly path for manifests embedded in resources.

Fixes Office 2016 installer, which removes its .exe directory from load
path, but expects to be able to load files listed in manifest.

Signed-off-by: Jacek Caban <jacek@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>

wine commit id 2d764e90dd2c624f7a2d863ab29bd418ed33d252 by Jacek Caban <jacek@codeweavers.com>

* [WINESYNC] ntdll: Store the default process activation context into the PEB.

Signed-off-by: Gabriel Ivăncescu <gabrielopcode@gmail.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>

wine commit id e95d0813fdfcfcac2bb1761e62e1d54e6f73cd6d by Gabriel Ivăncescu <gabrielopcode@gmail.com>

* [WINESYNC] ntdll: Use wcsicmp() instead of strcmpiW() where possible.

Signed-off-by: Alexandre Julliard <julliard@winehq.org>

wine commit id 3e049b6b962b8e6f048101b9910c09d5b1d8f167 by Alexandre Julliard <julliard@winehq.org>

* [WINESYNC] ntdll: Use wcsnicmp() instead of strncmpiW() where possible.

Signed-off-by: Alexandre Julliard <julliard@winehq.org>

wine commit id f831b3bd3d6b013893be7645df3a9cd05289c415 by Alexandre Julliard <julliard@winehq.org>

* [WINESYNC] ntdll: Use RtlEqualUnicodeString() instead of strcmpiW().

Signed-off-by: Alexandre Julliard <julliard@winehq.org>

wine commit id 4d93bafe961ed53488ff0fb4b44cb1ad085531fe by Alexandre Julliard <julliard@winehq.org>

* [WINESYNC] ntdll: Avoid using memchrW().

Signed-off-by: Alexandre Julliard <julliard@winehq.org>

wine commit id 186f189107972b739311f95a4ba3833838349b32 by Alexandre Julliard <julliard@winehq.org>

* [WINESYNC] ntdll: Avoid using atoiW().

Signed-off-by: Alexandre Julliard <julliard@winehq.org>

wine commit id 8f3d869d784753d814a3493d01c3650f45389eda by Alexandre Julliard <julliard@winehq.org>

* [WINESYNC] ntdll: Avoid using sprintfW().

Signed-off-by: Alexandre Julliard <julliard@winehq.org>

wine commit id eb1b2e548656dc3d08cbf3c35454621491b84126 by Alexandre Julliard <julliard@winehq.org>

* [WINESYNC] ntdll: Use wcscpy() instead of strcpyW().

Signed-off-by: Alexandre Julliard <julliard@winehq.org>

wine commit id 18411a19b4ea3a68234980c56d4c252670dfc000 by Alexandre Julliard <julliard@winehq.org>

* [WINESYNC] ntdll: Use wcscat() instead of strcatW().

Signed-off-by: Alexandre Julliard <julliard@winehq.org>

wine commit id 80005ee016aeed42967adfe5b3042803d008c50d by Alexandre Julliard <julliard@winehq.org>

* [WINESYNC] ntdll: Use wcschr() instead of strchrW().

Signed-off-by: Alexandre Julliard <julliard@winehq.org>

wine commit id 6de0ab276b3b79db4331993316f529a43f67c29a by Alexandre Julliard <julliard@winehq.org>

* [WINESYNC] ntdll: Use wcsrchr() instead of strrchrW().

Signed-off-by: Alexandre Julliard <julliard@winehq.org>

wine commit id 285c5490a4c0ee4a92d042a3e6ab32e6bc14fb49 by Alexandre Julliard <julliard@winehq.org>

* [WINESYNC] ntdll: Use wcslen() instead of strlenW().

Signed-off-by: Alexandre Julliard <julliard@winehq.org>

wine commit id e003b9884edcccc417d41d30073b312648741aaa by Alexandre Julliard <julliard@winehq.org>

* [WINESYNC] ntdll: Use wcscmp() instead of strcmpW().

Signed-off-by: Alexandre Julliard <julliard@winehq.org>

wine commit id 4501ab0a7c80e31e602c540a446809e8ae3ebade by Alexandre Julliard <julliard@winehq.org>

* [WINESYNC] ntdll: Use wcsncmp() instead of strncmpW().

Signed-off-by: Alexandre Julliard <julliard@winehq.org>

wine commit id e36b97e1d0644f90606d27f5104bb09a910540d2 by Alexandre Julliard <julliard@winehq.org>

* [WINESYNC] ntdll: Make the windows directory a global variable.

Signed-off-by: Alexandre Julliard <julliard@winehq.org>

wine commit id ca13f489e18fb1f7944e3bdcfdfc4a810bf80994 by Alexandre Julliard <julliard@winehq.org>

* [WINESYNC] ntdll: Use single field for misc flags in ComClass redirection section.

Signed-off-by: Nikolay Sivov <nsivov@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>

wine commit id 72d055854b59db9059a3465f1e65247c0cc5e94e by Nikolay Sivov <nsivov@codeweavers.com>

* [WINESYNC] ntdll: Create class section for proxy-stub interface entries.

Signed-off-by: Nikolay Sivov <nsivov@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>

wine commit id dd9295b415345f2b686b65bd05fae0320cf6dc39 by Nikolay Sivov <nsivov@codeweavers.com>

* [WINESYNC] ntdll: Use the standard C library names for the printf functions.

Signed-off-by: Alexandre Julliard <julliard@winehq.org>

wine commit id 4478ba258e45559ac97353ab27951e84dd9865c1 by Alexandre Julliard <julliard@winehq.org>

* [WINESYNC] ntdll: Implement RtlActivateActivationContextEx().

Signed-off-by: Alexandre Julliard <julliard@winehq.org>

wine commit id c71da19d24a5d6f01e65b3b3691a9d7dd17a2278 by Alexandre Julliard <julliard@winehq.org>

* [WINESYNC] ntdll: Fix a memory leak (Valgrind).

Signed-off-by: Chao Long <longchao@uniontech.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>

wine commit id d0946955ec21e4da57aaec92459f81f131b27a49 by Chao Long <longchao@uniontech.com>

* [WINESYNC] rtl is now in sync with wine-staging wine-5.18

---------

Co-authored-by: winesync <ros-dev@reactos.org>
Co-authored-by: winesync <rosdev@reactos.org>

authored by

Timo Kreuzer
winesync
winesync
and committed by
GitHub
43dad82f 7983297b

+298 -196
+1 -1
dll/ntdll/def/ntdll.spec
··· 1066 1066 @ stub -version=0x600+ RtlProcessFlsData 1067 1067 @ stdcall RtlProtectHeap(ptr long) 1068 1068 @ stdcall RtlPushFrame(ptr) 1069 - @ stub -version=0x600+ RtlQueryActivationContextApplicationSettings 1069 + @ stdcall -version=0x600+ RtlQueryActivationContextApplicationSettings(long ptr wstr wstr ptr ptr ptr) 1070 1070 @ stdcall RtlQueryAtomInAtomTable(ptr long ptr ptr ptr ptr) 1071 1071 @ stub -version=0x600+ RtlQueryCriticalSectionOwner 1072 1072 @ stdcall RtlQueryDepthSList(ptr)
+1
dll/shellext/shellbtrfs/reactos.cpp
··· 9 9 #include "shellext.h" 10 10 #include <initguid.h> 11 11 #include <ntddstor.h> 12 + #define RtlUTF8ToUnicodeN RtlUTF8ToUnicodeN_ 12 13 #include <ndk/rtlfuncs.h> 13 14 14 15 #ifdef __cplusplus
+3 -3
media/doc/WINESYNC.txt
··· 263 263 264 264 sdk/lib/3rdparty/strmbase # Synced to WineStaging-3.3 265 265 266 - sdk/lib/rtl/actctx.c # Partly synced with WineStaging-1.9.16 267 - sdk/lib/rtl/timerqueue.c # Partly synced with WineStaging-1.7.55 268 - sdk/lib/rtl/wait.c # Partly synced with WineStaging-1.7.55 266 + sdk/lib/rtl/actctx.c # Synced to wine-5.18 267 + sdk/lib/rtl/timerqueue.c # Synced to wine-5.18 268 + sdk/lib/rtl/wait.c # Synced to wine-5.18 269 269 270 270 advapi32 - 271 271 dll/win32/advapi32/wine/cred.c # Synced to WineStaging-3.3
+12
sdk/include/ndk/rtlfuncs.h
··· 210 210 return TempLuid; 211 211 } 212 212 213 + _Must_inspect_result_ 214 + NTSYSAPI 215 + NTSTATUS 216 + NTAPI 217 + RtlUTF8ToUnicodeN( 218 + _Out_writes_bytes_to_(UnicodeStringMaxByteCount, *UnicodeStringActualByteCount) 219 + PWSTR UnicodeStringDestination, 220 + _In_ ULONG UnicodeStringMaxByteCount, 221 + _Out_ PULONG UnicodeStringActualByteCount, 222 + _In_reads_bytes_(UTF8StringByteCount) PCCH UTF8StringSource, 223 + _In_ ULONG UTF8StringByteCount); 224 + 213 225 // 214 226 // ASSERT Macros 215 227 //
+274 -192
sdk/lib/rtl/actctx.c
··· 9 9 * Jacek Caban for CodeWeavers 10 10 * Alexandre Julliard 11 11 * Stefan Ginsberg (stefan.ginsberg@reactos.org) 12 - * Samuel Serapi�n 12 + * Samuel Serapión 13 13 */ 14 14 15 15 /* Based on Wine 3.2-37c98396 */ ··· 33 33 #define FILE_END_OF_FILE_INFORMATION FILE_STANDARD_INFORMATION 34 34 #define FileEndOfFileInformation FileStandardInformation 35 35 #define RELATIVE_PATH RtlPathTypeRelative 36 - #define user_shared_data SharedUserData 36 + #define windows_dir SharedUserData->NtSystemRoot 37 + #define ARRAY_SIZE(a) (sizeof(a)/sizeof((a)[0])) 38 + #define wcsnicmp _wcsnicmp 39 + #define swprintf _snwprintf 37 40 38 41 #undef RT_MANIFEST 39 42 #undef CREATEPROCESS_MANIFEST_RESOURCE_ID ··· 252 255 struct comclassredirect_data 253 256 { 254 257 ULONG size; 255 - BYTE res; 256 - BYTE miscmask; 257 - BYTE res1[2]; 258 + ULONG flags; 258 259 DWORD model; 259 260 GUID clsid; 260 261 GUID alias; ··· 834 835 { 835 836 WCHAR* ptr; 836 837 837 - if (!(ptr = RtlAllocateHeap(GetProcessHeap(), 0, (strlenW(str) + 1) * sizeof(WCHAR)))) 838 + if (!(ptr = RtlAllocateHeap(GetProcessHeap(), 0, (wcslen(str) + 1) * sizeof(WCHAR)))) 838 839 return NULL; 839 - return strcpyW(ptr, str); 840 + return wcscpy(ptr, str); 840 841 } 841 842 842 843 static WCHAR *xmlstrdupW(const xmlstr_t* str) ··· 853 854 854 855 static inline BOOL xmlstr_cmp(const xmlstr_t* xmlstr, const WCHAR *str) 855 856 { 856 - return !strncmpW(xmlstr->ptr, str, xmlstr->len) && !str[xmlstr->len]; 857 + return !wcsncmp(xmlstr->ptr, str, xmlstr->len) && !str[xmlstr->len]; 857 858 } 858 859 859 860 static inline BOOL xmlstr_cmpi(const xmlstr_t* xmlstr, const WCHAR *str) 860 861 { 861 - return !strncmpiW(xmlstr->ptr, str, xmlstr->len) && !str[xmlstr->len]; 862 + return !wcsnicmp(xmlstr->ptr, str, xmlstr->len) && !str[xmlstr->len]; 862 863 } 863 864 864 865 static BOOL xml_attr_cmp( const struct xml_attr *attr, const WCHAR *str ) ··· 907 908 } 908 909 #endif // !__REACTOS__ 909 910 911 + static NTSTATUS get_module_filename( HMODULE module, UNICODE_STRING *str, unsigned int extra_len ) 912 + { 913 + NTSTATUS status; 914 + ULONG_PTR magic; 915 + LDR_DATA_TABLE_ENTRY *pldr; 916 + 917 + LdrLockLoaderLock(0, NULL, &magic); 918 + status = LdrFindEntryForAddress( module, &pldr ); 919 + if (status == STATUS_SUCCESS) 920 + { 921 + if ((str->Buffer = RtlAllocateHeap( GetProcessHeap(), 0, 922 + pldr->FullDllName.Length + extra_len + sizeof(WCHAR) ))) 923 + { 924 + memcpy( str->Buffer, pldr->FullDllName.Buffer, pldr->FullDllName.Length + sizeof(WCHAR) ); 925 + str->Length = pldr->FullDllName.Length; 926 + str->MaximumLength = pldr->FullDllName.Length + extra_len + sizeof(WCHAR); 927 + } 928 + else status = STATUS_NO_MEMORY; 929 + } 930 + LdrUnlockLoaderLock(0, magic); 931 + return status; 932 + } 933 + 910 934 static struct assembly *add_assembly(ACTIVATION_CONTEXT *actctx, enum assembly_type at) 911 935 { 912 936 struct assembly *assembly; ··· 1057 1081 RtlFreeHeap(GetProcessHeap(), 0, entity->u.clrsurrogate.clsid); 1058 1082 RtlFreeHeap(GetProcessHeap(), 0, entity->u.clrsurrogate.version); 1059 1083 break; 1084 + case ACTIVATION_CONTEXT_SECTION_APPLICATION_SETTINGS: 1085 + RtlFreeHeap(GetProcessHeap(), 0, entity->u.settings.name); 1086 + RtlFreeHeap(GetProcessHeap(), 0, entity->u.settings.value); 1087 + RtlFreeHeap(GetProcessHeap(), 0, entity->u.settings.ns); 1088 + break; 1060 1089 default: 1061 1090 FIXME("Unknown entity kind %d\n", entity->kind); 1062 1091 } ··· 1067 1096 static BOOL is_matching_string( const WCHAR *str1, const WCHAR *str2 ) 1068 1097 { 1069 1098 if (!str1) return !str2; 1070 - return str2 && !strcmpiW( str1, str2 ); 1099 + return str2 && !RtlCompareUnicodeStrings( str1, wcslen(str1), str2, wcslen(str2), TRUE ); 1071 1100 } 1072 1101 1073 1102 static BOOL is_matching_identity( const struct assembly_identity *id1, ··· 1077 1106 if (!is_matching_string( id1->arch, id2->arch )) return FALSE; 1078 1107 if (!is_matching_string( id1->public_key, id2->public_key )) return FALSE; 1079 1108 1080 - if (id1->language && id2->language && strcmpiW( id1->language, id2->language )) 1109 + if (id1->language && id2->language && !is_matching_string( id1->language, id2->language )) 1081 1110 { 1082 - if (strcmpW( wildcardW, id1->language ) && strcmpW( wildcardW, id2->language )) 1111 + if (wcscmp( wildcardW, id1->language ) && wcscmp( wildcardW, id2->language )) 1083 1112 return FALSE; 1084 1113 } 1085 1114 if (id1->version.major != id2->version.major) return FALSE; ··· 1157 1186 const WCHAR *key = ai->public_key ? ai->public_key : noneW; 1158 1187 const WCHAR *lang = ai->language ? ai->language : noneW; 1159 1188 const WCHAR *name = ai->name ? ai->name : noneW; 1160 - SIZE_T size = (strlenW(arch) + 1 + strlenW(name) + 1 + strlenW(key) + 24 + 1 + 1161 - strlenW(lang) + 1) * sizeof(WCHAR) + sizeof(mskeyW); 1189 + SIZE_T size = (wcslen(arch) + 1 + wcslen(name) + 1 + wcslen(key) + 24 + 1 + 1190 + wcslen(lang) + 1) * sizeof(WCHAR) + sizeof(mskeyW); 1162 1191 WCHAR *ret; 1163 1192 1164 1193 if (!(ret = RtlAllocateHeap( GetProcessHeap(), 0, size ))) return NULL; 1165 1194 1166 - strcpyW( ret, arch ); 1167 - strcatW( ret, undW ); 1168 - strcatW( ret, name ); 1169 - strcatW( ret, undW ); 1170 - strcatW( ret, key ); 1171 - strcatW( ret, undW ); 1172 - sprintfW( ret + strlenW(ret), version_formatW, 1195 + wcscpy( ret, arch ); 1196 + wcscat( ret, undW ); 1197 + wcscat( ret, name ); 1198 + wcscat( ret, undW ); 1199 + wcscat( ret, key ); 1200 + wcscat( ret, undW ); 1201 + swprintf( ret + wcslen(ret), size - wcslen(ret), version_formatW, 1173 1202 ai->version.major, ai->version.minor, ai->version.build, ai->version.revision ); 1174 - strcatW( ret, undW ); 1175 - strcatW( ret, lang ); 1176 - strcatW( ret, undW ); 1177 - strcatW( ret, mskeyW ); 1203 + wcscat( ret, undW ); 1204 + wcscat( ret, lang ); 1205 + wcscat( ret, undW ); 1206 + wcscat( ret, mskeyW ); 1178 1207 return ret; 1179 1208 } 1180 1209 ··· 1183 1212 WCHAR *p = buffer; 1184 1213 1185 1214 if (!str) return; 1186 - strcatW( buffer, prefix ); 1187 - p += strlenW(p); 1215 + wcscat( buffer, prefix ); 1216 + p += wcslen(p); 1188 1217 *p++ = '"'; 1189 - strcpyW( p, str ); 1190 - p += strlenW(p); 1218 + wcscpy( p, str ); 1219 + p += wcslen(p); 1191 1220 *p++ = '"'; 1192 1221 *p = 0; 1193 1222 } ··· 1206 1235 WCHAR version[64], *ret; 1207 1236 SIZE_T size = 0; 1208 1237 1209 - sprintfW( version, version_formatW, 1238 + swprintf( version, ARRAY_SIZE(version), version_formatW, 1210 1239 ai->version.major, ai->version.minor, ai->version.build, ai->version.revision ); 1211 - if (ai->name) size += strlenW(ai->name) * sizeof(WCHAR); 1212 - if (ai->arch) size += strlenW(archW) + strlenW(ai->arch) + 2; 1213 - if (ai->public_key) size += strlenW(public_keyW) + strlenW(ai->public_key) + 2; 1214 - if (ai->type) size += strlenW(typeW2) + strlenW(ai->type) + 2; 1215 - size += strlenW(versionW2) + strlenW(version) + 2; 1240 + if (ai->name) size += wcslen(ai->name) * sizeof(WCHAR); 1241 + if (ai->arch) size += wcslen(archW) + wcslen(ai->arch) + 2; 1242 + if (ai->public_key) size += wcslen(public_keyW) + wcslen(ai->public_key) + 2; 1243 + if (ai->type) size += wcslen(typeW2) + wcslen(ai->type) + 2; 1244 + size += wcslen(versionW2) + wcslen(version) + 2; 1216 1245 1217 1246 if (!(ret = RtlAllocateHeap( GetProcessHeap(), 0, (size + 1) * sizeof(WCHAR) ))) 1218 1247 return NULL; 1219 1248 1220 - if (ai->name) strcpyW( ret, ai->name ); 1249 + if (ai->name) wcscpy( ret, ai->name ); 1221 1250 else *ret = 0; 1222 1251 append_string( ret, archW, ai->arch ); 1223 1252 append_string( ret, public_keyW, ai->public_key ); ··· 1520 1549 1521 1550 static BOOL parse_text_content(xmlbuf_t* xmlbuf, xmlstr_t* content) 1522 1551 { 1523 - const WCHAR *ptr = memchrW(xmlbuf->ptr, '<', xmlbuf->end - xmlbuf->ptr); 1552 + const WCHAR *ptr; 1553 + 1554 + if (xmlbuf->error) return FALSE; 1524 1555 1525 - if (!ptr) return FALSE; 1556 + for (ptr = xmlbuf->ptr; ptr < xmlbuf->end; ptr++) if (*ptr == '<') break; 1557 + if (ptr == xmlbuf->end) return set_error( xmlbuf ); 1526 1558 1527 1559 content->ptr = xmlbuf->ptr; 1528 1560 content->len = ptr - xmlbuf->ptr; ··· 1659 1691 int min, max; 1660 1692 1661 1693 min = 0; 1662 - max = sizeof(olemisc_values)/sizeof(struct olemisc_entry) - 1; 1694 + max = ARRAY_SIZE(olemisc_values) - 1; 1663 1695 1664 1696 while (min <= max) 1665 1697 { ··· 1667 1699 1668 1700 n = (min+max)/2; 1669 1701 1670 - c = strncmpW(olemisc_values[n].name, str, len); 1702 + c = wcsncmp(olemisc_values[n].name, str, len); 1671 1703 if (!c && !olemisc_values[n].name[len]) 1672 1704 return olemisc_values[n].value; 1673 1705 ··· 1914 1946 else if (xml_attr_cmp(&attr, threadingmodelW)) 1915 1947 { 1916 1948 } 1949 + else if (!is_xmlns_attr( &attr )) 1950 + { 1951 + } 1917 1952 } 1918 1953 1919 1954 acl->actctx->sections |= IFACEREDIRECT_SECTION; ··· 1938 1973 start = str; 1939 1974 while (*str != ',' && (i++ < value->len)) str++; 1940 1975 1941 - if (!strncmpiW(start, restrictedW, str-start)) 1976 + if (!wcsnicmp(start, restrictedW, str-start)) 1942 1977 *flags |= LIBFLAG_FRESTRICTED; 1943 - else if (!strncmpiW(start, controlW, str-start)) 1978 + else if (!wcsnicmp(start, controlW, str-start)) 1944 1979 *flags |= LIBFLAG_FCONTROL; 1945 - else if (!strncmpiW(start, hiddenW, str-start)) 1980 + else if (!wcsnicmp(start, hiddenW, str-start)) 1946 1981 *flags |= LIBFLAG_FHIDDEN; 1947 - else if (!strncmpiW(start, hasdiskimageW, str-start)) 1982 + else if (!wcsnicmp(start, hasdiskimageW, str-start)) 1948 1983 *flags |= LIBFLAG_FHASDISKIMAGE; 1949 1984 else 1950 1985 { ··· 2038 2073 WCHAR buff[25]; 2039 2074 2040 2075 if (!ret) ret = buff; 2041 - return sprintfW(ret, fmtW, ver->major, ver->minor, ver->build, ver->revision); 2076 + return swprintf(ret, ARRAY_SIZE(buff), fmtW, ver->major, ver->minor, ver->build, ver->revision); 2042 2077 } 2043 2078 2044 2079 static void parse_window_class_elem( xmlbuf_t *xmlbuf, struct dll_redirect *dll, ··· 2292 2327 { 2293 2328 parse_assembly_identity_elem(xmlbuf, acl->actctx, &ai, &elem); 2294 2329 /* store the newly found identity for later loading */ 2295 - if (ai.arch && !wcscmp(ai.arch, wildcardW)) ai.arch = strdupW( current_archW ); 2330 + if (ai.arch && !wcscmp(ai.arch, wildcardW)) 2331 + { 2332 + RtlFreeHeap( GetProcessHeap(), 0, ai.arch ); 2333 + ai.arch = strdupW( current_archW ); 2334 + } 2296 2335 if (!add_dependent_assembly_id(acl, &ai)) set_error( xmlbuf ); 2297 2336 } 2298 2337 else if (xml_elem_cmp(&elem, bindingRedirectW, asmv1W)) ··· 2815 2854 } 2816 2855 2817 2856 static NTSTATUS parse_manifest( struct actctx_loader* acl, struct assembly_identity* ai, 2818 - LPCWSTR filename, LPCWSTR directory, BOOL shared, 2857 + LPCWSTR filename, HANDLE module, LPCWSTR directory, BOOL shared, 2819 2858 const void *buffer, SIZE_T size ) 2820 2859 { 2821 2860 xmlbuf_t xmlbuf; ··· 2831 2870 if (directory && !(assembly->directory = strdupW(directory))) 2832 2871 return STATUS_NO_MEMORY; 2833 2872 2834 - if (filename) assembly->manifest.info = strdupW( filename + 4 /* skip \??\ prefix */ ); 2873 + if (!filename) 2874 + { 2875 + UNICODE_STRING module_path; 2876 + if ((status = get_module_filename( module, &module_path, 0 ))) return status; 2877 + assembly->manifest.info = module_path.Buffer; 2878 + } 2879 + else if(!(assembly->manifest.info = strdupW( filename + 4 /* skip \??\ prefix */ ))) return STATUS_NO_MEMORY; 2880 + 2835 2881 assembly->manifest.type = assembly->manifest.info ? ACTIVATION_CONTEXT_PATH_TYPE_WIN32_FILE 2836 2882 : ACTIVATION_CONTEXT_PATH_TYPE_NONE; 2837 2883 ··· 2859 2905 } 2860 2906 else 2861 2907 { 2862 - /* TODO: this doesn't handle arbitrary encodings */ 2908 + DWORD len; 2863 2909 WCHAR *new_buff; 2864 - ULONG sizeU; 2865 2910 2866 - status = RtlMultiByteToUnicodeSize(&sizeU, buffer, size); 2911 + /* let's assume utf-8 for now */ 2912 + status = RtlUTF8ToUnicodeN( NULL, 0, &len, buffer, size ); 2867 2913 if (!NT_SUCCESS(status)) 2868 2914 { 2869 2915 DPRINT1("RtlMultiByteToUnicodeSize failed with %lx\n", status); 2870 2916 return STATUS_SXS_CANT_GEN_ACTCTX; 2871 2917 } 2872 2918 2873 - new_buff = RtlAllocateHeap(GetProcessHeap(), 0, sizeU); 2874 - if (!new_buff) 2875 - return STATUS_NO_MEMORY; 2876 - 2877 - status = RtlMultiByteToUnicodeN(new_buff, sizeU, &sizeU, buffer, size); 2919 + if (!(new_buff = RtlAllocateHeap( GetProcessHeap(), 0, len ))) return STATUS_NO_MEMORY; 2920 + status = RtlUTF8ToUnicodeN( new_buff, len, &len, buffer, size ); 2878 2921 if (!NT_SUCCESS(status)) 2879 2922 { 2880 2923 DPRINT1("RtlMultiByteToUnicodeN failed with %lx\n", status); ··· 2882 2925 } 2883 2926 2884 2927 xmlbuf.ptr = new_buff; 2885 - xmlbuf.end = xmlbuf.ptr + sizeU / sizeof(WCHAR); 2928 + xmlbuf.end = xmlbuf.ptr + len / sizeof(WCHAR); 2886 2929 status = parse_manifest_buffer( acl, assembly, ai, &xmlbuf ); 2887 2930 RtlFreeHeap( GetProcessHeap(), 0, new_buff ); 2888 2931 } ··· 2903 2946 return NtOpenFile( handle, GENERIC_READ | SYNCHRONIZE, &attr, &io, FILE_SHARE_READ, FILE_SYNCHRONOUS_IO_ALERT ); 2904 2947 } 2905 2948 2906 - static NTSTATUS get_module_filename( HMODULE module, UNICODE_STRING *str, unsigned int extra_len ) 2907 - { 2908 - NTSTATUS status; 2909 - ULONG_PTR magic; 2910 - LDR_DATA_TABLE_ENTRY *pldr; 2911 - 2912 - LdrLockLoaderLock(0, NULL, &magic); 2913 - status = LdrFindEntryForAddress( module, &pldr ); 2914 - if (status == STATUS_SUCCESS) 2915 - { 2916 - if ((str->Buffer = RtlAllocateHeap( GetProcessHeap(), 0, 2917 - pldr->FullDllName.Length + extra_len + sizeof(WCHAR) ))) 2918 - { 2919 - memcpy( str->Buffer, pldr->FullDllName.Buffer, pldr->FullDllName.Length + sizeof(WCHAR) ); 2920 - str->Length = pldr->FullDllName.Length; 2921 - str->MaximumLength = pldr->FullDllName.Length + extra_len + sizeof(WCHAR); 2922 - } 2923 - else status = STATUS_NO_MEMORY; 2924 - } 2925 - LdrUnlockLoaderLock(0, magic); 2926 - return status; 2927 - } 2928 - 2929 2949 static NTSTATUS get_manifest_in_module( struct actctx_loader* acl, struct assembly_identity* ai, 2930 2950 LPCWSTR filename, LPCWSTR directory, BOOL shared, 2931 2951 HANDLE hModule, LPCWSTR resname, ULONG lang ) ··· 2983 3003 if (status == STATUS_SUCCESS) status = LdrAccessResource(hModule, entry, &ptr, NULL); 2984 3004 2985 3005 if (status == STATUS_SUCCESS) 2986 - status = parse_manifest(acl, ai, filename, directory, shared, ptr, entry->Size); 3006 + status = parse_manifest(acl, ai, filename, hModule, directory, shared, ptr, entry->Size); 2987 3007 2988 3008 return status; 2989 3009 } ··· 3042 3062 status = LdrAccessResource(hModule, entry, &ptr, NULL); 3043 3063 3044 3064 if (status == STATUS_SUCCESS) 3045 - status = parse_manifest(acl, ai, filename, directory, shared, ptr, entry->Size); 3065 + status = parse_manifest(acl, ai, filename, hModule, directory, shared, ptr, entry->Size); 3046 3066 3047 3067 return status; 3048 3068 } ··· 3064 3084 3065 3085 if ((!((ULONG_PTR)resname >> 16))) 3066 3086 { 3067 - sprintfW(resnameBuf, L"#%u", PtrToUlong(resname)); 3087 + _swprintf(resnameBuf, L"#%u", PtrToUlong(resname)); 3068 3088 resptr = resnameBuf; 3069 3089 } 3070 3090 ··· 3141 3161 3142 3162 status = NtQueryInformationFile( file, &io, &info, sizeof(info), FileEndOfFileInformation ); 3143 3163 if (status == STATUS_SUCCESS) 3144 - status = parse_manifest(acl, ai, filename, directory, shared, base, info.EndOfFile.QuadPart); 3164 + status = parse_manifest(acl, ai, filename, NULL, directory, shared, base, info.EndOfFile.QuadPart); 3145 3165 3146 3166 NtUnmapViewOfSection( GetCurrentProcess(), base ); 3147 3167 return status; ··· 3168 3188 3169 3189 if (!(status = get_module_filename( module, &name, sizeof(dotManifestW) + 10*sizeof(WCHAR) ))) 3170 3190 { 3171 - if (resid != 1) sprintfW( name.Buffer + strlenW(name.Buffer), fmtW, resid ); 3172 - strcatW( name.Buffer, dotManifestW ); 3191 + if (resid != 1) swprintf( name.Buffer + wcslen(name.Buffer), 10, fmtW, resid ); 3192 + wcscat( name.Buffer, dotManifestW ); 3173 3193 if (!RtlDosPathNameToNtPathName_U( name.Buffer, &nameW, NULL, NULL )) 3174 3194 status = STATUS_RESOURCE_DATA_NOT_FOUND; 3175 3195 RtlFreeUnicodeString( &name ); ··· 3179 3199 else 3180 3200 { 3181 3201 if (!(buffer = RtlAllocateHeap( GetProcessHeap(), 0, 3182 - (strlenW(filename) + 10) * sizeof(WCHAR) + sizeof(dotManifestW) ))) 3202 + (wcslen(filename) + 10) * sizeof(WCHAR) + sizeof(dotManifestW) ))) 3183 3203 return STATUS_NO_MEMORY; 3184 - strcpyW( buffer, filename ); 3185 - if (resid != 1) sprintfW( buffer + strlenW(buffer), fmtW, resid ); 3186 - strcatW( buffer, dotManifestW ); 3204 + wcscpy( buffer, filename ); 3205 + if (resid != 1) swprintf( buffer + wcslen(buffer), 10, fmtW, resid ); 3206 + wcscat( buffer, dotManifestW ); 3187 3207 RtlInitUnicodeString( &nameW, buffer ); 3188 3208 } 3189 3209 ··· 3208 3228 UNICODE_STRING lookup_us; 3209 3229 IO_STATUS_BLOCK io; 3210 3230 const WCHAR *lang = ai->language; 3211 - unsigned int data_pos = 0, data_len; 3231 + unsigned int data_pos = 0, data_len, len; 3212 3232 char buffer[8192]; 3213 3233 3214 - if (!(lookup = RtlAllocateHeap( GetProcessHeap(), 0, 3215 - (strlenW(ai->arch) + strlenW(ai->name) 3216 - + strlenW(ai->public_key) + 20) * sizeof(WCHAR) 3217 - + sizeof(lookup_fmtW) ))) 3218 - return NULL; 3234 + if (!lang || !wcsicmp( lang, neutralW )) lang = wildcardW; 3219 3235 3220 - if (!lang || !strcmpiW( lang, neutralW )) lang = wildcardW; 3221 - sprintfW( lookup, lookup_fmtW, ai->arch, ai->name, ai->public_key, 3236 + len = wcslen(ai->arch) + wcslen(ai->name) + wcslen(ai->public_key) + wcslen(lang) + 20 + ARRAY_SIZE(lookup_fmtW); 3237 + if (!(lookup = RtlAllocateHeap( GetProcessHeap(), 0, len * sizeof(WCHAR) ))) return NULL; 3238 + swprintf( lookup, len, lookup_fmtW, ai->arch, ai->name, ai->public_key, 3222 3239 ai->version.major, ai->version.minor, lang ); 3223 3240 RtlInitUnicodeString( &lookup_us, lookup ); 3224 3241 ··· 3247 3264 if (dir_info->NextEntryOffset) data_pos += dir_info->NextEntryOffset; 3248 3265 else data_pos = data_len; 3249 3266 3250 - tmp = (WCHAR *)dir_info->FileName + (strchrW(lookup, '*') - lookup); 3251 - build = atoiW(tmp); 3267 + tmp = (WCHAR *)dir_info->FileName + (wcschr(lookup, '*') - lookup); 3268 + build = wcstoul( tmp, NULL, 10 ); 3252 3269 if (build < min_build) continue; 3253 - tmp = strchrW(tmp, '.') + 1; 3254 - revision = atoiW(tmp); 3270 + tmp = wcschr(tmp, '.') + 1; 3271 + revision = wcstoul( tmp, NULL, 10 ); 3255 3272 if (build == min_build && revision < min_revision) continue; 3256 - tmp = strchrW(tmp, '_') + 1; 3257 - tmp = strchrW(tmp, '_') + 1; 3273 + tmp = wcschr(tmp, '_') + 1; 3274 + tmp = wcschr(tmp, '_') + 1; 3258 3275 if (dir_info->FileNameLength - (tmp - dir_info->FileName) * sizeof(WCHAR) == sizeof(wine_trailerW) && 3259 - !memicmpW( tmp, wine_trailerW, sizeof(wine_trailerW) / sizeof(WCHAR) )) 3276 + !wcsnicmp( tmp, wine_trailerW, ARRAY_SIZE( wine_trailerW ))) 3260 3277 { 3261 3278 /* prefer a non-Wine manifest if we already have one */ 3262 3279 /* we'll still load the builtin dll if specified through DllOverrides */ ··· 3297 3314 if (!ai->arch || !ai->name || !ai->public_key) return STATUS_NO_SUCH_FILE; 3298 3315 3299 3316 if (!(path = RtlAllocateHeap( GetProcessHeap(), 0, sizeof(manifest_dirW) + 3300 - strlenW(user_shared_data->NtSystemRoot) * sizeof(WCHAR) ))) 3317 + wcslen(windows_dir) * sizeof(WCHAR) ))) 3301 3318 return STATUS_NO_MEMORY; 3302 3319 3303 - strcpyW( path, user_shared_data->NtSystemRoot ); 3304 - memcpy( path + strlenW(path), manifest_dirW, sizeof(manifest_dirW) ); 3320 + wcscpy( path, windows_dir ); 3321 + wcscat( path, manifest_dirW ); 3305 3322 3306 3323 if (!RtlDosPathNameToNtPathName_U( path, &path_us, NULL, NULL )) 3307 3324 { ··· 3332 3349 3333 3350 /* append file name to directory path */ 3334 3351 if (!(path = RtlReAllocateHeap( GetProcessHeap(), 0, path_us.Buffer, 3335 - path_us.Length + (strlenW(file) + 2) * sizeof(WCHAR) ))) 3352 + path_us.Length + (wcslen(file) + 2) * sizeof(WCHAR) ))) 3336 3353 { 3337 3354 RtlFreeHeap( GetProcessHeap(), 0, file ); 3338 3355 RtlFreeUnicodeString( &path_us ); ··· 3340 3357 } 3341 3358 3342 3359 path[path_us.Length/sizeof(WCHAR)] = '\\'; 3343 - strcpyW( path + path_us.Length/sizeof(WCHAR) + 1, file ); 3360 + wcscpy( path + path_us.Length/sizeof(WCHAR) + 1, file ); 3344 3361 RtlInitUnicodeString( &path_us, path ); 3345 - *strrchrW(file, '.') = 0; /* remove .manifest extension */ 3362 + *wcsrchr(file, '.') = 0; /* remove .manifest extension */ 3346 3363 3347 3364 if (!open_nt_file( &handle, &path_us )) 3348 3365 { ··· 3375 3392 /* FIXME: add support for language specific lookup */ 3376 3393 3377 3394 len = max(RtlGetFullPathName_U(acl->actctx->assemblies->manifest.info, 0, NULL, NULL) / sizeof(WCHAR), 3378 - strlenW(acl->actctx->appdir.info)); 3395 + wcslen(acl->actctx->appdir.info)); 3379 3396 3380 3397 nameW.Buffer = NULL; 3381 3398 if (!(buffer = RtlAllocateHeap( GetProcessHeap(), 0, 3382 - (len + 2 * strlenW(ai->name) + 2) * sizeof(WCHAR) + sizeof(dotManifestW) ))) 3399 + (len + 2 * wcslen(ai->name) + 2) * sizeof(WCHAR) + sizeof(dotManifestW) ))) 3383 3400 return STATUS_NO_MEMORY; 3384 3401 3385 3402 if (!(directory = build_assembly_dir( ai ))) ··· 3396 3413 * First 'appdir' is used as <dir>, if that failed 3397 3414 * it tries application manifest file path. 3398 3415 */ 3399 - strcpyW( buffer, acl->actctx->appdir.info ); 3400 - p = buffer + strlenW(buffer); 3416 + wcscpy( buffer, acl->actctx->appdir.info ); 3417 + p = buffer + wcslen(buffer); 3401 3418 for (i = 0; i < 4; i++) 3402 3419 { 3403 3420 if (i == 2) ··· 3407 3424 } 3408 3425 else *p++ = '\\'; 3409 3426 3410 - strcpyW( p, ai->name ); 3411 - p += strlenW(p); 3427 + wcscpy( p, ai->name ); 3428 + p += wcslen(p); 3412 3429 3413 - strcpyW( p, dotDllW ); 3430 + wcscpy( p, dotDllW ); 3414 3431 if (RtlDosPathNameToNtPathName_U( buffer, &nameW, NULL, NULL )) 3415 3432 { 3416 3433 status = open_nt_file( &file, &nameW ); ··· 3419 3436 status = get_manifest_in_pe_file( acl, ai, nameW.Buffer, directory, FALSE, file, 3420 3437 (LPCWSTR)CREATEPROCESS_MANIFEST_RESOURCE_ID, 0 ); 3421 3438 NtClose( file ); 3422 - break; 3439 + if (status == STATUS_SUCCESS) 3440 + break; 3423 3441 } 3424 3442 RtlFreeUnicodeString( &nameW ); 3425 3443 } 3426 3444 3427 - strcpyW( p, dotManifestW ); 3445 + wcscpy( p, dotManifestW ); 3428 3446 if (RtlDosPathNameToNtPathName_U( buffer, &nameW, NULL, NULL )) 3429 3447 { 3430 3448 status = open_nt_file( &file, &nameW ); ··· 3525 3543 /* each entry needs index, data and string data */ 3526 3544 total_len += sizeof(*index); 3527 3545 total_len += sizeof(*data); 3528 - total_len += aligned_string_len((strlenW(dll->name)+1)*sizeof(WCHAR)); 3546 + total_len += aligned_string_len((wcslen(dll->name)+1)*sizeof(WCHAR)); 3529 3547 3530 3548 DPRINT("assembly %d (%p), dll %d: dll name %S\n", i, assembly, j, dll->name); 3531 3549 } ··· 3561 3579 DPRINT("%d: dll name %S\n", j, dll->name); 3562 3580 /* setup new index entry */ 3563 3581 str.Buffer = dll->name; 3564 - str.Length = strlenW(dll->name)*sizeof(WCHAR); 3582 + str.Length = wcslen(dll->name)*sizeof(WCHAR); 3565 3583 str.MaximumLength = str.Length + sizeof(WCHAR); 3566 3584 /* hash original class name */ 3567 3585 RtlHashUnicodeString(&str, TRUE, HASH_STRING_ALGORITHM_X65599, &index->hash); ··· 3597 3615 static struct string_index *find_string_index(const struct strsection_header *section, const UNICODE_STRING *name) 3598 3616 { 3599 3617 struct string_index *iter, *index = NULL; 3618 + UNICODE_STRING str; 3600 3619 ULONG hash = 0, i; 3601 3620 3602 3621 DPRINT("section %p, name %wZ\n", section, name); ··· 3609 3628 DPRINT("iter->name %S\n", (WCHAR*)((BYTE*)section + iter->name_offset)); 3610 3629 if (iter->hash == hash) 3611 3630 { 3612 - const WCHAR *nameW = (WCHAR*)((BYTE*)section + iter->name_offset); 3613 - 3614 - if (!_wcsnicmp(nameW, name->Buffer, name->Length / sizeof(WCHAR)) && 3615 - wcslen(nameW) == name->Length / sizeof(WCHAR)) 3631 + str.Buffer = (WCHAR *)((BYTE *)section + iter->name_offset); 3632 + str.Length = iter->name_len; 3633 + if (RtlEqualUnicodeString( &str, name, TRUE )) 3616 3634 { 3617 3635 index = iter; 3618 3636 break; 3619 3637 } 3620 3638 else 3621 - WARN("hash collision 0x%08x, %wZ, %S\n", hash, name, nameW); 3639 + WARN("hash collision 0x%08x, %wZ, %wZ\n", hash, name, &str); 3622 3640 } 3623 3641 iter++; 3624 3642 } ··· 3726 3744 struct entity *entity = &dll->entities.base[k]; 3727 3745 if (entity->kind == ACTIVATION_CONTEXT_SECTION_WINDOW_CLASS_REDIRECTION) 3728 3746 { 3729 - int class_len = strlenW(entity->u.class.name) + 1; 3747 + int class_len = wcslen(entity->u.class.name) + 1; 3730 3748 int len; 3731 3749 3732 3750 /* each class entry needs index, data and string data */ ··· 3739 3757 len = get_assembly_version(assembly, NULL) + class_len + 1 /* '!' separator */; 3740 3758 else 3741 3759 len = class_len; 3742 - len += strlenW(dll->name) + 1; 3760 + len += wcslen(dll->name) + 1; 3743 3761 total_len += aligned_string_len(len*sizeof(WCHAR)); 3744 3762 3745 3763 class_count++; ··· 3779 3797 3780 3798 /* setup new index entry */ 3781 3799 str.Buffer = entity->u.class.name; 3782 - str.Length = strlenW(entity->u.class.name)*sizeof(WCHAR); 3800 + str.Length = wcslen(entity->u.class.name)*sizeof(WCHAR); 3783 3801 str.MaximumLength = str.Length + sizeof(WCHAR); 3784 3802 /* hash original class name */ 3785 3803 RtlHashUnicodeString(&str, TRUE, HASH_STRING_ALGORITHM_X65599, &index->hash); ··· 3789 3807 versioned_len = (get_assembly_version(assembly, NULL) + 1)*sizeof(WCHAR) + str.Length; 3790 3808 else 3791 3809 versioned_len = str.Length; 3792 - module_len = strlenW(dll->name)*sizeof(WCHAR); 3810 + module_len = wcslen(dll->name)*sizeof(WCHAR); 3793 3811 3794 3812 index->name_offset = name_offset; 3795 3813 index->name_len = str.Length; ··· 3821 3839 if (entity->u.class.versioned) 3822 3840 { 3823 3841 get_assembly_version(assembly, ptrW); 3824 - strcatW(ptrW, exclW); 3825 - strcatW(ptrW, entity->u.class.name); 3842 + wcscat(ptrW, exclW); 3843 + wcscat(ptrW, entity->u.class.name); 3826 3844 } 3827 3845 else 3828 3846 { ··· 3849 3867 { 3850 3868 struct string_index *iter, *index = NULL; 3851 3869 struct wndclass_redirect_data *class; 3870 + UNICODE_STRING str; 3852 3871 ULONG hash; 3853 3872 int i; 3854 3873 ··· 3873 3892 { 3874 3893 if (iter->hash == hash) 3875 3894 { 3876 - const WCHAR *nameW = (WCHAR*)((BYTE*)actctx->wndclass_section + iter->name_offset); 3877 - 3878 - if (!strcmpiW(nameW, name->Buffer)) 3895 + str.Buffer = (WCHAR *)((BYTE *)actctx->wndclass_section + iter->name_offset); 3896 + str.Length = iter->name_len; 3897 + if (RtlEqualUnicodeString( &str, name, TRUE )) 3879 3898 { 3880 3899 index = iter; 3881 3900 break; 3882 3901 } 3883 3902 else 3884 - WARN("hash collision 0x%08x, %wZ, %S\n", hash, name, nameW); 3903 + WARN("hash collision 0x%08x, %wZ, %wZ\n", hash, name, &str); 3885 3904 } 3886 3905 iter++; 3887 3906 } ··· 3934 3953 total_len += sizeof(*data); 3935 3954 /* help string is stored separately */ 3936 3955 if (*entity->u.typelib.helpdir) 3937 - total_len += aligned_string_len((strlenW(entity->u.typelib.helpdir)+1)*sizeof(WCHAR)); 3956 + total_len += aligned_string_len((wcslen(entity->u.typelib.helpdir)+1)*sizeof(WCHAR)); 3938 3957 3939 3958 /* module names are packed one after another */ 3940 - names_len += (strlenW(dll->name)+1)*sizeof(WCHAR); 3959 + names_len += (wcslen(dll->name)+1)*sizeof(WCHAR); 3941 3960 3942 3961 tlib_count++; 3943 3962 } ··· 3977 3996 NTSTATUS Status; 3978 3997 3979 3998 if (*entity->u.typelib.helpdir) 3980 - help_len = strlenW(entity->u.typelib.helpdir)*sizeof(WCHAR); 3999 + help_len = wcslen(entity->u.typelib.helpdir)*sizeof(WCHAR); 3981 4000 else 3982 4001 help_len = 0; 3983 4002 3984 - module_len = strlenW(dll->name)*sizeof(WCHAR); 4003 + module_len = wcslen(dll->name)*sizeof(WCHAR); 3985 4004 3986 4005 /* setup new index entry */ 3987 4006 RtlInitUnicodeString(&str, entity->u.typelib.tlbid); ··· 4120 4139 unsigned int str_len; 4121 4140 4122 4141 /* all string data is stored together in aligned block */ 4123 - str_len = strlenW(entity->u.comclass.name)+1; 4142 + str_len = wcslen(entity->u.comclass.name)+1; 4124 4143 if (entity->u.comclass.progid) 4125 - str_len += strlenW(entity->u.comclass.progid)+1; 4144 + str_len += wcslen(entity->u.comclass.progid)+1; 4126 4145 if (entity->u.comclass.version) 4127 - str_len += strlenW(entity->u.comclass.version)+1; 4146 + str_len += wcslen(entity->u.comclass.version)+1; 4128 4147 4129 4148 *len += sizeof(struct clrclass_data); 4130 4149 *len += aligned_string_len(str_len*sizeof(WCHAR)); ··· 4136 4155 { 4137 4156 /* progid string is stored separately */ 4138 4157 if (entity->u.comclass.progid) 4139 - *len += aligned_string_len((strlenW(entity->u.comclass.progid)+1)*sizeof(WCHAR)); 4158 + *len += aligned_string_len((wcslen(entity->u.comclass.progid)+1)*sizeof(WCHAR)); 4140 4159 4141 - *module_len += (strlenW(dll->name)+1)*sizeof(WCHAR); 4160 + *module_len += (wcslen(dll->name)+1)*sizeof(WCHAR); 4142 4161 } 4143 4162 4144 4163 *count += 1; ··· 4158 4177 struct entity *entity = &entities->base[i]; 4159 4178 if (entity->kind == ACTIVATION_CONTEXT_SECTION_COM_SERVER_REDIRECTION) 4160 4179 { 4161 - ULONG module_len, progid_len, str_len = 0; 4180 + ULONG module_len, progid_len, str_len = 0, miscmask; 4162 4181 struct comclassredirect_data *data; 4163 4182 struct guid_index *alias_index; 4164 4183 struct clrclass_data *clrdata; ··· 4166 4185 WCHAR *ptrW; 4167 4186 4168 4187 if (entity->u.comclass.progid) 4169 - progid_len = strlenW(entity->u.comclass.progid)*sizeof(WCHAR); 4188 + progid_len = wcslen(entity->u.comclass.progid)*sizeof(WCHAR); 4170 4189 else 4171 4190 progid_len = 0; 4172 4191 4173 - module_len = dll ? strlenW(dll->name)*sizeof(WCHAR) : strlenW(mscoreeW)*sizeof(WCHAR); 4192 + module_len = dll ? wcslen(dll->name)*sizeof(WCHAR) : wcslen(mscoreeW)*sizeof(WCHAR); 4174 4193 4175 4194 /* setup new index entry */ 4176 4195 RtlInitUnicodeString(&str, entity->u.comclass.clsid); ··· 4194 4213 /* setup data */ 4195 4214 data = (struct comclassredirect_data*)((BYTE*)section + (*index)->data_offset); 4196 4215 data->size = sizeof(*data); 4197 - data->res = 0; 4198 - data->res1[0] = 0; 4199 - data->res1[1] = 0; 4200 4216 data->model = entity->u.comclass.model; 4201 4217 data->clsid = (*index)->guid; 4202 4218 data->alias = alias_index->guid; ··· 4223 4239 data->miscstatusdocprint = entity->u.comclass.miscstatusdocprint; 4224 4240 4225 4241 /* mask describes which misc* data is available */ 4226 - data->miscmask = 0; 4242 + miscmask = 0; 4227 4243 if (data->miscstatus) 4228 - data->miscmask |= MiscStatus; 4244 + miscmask |= MiscStatus; 4229 4245 if (data->miscstatuscontent) 4230 - data->miscmask |= MiscStatusContent; 4246 + miscmask |= MiscStatusContent; 4231 4247 if (data->miscstatusthumbnail) 4232 - data->miscmask |= MiscStatusThumbnail; 4248 + miscmask |= MiscStatusThumbnail; 4233 4249 if (data->miscstatusicon) 4234 - data->miscmask |= MiscStatusIcon; 4250 + miscmask |= MiscStatusIcon; 4235 4251 if (data->miscstatusdocprint) 4236 - data->miscmask |= MiscStatusDocPrint; 4252 + miscmask |= MiscStatusDocPrint; 4253 + data->flags = miscmask << 8; 4237 4254 4238 4255 if (data->clrdata_offset) 4239 4256 { ··· 4242 4259 clrdata->size = sizeof(*clrdata); 4243 4260 clrdata->res[0] = 0; 4244 4261 clrdata->res[1] = 2; /* FIXME: unknown field */ 4245 - clrdata->module_len = strlenW(mscoreeW)*sizeof(WCHAR); 4262 + clrdata->module_len = wcslen(mscoreeW)*sizeof(WCHAR); 4246 4263 clrdata->module_offset = *module_offset + data->name_len + sizeof(WCHAR); 4247 - clrdata->name_len = strlenW(entity->u.comclass.name)*sizeof(WCHAR); 4264 + clrdata->name_len = wcslen(entity->u.comclass.name)*sizeof(WCHAR); 4248 4265 clrdata->name_offset = clrdata->size; 4249 - clrdata->version_len = entity->u.comclass.version ? strlenW(entity->u.comclass.version)*sizeof(WCHAR) : 0; 4266 + clrdata->version_len = entity->u.comclass.version ? wcslen(entity->u.comclass.version)*sizeof(WCHAR) : 0; 4250 4267 clrdata->version_offset = clrdata->version_len ? clrdata->name_offset + clrdata->name_len + sizeof(WCHAR) : 0; 4251 4268 clrdata->res2[0] = 0; 4252 4269 clrdata->res2[1] = 0; ··· 4448 4465 { 4449 4466 *len += sizeof(struct guid_index) + sizeof(struct ifacepsredirect_data); 4450 4467 if (entity->u.ifaceps.name) 4451 - *len += aligned_string_len((strlenW(entity->u.ifaceps.name)+1)*sizeof(WCHAR)); 4468 + *len += aligned_string_len((wcslen(entity->u.ifaceps.name)+1)*sizeof(WCHAR)); 4452 4469 *count += 1; 4453 4470 } 4454 4471 } ··· 4470 4487 NTSTATUS Status; 4471 4488 4472 4489 if (entity->u.ifaceps.name) 4473 - name_len = strlenW(entity->u.ifaceps.name)*sizeof(WCHAR); 4490 + name_len = wcslen(entity->u.ifaceps.name)*sizeof(WCHAR); 4474 4491 else 4475 4492 name_len = 0; 4476 4493 ··· 4668 4685 ULONG len; 4669 4686 4670 4687 total_len += sizeof(*index) + sizeof(*data); 4671 - len = strlenW(entity->u.clrsurrogate.name) + 1; 4688 + len = wcslen(entity->u.clrsurrogate.name) + 1; 4672 4689 if (entity->u.clrsurrogate.version) 4673 - len += strlenW(entity->u.clrsurrogate.version) + 1; 4690 + len += wcslen(entity->u.clrsurrogate.version) + 1; 4674 4691 total_len += aligned_string_len(len*sizeof(WCHAR)); 4675 4692 4676 4693 count++; ··· 4705 4722 NTSTATUS Status; 4706 4723 4707 4724 if (entity->u.clrsurrogate.version) 4708 - version_len = strlenW(entity->u.clrsurrogate.version)*sizeof(WCHAR); 4725 + version_len = wcslen(entity->u.clrsurrogate.version)*sizeof(WCHAR); 4709 4726 else 4710 4727 version_len = 0; 4711 - name_len = strlenW(entity->u.clrsurrogate.name)*sizeof(WCHAR); 4728 + name_len = wcslen(entity->u.clrsurrogate.name)*sizeof(WCHAR); 4712 4729 4713 4730 /* setup new index entry */ 4714 4731 RtlInitUnicodeString(&str, entity->u.clrsurrogate.clsid); ··· 4818 4835 { 4819 4836 if (entity->u.comclass.progid) 4820 4837 { 4821 - *total_len += single_len + aligned_string_len((strlenW(entity->u.comclass.progid)+1)*sizeof(WCHAR)); 4838 + *total_len += single_len + aligned_string_len((wcslen(entity->u.comclass.progid)+1)*sizeof(WCHAR)); 4822 4839 *count += 1; 4823 4840 } 4824 4841 4825 4842 for (j = 0; j < entity->u.comclass.progids.num; j++) 4826 - *total_len += aligned_string_len((strlenW(entity->u.comclass.progids.progids[j])+1)*sizeof(WCHAR)); 4843 + *total_len += aligned_string_len((wcslen(entity->u.comclass.progids.progids[j])+1)*sizeof(WCHAR)); 4827 4844 4828 4845 *total_len += single_len*entity->u.comclass.progids.num; 4829 4846 *count += entity->u.comclass.progids.num; ··· 5109 5126 return STATUS_SUCCESS; 5110 5127 } 5111 5128 5129 + static const WCHAR *find_app_settings( ACTIVATION_CONTEXT *actctx, const WCHAR *settings, const WCHAR *ns ) 5130 + { 5131 + unsigned int i, j; 5132 + 5133 + for (i = 0; i < actctx->num_assemblies; i++) 5134 + { 5135 + struct assembly *assembly = &actctx->assemblies[i]; 5136 + for (j = 0; j < assembly->entities.num; j++) 5137 + { 5138 + struct entity *entity = &assembly->entities.base[j]; 5139 + if (entity->kind == ACTIVATION_CONTEXT_SECTION_APPLICATION_SETTINGS && 5140 + !wcscmp( entity->u.settings.name, settings ) && 5141 + !wcscmp( entity->u.settings.ns, ns )) 5142 + return entity->u.settings.value; 5143 + } 5144 + } 5145 + return NULL; 5146 + } 5147 + 5112 5148 /* initialize the activation context for the current process */ 5113 5149 void actctx_init(PVOID* pOldShimData) 5114 5150 { ··· 5149 5185 { 5150 5186 DPRINT1("Failed to create the implicit act ctx. Status: 0x%x!!!\n", Status); 5151 5187 } 5188 + 5189 + #ifdef __REACTOS__ 5190 + NtCurrentTeb()->ProcessEnvironmentBlock->ActivationContextData = process_actctx->ActivationContextData; 5191 + #else 5192 + NtCurrentTeb()->Peb->ActivationContextData = process_actctx; 5193 + #endif // __REACTOS__ 5152 5194 } 5153 5195 5154 5196 ··· 5208 5250 5209 5251 status = get_module_filename( module, &dir, 0 ); 5210 5252 if (!NT_SUCCESS(status)) goto error; 5211 - if ((p = strrchrW( dir.Buffer, '\\' ))) p[1] = 0; 5253 + if ((p = wcsrchr( dir.Buffer, '\\' ))) p[1] = 0; 5212 5254 actctx->appdir.info = dir.Buffer; 5213 5255 } 5214 5256 ··· 5226 5268 { 5227 5269 DWORD dir_len, source_len; 5228 5270 5229 - dir_len = strlenW(pActCtx->lpAssemblyDirectory); 5230 - source_len = strlenW(pActCtx->lpSource); 5271 + dir_len = wcslen(pActCtx->lpAssemblyDirectory); 5272 + source_len = wcslen(pActCtx->lpSource); 5231 5273 if (!(source = RtlAllocateHeap( GetProcessHeap(), 0, (dir_len+source_len+2)*sizeof(WCHAR)))) 5232 5274 { 5233 5275 status = STATUS_NO_MEMORY; ··· 5394 5436 return STATUS_NOT_IMPLEMENTED; 5395 5437 } 5396 5438 5397 - NTSTATUS 5398 - NTAPI RtlActivateActivationContextEx( ULONG flags, PTEB tebAddress, HANDLE handle, PULONG_PTR cookie ) 5439 + /****************************************************************** 5440 + * RtlActivateActivationContext (NTDLL.@) 5441 + */ 5442 + NTSTATUS WINAPI RtlActivateActivationContext( ULONG unknown, HANDLE handle, PULONG_PTR cookie ) 5443 + { 5444 + return RtlActivateActivationContextEx( 0, NtCurrentTeb(), handle, cookie ); 5445 + } 5446 + 5447 + /****************************************************************** 5448 + * RtlActivateActivationContextEx (NTDLL.@) 5449 + */ 5450 + NTSTATUS WINAPI RtlActivateActivationContextEx( ULONG flags, TEB *teb, HANDLE handle, ULONG_PTR *cookie ) 5399 5451 { 5400 5452 RTL_ACTIVATION_CONTEXT_STACK_FRAME *frame; 5401 5453 5402 5454 if (!(frame = RtlAllocateHeap( GetProcessHeap(), 0, sizeof(*frame) ))) 5403 5455 return STATUS_NO_MEMORY; 5404 5456 5405 - frame->Previous = tebAddress->ActivationContextStackPointer->ActiveFrame; 5457 + frame->Previous = teb->ActivationContextStackPointer->ActiveFrame; 5406 5458 frame->ActivationContext = handle; 5407 5459 frame->Flags = 0; 5408 5460 5409 5461 DPRINT("ActiveSP %p: ACTIVATE (ActiveFrame %p -> NewFrame %p, Context %p)\n", 5410 - tebAddress->ActivationContextStackPointer, tebAddress->ActivationContextStackPointer->ActiveFrame, 5462 + teb->ActivationContextStackPointer, teb->ActivationContextStackPointer->ActiveFrame, 5411 5463 frame, handle); 5412 5464 5413 - tebAddress->ActivationContextStackPointer->ActiveFrame = frame; 5465 + teb->ActivationContextStackPointer->ActiveFrame = frame; 5414 5466 RtlAddRefActivationContext( handle ); 5415 5467 5416 5468 *cookie = (ULONG_PTR)frame; ··· 5418 5470 return STATUS_SUCCESS; 5419 5471 } 5420 5472 5421 - /****************************************************************** 5422 - * RtlActivateActivationContext (NTDLL.@) 5423 - */ 5424 - NTSTATUS NTAPI RtlActivateActivationContext( ULONG flags, HANDLE handle, PULONG_PTR cookie ) 5425 - { 5426 - return RtlActivateActivationContextEx(flags, NtCurrentTeb(), handle, cookie); 5427 - } 5428 - 5429 5473 /*********************************************************************** 5430 5474 * RtlDeactivateActivationContext (NTDLL.@) 5431 5475 */ ··· 5598 5642 if (actctx->num_assemblies) assembly = actctx->assemblies; 5599 5643 5600 5644 if (assembly && assembly->manifest.info) 5601 - manifest_len = strlenW(assembly->manifest.info) + 1; 5602 - if (actctx->config.info) config_len = strlenW(actctx->config.info) + 1; 5603 - if (actctx->appdir.info) appdir_len = strlenW(actctx->appdir.info) + 1; 5645 + manifest_len = wcslen(assembly->manifest.info) + 1; 5646 + if (actctx->config.info) config_len = wcslen(actctx->config.info) + 1; 5647 + if (actctx->appdir.info) appdir_len = wcslen(actctx->appdir.info) + 1; 5604 5648 len = sizeof(*acdi) + (manifest_len + config_len + appdir_len) * sizeof(WCHAR); 5605 5649 5606 5650 if (retlen) *retlen = len; ··· 5657 5701 assembly = &actctx->assemblies[index - 1]; 5658 5702 5659 5703 if (!(assembly_id = build_assembly_id( &assembly->id ))) return STATUS_NO_MEMORY; 5660 - id_len = strlenW(assembly_id) + 1; 5661 - if (assembly->directory) ad_len = strlenW(assembly->directory) + 1; 5704 + id_len = wcslen(assembly_id) + 1; 5705 + if (assembly->directory) ad_len = wcslen(assembly->directory) + 1; 5662 5706 5663 5707 if (assembly->manifest.info && 5664 5708 (assembly->type == ASSEMBLY_MANIFEST || assembly->type == ASSEMBLY_SHARED_MANIFEST)) 5665 - path_len = strlenW(assembly->manifest.info) + 1; 5709 + path_len = wcslen(assembly->manifest.info) + 1; 5666 5710 5667 5711 len = sizeof(*afdi) + (id_len + ad_len + path_len) * sizeof(WCHAR); 5668 5712 ··· 5728 5772 return STATUS_INVALID_PARAMETER; 5729 5773 dll = &assembly->dlls[acqi->ulFileIndexInAssembly]; 5730 5774 5731 - if (dll->name) dll_len = strlenW(dll->name) + 1; 5775 + if (dll->name) dll_len = wcslen(dll->name) + 1; 5732 5776 len = sizeof(*afdi) + dll_len * sizeof(WCHAR); 5733 5777 5734 5778 if (!buffer || bufsize < len) ··· 5945 5989 status = find_guid( implicit_actctx, section_kind, guid, flags, data ); 5946 5990 5947 5991 return status; 5992 + } 5993 + 5994 + 5995 + /*********************************************************************** 5996 + * RtlQueryActivationContextApplicationSettings (NTDLL.@) 5997 + */ 5998 + NTSTATUS WINAPI RtlQueryActivationContextApplicationSettings( DWORD flags, HANDLE handle, const WCHAR *ns, 5999 + const WCHAR *settings, WCHAR *buffer, 6000 + SIZE_T size, SIZE_T *written ) 6001 + { 6002 + ACTIVATION_CONTEXT *actctx; 6003 + const WCHAR *res; 6004 + 6005 + if (flags) 6006 + { 6007 + WARN( "unknown flags %08x\n", flags ); 6008 + return STATUS_INVALID_PARAMETER; 6009 + } 6010 + 6011 + if (ns) 6012 + { 6013 + if (wcscmp( ns, windowsSettings2005NSW ) && 6014 + wcscmp( ns, windowsSettings2011NSW ) && 6015 + wcscmp( ns, windowsSettings2016NSW ) && 6016 + wcscmp( ns, windowsSettings2017NSW )) 6017 + return STATUS_INVALID_PARAMETER; 6018 + } 6019 + else ns = windowsSettings2005NSW; 6020 + 6021 + if (!handle) handle = process_actctx; 6022 + if (!(actctx = check_actctx( handle ))) return STATUS_INVALID_PARAMETER; 6023 + 6024 + if (!(res = find_app_settings( actctx, settings, ns ))) return STATUS_SXS_KEY_NOT_FOUND; 6025 + 6026 + if (written) *written = wcslen(res) + 1; 6027 + if (size < wcslen(res)) return STATUS_BUFFER_TOO_SMALL; 6028 + wcscpy( buffer, res ); 6029 + return STATUS_SUCCESS; 5948 6030 } 5949 6031 5950 6032 #ifdef __REACTOS__
+7
sdk/tools/winesync/rtl.cfg
··· 1 + directories: null 2 + files: 3 + dlls/ntdll/actctx.c: sdk/lib/rtl/actctx.c 4 + dlls/ntdll/timerqueue.c: sdk/lib/rtl/timerqueue.c 5 + dlls/ntdll/wait.c: sdk/lib/rtl/wait.c 6 + tags: 7 + wine: wine-5.18