Hey Eric,
On 2019-08-24 14:01, Eric Kohl wrote:
+PSTR
+WINAPI
+NetpAllocStrFromWStr(
+ _In_ PWSTR InString)
+{
+ UNICODE_STRING UnicodeString;
+ OEM_STRING OemString;
+ ULONG Size;
+ NET_API_STATUS NetStatus;
+ NTSTATUS Status;
+
+ RtlInitUnicodeString(&UnicodeString, InString);
+
+ Size = RtlUnicodeStringToOemSize(&UnicodeString);
+ NetStatus = NetApiBufferAllocate(Size,
+ (PVOID*)&OemString.Buffer);
+ if (NetStatus != NERR_Success)
+ return NULL;
+
It seems like OemString.MaximumLength should be initialized before
calling RtlUnicodeStringToOemString?
+ Status =
RtlUnicodeStringToOemString(&OemString,
+ &UnicodeString,
+ FALSE);
+ if (!NT_SUCCESS(Status))
+ {
+ NetApiBufferFree(OemString.Buffer);
+ return NULL;
+ }
+
+ return OemString.Buffer;
+}
Best,
Thomas