diff --git a/reactos/dll/win32/kernel32/client/job.c b/reactos/dll/win32/kernel32/client/job.c index 6e830ed8685..4e28f711488 100644 --- a/reactos/dll/win32/kernel32/client/job.c +++ b/reactos/dll/win32/kernel32/client/job.c @@ -92,31 +92,8 @@ OpenJobObjectA(DWORD dwDesiredAccess, 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); } diff --git a/reactos/dll/win32/kernel32/include/base_x.h b/reactos/dll/win32/kernel32/include/base_x.h index 877e11375a9..4405710c4c8 100644 --- a/reactos/dll/win32/kernel32/include/base_x.h +++ b/reactos/dll/win32/kernel32/include/base_x.h @@ -68,6 +68,17 @@ if (NT_SUCCESS(Status)) return obj##W(UnicodeCache->Buffer, ##__VA_ARGS__); \ 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