summaryrefslogblamecommitdiffstats
path: root/private/ntos/boot/lib/blload.c
blob: 653ea9765a2b1fa2120bc6b1a25ba8a3a71c19b7 (plain) (tree)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736































































































































































































































































































































































































































































































































































































































































































































































                                                                                           
/*++

Copyright (c) 1992  Microsoft Corporation

Module Name:

    blload.c

Abstract:

    This module provides common code for loading things like drivers, NLS files, registry.
    Used by both the osloader and the setupldr.

Author:

    John Vert (jvert) 8-Oct-1993

Environment:

    ARC environment

Revision History:

--*/
#include "bldr.h"
#include "stdio.h"

ARC_STATUS
BlLoadSystemHive(
    IN ULONG DeviceId,
    IN PCHAR DeviceName,
    IN PCHAR DirectoryPath,
    IN PCHAR HiveName
    )

/*++

Routine Description:

    Loads the registry SYSTEM hive from <BootDirectory>\config\system.

    Allocates a memory descriptor to hold the hive image, reads the hive
    image into this descriptor, and updates the registry pointers in the
    LoaderBlock.

Arguments:

    DeviceId - Supplies the file id of the device the system tree is on.

    DeviceName - Supplies the name of the device the system tree is on.

    DirectoryPath - Supplies a pointer to the zero-terminated directory path
        of the root of the NT tree.

    HiveName - Supplies the name of the system hive ("SYSTEM" or "SYSTEM.ALT")

Return Value:

    TRUE - system hive successfully loaded.

    FALSE - system hive could not be loaded.

--*/

{
    CHAR RegistryName[256];
    ULONG FileId;
    ARC_STATUS Status;
    FILE_INFORMATION FileInformation;
    ULONG FileSize;
    ULONG ActualBase;
    PVOID LocalPointer;
    LARGE_INTEGER SeekValue;
    ULONG Count;
    PCHAR FailReason;

    //
    // Create the full filename for the SYSTEM hive.
    //

    strcpy(&RegistryName[0], DirectoryPath);
    strcat(&RegistryName[0], HiveName);
    BlOutputLoadMessage(DeviceName, &RegistryName[0]);
    Status = BlOpen(DeviceId, &RegistryName[0], ArcOpenReadOnly, &FileId);
    if (Status != ESUCCESS) {
        FailReason = "BlOpen";
        goto HiveLoadFailed;
    }

    //
    // Determine the length of the registry file
    //
    Status = BlGetFileInformation(FileId, &FileInformation);
    if (Status != ESUCCESS) {
        BlClose(FileId);
        FailReason = "BlGetFileInformation";
        goto HiveLoadFailed;
    }

    FileSize = FileInformation.EndingAddress.LowPart;
    if (FileSize == 0) {
        Status = EINVAL;
        BlClose(FileId);
        FailReason = "FileSize == 0";
        goto HiveLoadFailed;
    }

    //
    // Round up to a page boundary, allocate a memory
    // descriptor, fill in the registry fields in the
    // loader parameter block, and read the registry data
    // into memory.
    //

    Status = BlAllocateDescriptor(LoaderRegistryData,
                                  0x0,
                                  (FileSize + PAGE_SIZE - 1) >> PAGE_SHIFT,
                                  &ActualBase);
    if (Status != ESUCCESS) {
        BlClose(FileId);
        FailReason = "BlAllocateDescriptor";
        goto HiveLoadFailed;
    }

    LocalPointer = (PVOID)(KSEG0_BASE | (ActualBase << PAGE_SHIFT));
    BlLoaderBlock->RegistryLength = FileSize;
    BlLoaderBlock->RegistryBase = LocalPointer;

    //
    // Read the SYSTEM hive into the allocated memory.
    //

    SeekValue.QuadPart = 0;
    Status = BlSeek(FileId, &SeekValue, SeekAbsolute);
    if (Status != ESUCCESS) {
        BlClose(FileId);
        FailReason = "BlSeek";
        goto HiveLoadFailed;
    }
    Status = BlRead(FileId, LocalPointer, FileSize, &Count);
    BlClose(FileId);
    if (Status != ESUCCESS) {
        FailReason = "BlRead";
        goto HiveLoadFailed;
    }

    return(ESUCCESS);

HiveLoadFailed:
    //
    // The system hive didn't exist, or was corrupt.  Pass a NULL
    // pointer into the system, so it gets recreated.
    //
    return(Status);

}


