Skip to content

Commit bf40c7a

Browse files
committed
[KERNEL32] Let KERNEL32 assign security to NLS section names
Currently Kernel32 doesn't make any server call to Basesrv in order to create NLS section names, instead it's Kernel32 itself that handles the job of NLS section names. With that said, let Kernel32 assign a security descriptor to NLS section names. See the FIXME comment on code for further dtails
1 parent 5696e4b commit bf40c7a

File tree

1 file changed

+22
-1
lines changed
  • dll/win32/kernel32/winnls/string

1 file changed

+22
-1
lines changed

dll/win32/kernel32/winnls/string/nls.c

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,9 @@ GetCPFileNameFromRegistry(UINT CodePage, LPWSTR FileName, ULONG FileNameSize);
5959
NTSTATUS
6060
CreateNlsDirectorySecurity(_Out_ PSECURITY_DESCRIPTOR *NlsSecurityDescriptor);
6161

62+
NTSTATUS WINAPI
63+
CreateNlsSecurityDescriptor(_Out_ PSECURITY_DESCRIPTOR *SecurityDescriptor, _In_ SIZE_T DescriptorSize, _In_ ULONG AccessMask);
64+
6265
/* PRIVATE FUNCTIONS **********************************************************/
6366

6467
/**
@@ -219,6 +222,7 @@ IntGetCodePageEntry(UINT CodePage)
219222
WCHAR FileName[MAX_PATH + 1];
220223
UINT FileNamePos;
221224
PCODEPAGE_ENTRY CodePageEntry;
225+
PSECURITY_DESCRIPTOR NlsSd;
222226
if (CodePage == CP_ACP)
223227
{
224228
return &AnsiCodePage;
@@ -281,7 +285,23 @@ IntGetCodePageEntry(UINT CodePage)
281285
RtlInitAnsiString(&AnsiName, SectionName);
282286
RtlAnsiStringToUnicodeString(&UnicodeName, &AnsiName, TRUE);
283287

284-
InitializeObjectAttributes(&ObjectAttributes, &UnicodeName, 0, NULL, NULL);
288+
/*
289+
* FIXME: IntGetCodePageEntry should not create any security
290+
* descriptor here but instead this responsibility should be
291+
* assigned to Base Server API (aka basesrv.dll). That is,
292+
* kernel32 must instruct basesrv.dll on creating NLS section
293+
* names that do not exist through API message communication.
294+
* However since we do not do that, let the kernel32 do the job
295+
* by assigning security to NLS section names for the time being...
296+
*/
297+
Status = CreateNlsSecurityDescriptor(&NlsSd, sizeof(SECURITY_DESCRIPTOR), SECTION_MAP_READ);
298+
if (!NT_SUCCESS(Status))
299+
{
300+
RtlLeaveCriticalSection(&CodePageListLock);
301+
return NULL;
302+
}
303+
304+
InitializeObjectAttributes(&ObjectAttributes, &UnicodeName, 0, NULL, NlsSd);
285305

286306
/* Try to open the section first */
287307
Status = NtOpenSection(&SectionHandle, SECTION_MAP_READ, &ObjectAttributes);
@@ -329,6 +349,7 @@ IntGetCodePageEntry(UINT CodePage)
329349
}
330350
}
331351
RtlFreeUnicodeString(&UnicodeName);
352+
HeapFree(GetProcessHeap(), 0, NlsSd);
332353

333354
if (!NT_SUCCESS(Status))
334355
{

0 commit comments

Comments
 (0)