mirror of
https://github.com/reactos/reactos.git
synced 2025-08-03 18:25:58 +00:00
[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. svn path=/trunk/; revision=52789
This commit is contained in:
parent
5496adb4bc
commit
d06e82af03
2 changed files with 13 additions and 25 deletions
|
@ -92,31 +92,8 @@ OpenJobObjectA(DWORD dwDesiredAccess,
|
||||||
BOOL bInheritHandle,
|
BOOL bInheritHandle,
|
||||||
LPCSTR lpName)
|
LPCSTR lpName)
|
||||||
{
|
{
|
||||||
ANSI_STRING AnsiName;
|
/* Call the W(ide) function */
|
||||||
UNICODE_STRING UnicodeName;
|
ConvertOpenWin32AnsiObjectApiToUnicodeApi(JobObject, dwDesiredAccess, bInheritHandle, lpName);
|
||||||
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;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -68,6 +68,17 @@
|
||||||
if (NT_SUCCESS(Status)) return obj##W(UnicodeCache->Buffer, ##__VA_ARGS__); \
|
if (NT_SUCCESS(Status)) return obj##W(UnicodeCache->Buffer, ##__VA_ARGS__); \
|
||||||
ConvertAnsiToUnicodeEpilogue
|
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)
|
// 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
|
// wraps the usual code path required to create an NT object based on a Unicode
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue