Author: ion
Date: Sat Jul 23 09:58:48 2011
New Revision: 52792
URL: http://svn.reactos.org/svn/reactos?rev=52792&view=rev
Log:
[KERNEL32]: Forgot this, sorry.
Modified:
trunk/reactos/dll/win32/kernel32/kernel32.pspec
trunk/reactos/dll/win32/kernel32/kernel32.spec
Modified: trunk/reactos/dll/win32/kernel32/kernel32.pspec
URL: http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/kernel32/kernel3…
==============================================================================
--- trunk/reactos/dll/win32/kernel32/kernel32.pspec [iso-8859-1] (original)
+++ trunk/reactos/dll/win32/kernel32/kernel32.pspec [iso-8859-1] Sat Jul 23 09:58:48 2011
@@ -136,8 +136,6 @@
;@ stdcall CreateDirectoryTransactedW ; Win 7
@ stdcall CreateDirectoryW(wstr ptr)
@ stdcall CreateEventA(ptr long long str)
-@ stdcall CreateEventExA(ptr str long long)
-@ stdcall CreateEventExW(ptr wstr long long)
@ stdcall CreateEventW(ptr long long wstr)
@ stdcall CreateFiber(long ptr ptr)
@ stdcall CreateFiberEx(long long long ptr ptr)
@@ -162,8 +160,6 @@
@ stdcall CreateMailslotW(ptr long long ptr)
@ stdcall CreateMemoryResourceNotification(long)
@ stdcall CreateMutexA(ptr long str)
-@ stdcall CreateMutexExA(ptr str long long)
-@ stdcall CreateMutexExW(ptr wstr long long)
@ stdcall CreateMutexW(ptr long wstr)
@ stdcall CreateNamedPipeA(str long long long long long long ptr)
@ stdcall CreateNamedPipeW(wstr long long long long long long ptr)
@@ -179,8 +175,6 @@
@ stdcall CreateRemoteThread(long ptr long ptr long long ptr)
;@ stdcall CreateRemoteThreadEx api-ms-win-core-processthreads-l1-1-0.CreateRemoteThreadEx ; Win 7
@ stdcall CreateSemaphoreA(ptr long long str)
-@ stdcall CreateSemaphoreExA(ptr long long str long long)
-@ stdcall CreateSemaphoreExW(ptr long long wstr long long)
@ stdcall CreateSemaphoreW(ptr long long wstr)
@ stdcall CreateSocketHandle()
;@ stdcall CreateSymbolicLinkTransactedA ; Win 7
@@ -200,8 +194,6 @@
;@ stdcall arch=x86_64 CreateUmsThreadContext
@ stdcall CreateVirtualBuffer(long long long) ; missing in Win 7
@ stdcall CreateWaitableTimerA(ptr long str)
-@ stdcall CreateWaitableTimerExA(ptr str long long)
-@ stdcall CreateWaitableTimerExW(ptr wstr long long)
@ stdcall CreateWaitableTimerW(ptr long wstr)
@ stdcall DeactivateActCtx(long ptr)
@ stdcall DebugActiveProcess(long)
Modified: trunk/reactos/dll/win32/kernel32/kernel32.spec
URL: http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/kernel32/kernel3…
==============================================================================
--- trunk/reactos/dll/win32/kernel32/kernel32.spec [iso-8859-1] (original)
+++ trunk/reactos/dll/win32/kernel32/kernel32.spec [iso-8859-1] Sat Jul 23 09:58:48 2011
@@ -134,8 +134,6 @@
;@ stdcall CreateDirectoryTransactedW ; Win 7
@ stdcall CreateDirectoryW(wstr ptr)
@ stdcall CreateEventA(ptr long long str)
-@ stdcall CreateEventExA(ptr str long long)
-@ stdcall CreateEventExW(ptr wstr long long)
@ stdcall CreateEventW(ptr long long wstr)
@ stdcall CreateFiber(long ptr ptr)
@ stdcall CreateFiberEx(long long long ptr ptr)
@@ -160,8 +158,6 @@
@ stdcall CreateMailslotW(ptr long long ptr)
@ stdcall CreateMemoryResourceNotification(long)
@ stdcall CreateMutexA(ptr long str)
-@ stdcall CreateMutexExA(ptr str long long)
-@ stdcall CreateMutexExW(ptr wstr long long)
@ stdcall CreateMutexW(ptr long wstr)
@ stdcall CreateNamedPipeA(str long long long long long long ptr)
@ stdcall CreateNamedPipeW(wstr long long long long long long ptr)
@@ -177,8 +173,6 @@
@ stdcall CreateRemoteThread(long ptr long ptr long long ptr)
;@ stdcall CreateRemoteThreadEx api-ms-win-core-processthreads-l1-1-0.CreateRemoteThreadEx ; Win 7
@ stdcall CreateSemaphoreA(ptr long long str)
-@ stdcall CreateSemaphoreExA(ptr long long str long long)
-@ stdcall CreateSemaphoreExW(ptr long long wstr long long)
@ stdcall CreateSemaphoreW(ptr long long wstr)
@ stdcall CreateSocketHandle()
;@ stdcall CreateSymbolicLinkTransactedA ; Win 7
@@ -198,8 +192,6 @@
;@ stdcall arch=x86_64 CreateUmsThreadContext
@ stdcall CreateVirtualBuffer(long long long) ; missing in Win 7
@ stdcall CreateWaitableTimerA(ptr long str)
-@ stdcall CreateWaitableTimerExA(ptr str long long)
-@ stdcall CreateWaitableTimerExW(ptr wstr long long)
@ stdcall CreateWaitableTimerW(ptr long wstr)
@ stdcall DeactivateActCtx(long ptr)
@ stdcall DebugActiveProcess(long)
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.
Author: ion
Date: Sat Jul 23 00:30:56 2011
New Revision: 52787
URL: http://svn.reactos.org/svn/reactos?rev=52787&view=rev
Log:
[KERNEL32]: Fix bugs #4, #5, #6. CreateJobObjectA was building a dynamic string isntead of using the TEB. It was also not returning the right error code in case of error. It was also allowing jobs to have names past 260 characters. Fixed by using the ConvertWin32AnsiObjectApiToUnicodeApi macro from 5-6 revisions ago.
Modified:
trunk/reactos/dll/win32/kernel32/client/job.c
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 00:30:56 2011
@@ -27,32 +27,8 @@
CreateJobObjectA(LPSECURITY_ATTRIBUTES lpJobAttributes,
LPCSTR lpName)
{
- HANDLE hJob;
- ANSI_STRING AnsiName;
- UNICODE_STRING UnicodeName;
-
- if (lpName != NULL)
- {
- NTSTATUS Status;
-
- RtlInitAnsiString(&AnsiName, lpName);
- Status = RtlAnsiStringToUnicodeString(&UnicodeName, &AnsiName, TRUE);
- if (!NT_SUCCESS(Status))
- {
- SetLastErrorByStatus(Status);
- return FALSE;
- }
- }
-
- hJob = CreateJobObjectW(lpJobAttributes,
- ((lpName != NULL) ? UnicodeName.Buffer : NULL));
-
- if (lpName != NULL)
- {
- RtlFreeUnicodeString(&UnicodeName);
- }
-
- return hJob;
+ /* Call the W(ide) function */
+ ConvertWin32AnsiObjectApiToUnicodeApi(JobObject, lpName, lpJobAttributes);
}
Author: ion
Date: Sat Jul 23 00:28:33 2011
New Revision: 52785
URL: http://svn.reactos.org/svn/reactos?rev=52785&view=rev
Log:
[KERNEL32]: New macro, not yet used. This one implements the CreateXxxW APIs (or rather, will).
Modified:
trunk/reactos/dll/win32/kernel32/include/base_x.h
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 00:28:33 2011
@@ -68,3 +68,51 @@
if (NT_SUCCESS(Status)) return obj##W(UnicodeCache->Buffer, args); \
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.
+//
+// It makes use of BasepConvertObjectAttributes and allows for a custom access
+// mode to be used, and also sets the correct error codes in case of a collision
+//
+#define CreateNtObjectFromWin32ApiPrologue(sec, name) \
+{ \
+ NTSTATUS Status; \
+ OBJECT_ATTRIBUTES LocalAttributes; \
+ POBJECT_ATTRIBUTES ObjectAttributes; \
+ HANDLE Handle; \
+ UNICODE_STRING ObjectName; \
+ if (name) RtlInitUnicodeString(&ObjectName, name); \
+ ObjectAttributes = BasepConvertObjectAttributes(&LocalAttributes, \
+ sec, \
+ name ? &ObjectName : NULL);
+#define CreateNtObjectFromWin32ApiBody(ntobj, access, args...) \
+ Status = NtCreate##ntobj(&Handle, access, ObjectAttributes, args);
+#define CreateNtObjectFromWin32ApiEpilogue \
+ if (NT_SUCCESS(Status)) \
+ { \
+ if (Status == STATUS_OBJECT_NAME_EXISTS) \
+ SetLastError(ERROR_ALREADY_EXISTS); \
+ else \
+ SetLastError(ERROR_SUCCESS); \
+ return Handle; \
+ } \
+ SetLastErrorByStatus(Status); \
+ return NULL; \
+}
+
+//
+// This macro uses the CreateNtObjectFromWin32Api macros from above to create an
+// NT object based on the Win32 API settings.
+//
+// Note that it is hardcoded to always use XXX_ALL_ACCESS permissions, which is
+// the behavior up until Vista. When/if the target moves to Vista, the macro can
+// be improved to support caller-specified access masks, as the underlying macro
+// above does support this.
+//
+#define CreateNtObjectFromWin32Api(obj, ntobj, capsobj, sec, name, args...) \
+ CreateNtObjectFromWin32ApiPrologue(sec, name); \
+ CreateNtObjectFromWin32ApiBody(ntobj, capsobj##_ALL_ACCESS, args); \
+ CreateNtObjectFromWin32ApiEpilogue
+