ReactOS Fundraising Campaign 2012
 
€ 4,410 / € 30,000

Information | Donate

Home | Info | Community | Development | myReactOS | Contact Us

  1. Home
  2. Community
  3. Development
  4. myReactOS
  5. Fundraiser 2012

  1. Main Page
  2. Alphabetical List
  3. Data Structures
  4. Directories
  5. File List
  6. Data Fields
  7. Globals
  8. Related Pages

ReactOS Development > Doxygen

BOOLEAN WinLdrLoadSystemHive ( IN OUT PLOADER_PARAMETER_BLOCK  LoaderBlock,
IN LPCSTR  DirectoryPath,
IN LPCSTR  HiveName 
)

Definition at line 32 of file wlregistry.c.

Referenced by WinLdrInitSystemHive().

{
    ULONG FileId;
    CHAR FullHiveName[256];
    LONG Status;
    FILEINFORMATION FileInfo;
    ULONG HiveFileSize;
    ULONG_PTR HiveDataPhysical;
    PVOID HiveDataVirtual;
    ULONG BytesRead;
    LPCWSTR FsService;

    /* Concatenate path and filename to get the full name */
    strcpy(FullHiveName, DirectoryPath);
    strcat(FullHiveName, HiveName);
    //Print(L"Loading %s...\n", FullHiveName);
    Status = ArcOpen(FullHiveName, OpenReadOnly, &FileId);

    if (Status != ESUCCESS)
    {
        UiMessageBox("Opening hive file failed!");
        return FALSE;
    }

    /* Get the file length */
    Status = ArcGetFileInformation(FileId, &FileInfo);

    if (Status != ESUCCESS)
    {
        ArcClose(FileId);
        UiMessageBox("Hive file has 0 size!");
        return FALSE;
    }
    HiveFileSize = FileInfo.EndingAddress.LowPart;

    /* Round up the size to page boundary and alloc memory */
    HiveDataPhysical = (ULONG_PTR)MmAllocateMemoryWithType(
        MM_SIZE_TO_PAGES(HiveFileSize + MM_PAGE_SIZE - 1) << MM_PAGE_SHIFT,
        LoaderRegistryData);

    if (HiveDataPhysical == 0)
    {
        ArcClose(FileId);
        UiMessageBox("Unable to alloc memory for a hive!");
        return FALSE;
    }

    /* Convert address to virtual */
    HiveDataVirtual = PaToVa((PVOID)HiveDataPhysical);

    /* Fill LoaderBlock's entries */
    LoaderBlock->RegistryLength = HiveFileSize;
    LoaderBlock->RegistryBase = HiveDataVirtual;

    /* Finally read from file to the memory */
    Status = ArcRead(FileId, (PVOID)HiveDataPhysical, HiveFileSize, &BytesRead);
    if (Status != ESUCCESS)
    {
        ArcClose(FileId);
        UiMessageBox("Unable to read from hive file!");
        return FALSE;
    }

    // Add boot filesystem driver to the list
    FsService = FsGetServiceName(FileId);
    if (FsService)
    {
        TRACE("  Adding filesystem service %S\n", FsService);
        Status = WinLdrAddDriverToList(&LoaderBlock->BootDriverListHead,
            L"\\Registry\\Machine\\System\\CurrentControlSet\\Services\\",
            NULL,
            (LPWSTR)FsService);
        if (!Status)
            TRACE(" Failed to add filesystem service\n");
    }
    else
    {
        TRACE("  No required filesystem service\n");
    }

    ArcClose(FileId);
    return TRUE;
}

Generated on Sat May 26 2012 04:47:30 for ReactOS by doxygen 1.7.6.1

ReactOS is a registered trademark or a trademark of ReactOS Foundation in the United States and other countries.