Skip to content

Commit 05ab368

Browse files
committed
Add COM Interface marshal for new Game-related v0.1.1 APIs
1 parent 6905de6 commit 05ab368

File tree

2 files changed

+14
-4
lines changed

2 files changed

+14
-4
lines changed

SharedStatic.Generic.cs

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,12 @@
44
using System;
55
using System.Runtime.CompilerServices;
66
using System.Runtime.InteropServices;
7-
using System.Runtime.InteropServices.Marshalling;
87
using System.Threading;
98

9+
#if !MANUALCOM
10+
using System.Runtime.InteropServices.Marshalling;
11+
#endif
12+
1013
using static Hi3Helper.Plugin.Core.Utility.GameManagerExtension;
1114

1215
namespace Hi3Helper.Plugin.Core;
@@ -46,12 +49,15 @@ public static unsafe int LaunchGameFromGameManagerAsync(nint gameManagerP, nint
4649
try
4750
{
4851
#if MANUALCOM
52+
IPlugin? plugin = ComWrappers.ComInterfaceDispatch.GetInstance<IPlugin>((ComWrappers.ComInterfaceDispatch*)gameManagerP);
53+
IGameManager? gameManager = ComWrappers.ComInterfaceDispatch.GetInstance<IGameManager>((ComWrappers.ComInterfaceDispatch*)gameManagerP);
4954
#else
50-
IPlugin? plugin = ComInterfaceMarshaller<IPlugin>.ConvertToManaged((void*)pluginP);
55+
IPlugin? plugin = ComInterfaceMarshaller<IPlugin>.ConvertToManaged((void*)pluginP);
5156
IGameManager? gameManager = ComInterfaceMarshaller<IGameManager>.ConvertToManaged((void*)gameManagerP);
52-
PrintGameLog printGameLogCallback = Marshal.GetDelegateForFunctionPointer<PrintGameLog>(printGameLogCallbackP);
5357
#endif
5458

59+
PrintGameLog printGameLogCallback = Marshal.GetDelegateForFunctionPointer<PrintGameLog>(printGameLogCallbackP);
60+
5561
if (ThisPluginExport == null)
5662
{
5763
throw new NullReferenceException("The ThisPluginExport field is null!");
@@ -103,6 +109,7 @@ public static unsafe int IsGameRunning(nint gameManagerP, out int isGameRunningI
103109
try
104110
{
105111
#if MANUALCOM
112+
IGameManager? gameManager = ComWrappers.ComInterfaceDispatch.GetInstance<IGameManager>((ComWrappers.ComInterfaceDispatch*)gameManagerP);
106113
#else
107114
IGameManager? gameManager = ComInterfaceMarshaller<IGameManager>.ConvertToManaged((void*)gameManagerP);
108115
#endif
@@ -134,6 +141,8 @@ public static unsafe int WaitRunningGameAsync(nint gameManagerP, nint pluginP, r
134141
try
135142
{
136143
#if MANUALCOM
144+
IPlugin? plugin = ComWrappers.ComInterfaceDispatch.GetInstance<IPlugin>((ComWrappers.ComInterfaceDispatch*)gameManagerP);
145+
IGameManager? gameManager = ComWrappers.ComInterfaceDispatch.GetInstance<IGameManager>((ComWrappers.ComInterfaceDispatch*)gameManagerP);
137146
#else
138147
IPlugin? plugin = ComInterfaceMarshaller<IPlugin>.ConvertToManaged((void*)pluginP);
139148
IGameManager? gameManager = ComInterfaceMarshaller<IGameManager>.ConvertToManaged((void*)gameManagerP);
@@ -184,6 +193,7 @@ public static unsafe int KillRunningGame(nint gameManagerP, out int wasGameRunni
184193
try
185194
{
186195
#if MANUALCOM
196+
IGameManager? gameManager = ComWrappers.ComInterfaceDispatch.GetInstance<IGameManager>((ComWrappers.ComInterfaceDispatch*)gameManagerP);
187197
#else
188198
IGameManager? gameManager = ComInterfaceMarshaller<IGameManager>.ConvertToManaged((void*)gameManagerP);
189199
#endif

SharedStatic.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -317,7 +317,7 @@ currentLocale[range[0]].Length is < 2 or > 3 ||
317317
/// Specify which <see cref="IPlugin"/> instance to load and use in this plugin.
318318
/// </summary>
319319
/// <typeparam name="TPlugin">A member of COM Interface of <see cref="IPlugin"/>.</typeparam>
320-
protected static void Load<TPlugin>(SharedStatic thisExportType, GameVersion interceptDllVersionTo = default)
320+
protected static void Load<TPlugin>(GameVersion interceptDllVersionTo = default)
321321
where TPlugin : class, IPlugin, new()
322322
{
323323
if (interceptDllVersionTo != GameVersion.Empty)

0 commit comments

Comments
 (0)