Mark Harmstone mark@harmstone.com writes:
+static NTSTATUS load_string_us( ULONG id, LANGID lang, PUNICODE_STRING us ) +{
- const IMAGE_RESOURCE_DATA_ENTRY *data;
- LDR_RESOURCE_INFO info;
- NTSTATUS status;
- WCHAR *p;
- int i;
- info.Type = 6; /* RT_STRING */
- info.Name = (id >> 4) + 1;
- info.Language = lang;
- if ((status = LdrFindResource_U( kernel32_handle, &info, 3, &data ))) return status;
- p = (WCHAR *)((char *)kernel32_handle + data->OffsetToData);
- for (i = 0; i < (id & 0x0f); i++) p += *p + 1;
- if (*p >= us->MaximumLength / sizeof(WCHAR)) return STATUS_BUFFER_TOO_SMALL;
- us->Length = *p * sizeof(WCHAR);
- memcpy( us->Buffer, p + 1, us->Length );
- return STATUS_SUCCESS;
+}
You could probably reuse the existing helper. This would need some tests about the behavior on short buffers.
- /* kernel32 doesn't store information about primary languages */
LOCALE_SPARENT seems pretty close.