File tree Expand file tree Collapse file tree 2 files changed +55
-0
lines changed
Expand file tree Collapse file tree 2 files changed +55
-0
lines changed Original file line number Diff line number Diff line change @@ -70,3 +70,10 @@ PeLdrCheckForLoadedDll(
7070PVOID
7171PeLdrInitSecurityCookie (
7272 _In_ PLDR_DATA_TABLE_ENTRY LdrEntry );
73+
74+ BOOLEAN
75+ PeLdrLoadBootImage (
76+ _In_ PCSTR FilePath ,
77+ _In_ PCSTR BaseDllName ,
78+ _Out_ PVOID * ImageBase ,
79+ _Out_ PLDR_DATA_TABLE_ENTRY * DataTableEntry );
Original file line number Diff line number Diff line change @@ -1044,3 +1044,51 @@ PeLdrLoadImage(
10441044{
10451045 return PeLdrLoadImageEx (FilePath , MemoryType , ImageBasePA , TRUE);
10461046}
1047+
1048+ BOOLEAN
1049+ PeLdrLoadBootImage (
1050+ _In_ PCSTR FilePath ,
1051+ _In_ PCSTR BaseDllName ,
1052+ _Out_ PVOID * ImageBase ,
1053+ _Out_ PLDR_DATA_TABLE_ENTRY * DataTableEntry )
1054+ {
1055+ BOOLEAN Success ;
1056+
1057+ /* Load the image as a bootloader image */
1058+ Success = PeLdrLoadImageEx (FilePath ,
1059+ LoaderLoadedProgram ,
1060+ ImageBase ,
1061+ FALSE);
1062+ if (!Success )
1063+ {
1064+ WARN ("Failed to load boot image '%s'\n" , FilePath );
1065+ return FALSE;
1066+ }
1067+
1068+ /* Allocate a DTE */
1069+ Success = PeLdrAllocateDataTableEntry (& FrLdrModuleList ,
1070+ BaseDllName ,
1071+ FilePath ,
1072+ * ImageBase ,
1073+ DataTableEntry );
1074+ if (!Success )
1075+ {
1076+ /* Cleanup and bail out */
1077+ ERR ("Failed to allocate DTE for '%s'\n" , FilePath );
1078+ MmFreeMemory (* ImageBase );
1079+ return FALSE;
1080+ }
1081+
1082+ /* Resolve imports */
1083+ Success = PeLdrScanImportDescriptorTable (& FrLdrModuleList , "" , * DataTableEntry );
1084+ if (!Success )
1085+ {
1086+ /* Cleanup and bail out */
1087+ ERR ("Failed to resolve imports for '%s'\n" , FilePath );
1088+ PeLdrFreeDataTableEntry (* DataTableEntry );
1089+ MmFreeMemory (* ImageBase );
1090+ return FALSE;
1091+ }
1092+
1093+ return TRUE;
1094+ }
You can’t perform that action at this time.
0 commit comments