Skip to content

Commit 2795360

Browse files
[FREELDR:APPLETV] Fix MSVC build (don't msvc build; disk access is still broken)
1 parent 2f517c8 commit 2795360

File tree

3 files changed

+18
-12
lines changed

3 files changed

+18
-12
lines changed

boot/freeldr/freeldr/arch/i386/appletv/appletventry.S

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,9 @@
99
#include <arch/pc/x86common.h>
1010
#include <arch/pc/pcbios.h>
1111

12+
EXTERN _InitIdt:PROC
13+
EXTERN _i386Idt:DWORD
14+
1215
#ifdef _USE_ML
1316
EXTERN __bss_start__:DWORD
1417
EXTERN __bss_end__:DWORD
@@ -17,10 +20,7 @@ EXTERN __bss_end__:DWORD
1720
#define APPLETV_COMMAND_LINE_OFFSET 4
1821

1922
/* VOID __cdecl BootMain(IN PCCH CmdLine) */
20-
EXTERN _BootMain
21-
22-
/* Align to 32 bits boundary */
23-
.align 4
23+
EXTERN _BootMain:PROC
2424

2525
.code32
2626
ASSUME ES:NOTHING, FS:NOTHING, GS:NOTHING
@@ -128,4 +128,4 @@ i386idtptr:
128128
.word 255 /* Limit */
129129
.long _i386Idt /* Base Address */
130130

131-
END
131+
END

boot/freeldr/freeldr/include/arch/appletv/boot_args.h

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,21 +12,27 @@
1212
#define DISPLAY_MODE_GRAPHICS 1
1313
#define DISPLAY_MODE_TEXT 2
1414

15+
#ifdef _MSC_VER
16+
#define ALIGNED(a) __declspec(align(a))
17+
#else
18+
#define ALIGNED(a) __attribute__((aligned(a)))
19+
#endif
20+
1521
/* Video parameters passed to kernel. */
16-
typedef struct {
22+
typedef struct ALIGNED(4) {
1723
UINT32 BaseAddress; /* Base video address */
1824
UINT32 DisplayMode; /* Display mode specifier */
1925
UINT32 Pitch; /* Bytes per row */
2026
UINT32 Width; /* Display width in pixels */
2127
UINT32 Height; /* Display height in pixels */
2228
UINT32 Depth; /* Display depth in bits */
23-
} __attribute__((aligned(4))) MACH_VIDEO, *PMACH_VIDEO;
29+
} MACH_VIDEO, *PMACH_VIDEO;
2430

2531
/* Boot arguments struct passed into loader. A pointer to this struct is located in the EAX register upon kernel load.
2632
* See xnu-1228 pexpert/pexpert/i386/boot.h.
2733
*/
2834

29-
typedef struct {
35+
typedef struct ALIGNED(4) {
3036
UINT16 Revision; /* Revision of this structure */
3137
UINT16 Version; /* Version of this structure */
3238

@@ -53,6 +59,6 @@ typedef struct {
5359

5460
UINT8 __reserved1[3];
5561
UINT8 __reserved2[7];
56-
} __attribute__((aligned(4))) MACH_BOOTARGS, *PMACH_BOOTARGS;
62+
} MACH_BOOTARGS, *PMACH_BOOTARGS;
5763

5864
extern PMACH_BOOTARGS BootArgs;

sdk/tools/pe2macho/pe2macho.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ FindOptionalHeaderFromFileHeader(PIMAGE_FILE_HEADER FileHeader)
5757

5858
static
5959
PMACHO_HEADER
60-
CreateMachOHeaderFromPeHeader(PIMAGE_OPTIONAL_HEADER32 OptionalHeader, PUINT Size)
60+
CreateMachOHeaderFromPeHeader(PIMAGE_OPTIONAL_HEADER32 OptionalHeader, UINT32 PeSize, PUINT Size)
6161
{
6262
UINT32 MachoInfoSize;
6363
PMACHO_HEADER MachoHeader;
@@ -83,7 +83,7 @@ CreateMachOHeaderFromPeHeader(PIMAGE_OPTIONAL_HEADER32 OptionalHeader, PUINT Siz
8383

8484
memset(MachoHeader, 0, MachoInfoSize);
8585

86-
SizeOfExecData = OptionalHeader->SizeOfInitializedData - 1;
86+
SizeOfExecData = PeSize - 0x1000 - 1;
8787

8888
// Fill out Mach-O header.
8989
MachoHeader->MagicNumber = MACHO_MAGIC;
@@ -239,7 +239,7 @@ main(INT argc, PCHAR argv[])
239239
}
240240

241241
// Convert PE executable header to Mach-O
242-
MachoHeader = CreateMachOHeaderFromPeHeader(PeOptionalHeader, &MachoSize);
242+
MachoHeader = CreateMachOHeaderFromPeHeader(PeOptionalHeader, InputFileLength, &MachoSize);
243243
if (!MachoHeader)
244244
{
245245
fprintf(stderr, "Failed to create Mach-O header!\n");

0 commit comments

Comments
 (0)