ARC_STATUS
BlLoadNLSData(
    IN ULONG DeviceId,
    IN PCHAR DeviceName,
    IN PCHAR DirectoryPath,
    IN PUNICODE_STRING AnsiCodepage,
    IN PUNICODE_STRING OemCodepage,
    IN PUNICODE_STRING LanguageTable,
    OUT PCHAR BadFileName
    )

/*++

Routine Description:

    This routine loads all the NLS data files into one contiguous block of
    memory.

Arguments:

    DeviceId - Supplies the file id of the device the system tree is on.

    DeviceName - Supplies the name of the device the system tree is on.

    DirectoryPath - Supplies a pointer to the zero-terminated path
        of the directory containing the NLS files.

    AnsiCodePage - Supplies the filename of the ANSI codepage data file.

    OemCodePage - Supplies the filename of the OEM codepage data file.

    LanguageTable - Supplies the filename of the Unicode language case table.

    BadFileName - Returns the filename of the NLS file that was missing
        or invalid.  This will not be filled in if ESUCCESS is returned.

Return Value:

    ESUCCESS is returned if the NLS data was successfully loaded.
        Otherwise, an unsuccessful status is returned.

--*/

{
    CHAR Filename[100];
    ULONG AnsiFileId;
    ULONG OemFileId;
    ULONG LanguageFileId;
    ARC_STATUS Status;
    FILE_INFORMATION FileInformation;
    ULONG AnsiFileSize;
    ULONG OemFileSize;
    ULONG LanguageFileSize;
    ULONG TotalSize;
    ULONG ActualBase;
    PVOID LocalPointer;
    LARGE_INTEGER SeekValue;
    ULONG Count;
    BOOLEAN OemIsSameAsAnsi = FALSE;

    //
    // Under the Japanese version of NT, ANSI code page and OEM codepage
    // is same. In this case, we share the same data to save and memory.
    //

    if ( (AnsiCodepage->Length == OemCodepage->Length) &&
         (_wcsnicmp(AnsiCodepage->Buffer,
                   OemCodepage->Buffer,
                   AnsiCodepage->Length) == 0)) {

        OemIsSameAsAnsi = TRUE;
    }

    //
    // Open the ANSI data file
    //
    sprintf(Filename, "%s%wZ", DirectoryPath,AnsiCodepage);
    BlOutputLoadMessage(DeviceName, Filename);
    Status = BlOpen(DeviceId, Filename, ArcOpenReadOnly, &AnsiFileId);
    if (Status != ESUCCESS) {
        goto NlsLoadFailed;
    }
    Status = BlGetFileInformation(AnsiFileId, &FileInformation);
    BlClose(AnsiFileId);
    if (Status != ESUCCESS) {
        goto NlsLoadFailed;
    }
    AnsiFileSize = FileInformation.EndingAddress.LowPart;

    //
    // Open the OEM data file
    //
    if (OemIsSameAsAnsi) {
        OemFileSize = 0;
    } else {
        sprintf(Filename, "%s%wZ", DirectoryPath, OemCodepage);
        BlOutputLoadMessage(DeviceName, Filename);
        Status = BlOpen(DeviceId, Filename, ArcOpenReadOnly, &OemFileId);
        if (Status != ESUCCESS) {
            goto NlsLoadFailed;
        }
        Status = BlGetFileInformation(OemFileId, &FileInformation);
        BlClose(OemFileId);
        if (Status != ESUCCESS) {
            goto NlsLoadFailed;
        }
        OemFileSize = FileInformation.EndingAddress.LowPart;
    }

    //
    // Open the language codepage file
    //
    sprintf(Filename, "%s%wZ", DirectoryPath,LanguageTable);
    BlOutputLoadMessage(DeviceName, Filename);
    Status = BlOpen(DeviceId, Filename, ArcOpenReadOnly, &LanguageFileId);
    if (Status != ESUCCESS) {
        goto NlsLoadFailed;
    }
    Status = BlGetFileInformation(LanguageFileId, &FileInformation);
    BlClose(LanguageFileId);
    if (Status != ESUCCESS) {
        goto NlsLoadFailed;
    }
    LanguageFileSize = FileInformation.EndingAddress.LowPart;

    //
    // Calculate the total size of the descriptor needed.  We want each
    // data file to start on a page boundary, so round up each size to
    // page granularity.
    //
    TotalSize = ROUND_TO_PAGES(AnsiFileSize) +
                ROUND_TO_PAGES(OemFileSize)  +
                ROUND_TO_PAGES(LanguageFileSize);

    Status = BlAllocateDescriptor(LoaderNlsData,
                                  0x0,
                                  TotalSize >> PAGE_SHIFT,
                                  &ActualBase);
    if (Status != ESUCCESS) {
        goto NlsLoadFailed;
    }
    LocalPointer = (PVOID)(KSEG0_BASE | (ActualBase << PAGE_SHIFT));
    BlLoaderBlock->NlsData->AnsiCodePageData = LocalPointer;
    BlLoaderBlock->NlsData->OemCodePageData = (PVOID)((PUCHAR)LocalPointer +
                                             ROUND_TO_PAGES(AnsiFileSize));
    BlLoaderBlock->NlsData->UnicodeCaseTableData = (PVOID)((PUCHAR)LocalPointer +
                                             ROUND_TO_PAGES(AnsiFileSize) +
                                             ROUND_TO_PAGES(OemFileSize));

    //
    // Let OemCodePageData point as same location as AnsiCodePageData.
    //
    if( OemIsSameAsAnsi ) {
        BlLoaderBlock->NlsData->OemCodePageData = BlLoaderBlock->NlsData->AnsiCodePageData;
    }

    //
    // Read NLS data into memory
    //
    // open and read ANSI file
    //

    sprintf(Filename, "%s%wZ", DirectoryPath,AnsiCodepage);
    Status = BlOpen(DeviceId, Filename, ArcOpenReadOnly, &AnsiFileId);
    if (Status != ESUCCESS) {
        goto NlsLoadFailed;
    }
    SeekValue.QuadPart = 0;
    Status = BlSeek(AnsiFileId, &SeekValue, SeekAbsolute);
    if (Status != ESUCCESS) {
        goto NlsLoadFailed;
    }
    Status = BlRead(AnsiFileId,
                    BlLoaderBlock->NlsData->AnsiCodePageData,
                    AnsiFileSize,
                    &Count);
    if (Status != ESUCCESS) {
        goto NlsLoadFailed;
    }
    BlClose(AnsiFileId);

    //
    // Open and read OEM file
    //
    if (!OemIsSameAsAnsi) {
        sprintf(Filename, "%s%wZ", DirectoryPath, OemCodepage);
        Status = BlOpen(DeviceId, Filename, ArcOpenReadOnly, &OemFileId);
        if (Status != ESUCCESS) {
            goto NlsLoadFailed;
        }
        SeekValue.QuadPart = 0;
        Status = BlSeek(OemFileId, &SeekValue, SeekAbsolute);
        if (Status != ESUCCESS) {
            goto NlsLoadFailed;
        }
        Status = BlRead(OemFileId,
                        BlLoaderBlock->NlsData->OemCodePageData,
                        OemFileSize,
                        &Count);
        if (Status != ESUCCESS) {
            goto NlsLoadFailed;
        }
        BlClose(OemFileId);
    }

    //
    // open and read Language file
    //

    sprintf(Filename, "%s%wZ", DirectoryPath,LanguageTable);
    Status = BlOpen(DeviceId, Filename, ArcOpenReadOnly, &LanguageFileId);
    if (Status != ESUCCESS) {
        goto NlsLoadFailed;
    }
    SeekValue.QuadPart = 0;
    Status = BlSeek(LanguageFileId, &SeekValue, SeekAbsolute);
    if (Status != ESUCCESS) {
        goto NlsLoadFailed;
    }
    Status = BlRead(LanguageFileId,
                    BlLoaderBlock->NlsData->UnicodeCaseTableData,
                    LanguageFileSize,
                    &Count);
    if (Status != ESUCCESS) {
        goto NlsLoadFailed;
    }
    BlClose(LanguageFileId);

    return(ESUCCESS);

NlsLoadFailed:
    strcpy(BadFileName,Filename);
    return(Status);
}

