Skip to content

Commit

Permalink
Merge pull request #69 from AnErrupTion/main
Browse files Browse the repository at this point in the history
Update to .NET 7 and newer Windows SDK
  • Loading branch information
Dell-Optiplex-390 authored Nov 28, 2022
2 parents 80e57cd + bbbae3f commit 10737de
Show file tree
Hide file tree
Showing 16 changed files with 46 additions and 44 deletions.
5 changes: 4 additions & 1 deletion ConsoleApp1/ConsoleApp1.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,17 @@

<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net6.0</TargetFramework>
<TargetFramework>net7.0</TargetFramework>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
<BaseOutputPath>..\bin</BaseOutputPath>

<Optimize>true</Optimize>
<SelfContained>false</SelfContained>

<GenerateAssemblyInfo>false</GenerateAssemblyInfo>
<GenerateTargetFrameworkAttribute>false</GenerateTargetFrameworkAttribute>
<ErrorOnDuplicatePublishOutputFiles>false</ErrorOnDuplicatePublishOutputFiles>
<AppendTargetFrameworkToOutputPath>false</AppendTargetFrameworkToOutputPath>

<IlcSystemModule>Corlib</IlcSystemModule>
<EntryPointSymbol>Main</EntryPointSymbol>
Expand Down
7 changes: 5 additions & 2 deletions ConsoleOS/ConsoleOS.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -2,22 +2,25 @@

<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net6.0</TargetFramework>
<TargetFramework>net7.0</TargetFramework>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
<BaseOutputPath>..\bin</BaseOutputPath>

<Optimize>true</Optimize>
<SelfContained>false</SelfContained>

<GenerateAssemblyInfo>false</GenerateAssemblyInfo>
<GenerateTargetFrameworkAttribute>false</GenerateTargetFrameworkAttribute>
<ErrorOnDuplicatePublishOutputFiles>false</ErrorOnDuplicatePublishOutputFiles>
<AppendTargetFrameworkToOutputPath>false</AppendTargetFrameworkToOutputPath>

<DefineConstants>Kernel;HasGC;UseAPIC;</DefineConstants>

<IlcSystemModule>Corlib</IlcSystemModule>
<EntryPointSymbol>Entry</EntryPointSymbol>
<LinkerSubsystem>NATIVE</LinkerSubsystem>
<!--Make the code faster!-->
<IlcOptimizationPreference>Size</IlcOptimizationPreference>
<IlcOptimizationPreference>Speed</IlcOptimizationPreference>
</PropertyGroup>

<Target Name="RenameExt" AfterTargets="CopyNativeBinary">
Expand Down
2 changes: 1 addition & 1 deletion Corlib/Corlib.csproj
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>net6.0</TargetFramework>
<TargetFramework>net7.0</TargetFramework>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
<BaseOutputPath>..\bin</BaseOutputPath>

Expand Down
7 changes: 5 additions & 2 deletions Corlib/Internal/Runtime/CompilerHelpers/StartupCodeHelpers.cs
Original file line number Diff line number Diff line change
Expand Up @@ -39,10 +39,10 @@ static void RhpPinvoke(IntPtr frame) { }
static void RhpPinvokeReturn(IntPtr frame) { }

[DllImport("*")]
static unsafe extern void memset(byte* ptr, byte c, ulong count);
public static unsafe extern void memset(byte* ptr, byte c, ulong count);

[DllImport("*")]
static unsafe extern void memcpy(byte* dest, byte* src, ulong count);
public static unsafe extern void memcpy(byte* dest, byte* src, ulong count);

[RuntimeExport("RhpNewFast")]
static unsafe object RhpNewFast(EEType* pEEType)
Expand All @@ -64,6 +64,9 @@ static unsafe object RhpNewFast(EEType* pEEType)
[DllImport("*")]
public static extern nint malloc(ulong size);

[DllImport("*")]
public static extern ulong free(nint ptr);

