diff --git a/.drone.yml b/.drone.yml index 7742bb8..f6fe2bf 100644 --- a/.drone.yml +++ b/.drone.yml @@ -6,6 +6,7 @@ steps: image: mcr.microsoft.com/dotnet/sdk:8.0 commands: - dotnet build --configuration Release Eazfuscator-Launcher/Eazfuscator-Launcher.csproj + - dotnet build --configuration Release VisualStudioMock/VisualStudioMock.csproj - name: docker image: plugins/docker diff --git a/Dockerfile b/Dockerfile index a9d1177..3117f44 100644 --- a/Dockerfile +++ b/Dockerfile @@ -38,7 +38,9 @@ RUN wget -nv -O- https://dl.winehq.org/wine-builds/winehq.key | APT_KEY_DONT_WAR && dpkg --add-architecture i386 \ && apt-get update \ && DEBIAN_FRONTEND="noninteractive" apt-get install -y --install-recommends wine-${WINE_BRANCH} \ - && rm -rf /var/lib/apt/lists/* + && rm -rf /var/lib/apt/lists/* \ + && sed -i -E "s:PATH=\"?([^\"]*)\"?:PATH=/opt/wine-stable/bin\:\1:g" /etc/environment \ + && export PATH=/opt/wine-stable/bin:$PATH COPY entrypoint.sh /usr/bin/entrypoint @@ -63,6 +65,7 @@ ENV DISPLAY ":95" ENV WINEARCH win32 COPY tools/* /root/.wine/drive_c/windows/system32/ +COPY VisualStudioMock/bin/Release/net472/VisualStudioMock.exe /root/.wine/drive_c/VisualStudioMock.exe RUN set -x -e; \ # Install dotnet @@ -102,6 +105,8 @@ RUN set -x -e; \ # Install socat to temporarily overcome bug until dotnet 9 gets released and have the bug https://github.com/dotnet/runtime/issues/98441 fixed apt update; \ apt install -y --no-install-recommends socat; \ + # Register VisualStudioMock + wine "c:\\VisualStudioMock.exe" /reg; \ # Clean-up rm -rf /tmp/eaz.zip /tmp/eaz /tmp/dotnet.exe /tmp/chk /var/lib/apt/lists/*; \ # Complete diff --git a/VisualStudioMock/ComProxy.cs b/VisualStudioMock/ComProxy.cs index 938ca36..5e9afbb 100644 --- a/VisualStudioMock/ComProxy.cs +++ b/VisualStudioMock/ComProxy.cs @@ -1,4 +1,4 @@ -//#define LOG_CALLS +#define LOG_CALLS using System; using System.Runtime.InteropServices; @@ -44,6 +44,8 @@ namespace VisualStudioMock this._realInstanceN = Marshal.GetIUnknownForObject(instance); this._proxyInstanceN = Marshal.AllocHGlobal(IntPtr.Size * 4); + this._getInterfaceN = Marshal.GetFunctionPointerForDelegate((Delegate)(this._getInterface = new GetInterfaceDelegate(GetInterface))); + IntPtr vtbl = _proxyInstanceN + IntPtr.Size; Marshal.WriteIntPtr(_proxyInstanceN, vtbl); Marshal.WriteIntPtr(vtbl, this._getInterfaceN = Marshal.GetFunctionPointerForDelegate((Delegate)(this._getInterface = new GetInterfaceDelegate(GetInterface)))); @@ -120,12 +122,12 @@ namespace VisualStudioMock private int AddRef(IntPtr @this) { - return 1; + return Marshal.AddRef(_realInstanceN); } private int Release(IntPtr @this) { - return 1; + return Marshal.Release(_realInstanceN); } private static IntPtr CreateThunk(IntPtr @this, IntPtr jmpTarget) diff --git a/VisualStudioMock/SetupConfiguration.cs b/VisualStudioMock/SetupConfiguration.cs index 6ed6528..339919b 100644 --- a/VisualStudioMock/SetupConfiguration.cs +++ b/VisualStudioMock/SetupConfiguration.cs @@ -10,6 +10,11 @@ namespace VisualStudioMock { private readonly SetupInstance _singleInstance; + static SetupConfiguration() + { + AppDomain.CurrentDomain.UnhandledException += (object sender, UnhandledExceptionEventArgs e) => Console.WriteLine("Exception: "); + } + public SetupConfiguration() { Ext.LogCall(nameof(SetupConfiguration), ".ctor"); diff --git a/VisualStudioMock/SetupInstance.cs b/VisualStudioMock/SetupInstance.cs index 20b8271..470192d 100644 --- a/VisualStudioMock/SetupInstance.cs +++ b/VisualStudioMock/SetupInstance.cs @@ -16,8 +16,8 @@ namespace VisualStudioMock public string GetDisplayName([In, MarshalAs(UnmanagedType.U4)] int lcid = 0) { - Ext.LogCall(nameof(SetupInstance), nameof(GetDisplayName)); - return "display name"; + Ext.LogCall(nameof(SetupInstance), nameof(GetDisplayName), "Lcid = " + lcid.ToString()); + return "Visual Studio Community 2022"; } public string GetInstallationName() diff --git a/VisualStudioMockTest/Program.cs b/VisualStudioMockTest/Program.cs index bf6421e..a3e4f59 100644 --- a/VisualStudioMockTest/Program.cs +++ b/VisualStudioMockTest/Program.cs @@ -18,6 +18,7 @@ class A { ISetupInstance2 c = (ISetupInstance2)b[0]; Console.WriteLine("Instance - " + c.GetDisplayName()); + Console.WriteLine("\t GetDisplayName = " + c.GetDisplayName()); Console.WriteLine("\t GetInstallationVersion = " + c.GetInstallationVersion()); Console.WriteLine("\t GetInstallationPath = " + c.GetInstallationPath()); Console.WriteLine("\t GetEnginePath = " + c.GetEnginePath());