Author: ion Date: Sat Jul 23 02:17:26 2011 New Revision: 52788
URL: http://svn.reactos.org/svn/reactos?rev=52788&view=rev Log: [KERNEL32]: Fix the object macros to be MSVC/C99 compatible. Also allow for the variadic part to contain no arguments. [KERNEL32]: Fix bugs #7, #8, #9, #10: CreateJobObjectW did not add OBJ_OPENIF to named jobs, it did not add named objects in the BaseNamedObjects directory, it did not correctly set ERROR_ALREADY_EXISTS when collisions happened, and it did not set ERROR_SUCCESS when the object was created. All this was fixed by using the new CreateNtObjectFromWin32Api 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/j... ============================================================================== --- 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 02:17:26 2011 @@ -18,72 +18,29 @@
/* FUNCTIONS ****************************************************************/
- /* * @implemented */ HANDLE WINAPI -CreateJobObjectA(LPSECURITY_ATTRIBUTES lpJobAttributes, - LPCSTR lpName) +CreateJobObjectA(IN LPSECURITY_ATTRIBUTES lpJobAttributes, + IN LPCSTR lpName) { /* Call the W(ide) function */ ConvertWin32AnsiObjectApiToUnicodeApi(JobObject, lpName, lpJobAttributes); }
- /* * @implemented */ HANDLE WINAPI -CreateJobObjectW(LPSECURITY_ATTRIBUTES lpJobAttributes, - LPCWSTR lpName) -{ - UNICODE_STRING JobName; - OBJECT_ATTRIBUTES ObjectAttributes; - ULONG Attributes = 0; - PVOID SecurityDescriptor; - HANDLE hJob; - NTSTATUS Status; - - if (lpName != NULL) - { - RtlInitUnicodeString(&JobName, lpName); - } - - if (lpJobAttributes != NULL) - { - if (lpJobAttributes->bInheritHandle) - { - Attributes |= OBJ_INHERIT; - } - - SecurityDescriptor = lpJobAttributes->lpSecurityDescriptor; - } - else - { - SecurityDescriptor = NULL; - } - - InitializeObjectAttributes(&ObjectAttributes, - ((lpName != NULL) ? &JobName : NULL), - Attributes, - NULL, - SecurityDescriptor); - - Status = NtCreateJobObject(&hJob, - JOB_OBJECT_ALL_ACCESS, - &ObjectAttributes); - if (!NT_SUCCESS(Status)) - { - SetLastErrorByStatus(Status); - return NULL; - } - - return hJob; -} - +CreateJobObjectW(IN LPSECURITY_ATTRIBUTES lpJobAttributes, + IN LPCWSTR lpName) +{ + /* Create the NT object */ + CreateNtObjectFromWin32Api(JobObject, JobObject, JOB, lpJobAttributes, lpName); +}
/* * @implemented
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 02:17:26 2011 @@ -51,21 +51,21 @@ // This macro uses the ConvertAnsiToUnicode macros above to convert a CreateXxxA // Win32 API into its equivalent CreateXxxW API. // -#define ConvertWin32AnsiObjectApiToUnicodeApi(obj, name, args...) \ +#define ConvertWin32AnsiObjectApiToUnicodeApi(obj, name, ...) \ ConvertAnsiToUnicodePrologue \ - if (!name) return Create##obj##W(args, NULL); \ + if (!name) return Create##obj##W(__VA_ARGS__, NULL); \ ConvertAnsiToUnicodeBody(name) \ - if (NT_SUCCESS(Status)) return Create##obj##W(args, UnicodeCache->Buffer); \ + if (NT_SUCCESS(Status)) return Create##obj##W(__VA_ARGS__, UnicodeCache->Buffer); \ ConvertAnsiToUnicodeEpilogue
// // This macro uses the ConvertAnsiToUnicode macros above to convert a FindFirst*A // Win32 API into its equivalent FindFirst*W API. // -#define ConvertWin32AnsiChangeApiToUnicodeApi(obj, name, args...) \ +#define ConvertWin32AnsiChangeApiToUnicodeApi(obj, name, ...) \ ConvertAnsiToUnicodePrologue \ ConvertAnsiToUnicodeBody(name) \ - if (NT_SUCCESS(Status)) return obj##W(UnicodeCache->Buffer, args); \ + if (NT_SUCCESS(Status)) return obj##W(UnicodeCache->Buffer, ##__VA_ARGS__); \ ConvertAnsiToUnicodeEpilogue
// @@ -87,8 +87,8 @@ ObjectAttributes = BasepConvertObjectAttributes(&LocalAttributes, \ sec, \ name ? &ObjectName : NULL); -#define CreateNtObjectFromWin32ApiBody(ntobj, access, args...) \ - Status = NtCreate##ntobj(&Handle, access, ObjectAttributes, args); +#define CreateNtObjectFromWin32ApiBody(ntobj, access, ...) \ + Status = NtCreate##ntobj(&Handle, access, ObjectAttributes, ##__VA_ARGS__); #define CreateNtObjectFromWin32ApiEpilogue \ if (NT_SUCCESS(Status)) \ { \ @@ -111,8 +111,8 @@ // be improved to support caller-specified access masks, as the underlying macro // above does support this. // -#define CreateNtObjectFromWin32Api(obj, ntobj, capsobj, sec, name, args...) \ +#define CreateNtObjectFromWin32Api(obj, ntobj, capsobj, sec, name, ...) \ CreateNtObjectFromWin32ApiPrologue(sec, name); \ - CreateNtObjectFromWin32ApiBody(ntobj, capsobj##_ALL_ACCESS, args); \ + CreateNtObjectFromWin32ApiBody(ntobj, capsobj##_ALL_ACCESS, ##__VA_ARGS__); \ CreateNtObjectFromWin32ApiEpilogue