[RuntimeExport("RhpNewArray")]
internal static unsafe object RhpNewArray(EEType* pEEType, int length)
{
Expand Down
22 changes: 5 additions & 17 deletions Corlib/System/Diagnostics/Process.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,9 @@ public static void Start(byte[] exe)
if (!nthdr->OptionalHeader.BaseRelocationTable.VirtualAddress) return;
if (nthdr->OptionalHeader.ImageBase != 0x140000000) return;

byte* newPtr = (byte*)malloc(nthdr->OptionalHeader.SizeOfImage);
memset(newPtr, 0, nthdr->OptionalHeader.SizeOfImage);
memcpy(newPtr, ptr, nthdr->OptionalHeader.SizeOfHeaders);
byte* newPtr = (byte*)StartupCodeHelpers.malloc(nthdr->OptionalHeader.SizeOfImage);
StartupCodeHelpers.memset(newPtr, 0, nthdr->OptionalHeader.SizeOfImage);
StartupCodeHelpers.memcpy(newPtr, ptr, nthdr->OptionalHeader.SizeOfHeaders);

DOSHeader* newdoshdr = (DOSHeader*)newPtr;
NtHeaders64* newnthdr = (NtHeaders64*)(newPtr + newdoshdr->e_lfanew);
Expand All @@ -28,33 +28,21 @@ public static void Start(byte[] exe)
for (int i = 0; i < newnthdr->FileHeader.NumberOfSections; i++)
{
if (*(ulong*)sections[i].Name == 0x73656C75646F6D2E) moduleSeg = (IntPtr)((ulong)newPtr + sections[i].VirtualAddress);
memcpy((byte*)((ulong)newPtr + sections[i].VirtualAddress), ptr + sections[i].PointerToRawData, sections[i].SizeOfRawData);
StartupCodeHelpers.memcpy((byte*)((ulong)newPtr + sections[i].VirtualAddress), ptr + sections[i].PointerToRawData, sections[i].SizeOfRawData);
}
FixImageRelocations(newdoshdr, newnthdr, (long)((ulong)newPtr - newnthdr->OptionalHeader.ImageBase));

delegate*<void> p = (delegate*<void>)((ulong)newPtr + newnthdr->OptionalHeader.AddressOfEntryPoint);
//TO-DO disposing
StartupCodeHelpers.InitializeModules(moduleSeg);
StartThread(p);
//free((IntPtr)ptr);
//StartupCodeHelpers.free((IntPtr)ptr);
}
}

[DllImport("*")]
static extern nint malloc(ulong size);

[DllImport("*")]
static extern ulong free(nint ptr);

[DllImport("StartThread")]
static extern void StartThread(delegate*<void> func);

[DllImport("*")]
static unsafe extern void memset(byte* ptr, byte c, ulong count);

[DllImport("*")]
static unsafe extern void memcpy(byte* dest, byte* src, ulong count);

