From e32b983bdfe05704c89161f65b6ee52fa9f66dc2 Mon Sep 17 00:00:00 2001 From: Aetopia <41850963+Aetopia@users.noreply.github.com> Date: Tue, 15 Oct 2024 23:22:09 +0530 Subject: [PATCH] first commit --- .gitignore | 484 ++++++++++++++++++++++++++++ src/ApplicationActivationManager.cs | 12 + src/Game.cs | 52 +++ src/Library.cs | 55 ++++ src/Minecraft.UWP.csproj | 13 + src/Native.cs | 54 ++++ src/PackageDebugSettings.cs | 78 +++++ 7 files changed, 748 insertions(+) create mode 100644 .gitignore create mode 100644 src/ApplicationActivationManager.cs create mode 100644 src/Game.cs create mode 100644 src/Library.cs create mode 100644 src/Minecraft.UWP.csproj create mode 100644 src/Native.cs create mode 100644 src/PackageDebugSettings.cs diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..5e57f18 --- /dev/null +++ b/.gitignore @@ -0,0 +1,484 @@ +## Ignore Visual Studio temporary files, build results, and +## files generated by popular Visual Studio add-ons. +## +## Get latest from `dotnet new gitignore` + +# dotenv files +.env + +# User-specific files +*.rsuser +*.suo +*.user +*.userosscache +*.sln.docstates + +# User-specific files (MonoDevelop/Xamarin Studio) +*.userprefs + +# Mono auto generated files +mono_crash.* + +# Build results +[Dd]ebug/ +[Dd]ebugPublic/ +[Rr]elease/ +[Rr]eleases/ +x64/ +x86/ +[Ww][Ii][Nn]32/ +[Aa][Rr][Mm]/ +[Aa][Rr][Mm]64/ +bld/ +[Bb]in/ +[Oo]bj/ +[Ll]og/ +[Ll]ogs/ + +# Visual Studio 2015/2017 cache/options directory +.vs/ +# Uncomment if you have tasks that create the project's static files in wwwroot +#wwwroot/ + +# Visual Studio 2017 auto generated files +Generated\ Files/ + +# MSTest test Results +[Tt]est[Rr]esult*/ +[Bb]uild[Ll]og.* + +# NUnit +*.VisualState.xml +TestResult.xml +nunit-*.xml + +# Build Results of an ATL Project +[Dd]ebugPS/ +[Rr]eleasePS/ +dlldata.c + +# Benchmark Results +BenchmarkDotNet.Artifacts/ + +# .NET +project.lock.json +project.fragment.lock.json +artifacts/ + +# Tye +.tye/ + +# ASP.NET Scaffolding +ScaffoldingReadMe.txt + +# StyleCop +StyleCopReport.xml + +# Files built by Visual Studio +*_i.c +*_p.c +*_h.h +*.ilk +*.meta +*.obj +*.iobj +*.pch +*.pdb +*.ipdb +*.pgc +*.pgd +*.rsp +*.sbr +*.tlb +*.tli +*.tlh +*.tmp +*.tmp_proj +*_wpftmp.csproj +*.log +*.tlog +*.vspscc +*.vssscc +.builds +*.pidb +*.svclog +*.scc + +# Chutzpah Test files +_Chutzpah* + +# Visual C++ cache files +ipch/ +*.aps +*.ncb +*.opendb +*.opensdf +*.sdf +*.cachefile +*.VC.db +*.VC.VC.opendb + +# Visual Studio profiler +*.psess +*.vsp +*.vspx +*.sap + +# Visual Studio Trace Files +*.e2e + +# TFS 2012 Local Workspace +$tf/ + +# Guidance Automation Toolkit +*.gpState + +# ReSharper is a .NET coding add-in +_ReSharper*/ +*.[Rr]e[Ss]harper +*.DotSettings.user + +# TeamCity is a build add-in +_TeamCity* + +# DotCover is a Code Coverage Tool +*.dotCover + +# AxoCover is a Code Coverage Tool +.axoCover/* +!.axoCover/settings.json + +# Coverlet is a free, cross platform Code Coverage Tool +coverage*.json +coverage*.xml +coverage*.info + +# Visual Studio code coverage results +*.coverage +*.coveragexml + +# NCrunch +_NCrunch_* +.*crunch*.local.xml +nCrunchTemp_* + +# MightyMoose +*.mm.* +AutoTest.Net/ + +# Web workbench (sass) +.sass-cache/ + +# Installshield output folder +[Ee]xpress/ + +# DocProject is a documentation generator add-in +DocProject/buildhelp/ +DocProject/Help/*.HxT +DocProject/Help/*.HxC +DocProject/Help/*.hhc +DocProject/Help/*.hhk +DocProject/Help/*.hhp +DocProject/Help/Html2 +DocProject/Help/html + +# Click-Once directory +publish/ + +# Publish Web Output +*.[Pp]ublish.xml +*.azurePubxml +# Note: Comment the next line if you want to checkin your web deploy settings, +# but database connection strings (with potential passwords) will be unencrypted +*.pubxml +*.publishproj + +# Microsoft Azure Web App publish settings. Comment the next line if you want to +# checkin your Azure Web App publish settings, but sensitive information contained +# in these scripts will be unencrypted +PublishScripts/ + +# NuGet Packages +*.nupkg +# NuGet Symbol Packages +*.snupkg +# The packages folder can be ignored because of Package Restore +**/[Pp]ackages/* +# except build/, which is used as an MSBuild target. +!**/[Pp]ackages/build/ +# Uncomment if necessary however generally it will be regenerated when needed +#!**/[Pp]ackages/repositories.config +# NuGet v3's project.json files produces more ignorable files +*.nuget.props +*.nuget.targets + +# Microsoft Azure Build Output +csx/ +*.build.csdef + +# Microsoft Azure Emulator +ecf/ +rcf/ + +# Windows Store app package directories and files +AppPackages/ +BundleArtifacts/ +Package.StoreAssociation.xml +_pkginfo.txt +*.appx +*.appxbundle +*.appxupload + +# Visual Studio cache files +# files ending in .cache can be ignored +*.[Cc]ache +# but keep track of directories ending in .cache +!?*.[Cc]ache/ + +# Others +ClientBin/ +~$* +*~ +*.dbmdl +*.dbproj.schemaview +*.jfm +*.pfx +*.publishsettings +orleans.codegen.cs + +# Including strong name files can present a security risk +# (https://github.com/github/gitignore/pull/2483#issue-259490424) +#*.snk + +# Since there are multiple workflows, uncomment next line to ignore bower_components +# (https://github.com/github/gitignore/pull/1529#issuecomment-104372622) +#bower_components/ + +# RIA/Silverlight projects +Generated_Code/ + +# Backup & report files from converting an old project file +# to a newer Visual Studio version. Backup files are not needed, +# because we have git ;-) +_UpgradeReport_Files/ +Backup*/ +UpgradeLog*.XML +UpgradeLog*.htm +ServiceFabricBackup/ +*.rptproj.bak + +# SQL Server files +*.mdf +*.ldf +*.ndf + +# Business Intelligence projects +*.rdl.data +*.bim.layout +*.bim_*.settings +*.rptproj.rsuser +*- [Bb]ackup.rdl +*- [Bb]ackup ([0-9]).rdl +*- [Bb]ackup ([0-9][0-9]).rdl + +# Microsoft Fakes +FakesAssemblies/ + +# GhostDoc plugin setting file +*.GhostDoc.xml + +# Node.js Tools for Visual Studio +.ntvs_analysis.dat +node_modules/ + +# Visual Studio 6 build log +*.plg + +# Visual Studio 6 workspace options file +*.opt + +# Visual Studio 6 auto-generated workspace file (contains which files were open etc.) +*.vbw + +# Visual Studio 6 auto-generated project file (contains which files were open etc.) +*.vbp + +# Visual Studio 6 workspace and project file (working project files containing files to include in project) +*.dsw +*.dsp + +# Visual Studio 6 technical files +*.ncb +*.aps + +# Visual Studio LightSwitch build output +**/*.HTMLClient/GeneratedArtifacts +**/*.DesktopClient/GeneratedArtifacts +**/*.DesktopClient/ModelManifest.xml +**/*.Server/GeneratedArtifacts +**/*.Server/ModelManifest.xml +_Pvt_Extensions + +# Paket dependency manager +.paket/paket.exe +paket-files/ + +# FAKE - F# Make +.fake/ + +# CodeRush personal settings +.cr/personal + +# Python Tools for Visual Studio (PTVS) +__pycache__/ +*.pyc + +# Cake - Uncomment if you are using it +# tools/** +# !tools/packages.config + +# Tabs Studio +*.tss + +# Telerik's JustMock configuration file +*.jmconfig + +# BizTalk build output +*.btp.cs +*.btm.cs +*.odx.cs +*.xsd.cs + +# OpenCover UI analysis results +OpenCover/ + +# Azure Stream Analytics local run output +ASALocalRun/ + +# MSBuild Binary and Structured Log +*.binlog + +# NVidia Nsight GPU debugger configuration file +*.nvuser + +# MFractors (Xamarin productivity tool) working folder +.mfractor/ + +# Local History for Visual Studio +.localhistory/ + +# Visual Studio History (VSHistory) files +.vshistory/ + +# BeatPulse healthcheck temp database +healthchecksdb + +# Backup folder for Package Reference Convert tool in Visual Studio 2017 +MigrationBackup/ + +# Ionide (cross platform F# VS Code tools) working folder +.ionide/ + +# Fody - auto-generated XML schema +FodyWeavers.xsd + +# VS Code files for those working on multiple tools +.vscode/* +!.vscode/settings.json +!.vscode/tasks.json +!.vscode/launch.json +!.vscode/extensions.json +*.code-workspace + +# Local History for Visual Studio Code +.history/ + +# Windows Installer files from build outputs +*.cab +*.msi +*.msix +*.msm +*.msp + +# JetBrains Rider +*.sln.iml +.idea + +## +## Visual studio for Mac +## + + +# globs +Makefile.in +*.userprefs +*.usertasks +config.make +config.status +aclocal.m4 +install-sh +autom4te.cache/ +*.tar.gz +tarballs/ +test-results/ + +# Mac bundle stuff +*.dmg +*.app + +# content below from: https://github.com/github/gitignore/blob/master/Global/macOS.gitignore +# General +.DS_Store +.AppleDouble +.LSOverride + +# Icon must end with two \r +Icon + + +# Thumbnails +._* + +# Files that might appear in the root of a volume +.DocumentRevisions-V100 +.fseventsd +.Spotlight-V100 +.TemporaryItems +.Trashes +.VolumeIcon.icns +.com.apple.timemachine.donotpresent + +# Directories potentially created on remote AFP share +.AppleDB +.AppleDesktop +Network Trash Folder +Temporary Items +.apdisk + +# content below from: https://github.com/github/gitignore/blob/master/Global/Windows.gitignore +# Windows thumbnail cache files +Thumbs.db +ehthumbs.db +ehthumbs_vista.db + +# Dump file +*.stackdump + +# Folder config file +[Dd]esktop.ini + +# Recycle Bin used on file shares +$RECYCLE.BIN/ + +# Windows Installer files +*.cab +*.msi +*.msix +*.msm +*.msp + +# Windows shortcuts +*.lnk + +# Vim temporary swap files +*.swp diff --git a/src/ApplicationActivationManager.cs b/src/ApplicationActivationManager.cs new file mode 100644 index 0000000..b8ac674 --- /dev/null +++ b/src/ApplicationActivationManager.cs @@ -0,0 +1,12 @@ +using System.Runtime.InteropServices; +using System.Runtime.CompilerServices; + +[ComImport, Guid("2E941141-7F97-4756-BA1D-9DECDE894A3D"), InterfaceType(ComInterfaceType.InterfaceIsIUnknown)] +interface IApplicationActivationManager { int ActivateApplication(string appUserModelId, string arguments, int options, out int processId); } + +[ComImport, Guid("45BA127D-10A8-46EA-8AB7-56EA9078943C")] +sealed class ApplicationActivationManager : IApplicationActivationManager +{ + [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime)] + public extern int ActivateApplication(string appUserModelId, string arguments, int options, out int processId); +} \ No newline at end of file diff --git a/src/Game.cs b/src/Game.cs new file mode 100644 index 0000000..6379c76 --- /dev/null +++ b/src/Game.cs @@ -0,0 +1,52 @@ +namespace Minecraft.UWP; + +using System; +using System.IO; +using System.Linq; +using System.Threading; +using System.ComponentModel; +using System.Threading.Tasks; +using Windows.Management.Core; +using Windows.Management.Deployment; +using System.Runtime.InteropServices; + +public sealed class Game +{ + static readonly ApplicationActivationManager applicationActivationManager = new(); + + static readonly PackageManager packageManager = new(); + + static readonly PackageDebugSettings packageDebugSettings = new(); + + const string packageFamilyName = "Microsoft.MinecraftUWP_8wekyb3d8bbwe"; + + const string appUserModelId = "Microsoft.MinecraftUWP_8wekyb3d8bbwe!App"; + + public readonly int ProcessId; + + internal Game(int processId) => ProcessId = processId; + + public static int Launch() + { + var package = packageManager.FindPackagesForUser(string.Empty, packageFamilyName).FirstOrDefault() ?? throw new Win32Exception(Native.ERROR_INSTALL_PACKAGE_NOT_FOUND); + Marshal.ThrowExceptionForHR(packageDebugSettings.GetPackageExecutionState(package.Id.FullName, out var packageExecutionState)); + Marshal.ThrowExceptionForHR(packageDebugSettings.EnableDebugging(package.Id.FullName, default, default)); + + using ManualResetEventSlim @event = new(packageExecutionState is not PackageExecutionState.Unknown or PackageExecutionState.Terminated); + using FileSystemWatcher watcher = new(ApplicationDataManager.CreateForPackageFamily(packageFamilyName).LocalFolder.Path) + { + NotifyFilter = NotifyFilters.FileName, + IncludeSubdirectories = true, + EnableRaisingEvents = true + }; + watcher.Deleted += (_, e) => { if (e.Name.Equals(@"games\com.mojang\minecraftpe\resource_init_lock", StringComparison.OrdinalIgnoreCase)) @event.Set(); }; + + Marshal.ThrowExceptionForHR(applicationActivationManager.ActivateApplication(appUserModelId, default, Native.AO_NOERRORUI, out var processId)); @event.Wait(); return processId; + } + + public static async Task LaunchAsync() => await Task.Run(Launch).ConfigureAwait(false); + + public void Load(string path) => Library.Load(ProcessId, Path.GetFullPath(path)); + + public async Task LoadAsync(string path) => await Task.Run(() => Load(path)).ConfigureAwait(false); +} \ No newline at end of file diff --git a/src/Library.cs b/src/Library.cs new file mode 100644 index 0000000..70b54f7 --- /dev/null +++ b/src/Library.cs @@ -0,0 +1,55 @@ +using System.ComponentModel; +using System.IO; +using System.Runtime.InteropServices; +using System.Security.AccessControl; +using System.Security.Principal; +using System.Threading; + +static class Library +{ + static readonly SecurityIdentifier identifier = new("S-1-15-2-1"); + + static readonly nint lpStartAddress; + + static Library() + { + var hModule = Native.LoadLibraryEx("Kernel32.dll", default, Native.LOAD_LIBRARY_SEARCH_SYSTEM32); + lpStartAddress = Native.GetProcAddress(hModule, "LoadLibraryW"); + Native.FreeLibrary(hModule); + } + + internal static void Load(int processId, string path) + { + if (File.Exists(path)) + { + var security = File.GetAccessControl(path); + security.AddAccessRule(new(identifier, FileSystemRights.ReadAndExecute, AccessControlType.Allow)); + File.SetAccessControl(path, security); + } + else throw new FileNotFoundException(); + + nint hProcess = default, lpBaseAddress = default, hThread = default; + try + { + hProcess = Native.OpenProcess(Native.PROCESS_ALL_ACCESS, false, processId); + if (hProcess == default) throw new Win32Exception(Marshal.GetLastWin32Error()); + + var nSize = sizeof(char) * (path.Length + 1); + + lpBaseAddress = Native.VirtualAllocEx(hProcess, default, nSize, Native.MEM_COMMIT | Native.MEM_RESERVE, Native.PAGE_EXECUTE_READWRITE); + if (lpBaseAddress == default) throw new Win32Exception(Marshal.GetLastWin32Error()); + + if (!Native.WriteProcessMemory(hProcess, lpBaseAddress, Marshal.StringToHGlobalUni(path), nSize, out _)) throw new Win32Exception(Marshal.GetLastWin32Error()); + + hThread = Native.CreateRemoteThread(hProcess, default, 0, lpStartAddress, lpBaseAddress, 0, out _); + if (hThread == default) throw new Win32Exception(Marshal.GetLastWin32Error()); + Native.WaitForSingleObject(hThread, Timeout.Infinite); + } + finally + { + Native.VirtualFreeEx(hProcess, lpBaseAddress, 0, Native.MEM_RELEASE); + Native.CloseHandle(hThread); + Native.CloseHandle(hProcess); + } + } +} \ No newline at end of file diff --git a/src/Minecraft.UWP.csproj b/src/Minecraft.UWP.csproj new file mode 100644 index 0000000..910ea0b --- /dev/null +++ b/src/Minecraft.UWP.csproj @@ -0,0 +1,13 @@ + + + + net481 + latest + IDE0130 + true + + + + + + \ No newline at end of file diff --git a/src/Native.cs b/src/Native.cs new file mode 100644 index 0000000..013838e --- /dev/null +++ b/src/Native.cs @@ -0,0 +1,54 @@ +using System.Security; +using System.Runtime.InteropServices; + +static class Native +{ + internal const int LOAD_LIBRARY_SEARCH_SYSTEM32 = 0x00000800; + + internal const int MEM_RELEASE = 0x00008000; + + internal const int PROCESS_ALL_ACCESS = 0X1FFFFF; + + internal const int MEM_COMMIT = 0x00001000; + + internal const int MEM_RESERVE = 0x00002000; + + internal const int PAGE_EXECUTE_READWRITE = 0x40; + + internal const int ERROR_INSTALL_PACKAGE_NOT_FOUND = unchecked((int)0x80073CF1); + + internal const int AO_NOERRORUI = 0x00000002; + + [DllImport("Kernel32", SetLastError = true), DefaultDllImportSearchPaths(DllImportSearchPath.System32), SuppressUnmanagedCodeSecurity] + internal static extern nint OpenProcess(int dwDesiredAccess, bool bInheritHandle, int dwProcessId); + + [DllImport("Kernel32", SetLastError = true), DefaultDllImportSearchPaths(DllImportSearchPath.System32), SuppressUnmanagedCodeSecurity] + internal static extern int WaitForSingleObject(nint hHandle, int dwMilliseconds); + + [DllImport("Kernel32", SetLastError = true), DefaultDllImportSearchPaths(DllImportSearchPath.System32), SuppressUnmanagedCodeSecurity] + internal static extern bool CloseHandle(nint hObject); + + [DllImport("Kernel32", SetLastError = true), DefaultDllImportSearchPaths(DllImportSearchPath.System32), SuppressUnmanagedCodeSecurity] + internal static extern nint VirtualAllocEx(nint hProcess, nint lpAddress, int dwSize, int flAllocationType, int flProtect); + + [DllImport("Kernel32", SetLastError = true), DefaultDllImportSearchPaths(DllImportSearchPath.System32), SuppressUnmanagedCodeSecurity] + internal static extern bool WriteProcessMemory(nint hProcess, nint lpBaseAddress, nint lpBuffer, int nSize, out int lpNumberOfBytesWritten); + + [DllImport("Kernel32", SetLastError = true), DefaultDllImportSearchPaths(DllImportSearchPath.System32), SuppressUnmanagedCodeSecurity] + internal static extern nint CreateRemoteThread(nint hProcess, nint lpThreadAttributes, int dwStackSize, nint lpStartAddress, nint lpParameter, int dwCreationFlags, out int lpThreadId); + + [DllImport("Kernel32", CharSet = CharSet.Auto, SetLastError = true), DefaultDllImportSearchPaths(DllImportSearchPath.System32), SuppressUnmanagedCodeSecurity] + internal static extern nint LoadLibraryEx(string lpLibFileName, nint hFile, int dwFlags); + + [DllImport("Kernel32", SetLastError = true), DefaultDllImportSearchPaths(DllImportSearchPath.System32), SuppressUnmanagedCodeSecurity] + internal static extern bool FreeLibrary(nint hLibModule); + + [DllImport("Kernel32", SetLastError = true), DefaultDllImportSearchPaths(DllImportSearchPath.System32), SuppressUnmanagedCodeSecurity] + internal static extern nint GetProcAddress(nint hModule, string lpProcName); + + [DllImport("Kernel32", SetLastError = true), DefaultDllImportSearchPaths(DllImportSearchPath.System32), SuppressUnmanagedCodeSecurity] + internal static extern bool VirtualFreeEx(nint hProcess, nint lpAddress, int dwSize, nint dwFreeType); + + [DllImport("Shlwapi", SetLastError = true, CharSet = CharSet.Auto), DefaultDllImportSearchPaths(DllImportSearchPath.System32), SuppressUnmanagedCodeSecurity] + internal static extern bool PathIsRelative(string pszPath); +} \ No newline at end of file diff --git a/src/PackageDebugSettings.cs b/src/PackageDebugSettings.cs new file mode 100644 index 0000000..3866086 --- /dev/null +++ b/src/PackageDebugSettings.cs @@ -0,0 +1,78 @@ +using System; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; + +enum PackageExecutionState { Unknown, Running, Suspending, Suspended, Terminated } + +[ComImport, Guid("F27C3930-8029-4AD1-94E3-3DBA417810C1"), InterfaceType(ComInterfaceType.InterfaceIsIUnknown)] +interface IPackageDebugSettings +{ + int EnableDebugging(string packageFullName, string debuggerCommandLine, string environment); + + int DisableDebugging(string packageFullName); + + int Suspend(string packageFullName); + + int Resume(string packageFullName); + + int TerminateAllProcesses(string packageFullName); + + int SetTargetSessionId(ulong sessionId); + + int EnumerateBackgroundTasks(string packageFullName, nint taskCount, nint taskIds, nint taskNames); + + int ActivateBackgroundTask(ref Guid taskId); + + int StartServicing(string packageFullName); + + int StopServicing(string packageFullName); + + int StartSessionRedirection(string packageFullName, ulong sessionId); + + int StopSessionRedirection(string packageFullName); + + int GetPackageExecutionState(string packageFullName, out PackageExecutionState packageExecutionState); +} + +[ComImport, Guid("B1AEC16F-2383-4852-B0E9-8F0B1DC66B4D")] +sealed class PackageDebugSettings : IPackageDebugSettings +{ + [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime)] + public extern int GetPackageExecutionState(string packageFullName, out PackageExecutionState packageExecutionState); + + [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime)] + public extern int EnableDebugging(string packageFullName, string debuggerCommandLine, string environment); + + [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime)] + public extern int DisableDebugging(string packageFullName); + + [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime)] + public extern int Suspend(string packageFullName); + + [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime)] + public extern int Resume(string packageFullName); + + [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime)] + public extern int TerminateAllProcesses(string packageFullName); + + [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime)] + public extern int SetTargetSessionId(ulong sessionId); + + [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime)] + public extern int EnumerateBackgroundTasks(string packageFullName, nint taskCount, nint taskIds, nint taskNames); + + [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime)] + public extern int ActivateBackgroundTask(ref Guid taskId); + + [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime)] + public extern int StartServicing(string packageFullName); + + [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime)] + public extern int StopServicing(string packageFullName); + + [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime)] + public extern int StartSessionRedirection(string packageFullName, ulong sessionId); + [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime)] + public extern int StopSessionRedirection(string packageFullName); + +} \ No newline at end of file