mirror of
https://github.com/reactos/reactos.git
synced 2025-02-25 01:39:30 +00:00
[KERNEL32]: New macro, not yet used. This one implements the CreateXxxW APIs (or rather, will).
svn path=/trunk/; revision=52785
This commit is contained in:
parent
acd4c15b61
commit
f185a728a7
1 changed files with 48 additions and 0 deletions
|
@ -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
|
||||
|
||||
|
|
Loading…
Reference in a new issue