Author: pschweitzer
Date: Tue Feb 22 18:43:38 2011
New Revision: 50867
URL:
http://svn.reactos.org/svn/reactos?rev=50867&view=rev
Log:
[KERNEL32]
Don't make GetBinaryTypeA() rely on Wine's strings conversions functions
Modified:
trunk/reactos/dll/win32/kernel32/file/bintype.c
Modified: trunk/reactos/dll/win32/kernel32/file/bintype.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/kernel32/file/bi…
==============================================================================
--- trunk/reactos/dll/win32/kernel32/file/bintype.c [iso-8859-1] (original)
+++ trunk/reactos/dll/win32/kernel32/file/bintype.c [iso-8859-1] Tue Feb 22 18:43:38 2011
@@ -301,23 +301,43 @@
*/
BOOL
WINAPI
-GetBinaryTypeA (
- LPCSTR lpApplicationName,
- LPDWORD lpBinaryType
- )
+GetBinaryTypeA(IN LPCSTR lpApplicationName,
+ OUT LPDWORD lpBinaryType)
{
- PWCHAR ApplicationNameW;
-
- if(!lpApplicationName || !lpBinaryType)
- {
- SetLastError(ERROR_INVALID_PARAMETER);
- return FALSE;
- }
-
- if (!(ApplicationNameW = FilenameA2W(lpApplicationName, FALSE)))
- return FALSE;
-
- return GetBinaryTypeW(ApplicationNameW, lpBinaryType);
+ ANSI_STRING ApplicationNameString;
+ UNICODE_STRING ApplicationNameW;
+ BOOL StringAllocated = FALSE, Result;
+ NTSTATUS Status;
+
+ RtlInitAnsiString(&ApplicationNameString, lpApplicationName);
+
+ if (ApplicationNameString.Length * sizeof(WCHAR) >=
NtCurrentTeb()->StaticUnicodeString.MaximumLength)
+ {
+ StringAllocated = TRUE;
+ Status = RtlAnsiStringToUnicodeString(&ApplicationNameW,
&ApplicationNameString, TRUE);
+ }
+ else
+ {
+ Status =
RtlAnsiStringToUnicodeString(&(NtCurrentTeb()->StaticUnicodeString),
&ApplicationNameString, FALSE);
+ }
+
+ if (!NT_SUCCESS(Status))
+ {
+ BaseSetLastNTError(Status);
+ return FALSE;
+ }
+
+ if (StringAllocated)
+ {
+ Result = GetBinaryTypeW(ApplicationNameW.Buffer, lpBinaryType);
+ RtlFreeUnicodeString(&ApplicationNameW);
+ }
+ else
+ {
+ Result = GetBinaryTypeW(NtCurrentTeb()->StaticUnicodeString.Buffer,
lpBinaryType);
+ }
+
+ return Result;
}
/* EOF */