diff --git a/VirtualComputerMSCOM/pom.xml b/VirtualComputerMSCOM/pom.xml index 2a77e96..a590d61 100644 --- a/VirtualComputerMSCOM/pom.xml +++ b/VirtualComputerMSCOM/pom.xml @@ -14,13 +14,13 @@ - + - + + --> net.sf.jni4net clr @@ -32,9 +32,15 @@ 3.0 - net.sf.jacob-project - jacob - 1.19 + org.virtualbox + VirtualBox-JWS + 6.1 + + + org.projectlombok + lombok + 1.18.20 + provided diff --git a/VirtualComputerMSCOM/src/main/java/com/jacob/com/COMConverter.java b/VirtualComputerMSCOM/src/main/java/com/jacob/com/COMConverter.java deleted file mode 100644 index 6ae3db1..0000000 --- a/VirtualComputerMSCOM/src/main/java/com/jacob/com/COMConverter.java +++ /dev/null @@ -1,11 +0,0 @@ -package com.jacob.com; - -public class COMConverter { - public static long GetVariantAddress(Variant variant) { - return variant.m_pVariant; - } - - public static void SetVariantAddress(Variant variant, long addr) { - variant.m_pVariant = addr; - } -} diff --git a/VirtualComputerMSCOM/src/main/java/sznp/virtualcomputer/util/COMUtils.java b/VirtualComputerMSCOM/src/main/java/sznp/virtualcomputer/util/COMUtils.java index 7185698..9cde1ee 100644 --- a/VirtualComputerMSCOM/src/main/java/sznp/virtualcomputer/util/COMUtils.java +++ b/VirtualComputerMSCOM/src/main/java/sznp/virtualcomputer/util/COMUtils.java @@ -16,12 +16,7 @@ public final class COMUtils { } public static IEventListener registerListener(IEventSource source, IEventHandler listener, List types) { - var variant = new Variant(); - COMConverter.SetVariantAddress(variant, Exports.GetEventHandler(listener, COMConverter.GetVariantAddress(variant))); - System.out.println("Variant as int: "+variant.toInt()); - var ret = new IEventListener(variant.changeType((short) 9).getDispatch()); //Object variant to dispatch variant - source.registerListener(ret, types, true); - return ret; + source.registerListener(, types, true); } @SneakyThrows diff --git a/VirtualComputerMSCOM/src/main/java/sznp/virtualcomputer/util/IEventHandler.java b/VirtualComputerMSCOM/src/main/java/sznp/virtualcomputer/util/IEventHandler.java index 82baa09..769b5c6 100644 --- a/VirtualComputerMSCOM/src/main/java/sznp/virtualcomputer/util/IEventHandler.java +++ b/VirtualComputerMSCOM/src/main/java/sznp/virtualcomputer/util/IEventHandler.java @@ -1,10 +1,9 @@ package sznp.virtualcomputer.util; -import com.jacob.com.Dispatch; import lombok.var; import org.virtualbox_6_1.IEvent; -public interface IEventHandler extends virtualcomputerwindows.IEventHandler { +public interface IEventHandler { void handleEvent(IEvent iEvent); @Override diff --git a/VirtualComputerWindows/VirtualComputerWindows.sln b/VirtualComputerWindows/VirtualComputerWindows.sln index e73c2ef..281ec05 100644 --- a/VirtualComputerWindows/VirtualComputerWindows.sln +++ b/VirtualComputerWindows/VirtualComputerWindows.sln @@ -3,7 +3,7 @@ Microsoft Visual Studio Solution File, Format Version 12.00 # Visual Studio 15 VisualStudioVersion = 15.0.26403.7 MinimumVisualStudioVersion = 10.0.40219.1 -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "VirtualComputerWindows", "VirtualComputerWindows\VirtualComputerWindows.csproj", "{5E734F17-FF74-4187-A6E4-B7E1DAB272F8}" +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "VirtualComputerWindows", "VirtualComputerWindows\VirtualComputerWindows.csproj", "{FA1D1EAA-1984-4CC9-9656-98357FDD1A61}" EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution @@ -15,18 +15,8 @@ Global Release|x86 = Release|x86 EndGlobalSection GlobalSection(ProjectConfigurationPlatforms) = postSolution - {5E734F17-FF74-4187-A6E4-B7E1DAB272F8}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {5E734F17-FF74-4187-A6E4-B7E1DAB272F8}.Debug|Any CPU.Build.0 = Debug|Any CPU - {5E734F17-FF74-4187-A6E4-B7E1DAB272F8}.Debug|x64.ActiveCfg = Debug|x64 - {5E734F17-FF74-4187-A6E4-B7E1DAB272F8}.Debug|x64.Build.0 = Debug|x64 - {5E734F17-FF74-4187-A6E4-B7E1DAB272F8}.Debug|x86.ActiveCfg = Debug|x86 - {5E734F17-FF74-4187-A6E4-B7E1DAB272F8}.Debug|x86.Build.0 = Debug|x86 - {5E734F17-FF74-4187-A6E4-B7E1DAB272F8}.Release|Any CPU.ActiveCfg = Release|Any CPU - {5E734F17-FF74-4187-A6E4-B7E1DAB272F8}.Release|Any CPU.Build.0 = Release|Any CPU - {5E734F17-FF74-4187-A6E4-B7E1DAB272F8}.Release|x64.ActiveCfg = Release|x64 - {5E734F17-FF74-4187-A6E4-B7E1DAB272F8}.Release|x64.Build.0 = Release|x64 - {5E734F17-FF74-4187-A6E4-B7E1DAB272F8}.Release|x86.ActiveCfg = Release|x86 - {5E734F17-FF74-4187-A6E4-B7E1DAB272F8}.Release|x86.Build.0 = Release|x86 + {FA1D1EAA-1984-4CC9-9656-98357FDD1A61}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {FA1D1EAA-1984-4CC9-9656-98357FDD1A61}.Debug|Any CPU.Build.0 = Debug|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE diff --git a/VirtualComputerWindows/VirtualComputerWindows/Class1.cs b/VirtualComputerWindows/VirtualComputerWindows/Class1.cs new file mode 100644 index 0000000..11e4028 --- /dev/null +++ b/VirtualComputerWindows/VirtualComputerWindows/Class1.cs @@ -0,0 +1,26 @@ +using System; +using VirtualBox; + +namespace VirtualComputerWindows +{ + public static class Class1 + { + public static void Main(string[] args) + { + Console.WriteLine("Starting VirtualBox..."); + var vbox = new VirtualBoxClass(); + var machines = vbox.Machines.As(); + var session = new SessionClass(); + //machines[0].LockMachine(session, LockType.LockType_VM); + //var prog = session.Console.PowerUp(); - Unknown error initializing kernel driver (VERR_SUPDRV_NOT_BUDDING_VM_PROCESS_1) + var prog = machines[0].LaunchVMProcess(session, "headless", Array.Empty()); + prog.WaitForCompletion(-1); + Console.WriteLine("Error: " + prog.ErrorInfo?.Text); + session.Console.Display.AttachFramebuffer(0, new MCFramebuffer()); + Console.WriteLine("All set up"); + Console.ReadLine(); + } + + public static T[] As(this Array array) => (T[]) array; + } +} diff --git a/VirtualComputerWindows/VirtualComputerWindows/EventHandler.cs b/VirtualComputerWindows/VirtualComputerWindows/EventHandler.cs deleted file mode 100644 index 5b817f3..0000000 --- a/VirtualComputerWindows/VirtualComputerWindows/EventHandler.cs +++ /dev/null @@ -1,38 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Runtime.InteropServices; -using System.Text; -using System.Threading.Tasks; -using VirtualBox; - -namespace VirtualComputerWindows -{ - public class EventHandler : IEventListener - { - private readonly IEventHandler handler; - private bool enabled = true; - - /** - * New MSCOM event handler. - * - * @param handler The handle method that handles what needs to be handled - */ - public EventHandler(IEventHandler handler) - { - this.handler = handler; - } - - public void HandleEvent(IEvent aEvent) - { - if (!enabled) - return; - handler.handleEvent((long)Marshal.GetIDispatchForObject(aEvent)); - } - - public void disable() - { - enabled = false; - } - } -} diff --git a/VirtualComputerWindows/VirtualComputerWindows/Exports.cs b/VirtualComputerWindows/VirtualComputerWindows/Exports.cs deleted file mode 100644 index f24e924..0000000 --- a/VirtualComputerWindows/VirtualComputerWindows/Exports.cs +++ /dev/null @@ -1,76 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Runtime.InteropServices; -using System.Text; -using System.Threading.Tasks; -using VirtualBox; - -namespace VirtualComputerWindows -{ - public static class Exports - { - [DllImport(@"C:\Program Files\Oracle\VirtualBox\VBoxRT.dll", CallingConvention = CallingConvention.StdCall)] - private static extern void RTR3InitExe(int argc, string argv, int zeroflags); - /*[DllImport(@"C:\Program Files\Oracle\VirtualBox\VBoxVMM.dll", CallingConvention = CallingConvention.StdCall)] - private static extern int VMMDoHmTest(IntPtr vmstruct);*/ - - private static VirtualBoxClient vbc; - - private static void Init() - { - try - { - //Environment.SetEnvironmentVariable("VBOX_HOME", @"C:\Program Files\Oracle\VirtualBox\"); - //TODO: Only finds the VBoxVMM.dll when placed in the VirtualBox dir (regardless of working dir) - //Even then there are hardening issues: VERR_SUPDRV_NOT_BUDDING_VM_PROCESS_1 - //https://www.virtualbox.org/svn/vbox/trunk/src/VBox/HostDrivers/Support/win/SUPDrv-win.cpp - vbc = new VirtualBoxClientClass(); //GetObjectFromIUnknown - /*var vbox = vbc.VirtualBox; - //RTR3InitExe(0, "", 0); - var ses = vbc.Session; - var machine = vbox.Machines.GetValue(0) as IMachine; - ses.Name = "minecraft"; - machine.LockMachine(ses, LockType.LockType_VM); - Console.WriteLine("Locking..."); - while (ses.State != SessionState.SessionState_Locked) ; - Console.WriteLine("Locked"); - machine = ses.Machine; - Console.WriteLine("Powering up..."); - ses.Console.PowerUp().WaitForCompletion(10000);*/ - } - catch(Exception e) - { - Console.WriteLine(e); - //Console.ReadLine(); - } - } - - private static void Main() - { - //Init(); - GetEventHandler(null, 0L); - Console.ReadLine(); - - } - - private static WinFrameBuffer framebuffer; - public static long GetFrameBuffer(IMCFrameBuffer framebuffer, long addr) - { - Exports.framebuffer = new WinFrameBuffer(framebuffer); - Marshal.GetNativeVariantForObject(Exports.framebuffer, (IntPtr)addr); - return (long)Marshal.GetIDispatchForObject(Exports.framebuffer); - } - - private static EventHandler eventHandler; - private static DispatchWrapper handlerWrapper; - public static long GetEventHandler(IEventHandler handler, long addr) - { - eventHandler = new EventHandler(handler); - //handlerWrapper = new DispatchWrapper(eventHandler); - Marshal.GetNativeVariantForObject(eventHandler, (IntPtr)addr); - //return (long)Marshal.GetIDispatchForObject(eventHandler); - return addr; - } - } -} diff --git a/VirtualComputerWindows/VirtualComputerWindows/IEventHandler.cs b/VirtualComputerWindows/VirtualComputerWindows/IEventHandler.cs deleted file mode 100644 index 840f9e5..0000000 --- a/VirtualComputerWindows/VirtualComputerWindows/IEventHandler.cs +++ /dev/null @@ -1,13 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; - -namespace VirtualComputerWindows -{ - public interface IEventHandler - { - void handleEvent(long iEvent); - } -} diff --git a/VirtualComputerWindows/VirtualComputerWindows/IMCFrameBuffer.cs b/VirtualComputerWindows/VirtualComputerWindows/IMCFrameBuffer.cs deleted file mode 100644 index f617050..0000000 --- a/VirtualComputerWindows/VirtualComputerWindows/IMCFrameBuffer.cs +++ /dev/null @@ -1,17 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; - -namespace VirtualComputerWindows -{ - public interface IMCFrameBuffer - { - void notifyUpdate(long x, long y, long width, long height); - - void notifyUpdateImage(long x, long y, long width, long height, byte[] image); - - void notifyChange(long screenId, long xOrigin, long yOrigin, long width, long height); - } -} diff --git a/VirtualComputerWindows/VirtualComputerWindows/MCFramebuffer.cs b/VirtualComputerWindows/VirtualComputerWindows/MCFramebuffer.cs new file mode 100644 index 0000000..465a968 --- /dev/null +++ b/VirtualComputerWindows/VirtualComputerWindows/MCFramebuffer.cs @@ -0,0 +1,56 @@ +using System; +using VirtualBox; + +namespace VirtualComputerWindows +{ + public class MCFramebuffer : IFramebuffer + { + public void NotifyUpdate(uint aX, uint aY, uint aWidth, uint aHeight) + { + Console.Error.WriteLine($"Unexpected NotifyUpdate: {aX} {aY} {aWidth} {aHeight}"); + } + + public void NotifyUpdateImage(uint aX, uint aY, uint aWidth, uint aHeight, Array aImage) + { + Console.WriteLine("NotifyUpdateImage"); + } + + public void NotifyChange(uint aScreenId, uint aXOrigin, uint aYOrigin, uint aWidth, uint aHeight) + { + Console.WriteLine("NotifyChange"); + } + + public int VideoModeSupported(uint aWidth, uint aHeight, uint aBpp) + { + Console.WriteLine("VideoModeSupported"); + return 1; + } + + public uint GetVisibleRegion(ref byte aRectangles, uint aCount) + { + return 0; + } + + public void SetVisibleRegion(ref byte aRectangles, uint aCount) + { + } + + public void ProcessVHWACommand(ref byte aCommand, int aEnmCmd, int aFromGuest) + { + } + + public void Notify3DEvent(uint aType, Array aData) + { + } + + public uint Width { get; } = 640; + public uint Height { get; } = 480; + public uint BitsPerPixel { get; } = 32; + public uint BytesPerLine { get; } = 640 * 4; + public BitmapFormat PixelFormat { get; } = BitmapFormat.BitmapFormat_BGRA; + public uint HeightReduction { get; } = 0; + public IFramebufferOverlay Overlay { get; } + public long WinId { get; } = 0; + public Array Capabilities { get; } = new[] {FramebufferCapabilities.FramebufferCapabilities_UpdateImage}; + } +} \ No newline at end of file diff --git a/VirtualComputerWindows/VirtualComputerWindows/Properties/AssemblyInfo.cs b/VirtualComputerWindows/VirtualComputerWindows/Properties/AssemblyInfo.cs deleted file mode 100644 index 3e59a04..0000000 --- a/VirtualComputerWindows/VirtualComputerWindows/Properties/AssemblyInfo.cs +++ /dev/null @@ -1,36 +0,0 @@ -using System.Reflection; -using System.Runtime.CompilerServices; -using System.Runtime.InteropServices; - -// General Information about an assembly is controlled through the following -// set of attributes. Change these attribute values to modify the information -// associated with an assembly. -[assembly: AssemblyTitle("VirtualComputerWindows")] -[assembly: AssemblyDescription("")] -[assembly: AssemblyConfiguration("")] -[assembly: AssemblyCompany("")] -[assembly: AssemblyProduct("VirtualComputerWindows")] -[assembly: AssemblyCopyright("Copyright © 2017")] -[assembly: AssemblyTrademark("")] -[assembly: AssemblyCulture("")] - -// Setting ComVisible to false makes the types in this assembly not visible -// to COM components. If you need to access a type in this assembly from -// COM, set the ComVisible attribute to true on that type. -[assembly: ComVisible(false)] - -// The following GUID is for the ID of the typelib if this project is exposed to COM -[assembly: Guid("5e734f17-ff74-4187-a6e4-b7e1dab272f8")] - -// Version information for an assembly consists of the following four values: -// -// Major Version -// Minor Version -// Build Number -// Revision -// -// You can specify all the values or you can default the Build and Revision Numbers -// by using the '*' as shown below: -// [assembly: AssemblyVersion("1.0.*")] -[assembly: AssemblyVersion("1.0.0.0")] -[assembly: AssemblyFileVersion("1.0.0.0")] diff --git a/VirtualComputerWindows/VirtualComputerWindows/VirtualComputerWindows.csproj b/VirtualComputerWindows/VirtualComputerWindows/VirtualComputerWindows.csproj index 9f11cac..fb587df 100644 --- a/VirtualComputerWindows/VirtualComputerWindows/VirtualComputerWindows.csproj +++ b/VirtualComputerWindows/VirtualComputerWindows/VirtualComputerWindows.csproj @@ -1,118 +1,20 @@ - - - - - Debug - AnyCPU - {5E734F17-FF74-4187-A6E4-B7E1DAB272F8} - Exe - Properties - VirtualComputerWindows - VirtualComputerWindows - v4.6.1 - 512 - - VirtualComputerWindows - true - false - 1 - false - false - - - true - full - false - bin\Debug\ - DEBUG;TRACE - prompt - 4 - - - pdbonly - true - bin\Release\ - TRACE - prompt - 4 - - - true - bin\x64\Debug\ - DEBUG;TRACE - full - AnyCPU - prompt - MinimumRecommendedRules.ruleset - false - - - bin\x64\Release\ - TRACE - true - pdbonly - x64 - prompt - MinimumRecommendedRules.ruleset - - - true - bin\x86\Debug\ - DEBUG;TRACE - full - x86 - prompt - MinimumRecommendedRules.ruleset - - - bin\x86\Release\ - TRACE - true - pdbonly - x86 - prompt - MinimumRecommendedRules.ruleset - - - - - - - - - - ..\packages\System.Runtime.InteropServices.RuntimeInformation.4.3.0\lib\net45\System.Runtime.InteropServices.RuntimeInformation.dll - - - - - - - - - - - - - - - - - - - - - - - {D7569351-1750-46F0-936E-BD127D5BC264} - 1 - 3 - 0 - tlbimp - False - False - - - - - \ No newline at end of file + + + + net5.0 + Exe + + + + + {D7569351-1750-46F0-936E-BD127D5BC264} + 1 + 3 + 0 + tlbimp + False + False + + + + diff --git a/VirtualComputerWindows/VirtualComputerWindows/WinFrameBuffer.cs b/VirtualComputerWindows/VirtualComputerWindows/WinFrameBuffer.cs deleted file mode 100644 index a0f8d4f..0000000 --- a/VirtualComputerWindows/VirtualComputerWindows/WinFrameBuffer.cs +++ /dev/null @@ -1,76 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Runtime.InteropServices; -using System.Text; -using System.Threading.Tasks; -using VirtualBox; - -namespace VirtualComputerWindows -{ - public class WinFrameBuffer : IFramebuffer - { - private IMCFrameBuffer framebuffer; - public WinFrameBuffer(IMCFrameBuffer framebuffer) - { - this.framebuffer = framebuffer; - } - - public void NotifyUpdate(uint aX, uint aY, uint aWidth, uint aHeight) - { - framebuffer.notifyUpdate(aX, aY, aWidth, aHeight); - } - - public void NotifyUpdateImage(uint aX, uint aY, uint aWidth, uint aHeight, Array aImage) - { - framebuffer.notifyUpdateImage(aX, aY, aWidth, aHeight, (byte[])aImage); - } - - public void NotifyChange(uint aScreenId, uint aXOrigin, uint aYOrigin, uint aWidth, uint aHeight) - { - framebuffer.notifyChange(aScreenId, aXOrigin, aYOrigin, aWidth, aHeight); - } - - public int VideoModeSupported(uint aWidth, uint aHeight, uint aBpp) - { - return 1; - } - - public uint GetVisibleRegion(ref byte aRectangles, uint aCount) - { - return 0; - } - - public void SetVisibleRegion(ref byte aRectangles, uint aCount) - { - } - - public void ProcessVHWACommand(ref byte aCommand, int aEnmCmd, int aFromGuest) - { - Console.WriteLine("VHWA command! " + aCommand); - } - - public void Notify3DEvent(uint aType, Array aData) - { - Console.WriteLine("3D event! " + aType); - } - - public uint Width => 640; - - public uint Height => 480; - - public uint BitsPerPixel => 32; - - public uint BytesPerLine => 640; - - public BitmapFormat PixelFormat => BitmapFormat.BitmapFormat_BGRA; - - public uint HeightReduction => 0; - - public IFramebufferOverlay Overlay => null; - - public long WinId => 0; - - public Array Capabilities => new[] { FramebufferCapabilities.FramebufferCapabilities_RenderCursor, FramebufferCapabilities.FramebufferCapabilities_UpdateImage }; - } -} diff --git a/VirtualComputerWindows/VirtualComputerWindows/app.config b/VirtualComputerWindows/VirtualComputerWindows/app.config deleted file mode 100644 index e0f92b1..0000000 --- a/VirtualComputerWindows/VirtualComputerWindows/app.config +++ /dev/null @@ -1,15 +0,0 @@ - - - - - - - - - - - - - - - diff --git a/VirtualComputerWindows/VirtualComputerWindows/packages.config b/VirtualComputerWindows/VirtualComputerWindows/packages.config deleted file mode 100644 index ae13583..0000000 --- a/VirtualComputerWindows/VirtualComputerWindows/packages.config +++ /dev/null @@ -1,4 +0,0 @@ - - - - \ No newline at end of file diff --git a/repo/org/virtualbox/VirtualBox-JWS/6.1/VirtualBox-JWS-6.1.pom b/repo/org/virtualbox/VirtualBox-JWS/6.1/VirtualBox-JWS-6.1.pom new file mode 100644 index 0000000..328f330 --- /dev/null +++ b/repo/org/virtualbox/VirtualBox-JWS/6.1/VirtualBox-JWS-6.1.pom @@ -0,0 +1,9 @@ + + + 4.0.0 + org.virtualbox + VirtualBox-JWS + 6.1 + POM was created from install:install-file + diff --git a/repo/org/virtualbox/VirtualBox-JWS/maven-metadata-local.xml b/repo/org/virtualbox/VirtualBox-JWS/maven-metadata-local.xml new file mode 100644 index 0000000..e1c2529 --- /dev/null +++ b/repo/org/virtualbox/VirtualBox-JWS/maven-metadata-local.xml @@ -0,0 +1,12 @@ + + + org.virtualbox + VirtualBox-JWS + + 6.1 + + 6.1 + + 20210603224925 + +