NTSTATUS NTAPI NtCreateKey( PHANDLE KeyHandle, ACCESS_MASK DesiredAccess, POBJECT_ATTRIBUTES ObjectAttributes, ULONG TitleIndex, PUNICODE_STRING Class, ULONG CreateOptions, PULONG Disposition ) { object_attributes_t oa; NTSTATUS r; regkey_t *key = NULL; trace("%p %08lx %p %lu %p %lu %p\n", KeyHandle, DesiredAccess, ObjectAttributes, TitleIndex, Class, CreateOptions, Disposition ); if (Disposition) { r = verify_for_write( Disposition, sizeof *Disposition ); if (r < STATUS_SUCCESS) return r; } r = oa.copy_from_user( ObjectAttributes ); if (r < STATUS_SUCCESS) return r; trace("len %08lx root %p attr %08lx %pus\n", oa.Length, oa.RootDirectory, oa.Attributes, oa.ObjectName); unicode_string_t cls; if (Class) { r = cls.copy_from_user( Class ); if (r < STATUS_SUCCESS) return r; } bool opened_existing = false; r = create_key( &key, &oa, opened_existing ); if (r == STATUS_SUCCESS) { if (Disposition) { ULONG dispos = opened_existing ? REG_OPENED_EXISTING_KEY : REG_CREATED_NEW_KEY; copy_to_user( Disposition, &dispos, sizeof *Disposition ); } key->cls.copy( &cls ); r = alloc_user_handle( key, DesiredAccess, KeyHandle ); //release( event ); } return r; }
NTSTATUS NTAPI NtCreateThread( PHANDLE Thread, ACCESS_MASK DesiredAccess, POBJECT_ATTRIBUTES ObjectAttributes, HANDLE Process, PCLIENT_ID ClientId, PCONTEXT Context, PINITIAL_TEB InitialTeb, BOOLEAN CreateSuspended ) { INITIAL_TEB init_teb; CONTEXT ctx; NTSTATUS r; process_t *p; thread_t *t = NULL; CLIENT_ID id; dprintf("%p %08lx %p %p %p %p %p %d\n", Thread, DesiredAccess, ObjectAttributes, Process, ClientId, Context, InitialTeb, CreateSuspended); r = copy_from_user( &ctx, Context, sizeof ctx ); if (r < STATUS_SUCCESS) return r; r = copy_from_user( &init_teb, InitialTeb, sizeof init_teb ); if (r < STATUS_SUCCESS) return r; r = process_from_handle( Process, &p ); if (r < STATUS_SUCCESS) return r; memset( &id, 0, sizeof id ); r = create_thread( &t, p, &id, &ctx, &init_teb, CreateSuspended ); if (r == STATUS_SUCCESS) { r = alloc_user_handle( t, DesiredAccess, Thread ); release( t ); } if (r == STATUS_SUCCESS) r = copy_to_user( ClientId, &id, sizeof id ); return r; }
NTSTATUS NTAPI NtOpenKey( PHANDLE KeyHandle, ACCESS_MASK DesiredAccess, POBJECT_ATTRIBUTES ObjectAttributes ) { OBJECT_ATTRIBUTES oa; unicode_string_t us; NTSTATUS r; regkey_t *key = NULL; trace("%p %08lx %p\n", KeyHandle, DesiredAccess, ObjectAttributes ); // copies the unicode string before validating object attributes struct r = copy_from_user( &oa, ObjectAttributes, sizeof oa ); if (r < STATUS_SUCCESS) return r; r = us.copy_from_user( oa.ObjectName ); if (r < STATUS_SUCCESS) return r; oa.ObjectName = &us; if (oa.Length != sizeof oa) return STATUS_INVALID_PARAMETER; trace("len %08lx root %p attr %08lx %pus\n", oa.Length, oa.RootDirectory, oa.Attributes, oa.ObjectName); r = open_key( &key, &oa ); trace("open_key returned %08lx\n", r); if (r == STATUS_SUCCESS) { r = alloc_user_handle( key, DesiredAccess, KeyHandle ); //release( event ); } return r; }