static void FixImageRelocations(DOSHeader* dos_header, NtHeaders64* nt_header, long delta)
{
ulong size;
Expand Down
7 changes: 5 additions & 2 deletions CosmosKernel1/CosmosKernel1.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -2,22 +2,25 @@

<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net6.0</TargetFramework>
<TargetFramework>net7.0</TargetFramework>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
<BaseOutputPath>..\bin</BaseOutputPath>

<Optimize>true</Optimize>
<SelfContained>false</SelfContained>

<GenerateAssemblyInfo>false</GenerateAssemblyInfo>
<GenerateTargetFrameworkAttribute>false</GenerateTargetFrameworkAttribute>
<ErrorOnDuplicatePublishOutputFiles>false</ErrorOnDuplicatePublishOutputFiles>
<AppendTargetFrameworkToOutputPath>false</AppendTargetFrameworkToOutputPath>

<DefineConstants>Kernel;HasGC;UseAPIC;</DefineConstants>

<IlcSystemModule>Corlib</IlcSystemModule>
<EntryPointSymbol>Entry</EntryPointSymbol>
<LinkerSubsystem>NATIVE</LinkerSubsystem>
<!--Make the code faster!-->
<IlcOptimizationPreference>Size</IlcOptimizationPreference>
<IlcOptimizationPreference>Speed</IlcOptimizationPreference>
</PropertyGroup>

<Target Name="RenameExt" AfterTargets="CopyNativeBinary">
Expand Down
2 changes: 1 addition & 1 deletion CosmosKernel1/Kernel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ namespace CosmosKernel1
{
public class Kernel : Sys.Kernel
{
static extern void Main();
static void Main() { }

[RuntimeExport("KMain")]
static void KMain()
Expand Down
1 change: 0 additions & 1 deletion DoomPortable
Submodule DoomPortable deleted from 8bac1c
2 changes: 1 addition & 1 deletion LibC/LibC.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@
<Keyword>Win32Proj</Keyword>
<ProjectGuid>{19d564ff-d5ce-4566-9ef6-088112a4f08f}</ProjectGuid>
<RootNamespace>LibC</RootNamespace>
<WindowsTargetPlatformVersion>10.0</WindowsTargetPlatformVersion>
<WindowsTargetPlatformVersion>10.0.22000.0</WindowsTargetPlatformVersion>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
Expand Down
7 changes: 5 additions & 2 deletions MOOS/MOOS.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -2,22 +2,25 @@

<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net6.0</TargetFramework>
<TargetFramework>net7.0</TargetFramework>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
<BaseOutputPath>..\bin</BaseOutputPath>

<Optimize>true</Optimize>
<SelfContained>false</SelfContained>

<GenerateAssemblyInfo>false</GenerateAssemblyInfo>
<GenerateTargetFrameworkAttribute>false</GenerateTargetFrameworkAttribute>
<ErrorOnDuplicatePublishOutputFiles>false</ErrorOnDuplicatePublishOutputFiles>
<AppendTargetFrameworkToOutputPath>false</AppendTargetFrameworkToOutputPath>

<DefineConstants>Kernel;HasGC;UseAPIC;HasGUI</DefineConstants>

<IlcSystemModule>Corlib</IlcSystemModule>
<EntryPointSymbol>Entry</EntryPointSymbol>
<LinkerSubsystem>NATIVE</LinkerSubsystem>
<!--Make the code faster!-->
<IlcOptimizationPreference>Size</IlcOptimizationPreference>
<IlcOptimizationPreference>Speed</IlcOptimizationPreference>
</PropertyGroup>

<Target Name="RenameExt" AfterTargets="CopyNativeBinary">
Expand Down
2 changes: 1 addition & 1 deletion MOOS/Properties/launchSettings.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"Run.bat": {
"commandName": "Executable",
"executablePath": "Run.bat",
"commandLineArgs": "MOOS vmware",
"commandLineArgs": "MOOS qemu",
"workingDirectory": "../"
}
}
Expand Down
1 change: 0 additions & 1 deletion NESPortable
Submodule NESPortable deleted from c115be
2 changes: 1 addition & 1 deletion NativeLib/NativeLib.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@
<Keyword>Win32Proj</Keyword>
<ProjectGuid>{4c81c206-f900-4cec-b646-828a840817a6}</ProjectGuid>
<RootNamespace>NativeLib</RootNamespace>
<WindowsTargetPlatformVersion>10.0.19041.0</WindowsTargetPlatformVersion>
<WindowsTargetPlatformVersion>10.0.22000.0</WindowsTargetPlatformVersion>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
Expand Down
14 changes: 7 additions & 7 deletions Run.bat
Original file line number Diff line number Diff line change
Expand Up @@ -2,24 +2,24 @@
if "%1" equ "" (
goto error
)
if not exist "bin\debug\net6.0\win-x64\native\%1.mue" (
if not exist "bin\debug\win-x64\native\%1.mue" (
echo "Please select the project that you want to Run on Visual Studio Solution Explorer and then press Ctrl+B to build the project first!"
echo "Make sure the project that you build is what you selected on Visual Studio Dropdown Menu!"
pause
exit
)
::build-iso

cd Tools
del /q grub2\boot\ramdisk.tar
7-Zip\7z.exe a grub2\boot\ramdisk.tar ..\Ramdisk\*
nasm.exe -fbin Trampoline.asm -o trampoline.o
nasm.exe -fbin EntryPoint.asm -o loader.o
copy /b loader.o+..\bin\debug\net6.0\win-x64\native\%1.mue grub2\boot\kernel.bin
copy /b loader.o+..\bin\debug\win-x64\native\%1.mue grub2\boot\kernel.bin
del /q trampoline.o
del /q loader.o
mkisofs.exe -relaxed-filenames -J -R -o ..\bin\debug\net6.0\win-x64\native\%1.iso -b boot/grub/i386-pc/eltorito.img -no-emul-boot -boot-load-size 4 -boot-info-table grub2
mkisofs.exe -relaxed-filenames -J -R -o ..\bin\debug\win-x64\native\%1.iso -b boot/grub/i386-pc/eltorito.img -no-emul-boot -boot-load-size 4 -boot-info-table grub2
cd..
::end-build-iso

if "%2" equ "qemu" (
if not exist "C:\Program Files\Intel\HAXM\IntelHaxm.sys" (
echo "Please install Intel Hardware Accelerated Execution Manager (HAXM) in order to speed up QEMU https://github.com/intel/haxm/releases"
Expand All @@ -31,7 +31,7 @@ if "%2" equ "qemu" (
pause
exit
)
"C:\Program Files\qemu\qemu-system-x86_64.exe" -accel hax -m 1024 -smp 2 -k en-gb -boot d -cdrom "bin\debug\net6.0\win-x64\native\%1.iso" -d guest_errors -serial stdio -device AC97 -rtc base=localtime
"C:\Program Files\qemu\qemu-system-x86_64.exe" -accel hax -m 1024 -smp 2 -k en-gb -boot d -cdrom "bin\debug\win-x64\native\%1.iso" -d guest_errors -serial stdio -device AC97 -rtc base=localtime
) else if "%2" equ "vmware" (
if exist "C:\Program Files (x86)\VMware\VMware Workstation\vmplayer.exe" (
"C:\Program Files (x86)\VMware\VMware Workstation\vmplayer.exe" "Tools\VMWare\MOOS\MOOS.vmx"
Expand All @@ -44,7 +44,7 @@ if "%2" equ "qemu" (
)
) else (
:error
echo "Invalid parameters, do not running this batch file manually!"
echo "Invalid parameters, do not run this batch file manually!"
pause
exit
)
Binary file modified Tools/VMWare/MOOS/MOOS.nvram
Binary file not shown.
9 changes: 5 additions & 4 deletions Tools/VMWare/MOOS/MOOS.vmx
Original file line number Diff line number Diff line change
Expand Up @@ -31,14 +31,14 @@ sound.present = "TRUE"
numvcpus = "2"
memsize = "1024"
ide1:0.deviceType = "cdrom-image"
ide1:0.fileName = "..\..\..\bin\Debug\net6.0\win-x64\native\MOOS.iso"
ide1:0.fileName = "..\..\..\bin\Debug\win-x64\native\MOOS.iso"
ide1:0.present = "TRUE"
extendedConfigFile = "MOOS.vmxf"
floppy0.present = "FALSE"
numa.autosize.cookie = "20001"
numa.autosize.vcpu.maxPerVirtualNode = "2"
uuid.bios = "56 4d d8 67 2d c9 10 66-f0 db 7e 21 af 0b cf 65"
uuid.location = "56 4d d8 67 2d c9 10 66-f0 db 7e 21 af 0b cf 65"
uuid.bios = "56 4d 22 cc 81 27 6a 69-ba 39 78 cf b0 1b 6b 23"
uuid.location = "56 4d 22 cc 81 27 6a 69-ba 39 78 cf b0 1b 6b 23"
pciBridge0.pciSlotNumber = "17"
pciBridge4.pciSlotNumber = "21"
pciBridge5.pciSlotNumber = "22"
Expand Down Expand Up @@ -72,8 +72,9 @@ ethernet0.addressType = "generated"
ethernet0.virtualDev = "e1000"
ethernet0.present = "TRUE"
ethernet0.pciSlotNumber = "33"
ethernet0.generatedAddress = "00:0c:29:0b:cf:65"
ethernet0.generatedAddress = "00:0c:29:1b:6b:23"
ethernet0.generatedAddressOffset = "0"
vmxstats.filename = "MOOS.scoreboard"
usb:0.present = "TRUE"
usb:0.deviceType = "hid"
usb:0.port = "0"
Expand Down

0 comments on commit 10737de

Please sign in to comment.