Author: ion
Date: Sat Jul 23 09:28:15 2011
New Revision: 52789
URL:
http://svn.reactos.org/svn/reactos?rev=52789&view=rev
Log:
[KERNEL32]: Add ConvertOpenWin32AnsiObjectApiToUnicodeApi macro.
[KERNEL32]: Fix bugs #11, #12, #13: OpenJobObjectA did not correctly set the error code in
case the string was too long, nor did it use the TEB's static unicode cache, nor did
it enforce a 260 character object name limit. Fixed by using the new macro.
Modified:
trunk/reactos/dll/win32/kernel32/client/job.c
trunk/reactos/dll/win32/kernel32/include/base_x.h
Modified: trunk/reactos/dll/win32/kernel32/client/job.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/kernel32/client/…
==============================================================================
--- trunk/reactos/dll/win32/kernel32/client/job.c [iso-8859-1] (original)
+++ trunk/reactos/dll/win32/kernel32/client/job.c [iso-8859-1] Sat Jul 23 09:28:15 2011
@@ -92,31 +92,8 @@
BOOL bInheritHandle,
LPCSTR lpName)
{
- ANSI_STRING AnsiName;
- UNICODE_STRING UnicodeName;
- HANDLE hJob;
- NTSTATUS Status;
-
- if (lpName == NULL)
- {
- SetLastError(ERROR_INVALID_PARAMETER);
- return NULL;
- }
-
- RtlInitAnsiString(&AnsiName, lpName);
- Status = RtlAnsiStringToUnicodeString(&UnicodeName, &AnsiName, TRUE);
- if (!NT_SUCCESS(Status))
- {
- SetLastErrorByStatus(Status);
- return FALSE;
- }
-
- hJob = OpenJobObjectW(dwDesiredAccess,
- bInheritHandle,
- UnicodeName.Buffer);
-
- RtlFreeUnicodeString(&UnicodeName);
- return hJob;
+ /* Call the W(ide) function */
+ ConvertOpenWin32AnsiObjectApiToUnicodeApi(JobObject, dwDesiredAccess, bInheritHandle,
lpName);
}
Modified: trunk/reactos/dll/win32/kernel32/include/base_x.h
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/kernel32/include…
==============================================================================
--- trunk/reactos/dll/win32/kernel32/include/base_x.h [iso-8859-1] (original)
+++ trunk/reactos/dll/win32/kernel32/include/base_x.h [iso-8859-1] Sat Jul 23 09:28:15
2011
@@ -69,6 +69,17 @@
ConvertAnsiToUnicodeEpilogue
//
+// This macro uses the ConvertAnsiToUnicode macros above to convert a OpenXxxA
+// Win32 API into its equivalent OpenXxxW API.
+//
+#define ConvertOpenWin32AnsiObjectApiToUnicodeApi(obj, acc, inh, name) \
+ ConvertAnsiToUnicodePrologue \
+ if (!name) SetLastError(ERROR_INVALID_PARAMETER); return NULL; \
+ ConvertAnsiToUnicodeBody(name) \
+ if (NT_SUCCESS(Status)) return Open##obj##W(acc, inh, UnicodeCache->Buffer);\
+ ConvertAnsiToUnicodeEpilogue
+
+//
// This macro (split it up in 3 pieces to allow for intermediary code in between)
// wraps the usual code path required to create an NT object based on a Unicode
// (Wide) Win32 object creation API.