reactos操作系统实现(79)

前端之家收集整理的这篇文章主要介绍了reactos操作系统实现(79)前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。

下面这个函数实现标记引导分区,代码如下:

#001 BOOLEAN

#002 INIT_FUNCTION

#003 NTAPI

#004 IopMarkBootPartition(IN PLOADER_PARAMETER_BLOCK LoaderBlock)

#005 {

#006 OBJECT_ATTRIBUTES ObjectAttributes;

#007 STRING DeviceString;

#008 CHAR Buffer[256];

#009 UNICODE_STRING DeviceName;

#010 NTSTATUS Status;

#011 HANDLE FileHandle;

#012 IO_STATUS_BLOCK IoStatusBlock;

#013 PFILE_OBJECT FileObject;

#014

创建ARC的设备名称

#015 /* Build the ARC device name */

#016 sprintf(Buffer,"//ArcName//%s",LoaderBlock->ArcBootDeviceName);

#017 RtlInitAnsiString(&DeviceString,Buffer);

#018 Status = RtlAnsiStringToUnicodeString(&DeviceName,&DeviceString,TRUE);

#019 if (!NT_SUCCESS(Status)) return FALSE;

#020

打开引导设备。

#021 /* Open it */

#022 InitializeObjectAttributes(&ObjectAttributes,

#023 &DeviceName,

#024 OBJ_CASE_INSENSITIVE,

#025 NULL,

#026 NULL);

#027 Status = ZwOpenFile(&FileHandle,

#028 FILE_READ_ATTRIBUTES,

#029 &ObjectAttributes,

#030 &IoStatusBlock,

#031 0,

#032 FILE_NON_DIRECTORY_FILE);

#033 if (!NT_SUCCESS(Status))

#034 {

#035 /* Fail */

#036 KeBugCheckEx(INACCESSIBLE_BOOT_DEVICE,

#037 (ULONG_PTR)&DeviceName,

#038 Status,

#039 0,

#040 0);

#041 }

#042

获取这个设备的对象。

#043 /* Get the DO */

#044 Status = ObReferenceObjectByHandle(FileHandle,

#045 0,

#046 IoFileObjectType,

#047 KernelMode,

#048 (PVOID *)&FileObject,

#049 NULL);

#050 if (!NT_SUCCESS(Status))

#051 {

#052 /* Fail */

#053 RtlFreeUnicodeString(&DeviceName);

#054 return FALSE;

#055 }

#056

标记这个文件对象是引导分区。

#057 /* Mark it as the boot partition */

#058 FileObject->DeviceObject->Flags |= DO_SYSTEM_BOOT_PARTITION;

#059

#060 /* Save a copy of the DO for the I/O Error Logger */

#061 ObReferenceObject(FileObject->DeviceObject);

#062 IopErrorlogobject = FileObject->DeviceObject;

#063

#064 /* Cleanup and return success */

#065 RtlFreeUnicodeString(&DeviceName);

#066 NtClose(FileHandle);

#067 ObDereferenceObject(FileObject);

#068 return TRUE;

#069 }

#070

原文链接:https://www.f2er.com/react/308451.html

猜你在找的React相关文章