ARC_STATUS
BlLoadOemHalFont(
    IN ULONG DeviceId,
    IN PCHAR DeviceName,
    IN PCHAR DirectoryPath,
    IN PUNICODE_STRING OemHalFont,
    OUT PCHAR BadFileName
    )

/*++

Routine Description:

    This routine loads the OEM font file for use the HAL display string
    function.

Arguments:

    DeviceId - Supplies the file id of the device the system tree is on.

    DeviceName - Supplies the name of the device the system tree is on.

    DirectoryPath - Supplies a pointer to the directory path of the root
        of the NT tree.

    Fontfile - Supplies the filename of the OEM font file.

    BadFileName - Returns the filename of the OEM font file that was missing
        or invalid.

Return Value:

    ESUCCESS is returned if the OEM font was successfully loaded. Otherwise,
    an unsuccessful status is returned and the bad file name is filled.

--*/

{

    PVOID FileBuffer;
    ULONG Count;
    PIMAGE_DOS_HEADER DosHeader;
    ULONG FileId;
    FILE_INFORMATION FileInformation;
    CHAR Filename[100];
    ULONG FileSize;
    ARC_STATUS Status;
    POEM_FONT_FILE_HEADER FontHeader;
    PIMAGE_OS2_HEADER Os2Header;
    ULONG ScaleFactor;
    RESOURCE_TYPE_INFORMATION UNALIGNED *TableAddress;
    RESOURCE_TYPE_INFORMATION UNALIGNED *TableEnd;
    RESOURCE_NAME_INFORMATION UNALIGNED *TableName;

    //
    // Open the OEM font file.
    //

    BlLoaderBlock->OemFontFile = NULL;

    sprintf(&Filename[0], "%s%wZ", DirectoryPath, OemHalFont);
    BlOutputLoadMessage(DeviceName, &Filename[0]);
    Status = BlOpen(DeviceId, &Filename[0], ArcOpenReadOnly, &FileId);
    if (Status != ESUCCESS) {
        goto OemLoadExit;
    }

    //
    // Get the size of the font file and allocate a buffer from the heap
    // to hold the font file. Typically this file is about 4kb in length.
    //

    Status = BlGetFileInformation(FileId, &FileInformation);
    if (Status != ESUCCESS) {
        goto OemLoadExit;
    }

    FileSize = FileInformation.EndingAddress.LowPart;
    FileBuffer = BlAllocateHeap(FileSize + BlDcacheFillSize - 1);
    if (FileBuffer == NULL) {
        Status = ENOMEM;
        goto OemLoadExit;
    }

    //
    // Round the file buffer address up to a cache line boundary and read
    // the file into memory.
    //

    FileBuffer = (PVOID)((ULONG)FileBuffer + BlDcacheFillSize - 1);
    FileBuffer = (PVOID)((ULONG)FileBuffer & ~(BlDcacheFillSize - 1));
    Status = BlRead(FileId,
                    FileBuffer,
                    FileSize,
                    &Count);

    if (Status != ESUCCESS) {
        goto OemLoadExit;
    }

    //
    // Attempt to recognize the file as either a .fon or .fnt file.
    //
    // Check if the file has a DOS header or a font file header. If the
    // file has a font file header, then it is a .fnt file. Otherwise,
    // it must be checked for an OS/2 executable with a font resource.
    //

    Status = EBADF;
    DosHeader = (PIMAGE_DOS_HEADER)FileBuffer;
    if (DosHeader->e_magic != IMAGE_DOS_SIGNATURE) {

        //
        // Check if the file has a font file header.
        //

        FontHeader = (POEM_FONT_FILE_HEADER)FileBuffer;
        if ((FontHeader->Version != OEM_FONT_VERSION) ||
            (FontHeader->Type != OEM_FONT_TYPE) ||
            (FontHeader->Italic != OEM_FONT_ITALIC) ||
            (FontHeader->Underline != OEM_FONT_UNDERLINE) ||
            (FontHeader->StrikeOut != OEM_FONT_STRIKEOUT) ||
            (FontHeader->CharacterSet != OEM_FONT_CHARACTER_SET) ||
            (FontHeader->Family != OEM_FONT_FAMILY) ||
            (FontHeader->PixelWidth > 32)) {

            goto OemLoadExit;

        } else {
            BlLoaderBlock->OemFontFile = (PVOID)FontHeader;
            Status = ESUCCESS;
            goto OemLoadExit;
        }
    }

    //
    // Check if the file has an OS/2 header.
    //

    if ((FileSize < sizeof(IMAGE_DOS_HEADER)) || (FileSize < (ULONG)DosHeader->e_lfanew)) {
        goto OemLoadExit;
    }

    Os2Header = (PIMAGE_OS2_HEADER)((PUCHAR)DosHeader + DosHeader->e_lfanew);
    if (Os2Header->ne_magic != IMAGE_OS2_SIGNATURE) {
        goto OemLoadExit;
    }

    //
    // Check if the resource table exists.
    //

    if ((Os2Header->ne_restab - Os2Header->ne_rsrctab) == 0) {
        goto OemLoadExit;
    }

    //
    // Compute address of resource table and search the table for a font
    // resource.
    //

    TableAddress =
        (PRESOURCE_TYPE_INFORMATION)((PUCHAR)Os2Header + Os2Header->ne_rsrctab);

    TableEnd =
        (PRESOURCE_TYPE_INFORMATION)((PUCHAR)Os2Header + Os2Header->ne_restab);

    ScaleFactor = *((SHORT UNALIGNED *)TableAddress)++;
    while ((TableAddress < TableEnd) &&
           (TableAddress->Ident != 0) &&
           (TableAddress->Ident != FONT_RESOURCE)) {

        TableAddress =
                (PRESOURCE_TYPE_INFORMATION)((PUCHAR)(TableAddress + 1) +
                    (TableAddress->Number * sizeof(RESOURCE_NAME_INFORMATION)));
    }

    if ((TableAddress >= TableEnd) || (TableAddress->Ident != FONT_RESOURCE)) {
        goto OemLoadExit;
    }

    //
    // Compute address of resource name information and check if the resource
    // is within the file.
    //

    TableName = (PRESOURCE_NAME_INFORMATION)(TableAddress + 1);
    if (FileSize < ((TableName->Offset << ScaleFactor) + sizeof(OEM_FONT_FILE_HEADER))) {
        goto OemLoadExit;
    }

    //
    // Compute the address of the font file header and check if the header
    // contains correct information.
    //

    FontHeader = (POEM_FONT_FILE_HEADER)((PCHAR)FileBuffer +
                                            (TableName->Offset << ScaleFactor));

    if ((FontHeader->Version != OEM_FONT_VERSION) ||
        (FontHeader->Type != OEM_FONT_TYPE) ||
        (FontHeader->Italic != OEM_FONT_ITALIC) ||
        (FontHeader->Underline != OEM_FONT_UNDERLINE) ||
        (FontHeader->StrikeOut != OEM_FONT_STRIKEOUT) ||
        (FontHeader->CharacterSet != OEM_FONT_CHARACTER_SET) ||
        (FontHeader->PixelWidth > 32)) {
        goto OemLoadExit;

    } else {
        BlLoaderBlock->OemFontFile = (PVOID)FontHeader;
        Status = ESUCCESS;
        goto OemLoadExit;
    }

    //
    // Exit loading of the OEM font file.
    //

OemLoadExit:
    BlClose(FileId);
    strcpy(BadFileName,&Filename[0]);
    return(Status);
}


