ntoskrnl.exe: Implement file object constructor.

Signed-off-by: Jacek Caban <jacek@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
Jacek Caban 2019-02-26 13:39:57 +01:00 committed by Alexandre Julliard
parent 855314449b
commit 637e01e217
2 changed files with 15 additions and 1 deletions

View File

@ -369,16 +369,26 @@ NTSTATUS WINAPI ObReferenceObjectByHandle( HANDLE handle, ACCESS_MASK access,
}
static void *create_file_object( HANDLE handle );
static const WCHAR file_type_name[] = {'F','i','l','e',0};
static struct _OBJECT_TYPE file_type = {
file_type_name,
NULL,
create_file_object,
free_kernel_object
};
POBJECT_TYPE IoFileObjectType = &file_type;
static void *create_file_object( HANDLE handle )
{
FILE_OBJECT *file;
if (!(file = alloc_kernel_object( IoFileObjectType, sizeof(*file), 0 ))) return NULL;
file->Type = 5; /* MSDN */
file->Size = sizeof(*file);
return file;
}
/* transfer result of IRP back to wineserver */
static NTSTATUS WINAPI dispatch_irp_completion( DEVICE_OBJECT *device, IRP *irp, void *context )

View File

@ -664,6 +664,7 @@ static void test_ob_reference(const WCHAR *test_path)
{
OBJECT_ATTRIBUTES attr = { sizeof(attr) };
HANDLE event_handle, file_handle, file_handle2, thread_handle;
FILE_OBJECT *file;
void *obj1, *obj2;
UNICODE_STRING pathU;
IO_STATUS_BLOCK io;
@ -732,6 +733,9 @@ static void test_ob_reference(const WCHAR *test_path)
todo_wine
ok(obj1 == obj2, "obj1 != obj2\n");
file = obj1;
ok(file->Type == 5, "Type = %u\n", file->Type);
ObDereferenceObject(obj1);
ObDereferenceObject(obj2);