ARC_STATUS
BlLoadDeviceDriver (
    IN ULONG DeviceId,
    IN PCHAR LoadDevice,
    IN PCHAR DirectoryPath,
    IN PCHAR DriverName,
    IN ULONG DriverFlags,
    OUT PLDR_DATA_TABLE_ENTRY *DriverDataTableEntry
    )

/*++

Routine Description:

    This routine loads the specified device driver and resolves all DLL
    references if the driver is not already loaded.

Arguments:

    DeviceId - Supplies the file id of the device on which the specified
        device driver is loaded from.

    LoadDevice - Supplies a pointer to a zero terminated load device
        string.

    DirectoryPath - Supplies a pointer to a zero terminated directory
        path string.

    DriverName - Supplies a pointer to a zero terminated device driver
        name string.

    DriverFlags - Supplies the driver flags that are to be set in the
        generated data table entry.

    DriverDataTableEntry - Receives a pointer to the data table entry
        created for the newly-loaded driver.

Return Value:

    ESUCCESS is returned if the specified driver is successfully loaded
    or it is already loaded. Otherwise, and unsuccessful status is
    returned.

--*/

{

    CHAR DllName[256];
    CHAR FullName[256];
    PVOID Base;
    ARC_STATUS Status;

    //
    // Generate the DLL name for the device driver.
    //

    strcpy(&DllName[0], DriverName);

    //
    // If the specified device driver is not already loaded, then load it.
    //

    if (BlCheckForLoadedDll(&DllName[0], DriverDataTableEntry) == FALSE) {

        //
        // Generate the full path name of device driver.
        //

        strcpy(&FullName[0], &DirectoryPath[0]);
        strcat(&FullName[0], DriverName);
        BlOutputLoadMessage(LoadDevice, &FullName[0]);
        Status = BlLoadImage(DeviceId,
                             LoaderBootDriver,
                             &FullName[0],
                             TARGET_IMAGE,
                             &Base);

        if (Status != ESUCCESS) {
            return Status;
        }

        //
        // Generate a data table entry for the driver, then clear the entry
        // processed flag. The I/O initialization code calls each DLL in the
        // loaded module list that does not have its entry processed flag set.
        //

        Status = BlAllocateDataTableEntry(&DllName[0],
                                          DriverName,
                                          Base,
                                          DriverDataTableEntry);

        if (Status != ESUCCESS) {
            return Status;
        }

        (*DriverDataTableEntry)->Flags |= DriverFlags;

        //
        // Scan the import table and load all the referenced DLLs.
        //

        Status = BlScanImportDescriptorTable(DeviceId,
                                             LoadDevice,
                                             &DirectoryPath[0],
                                             *DriverDataTableEntry);

        if (Status != ESUCCESS) {
            //
            // Remove the driver from the load order list.
            //
            RemoveEntryList(&(*DriverDataTableEntry)->InLoadOrderLinks);
            return Status;
        }

    }
    return ESUCCESS;
}