From 73dd9e7c06fb751344b3e3e1a76b559112191627 Mon Sep 17 00:00:00 2001 From: Rutherther Date: Thu, 27 Jan 2022 22:54:19 +0100 Subject: [PATCH] chore: remove projects for local injectable client, move them to NosSmooth.Local --- .../ChatCommandInterceptor.cs | 92 ----- .../ChatCommandsOptions.cs | 18 - .../NosSmooth.ChatCommands/FeedbackService.cs | 68 ---- .../NosSmooth.ChatCommands.csproj | 18 - .../ServiceCollectionExtensions.cs | 36 -- .../NosSmooth.Inject/NosSmooth.Inject.vcxproj | 174 -------- .../NosSmooth.Inject.vcxproj.filters | 39 -- Local/NosSmooth.Inject/coreclr_delegates.h | 47 --- Local/NosSmooth.Inject/dllmain.cpp | 19 - Local/NosSmooth.Inject/framework.h | 5 - Local/NosSmooth.Inject/hostfxr.h | 323 --------------- Local/NosSmooth.Inject/nethost.h | 94 ----- Local/NosSmooth.Inject/nossmooth.cpp | 125 ------ Local/NosSmooth.Inject/nossmooth.h | 15 - Local/NosSmooth.Inject/pch.cpp | 5 - Local/NosSmooth.Inject/pch.h | 13 - .../Commands/InjectCommand.cs | 68 ---- .../Commands/ListProcessesCommand.cs | 41 -- .../NosSmooth.Injector.CLI.csproj | 28 -- Local/NosSmooth.Injector.CLI/Program.cs | 75 ---- Local/NosSmooth.Injector.CLI/app.manifest | 11 - .../Errors/InjectionFailedError.cs | 15 - .../Errors/InsufficientPermissionsError.cs | 20 - .../Errors/ProcessNotFoundError.cs | 16 - Local/NosSmooth.Injector/LoadParams.cs | 44 -- .../ManagedMemoryAllocation.cs | 47 --- Local/NosSmooth.Injector/NosInjector.cs | 155 -------- .../NosSmooth.Injector/NosInjectorOptions.cs | 32 -- .../NosSmooth.Injector.csproj | 15 - .../Errors/BindingNotFoundError.cs | 17 - .../Errors/CouldNotInitializeModuleError.cs | 17 - .../Errors/NotNostaleProcessError.cs | 17 - .../Extensions/MemoryExtensions.cs | 33 -- .../Extensions/ServiceCollectionExtensions.cs | 44 -- .../NosSmooth.LocalBinding/IsExternalInit.cs | 15 - .../NosBindingManager.cs | 375 ------------------ .../NosBrowserManager.cs | 279 ------------- .../NosSmooth.LocalBinding.csproj | 18 - .../Objects/NetworkBinding.cs | 236 ----------- .../Objects/NostaleStringA.cs | 84 ---- .../Objects/PetManagerBinding.cs | 129 ------ .../Objects/PlayerManagerBinding.cs | 284 ------------- .../Objects/UnitManagerBinding.cs | 164 -------- .../Options/CharacterBindingOptions.cs | 47 --- .../Options/NetworkBindingOptions.cs | 44 -- .../Options/PetManagerBindingOptions.cs | 26 -- .../Options/PetManagerOptions.cs | 28 -- .../Options/PlayerManagerOptions.cs | 27 -- .../Options/SceneManagerOptions.cs | 30 -- .../Options/UnitManagerBindingOptions.cs | 38 -- .../Structs/ControlManager.cs | 78 ---- .../Structs/MapBaseObj.cs | 68 ---- .../Structs/MapNpcObj.cs | 25 -- .../Structs/MapPlayerObj.cs | 45 --- .../Structs/NostaleList.cs | 122 ------ .../Structs/NostaleObject.cs | 43 -- .../Structs/PetManager.cs | 51 --- .../Structs/PetManagerList.cs | 54 --- .../Structs/PlayerManager.cs | 94 ----- .../Structs/SceneManager.cs | 160 -------- .../Walk/ControlCommandWalkHandler.cs | 145 ------- .../Walk/Errors/WalkNotFinishedError.cs | 18 - .../Walk/PetWalkCommandHandler.cs | 75 ---- .../Walk/PlayerWalkCommandHandler.cs | 71 ---- .../Walk/WalkCommandHandlerOptions.cs | 23 -- .../Walk/WalkUnfinishedReason.cs | 36 -- .../Extensions/ServiceCollectionExtensions.cs | 51 --- .../IPacketInterceptor.cs | 28 -- Local/NosSmooth.LocalClient/IsExternalInit.cs | 15 - .../LocalClientOptions.cs | 18 - .../NosSmooth.LocalClient.csproj | 21 - .../NostaleLocalClient.cs | 216 ---------- Local/NosSmooth.LocalClient/NostaleWindow.cs | 58 --- Local/NosSmooth.LocalClient/Utils/User32.cs | 88 ---- NosSmooth.Unix.sln | 191 --------- NosSmooth.Unix.sln.DotSettings | 6 - NosSmooth.sln | 187 --------- .../ExternalBrowser/ExternalBrowser.csproj | 15 - Samples/ExternalBrowser/Program.cs | 75 ---- Samples/InterceptNameChanger/DllMain.cs | 45 --- Samples/InterceptNameChanger/FodyWeavers.xml | 3 - .../InterceptNameChanger.csproj | 25 -- .../NameChangeInterceptor.cs | 81 ---- Samples/InterceptNameChanger/NameChanger.cs | 86 ---- .../Properties/AssemblyInfo.cs | 41 -- Samples/SimpleChat/DllMain.cs | 32 -- Samples/SimpleChat/FodyWeavers.xml | 4 - Samples/SimpleChat/SayResponder.cs | 51 --- Samples/SimpleChat/SimpleChat.cs | 74 ---- Samples/SimpleChat/SimpleChat.csproj | 26 -- .../WalkCommands/Commands/CombatCommands.cs | 92 ----- .../WalkCommands/Commands/DetachCommand.cs | 52 --- Samples/WalkCommands/Commands/WalkCommands.cs | 87 ---- Samples/WalkCommands/DllMain.cs | 40 -- Samples/WalkCommands/FodyWeavers.xml | 3 - Samples/WalkCommands/Startup.cs | 82 ---- Samples/WalkCommands/WalkCommands.csproj | 42 -- 97 files changed, 6553 deletions(-) delete mode 100644 Local/NosSmooth.ChatCommands/ChatCommandInterceptor.cs delete mode 100644 Local/NosSmooth.ChatCommands/ChatCommandsOptions.cs delete mode 100644 Local/NosSmooth.ChatCommands/FeedbackService.cs delete mode 100644 Local/NosSmooth.ChatCommands/NosSmooth.ChatCommands.csproj delete mode 100644 Local/NosSmooth.ChatCommands/ServiceCollectionExtensions.cs delete mode 100644 Local/NosSmooth.Inject/NosSmooth.Inject.vcxproj delete mode 100644 Local/NosSmooth.Inject/NosSmooth.Inject.vcxproj.filters delete mode 100644 Local/NosSmooth.Inject/coreclr_delegates.h delete mode 100644 Local/NosSmooth.Inject/dllmain.cpp delete mode 100644 Local/NosSmooth.Inject/framework.h delete mode 100644 Local/NosSmooth.Inject/hostfxr.h delete mode 100644 Local/NosSmooth.Inject/nethost.h delete mode 100644 Local/NosSmooth.Inject/nossmooth.cpp delete mode 100644 Local/NosSmooth.Inject/nossmooth.h delete mode 100644 Local/NosSmooth.Inject/pch.cpp delete mode 100644 Local/NosSmooth.Inject/pch.h delete mode 100644 Local/NosSmooth.Injector.CLI/Commands/InjectCommand.cs delete mode 100644 Local/NosSmooth.Injector.CLI/Commands/ListProcessesCommand.cs delete mode 100644 Local/NosSmooth.Injector.CLI/NosSmooth.Injector.CLI.csproj delete mode 100644 Local/NosSmooth.Injector.CLI/Program.cs delete mode 100644 Local/NosSmooth.Injector.CLI/app.manifest delete mode 100644 Local/NosSmooth.Injector/Errors/InjectionFailedError.cs delete mode 100644 Local/NosSmooth.Injector/Errors/InsufficientPermissionsError.cs delete mode 100644 Local/NosSmooth.Injector/Errors/ProcessNotFoundError.cs delete mode 100644 Local/NosSmooth.Injector/LoadParams.cs delete mode 100644 Local/NosSmooth.Injector/ManagedMemoryAllocation.cs delete mode 100644 Local/NosSmooth.Injector/NosInjector.cs delete mode 100644 Local/NosSmooth.Injector/NosInjectorOptions.cs delete mode 100644 Local/NosSmooth.Injector/NosSmooth.Injector.csproj delete mode 100644 Local/NosSmooth.LocalBinding/Errors/BindingNotFoundError.cs delete mode 100644 Local/NosSmooth.LocalBinding/Errors/CouldNotInitializeModuleError.cs delete mode 100644 Local/NosSmooth.LocalBinding/Errors/NotNostaleProcessError.cs delete mode 100644 Local/NosSmooth.LocalBinding/Extensions/MemoryExtensions.cs delete mode 100644 Local/NosSmooth.LocalBinding/Extensions/ServiceCollectionExtensions.cs delete mode 100644 Local/NosSmooth.LocalBinding/IsExternalInit.cs delete mode 100644 Local/NosSmooth.LocalBinding/NosBindingManager.cs delete mode 100644 Local/NosSmooth.LocalBinding/NosBrowserManager.cs delete mode 100644 Local/NosSmooth.LocalBinding/NosSmooth.LocalBinding.csproj delete mode 100644 Local/NosSmooth.LocalBinding/Objects/NetworkBinding.cs delete mode 100644 Local/NosSmooth.LocalBinding/Objects/NostaleStringA.cs delete mode 100644 Local/NosSmooth.LocalBinding/Objects/PetManagerBinding.cs delete mode 100644 Local/NosSmooth.LocalBinding/Objects/PlayerManagerBinding.cs delete mode 100644 Local/NosSmooth.LocalBinding/Objects/UnitManagerBinding.cs delete mode 100644 Local/NosSmooth.LocalBinding/Options/CharacterBindingOptions.cs delete mode 100644 Local/NosSmooth.LocalBinding/Options/NetworkBindingOptions.cs delete mode 100644 Local/NosSmooth.LocalBinding/Options/PetManagerBindingOptions.cs delete mode 100644 Local/NosSmooth.LocalBinding/Options/PetManagerOptions.cs delete mode 100644 Local/NosSmooth.LocalBinding/Options/PlayerManagerOptions.cs delete mode 100644 Local/NosSmooth.LocalBinding/Options/SceneManagerOptions.cs delete mode 100644 Local/NosSmooth.LocalBinding/Options/UnitManagerBindingOptions.cs delete mode 100644 Local/NosSmooth.LocalBinding/Structs/ControlManager.cs delete mode 100644 Local/NosSmooth.LocalBinding/Structs/MapBaseObj.cs delete mode 100644 Local/NosSmooth.LocalBinding/Structs/MapNpcObj.cs delete mode 100644 Local/NosSmooth.LocalBinding/Structs/MapPlayerObj.cs delete mode 100644 Local/NosSmooth.LocalBinding/Structs/NostaleList.cs delete mode 100644 Local/NosSmooth.LocalBinding/Structs/NostaleObject.cs delete mode 100644 Local/NosSmooth.LocalBinding/Structs/PetManager.cs delete mode 100644 Local/NosSmooth.LocalBinding/Structs/PetManagerList.cs delete mode 100644 Local/NosSmooth.LocalBinding/Structs/PlayerManager.cs delete mode 100644 Local/NosSmooth.LocalBinding/Structs/SceneManager.cs delete mode 100644 Local/NosSmooth.LocalClient/CommandHandlers/Walk/ControlCommandWalkHandler.cs delete mode 100644 Local/NosSmooth.LocalClient/CommandHandlers/Walk/Errors/WalkNotFinishedError.cs delete mode 100644 Local/NosSmooth.LocalClient/CommandHandlers/Walk/PetWalkCommandHandler.cs delete mode 100644 Local/NosSmooth.LocalClient/CommandHandlers/Walk/PlayerWalkCommandHandler.cs delete mode 100644 Local/NosSmooth.LocalClient/CommandHandlers/Walk/WalkCommandHandlerOptions.cs delete mode 100644 Local/NosSmooth.LocalClient/CommandHandlers/Walk/WalkUnfinishedReason.cs delete mode 100644 Local/NosSmooth.LocalClient/Extensions/ServiceCollectionExtensions.cs delete mode 100644 Local/NosSmooth.LocalClient/IPacketInterceptor.cs delete mode 100644 Local/NosSmooth.LocalClient/IsExternalInit.cs delete mode 100644 Local/NosSmooth.LocalClient/LocalClientOptions.cs delete mode 100644 Local/NosSmooth.LocalClient/NosSmooth.LocalClient.csproj delete mode 100644 Local/NosSmooth.LocalClient/NostaleLocalClient.cs delete mode 100644 Local/NosSmooth.LocalClient/NostaleWindow.cs delete mode 100644 Local/NosSmooth.LocalClient/Utils/User32.cs delete mode 100644 NosSmooth.Unix.sln delete mode 100644 NosSmooth.Unix.sln.DotSettings delete mode 100644 Samples/ExternalBrowser/ExternalBrowser.csproj delete mode 100644 Samples/ExternalBrowser/Program.cs delete mode 100644 Samples/InterceptNameChanger/DllMain.cs delete mode 100644 Samples/InterceptNameChanger/FodyWeavers.xml delete mode 100644 Samples/InterceptNameChanger/InterceptNameChanger.csproj delete mode 100644 Samples/InterceptNameChanger/NameChangeInterceptor.cs delete mode 100644 Samples/InterceptNameChanger/NameChanger.cs delete mode 100644 Samples/InterceptNameChanger/Properties/AssemblyInfo.cs delete mode 100644 Samples/SimpleChat/DllMain.cs delete mode 100644 Samples/SimpleChat/FodyWeavers.xml delete mode 100644 Samples/SimpleChat/SayResponder.cs delete mode 100644 Samples/SimpleChat/SimpleChat.cs delete mode 100644 Samples/SimpleChat/SimpleChat.csproj delete mode 100644 Samples/WalkCommands/Commands/CombatCommands.cs delete mode 100644 Samples/WalkCommands/Commands/DetachCommand.cs delete mode 100644 Samples/WalkCommands/Commands/WalkCommands.cs delete mode 100644 Samples/WalkCommands/DllMain.cs delete mode 100644 Samples/WalkCommands/FodyWeavers.xml delete mode 100644 Samples/WalkCommands/Startup.cs delete mode 100644 Samples/WalkCommands/WalkCommands.csproj diff --git a/Local/NosSmooth.ChatCommands/ChatCommandInterceptor.cs b/Local/NosSmooth.ChatCommands/ChatCommandInterceptor.cs deleted file mode 100644 index 9758f7e1ff93793ba02d94b360c93f392731beb2..0000000000000000000000000000000000000000 --- a/Local/NosSmooth.ChatCommands/ChatCommandInterceptor.cs +++ /dev/null @@ -1,92 +0,0 @@ -// -// ChatCommandInterceptor.cs -// -// Copyright (c) František Boháček. All rights reserved. -// Licensed under the MIT license. See LICENSE file in the project root for full license information. - -using System.Reflection.Emit; -using Microsoft.Extensions.Logging; -using Microsoft.Extensions.Options; -using NosSmooth.Core.Extensions; -using NosSmooth.LocalClient; -using NosSmooth.Packets.Enums; -using NosSmooth.Packets.Enums.Chat; -using NosSmooth.Packets.Server.Chat; -using Remora.Commands.Services; - -namespace NosSmooth.ChatCommands; - -/// -/// Handles commands in the chat. -/// -public class ChatCommandInterceptor : IPacketInterceptor -{ - private readonly CommandService _commandService; - private readonly IServiceProvider _serviceProvider; - private readonly FeedbackService _feedbackService; - private readonly ILogger _logger; - private readonly ChatCommandsOptions _options; - - /// - /// Initializes a new instance of the class. - /// - /// The options. - /// The command service. - /// The services. - /// The feedback service. - /// The logger. - public ChatCommandInterceptor - ( - IOptions options, - CommandService commandService, - IServiceProvider serviceProvider, - FeedbackService feedbackService, - ILogger logger - ) - { - _commandService = commandService; - _serviceProvider = serviceProvider; - _feedbackService = feedbackService; - _logger = logger; - _options = options.Value; - } - - /// - public bool InterceptSend(ref string packet) - { - ReadOnlySpan span = packet; - if (span.StartsWith("say ") && span.Slice(4).StartsWith(_options.Prefix)) - { - var command = span.Slice(4 + _options.Prefix.Length).ToString(); - Task.Run(async () => await ExecuteCommand(command)); - return false; - } - - return true; - } - - /// - public bool InterceptReceive(ref string packet) - { - return true; - } - - private async Task ExecuteCommand(string command) - { - var preparedResult = await _commandService.TryPrepareCommandAsync(command, _serviceProvider); - if (!preparedResult.IsSuccess) - { - _logger.LogError($"Could not prepare \"{command}\""); - _logger.LogResultError(preparedResult); - await _feedbackService.SendErrorMessageAsync($"Could not prepare the given command. {preparedResult.Error.Message}"); - } - - var executeResult = await _commandService.TryExecuteAsync(preparedResult.Entity, _serviceProvider); - if (!executeResult.IsSuccess) - { - _logger.LogError($"Could not execute \"{command}\""); - _logger.LogResultError(executeResult); - await _feedbackService.SendErrorMessageAsync($"Could not execute the given command. {executeResult.Error.Message}"); - } - } -} \ No newline at end of file diff --git a/Local/NosSmooth.ChatCommands/ChatCommandsOptions.cs b/Local/NosSmooth.ChatCommands/ChatCommandsOptions.cs deleted file mode 100644 index 38e892259536aec19be1706fc11eec906c3df064..0000000000000000000000000000000000000000 --- a/Local/NosSmooth.ChatCommands/ChatCommandsOptions.cs +++ /dev/null @@ -1,18 +0,0 @@ -// -// ChatCommandsOptions.cs -// -// Copyright (c) František Boháček. All rights reserved. -// Licensed under the MIT license. See LICENSE file in the project root for full license information. - -namespace NosSmooth.ChatCommands; - -/// -/// Options for . -/// -public class ChatCommandsOptions -{ - /// - /// Gets or sets the command prefix. - /// - public string Prefix { get; set; } = "#"; -} \ No newline at end of file diff --git a/Local/NosSmooth.ChatCommands/FeedbackService.cs b/Local/NosSmooth.ChatCommands/FeedbackService.cs deleted file mode 100644 index 31ab98fde6e1204046753502fb5e89105d10eb8a..0000000000000000000000000000000000000000 --- a/Local/NosSmooth.ChatCommands/FeedbackService.cs +++ /dev/null @@ -1,68 +0,0 @@ -// -// FeedbackService.cs -// -// Copyright (c) František Boháček. All rights reserved. -// Licensed under the MIT license. See LICENSE file in the project root for full license information. - -using NosSmooth.Core.Client; -using NosSmooth.Packets.Enums; -using NosSmooth.Packets.Enums.Chat; -using NosSmooth.Packets.Server.Chat; -using Remora.Results; - -namespace NosSmooth.ChatCommands; - -/// -/// Feedback for chat commands. -/// -public class FeedbackService -{ - private readonly INostaleClient _client; - - /// - /// Initializes a new instance of the class. - /// - /// The nostale client. - public FeedbackService(INostaleClient client) - { - _client = client; - - } - - /// - /// Send message error. - /// - /// The message to send. - /// The cancellation token for cancelling the operation. - /// A result that may or may not have succeeded. - public Task SendErrorMessageAsync(string message, CancellationToken ct = default) - => SendMessageAsync(message, SayColor.Red, ct); - - /// - /// Send message success. - /// - /// The message to send. - /// The cancellation token for cancelling the operation. - /// A result that may or may not have succeeded. - public Task SendSuccessMessageAsync(string message, CancellationToken ct = default) - => SendMessageAsync(message, SayColor.Green, ct); - - /// - /// Send message info. - /// - /// The message to send. - /// The cancellation token for cancelling the operation. - /// A result that may or may not have succeeded. - public Task SendInfoMessageAsync(string message, CancellationToken ct = default) - => SendMessageAsync(message, SayColor.Default, ct); - - /// - /// Send message with the given color. - /// - /// The message to send. - /// The color. - /// The cancellation token for cancelling the operation. - /// A result that may or may not have succeeded. - public Task SendMessageAsync(string message, SayColor color, CancellationToken ct = default) - => _client.ReceivePacketAsync(new SayPacket(EntityType.Map, 0, color, message), ct); -} \ No newline at end of file diff --git a/Local/NosSmooth.ChatCommands/NosSmooth.ChatCommands.csproj b/Local/NosSmooth.ChatCommands/NosSmooth.ChatCommands.csproj deleted file mode 100644 index 5cad30c277e2390cf612b7d7a543d0cd90b30d4c..0000000000000000000000000000000000000000 --- a/Local/NosSmooth.ChatCommands/NosSmooth.ChatCommands.csproj +++ /dev/null @@ -1,18 +0,0 @@ - - - - net6.0 - enable - enable - - - - - - - - - - - - diff --git a/Local/NosSmooth.ChatCommands/ServiceCollectionExtensions.cs b/Local/NosSmooth.ChatCommands/ServiceCollectionExtensions.cs deleted file mode 100644 index f5e8f1afaf92fd864f94f1883b09ddd4b5c40f3b..0000000000000000000000000000000000000000 --- a/Local/NosSmooth.ChatCommands/ServiceCollectionExtensions.cs +++ /dev/null @@ -1,36 +0,0 @@ -// -// ServiceCollectionExtensions.cs -// -// Copyright (c) František Boháček. All rights reserved. -// Licensed under the MIT license. See LICENSE file in the project root for full license information. - -using Microsoft.Extensions.DependencyInjection; -using NosSmooth.LocalClient; -using NosSmooth.LocalClient.Extensions; -using Remora.Commands.Extensions; - -namespace NosSmooth.ChatCommands; - -/// -/// Extension methods for . -/// -public static class ServiceCollectionExtensions -{ - /// - /// Adds NosTale commands and the interceptor to execute commands with. - /// - /// The service collection. - /// The prefix for the commands. - /// The collection. - public static IServiceCollection AddNostaleChatCommands(this IServiceCollection serviceCollection, string prefix = "#") - { - serviceCollection - .Configure((o) => o.Prefix = prefix); - - return serviceCollection - .AddCommands() - .Configure(o => o.AllowIntercept = true) - .AddSingleton() - .AddPacketInterceptor(); - } -} \ No newline at end of file diff --git a/Local/NosSmooth.Inject/NosSmooth.Inject.vcxproj b/Local/NosSmooth.Inject/NosSmooth.Inject.vcxproj deleted file mode 100644 index 0093b71622d7a607a696e61da651a5cbe6b50342..0000000000000000000000000000000000000000 --- a/Local/NosSmooth.Inject/NosSmooth.Inject.vcxproj +++ /dev/null @@ -1,174 +0,0 @@ - - - - - Debug - Win32 - - - Release - Win32 - - - Debug - x64 - - - Release - x64 - - - - 16.0 - Win32Proj - {ca2873d8-bd0b-4583-818d-b94a3c2abba3} - NosSmoothInject - 10.0 - - - - DynamicLibrary - true - v143 - Unicode - - - DynamicLibrary - false - v143 - true - Unicode - - - DynamicLibrary - true - v143 - Unicode - - - DynamicLibrary - false - v143 - true - Unicode - - - - - - - - - - - - - - - - - - - - - true - - - false - - - true - - - false - - - - Level3 - true - WIN32;_DEBUG;NOSSMOOTHINJECT_EXPORTS;_WINDOWS;_USRDLL;%(PreprocessorDefinitions) - true - NotUsing - pch.h - - - Windows - true - false - %(AdditionalLibraryDirectories) - nethost.lib;%(AdditionalDependencies) - - - - - Level3 - true - true - true - WIN32;NDEBUG;NOSSMOOTHINJECT_EXPORTS;_WINDOWS;_USRDLL;%(PreprocessorDefinitions) - true - NotUsing - pch.h - - - Windows - true - true - true - false - %(AdditionalLibraryDirectories) - nethost.lib;%(AdditionalDependencies) - - - - - Level3 - true - _DEBUG;NOSSMOOTHINJECT_EXPORTS;_WINDOWS;_USRDLL;%(PreprocessorDefinitions) - true - NotUsing - pch.h - - - Windows - true - false - %(AdditionalLibraryDirectories) - nethost.lib;%(AdditionalDependencies) - - - - - Level3 - true - true - true - NDEBUG;NOSSMOOTHINJECT_EXPORTS;_WINDOWS;_USRDLL;%(PreprocessorDefinitions) - true - NotUsing - pch.h - - - Windows - true - true - true - false - %(AdditionalLibraryDirectories) - nethost.lib;%(AdditionalDependencies) - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/Local/NosSmooth.Inject/NosSmooth.Inject.vcxproj.filters b/Local/NosSmooth.Inject/NosSmooth.Inject.vcxproj.filters deleted file mode 100644 index 809672eb3fc259b68027ca28bf78ba384f57331d..0000000000000000000000000000000000000000 --- a/Local/NosSmooth.Inject/NosSmooth.Inject.vcxproj.filters +++ /dev/null @@ -1,39 +0,0 @@ - - - - - {4FC737F1-C7A5-4376-A066-2A32D752A2FF} - cpp;c;cc;cxx;c++;cppm;ixx;def;odl;idl;hpj;bat;asm;asmx - - - {93995380-89BD-4b04-88EB-625FBE52EBFB} - h;hh;hpp;hxx;h++;hm;inl;inc;ipp;xsd - - - {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} - rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms - - - - - Source Files - - - Source Files - - - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - \ No newline at end of file diff --git a/Local/NosSmooth.Inject/coreclr_delegates.h b/Local/NosSmooth.Inject/coreclr_delegates.h deleted file mode 100644 index dc146385848f5c634e7fd21be4cc5f53b9278c36..0000000000000000000000000000000000000000 --- a/Local/NosSmooth.Inject/coreclr_delegates.h +++ /dev/null @@ -1,47 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. - -#ifndef __CORECLR_DELEGATES_H__ -#define __CORECLR_DELEGATES_H__ - -#include - -#if defined(_WIN32) -#define CORECLR_DELEGATE_CALLTYPE __stdcall -#ifdef _WCHAR_T_DEFINED -typedef wchar_t char_t; -#else -typedef unsigned short char_t; -#endif -#else -#define CORECLR_DELEGATE_CALLTYPE -typedef char char_t; -#endif - -#define UNMANAGEDCALLERSONLY_METHOD ((const char_t*)-1) - -// Signature of delegate returned by coreclr_delegate_type::load_assembly_and_get_function_pointer -typedef int (CORECLR_DELEGATE_CALLTYPE* load_assembly_and_get_function_pointer_fn)( - const char_t* assembly_path /* Fully qualified path to assembly */, - const char_t* type_name /* Assembly qualified type name */, - const char_t* method_name /* Public static method name compatible with delegateType */, - const char_t* delegate_type_name /* Assembly qualified delegate type name or null - or UNMANAGEDCALLERSONLY_METHOD if the method is marked with - the UnmanagedCallersOnlyAttribute. */, - void* reserved /* Extensibility parameter (currently unused and must be 0) */, - /*out*/ void** delegate /* Pointer where to store the function pointer result */); - -// Signature of delegate returned by load_assembly_and_get_function_pointer_fn when delegate_type_name == null (default) -typedef int (CORECLR_DELEGATE_CALLTYPE* component_entry_point_fn)(void* arg, int32_t arg_size_in_bytes); - -typedef int (CORECLR_DELEGATE_CALLTYPE* get_function_pointer_fn)( - const char_t* type_name /* Assembly qualified type name */, - const char_t* method_name /* Public static method name compatible with delegateType */, - const char_t* delegate_type_name /* Assembly qualified delegate type name or null, - or UNMANAGEDCALLERSONLY_METHOD if the method is marked with - the UnmanagedCallersOnlyAttribute. */, - void* load_context /* Extensibility parameter (currently unused and must be 0) */, - void* reserved /* Extensibility parameter (currently unused and must be 0) */, - /*out*/ void** delegate /* Pointer where to store the function pointer result */); - -#endif // __CORECLR_DELEGATES_H__ \ No newline at end of file diff --git a/Local/NosSmooth.Inject/dllmain.cpp b/Local/NosSmooth.Inject/dllmain.cpp deleted file mode 100644 index 52d4ad2fdd1cd9338e5e87f0edfcb8a03b2a9da0..0000000000000000000000000000000000000000 --- a/Local/NosSmooth.Inject/dllmain.cpp +++ /dev/null @@ -1,19 +0,0 @@ -// dllmain.cpp : Defines the entry point for the DLL application. -#include - -BOOL APIENTRY DllMain( HMODULE hModule, - DWORD ul_reason_for_call, - LPVOID lpReserved - ) -{ - switch (ul_reason_for_call) - { - case DLL_PROCESS_ATTACH: - case DLL_THREAD_ATTACH: - case DLL_THREAD_DETACH: - case DLL_PROCESS_DETACH: - break; - } - return TRUE; -} - diff --git a/Local/NosSmooth.Inject/framework.h b/Local/NosSmooth.Inject/framework.h deleted file mode 100644 index 54b83e94fd330dce07fdad560a0101140e0989a3..0000000000000000000000000000000000000000 --- a/Local/NosSmooth.Inject/framework.h +++ /dev/null @@ -1,5 +0,0 @@ -#pragma once - -#define WIN32_LEAN_AND_MEAN // Exclude rarely-used stuff from Windows headers -// Windows Header Files -#include diff --git a/Local/NosSmooth.Inject/hostfxr.h b/Local/NosSmooth.Inject/hostfxr.h deleted file mode 100644 index 232da033976dda498cc8c85c9cc598a2bd3fd782..0000000000000000000000000000000000000000 --- a/Local/NosSmooth.Inject/hostfxr.h +++ /dev/null @@ -1,323 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. - -#ifndef __HOSTFXR_H__ -#define __HOSTFXR_H__ - -#include -#include - -#if defined(_WIN32) -#define HOSTFXR_CALLTYPE __cdecl -#ifdef _WCHAR_T_DEFINED -typedef wchar_t char_t; -#else -typedef unsigned short char_t; -#endif -#else -#define HOSTFXR_CALLTYPE -typedef char char_t; -#endif - -enum hostfxr_delegate_type -{ - hdt_com_activation, - hdt_load_in_memory_assembly, - hdt_winrt_activation, - hdt_com_register, - hdt_com_unregister, - hdt_load_assembly_and_get_function_pointer, - hdt_get_function_pointer, -}; - -typedef int32_t(HOSTFXR_CALLTYPE* hostfxr_main_fn)(const int argc, const char_t** argv); -typedef int32_t(HOSTFXR_CALLTYPE* hostfxr_main_startupinfo_fn)( - const int argc, - const char_t** argv, - const char_t* host_path, - const char_t* dotnet_root, - const char_t* app_path); -typedef int32_t(HOSTFXR_CALLTYPE* hostfxr_main_bundle_startupinfo_fn)( - const int argc, - const char_t** argv, - const char_t* host_path, - const char_t* dotnet_root, - const char_t* app_path, - int64_t bundle_header_offset); - -typedef void(HOSTFXR_CALLTYPE* hostfxr_error_writer_fn)(const char_t* message); - -// -// Sets a callback which is to be used to write errors to. -// -// Parameters: -// error_writer -// A callback function which will be invoked every time an error is to be reported. -// Or nullptr to unregister previously registered callback and return to the default behavior. -// Return value: -// The previously registered callback (which is now unregistered), or nullptr if no previous callback -// was registered -// -// The error writer is registered per-thread, so the registration is thread-local. On each thread -// only one callback can be registered. Subsequent registrations overwrite the previous ones. -// -// By default no callback is registered in which case the errors are written to stderr. -// -// Each call to the error writer is sort of like writing a single line (the EOL character is omitted). -// Multiple calls to the error writer may occure for one failure. -// -// If the hostfxr invokes functions in hostpolicy as part of its operation, the error writer -// will be propagated to hostpolicy for the duration of the call. This means that errors from -// both hostfxr and hostpolicy will be reporter through the same error writer. -// -typedef hostfxr_error_writer_fn(HOSTFXR_CALLTYPE* hostfxr_set_error_writer_fn)(hostfxr_error_writer_fn error_writer); - -typedef void* hostfxr_handle; -struct hostfxr_initialize_parameters -{ - size_t size; - const char_t* host_path; - const char_t* dotnet_root; -}; - -// -// Initializes the hosting components for a dotnet command line running an application -// -// Parameters: -// argc -// Number of argv arguments -// argv -// Command-line arguments for running an application (as if through the dotnet executable). -// Only command-line arguments which are accepted by runtime installation are supported, SDK/CLI commands are not supported. -// For example 'app.dll app_argument_1 app_argument_2`. -// parameters -// Optional. Additional parameters for initialization -// host_context_handle -// On success, this will be populated with an opaque value representing the initialized host context -// -// Return value: -// Success - Hosting components were successfully initialized -// HostInvalidState - Hosting components are already initialized -// -// This function parses the specified command-line arguments to determine the application to run. It will -// then find the corresponding .runtimeconfig.json and .deps.json with which to resolve frameworks and -// dependencies and prepare everything needed to load the runtime. -// -// This function only supports arguments for running an application. It does not support SDK commands. -// -// This function does not load the runtime. -// -typedef int32_t(HOSTFXR_CALLTYPE* hostfxr_initialize_for_dotnet_command_line_fn)( - int argc, - const char_t** argv, - const struct hostfxr_initialize_parameters* parameters, - /*out*/ hostfxr_handle* host_context_handle); - -// -// Initializes the hosting components using a .runtimeconfig.json file -// -// Parameters: -// runtime_config_path -// Path to the .runtimeconfig.json file -// parameters -// Optional. Additional parameters for initialization -// host_context_handle -// On success, this will be populated with an opaque value representing the initialized host context -// -// Return value: -// Success - Hosting components were successfully initialized -// Success_HostAlreadyInitialized - Config is compatible with already initialized hosting components -// Success_DifferentRuntimeProperties - Config has runtime properties that differ from already initialized hosting components -// CoreHostIncompatibleConfig - Config is incompatible with already initialized hosting components -// -// This function will process the .runtimeconfig.json to resolve frameworks and prepare everything needed -// to load the runtime. It will only process the .deps.json from frameworks (not any app/component that -// may be next to the .runtimeconfig.json). -// -// This function does not load the runtime. -// -// If called when the runtime has already been loaded, this function will check if the specified runtime -// config is compatible with the existing runtime. -// -// Both Success_HostAlreadyInitialized and Success_DifferentRuntimeProperties codes are considered successful -// initializations. In the case of Success_DifferentRuntimeProperties, it is left to the consumer to verify that -// the difference in properties is acceptable. -// -typedef int32_t(HOSTFXR_CALLTYPE* hostfxr_initialize_for_runtime_config_fn)( - const char_t* runtime_config_path, - const struct hostfxr_initialize_parameters* parameters, - /*out*/ hostfxr_handle* host_context_handle); - -// -// Gets the runtime property value for an initialized host context -// -// Parameters: -// host_context_handle -// Handle to the initialized host context -// name -// Runtime property name -// value -// Out parameter. Pointer to a buffer with the property value. -// -// Return value: -// The error code result. -// -// The buffer pointed to by value is owned by the host context. The lifetime of the buffer is only -// guaranteed until any of the below occur: -// - a 'run' method is called for the host context -// - properties are changed via hostfxr_set_runtime_property_value -// - the host context is closed via 'hostfxr_close' -// -// If host_context_handle is nullptr and an active host context exists, this function will get the -// property value for the active host context. -// -typedef int32_t(HOSTFXR_CALLTYPE* hostfxr_get_runtime_property_value_fn)( - const hostfxr_handle host_context_handle, - const char_t* name, - /*out*/ const char_t** value); - -// -// Sets the value of a runtime property for an initialized host context -// -// Parameters: -// host_context_handle -// Handle to the initialized host context -// name -// Runtime property name -// value -// Value to set -// -// Return value: -// The error code result. -// -// Setting properties is only supported for the first host context, before the runtime has been loaded. -// -// If the property already exists in the host context, it will be overwritten. If value is nullptr, the -// property will be removed. -// -typedef int32_t(HOSTFXR_CALLTYPE* hostfxr_set_runtime_property_value_fn)( - const hostfxr_handle host_context_handle, - const char_t* name, - const char_t* value); - -// -// Gets all the runtime properties for an initialized host context -// -// Parameters: -// host_context_handle -// Handle to the initialized host context -// count -// [in] Size of the keys and values buffers -// [out] Number of properties returned (size of keys/values buffers used). If the input value is too -// small or keys/values is nullptr, this is populated with the number of available properties -// keys -// Array of pointers to buffers with runtime property keys -// values -// Array of pointers to buffers with runtime property values -// -// Return value: -// The error code result. -// -// The buffers pointed to by keys and values are owned by the host context. The lifetime of the buffers is only -// guaranteed until any of the below occur: -// - a 'run' method is called for the host context -// - properties are changed via hostfxr_set_runtime_property_value -// - the host context is closed via 'hostfxr_close' -// -// If host_context_handle is nullptr and an active host context exists, this function will get the -// properties for the active host context. -// -typedef int32_t(HOSTFXR_CALLTYPE* hostfxr_get_runtime_properties_fn)( - const hostfxr_handle host_context_handle, - /*inout*/ size_t* count, - /*out*/ const char_t** keys, - /*out*/ const char_t** values); - -// -// Load CoreCLR and run the application for an initialized host context -// -// Parameters: -// host_context_handle -// Handle to the initialized host context -// -// Return value: -// If the app was successfully run, the exit code of the application. Otherwise, the error code result. -// -// The host_context_handle must have been initialized using hostfxr_initialize_for_dotnet_command_line. -// -// This function will not return until the managed application exits. -// -typedef int32_t(HOSTFXR_CALLTYPE* hostfxr_run_app_fn)(const hostfxr_handle host_context_handle); - -// -// Gets a typed delegate from the currently loaded CoreCLR or from a newly created one. -// -// Parameters: -// host_context_handle -// Handle to the initialized host context -// type -// Type of runtime delegate requested -// delegate -// An out parameter that will be assigned the delegate. -// -// Return value: -// The error code result. -// -// If the host_context_handle was initialized using hostfxr_initialize_for_runtime_config, -// then all delegate types are supported. -// If the host_context_handle was initialized using hostfxr_initialize_for_dotnet_command_line, -// then only the following delegate types are currently supported: -// hdt_load_assembly_and_get_function_pointer -// hdt_get_function_pointer -// -typedef int32_t(HOSTFXR_CALLTYPE* hostfxr_get_runtime_delegate_fn)( - const hostfxr_handle host_context_handle, - enum hostfxr_delegate_type type, - /*out*/ void** delegate); - -// -// Closes an initialized host context -// -// Parameters: -// host_context_handle -// Handle to the initialized host context -// -// Return value: -// The error code result. -// -typedef int32_t(HOSTFXR_CALLTYPE* hostfxr_close_fn)(const hostfxr_handle host_context_handle); - -struct hostfxr_dotnet_environment_sdk_info -{ - size_t size; - const char_t* version; - const char_t* path; -}; - -typedef void(HOSTFXR_CALLTYPE* hostfxr_get_dotnet_environment_info_result_fn)( - const struct hostfxr_dotnet_environment_info* info, - void* result_context); - -struct hostfxr_dotnet_environment_framework_info -{ - size_t size; - const char_t* name; - const char_t* version; - const char_t* path; -}; - -struct hostfxr_dotnet_environment_info -{ - size_t size; - - const char_t* hostfxr_version; - const char_t* hostfxr_commit_hash; - - size_t sdk_count; - const hostfxr_dotnet_environment_sdk_info* sdks; - - size_t framework_count; - const hostfxr_dotnet_environment_framework_info* frameworks; -}; - -#endif //__HOSTFXR_H__ \ No newline at end of file diff --git a/Local/NosSmooth.Inject/nethost.h b/Local/NosSmooth.Inject/nethost.h deleted file mode 100644 index 52c5635ee0ba7cd856c8e03ae0e335e5f81912ef..0000000000000000000000000000000000000000 --- a/Local/NosSmooth.Inject/nethost.h +++ /dev/null @@ -1,94 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -#ifndef __NETHOST_H__ -#define __NETHOST_H__ - -#include - -#if defined(_WIN32) -#ifdef NETHOST_EXPORT -#define NETHOST_API __declspec(dllexport) -#else -#define NETHOST_API __declspec(dllimport) -#endif - -#define NETHOST_CALLTYPE __stdcall -#ifdef _WCHAR_T_DEFINED -typedef wchar_t char_t; -#else -typedef unsigned short char_t; -#endif -#else -#ifdef NETHOST_EXPORT -#define NETHOST_API __attribute__((__visibility__("default"))) -#else -#define NETHOST_API -#endif - -#define NETHOST_CALLTYPE -typedef char char_t; -#endif - -#ifdef __cplusplus -extern "C" { -#endif - - // Parameters for get_hostfxr_path - // - // Fields: - // size - // Size of the struct. This is used for versioning. - // - // assembly_path - // Path to the compenent's assembly. - // If specified, hostfxr is located as if the assembly_path is the apphost - // - // dotnet_root - // Path to directory containing the dotnet executable. - // If specified, hostfxr is located as if an application is started using - // 'dotnet app.dll', which means it will be searched for under the dotnet_root - // path and the assembly_path is ignored. - // - struct get_hostfxr_parameters { - size_t size; - const char_t* assembly_path; - const char_t* dotnet_root; - }; - - // - // Get the path to the hostfxr library - // - // Parameters: - // buffer - // Buffer that will be populated with the hostfxr path, including a null terminator. - // - // buffer_size - // [in] Size of buffer in char_t units. - // [out] Size of buffer used in char_t units. If the input value is too small - // or buffer is nullptr, this is populated with the minimum required size - // in char_t units for a buffer to hold the hostfxr path - // - // get_hostfxr_parameters - // Optional. Parameters that modify the behaviour for locating the hostfxr library. - // If nullptr, hostfxr is located using the enviroment variable or global registration - // - // Return value: - // 0 on success, otherwise failure - // 0x80008098 - buffer is too small (HostApiBufferTooSmall) - // - // Remarks: - // The full search for the hostfxr library is done on every call. To minimize the need - // to call this function multiple times, pass a large buffer (e.g. PATH_MAX). - // - NETHOST_API int NETHOST_CALLTYPE get_hostfxr_path( - char_t* buffer, - size_t* buffer_size, - const struct get_hostfxr_parameters* parameters); - -#ifdef __cplusplus -} // extern "C" -#endif - -#endif // __NETHOST_H__ diff --git a/Local/NosSmooth.Inject/nossmooth.cpp b/Local/NosSmooth.Inject/nossmooth.cpp deleted file mode 100644 index b5254baada9671eed68afa0ed486cd59912d61e2..0000000000000000000000000000000000000000 --- a/Local/NosSmooth.Inject/nossmooth.cpp +++ /dev/null @@ -1,125 +0,0 @@ -#include "nossmooth.h" - -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -// Standard headers -#include -#include -#include -#include -#include -#include -#include "nethost.h" -#include "coreclr_delegates.h" -#include "hostfxr.h" - -#include - -#define STR(s) L ## s -#define CH(c) L ## c -#define DIR_SEPARATOR L'\\' - -using string_t = std::basic_string; - -// Globals to hold hostfxr exports -hostfxr_initialize_for_runtime_config_fn init_fptr; -hostfxr_get_runtime_delegate_fn get_delegate_fptr; -hostfxr_close_fn close_fptr; - -// Forward declarations -bool load_hostfxr(); -load_assembly_and_get_function_pointer_fn get_dotnet_load_assembly(const char_t* assembly); - -/******************************************************************************************** - * Function used to load and activate .NET Core - ********************************************************************************************/ - - // Forward declarations -void* load_library(const char_t*); -void* get_export(void*, const char*); - -void* load_library(const char_t* path) -{ - HMODULE h = ::LoadLibraryW(path); - assert(h != nullptr); - return (void*)h; -} -void* get_export(void* h, const char* name) -{ - void* f = ::GetProcAddress((HMODULE)h, name); - assert(f != nullptr); - return f; -} - -// Using the nethost library, discover the location of hostfxr and get exports -bool load_hostfxr() -{ - // Pre-allocate a large buffer for the path to hostfxr - char_t buffer[MAX_PATH]; - size_t buffer_size = sizeof(buffer) / sizeof(char_t); - int rc = get_hostfxr_path(buffer, &buffer_size, nullptr); - if (rc != 0) - return false; - - // Load hostfxr and get desired exports - void* lib = load_library(buffer); - init_fptr = (hostfxr_initialize_for_runtime_config_fn)get_export(lib, "hostfxr_initialize_for_runtime_config"); - get_delegate_fptr = (hostfxr_get_runtime_delegate_fn)get_export(lib, "hostfxr_get_runtime_delegate"); - close_fptr = (hostfxr_close_fn)get_export(lib, "hostfxr_close"); - - return (init_fptr && get_delegate_fptr && close_fptr); -} - -// Load and initialize .NET Core and get desired function pointer for scenario -load_assembly_and_get_function_pointer_fn get_dotnet_load_assembly(const char_t* config_path) -{ - // Load .NET Core - void* load_assembly_and_get_function_pointer = nullptr; - hostfxr_handle cxt = nullptr; - int rc = init_fptr(config_path, nullptr, &cxt); - if (rc != 0 || cxt == nullptr) - { - std::cerr << "Init failed: " << std::hex << std::showbase << rc << std::endl; - close_fptr(cxt); - return nullptr; - } - - // Get the load assembly function pointer - rc = get_delegate_fptr( - cxt, - hdt_load_assembly_and_get_function_pointer, - &load_assembly_and_get_function_pointer); - if (rc != 0 || load_assembly_and_get_function_pointer == nullptr) - std::cerr << "Get delegate failed: " << std::hex << std::showbase << rc << std::endl; - - close_fptr(cxt); - return (load_assembly_and_get_function_pointer_fn)load_assembly_and_get_function_pointer; -} - -bool LoadAndCallMethod(LoadParams* params) -{ - if (!load_hostfxr()) - { - assert(false && "Failure: load_hostfxr()"); - return false; - } - - load_assembly_and_get_function_pointer_fn load_assembly_and_get_function_pointer = nullptr; - load_assembly_and_get_function_pointer = get_dotnet_load_assembly(params->runtimeConfigPath); - assert(load_assembly_and_get_function_pointer != nullptr && "Failure: get_dotnet_load_assembly()"); - - typedef void (CORECLR_DELEGATE_CALLTYPE* main_entry_point_fn)(); - main_entry_point_fn main = nullptr; - int rc = load_assembly_and_get_function_pointer( - params->libraryPath, - params->typePath, - params->methodName, - UNMANAGEDCALLERSONLY_METHOD, - nullptr, - (void**)&main); - assert(rc == 0 && main != nullptr && "Failure: load_assembly_and_get_function_pointer()"); - main(); - return true; -} \ No newline at end of file diff --git a/Local/NosSmooth.Inject/nossmooth.h b/Local/NosSmooth.Inject/nossmooth.h deleted file mode 100644 index 55f846197658089f4538694f9c6df460cafe6137..0000000000000000000000000000000000000000 --- a/Local/NosSmooth.Inject/nossmooth.h +++ /dev/null @@ -1,15 +0,0 @@ -#pragma once -#include - -#pragma pack(push, 1) -struct LoadParams -{ - wchar_t *libraryPath; - wchar_t *runtimeConfigPath; - wchar_t *typePath; - wchar_t *methodName; -}; -#pragma pack(pop) -#define DllExport extern "C" __declspec( dllexport ) - -DllExport bool LoadAndCallMethod(LoadParams* params); \ No newline at end of file diff --git a/Local/NosSmooth.Inject/pch.cpp b/Local/NosSmooth.Inject/pch.cpp deleted file mode 100644 index 64b7eef6d6b9aa96524c78e21aab9e3e6cde71d0..0000000000000000000000000000000000000000 --- a/Local/NosSmooth.Inject/pch.cpp +++ /dev/null @@ -1,5 +0,0 @@ -// pch.cpp: source file corresponding to the pre-compiled header - -#include "pch.h" - -// When you are using pre-compiled headers, this source file is necessary for compilation to succeed. diff --git a/Local/NosSmooth.Inject/pch.h b/Local/NosSmooth.Inject/pch.h deleted file mode 100644 index 885d5d62e48eed596a0c367a75461043c638dca3..0000000000000000000000000000000000000000 --- a/Local/NosSmooth.Inject/pch.h +++ /dev/null @@ -1,13 +0,0 @@ -// pch.h: This is a precompiled header file. -// Files listed below are compiled only once, improving build performance for future builds. -// This also affects IntelliSense performance, including code completion and many code browsing features. -// However, files listed here are ALL re-compiled if any one of them is updated between builds. -// Do not add files here that you will be updating frequently as this negates the performance advantage. - -#ifndef PCH_H -#define PCH_H - -// add headers that you want to pre-compile here -#include "framework.h" - -#endif //PCH_H diff --git a/Local/NosSmooth.Injector.CLI/Commands/InjectCommand.cs b/Local/NosSmooth.Injector.CLI/Commands/InjectCommand.cs deleted file mode 100644 index 03f6b9966cd1eff4bfa44c38ce9ac133ae927658..0000000000000000000000000000000000000000 --- a/Local/NosSmooth.Injector.CLI/Commands/InjectCommand.cs +++ /dev/null @@ -1,68 +0,0 @@ -// -// InjectCommand.cs -// -// Copyright (c) František Boháček. All rights reserved. -// Licensed under the MIT license. See LICENSE file in the project root for full license information. - -using System.ComponentModel; -using System.Diagnostics; -using Remora.Commands.Attributes; -using Remora.Commands.Groups; -using Remora.Results; - -namespace NosSmooth.Injector.CLI.Commands -{ - /// - /// Injection command for injecting .NET 5+ libraries with UnmanagedCallersOnly method. - /// - internal class InjectCommand : CommandGroup - { - private readonly NosInjector _injector; - - /// - /// Initializes a new instance of the class. - /// - /// The nos smooth injector. - public InjectCommand(NosInjector injector) - { - _injector = injector; - } - - /// - /// The command to inject. - /// - /// The id of the process or part of its name. - /// The path to the dll to inject. - /// The full type specifier. Default is LibraryName.DllMain, LibraryName. - /// The name of the UnmanagedCallersOnly method. Default is Main. - /// A result that may or may not have succeeded. - [Command("inject")] - public Task Inject - ( - [Description("The id of the process to inject into.")] - string process, - [Description("The path to the dll to inject.")] - string dllPath, - [Option('t', "type"), Description("The full type specifier. Default is LibraryName.DllMain, LibraryName")] - string? typeName = null, - [Option('m', "method"), Description("The name of the UnmanagedCallersOnly method. Default is Main")] - string? methodName = null - ) - { - if (!int.TryParse(process, out var processId)) - { - var foundProcess = Process.GetProcesses().FirstOrDefault(x => x.ProcessName.Contains(process, StringComparison.OrdinalIgnoreCase)); - if (foundProcess is null) - { - return Task.FromResult(Result.FromError(new NotFoundError("Could not find the given process."))); - } - - processId = foundProcess.Id; - } - - var dllName = Path.GetFileNameWithoutExtension(dllPath); - return Task.FromResult - (_injector.Inject(processId, dllPath, $"{dllName}.DllMain, {dllName}", methodName ?? "Main")); - } - } -} \ No newline at end of file diff --git a/Local/NosSmooth.Injector.CLI/Commands/ListProcessesCommand.cs b/Local/NosSmooth.Injector.CLI/Commands/ListProcessesCommand.cs deleted file mode 100644 index 9f7315701b23d601da902f6ef6072a79cf2348d7..0000000000000000000000000000000000000000 --- a/Local/NosSmooth.Injector.CLI/Commands/ListProcessesCommand.cs +++ /dev/null @@ -1,41 +0,0 @@ -// -// ListProcessesCommand.cs -// -// Copyright (c) František Boháček. All rights reserved. -// Licensed under the MIT license. See LICENSE file in the project root for full license information. - -using System.Diagnostics; -using Remora.Commands.Attributes; -using Remora.Commands.Groups; -using Remora.Results; - -namespace NosSmooth.Injector.CLI.Commands -{ - /// - /// Command for listing processes to find id of NosTale process. - /// - internal class ListProcessesCommand : CommandGroup - { - /// - /// Lists processes by the given criteria. - /// - /// What should the name of the process contain. - /// A result that may or may not have succeeded. - [Command("list")] - public Task List(string nameContains = "Nostale") - { - var processes = Process.GetProcesses(); - foreach (var process in processes.Where(x => x.ProcessName.Contains(nameContains, StringComparison.OrdinalIgnoreCase))) - { - Console.WriteLine(ProcessToString(process)); - } - - return Task.FromResult(Result.FromSuccess()); - } - - private string ProcessToString(Process process) - { - return $"{process.ProcessName} - {process.Id}"; - } - } -} diff --git a/Local/NosSmooth.Injector.CLI/NosSmooth.Injector.CLI.csproj b/Local/NosSmooth.Injector.CLI/NosSmooth.Injector.CLI.csproj deleted file mode 100644 index 7ce67a960d22adc9e95f708e5dec0b4e132e552f..0000000000000000000000000000000000000000 --- a/Local/NosSmooth.Injector.CLI/NosSmooth.Injector.CLI.csproj +++ /dev/null @@ -1,28 +0,0 @@ - - - - Exe - net6.0 - enable - enable - app.manifest - - - - - - - - - - - - - - - - - - - - diff --git a/Local/NosSmooth.Injector.CLI/Program.cs b/Local/NosSmooth.Injector.CLI/Program.cs deleted file mode 100644 index 62c7d80826c578aa5de7154d579d670831f542ab..0000000000000000000000000000000000000000 --- a/Local/NosSmooth.Injector.CLI/Program.cs +++ /dev/null @@ -1,75 +0,0 @@ -// -// Program.cs -// -// Copyright (c) František Boháček. All rights reserved. -// Licensed under the MIT license. See LICENSE file in the project root for full license information. - -using Microsoft.Extensions.DependencyInjection; -using NosSmooth.Injector.CLI.Commands; -using Remora.Commands.Extensions; -using Remora.Commands.Services; -using Remora.Results; - -namespace NosSmooth.Injector.CLI -{ - /// - /// The entrypoint class. - /// - public static class Program - { - /// - /// The entrypoint method. - /// - /// The command line arguments. - /// A task that may or may not have succeeded. - public static async Task Main(string[] argv) - { - var services = CreateServices(); - var commandService = services.GetRequiredService(); - var preparedCommandResult = await commandService.TryPrepareCommandAsync(string.Join(' ', argv), services); - if (!preparedCommandResult.IsSuccess) - { - Console.Error.WriteLine($"There was an error, {preparedCommandResult.Error.Message}"); - return; - } - - if (preparedCommandResult.Entity is null) - { - Console.Error.WriteLine("You must enter a command such ast list or inject."); - return; - } - - var executionResult = await commandService.TryExecuteAsync(preparedCommandResult.Entity, services); - if (!executionResult.Entity.IsSuccess) - { - switch (executionResult.Entity.Error) - { - case ExceptionError exc: - Console.Error.WriteLine($"There was an exception, {exc.Exception.Message}"); - break; - default: - Console.Error.WriteLine($"There was an error, {executionResult.Entity.Error!.Message}"); - break; - } - - return; - } - } - - private static IServiceProvider CreateServices() - { - var collection = new ServiceCollection(); - collection - .AddSingleton() - .AddOptions(); - - collection - .AddCommands() - .AddCommandTree() - .WithCommandGroup() - .WithCommandGroup(); - - return collection.BuildServiceProvider(); - } - } -} diff --git a/Local/NosSmooth.Injector.CLI/app.manifest b/Local/NosSmooth.Injector.CLI/app.manifest deleted file mode 100644 index 26cb1ef138e1f6c624354b025086a68ceb4fec8d..0000000000000000000000000000000000000000 --- a/Local/NosSmooth.Injector.CLI/app.manifest +++ /dev/null @@ -1,11 +0,0 @@ - - - - - - - - - - - \ No newline at end of file diff --git a/Local/NosSmooth.Injector/Errors/InjectionFailedError.cs b/Local/NosSmooth.Injector/Errors/InjectionFailedError.cs deleted file mode 100644 index fed27cd356233e7fcd67d9782dbc537c004ef13d..0000000000000000000000000000000000000000 --- a/Local/NosSmooth.Injector/Errors/InjectionFailedError.cs +++ /dev/null @@ -1,15 +0,0 @@ -// -// InjectionFailedError.cs -// -// Copyright (c) František Boháček. All rights reserved. -// Licensed under the MIT license. See LICENSE file in the project root for full license information. - -using Remora.Results; - -namespace NosSmooth.Injector.Errors; - -/// -/// The injection could not be finished successfully. -/// -/// The path to the dll. -public record InjectionFailedError(string DllPath) : ResultError($"Could not inject {DllPath} dll into the process."); \ No newline at end of file diff --git a/Local/NosSmooth.Injector/Errors/InsufficientPermissionsError.cs b/Local/NosSmooth.Injector/Errors/InsufficientPermissionsError.cs deleted file mode 100644 index 92d6ee98278f11e93d20eba8afae21c00231ac5b..0000000000000000000000000000000000000000 --- a/Local/NosSmooth.Injector/Errors/InsufficientPermissionsError.cs +++ /dev/null @@ -1,20 +0,0 @@ -// -// InsufficientPermissionsError.cs -// -// Copyright (c) František Boháček. All rights reserved. -// Licensed under the MIT license. See LICENSE file in the project root for full license information. - -using Remora.Results; - -namespace NosSmooth.Injector.Errors; - -/// -/// The current user has insufficient permissions to inject into the given process. -/// -/// The id of the process. -/// The name of the process. -public record InsufficientPermissionsError(long ProcessId, string ProcessName) - : ResultError - ( - $"Insufficient permissions to open process {ProcessId} ({ProcessName}). Try running the injector as administrator." - ); \ No newline at end of file diff --git a/Local/NosSmooth.Injector/Errors/ProcessNotFoundError.cs b/Local/NosSmooth.Injector/Errors/ProcessNotFoundError.cs deleted file mode 100644 index b1c04b731e979fd147f68a1619630e93b4e60ac6..0000000000000000000000000000000000000000 --- a/Local/NosSmooth.Injector/Errors/ProcessNotFoundError.cs +++ /dev/null @@ -1,16 +0,0 @@ -// -// ProcessNotFoundError.cs -// -// Copyright (c) František Boháček. All rights reserved. -// Licensed under the MIT license. See LICENSE file in the project root for full license information. - -using Remora.Results; - -namespace NosSmooth.Injector.Errors; - -/// -/// The given process was not found. -/// -/// The id of the process. -public record ProcessNotFoundError(string ProcessId) - : NotFoundError($"Could not find process with the given id {ProcessId}."); \ No newline at end of file diff --git a/Local/NosSmooth.Injector/LoadParams.cs b/Local/NosSmooth.Injector/LoadParams.cs deleted file mode 100644 index e2496124469f15cf23f75e347e0aff9762de5eb7..0000000000000000000000000000000000000000 --- a/Local/NosSmooth.Injector/LoadParams.cs +++ /dev/null @@ -1,44 +0,0 @@ -// -// LoadParams.cs -// -// Copyright (c) František Boháček. All rights reserved. -// Licensed under the MIT license. See LICENSE file in the project root for full license information. - -using System; -using System.Collections.Generic; -using System.Linq; -using System.Runtime.InteropServices; -using System.Text; -using System.Threading.Tasks; - -namespace NosSmooth.Injector -{ - /// - /// The parameters passed to the inject module. - /// - internal struct LoadParams - { - /// - /// The full path of the library. - /// - public int LibraryPath; - - /// - /// The full path of the library. - /// - public int RuntimeConfigPath; - - /// - /// The full path to the type with the method marked as UnsafeCallersOnly. - /// - /// - /// Can be for example "LibraryNamespace.Type, LibraryNamespace". - /// - public int TypePath; - - /// - /// The name of the method to execute. - /// - public int MethodName; - } -} diff --git a/Local/NosSmooth.Injector/ManagedMemoryAllocation.cs b/Local/NosSmooth.Injector/ManagedMemoryAllocation.cs deleted file mode 100644 index 8d7308e076a5d3e6f218f11df9eacf258567729e..0000000000000000000000000000000000000000 --- a/Local/NosSmooth.Injector/ManagedMemoryAllocation.cs +++ /dev/null @@ -1,47 +0,0 @@ -// -// ManagedMemoryAllocation.cs -// -// Copyright (c) František Boháček. All rights reserved. -// Licensed under the MIT license. See LICENSE file in the project root for full license information. - -using System.Net.NetworkInformation; -using Reloaded.Memory.Sources; - -namespace NosSmooth.Injector; - -/// -/// Represents freeable memory allocation. -/// -internal class ManagedMemoryAllocation : IDisposable -{ - private readonly IMemory _memory; - - /// - /// Initializes a new instance of the class. - /// - /// The memory with allocation. - /// The pointer to allocated memory. - public ManagedMemoryAllocation(IMemory memory, IntPtr pointer) - { - Pointer = pointer; - _memory = memory; - - } - - /// - /// The allocated pointer number. - /// - public IntPtr Pointer { get; private set; } - - /// - /// Whether the memory is currently allocated. - /// - public bool Allocated => Pointer != IntPtr.Zero; - - /// - public void Dispose() - { - _memory.Free(Pointer); - Pointer = IntPtr.Zero; - } -} \ No newline at end of file diff --git a/Local/NosSmooth.Injector/NosInjector.cs b/Local/NosSmooth.Injector/NosInjector.cs deleted file mode 100644 index 2ee64ebf4012b2f22f7084c4bacd040bed1f1c38..0000000000000000000000000000000000000000 --- a/Local/NosSmooth.Injector/NosInjector.cs +++ /dev/null @@ -1,155 +0,0 @@ -// -// NosInjector.cs -// -// Copyright (c) František Boháček. All rights reserved. -// Licensed under the MIT license. See LICENSE file in the project root for full license information. - -using System.Diagnostics; -using System.Security; -using System.Text; -using Microsoft.Extensions.Options; -using NosSmooth.Injector.Errors; -using Reloaded.Memory.Sources; -using Remora.Results; - -namespace NosSmooth.Injector; - -/// -/// Nos smooth injector for .NET 5+ projects. -/// -/// -/// If you want to inject your project into NosTale that -/// uses NosSmooth.LocalClient, use this injector. -/// You must expose static UnmanagedCallersOnly method. -/// -public class NosInjector -{ - private readonly NosInjectorOptions _options; - - /// - /// Initializes a new instance of the class. - /// - /// The injector options. - public NosInjector(IOptions options) - { - _options = options.Value; - } - - /// - /// Inject the given .NET 5+ dll into NosTale process. - /// - /// - /// The dll must also have .runtimeconfig.json present next to the dll. - /// - /// The id of the process to inject to. - /// The absolute path to the dll to inject. - /// The full path to the class. Such as "MyLibrary.DllMain, MyLibrary". - /// The name of the method to execute. The method should return void and have no parameters. - /// A result that may or may not have succeeded. - public Result Inject - ( - int processId, - string dllPath, - string classPath, - string methodName = "Main" - ) - { - using var process = Process.GetProcessById(processId); - return Inject(process, dllPath, classPath, methodName); - } - - /// - /// Inject the given .NET 5+ dll into NosTale process. - /// - /// - /// The dll must also have .runtimeconfig.json present next to the dll. - /// - /// The process to inject to. - /// The absolute path to the dll to inject. - /// The full path to the class. Such as "MyLibrary.DllMain, MyLibrary". - /// The name of the method to execute. The method should return void and have no parameters. - /// A result that may or may not have succeeded. - public Result Inject - ( - Process process, - string dllPath, - string classPath, - string methodName = "Main" - ) - { - try - { - using var injector = new Reloaded.Injector.Injector(process); - var memory = new ExternalMemory(process); - - var directoryName = Path.GetDirectoryName(dllPath); - if (directoryName is null) - { - return new GenericError("There was an error obtaining directory name of the dll path."); - } - - var runtimePath = Path.Combine - (directoryName, Path.GetFileNameWithoutExtension(dllPath)) + ".runtimeconfig.json"; - - using var dllPathMemory = AllocateString(memory, dllPath); - using var classPathMemory = AllocateString(memory, classPath); - using var methodNameMemory = AllocateString(memory, methodName); - using var runtimePathMemory = AllocateString(memory, runtimePath); - - if (!dllPathMemory.Allocated || !classPathMemory.Allocated || !methodNameMemory.Allocated - || !runtimePathMemory.Allocated) - { - return new GenericError("Could not allocate memory in the external process."); - } - - var loadParams = new LoadParams() - { - LibraryPath = (int)dllPathMemory.Pointer, - MethodName = (int)methodNameMemory.Pointer, - RuntimeConfigPath = (int)runtimePathMemory.Pointer, - TypePath = (int)classPathMemory.Pointer - }; - - var nosSmoothInjectPath = Path.GetFullPath(_options.NosSmoothInjectPath); - var injected = injector.Inject(nosSmoothInjectPath); - if (injected == 0) - { - return new InjectionFailedError(nosSmoothInjectPath); - } - - var functionResult = injector.CallFunction(nosSmoothInjectPath, "LoadAndCallMethod", loadParams); - if (functionResult != 0) - { - return new InjectionFailedError(dllPath); - } - - return Result.FromSuccess(); - } - catch (UnauthorizedAccessException) - { - return new InsufficientPermissionsError(process.Id, process.ProcessName); - } - catch (SecurityException) - { - return new InsufficientPermissionsError(process.Id, process.ProcessName); - } - catch (Exception e) - { - return e; - } - } - - private ManagedMemoryAllocation AllocateString(IMemory memory, string str) - { - var bytes = Encoding.Unicode.GetBytes(str); - var allocated = memory.Allocate(bytes.Length + 1); - if (allocated == IntPtr.Zero) - { - return new ManagedMemoryAllocation(memory, allocated); - } - - memory.SafeWriteRaw(allocated + bytes.Length, new byte[] { 0 }); - memory.SafeWriteRaw(allocated, bytes); - return new ManagedMemoryAllocation(memory, allocated); - } -} \ No newline at end of file diff --git a/Local/NosSmooth.Injector/NosInjectorOptions.cs b/Local/NosSmooth.Injector/NosInjectorOptions.cs deleted file mode 100644 index 234f6459ef8e59694ac8d14854b09f6266cdbb1a..0000000000000000000000000000000000000000 --- a/Local/NosSmooth.Injector/NosInjectorOptions.cs +++ /dev/null @@ -1,32 +0,0 @@ -// -// NosInjectorOptions.cs -// -// Copyright (c) František Boháček. All rights reserved. -// Licensed under the MIT license. See LICENSE file in the project root for full license information. - -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; -using Microsoft.Extensions.Options; - -namespace NosSmooth.Injector -{ - /// - /// Options for NosInjector. - /// - public class NosInjectorOptions : IOptions - { - /// - /// Gets or sets the path to the nos smooth inject dll. - /// - /// - /// If not absolute path, then relative path from the current executing process is assumed. - /// - public string NosSmoothInjectPath { get; set; } = "NosSmooth.Inject.dll"; - - /// - public NosInjectorOptions Value => this; - } -} diff --git a/Local/NosSmooth.Injector/NosSmooth.Injector.csproj b/Local/NosSmooth.Injector/NosSmooth.Injector.csproj deleted file mode 100644 index e2226997ae286c3c5ee749613d15666e8e385b13..0000000000000000000000000000000000000000 --- a/Local/NosSmooth.Injector/NosSmooth.Injector.csproj +++ /dev/null @@ -1,15 +0,0 @@ - - - - net6.0 - enable - enable - - - - - - - - - diff --git a/Local/NosSmooth.LocalBinding/Errors/BindingNotFoundError.cs b/Local/NosSmooth.LocalBinding/Errors/BindingNotFoundError.cs deleted file mode 100644 index 182db6d352be33fc56318f778b21c7b9f5328c0e..0000000000000000000000000000000000000000 --- a/Local/NosSmooth.LocalBinding/Errors/BindingNotFoundError.cs +++ /dev/null @@ -1,17 +0,0 @@ -// -// BindingNotFoundError.cs -// -// Copyright (c) František Boháček. All rights reserved. -// Licensed under the MIT license. See LICENSE file in the project root for full license information. - -using Remora.Results; - -namespace NosSmooth.LocalBinding.Errors; - -/// -/// The memory pattern was not found in the memory. -/// -/// The pattern that could not be found. -/// The entity the pattern should represent. -public record BindingNotFoundError(string Pattern, string Path) - : ResultError($"Could not find pattern ({Pattern}) in the memory while searching for {Path}."); diff --git a/Local/NosSmooth.LocalBinding/Errors/CouldNotInitializeModuleError.cs b/Local/NosSmooth.LocalBinding/Errors/CouldNotInitializeModuleError.cs deleted file mode 100644 index c63303aa4261998851f062015437d5ca7da697ca..0000000000000000000000000000000000000000 --- a/Local/NosSmooth.LocalBinding/Errors/CouldNotInitializeModuleError.cs +++ /dev/null @@ -1,17 +0,0 @@ -// -// CouldNotInitializeModuleError.cs -// -// Copyright (c) František Boháček. All rights reserved. -// Licensed under the MIT license. See LICENSE file in the project root for full license information. - -using Remora.Results; - -namespace NosSmooth.LocalBinding.Errors; - -/// -/// Could not initialize the given NosTale module. -/// -/// The module type that could not be initialized. -/// The error why the module could not be initialized. -public record CouldNotInitializeModuleError - (Type Module, IResultError UnderlyingError) : ResultError($"Could initialize a nostale module {Module.FullName}."); \ No newline at end of file diff --git a/Local/NosSmooth.LocalBinding/Errors/NotNostaleProcessError.cs b/Local/NosSmooth.LocalBinding/Errors/NotNostaleProcessError.cs deleted file mode 100644 index 9227b9240f0bd6b10de876a3f5ca5a8161342f29..0000000000000000000000000000000000000000 --- a/Local/NosSmooth.LocalBinding/Errors/NotNostaleProcessError.cs +++ /dev/null @@ -1,17 +0,0 @@ -// -// NotNostaleProcessError.cs -// -// Copyright (c) František Boháček. All rights reserved. -// Licensed under the MIT license. See LICENSE file in the project root for full license information. - -using System.Diagnostics; -using Remora.Results; - -namespace NosSmooth.LocalBinding.Errors; - -/// -/// The process you tried to browse is not a nostale process. -/// -/// -public record NotNostaleProcessError(Process process) : ResultError - ($"The process {process.ProcessName} ({process.Id} is not a NosTale process."); \ No newline at end of file diff --git a/Local/NosSmooth.LocalBinding/Extensions/MemoryExtensions.cs b/Local/NosSmooth.LocalBinding/Extensions/MemoryExtensions.cs deleted file mode 100644 index c367ed277fb1cda3f6eb8ca860631f3930780f9d..0000000000000000000000000000000000000000 --- a/Local/NosSmooth.LocalBinding/Extensions/MemoryExtensions.cs +++ /dev/null @@ -1,33 +0,0 @@ -// -// MemoryExtensions.cs -// -// Copyright (c) František Boháček. All rights reserved. -// Licensed under the MIT license. See LICENSE file in the project root for full license information. - -using Reloaded.Memory.Sources; - -namespace NosSmooth.LocalBinding.Extensions; - -/// -/// Extension methods for . -/// -public static class MemoryExtensions -{ - /// - /// Follows the offsets to a 32-bit pointer. - /// - /// The memory. - /// The static address to follow offsets from. - /// The offsets, first offset is the 0-th element. - /// A final address. - public static IntPtr FollowStaticAddressOffsets(this IMemory memory, int staticAddress, int[] offsets) - { - int address = staticAddress; - foreach (var offset in offsets) - { - memory.SafeRead((IntPtr)(address + offset), out address); - } - - return (IntPtr)address; - } -} \ No newline at end of file diff --git a/Local/NosSmooth.LocalBinding/Extensions/ServiceCollectionExtensions.cs b/Local/NosSmooth.LocalBinding/Extensions/ServiceCollectionExtensions.cs deleted file mode 100644 index 21383f6ec2cb0eb0888246c8890ad1316bb61fde..0000000000000000000000000000000000000000 --- a/Local/NosSmooth.LocalBinding/Extensions/ServiceCollectionExtensions.cs +++ /dev/null @@ -1,44 +0,0 @@ -// -// ServiceCollectionExtensions.cs -// -// Copyright (c) František Boháček. All rights reserved. -// Licensed under the MIT license. See LICENSE file in the project root for full license information. - -using Microsoft.Extensions.DependencyInjection; -using NosSmooth.LocalBinding.Objects; -using NosSmooth.LocalBinding.Structs; - -namespace NosSmooth.LocalBinding.Extensions; - -/// -/// Contains extension methods for . -/// -public static class ServiceCollectionExtensions -{ - /// - /// Adds bindings to Nostale objects along with to initialize those. - /// - /// - /// Adds and . - /// You have to initialize these using - /// prior to requesting them from the provider, otherwise an exception - /// will be thrown. - /// - /// The service collection. - /// The collection. - public static IServiceCollection AddNostaleBindings(this IServiceCollection serviceCollection) - { - return serviceCollection - .AddSingleton() - .AddSingleton() - .AddSingleton(p => p.GetRequiredService().PlayerManager) - .AddSingleton(p => p.GetRequiredService().SceneManager) - .AddSingleton(p => p.GetRequiredService().PetManagerList) - .AddSingleton(p => p.GetRequiredService().SceneManager) - .AddSingleton(p => p.GetRequiredService().PetManagerList) - .AddSingleton(p => p.GetRequiredService().PlayerManager) - .AddSingleton(p => p.GetRequiredService().PetManager) - .AddSingleton(p => p.GetRequiredService().UnitManager) - .AddSingleton(p => p.GetRequiredService().Network); - } -} \ No newline at end of file diff --git a/Local/NosSmooth.LocalBinding/IsExternalInit.cs b/Local/NosSmooth.LocalBinding/IsExternalInit.cs deleted file mode 100644 index 7c63200cfae2cfd2a9607d18344f77c095a28e9d..0000000000000000000000000000000000000000 --- a/Local/NosSmooth.LocalBinding/IsExternalInit.cs +++ /dev/null @@ -1,15 +0,0 @@ -// -// IsExternalInit.cs -// -// Copyright (c) František Boháček. All rights reserved. -// Licensed under the MIT license. See LICENSE file in the project root for full license information. - -namespace System.Runtime.CompilerServices -{ - /// - /// Dummy. - /// - public class IsExternalInit - { - } -} \ No newline at end of file diff --git a/Local/NosSmooth.LocalBinding/NosBindingManager.cs b/Local/NosSmooth.LocalBinding/NosBindingManager.cs deleted file mode 100644 index c4923c53ae83988674f0e8f3d88c9b310f3a4d6b..0000000000000000000000000000000000000000 --- a/Local/NosSmooth.LocalBinding/NosBindingManager.cs +++ /dev/null @@ -1,375 +0,0 @@ -// -// NosBindingManager.cs -// -// Copyright (c) František Boháček. All rights reserved. -// Licensed under the MIT license. See LICENSE file in the project root for full license information. - -using System.Diagnostics; -using Microsoft.Extensions.Options; -using NosSmooth.LocalBinding.Errors; -using NosSmooth.LocalBinding.Objects; -using NosSmooth.LocalBinding.Options; -using Reloaded.Hooks; -using Reloaded.Hooks.Definitions; -using Reloaded.Memory.Sigscan; -using Reloaded.Memory.Sources; -using Remora.Results; - -namespace NosSmooth.LocalBinding; - -/// -/// Nostale entity binding manager. -/// -public class NosBindingManager : IDisposable -{ - private readonly NosBrowserManager _browserManager; - private readonly PetManagerBindingOptions _petManagerBindingOptions; - private readonly CharacterBindingOptions _characterBindingOptions; - private readonly NetworkBindingOptions _networkBindingOptions; - private UnitManagerBindingOptions _unitManagerBindingOptions; - - private NetworkBinding? _networkBinding; - private PlayerManagerBinding? _characterBinding; - private UnitManagerBinding? _unitManagerBinding; - private PetManagerBinding? _petManagerBinding; - - /// - /// Initializes a new instance of the class. - /// - /// The NosTale browser manager. - /// The character binding options. - /// The network binding options. - /// The scene manager binding options. - /// The pet manager binding options. - public NosBindingManager - ( - NosBrowserManager browserManager, - IOptions characterBindingOptions, - IOptions networkBindingOptions, - IOptions sceneManagerBindingOptions, - IOptions petManagerBindingOptions - ) - { - _browserManager = browserManager; - Hooks = new ReloadedHooks(); - Memory = new Memory(); - Scanner = new Scanner(Process.GetCurrentProcess(), Process.GetCurrentProcess().MainModule); - _characterBindingOptions = characterBindingOptions.Value; - _networkBindingOptions = networkBindingOptions.Value; - _unitManagerBindingOptions = sceneManagerBindingOptions.Value; - _petManagerBindingOptions = petManagerBindingOptions.Value; - } - - /// - /// Gets the memory scanner. - /// - internal Scanner Scanner { get; } - - /// - /// Gets the reloaded hooks. - /// - internal IReloadedHooks Hooks { get; } - - /// - /// Gets the current process memory. - /// - internal IMemory Memory { get; } - - /// - /// Gets the network binding. - /// - /// Thrown if the manager is not initialized yet. - public NetworkBinding Network - { - get - { - if (_networkBinding is null) - { - throw new InvalidOperationException - ( - "Could not get network. The binding manager is not initialized. Did you forget to call NosBindingManager.Initialize?" - ); - } - - return _networkBinding; - } - } - - /// - /// Gets the character binding. - /// - /// Thrown if the manager is not initialized yet. - public PlayerManagerBinding PlayerManager - { - get - { - if (_characterBinding is null) - { - throw new InvalidOperationException - ( - "Could not get character. The binding manager is not initialized. Did you forget to call NosBindingManager.Initialize?" - ); - } - - return _characterBinding; - } - } - - /// - /// Gets the character binding. - /// - /// Thrown if the manager is not initialized yet. - public UnitManagerBinding UnitManager - { - get - { - if (_unitManagerBinding is null) - { - throw new InvalidOperationException - ( - "Could not get scene manager. The binding manager is not initialized. Did you forget to call NosBindingManager.Initialize?" - ); - } - - return _unitManagerBinding; - } - } - - /// - /// Gets the pet manager binding. - /// - /// Thrown if the manager is not initialized yet. - public PetManagerBinding PetManager - { - get - { - if (_petManagerBinding is null) - { - throw new InvalidOperationException - ( - "Could not get pet manager. The binding manager is not initialized. Did you forget to call NosBindingManager.Initialize?" - ); - } - - return _petManagerBinding; - } - } - - /// - /// Initialize the existing bindings and hook NosTale functions. - /// - /// A result that may or may not have succeeded. - public IResult Initialize() - { - List errorResults = new List(); - var browserInitializationResult = _browserManager.Initialize(); - if (!browserInitializationResult.IsSuccess) - { - if (browserInitializationResult.Error is NotNostaleProcessError) - { - return browserInitializationResult; - } - - errorResults.Add(browserInitializationResult); - } - - try - { - var network = NetworkBinding.Create(this, _networkBindingOptions); - if (!network.IsSuccess) - { - errorResults.Add - ( - Result.FromError - ( - new CouldNotInitializeModuleError(typeof(NetworkBinding), network.Error), - network - ) - ); - } - - _networkBinding = network.Entity; - } - catch (Exception e) - { - errorResults.Add( - Result.FromError - ( - new CouldNotInitializeModuleError(typeof(NetworkBinding), new ExceptionError(e)), - (Result)new ExceptionError(e) - )); - } - - try - { - var playerManagerBinding = PlayerManagerBinding.Create - ( - this, - _browserManager.PlayerManager, - _characterBindingOptions - ); - if (!playerManagerBinding.IsSuccess) - { - errorResults.Add - ( - Result.FromError - ( - new CouldNotInitializeModuleError(typeof(PlayerManagerBinding), playerManagerBinding.Error), - playerManagerBinding - ) - ); - } - _characterBinding = playerManagerBinding.Entity; - } - catch (Exception e) - { - errorResults.Add - ( - Result.FromError - ( - new CouldNotInitializeModuleError(typeof(PlayerManagerBinding), new ExceptionError(e)), - (Result)new ExceptionError(e) - ) - ); - } - - try - { - var unitManagerBinding = UnitManagerBinding.Create - ( - this, - _unitManagerBindingOptions - ); - if (!unitManagerBinding.IsSuccess) - { - errorResults.Add - ( - Result.FromError - ( - new CouldNotInitializeModuleError(typeof(UnitManagerBinding), unitManagerBinding.Error), - unitManagerBinding - ) - ); - } - _unitManagerBinding = unitManagerBinding.Entity; - } - catch (Exception e) - { - errorResults.Add - ( - Result.FromError - ( - new CouldNotInitializeModuleError(typeof(UnitManagerBinding), new ExceptionError(e)), - (Result)new ExceptionError(e) - ) - ); - } - - try - { - var petManagerBinding = PetManagerBinding.Create - ( - this, - _browserManager.PetManagerList, - _petManagerBindingOptions - ); - if (!petManagerBinding.IsSuccess) - { - errorResults.Add - ( - Result.FromError - ( - new CouldNotInitializeModuleError(typeof(PetManagerBinding), petManagerBinding.Error), - petManagerBinding - ) - ); - } - _petManagerBinding = petManagerBinding.Entity; - } - catch (Exception e) - { - errorResults.Add - ( - Result.FromError - ( - new CouldNotInitializeModuleError(typeof(UnitManagerBinding), new ExceptionError(e)), - (Result)new ExceptionError(e) - ) - ); - } - - return errorResults.Count switch - { - 0 => Result.FromSuccess(), - 1 => errorResults[0], - _ => (Result)new AggregateError(errorResults) - }; - } - - /// - /// Disable the currently enabled nostale hooks. - /// - /// A result that may or may not have succeeded. - public Result DisableHooks() - { - if (_networkBinding is not null) - { - var result = _networkBinding.DisableHooks(); - if (!result.IsSuccess) - { - return result; - } - } - - return Result.FromSuccess(); - } - - /// - public void Dispose() - { - Scanner.Dispose(); - DisableHooks(); - } - - /// - /// Create a hook object for the given pattern. - /// - /// The name of the binding. - /// The callback function to call instead of the original one. - /// The pattern. - /// The offset from the pattern. - /// Whether to activate the hook. - /// The type of the function. - /// The hook object or an error. - internal Result> CreateHookFromPattern - ( - string name, - TFunction callbackFunction, - string pattern, - int offset = 0, - bool hook = true - ) - { - var walkFunctionAddress = Scanner.CompiledFindPattern(pattern); - if (!walkFunctionAddress.Found) - { - return new BindingNotFoundError(pattern, "PetManagerBinding.PetWalk"); - } - - try - { - return Result>.FromSuccess - ( - Hooks.CreateHook - ( - callbackFunction, - walkFunctionAddress.Offset + (int)_browserManager.Process.MainModule!.BaseAddress - ) - ); - } - catch (Exception e) - { - return e; - } - } -} \ No newline at end of file diff --git a/Local/NosSmooth.LocalBinding/NosBrowserManager.cs b/Local/NosSmooth.LocalBinding/NosBrowserManager.cs deleted file mode 100644 index c11050a273235264ae0287d646644c163c69fccd..0000000000000000000000000000000000000000 --- a/Local/NosSmooth.LocalBinding/NosBrowserManager.cs +++ /dev/null @@ -1,279 +0,0 @@ -// -// NosBrowserManager.cs -// -// Copyright (c) František Boháček. All rights reserved. -// Licensed under the MIT license. See LICENSE file in the project root for full license information. - -using System.Diagnostics; -using Microsoft.Extensions.Options; -using NosSmooth.LocalBinding.Errors; -using NosSmooth.LocalBinding.Options; -using NosSmooth.LocalBinding.Structs; -using Reloaded.Memory.Sigscan; -using Reloaded.Memory.Sources; -using Remora.Results; - -namespace NosSmooth.LocalBinding; - -/// -/// Used for browsing a nostale process data. -/// -public class NosBrowserManager -{ - /// - /// Checks whether the given process is a NosTale client process. - /// - /// - /// This is just a guess based on presence of "NostaleData" directory. - /// - /// The process to check. - /// Whether the process is a NosTale client. - public static bool IsProcessNostaleProcess(Process process) - { - if (process.MainModule is null) - { - return false; - } - - var processDirectory = Path.GetDirectoryName(process.MainModule.FileName); - if (processDirectory is null) - { - return false; - } - - return Directory.Exists(Path.Combine(processDirectory, "NostaleData")); - } - - /// - /// Get all running nostale processes. - /// - /// The nostale processes. - public static IEnumerable GetAllNostaleProcesses() - => Process - .GetProcesses() - .Where(IsProcessNostaleProcess); - - private readonly PlayerManagerOptions _playerManagerOptions; - private readonly SceneManagerOptions _sceneManagerOptions; - private readonly PetManagerOptions _petManagerOptions; - private PlayerManager? _playerManager; - private SceneManager? _sceneManager; - private PetManagerList? _petManagerList; - - /// - /// Initializes a new instance of the class. - /// - /// The options for obtaining player manager. - /// The scene manager options. - /// The pet manager options. - public NosBrowserManager - ( - IOptions playerManagerOptions, - IOptions sceneManagerOptions, - IOptions petManagerOptions - ) - : this - ( - Process.GetCurrentProcess(), - playerManagerOptions.Value, - sceneManagerOptions.Value, - petManagerOptions.Value - ) - { - } - - /// - /// Initializes a new instance of the class. - /// - /// The process to browse. - /// The options for obtaining player manager. - /// The scene manager options. - /// The pet manager options. - public NosBrowserManager - ( - Process process, - PlayerManagerOptions playerManagerOptions, - SceneManagerOptions sceneManagerOptions, - PetManagerOptions petManagerOptions - ) - { - _playerManagerOptions = playerManagerOptions; - _sceneManagerOptions = sceneManagerOptions; - _petManagerOptions = petManagerOptions; - Process = process; - Memory = new ExternalMemory(process); - Scanner = new Scanner(process, process.MainModule); - } - - /// - /// The NosTale process. - /// - public Process Process { get; } - - /// - /// Gets the memory scanner. - /// - internal Scanner Scanner { get; } - - /// - /// Gets the current process memory. - /// - internal IMemory Memory { get; } - - /// - /// Gets whether this is a NosTale process or not. - /// - public bool IsNostaleProcess => NosBrowserManager.IsProcessNostaleProcess(Process); - - /// - /// Gets whether the player is currently in game. - /// - /// - /// It may be unsafe to access some data if the player is not in game. - /// - public bool IsInGame - { - get - { - var player = PlayerManager.Player; - return player.Address != IntPtr.Zero; - } - } - - /// - /// Gets the player manager. - /// - /// Thrown if the browser is not initialized or there was an error with initialization of player manager. - public PlayerManager PlayerManager - { - get - { - if (_playerManager is null) - { - throw new InvalidOperationException - ( - "Could not get player manager. The browser manager is not initialized. Did you forget to call NosBrowserManager.Initialize?" - ); - } - - return _playerManager; - } - } - - /// - /// Gets the scene manager. - /// - /// Thrown if the browser is not initialized or there was an error with initialization of scene manager. - public SceneManager SceneManager - { - get - { - if (_sceneManager is null) - { - throw new InvalidOperationException - ( - "Could not get scene manager. The browser manager is not initialized. Did you forget to call NosBrowserManager.Initialize?" - ); - } - - return _sceneManager; - } - } - - /// - /// Gets the pet manager list. - /// - /// Thrown if the browser is not initialized or there was an error with initialization of pet manager list. - public PetManagerList PetManagerList - { - get - { - if (_petManagerList is null) - { - throw new InvalidOperationException - ( - "Could not get pet manager list. The browser manager is not initialized. Did you forget to call NosBrowserManager.Initialize?" - ); - } - - return _petManagerList; - } - } - - /// - /// Initialize the nos browser modules. - /// - /// - /// Needed to use all of the classes from NosTale. - /// - /// A result that may or may not have succeeded. - public IResult Initialize() - { - if (!IsNostaleProcess) - { - return (Result)new NotNostaleProcessError(Process); - } - - List errorResults = new List(); - if (_playerManager is null) - { - var playerManagerResult = PlayerManager.Create(this, _playerManagerOptions); - if (!playerManagerResult.IsSuccess) - { - errorResults.Add - ( - Result.FromError - ( - new CouldNotInitializeModuleError(typeof(PlayerManager), playerManagerResult.Error), - playerManagerResult - ) - ); - } - - _playerManager = playerManagerResult.Entity; - } - - if (_sceneManager is null) - { - var sceneManagerResult = SceneManager.Create(this, _sceneManagerOptions); - if (!sceneManagerResult.IsSuccess) - { - errorResults.Add - ( - Result.FromError - ( - new CouldNotInitializeModuleError(typeof(SceneManager), sceneManagerResult.Error), - sceneManagerResult - ) - ); - } - - _sceneManager = sceneManagerResult.Entity; - } - - if (_petManagerList is null) - { - var petManagerResult = PetManagerList.Create(this, _petManagerOptions); - if (!petManagerResult.IsSuccess) - { - errorResults.Add - ( - Result.FromError - ( - new CouldNotInitializeModuleError(typeof(PetManagerList), petManagerResult.Error), - petManagerResult - ) - ); - } - - _petManagerList = petManagerResult.Entity; - } - - return errorResults.Count switch - { - 0 => Result.FromSuccess(), - 1 => errorResults[0], - _ => (Result)new AggregateError(errorResults) - }; - } -} \ No newline at end of file diff --git a/Local/NosSmooth.LocalBinding/NosSmooth.LocalBinding.csproj b/Local/NosSmooth.LocalBinding/NosSmooth.LocalBinding.csproj deleted file mode 100644 index e9f722aaae139731ab705db020a3142b96ab4809..0000000000000000000000000000000000000000 --- a/Local/NosSmooth.LocalBinding/NosSmooth.LocalBinding.csproj +++ /dev/null @@ -1,18 +0,0 @@ - - - - netstandard2.0 - enable - enable - 10 - - - - - - - - - - - diff --git a/Local/NosSmooth.LocalBinding/Objects/NetworkBinding.cs b/Local/NosSmooth.LocalBinding/Objects/NetworkBinding.cs deleted file mode 100644 index 97ce0fcf6b3733dadd315ca75e9c16d70bf50169..0000000000000000000000000000000000000000 --- a/Local/NosSmooth.LocalBinding/Objects/NetworkBinding.cs +++ /dev/null @@ -1,236 +0,0 @@ -// -// NetworkBinding.cs -// -// Copyright (c) František Boháček. All rights reserved. -// Licensed under the MIT license. See LICENSE file in the project root for full license information. - -using System.Diagnostics; -using System.Runtime.InteropServices; -using NosSmooth.LocalBinding.Errors; -using NosSmooth.LocalBinding.Options; -using Reloaded.Hooks.Definitions; -using Reloaded.Hooks.Definitions.X86; -using Remora.Results; - -namespace NosSmooth.LocalBinding.Objects; - -/// -/// The binding to nostale network object. -/// -public class NetworkBinding -{ - [Function - ( - new[] { FunctionAttribute.Register.eax, FunctionAttribute.Register.edx }, - FunctionAttribute.Register.eax, - FunctionAttribute.StackCleanup.Callee - )] - private delegate void PacketSendDelegate(IntPtr packetObject, IntPtr packetString); - - [Function - ( - new[] { FunctionAttribute.Register.eax, FunctionAttribute.Register.edx }, - FunctionAttribute.Register.eax, - FunctionAttribute.StackCleanup.Callee - )] - private delegate void PacketReceiveDelegate(IntPtr packetObject, IntPtr packetString); - - /// - /// Create the network binding with finding the network object and functions. - /// - /// The binding manager. - /// The options for the binding. - /// A network binding or an error. - public static Result Create(NosBindingManager bindingManager, NetworkBindingOptions options) - { - var process = Process.GetCurrentProcess(); - var networkObjectAddress = bindingManager.Scanner.CompiledFindPattern(options.NetworkObjectPattern); - if (!networkObjectAddress.Found) - { - return new BindingNotFoundError(options.NetworkObjectPattern, "NetworkBinding"); - } - - var packetSendAddress = bindingManager.Scanner.CompiledFindPattern(options.SendFunctionPattern); - if (!packetSendAddress.Found) - { - return new BindingNotFoundError(options.SendFunctionPattern, "NetworkBinding.SendPacket"); - } - - var packetReceiveAddress = bindingManager.Scanner.CompiledFindPattern(options.ReceiveFunctionPattern); - if (!packetReceiveAddress.Found) - { - return new BindingNotFoundError(options.ReceiveFunctionPattern, "NetworkBinding.ReceivePacket"); - } - - var sendFunction = bindingManager.Hooks.CreateFunction - (packetSendAddress.Offset + (int)process.MainModule!.BaseAddress); - var sendWrapper = sendFunction.GetWrapper(); - - var receiveFunction = bindingManager.Hooks.CreateFunction - (packetReceiveAddress.Offset + (int)process.MainModule!.BaseAddress); - var receiveWrapper = receiveFunction.GetWrapper(); - - var binding = new NetworkBinding - ( - bindingManager, - (IntPtr)(networkObjectAddress.Offset + (int)process.MainModule!.BaseAddress + 0x01), - sendWrapper, - receiveWrapper - ); - - if (options.HookSend) - { - binding._sendHook = sendFunction - .Hook(binding.SendPacketDetour); - binding._originalSend = binding._sendHook.OriginalFunction; - } - - if (options.HookReceive) - { - binding._receiveHook = receiveFunction - .Hook(binding.ReceivePacketDetour); - binding._originalReceive = binding._receiveHook.OriginalFunction; - } - - binding._sendHook?.Activate(); - binding._receiveHook?.Activate(); - return binding; - } - - private readonly NosBindingManager _bindingManager; - private readonly IntPtr _networkManagerAddress; - private IHook? _sendHook; - private IHook? _receiveHook; - private PacketSendDelegate _originalSend; - private PacketReceiveDelegate _originalReceive; - - private NetworkBinding - ( - NosBindingManager bindingManager, - IntPtr networkManagerAddress, - PacketSendDelegate originalSend, - PacketReceiveDelegate originalReceive - ) - { - _bindingManager = bindingManager; - _networkManagerAddress = networkManagerAddress; - _originalSend = originalSend; - _originalReceive = originalReceive; - } - - /// - /// Event that is called when packet send was called by NosTale. - /// - /// - /// The send must be hooked for this event to be called. - /// - public event Func? PacketSend; - - /// - /// Event that is called when packet receive was called by NosTale. - /// - /// - /// The receive must be hooked for this event to be called. - /// - public event Func? PacketReceive; - - /// - /// Send the given packet. - /// - /// The packet to send. - /// A result that may or may not have succeeded. - public Result SendPacket(string packet) - { - try - { - using var nostaleString = NostaleStringA.Create(_bindingManager.Memory, packet); - _originalSend(GetManagerAddress(false), nostaleString.Get()); - } - catch (Exception e) - { - return e; - } - - return Result.FromSuccess(); - } - - /// - /// Receive the given packet. - /// - /// The packet to receive. - /// A result that may or may not have succeeded. - public Result ReceivePacket(string packet) - { - try - { - using var nostaleString = NostaleStringA.Create(_bindingManager.Memory, packet); - _originalReceive(GetManagerAddress(true), nostaleString.Get()); - } - catch (Exception e) - { - return e; - } - - return Result.FromSuccess(); - } - - /// - /// Disable all the hooks that are currently enabled. - /// - /// A result that may or may not have succeeded. - public Result DisableHooks() - { - _receiveHook?.Disable(); - _sendHook?.Disable(); - return Result.FromSuccess(); - } - - private IntPtr GetManagerAddress(bool third) - { - IntPtr networkManager = _networkManagerAddress; - _bindingManager.Memory.Read(networkManager, out networkManager); - _bindingManager.Memory.Read(networkManager, out networkManager); - _bindingManager.Memory.Read(networkManager, out networkManager); - - if (third) - { - _bindingManager.Memory.Read(networkManager + 0x34, out networkManager); - } - - return networkManager; - } - - private void SendPacketDetour(IntPtr packetObject, IntPtr packetString) - { - var packet = Marshal.PtrToStringAnsi(packetString); - if (packet is null) - { // ? - _originalSend(packetObject, packetString); - } - else - { - var result = PacketSend?.Invoke(packet); - if (result ?? true) - { - _originalSend(packetObject, packetString); - } - } - } - - private void ReceivePacketDetour(IntPtr packetObject, IntPtr packetString) - { - var packet = Marshal.PtrToStringAnsi(packetString); - if (packet is null) - { // ? - _originalReceive(packetObject, packetString); - } - else - { - var result = PacketReceive?.Invoke(packet); - if (result ?? true) - { - _originalReceive(packetObject, packetString); - } - } - } -} \ No newline at end of file diff --git a/Local/NosSmooth.LocalBinding/Objects/NostaleStringA.cs b/Local/NosSmooth.LocalBinding/Objects/NostaleStringA.cs deleted file mode 100644 index 9744f0433bb74a2d54182ed75c7fa782a1b146fa..0000000000000000000000000000000000000000 --- a/Local/NosSmooth.LocalBinding/Objects/NostaleStringA.cs +++ /dev/null @@ -1,84 +0,0 @@ -// -// NostaleStringA.cs -// -// Copyright (c) František Boháček. All rights reserved. -// Licensed under the MIT license. See LICENSE file in the project root for full license information. - -using System.Text; -using Reloaded.Memory.Sources; - -namespace NosSmooth.LocalBinding.Objects; - -/// -/// Represents nostale string object. -/// -public class NostaleStringA : IDisposable -{ - private readonly IMemory _memory; - private IntPtr _pointer; - - /// - /// Create an instance of . - /// - /// The memory to allocate the string on. - /// The string contents. - /// A nostale string. - public static NostaleStringA Create(IMemory memory, string data) - { - var bytes = Encoding.ASCII.GetBytes(data); - var allocated = memory.Allocate(bytes.Length + 1 + 8); - memory.SafeWrite(allocated, 1); - memory.SafeWrite(allocated + 4, data.Length); - memory.SafeWriteRaw(allocated + 8, bytes); - memory.SafeWrite(allocated + 8 + data.Length, 0); - - return new NostaleStringA(memory, allocated); - } - - private NostaleStringA(IMemory memory, IntPtr pointer) - { - _memory = memory; - _pointer = pointer; - - } - - /// - /// Finalizes an instance of the class. - /// - ~NostaleStringA() - { - Free(); - } - - /// - /// Gets whether the string is still allocated. - /// - public bool Allocated => _pointer != IntPtr.Zero; - - /// - /// Get the pointer to the string. - /// - /// A pointer to the string to pass to NosTale. - public IntPtr Get() - { - return _pointer + 0x08; - } - - /// - /// Free the memory allocated by the string. - /// - public void Free() - { - if (Allocated) - { - _memory.Free(_pointer); - _pointer = IntPtr.Zero; - } - } - - /// - public void Dispose() - { - Free(); - } -} \ No newline at end of file diff --git a/Local/NosSmooth.LocalBinding/Objects/PetManagerBinding.cs b/Local/NosSmooth.LocalBinding/Objects/PetManagerBinding.cs deleted file mode 100644 index e3a435e3856d695714ac699f103a86acb24d3c35..0000000000000000000000000000000000000000 --- a/Local/NosSmooth.LocalBinding/Objects/PetManagerBinding.cs +++ /dev/null @@ -1,129 +0,0 @@ -// -// PetManagerBinding.cs -// -// Copyright (c) František Boháček. All rights reserved. -// Licensed under the MIT license. See LICENSE file in the project root for full license information. - -using NosSmooth.LocalBinding.Options; -using NosSmooth.LocalBinding.Structs; -using Reloaded.Hooks.Definitions; -using Reloaded.Hooks.Definitions.X86; -using Remora.Results; - -namespace NosSmooth.LocalBinding.Objects; - -/// -/// The binding to NosTale pet manager. -/// -public class PetManagerBinding -{ - /// - /// Create nostale pet manager binding. - /// - /// The binding manager. - /// The list of the pet managers. - /// The options. - /// A pet manager binding or and error. - public static Result Create - (NosBindingManager bindingManager, PetManagerList petManagerList, PetManagerBindingOptions options) - { - var petManager = new PetManagerBinding(petManagerList); - var hookResult = bindingManager.CreateHookFromPattern - ( - "PetManagerBinding.PetWalk", - petManager.PetWalkDetour, - options.PetWalkPattern, - hook: options.HookPetWalk - ); - - if (!hookResult.IsSuccess) - { - return Result.FromError(hookResult); - } - - petManager._petWalkHook = hookResult.Entity; - return petManager; - } - - [Function - ( - new[] { FunctionAttribute.Register.eax, FunctionAttribute.Register.edx, FunctionAttribute.Register.ecx }, - FunctionAttribute.Register.eax, - FunctionAttribute.StackCleanup.Callee - )] - private delegate bool PetWalkDelegate - ( - IntPtr petManagerPtr, - uint position, - short unknown0 = 0, - int unknown1 = 1, - int unknown2 = 1 - ); - - private IHook _petWalkHook = null!; - - private PetManagerBinding(PetManagerList petManagerList) - { - PetManagerList = petManagerList; - } - - /// - /// Gets the hook of the pet walk function. - /// - public IHook PetWalkHook => _petWalkHook; - - /// - /// Gets pet manager list. - /// - public PetManagerList PetManagerList { get; } - - /// - /// Walk the given pet to the given location. - /// - /// Index of the pet to walk. -1 for every pet currently available. - /// The x coordinate. - /// The y coordinate. - /// A result returned from NosTale or an error. - public Result PetWalk(int selector, ushort x, ushort y) - { - uint position = ((uint)y << 16) | x; - if (PetManagerList.Length < selector + 1) - { - return new NotFoundError("Could not find the pet using the given selector."); - } - - if (selector == -1) - { - bool lastResult = true; - for (int i = 0; i < PetManagerList.Length; i++) - { - lastResult = _petWalkHook.OriginalFunction(PetManagerList[i].Address, position); - } - - return lastResult; - } - else - { - return _petWalkHook.OriginalFunction(PetManagerList[selector].Address, position); - } - } - - private bool PetWalkDetour - ( - IntPtr petManagerPtr, - uint position, - short unknown0 = 0, - int unknown1 = 1, - int unknown2 = 1 - ) - { - return _petWalkHook.OriginalFunction - ( - petManagerPtr, - position, - unknown0, - unknown1, - unknown2 - ); - } -} \ No newline at end of file diff --git a/Local/NosSmooth.LocalBinding/Objects/PlayerManagerBinding.cs b/Local/NosSmooth.LocalBinding/Objects/PlayerManagerBinding.cs deleted file mode 100644 index 809fe899c2aa7f9873a5f273286efb6443caea51..0000000000000000000000000000000000000000 --- a/Local/NosSmooth.LocalBinding/Objects/PlayerManagerBinding.cs +++ /dev/null @@ -1,284 +0,0 @@ -// -// PlayerManagerBinding.cs -// -// Copyright (c) František Boháček. All rights reserved. -// Licensed under the MIT license. See LICENSE file in the project root for full license information. - -using System.Diagnostics; -using NosSmooth.LocalBinding.Errors; -using NosSmooth.LocalBinding.Options; -using NosSmooth.LocalBinding.Structs; -using Reloaded.Hooks.Definitions; -using Reloaded.Hooks.Definitions.X86; -using Remora.Results; - -namespace NosSmooth.LocalBinding.Objects; - -/// -/// The nostale binding of a character. -/// -public class PlayerManagerBinding -{ - [Function - ( - new[] { FunctionAttribute.Register.eax, FunctionAttribute.Register.edx, FunctionAttribute.Register.ecx }, - FunctionAttribute.Register.eax, - FunctionAttribute.StackCleanup.Callee - )] - private delegate bool WalkDelegate(IntPtr playerManagerPtr, int position, short unknown0 = 0, int unknown1 = 1); - - [Function - ( - new[] { FunctionAttribute.Register.eax, FunctionAttribute.Register.edx, FunctionAttribute.Register.ecx }, - FunctionAttribute.Register.eax, - FunctionAttribute.StackCleanup.Callee - )] - private delegate bool FollowEntityDelegate - ( - IntPtr playerManagerPtr, - IntPtr entityPtr, - int unknown1 = 0, - int unknown2 = 1 - ); - - [Function - ( - new[] { FunctionAttribute.Register.eax, FunctionAttribute.Register.edx }, - FunctionAttribute.Register.eax, - FunctionAttribute.StackCleanup.Callee - )] - private delegate void UnfollowEntityDelegate(IntPtr playerManagerPtr, int unknown = 0); - - /// - /// Create the network binding with finding the network object and functions. - /// - /// The binding manager. - /// The player manager. - /// The options for the binding. - /// A network binding or an error. - public static Result Create(NosBindingManager bindingManager, PlayerManager playerManager, CharacterBindingOptions options) - { - var process = Process.GetCurrentProcess(); - - var walkFunctionAddress = bindingManager.Scanner.CompiledFindPattern(options.WalkFunctionPattern); - if (!walkFunctionAddress.Found) - { - return new BindingNotFoundError(options.WalkFunctionPattern, "CharacterBinding.Walk"); - } - - var followEntityAddress = bindingManager.Scanner.CompiledFindPattern(options.FollowEntityPattern); - if (!followEntityAddress.Found) - { - return new BindingNotFoundError(options.FollowEntityPattern, "CharacterBinding.FollowEntity"); - } - - var unfollowEntityAddress = bindingManager.Scanner.CompiledFindPattern(options.UnfollowEntityPattern); - if (!unfollowEntityAddress.Found) - { - return new BindingNotFoundError(options.UnfollowEntityPattern, "CharacterBinding.UnfollowEntity"); - } - - var walkFunction = bindingManager.Hooks.CreateFunction - (walkFunctionAddress.Offset + (int)process.MainModule!.BaseAddress); - var walkWrapper = walkFunction.GetWrapper(); - - var followEntityFunction = bindingManager.Hooks.CreateFunction - (followEntityAddress.Offset + (int)process.MainModule!.BaseAddress); - var followEntityWrapper = followEntityFunction.GetWrapper(); - - var unfollowEntityFunction = bindingManager.Hooks.CreateFunction - (unfollowEntityAddress.Offset + (int)process.MainModule!.BaseAddress); - var unfollowEntityWrapper = unfollowEntityFunction.GetWrapper(); - - var binding = new PlayerManagerBinding - ( - bindingManager, - playerManager, - walkWrapper, - followEntityWrapper, - unfollowEntityWrapper - ); - - if (options.HookWalk) - { - binding._walkHook = walkFunction - .Hook(binding.WalkDetour); - binding._originalWalk = binding._walkHook.OriginalFunction; - } - - if (options.HookFollowEntity) - { - binding._followHook = followEntityFunction.Hook(binding.FollowEntityDetour); - binding._originalFollowEntity = binding._followHook.OriginalFunction; - } - - if (options.HookUnfollowEntity) - { - binding._unfollowHook = unfollowEntityFunction.Hook(binding.UnfollowEntityDetour); - binding._originalUnfollowEntity = binding._unfollowHook.OriginalFunction; - } - - binding._walkHook?.Activate(); - binding._followHook?.Activate(); - binding._unfollowHook?.Activate(); - return binding; - } - - private readonly NosBindingManager _bindingManager; - - private IHook? _walkHook; - private IHook? _followHook; - private IHook? _unfollowHook; - - private FollowEntityDelegate _originalFollowEntity; - private UnfollowEntityDelegate _originalUnfollowEntity; - private WalkDelegate _originalWalk; - - private PlayerManagerBinding - ( - NosBindingManager bindingManager, - PlayerManager playerManager, - WalkDelegate originalWalk, - FollowEntityDelegate originalFollowEntity, - UnfollowEntityDelegate originalUnfollowEntity - ) - { - PlayerManager = playerManager; - _bindingManager = bindingManager; - _originalWalk = originalWalk; - _originalFollowEntity = originalFollowEntity; - _originalUnfollowEntity = originalUnfollowEntity; - } - - /// - /// Gets the player manager. - /// - public PlayerManager PlayerManager { get; } - - /// - /// Event that is called when walk was called by NosTale. - /// - /// - /// The walk must be hooked for this event to be called. - /// - public event Func? WalkCall; - - /// - /// Event that is called when entity follow or unfollow was called. - /// - /// - /// The follow/unfollow entity must be hooked for this event to be called. - /// - public event Func? FollowEntityCall; - - /// - /// Disable all the hooks that are currently enabled. - /// - /// A result that may or may not have succeeded. - public Result DisableHooks() - { - _walkHook?.Disable(); - return Result.FromSuccess(); - } - - /// - /// Walk to the given position. - /// - /// The x coordinate. - /// The y coordinate. - /// A result that may or may not have succeeded. - public Result Walk(ushort x, ushort y) - { - int param = (y << 16) | x; - try - { - return _originalWalk(PlayerManager.Address, param); - } - catch (Exception e) - { - return e; - } - } - - private bool WalkDetour(IntPtr characterObject, int position, short unknown0, int unknown1) - { - var result = WalkCall?.Invoke((ushort)(position & 0xFFFF), (ushort)((position >> 16) & 0xFFFF)); - if (result ?? true) - { - return _originalWalk(characterObject, position, unknown0, unknown1); - } - - return false; - } - - /// - /// Follow the entity. - /// - /// The entity. - /// A result that may or may not have succeeded. - public Result FollowEntity(MapBaseObj? entity) - => FollowEntity(entity?.Address ?? IntPtr.Zero); - - /// - /// Follow the entity. - /// - /// The entity address. - /// A result that may or may not have succeeded. - public Result FollowEntity(IntPtr entityAddress) - { - try - { - _originalFollowEntity(PlayerManager.Address, entityAddress); - } - catch (Exception e) - { - return e; - } - - return Result.FromSuccess(); - } - - /// - /// Stop following entity. - /// - /// A result that may or may not have succeeded. - public Result UnfollowEntity() - { - try - { - _originalUnfollowEntity(PlayerManager.Address); - } - catch (Exception e) - { - return e; - } - - return Result.FromSuccess(); - } - - private bool FollowEntityDetour - ( - IntPtr playerManagerPtr, - IntPtr entityPtr, - int unknown1, - int unknown2 - ) - { - var result = FollowEntityCall?.Invoke(new MapBaseObj(_bindingManager.Memory, entityPtr)); - if (result ?? true) - { - return _originalFollowEntity(playerManagerPtr, entityPtr, unknown1, unknown2); - } - - return false; - } - - private void UnfollowEntityDetour(IntPtr playerManagerPtr, int unknown) - { - var result = FollowEntityCall?.Invoke(null); - if (result ?? true) - { - _originalUnfollowEntity(playerManagerPtr, unknown); - } - } -} \ No newline at end of file diff --git a/Local/NosSmooth.LocalBinding/Objects/UnitManagerBinding.cs b/Local/NosSmooth.LocalBinding/Objects/UnitManagerBinding.cs deleted file mode 100644 index f1a8fc60c6ba6a5c80c5e89b6968bc56fd40381b..0000000000000000000000000000000000000000 --- a/Local/NosSmooth.LocalBinding/Objects/UnitManagerBinding.cs +++ /dev/null @@ -1,164 +0,0 @@ -// -// UnitManagerBinding.cs -// -// Copyright (c) František Boháček. All rights reserved. -// Licensed under the MIT license. See LICENSE file in the project root for full license information. - -using System.Diagnostics; -using NosSmooth.LocalBinding.Errors; -using NosSmooth.LocalBinding.Extensions; -using NosSmooth.LocalBinding.Options; -using NosSmooth.LocalBinding.Structs; -using Reloaded.Hooks; -using Reloaded.Hooks.Definitions; -using Reloaded.Hooks.Definitions.X86; -using Reloaded.Memory.Buffers.Internal.Kernel32; -using Remora.Results; -using SharpDisasm.Udis86; - -namespace NosSmooth.LocalBinding.Objects; - -/// -/// The nostale binding of a scene manager. -/// -/// -/// The scene manager holds addresses to entities, mouse position, .... -/// -public class UnitManagerBinding -{ - [Function - ( - new[] { FunctionAttribute.Register.eax, FunctionAttribute.Register.edx }, - FunctionAttribute.Register.eax, - FunctionAttribute.StackCleanup.Callee - )] - private delegate int FocusEntityDelegate(IntPtr unitManagerPtr, IntPtr entityPtr); - - /// - /// Create the scene manager binding. - /// - /// The binding manager. - /// The options for the binding. - /// A network binding or an error. - public static Result Create - (NosBindingManager bindingManager, UnitManagerBindingOptions bindingOptions) - { - var process = Process.GetCurrentProcess(); - - var unitManagerStaticAddress = bindingManager.Scanner.CompiledFindPattern(bindingOptions.UnitManagerPattern); - if (!unitManagerStaticAddress.Found) - { - return new BindingNotFoundError(bindingOptions.UnitManagerPattern, "UnitManagerBinding.UnitManager"); - } - - var focusEntityAddress = bindingManager.Scanner.CompiledFindPattern(bindingOptions.FocusEntityPattern); - if (!focusEntityAddress.Found) - { - return new BindingNotFoundError(bindingOptions.FocusEntityPattern, "UnitManagerBinding.FocusEntity"); - } - - var focusEntityFunction = bindingManager.Hooks.CreateFunction - (focusEntityAddress.Offset + (int)process.MainModule!.BaseAddress + 0x04); - var focusEntityWrapper = focusEntityFunction.GetWrapper(); - - var binding = new UnitManagerBinding - ( - bindingManager, - (int)process.MainModule!.BaseAddress + unitManagerStaticAddress.Offset, - bindingOptions.UnitManagerOffsets, - focusEntityWrapper - ); - - if (bindingOptions.HookFocusEntity) - { - binding._focusHook = focusEntityFunction.Hook(binding.FocusEntityDetour); - binding._originalFocusEntity = binding._focusHook.OriginalFunction; - } - - binding._focusHook?.Activate(); - return binding; - } - - private readonly int _staticUnitManagerAddress; - private readonly int[] _unitManagerOffsets; - - private readonly NosBindingManager _bindingManager; - private FocusEntityDelegate _originalFocusEntity; - - private IHook? _focusHook; - - private UnitManagerBinding - ( - NosBindingManager bindingManager, - int staticUnitManagerAddress, - int[] unitManagerOffsets, - FocusEntityDelegate originalFocusEntity - ) - { - _originalFocusEntity = originalFocusEntity; - _bindingManager = bindingManager; - _staticUnitManagerAddress = staticUnitManagerAddress; - _unitManagerOffsets = unitManagerOffsets; - } - - /// - /// Gets the address of unit manager. - /// - public IntPtr Address => _bindingManager.Memory.FollowStaticAddressOffsets - (_staticUnitManagerAddress, _unitManagerOffsets); - - /// - /// Event that is called when entity focus was called by NosTale. - /// - /// - /// The focus entity must be hooked for this event to be called. - /// - public event Func? EntityFocus; - - /// - /// Focus the entity. - /// - /// The entity. - /// A result that may or may not have succeeded. - public Result FocusEntity(MapBaseObj? entity) - => FocusEntity(entity?.Address ?? IntPtr.Zero); - - /// - /// Focus the entity. - /// - /// The entity address. - /// A result that may or may not have succeeded. - public Result FocusEntity(IntPtr entityAddress) - { - try - { - var res = _originalFocusEntity(Address, entityAddress); - Console.WriteLine(res); - } - catch (Exception e) - { - return e; - } - - return Result.FromSuccess(); - } - - private int FocusEntityDetour(IntPtr unitManagerPtr, IntPtr entityId) - { - MapBaseObj? obj = null; - if (entityId != IntPtr.Zero) - { - obj = new MapBaseObj(_bindingManager.Memory, entityId); - } - - var result = EntityFocus?.Invoke(obj); - if (result ?? true) - { - var res = _originalFocusEntity(unitManagerPtr, entityId); - Console.WriteLine(res); - return res; - } - - return 0; - } -} \ No newline at end of file diff --git a/Local/NosSmooth.LocalBinding/Options/CharacterBindingOptions.cs b/Local/NosSmooth.LocalBinding/Options/CharacterBindingOptions.cs deleted file mode 100644 index c06dee91216dddf1160e2cef691dc5af914cc9ad..0000000000000000000000000000000000000000 --- a/Local/NosSmooth.LocalBinding/Options/CharacterBindingOptions.cs +++ /dev/null @@ -1,47 +0,0 @@ -// -// CharacterBindingOptions.cs -// -// Copyright (c) František Boháček. All rights reserved. -// Licensed under the MIT license. See LICENSE file in the project root for full license information. - -using NosSmooth.LocalBinding.Objects; - -namespace NosSmooth.LocalBinding.Options; - -/// -/// Options for . -/// -public class CharacterBindingOptions -{ - /// - /// Gets or sets whether to hook the walk function. - /// - public bool HookWalk { get; set; } = true; - - /// - /// Gets or sets the pattern to find the walk function at. - /// - public string WalkFunctionPattern { get; set; } = "55 8B EC 83 C4 EC 53 56 57 66 89 4D FA"; - - /// - /// Gets or sets the pattern to find the follow entity method at. - /// - public string FollowEntityPattern { get; set; } - = "55 8B EC 51 53 56 57 88 4D FF 8B F2 8B F8"; - - /// - /// Gets or sets the pattern to find the unfollow entity method at. - /// - public string UnfollowEntityPattern { get; set; } - = "80 78 14 00 74 1A"; - - /// - /// Gets or sets whether to hook the follow entity function. - /// - public bool HookFollowEntity { get; set; } = true; - - /// - /// Gets or sets whether to hook the unfollow entity function. - /// - public bool HookUnfollowEntity { get; set; } = true; -} \ No newline at end of file diff --git a/Local/NosSmooth.LocalBinding/Options/NetworkBindingOptions.cs b/Local/NosSmooth.LocalBinding/Options/NetworkBindingOptions.cs deleted file mode 100644 index 8a0b9a185f572e584e8fcd27948338b91ce077cf..0000000000000000000000000000000000000000 --- a/Local/NosSmooth.LocalBinding/Options/NetworkBindingOptions.cs +++ /dev/null @@ -1,44 +0,0 @@ -// -// NetworkBindingOptions.cs -// -// Copyright (c) František Boháček. All rights reserved. -// Licensed under the MIT license. See LICENSE file in the project root for full license information. - -using NosSmooth.LocalBinding.Objects; - -namespace NosSmooth.LocalBinding.Options; - -/// -/// Options for . -/// -public class NetworkBindingOptions -{ - /// - /// Gets or sets whether to hook the send packet function. - /// - public bool HookSend { get; set; } = true; - - /// - /// Gets or sets whether to hook the receive packet function. - /// - public bool HookReceive { get; set; } = true; - - /// - /// Gets or sets the pattern to find the network object at. - /// - /// - /// The address of the object is "three pointers down" from address found on this pattern. - /// - public string NetworkObjectPattern { get; set; } - = "A1 ?? ?? ?? ?? 8B 00 BA ?? ?? ?? ?? E8 ?? ?? ?? ?? E9 ?? ?? ?? ?? A1 ?? ?? ?? ?? 8B 00 8B 40 40"; - - /// - /// Gets or sets the pattern to find the send packet function at. - /// - public string SendFunctionPattern { get; set; } = "53 56 8B F2 8B D8 EB 04"; - - /// - /// Gets or sets the pattern to find the receive function at. - /// - public string ReceiveFunctionPattern { get; set; } = "55 8B EC 83 C4 F4 53 56 57 33 C9 89 4D F4 89 55 FC 8B D8 8B 45 FC"; -} \ No newline at end of file diff --git a/Local/NosSmooth.LocalBinding/Options/PetManagerBindingOptions.cs b/Local/NosSmooth.LocalBinding/Options/PetManagerBindingOptions.cs deleted file mode 100644 index e63ed5caa0b0bf93af0b07fbeac32da4cf78123e..0000000000000000000000000000000000000000 --- a/Local/NosSmooth.LocalBinding/Options/PetManagerBindingOptions.cs +++ /dev/null @@ -1,26 +0,0 @@ -// -// PetManagerBindingOptions.cs -// -// Copyright (c) František Boháček. All rights reserved. -// Licensed under the MIT license. See LICENSE file in the project root for full license information. - -using NosSmooth.LocalBinding.Objects; - -namespace NosSmooth.LocalBinding.Options; - -/// -/// Options for . -/// -public class PetManagerBindingOptions -{ - /// - /// Gets or sets the pattern of a pet walk function. - /// - public string PetWalkPattern { get; set; } - = "55 8b ec 83 c4 e4 53 56 57 8b f9 89 55 fc 8b d8 c6 45 fb 00"; - - /// - /// Gets or sets whether to hook the pet walk function. - /// - public bool HookPetWalk { get; set; } = true; -} \ No newline at end of file diff --git a/Local/NosSmooth.LocalBinding/Options/PetManagerOptions.cs b/Local/NosSmooth.LocalBinding/Options/PetManagerOptions.cs deleted file mode 100644 index ad8a8ccda95970d7d94ef47be57d11e2ac7db95a..0000000000000000000000000000000000000000 --- a/Local/NosSmooth.LocalBinding/Options/PetManagerOptions.cs +++ /dev/null @@ -1,28 +0,0 @@ -// -// PetManagerOptions.cs -// -// Copyright (c) František Boháček. All rights reserved. -// Licensed under the MIT license. See LICENSE file in the project root for full license information. - -using NosSmooth.LocalBinding.Objects; -using NosSmooth.LocalBinding.Structs; - -namespace NosSmooth.LocalBinding.Options; - -/// -/// Options for . -/// -public class PetManagerOptions -{ - /// - /// Gets or sets the pattern to find static pet manager list address at. - /// - public string PetManagerListPattern { get; set; } - = "8B F8 8B D3 A1 ?? ?? ?? ?? E8 ?? ?? ?? ?? 8B D0"; - - /// - /// Gets or sets the offsets to find the pet manager list at from the static address. - /// - public int[] PetManagerListOffsets { get; set; } - = { 5, 0 }; -} \ No newline at end of file diff --git a/Local/NosSmooth.LocalBinding/Options/PlayerManagerOptions.cs b/Local/NosSmooth.LocalBinding/Options/PlayerManagerOptions.cs deleted file mode 100644 index b2be60917a690c9fc0f99c470f7f770b303e15f1..0000000000000000000000000000000000000000 --- a/Local/NosSmooth.LocalBinding/Options/PlayerManagerOptions.cs +++ /dev/null @@ -1,27 +0,0 @@ -// -// PlayerManagerOptions.cs -// -// Copyright (c) František Boháček. All rights reserved. -// Licensed under the MIT license. See LICENSE file in the project root for full license information. - -using NosSmooth.LocalBinding.Structs; - -namespace NosSmooth.LocalBinding.Options; - -/// -/// Options for . -/// -public class PlayerManagerOptions -{ - /// - /// Gets or sets the pattern to find the character object at. - /// - public string PlayerManagerPattern { get; set; } - = "33 C9 8B 55 FC A1 ?? ?? ?? ?? E8 ?? ?? ?? ??"; - - /// - /// Gets or sets the offsets to find the player manager at from the static address. - /// - public int[] PlayerManagerOffsets { get; set; } - = { 6, 0 }; -} \ No newline at end of file diff --git a/Local/NosSmooth.LocalBinding/Options/SceneManagerOptions.cs b/Local/NosSmooth.LocalBinding/Options/SceneManagerOptions.cs deleted file mode 100644 index 80260a665049e67dd1727c58269a03f614e5eca0..0000000000000000000000000000000000000000 --- a/Local/NosSmooth.LocalBinding/Options/SceneManagerOptions.cs +++ /dev/null @@ -1,30 +0,0 @@ -// -// SceneManagerOptions.cs -// -// Copyright (c) František Boháček. All rights reserved. -// Licensed under the MIT license. See LICENSE file in the project root for full license information. - -using NosSmooth.LocalBinding.Structs; - -namespace NosSmooth.LocalBinding.Options; - -/// -/// Options for . -/// -public class SceneManagerOptions -{ - /// - /// Gets or sets the pattern to find the scene manager object at. - /// - /// - /// The address of the object is direct pointer to the scene manager. - /// - public string SceneManagerObjectPattern { get; set; } - = "FF ?? ?? ?? ?? ?? FF FF FF 00 00 00 00 00 00 00 00 00 00 00 00 FF FF FF FF"; - - /// - /// Gets or sets the offsets to find the scene manager at from the static address. - /// - public int[] SceneManagerOffsets { get; set; } - = { 1 }; -} \ No newline at end of file diff --git a/Local/NosSmooth.LocalBinding/Options/UnitManagerBindingOptions.cs b/Local/NosSmooth.LocalBinding/Options/UnitManagerBindingOptions.cs deleted file mode 100644 index e5de2c1f3daea29ee14cc2a49c46f6983f3e48e8..0000000000000000000000000000000000000000 --- a/Local/NosSmooth.LocalBinding/Options/UnitManagerBindingOptions.cs +++ /dev/null @@ -1,38 +0,0 @@ -// -// UnitManagerBindingOptions.cs -// -// Copyright (c) František Boháček. All rights reserved. -// Licensed under the MIT license. See LICENSE file in the project root for full license information. - -using NosSmooth.LocalBinding.Objects; - -namespace NosSmooth.LocalBinding.Options; - -/// -/// Options for . -/// -public class UnitManagerBindingOptions -{ - /// - /// Gets or sets the pattern to static address of unit manager. - /// - public string UnitManagerPattern { get; set; } - = "TODO"; - - /// - /// Gets or sets the pointer offsets from the unit manager static address. - /// - public int[] UnitManagerOffsets { get; set; } - = { 15 }; - - /// - /// Gets or sets the pattern to find the focus entity method at. - /// - public string FocusEntityPattern { get; set; } - = "73 00 00 00 55 8b ec b9 05 00 00 00"; - - /// - /// Gets or sets whether to hook the Focus entity function. - /// - public bool HookFocusEntity { get; set; } = true; -} \ No newline at end of file diff --git a/Local/NosSmooth.LocalBinding/Structs/ControlManager.cs b/Local/NosSmooth.LocalBinding/Structs/ControlManager.cs deleted file mode 100644 index 12ff79be61a8797cd93ac74276ada115df045332..0000000000000000000000000000000000000000 --- a/Local/NosSmooth.LocalBinding/Structs/ControlManager.cs +++ /dev/null @@ -1,78 +0,0 @@ -// -// ControlManager.cs -// -// Copyright (c) František Boháček. All rights reserved. -// Licensed under the MIT license. See LICENSE file in the project root for full license information. - -using Reloaded.Memory.Sources; - -namespace NosSmooth.LocalBinding.Structs; - -/// -/// Base for player and pet managers. -/// -public abstract class ControlManager : NostaleObject -{ - /// - /// Initializes a new instance of the class. - /// - /// The memory. - /// The address of the manager. - protected ControlManager(IMemory memory, IntPtr address) - : base(memory, address) - { - } - - /// - /// Gets the entity this control manager is for. - /// - public abstract MapBaseObj Entity { get; } - - /// - /// Gets the current player position x coordinate. - /// - public int X - { - get - { - Memory.SafeRead(Address + 0x4, out short x); - return x; - } - } - - /// - /// Gets the current player position x coordinate. - /// - public int Y - { - get - { - Memory.SafeRead(Address + 0x6, out short y); - return y; - } - } - - /// - /// Gets the target x coordinate the player is moving to. - /// - public int TargetX - { - get - { - Memory.SafeRead(Address + 0x8, out short targetX); - return targetX; - } - } - - /// - /// Gets the target y coordinate the player is moving to. - /// - public int TargetY - { - get - { - Memory.SafeRead(Address + 0xA, out short targetX); - return targetX; - } - } -} \ No newline at end of file diff --git a/Local/NosSmooth.LocalBinding/Structs/MapBaseObj.cs b/Local/NosSmooth.LocalBinding/Structs/MapBaseObj.cs deleted file mode 100644 index 38ba7c80518d7259b0aaa1c7ad4670ccdc9582fc..0000000000000000000000000000000000000000 --- a/Local/NosSmooth.LocalBinding/Structs/MapBaseObj.cs +++ /dev/null @@ -1,68 +0,0 @@ -// -// MapBaseObj.cs -// -// Copyright (c) František Boháček. All rights reserved. -// Licensed under the MIT license. See LICENSE file in the project root for full license information. - -using Reloaded.Memory.Sources; - -namespace NosSmooth.LocalBinding.Structs; - -/// -/// Base map object. Common for players, monsters, npcs. -/// -public class MapBaseObj : NostaleObject -{ - /// - /// Initializes a new instance of the class. - /// - public MapBaseObj() - { - } - - /// - /// Initializes a new instance of the class. - /// - /// The memory. - /// The map object pointer. - public MapBaseObj(IMemory memory, IntPtr mapObjPointer) - : base(memory, mapObjPointer) - { - } - - /// - /// Gets the id of the entity. - /// - public long Id - { - get - { - Memory.SafeRead(Address + 0x08, out int id); - return id; - } - } - - /// - /// Gets the x coordinate of the entity. - /// - public ushort X - { - get - { - Memory.SafeRead(Address + 0x0C, out ushort x); - return x; - } - } - - /// - /// Gets the y coordinate of the entity. - /// - public ushort Y - { - get - { - Memory.SafeRead(Address + 0x0E, out ushort y); - return y; - } - } -} \ No newline at end of file diff --git a/Local/NosSmooth.LocalBinding/Structs/MapNpcObj.cs b/Local/NosSmooth.LocalBinding/Structs/MapNpcObj.cs deleted file mode 100644 index 80dd8475fd827b8de23625226a4aa3a4f701fd7f..0000000000000000000000000000000000000000 --- a/Local/NosSmooth.LocalBinding/Structs/MapNpcObj.cs +++ /dev/null @@ -1,25 +0,0 @@ -// -// MapNpcObj.cs -// -// Copyright (c) František Boháček. All rights reserved. -// Licensed under the MIT license. See LICENSE file in the project root for full license information. - -using Reloaded.Memory.Sources; - -namespace NosSmooth.LocalBinding.Structs; - -/// -/// Npc NosTale object. -/// -public class MapNpcObj : MapBaseObj -{ - /// - /// Initializes a new instance of the class. - /// - /// The memory. - /// The pointer to the object. - public MapNpcObj(IMemory memory, IntPtr mapObjPointer) - : base(memory, mapObjPointer) - { - } -} \ No newline at end of file diff --git a/Local/NosSmooth.LocalBinding/Structs/MapPlayerObj.cs b/Local/NosSmooth.LocalBinding/Structs/MapPlayerObj.cs deleted file mode 100644 index c4284a5ef7f016dc22da5d7d030a9fcf810c7ef5..0000000000000000000000000000000000000000 --- a/Local/NosSmooth.LocalBinding/Structs/MapPlayerObj.cs +++ /dev/null @@ -1,45 +0,0 @@ -// -// MapPlayerObj.cs -// -// Copyright (c) František Boháček. All rights reserved. -// Licensed under the MIT license. See LICENSE file in the project root for full license information. - -using System.Runtime.InteropServices; -using System.Text; -using Reloaded.Memory.Sources; - -namespace NosSmooth.LocalBinding.Structs; - -/// -/// NosTale Player object. -/// -public class MapPlayerObj : MapBaseObj -{ - private readonly IMemory _memory; - - /// - /// Initializes a new instance of the class. - /// - /// The memory. - /// The player object pointer. - public MapPlayerObj(IMemory memory, IntPtr mapObjPointer) - : base(memory, mapObjPointer) - { - _memory = memory; - } - - /// - /// Gets the name of the player. - /// - public string? Name - { - get - { - _memory.SafeRead(Address + 0x1EC, out int nameAddress); - _memory.SafeRead((IntPtr)nameAddress - 4, out int nameLength); - byte[] data = new byte[nameLength]; - _memory.SafeReadRaw((IntPtr)nameAddress, out data, nameLength); - return Encoding.ASCII.GetString(data); - } - } -} \ No newline at end of file diff --git a/Local/NosSmooth.LocalBinding/Structs/NostaleList.cs b/Local/NosSmooth.LocalBinding/Structs/NostaleList.cs deleted file mode 100644 index 4e914f8cad3fe9a867260f7645c333b8a4d4cc70..0000000000000000000000000000000000000000 --- a/Local/NosSmooth.LocalBinding/Structs/NostaleList.cs +++ /dev/null @@ -1,122 +0,0 @@ -// -// NostaleList.cs -// -// Copyright (c) František Boháček. All rights reserved. -// Licensed under the MIT license. See LICENSE file in the project root for full license information. - -using System.Collections; -using Reloaded.Memory.Pointers; -using Reloaded.Memory.Sources; - -namespace NosSmooth.LocalBinding.Structs; - -/// -/// A class representing a list from nostale. -/// -/// The type. -public class NostaleList : IEnumerable - where T : NostaleObject, new() -{ - private readonly IMemory _memory; - - /// - /// Initializes a new instance of the class. - /// - /// The memory. - /// The object list pointer. - public NostaleList(IMemory memory, IntPtr objListPointer) - { - _memory = memory; - Address = objListPointer; - } - - /// - /// Gets the address. - /// - protected IntPtr Address { get; } - - /// - /// Gets the element at the given index. - /// - /// The index of the element. - /// Thrown if the index is not in the bounds of the array. - public T this[int index] - { - get - { - if (index >= Length || index < 0) - { - throw new IndexOutOfRangeException(); - } - - _memory.SafeRead(Address + 0x04, out int arrayAddress); - _memory.SafeRead((IntPtr)arrayAddress + (0x04 * index), out int objectAddress); - - return new T - { - Memory = _memory, - Address = (IntPtr)objectAddress - }; - } - } - - /// - /// Gets the length of the array. - /// - public int Length - { - get - { - _memory.SafeRead(Address + 0x08, out int length); - return length; - } - } - - /// - public IEnumerator GetEnumerator() - { - return new NostaleListEnumerator(this); - } - - /// - IEnumerator IEnumerable.GetEnumerator() - { - return GetEnumerator(); - } - - private class NostaleListEnumerator : IEnumerator - { - private readonly NostaleList _list; - private int _index; - - public NostaleListEnumerator(NostaleList list) - { - _index = -1; - _list = list; - } - - public bool MoveNext() - { - if (_list.Length > _index + 1) - { - _index++; - return true; - } - - return false; - } - - public void Reset() - { - _index = -1; - } - - public T Current => _list[_index]; - - object IEnumerator.Current => Current; - - public void Dispose() - { - } - } -} \ No newline at end of file diff --git a/Local/NosSmooth.LocalBinding/Structs/NostaleObject.cs b/Local/NosSmooth.LocalBinding/Structs/NostaleObject.cs deleted file mode 100644 index 6f53b8d0f3e6cafa439d1fe0ef857f3a3fc122ce..0000000000000000000000000000000000000000 --- a/Local/NosSmooth.LocalBinding/Structs/NostaleObject.cs +++ /dev/null @@ -1,43 +0,0 @@ -// -// NostaleObject.cs -// -// Copyright (c) František Boháček. All rights reserved. -// Licensed under the MIT license. See LICENSE file in the project root for full license information. - -using Reloaded.Memory.Sources; - -namespace NosSmooth.LocalBinding.Structs; - -/// -/// A NosTale object base. -/// -public abstract class NostaleObject -{ - /// - /// Initializes a new instance of the class. - /// - internal NostaleObject() - { - } - - /// - /// Initializes a new instance of the class. - /// - /// The memory. - /// The address in the memory. - protected NostaleObject(IMemory memory, IntPtr address) - { - Memory = memory; - Address = address; - } - - /// - /// Gets the memory the object is stored in. - /// - internal virtual IMemory Memory { get; set; } = null!; - - /// - /// Gets the address of the object. - /// - public virtual IntPtr Address { get; internal set; } = IntPtr.Zero; -} \ No newline at end of file diff --git a/Local/NosSmooth.LocalBinding/Structs/PetManager.cs b/Local/NosSmooth.LocalBinding/Structs/PetManager.cs deleted file mode 100644 index cd14b0142be44bfd8e6857b6642448f131372788..0000000000000000000000000000000000000000 --- a/Local/NosSmooth.LocalBinding/Structs/PetManager.cs +++ /dev/null @@ -1,51 +0,0 @@ -// -// PetManager.cs -// -// Copyright (c) František Boháček. All rights reserved. -// Licensed under the MIT license. See LICENSE file in the project root for full license information. - -using NosSmooth.LocalBinding.Errors; -using NosSmooth.LocalBinding.Options; -using Reloaded.Memory.Sources; -using Remora.Results; - -namespace NosSmooth.LocalBinding.Structs; - -/// -/// NosTale pet manager. -/// -public class PetManager : ControlManager -{ - /// - /// Initializes a new instance of the class. - /// - public PetManager() - : base(null!, IntPtr.Zero) - { - } - - /// - /// Initializes a new instance of the class. - /// - /// The memory. - /// The pet manager address. - public PetManager(IMemory memory, IntPtr petManagerAddress) - : base(memory, petManagerAddress) - { - } - - /// - /// Gets the player object. - /// - public MapNpcObj Pet - { - get - { - Memory.SafeRead(Address + 0x7C, out int playerAddress); - return new MapNpcObj(Memory, (IntPtr)playerAddress); - } - } - - /// - public override MapBaseObj Entity => Pet; -} \ No newline at end of file diff --git a/Local/NosSmooth.LocalBinding/Structs/PetManagerList.cs b/Local/NosSmooth.LocalBinding/Structs/PetManagerList.cs deleted file mode 100644 index 37e99f3637a90004317b04f18b1675a1b8d5df8c..0000000000000000000000000000000000000000 --- a/Local/NosSmooth.LocalBinding/Structs/PetManagerList.cs +++ /dev/null @@ -1,54 +0,0 @@ -// -// PetManagerList.cs -// -// Copyright (c) František Boháček. All rights reserved. -// Licensed under the MIT license. See LICENSE file in the project root for full license information. - -using NosSmooth.LocalBinding.Errors; -using NosSmooth.LocalBinding.Extensions; -using NosSmooth.LocalBinding.Options; -using Reloaded.Memory.Sources; -using Remora.Results; -using SharpDisasm.Udis86; - -namespace NosSmooth.LocalBinding.Structs; - -/// -/// NosTale list of . -/// -public class PetManagerList : NostaleList -{ - /// - /// Create instance. - /// - /// The NosTale process browser. - /// The options. - /// The player manager or an error. - public static Result Create(NosBrowserManager nosBrowserManager, PetManagerOptions options) - { - var characterObjectAddress = nosBrowserManager.Scanner.CompiledFindPattern(options.PetManagerListPattern); - if (!characterObjectAddress.Found) - { - return new BindingNotFoundError(options.PetManagerListPattern, "PetManagerList"); - } - - if (nosBrowserManager.Process.MainModule is null) - { - return new NotFoundError("Cannot find the main module of the target process."); - } - - int staticManagerAddress = (int)nosBrowserManager.Process.MainModule.BaseAddress + characterObjectAddress.Offset; - return new PetManagerList(nosBrowserManager.Memory, staticManagerAddress, options.PetManagerListOffsets); - } - - /// - /// Initializes a new instance of the class. - /// - /// The memory. - /// The static pet manager address. - /// The offsets to follow to the pet manager list address. - public PetManagerList(IMemory memory, int staticPetManagerListAddress, int[] staticPetManagerOffsets) - : base(memory, memory.FollowStaticAddressOffsets(staticPetManagerListAddress, staticPetManagerOffsets)) - { - } -} \ No newline at end of file diff --git a/Local/NosSmooth.LocalBinding/Structs/PlayerManager.cs b/Local/NosSmooth.LocalBinding/Structs/PlayerManager.cs deleted file mode 100644 index 900bf548c48c6530f21f8a8b131c7b581bd4c0b0..0000000000000000000000000000000000000000 --- a/Local/NosSmooth.LocalBinding/Structs/PlayerManager.cs +++ /dev/null @@ -1,94 +0,0 @@ -// -// PlayerManager.cs -// -// Copyright (c) František Boháček. All rights reserved. -// Licensed under the MIT license. See LICENSE file in the project root for full license information. - -using Microsoft.Extensions.Options; -using NosSmooth.LocalBinding.Errors; -using NosSmooth.LocalBinding.Extensions; -using NosSmooth.LocalBinding.Options; -using Reloaded.Memory.Sources; -using Remora.Results; - -namespace NosSmooth.LocalBinding.Structs; - -/// -/// NosTale player manager. -/// -public class PlayerManager : ControlManager -{ - /// - /// Create instance. - /// - /// The NosTale process browser. - /// The options. - /// The player manager or an error. - public static Result Create(NosBrowserManager nosBrowserManager, PlayerManagerOptions options) - { - var characterObjectAddress = nosBrowserManager.Scanner.CompiledFindPattern(options.PlayerManagerPattern); - if (!characterObjectAddress.Found) - { - return new BindingNotFoundError(options.PlayerManagerPattern, "PlayerManager"); - } - - if (nosBrowserManager.Process.MainModule is null) - { - return new NotFoundError("Cannot find the main module of the target process."); - } - - var staticAddress = (int)nosBrowserManager.Process.MainModule.BaseAddress + characterObjectAddress.Offset; - return new PlayerManager(nosBrowserManager.Memory, staticAddress, options.PlayerManagerOffsets); - } - - private readonly IMemory _memory; - private readonly int _staticPlayerManagerAddress; - private readonly int[] _playerManagerOffsets; - - /// - /// Initializes a new instance of the class. - /// - /// The memory. - /// The pointer to the beginning of the player manager structure. - /// The offsets to get the player manager address from the static one. - public PlayerManager(IMemory memory, int staticPlayerManagerAddress, int[] playerManagerOffsets) - : base(memory, IntPtr.Zero) - { - _memory = memory; - _staticPlayerManagerAddress = staticPlayerManagerAddress; - _playerManagerOffsets = playerManagerOffsets; - } - - /// - /// Gets the address to the player manager. - /// - public override IntPtr Address => _memory.FollowStaticAddressOffsets - (_staticPlayerManagerAddress, _playerManagerOffsets); - - /// - /// Gets the player object. - /// - public MapPlayerObj Player - { - get - { - _memory.SafeRead(Address + 0x20, out int playerAddress); - return new MapPlayerObj(_memory, (IntPtr)playerAddress); - } - } - - /// - /// Gets the player id. - /// - public int PlayerId - { - get - { - _memory.SafeRead(Address + 0x24, out int playerId); - return playerId; - } - } - - /// - public override MapBaseObj Entity => Player; -} \ No newline at end of file diff --git a/Local/NosSmooth.LocalBinding/Structs/SceneManager.cs b/Local/NosSmooth.LocalBinding/Structs/SceneManager.cs deleted file mode 100644 index 6e334290bcb6b95c0dae5decf5d78bc4cb0439ea..0000000000000000000000000000000000000000 --- a/Local/NosSmooth.LocalBinding/Structs/SceneManager.cs +++ /dev/null @@ -1,160 +0,0 @@ -// -// SceneManager.cs -// -// Copyright (c) František Boháček. All rights reserved. -// Licensed under the MIT license. See LICENSE file in the project root for full license information. - -using NosSmooth.LocalBinding.Errors; -using NosSmooth.LocalBinding.Extensions; -using NosSmooth.LocalBinding.Options; -using Reloaded.Memory.Sources; -using Remora.Results; - -namespace NosSmooth.LocalBinding.Structs; - -/// -/// Represents nostale scene manager struct. -/// -public class SceneManager -{ - /// - /// Create instance. - /// - /// The NosTale process browser. - /// The options. - /// The player manager or an error. - public static Result Create(NosBrowserManager nosBrowserManager, SceneManagerOptions options) - { - var characterObjectAddress = nosBrowserManager.Scanner.CompiledFindPattern(options.SceneManagerObjectPattern); - if (!characterObjectAddress.Found) - { - return new BindingNotFoundError(options.SceneManagerObjectPattern, "SceneManager"); - } - - if (nosBrowserManager.Process.MainModule is null) - { - return new NotFoundError("Cannot find the main module of the target process."); - } - - int staticManagerAddress = (int)nosBrowserManager.Process.MainModule.BaseAddress + characterObjectAddress.Offset; - return new SceneManager(nosBrowserManager.Memory, staticManagerAddress, options.SceneManagerOffsets); - } - - private readonly int[] _sceneManagerOffsets; - private readonly IMemory _memory; - private readonly int _staticSceneManagerAddress; - - /// - /// Initializes a new instance of the class. - /// - /// The memory. - /// The pointer to the scene manager. - /// The offsets from the static scene manager address. - public SceneManager(IMemory memory, int staticSceneManagerAddress, int[] sceneManagerOffsets) - { - _memory = memory; - _staticSceneManagerAddress = staticSceneManagerAddress; - _sceneManagerOffsets = sceneManagerOffsets; - } - - /// - /// Gets the address of the scene manager. - /// - public IntPtr Address => _memory.FollowStaticAddressOffsets(_staticSceneManagerAddress, _sceneManagerOffsets); - - /// - /// Gets the player list. - /// - public NostaleList PlayerList => new NostaleList(_memory, ReadPtr(Address + 0xC)); - - /// - /// Gets the monster list. - /// - public NostaleList MonsterList => new NostaleList(_memory, ReadPtr(Address + 0x10)); - - /// - /// Gets the npc list. - /// - public NostaleList NpcList => new NostaleList(_memory, ReadPtr(Address + 0x14)); - - /// - /// Gets the item list. - /// - public NostaleList ItemList => new NostaleList(_memory, ReadPtr(Address + 0x18)); - - /// - /// Gets the entity that is currently being followed by the player. - /// - public MapBaseObj? FollowEntity - { - get - { - var ptr = ReadPtr(Address + 0x48); - if (ptr == IntPtr.Zero) - { - return null; - } - - return new MapBaseObj(_memory, ptr); - } - } - - /// - /// Gets the lock on target marked address. - /// - public IntPtr LockOnTargetMarkedAddress - { - get - { - var ptr = ReadPtr(Address + 0x1C); - ptr = ReadPtr(ptr + 0x04); - ptr = ReadPtr(ptr + 0x00); - return ptr; - } - } - - private IntPtr ReadPtr(IntPtr ptr) - { - _memory.Read(ptr, out int read); - return (IntPtr)read; - } - - /// - /// Find the given entity address. - /// - /// The id of the entity. - /// The pointer to the entity or an error. - public Result FindEntity(int id) - { - if (id == 0) - { - return Result.FromSuccess(null); - } - - var item = ItemList.FirstOrDefault(x => x.Id == id); - if (item is not null) - { - return item; - } - - var monster = MonsterList.FirstOrDefault(x => x.Id == id); - if (monster is not null) - { - return monster; - } - - var npc = NpcList.FirstOrDefault(x => x.Id == id); - if (npc is not null) - { - return npc; - } - - var player = PlayerList.FirstOrDefault(x => x.Id == id); - if (player is not null) - { - return player; - } - - return new NotFoundError($"Could not find entity with id {id}"); - } -} \ No newline at end of file diff --git a/Local/NosSmooth.LocalClient/CommandHandlers/Walk/ControlCommandWalkHandler.cs b/Local/NosSmooth.LocalClient/CommandHandlers/Walk/ControlCommandWalkHandler.cs deleted file mode 100644 index 4c88abd60b84788cb67992c0b24ae64e2386356c..0000000000000000000000000000000000000000 --- a/Local/NosSmooth.LocalClient/CommandHandlers/Walk/ControlCommandWalkHandler.cs +++ /dev/null @@ -1,145 +0,0 @@ -// -// ControlCommandWalkHandler.cs -// -// Copyright (c) František Boháček. All rights reserved. -// Licensed under the MIT license. See LICENSE file in the project root for full license information. - -using NosSmooth.Core.Client; -using NosSmooth.Core.Commands.Control; -using NosSmooth.Core.Commands.Walking; -using NosSmooth.Core.Extensions; -using NosSmooth.LocalBinding.Structs; -using NosSmooth.LocalClient.CommandHandlers.Walk.Errors; -using Remora.Results; - -namespace NosSmooth.LocalClient.CommandHandlers.Walk; - -/// -/// Handler for control manager walk command. -/// -internal class ControlCommandWalkHandler -{ - private readonly INostaleClient _nostaleClient; - private readonly Func> _walkFunction; - private readonly ControlManager _controlManager; - private readonly WalkCommandHandlerOptions _options; - - private ushort _x; - private ushort _y; - - /// - /// Initializes a new instance of the class. - /// - /// The nostale client. - /// The walk function. - /// The control manager. - /// The options. - public ControlCommandWalkHandler - ( - INostaleClient nostaleClient, - Func> walkFunction, - ControlManager controlManager, - WalkCommandHandlerOptions options - ) - { - _nostaleClient = nostaleClient; - _walkFunction = walkFunction; - _controlManager = controlManager; - _options = options; - } - - /// - /// Handle walk take control command. - /// - /// The x coordinate. - /// The y coordinate. - /// The take control command. - /// The name of the take control group. - /// The cancellation token for cancelling the operation. - /// A representing the result of the asynchronous operation. - public async Task HandleCommand(ushort x, ushort y, ITakeControlCommand command, string groupName, CancellationToken ct = default) - { - _x = x; - _y = y; - - using CancellationTokenSource linked = CancellationTokenSource.CreateLinkedTokenSource(ct); - WalkUnfinishedReason? reason = null; - var takeControlCommand = command.CreateTakeControl - ( - groupName, - WalkGrantedCallback, - (r) => - { - reason = r switch - { - ControlCancelReason.AnotherTask => WalkUnfinishedReason.AnotherTask, - ControlCancelReason.UserAction => WalkUnfinishedReason.UserAction, - _ => WalkUnfinishedReason.Unknown - }; - return Task.FromResult(Result.FromSuccess()); - } - ); - - var commandResult = await _nostaleClient.SendCommandAsync(takeControlCommand, ct); - if (!commandResult.IsSuccess) - { - return commandResult; - } - - if (reason is null && !IsAt(x, y)) - { - reason = WalkUnfinishedReason.PathNotFound; - } - - if (reason is null) - { - return Result.FromSuccess(); - } - - return new WalkNotFinishedError - ( - _controlManager.X, - _controlManager.Y, - (WalkUnfinishedReason)reason - ); - } - - private bool IsAtTarget() - { - return _controlManager.TargetX == _controlManager.Entity.X - && _controlManager.TargetY == _controlManager.Entity.Y; - } - - private bool IsAt(ushort x, ushort y) - { - return _controlManager.Entity.X == x && _controlManager.Entity.Y == y; - } - - private async Task WalkGrantedCallback(CancellationToken ct) - { - var result = _walkFunction(_x, _y); - if (!result.IsSuccess) - { - return Result.FromError(result); - } - - while (!ct.IsCancellationRequested) - { - try - { - await Task.Delay(_options.CheckDelay, ct); - } - catch - { - // ignored - } - - if (IsAtTarget() || IsAt(_x, _y)) - { - return Result.FromSuccess(); - } - } - - return Result.FromSuccess(); // cancellation is handled in cancellation callback. - } -} \ No newline at end of file diff --git a/Local/NosSmooth.LocalClient/CommandHandlers/Walk/Errors/WalkNotFinishedError.cs b/Local/NosSmooth.LocalClient/CommandHandlers/Walk/Errors/WalkNotFinishedError.cs deleted file mode 100644 index 72cd86133309f7917de4df1127620e0b302bc8ec..0000000000000000000000000000000000000000 --- a/Local/NosSmooth.LocalClient/CommandHandlers/Walk/Errors/WalkNotFinishedError.cs +++ /dev/null @@ -1,18 +0,0 @@ -// -// WalkNotFinishedError.cs -// -// Copyright (c) František Boháček. All rights reserved. -// Licensed under the MIT license. See LICENSE file in the project root for full license information. - -using Remora.Results; - -namespace NosSmooth.LocalClient.CommandHandlers.Walk.Errors; - -/// -/// Represents an error that can be returned from walk command handler. -/// -/// The x coordinate where the player is. (if known) -/// The y coordinate where the player is. (if known) -/// -public record WalkNotFinishedError(int? X, int? Y, WalkUnfinishedReason Reason) - : ResultError($"Could not finish the walk to {X} {Y}, because {Reason}"); \ No newline at end of file diff --git a/Local/NosSmooth.LocalClient/CommandHandlers/Walk/PetWalkCommandHandler.cs b/Local/NosSmooth.LocalClient/CommandHandlers/Walk/PetWalkCommandHandler.cs deleted file mode 100644 index 7fe1083c79b5f7dd8587fe0b6d55c76f7372fb3e..0000000000000000000000000000000000000000 --- a/Local/NosSmooth.LocalClient/CommandHandlers/Walk/PetWalkCommandHandler.cs +++ /dev/null @@ -1,75 +0,0 @@ -// -// PetWalkCommandHandler.cs -// -// Copyright (c) František Boháček. All rights reserved. -// Licensed under the MIT license. See LICENSE file in the project root for full license information. - -using Microsoft.Extensions.Options; -using NosSmooth.Core.Client; -using NosSmooth.Core.Commands; -using NosSmooth.Core.Commands.Control; -using NosSmooth.Core.Commands.Walking; -using NosSmooth.LocalBinding.Objects; -using Remora.Results; - -namespace NosSmooth.LocalClient.CommandHandlers.Walk; - -/// -/// Handles . -/// -public class PetWalkCommandHandler : ICommandHandler -{ - /// - /// Group that is used for . - /// - public const string PetWalkControlGroup = "PetWalk"; - - private readonly PetManagerBinding _petManagerBinding; - private readonly INostaleClient _nostaleClient; - private readonly WalkCommandHandlerOptions _options; - - /// - /// Initializes a new instance of the class. - /// - /// The character object binding. - /// The nostale client. - /// The options. - public PetWalkCommandHandler - ( - PetManagerBinding petManagerBinding, - INostaleClient nostaleClient, - IOptions options - ) - { - _options = options.Value; - _petManagerBinding = petManagerBinding; - _nostaleClient = nostaleClient; - } - - /// - public async Task HandleCommand(PetWalkCommand command, CancellationToken ct = default) - { - if (_petManagerBinding.PetManagerList.Length < command.PetSelector + 1) - { - return new NotFoundError("Could not find the pet using the given selector."); - } - var petManager = _petManagerBinding.PetManagerList[command.PetSelector]; - - var handler = new ControlCommandWalkHandler - ( - _nostaleClient, - (x, y) => _petManagerBinding.PetWalk(command.PetSelector, x, y), - petManager, - _options - ); - - return await handler.HandleCommand - ( - command.TargetX, - command.TargetY, - command, - PetWalkControlGroup + "_" + command.PetSelector, - ct - ); - } -} \ No newline at end of file diff --git a/Local/NosSmooth.LocalClient/CommandHandlers/Walk/PlayerWalkCommandHandler.cs b/Local/NosSmooth.LocalClient/CommandHandlers/Walk/PlayerWalkCommandHandler.cs deleted file mode 100644 index 2c0b2dc0ce7cf4f43e0647cb1c0a03d249f81336..0000000000000000000000000000000000000000 --- a/Local/NosSmooth.LocalClient/CommandHandlers/Walk/PlayerWalkCommandHandler.cs +++ /dev/null @@ -1,71 +0,0 @@ -// -// PlayerWalkCommandHandler.cs -// -// Copyright (c) František Boháček. All rights reserved. -// Licensed under the MIT license. See LICENSE file in the project root for full license information. - -using Microsoft.Extensions.Options; -using NosSmooth.Core.Client; -using NosSmooth.Core.Commands; -using NosSmooth.Core.Commands.Control; -using NosSmooth.Core.Commands.Walking; -using NosSmooth.Core.Extensions; -using NosSmooth.LocalBinding.Objects; -using NosSmooth.LocalClient.CommandHandlers.Walk.Errors; -using Remora.Results; - -namespace NosSmooth.LocalClient.CommandHandlers.Walk; - -/// -/// Handles . -/// -public class PlayerWalkCommandHandler : ICommandHandler -{ - /// - /// Group that is used for . - /// - public const string PlayerWalkControlGroup = "PlayerWalk"; - - private readonly PlayerManagerBinding _playerManagerBinding; - private readonly INostaleClient _nostaleClient; - private readonly WalkCommandHandlerOptions _options; - - /// - /// Initializes a new instance of the class. - /// - /// The character object binding. - /// The nostale client. - /// The options. - public PlayerWalkCommandHandler - ( - PlayerManagerBinding playerManagerBinding, - INostaleClient nostaleClient, - IOptions options - ) - { - _options = options.Value; - _playerManagerBinding = playerManagerBinding; - _nostaleClient = nostaleClient; - } - - /// - public async Task HandleCommand(PlayerWalkCommand command, CancellationToken ct = default) - { - var handler = new ControlCommandWalkHandler - ( - _nostaleClient, - (x, y) => _playerManagerBinding.Walk(x, y), - _playerManagerBinding.PlayerManager, - _options - ); - - return await handler.HandleCommand - ( - command.TargetX, - command.TargetY, - command, - PlayerWalkControlGroup, - ct - ); - } -} \ No newline at end of file diff --git a/Local/NosSmooth.LocalClient/CommandHandlers/Walk/WalkCommandHandlerOptions.cs b/Local/NosSmooth.LocalClient/CommandHandlers/Walk/WalkCommandHandlerOptions.cs deleted file mode 100644 index 4acc353d97d68a5c10f7177bc762fcbf14d2504f..0000000000000000000000000000000000000000 --- a/Local/NosSmooth.LocalClient/CommandHandlers/Walk/WalkCommandHandlerOptions.cs +++ /dev/null @@ -1,23 +0,0 @@ -// -// WalkCommandHandlerOptions.cs -// -// Copyright (c) František Boháček. All rights reserved. -// Licensed under the MIT license. See LICENSE file in the project root for full license information. - -namespace NosSmooth.LocalClient.CommandHandlers.Walk -{ - /// - /// Options for . - /// - public class WalkCommandHandlerOptions - { - /// - /// The command handler sleeps for this duration, then checks for new info. Unit is milliseconds. - /// - /// - /// The operation is done with a cancellation token, if there is an outer event, then it can be faster. - /// Walk function is called again as well after this delay. - /// - public int CheckDelay { get; set; } = 50; - } -} diff --git a/Local/NosSmooth.LocalClient/CommandHandlers/Walk/WalkUnfinishedReason.cs b/Local/NosSmooth.LocalClient/CommandHandlers/Walk/WalkUnfinishedReason.cs deleted file mode 100644 index 51e228e6862c83b888eb783f171da97953276c83..0000000000000000000000000000000000000000 --- a/Local/NosSmooth.LocalClient/CommandHandlers/Walk/WalkUnfinishedReason.cs +++ /dev/null @@ -1,36 +0,0 @@ -// -// WalkUnfinishedReason.cs -// -// Copyright (c) František Boháček. All rights reserved. -// Licensed under the MIT license. See LICENSE file in the project root for full license information. - -namespace NosSmooth.LocalClient.CommandHandlers.Walk; - -/// -/// Reason for not finishing a walk. -/// -public enum WalkUnfinishedReason -{ - /// - /// There was an unknown unfinished reason. - /// - Unknown, - - /// - /// The client could not find path to the given location. - /// - /// - /// The user walked just some part of the path. - /// - PathNotFound, - - /// - /// The user has took an action that has cancelled the walk. - /// - UserAction, - - /// - /// There was another walk action that cancelled this one. - /// - AnotherTask -} \ No newline at end of file diff --git a/Local/NosSmooth.LocalClient/Extensions/ServiceCollectionExtensions.cs b/Local/NosSmooth.LocalClient/Extensions/ServiceCollectionExtensions.cs deleted file mode 100644 index a2b94f743c6373cc44424fddb2c29b17441fa023..0000000000000000000000000000000000000000 --- a/Local/NosSmooth.LocalClient/Extensions/ServiceCollectionExtensions.cs +++ /dev/null @@ -1,51 +0,0 @@ -// -// ServiceCollectionExtensions.cs -// -// Copyright (c) František Boháček. All rights reserved. -// Licensed under the MIT license. See LICENSE file in the project root for full license information. - -using Microsoft.Extensions.DependencyInjection; -using Microsoft.Extensions.DependencyInjection.Extensions; -using NosSmooth.Core.Client; -using NosSmooth.Core.Extensions; -using NosSmooth.LocalBinding.Extensions; -using NosSmooth.LocalClient.CommandHandlers.Walk; - -namespace NosSmooth.LocalClient.Extensions; - -/// -/// Contains extension methods for . -/// -public static class ServiceCollectionExtensions -{ - /// - /// Adds along with all core dependencies. - /// - /// The service collection. - /// The collection. - public static IServiceCollection AddLocalClient(this IServiceCollection serviceCollection) - { - serviceCollection.AddNostaleCore(); - serviceCollection.AddNostaleBindings(); - serviceCollection - .AddTakeControlCommand() - .AddCommandHandler() - .AddCommandHandler(); - serviceCollection.TryAddSingleton(); - serviceCollection.TryAddSingleton(p => p.GetRequiredService()); - - return serviceCollection; - } - - /// - /// Adds packet interceptor. - /// - /// The service collection. - /// The type of the interceptor. - /// The collection. - public static IServiceCollection AddPacketInterceptor(this IServiceCollection serviceCollection) - where TInterceptor : class, IPacketInterceptor - { - return serviceCollection.AddSingleton(); - } -} \ No newline at end of file diff --git a/Local/NosSmooth.LocalClient/IPacketInterceptor.cs b/Local/NosSmooth.LocalClient/IPacketInterceptor.cs deleted file mode 100644 index c31a6be2c3c6876363663d1850d0adffcb818bb2..0000000000000000000000000000000000000000 --- a/Local/NosSmooth.LocalClient/IPacketInterceptor.cs +++ /dev/null @@ -1,28 +0,0 @@ -// -// IPacketInterceptor.cs -// -// Copyright (c) František Boháček. All rights reserved. -// Licensed under the MIT license. See LICENSE file in the project root for full license information. - -namespace NosSmooth.LocalClient; - -/// -/// Used for intercepting packet communication, -/// changing the contents of the packets and/or cancelling them altogether. -/// -public interface IPacketInterceptor -{ - /// - /// Intercept the given packet. - /// - /// The packet itself, if it is changed, the modified packet will be sent. - /// Whether to send the packet to the server. - public bool InterceptSend(ref string packet); - - /// - /// Intercept the given packet. - /// - /// The packet itself, if it is changed, the modified packet will be received. - /// Whether to receive the packet by the client. - public bool InterceptReceive(ref string packet); -} \ No newline at end of file diff --git a/Local/NosSmooth.LocalClient/IsExternalInit.cs b/Local/NosSmooth.LocalClient/IsExternalInit.cs deleted file mode 100644 index 7c63200cfae2cfd2a9607d18344f77c095a28e9d..0000000000000000000000000000000000000000 --- a/Local/NosSmooth.LocalClient/IsExternalInit.cs +++ /dev/null @@ -1,15 +0,0 @@ -// -// IsExternalInit.cs -// -// Copyright (c) František Boháček. All rights reserved. -// Licensed under the MIT license. See LICENSE file in the project root for full license information. - -namespace System.Runtime.CompilerServices -{ - /// - /// Dummy. - /// - public class IsExternalInit - { - } -} \ No newline at end of file diff --git a/Local/NosSmooth.LocalClient/LocalClientOptions.cs b/Local/NosSmooth.LocalClient/LocalClientOptions.cs deleted file mode 100644 index cacf7cbee3f7737d39b7a34c8d4ffe4e2d7a5b92..0000000000000000000000000000000000000000 --- a/Local/NosSmooth.LocalClient/LocalClientOptions.cs +++ /dev/null @@ -1,18 +0,0 @@ -// -// LocalClientOptions.cs -// -// Copyright (c) František Boháček. All rights reserved. -// Licensed under the MIT license. See LICENSE file in the project root for full license information. - -namespace NosSmooth.LocalClient; - -/// -/// Options for . -/// -public class LocalClientOptions -{ - /// - /// Gets or sets whether the interception of packets should be allowed. - /// - public bool AllowIntercept { get; set; } -} \ No newline at end of file diff --git a/Local/NosSmooth.LocalClient/NosSmooth.LocalClient.csproj b/Local/NosSmooth.LocalClient/NosSmooth.LocalClient.csproj deleted file mode 100644 index b3fe80dc4c48b4d05ae6087faec63796f65c76b0..0000000000000000000000000000000000000000 --- a/Local/NosSmooth.LocalClient/NosSmooth.LocalClient.csproj +++ /dev/null @@ -1,21 +0,0 @@ - - - - enable - enable - 10 - net6.0;netstandard2.1 - - - - - - - - - - - - - - diff --git a/Local/NosSmooth.LocalClient/NostaleLocalClient.cs b/Local/NosSmooth.LocalClient/NostaleLocalClient.cs deleted file mode 100644 index 99cbd2940d5fbdeb6c372db65b140c6d282bb95c..0000000000000000000000000000000000000000 --- a/Local/NosSmooth.LocalClient/NostaleLocalClient.cs +++ /dev/null @@ -1,216 +0,0 @@ -// -// NostaleLocalClient.cs -// -// Copyright (c) František Boháček. All rights reserved. -// Licensed under the MIT license. See LICENSE file in the project root for full license information. - -using Microsoft.Extensions.DependencyInjection; -using Microsoft.Extensions.Logging; -using Microsoft.Extensions.Options; -using NosSmooth.Core.Client; -using NosSmooth.Core.Commands; -using NosSmooth.Core.Commands.Control; -using NosSmooth.Core.Extensions; -using NosSmooth.Core.Packets; -using NosSmooth.LocalBinding.Objects; -using NosSmooth.LocalBinding.Structs; -using NosSmooth.Packets; -using NosSmooth.Packets.Errors; -using NosSmooth.PacketSerializer.Abstractions.Attributes; -using Remora.Results; - -namespace NosSmooth.LocalClient; - -/// -/// The local nostale client. -/// -/// -/// Client used for living in the same process as NostaleClientX.exe. -/// It hooks the send and receive packet methods. -/// -public class NostaleLocalClient : BaseNostaleClient -{ - private readonly NetworkBinding _networkBinding; - private readonly PlayerManagerBinding _playerManagerBinding; - private readonly ControlCommands _controlCommands; - private readonly IPacketSerializer _packetSerializer; - private readonly IPacketHandler _packetHandler; - private readonly ILogger _logger; - private readonly IServiceProvider _provider; - private readonly LocalClientOptions _options; - private CancellationToken? _stopRequested; - private IPacketInterceptor? _interceptor; - - /// - /// Initializes a new instance of the class. - /// - /// The network binding. - /// The player manager binding. - /// The control commands. - /// The command processor. - /// The packet serializer. - /// The packet handler. - /// The logger. - /// The options for the client. - /// The dependency injection provider. - public NostaleLocalClient - ( - NetworkBinding networkBinding, - PlayerManagerBinding playerManagerBinding, - ControlCommands controlCommands, - CommandProcessor commandProcessor, - IPacketSerializer packetSerializer, - IPacketHandler packetHandler, - ILogger logger, - IOptions options, - IServiceProvider provider - ) - : base(commandProcessor, packetSerializer) - { - _options = options.Value; - _networkBinding = networkBinding; - _playerManagerBinding = playerManagerBinding; - _controlCommands = controlCommands; - _packetSerializer = packetSerializer; - _packetHandler = packetHandler; - _logger = logger; - _provider = provider; - } - - /// - public override async Task RunAsync(CancellationToken stopRequested = default) - { - _stopRequested = stopRequested; - _logger.LogInformation("Starting local client"); - _networkBinding.PacketSend += SendCallback; - _networkBinding.PacketReceive += ReceiveCallback; - - _playerManagerBinding.FollowEntityCall += FollowEntity; - _playerManagerBinding.WalkCall += Walk; - - try - { - await Task.Delay(-1, stopRequested); - } - catch - { - // ignored - } - - _networkBinding.PacketSend -= SendCallback; - _networkBinding.PacketReceive -= ReceiveCallback; - _playerManagerBinding.FollowEntityCall -= FollowEntity; - _playerManagerBinding.WalkCall -= Walk; - - return Result.FromSuccess(); - } - - /// - public override Task ReceivePacketAsync(string packetString, CancellationToken ct = default) - { - ReceivePacket(packetString); - return Task.FromResult(Result.FromSuccess()); - } - - /// - public override Task SendPacketAsync(string packetString, CancellationToken ct = default) - { - SendPacket(packetString); - return Task.FromResult(Result.FromSuccess()); - } - - private bool ReceiveCallback(string packet) - { - bool accepted = true; - if (_options.AllowIntercept) - { - if (_interceptor is null) - { - _interceptor = _provider.GetRequiredService(); - } - - accepted = _interceptor.InterceptReceive(ref packet); - } - - Task.Run(async () => await ProcessPacketAsync(PacketSource.Server, packet)); - - return accepted; - } - - private bool SendCallback(string packet) - { - bool accepted = true; - if (_options.AllowIntercept) - { - if (_interceptor is null) - { - _interceptor = _provider.GetRequiredService(); - } - - accepted = _interceptor.InterceptSend(ref packet); - } - - Task.Run(async () => await ProcessPacketAsync(PacketSource.Client, packet)); - - return accepted; - } - - private void SendPacket(string packetString) - { - _networkBinding.SendPacket(packetString); - _logger.LogDebug($"Sending client packet {packetString}"); - } - - private void ReceivePacket(string packetString) - { - _networkBinding.ReceivePacket(packetString); - _logger.LogDebug($"Receiving client packet {packetString}"); - } - - private async Task ProcessPacketAsync(PacketSource type, string packetString) - { - var packet = _packetSerializer.Deserialize(packetString, type); - if (!packet.IsSuccess) - { - if (packet.Error is not PacketConverterNotFoundError) - { - _logger.LogWarning("Could not parse {Packet}. Reason:", packetString); - _logger.LogResultError(packet); - } - - packet = new ParsingFailedPacket(packet, packetString); - } - - Result result; - if (type == PacketSource.Server) - { - result = await _packetHandler.HandleReceivedPacketAsync - (packet.Entity, packetString, _stopRequested ?? default); - } - else - { - result = await _packetHandler.HandleSentPacketAsync(packet.Entity, packetString, _stopRequested ?? default); - } - - if (!result.IsSuccess) - { - _logger.LogError("There was an error whilst handling packet"); - _logger.LogResultError(result); - } - } - - private bool FollowEntity(MapBaseObj? obj) - { - Task.Run - ( - async () => await _controlCommands.CancelAsync - (ControlCommandsFilter.UserCancellable, false, (CancellationToken)_stopRequested!) - ); - return true; - } - - private bool Walk(ushort x, ushort y) - { - return _controlCommands.AllowUserActions; - } -} \ No newline at end of file diff --git a/Local/NosSmooth.LocalClient/NostaleWindow.cs b/Local/NosSmooth.LocalClient/NostaleWindow.cs deleted file mode 100644 index f5e5b78ec7ec65fd11cb5af210a750ddacc22013..0000000000000000000000000000000000000000 --- a/Local/NosSmooth.LocalClient/NostaleWindow.cs +++ /dev/null @@ -1,58 +0,0 @@ -// -// NostaleWindow.cs -// -// Copyright (c) František Boháček. All rights reserved. -// Licensed under the MIT license. See LICENSE file in the project root for full license information. - -using NosSmooth.LocalClient.Utils; - -namespace NosSmooth.LocalClient; - -/// -/// Represents window of nostale client. -/// -public class NostaleWindow -{ - private const int WM_KEYDOWN = 0x0100; - private const int WM_KEYUP = 0x0101; - private const int WM_CHAR = 0x0102; - - /// - /// Initializes a new instance of the class. - /// - /// The handle of the window. - public NostaleWindow(IntPtr handle) => Handle = handle; - - /// - /// Gets the window handle. - /// - public IntPtr Handle { get; } - - /// - /// Changes the title of the window. - /// - /// The new name of the window. - public void Rename(string name) - { - User32.SetWindowText(Handle, name); - } - - /// - /// Bring the window to front. - /// - public void BringToFront() - { - User32.SetForegroundWindow(Handle); - } - - /// - /// Send the given key to the window. - /// - /// The id of the key. - public void SendKey(uint key) - { - User32.PostMessage(Handle, WM_KEYDOWN, key, 0); - User32.PostMessage(Handle, WM_CHAR, key, 0); - User32.PostMessage(Handle, WM_KEYUP, key, 0); - } -} \ No newline at end of file diff --git a/Local/NosSmooth.LocalClient/Utils/User32.cs b/Local/NosSmooth.LocalClient/Utils/User32.cs deleted file mode 100644 index fec527a17e13a664b0d71fe297905e5ca787f188..0000000000000000000000000000000000000000 --- a/Local/NosSmooth.LocalClient/Utils/User32.cs +++ /dev/null @@ -1,88 +0,0 @@ -// -// User32.cs -// -// Copyright (c) František Boháček. All rights reserved. -// Licensed under the MIT license. See LICENSE file in the project root for full license information. - -using System.Diagnostics.CodeAnalysis; -using System.Runtime.InteropServices; -using System.Text; -#pragma warning disable CS1591 - -namespace NosSmooth.LocalClient.Utils; - -/// -/// Represents class with extern calls to user32.dll. -/// -[SuppressMessage("StyleCop.CSharp.DocumentationRules", "SA1600", MessageId = "Elements should be documented", Justification = "user32.dll methods do not need documentation, it can be found on msdn.")] -public class User32 -{ - public delegate bool EnumWindowsProc(IntPtr hWnd, IntPtr lParam); - - [DllImport("user32.dll")] - public static extern int PostMessage(IntPtr hWnd, int uMsg, uint wParam, uint lParam); - - [DllImport("user32.dll")] - public static extern IntPtr FindWindow(string lpClassName, string lpWindowName); - - [DllImport("user32.dll")] - public static extern bool SetForegroundWindow(IntPtr hWnd); - - [DllImport("user32.dll")] - public static extern bool SetWindowText(IntPtr hWnd, string text); - - [DllImport("user32.dll")] - public static extern int EnumWindows(EnumWindowsProc callback, IntPtr lParam); - - [DllImport("user32.dll")] - public static extern int GetWindowText(IntPtr hWnd, StringBuilder text, int count); - - [DllImport("user32.dll", CharSet = CharSet.Unicode)] - public static extern int GetWindowTextLength(IntPtr hWnd); - - [DllImport("user32.dll")] - public static extern uint GetWindowThreadProcessId(IntPtr hWnd, out uint processId); - - /// - /// Finds all windows with the given title matching. - /// - /// The title to match. - /// The matched windows. - public static IEnumerable FindWindowsWithTitle(string title) - { - var windows = new List(); - EnumWindows( - (hWnd, lParam) => - { - string windowTitle = GetWindowTitle(hWnd); - if (windowTitle.Equals(title)) - { - windows.Add(hWnd); - } - - return true; - }, - IntPtr.Zero - ); - - return windows; - } - - /// - /// Returns the title of a window. - /// - /// The handle of the window. - /// The title of the window. - public static string GetWindowTitle(IntPtr hWnd) - { - int size = GetWindowTextLength(hWnd); - if (size == 0) - { - return string.Empty; - } - - var sb = new StringBuilder(size + 1); - GetWindowText(hWnd, sb, sb.Capacity); - return sb.ToString(); - } -} \ No newline at end of file diff --git a/NosSmooth.Unix.sln b/NosSmooth.Unix.sln deleted file mode 100644 index ac9e81f554074656b441d9aee4e2273555ca4e3d..0000000000000000000000000000000000000000 --- a/NosSmooth.Unix.sln +++ /dev/null @@ -1,191 +0,0 @@ - -Microsoft Visual Studio Solution File, Format Version 12.00 -# Visual Studio Version 17 -VisualStudioVersion = 17.0.32014.148 -MinimumVisualStudioVersion = 10.0.40219.1 -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "NosSmooth.Core", "Core\NosSmooth.Core\NosSmooth.Core.csproj", "{8CCDB0CD-DFB2-492E-B1A2-8DD030F923D3}" -EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "NosSmooth.Game", "Core\NosSmooth.Game\NosSmooth.Game.csproj", "{19666500-4636-4400-8855-496317F4A7F7}" -EndProject -Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Samples", "Samples", "{F20FE754-FDEA-4F3A-93D4-0750CB9EBB33}" -EndProject -Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Remote", "Remote", "{F9EFA63C-0A88-45EB-B36F-C4A9D63BDFD1}" -EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "NosSmooth.Cryptography", "Remote\NosSmooth.Cryptography\NosSmooth.Cryptography.csproj", "{05E3039D-EDF6-4CDC-B062-CB67760ACB5F}" -EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "NosSmooth.Language", "Core\NosSmooth.Language\NosSmooth.Language.csproj", "{06F03B1F-F68A-4C5B-B7FE-128A7CE1A1D7}" -EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "NosSmooth.Extensions", "Core\NosSmooth.Extensions\NosSmooth.Extensions.csproj", "{B6C23EA5-55FE-436A-96EA-FE2974C5881D}" -EndProject -Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Core", "Core", "{01B5E872-271F-4D30-A1AA-AD48D81840C5}" -EndProject -Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = ".metadata", ".metadata", "{FA63BCED-9D81-4FF7-BA75-A6F3BA31ECDE}" - ProjectSection(SolutionItems) = preProject - Directory.Build.props = Directory.Build.props - stylecop.ruleset = stylecop.ruleset - stylecop.json = stylecop.json - EndProjectSection -EndProject -Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Tests", "Tests", "{C6A8760D-92CB-4307-88A7-36CCAEBA4AD1}" -EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "NosSmooth.Packets.Tests", "Tests\NosSmooth.Packets.Tests\NosSmooth.Packets.Tests.csproj", "{CE7EE14A-BCC5-4A8B-8D9F-403BF09BD99A}" -EndProject -Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Packets", "Packets", "{1EBECD64-77C3-4D5B-BAD1-C2803E2FBD5E}" -EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "NosSmooth.Packets", "Packets\NosSmooth.Packets\NosSmooth.Packets.csproj", "{583D3651-E13F-481F-A9D9-A093DFCDB10F}" -EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "NosSmooth.PacketSerializer", "Packets\NosSmooth.PacketSerializer\NosSmooth.PacketSerializer.csproj", "{89509BB0-3618-4F8A-8D51-4B251BD13CD4}" -EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "NosSmooth.PacketSerializer.Abstractions", "Packets\NosSmooth.PacketSerializer.Abstractions\NosSmooth.PacketSerializer.Abstractions.csproj", "{77A62552-25AB-43FD-BFBA-5B5FD6F066A7}" -EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "NosSmooth.PacketSerializersGenerator", "Packets\NosSmooth.PacketSerializersGenerator\NosSmooth.PacketSerializersGenerator.csproj", "{CE4EB82B-7AAD-4689-BB13-557B7EFF4290}" -EndProject -Global - GlobalSection(SolutionConfigurationPlatforms) = preSolution - Debug|Any CPU = Debug|Any CPU - Debug|x64 = Debug|x64 - Debug|x86 = Debug|x86 - Release|Any CPU = Release|Any CPU - Release|x64 = Release|x64 - Release|x86 = Release|x86 - EndGlobalSection - GlobalSection(ProjectConfigurationPlatforms) = postSolution - {8CCDB0CD-DFB2-492E-B1A2-8DD030F923D3}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {8CCDB0CD-DFB2-492E-B1A2-8DD030F923D3}.Debug|Any CPU.Build.0 = Debug|Any CPU - {8CCDB0CD-DFB2-492E-B1A2-8DD030F923D3}.Debug|x64.ActiveCfg = Debug|Any CPU - {8CCDB0CD-DFB2-492E-B1A2-8DD030F923D3}.Debug|x64.Build.0 = Debug|Any CPU - {8CCDB0CD-DFB2-492E-B1A2-8DD030F923D3}.Debug|x86.ActiveCfg = Debug|Any CPU - {8CCDB0CD-DFB2-492E-B1A2-8DD030F923D3}.Debug|x86.Build.0 = Debug|Any CPU - {8CCDB0CD-DFB2-492E-B1A2-8DD030F923D3}.Release|Any CPU.ActiveCfg = Release|Any CPU - {8CCDB0CD-DFB2-492E-B1A2-8DD030F923D3}.Release|Any CPU.Build.0 = Release|Any CPU - {8CCDB0CD-DFB2-492E-B1A2-8DD030F923D3}.Release|x64.ActiveCfg = Release|Any CPU - {8CCDB0CD-DFB2-492E-B1A2-8DD030F923D3}.Release|x64.Build.0 = Release|Any CPU - {8CCDB0CD-DFB2-492E-B1A2-8DD030F923D3}.Release|x86.ActiveCfg = Release|Any CPU - {8CCDB0CD-DFB2-492E-B1A2-8DD030F923D3}.Release|x86.Build.0 = Release|Any CPU - {19666500-4636-4400-8855-496317F4A7F7}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {19666500-4636-4400-8855-496317F4A7F7}.Debug|Any CPU.Build.0 = Debug|Any CPU - {19666500-4636-4400-8855-496317F4A7F7}.Debug|x64.ActiveCfg = Debug|Any CPU - {19666500-4636-4400-8855-496317F4A7F7}.Debug|x64.Build.0 = Debug|Any CPU - {19666500-4636-4400-8855-496317F4A7F7}.Debug|x86.ActiveCfg = Debug|Any CPU - {19666500-4636-4400-8855-496317F4A7F7}.Debug|x86.Build.0 = Debug|Any CPU - {19666500-4636-4400-8855-496317F4A7F7}.Release|Any CPU.ActiveCfg = Release|Any CPU - {19666500-4636-4400-8855-496317F4A7F7}.Release|Any CPU.Build.0 = Release|Any CPU - {19666500-4636-4400-8855-496317F4A7F7}.Release|x64.ActiveCfg = Release|Any CPU - {19666500-4636-4400-8855-496317F4A7F7}.Release|x64.Build.0 = Release|Any CPU - {19666500-4636-4400-8855-496317F4A7F7}.Release|x86.ActiveCfg = Release|Any CPU - {19666500-4636-4400-8855-496317F4A7F7}.Release|x86.Build.0 = Release|Any CPU - {05E3039D-EDF6-4CDC-B062-CB67760ACB5F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {05E3039D-EDF6-4CDC-B062-CB67760ACB5F}.Debug|Any CPU.Build.0 = Debug|Any CPU - {05E3039D-EDF6-4CDC-B062-CB67760ACB5F}.Debug|x64.ActiveCfg = Debug|Any CPU - {05E3039D-EDF6-4CDC-B062-CB67760ACB5F}.Debug|x64.Build.0 = Debug|Any CPU - {05E3039D-EDF6-4CDC-B062-CB67760ACB5F}.Debug|x86.ActiveCfg = Debug|Any CPU - {05E3039D-EDF6-4CDC-B062-CB67760ACB5F}.Debug|x86.Build.0 = Debug|Any CPU - {05E3039D-EDF6-4CDC-B062-CB67760ACB5F}.Release|Any CPU.ActiveCfg = Release|Any CPU - {05E3039D-EDF6-4CDC-B062-CB67760ACB5F}.Release|Any CPU.Build.0 = Release|Any CPU - {05E3039D-EDF6-4CDC-B062-CB67760ACB5F}.Release|x64.ActiveCfg = Release|Any CPU - {05E3039D-EDF6-4CDC-B062-CB67760ACB5F}.Release|x64.Build.0 = Release|Any CPU - {05E3039D-EDF6-4CDC-B062-CB67760ACB5F}.Release|x86.ActiveCfg = Release|Any CPU - {05E3039D-EDF6-4CDC-B062-CB67760ACB5F}.Release|x86.Build.0 = Release|Any CPU - {06F03B1F-F68A-4C5B-B7FE-128A7CE1A1D7}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {06F03B1F-F68A-4C5B-B7FE-128A7CE1A1D7}.Debug|Any CPU.Build.0 = Debug|Any CPU - {06F03B1F-F68A-4C5B-B7FE-128A7CE1A1D7}.Debug|x64.ActiveCfg = Debug|Any CPU - {06F03B1F-F68A-4C5B-B7FE-128A7CE1A1D7}.Debug|x64.Build.0 = Debug|Any CPU - {06F03B1F-F68A-4C5B-B7FE-128A7CE1A1D7}.Debug|x86.ActiveCfg = Debug|Any CPU - {06F03B1F-F68A-4C5B-B7FE-128A7CE1A1D7}.Debug|x86.Build.0 = Debug|Any CPU - {06F03B1F-F68A-4C5B-B7FE-128A7CE1A1D7}.Release|Any CPU.ActiveCfg = Release|Any CPU - {06F03B1F-F68A-4C5B-B7FE-128A7CE1A1D7}.Release|Any CPU.Build.0 = Release|Any CPU - {06F03B1F-F68A-4C5B-B7FE-128A7CE1A1D7}.Release|x64.ActiveCfg = Release|Any CPU - {06F03B1F-F68A-4C5B-B7FE-128A7CE1A1D7}.Release|x64.Build.0 = Release|Any CPU - {06F03B1F-F68A-4C5B-B7FE-128A7CE1A1D7}.Release|x86.ActiveCfg = Release|Any CPU - {06F03B1F-F68A-4C5B-B7FE-128A7CE1A1D7}.Release|x86.Build.0 = Release|Any CPU - {B6C23EA5-55FE-436A-96EA-FE2974C5881D}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {B6C23EA5-55FE-436A-96EA-FE2974C5881D}.Debug|Any CPU.Build.0 = Debug|Any CPU - {B6C23EA5-55FE-436A-96EA-FE2974C5881D}.Debug|x64.ActiveCfg = Debug|Any CPU - {B6C23EA5-55FE-436A-96EA-FE2974C5881D}.Debug|x64.Build.0 = Debug|Any CPU - {B6C23EA5-55FE-436A-96EA-FE2974C5881D}.Debug|x86.ActiveCfg = Debug|Any CPU - {B6C23EA5-55FE-436A-96EA-FE2974C5881D}.Debug|x86.Build.0 = Debug|Any CPU - {B6C23EA5-55FE-436A-96EA-FE2974C5881D}.Release|Any CPU.ActiveCfg = Release|Any CPU - {B6C23EA5-55FE-436A-96EA-FE2974C5881D}.Release|Any CPU.Build.0 = Release|Any CPU - {B6C23EA5-55FE-436A-96EA-FE2974C5881D}.Release|x64.ActiveCfg = Release|Any CPU - {B6C23EA5-55FE-436A-96EA-FE2974C5881D}.Release|x64.Build.0 = Release|Any CPU - {B6C23EA5-55FE-436A-96EA-FE2974C5881D}.Release|x86.ActiveCfg = Release|Any CPU - {B6C23EA5-55FE-436A-96EA-FE2974C5881D}.Release|x86.Build.0 = Release|Any CPU - {CE7EE14A-BCC5-4A8B-8D9F-403BF09BD99A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {CE7EE14A-BCC5-4A8B-8D9F-403BF09BD99A}.Debug|Any CPU.Build.0 = Debug|Any CPU - {CE7EE14A-BCC5-4A8B-8D9F-403BF09BD99A}.Debug|x64.ActiveCfg = Debug|Any CPU - {CE7EE14A-BCC5-4A8B-8D9F-403BF09BD99A}.Debug|x64.Build.0 = Debug|Any CPU - {CE7EE14A-BCC5-4A8B-8D9F-403BF09BD99A}.Debug|x86.ActiveCfg = Debug|Any CPU - {CE7EE14A-BCC5-4A8B-8D9F-403BF09BD99A}.Debug|x86.Build.0 = Debug|Any CPU - {CE7EE14A-BCC5-4A8B-8D9F-403BF09BD99A}.Release|Any CPU.ActiveCfg = Release|Any CPU - {CE7EE14A-BCC5-4A8B-8D9F-403BF09BD99A}.Release|Any CPU.Build.0 = Release|Any CPU - {CE7EE14A-BCC5-4A8B-8D9F-403BF09BD99A}.Release|x64.ActiveCfg = Release|Any CPU - {CE7EE14A-BCC5-4A8B-8D9F-403BF09BD99A}.Release|x64.Build.0 = Release|Any CPU - {CE7EE14A-BCC5-4A8B-8D9F-403BF09BD99A}.Release|x86.ActiveCfg = Release|Any CPU - {CE7EE14A-BCC5-4A8B-8D9F-403BF09BD99A}.Release|x86.Build.0 = Release|Any CPU - {583D3651-E13F-481F-A9D9-A093DFCDB10F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {583D3651-E13F-481F-A9D9-A093DFCDB10F}.Debug|Any CPU.Build.0 = Debug|Any CPU - {583D3651-E13F-481F-A9D9-A093DFCDB10F}.Debug|x64.ActiveCfg = Debug|Any CPU - {583D3651-E13F-481F-A9D9-A093DFCDB10F}.Debug|x64.Build.0 = Debug|Any CPU - {583D3651-E13F-481F-A9D9-A093DFCDB10F}.Debug|x86.ActiveCfg = Debug|Any CPU - {583D3651-E13F-481F-A9D9-A093DFCDB10F}.Debug|x86.Build.0 = Debug|Any CPU - {583D3651-E13F-481F-A9D9-A093DFCDB10F}.Release|Any CPU.ActiveCfg = Release|Any CPU - {583D3651-E13F-481F-A9D9-A093DFCDB10F}.Release|Any CPU.Build.0 = Release|Any CPU - {583D3651-E13F-481F-A9D9-A093DFCDB10F}.Release|x64.ActiveCfg = Release|Any CPU - {583D3651-E13F-481F-A9D9-A093DFCDB10F}.Release|x64.Build.0 = Release|Any CPU - {583D3651-E13F-481F-A9D9-A093DFCDB10F}.Release|x86.ActiveCfg = Release|Any CPU - {583D3651-E13F-481F-A9D9-A093DFCDB10F}.Release|x86.Build.0 = Release|Any CPU - {89509BB0-3618-4F8A-8D51-4B251BD13CD4}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {89509BB0-3618-4F8A-8D51-4B251BD13CD4}.Debug|Any CPU.Build.0 = Debug|Any CPU - {89509BB0-3618-4F8A-8D51-4B251BD13CD4}.Debug|x64.ActiveCfg = Debug|Any CPU - {89509BB0-3618-4F8A-8D51-4B251BD13CD4}.Debug|x64.Build.0 = Debug|Any CPU - {89509BB0-3618-4F8A-8D51-4B251BD13CD4}.Debug|x86.ActiveCfg = Debug|Any CPU - {89509BB0-3618-4F8A-8D51-4B251BD13CD4}.Debug|x86.Build.0 = Debug|Any CPU - {89509BB0-3618-4F8A-8D51-4B251BD13CD4}.Release|Any CPU.ActiveCfg = Release|Any CPU - {89509BB0-3618-4F8A-8D51-4B251BD13CD4}.Release|Any CPU.Build.0 = Release|Any CPU - {89509BB0-3618-4F8A-8D51-4B251BD13CD4}.Release|x64.ActiveCfg = Release|Any CPU - {89509BB0-3618-4F8A-8D51-4B251BD13CD4}.Release|x64.Build.0 = Release|Any CPU - {89509BB0-3618-4F8A-8D51-4B251BD13CD4}.Release|x86.ActiveCfg = Release|Any CPU - {89509BB0-3618-4F8A-8D51-4B251BD13CD4}.Release|x86.Build.0 = Release|Any CPU - {77A62552-25AB-43FD-BFBA-5B5FD6F066A7}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {77A62552-25AB-43FD-BFBA-5B5FD6F066A7}.Debug|Any CPU.Build.0 = Debug|Any CPU - {77A62552-25AB-43FD-BFBA-5B5FD6F066A7}.Debug|x64.ActiveCfg = Debug|Any CPU - {77A62552-25AB-43FD-BFBA-5B5FD6F066A7}.Debug|x64.Build.0 = Debug|Any CPU - {77A62552-25AB-43FD-BFBA-5B5FD6F066A7}.Debug|x86.ActiveCfg = Debug|Any CPU - {77A62552-25AB-43FD-BFBA-5B5FD6F066A7}.Debug|x86.Build.0 = Debug|Any CPU - {77A62552-25AB-43FD-BFBA-5B5FD6F066A7}.Release|Any CPU.ActiveCfg = Release|Any CPU - {77A62552-25AB-43FD-BFBA-5B5FD6F066A7}.Release|Any CPU.Build.0 = Release|Any CPU - {77A62552-25AB-43FD-BFBA-5B5FD6F066A7}.Release|x64.ActiveCfg = Release|Any CPU - {77A62552-25AB-43FD-BFBA-5B5FD6F066A7}.Release|x64.Build.0 = Release|Any CPU - {77A62552-25AB-43FD-BFBA-5B5FD6F066A7}.Release|x86.ActiveCfg = Release|Any CPU - {77A62552-25AB-43FD-BFBA-5B5FD6F066A7}.Release|x86.Build.0 = Release|Any CPU - {CE4EB82B-7AAD-4689-BB13-557B7EFF4290}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {CE4EB82B-7AAD-4689-BB13-557B7EFF4290}.Debug|Any CPU.Build.0 = Debug|Any CPU - {CE4EB82B-7AAD-4689-BB13-557B7EFF4290}.Debug|x64.ActiveCfg = Debug|Any CPU - {CE4EB82B-7AAD-4689-BB13-557B7EFF4290}.Debug|x64.Build.0 = Debug|Any CPU - {CE4EB82B-7AAD-4689-BB13-557B7EFF4290}.Debug|x86.ActiveCfg = Debug|Any CPU - {CE4EB82B-7AAD-4689-BB13-557B7EFF4290}.Debug|x86.Build.0 = Debug|Any CPU - {CE4EB82B-7AAD-4689-BB13-557B7EFF4290}.Release|Any CPU.ActiveCfg = Release|Any CPU - {CE4EB82B-7AAD-4689-BB13-557B7EFF4290}.Release|Any CPU.Build.0 = Release|Any CPU - {CE4EB82B-7AAD-4689-BB13-557B7EFF4290}.Release|x64.ActiveCfg = Release|Any CPU - {CE4EB82B-7AAD-4689-BB13-557B7EFF4290}.Release|x64.Build.0 = Release|Any CPU - {CE4EB82B-7AAD-4689-BB13-557B7EFF4290}.Release|x86.ActiveCfg = Release|Any CPU - {CE4EB82B-7AAD-4689-BB13-557B7EFF4290}.Release|x86.Build.0 = Release|Any CPU - EndGlobalSection - GlobalSection(SolutionProperties) = preSolution - HideSolutionNode = FALSE - EndGlobalSection - GlobalSection(NestedProjects) = preSolution - {8CCDB0CD-DFB2-492E-B1A2-8DD030F923D3} = {01B5E872-271F-4D30-A1AA-AD48D81840C5} - {19666500-4636-4400-8855-496317F4A7F7} = {01B5E872-271F-4D30-A1AA-AD48D81840C5} - {05E3039D-EDF6-4CDC-B062-CB67760ACB5F} = {F9EFA63C-0A88-45EB-B36F-C4A9D63BDFD1} - {06F03B1F-F68A-4C5B-B7FE-128A7CE1A1D7} = {01B5E872-271F-4D30-A1AA-AD48D81840C5} - {CE7EE14A-BCC5-4A8B-8D9F-403BF09BD99A} = {C6A8760D-92CB-4307-88A7-36CCAEBA4AD1} - {583D3651-E13F-481F-A9D9-A093DFCDB10F} = {1EBECD64-77C3-4D5B-BAD1-C2803E2FBD5E} - {89509BB0-3618-4F8A-8D51-4B251BD13CD4} = {1EBECD64-77C3-4D5B-BAD1-C2803E2FBD5E} - {77A62552-25AB-43FD-BFBA-5B5FD6F066A7} = {1EBECD64-77C3-4D5B-BAD1-C2803E2FBD5E} - {CE4EB82B-7AAD-4689-BB13-557B7EFF4290} = {1EBECD64-77C3-4D5B-BAD1-C2803E2FBD5E} - EndGlobalSection - GlobalSection(ExtensibilityGlobals) = postSolution - SolutionGuid = {C5F46653-4DEC-429B-8580-4ED18ED9B4CA} - EndGlobalSection -EndGlobal diff --git a/NosSmooth.Unix.sln.DotSettings b/NosSmooth.Unix.sln.DotSettings deleted file mode 100644 index 48e4dc749091e7763801afcbabed64aa6ed8fd72..0000000000000000000000000000000000000000 --- a/NosSmooth.Unix.sln.DotSettings +++ /dev/null @@ -1,6 +0,0 @@ - - - $FILENAME$ - - Copyright (c) František Boháček. All rights reserved. - Licensed under the MIT license. See LICENSE file in the project root for full license information. \ No newline at end of file diff --git a/NosSmooth.sln b/NosSmooth.sln index 5806e50b38603cbb34982814bbf90efda5ba37aa..46881c063707958b1dc4302951186c6089aaacae 100644 --- a/NosSmooth.sln +++ b/NosSmooth.sln @@ -5,16 +5,6 @@ VisualStudioVersion = 17.0.32014.148 MinimumVisualStudioVersion = 10.0.40219.1 Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "NosSmooth.Core", "Core\NosSmooth.Core\NosSmooth.Core.csproj", "{8CCDB0CD-DFB2-492E-B1A2-8DD030F923D3}" EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "NosSmooth.Game", "Core\NosSmooth.Game\NosSmooth.Game.csproj", "{19666500-4636-4400-8855-496317F4A7F7}" -EndProject -Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Samples", "Samples", "{F20FE754-FDEA-4F3A-93D4-0750CB9EBB33}" -EndProject -Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Local", "Local", "{6078AE6E-7CD0-48E4-84E0-EB164D8881DA}" -EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "NosSmooth.LocalClient", "Local\NosSmooth.LocalClient\NosSmooth.LocalClient.csproj", "{46D0A205-CA30-41CC-9A80-10B543FBD344}" -EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "NosSmooth.Language", "Core\NosSmooth.Language\NosSmooth.Language.csproj", "{06F03B1F-F68A-4C5B-B7FE-128A7CE1A1D7}" -EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Core", "Core", "{01B5E872-271F-4D30-A1AA-AD48D81840C5}" EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = ".metadata", ".metadata", "{FA63BCED-9D81-4FF7-BA75-A6F3BA31ECDE}" @@ -22,16 +12,8 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = ".metadata", ".metadata", "{ Directory.build.props = Directory.build.props EndProjectSection EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "SimpleChat", "Samples\SimpleChat\SimpleChat.csproj", "{4017A4F4-5E59-48AA-A7D0-A8518148933A}" -EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Tests", "Tests", "{C6A8760D-92CB-4307-88A7-36CCAEBA4AD1}" EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "InterceptNameChanger", "Samples\InterceptNameChanger\InterceptNameChanger.csproj", "{F96F3AA0-131E-4B6B-AB21-BBE2DEBCEF3A}" -EndProject -Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "LowLevel", "LowLevel", "{9025731C-084E-4E82-8CD4-0F52D3AA1F54}" -EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "WalkCommands", "Samples\WalkCommands\WalkCommands.csproj", "{18A62EF6-ADDA-4224-90AB-2D5DCFC95D3E}" -EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "NosSmooth.Core.Tests", "Tests\NosSmooth.Core.Tests\NosSmooth.Core.Tests.csproj", "{1A10C624-48E5-425D-938E-31A4CC7AC687}" EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "NosSmooth.PacketSerializer", "Packets\NosSmooth.PacketSerializer\NosSmooth.PacketSerializer.csproj", "{C4DAFD83-C6DC-4597-AA1F-BA2F3ABB612C}" @@ -40,24 +22,12 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "NosSmooth.PacketSerializers EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "NosSmooth.Packets.Tests", "Tests\NosSmooth.Packets.Tests\NosSmooth.Packets.Tests.csproj", "{9BC56B40-64E3-4A8F-AD49-C52857A35026}" EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "NosSmooth.Inject", "Local\NosSmooth.Inject\NosSmooth.Inject.vcxproj", "{CA2873D8-BD0B-4583-818D-B94A3C2ABBA3}" -EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "NosSmooth.Injector.CLI", "Local\NosSmooth.Injector.CLI\NosSmooth.Injector.CLI.csproj", "{5D351C91-C631-40F6-82D2-F8D68468B076}" -EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "NosSmooth.Injector", "Local\NosSmooth.Injector\NosSmooth.Injector.csproj", "{7B68DE7D-159B-42A7-8CF8-69F156CD04DE}" -EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "NosSmooth.LocalBinding", "Local\NosSmooth.LocalBinding\NosSmooth.LocalBinding.csproj", "{BC0DCD32-E917-4187-8CF3-970D17301ED3}" -EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Packets", "Packets", "{54A49AC2-55B3-4156-8023-41C56719EBB5}" EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "NosSmooth.Packets", "Packets\NosSmooth.Packets\NosSmooth.Packets.csproj", "{86B4ED0C-CD28-4C6C-B58E-B4B1F7AAD683}" EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "NosSmooth.PacketSerializer.Abstractions", "Packets\NosSmooth.PacketSerializer.Abstractions\NosSmooth.PacketSerializer.Abstractions.csproj", "{CF03BCEA-EB5B-427F-8576-7DA7EB869BDC}" EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "NosSmooth.ChatCommands", "Local\NosSmooth.ChatCommands\NosSmooth.ChatCommands.csproj", "{7DC7FC22-EFA6-4EB0-8E75-99F746E50F6E}" -EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ExternalBrowser", "Samples\ExternalBrowser\ExternalBrowser.csproj", "{A3BCC882-6DCD-4326-8BC2-A5C78AD10361}" -EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU @@ -80,78 +50,6 @@ Global {8CCDB0CD-DFB2-492E-B1A2-8DD030F923D3}.Release|x64.Build.0 = Release|Any CPU {8CCDB0CD-DFB2-492E-B1A2-8DD030F923D3}.Release|x86.ActiveCfg = Release|Any CPU {8CCDB0CD-DFB2-492E-B1A2-8DD030F923D3}.Release|x86.Build.0 = Release|Any CPU - {19666500-4636-4400-8855-496317F4A7F7}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {19666500-4636-4400-8855-496317F4A7F7}.Debug|Any CPU.Build.0 = Debug|Any CPU - {19666500-4636-4400-8855-496317F4A7F7}.Debug|x64.ActiveCfg = Debug|Any CPU - {19666500-4636-4400-8855-496317F4A7F7}.Debug|x64.Build.0 = Debug|Any CPU - {19666500-4636-4400-8855-496317F4A7F7}.Debug|x86.ActiveCfg = Debug|Any CPU - {19666500-4636-4400-8855-496317F4A7F7}.Debug|x86.Build.0 = Debug|Any CPU - {19666500-4636-4400-8855-496317F4A7F7}.Release|Any CPU.ActiveCfg = Release|Any CPU - {19666500-4636-4400-8855-496317F4A7F7}.Release|Any CPU.Build.0 = Release|Any CPU - {19666500-4636-4400-8855-496317F4A7F7}.Release|x64.ActiveCfg = Release|Any CPU - {19666500-4636-4400-8855-496317F4A7F7}.Release|x64.Build.0 = Release|Any CPU - {19666500-4636-4400-8855-496317F4A7F7}.Release|x86.ActiveCfg = Release|Any CPU - {19666500-4636-4400-8855-496317F4A7F7}.Release|x86.Build.0 = Release|Any CPU - {46D0A205-CA30-41CC-9A80-10B543FBD344}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {46D0A205-CA30-41CC-9A80-10B543FBD344}.Debug|Any CPU.Build.0 = Debug|Any CPU - {46D0A205-CA30-41CC-9A80-10B543FBD344}.Debug|x64.ActiveCfg = Debug|Any CPU - {46D0A205-CA30-41CC-9A80-10B543FBD344}.Debug|x64.Build.0 = Debug|Any CPU - {46D0A205-CA30-41CC-9A80-10B543FBD344}.Debug|x86.ActiveCfg = Debug|Any CPU - {46D0A205-CA30-41CC-9A80-10B543FBD344}.Debug|x86.Build.0 = Debug|Any CPU - {46D0A205-CA30-41CC-9A80-10B543FBD344}.Release|Any CPU.ActiveCfg = Release|Any CPU - {46D0A205-CA30-41CC-9A80-10B543FBD344}.Release|Any CPU.Build.0 = Release|Any CPU - {46D0A205-CA30-41CC-9A80-10B543FBD344}.Release|x64.ActiveCfg = Release|Any CPU - {46D0A205-CA30-41CC-9A80-10B543FBD344}.Release|x64.Build.0 = Release|Any CPU - {46D0A205-CA30-41CC-9A80-10B543FBD344}.Release|x86.ActiveCfg = Release|Any CPU - {46D0A205-CA30-41CC-9A80-10B543FBD344}.Release|x86.Build.0 = Release|Any CPU - {06F03B1F-F68A-4C5B-B7FE-128A7CE1A1D7}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {06F03B1F-F68A-4C5B-B7FE-128A7CE1A1D7}.Debug|Any CPU.Build.0 = Debug|Any CPU - {06F03B1F-F68A-4C5B-B7FE-128A7CE1A1D7}.Debug|x64.ActiveCfg = Debug|Any CPU - {06F03B1F-F68A-4C5B-B7FE-128A7CE1A1D7}.Debug|x64.Build.0 = Debug|Any CPU - {06F03B1F-F68A-4C5B-B7FE-128A7CE1A1D7}.Debug|x86.ActiveCfg = Debug|Any CPU - {06F03B1F-F68A-4C5B-B7FE-128A7CE1A1D7}.Debug|x86.Build.0 = Debug|Any CPU - {06F03B1F-F68A-4C5B-B7FE-128A7CE1A1D7}.Release|Any CPU.ActiveCfg = Release|Any CPU - {06F03B1F-F68A-4C5B-B7FE-128A7CE1A1D7}.Release|Any CPU.Build.0 = Release|Any CPU - {06F03B1F-F68A-4C5B-B7FE-128A7CE1A1D7}.Release|x64.ActiveCfg = Release|Any CPU - {06F03B1F-F68A-4C5B-B7FE-128A7CE1A1D7}.Release|x64.Build.0 = Release|Any CPU - {06F03B1F-F68A-4C5B-B7FE-128A7CE1A1D7}.Release|x86.ActiveCfg = Release|Any CPU - {06F03B1F-F68A-4C5B-B7FE-128A7CE1A1D7}.Release|x86.Build.0 = Release|Any CPU - {4017A4F4-5E59-48AA-A7D0-A8518148933A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {4017A4F4-5E59-48AA-A7D0-A8518148933A}.Debug|Any CPU.Build.0 = Debug|Any CPU - {4017A4F4-5E59-48AA-A7D0-A8518148933A}.Debug|x64.ActiveCfg = Debug|Any CPU - {4017A4F4-5E59-48AA-A7D0-A8518148933A}.Debug|x64.Build.0 = Debug|Any CPU - {4017A4F4-5E59-48AA-A7D0-A8518148933A}.Debug|x86.ActiveCfg = Debug|Any CPU - {4017A4F4-5E59-48AA-A7D0-A8518148933A}.Debug|x86.Build.0 = Debug|Any CPU - {4017A4F4-5E59-48AA-A7D0-A8518148933A}.Release|Any CPU.ActiveCfg = Release|Any CPU - {4017A4F4-5E59-48AA-A7D0-A8518148933A}.Release|Any CPU.Build.0 = Release|Any CPU - {4017A4F4-5E59-48AA-A7D0-A8518148933A}.Release|x64.ActiveCfg = Release|Any CPU - {4017A4F4-5E59-48AA-A7D0-A8518148933A}.Release|x64.Build.0 = Release|Any CPU - {4017A4F4-5E59-48AA-A7D0-A8518148933A}.Release|x86.ActiveCfg = Release|Any CPU - {4017A4F4-5E59-48AA-A7D0-A8518148933A}.Release|x86.Build.0 = Release|Any CPU - {F96F3AA0-131E-4B6B-AB21-BBE2DEBCEF3A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {F96F3AA0-131E-4B6B-AB21-BBE2DEBCEF3A}.Debug|Any CPU.Build.0 = Debug|Any CPU - {F96F3AA0-131E-4B6B-AB21-BBE2DEBCEF3A}.Debug|x64.ActiveCfg = Debug|Any CPU - {F96F3AA0-131E-4B6B-AB21-BBE2DEBCEF3A}.Debug|x64.Build.0 = Debug|Any CPU - {F96F3AA0-131E-4B6B-AB21-BBE2DEBCEF3A}.Debug|x86.ActiveCfg = Debug|Any CPU - {F96F3AA0-131E-4B6B-AB21-BBE2DEBCEF3A}.Debug|x86.Build.0 = Debug|Any CPU - {F96F3AA0-131E-4B6B-AB21-BBE2DEBCEF3A}.Release|Any CPU.ActiveCfg = Release|Any CPU - {F96F3AA0-131E-4B6B-AB21-BBE2DEBCEF3A}.Release|Any CPU.Build.0 = Release|Any CPU - {F96F3AA0-131E-4B6B-AB21-BBE2DEBCEF3A}.Release|x64.ActiveCfg = Release|Any CPU - {F96F3AA0-131E-4B6B-AB21-BBE2DEBCEF3A}.Release|x64.Build.0 = Release|Any CPU - {F96F3AA0-131E-4B6B-AB21-BBE2DEBCEF3A}.Release|x86.ActiveCfg = Release|Any CPU - {F96F3AA0-131E-4B6B-AB21-BBE2DEBCEF3A}.Release|x86.Build.0 = Release|Any CPU - {18A62EF6-ADDA-4224-90AB-2D5DCFC95D3E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {18A62EF6-ADDA-4224-90AB-2D5DCFC95D3E}.Debug|Any CPU.Build.0 = Debug|Any CPU - {18A62EF6-ADDA-4224-90AB-2D5DCFC95D3E}.Debug|x64.ActiveCfg = Debug|Any CPU - {18A62EF6-ADDA-4224-90AB-2D5DCFC95D3E}.Debug|x64.Build.0 = Debug|Any CPU - {18A62EF6-ADDA-4224-90AB-2D5DCFC95D3E}.Debug|x86.ActiveCfg = Debug|Any CPU - {18A62EF6-ADDA-4224-90AB-2D5DCFC95D3E}.Debug|x86.Build.0 = Debug|Any CPU - {18A62EF6-ADDA-4224-90AB-2D5DCFC95D3E}.Release|Any CPU.ActiveCfg = Release|Any CPU - {18A62EF6-ADDA-4224-90AB-2D5DCFC95D3E}.Release|Any CPU.Build.0 = Release|Any CPU - {18A62EF6-ADDA-4224-90AB-2D5DCFC95D3E}.Release|x64.ActiveCfg = Release|Any CPU - {18A62EF6-ADDA-4224-90AB-2D5DCFC95D3E}.Release|x64.Build.0 = Release|Any CPU - {18A62EF6-ADDA-4224-90AB-2D5DCFC95D3E}.Release|x86.ActiveCfg = Release|Any CPU - {18A62EF6-ADDA-4224-90AB-2D5DCFC95D3E}.Release|x86.Build.0 = Release|Any CPU {1A10C624-48E5-425D-938E-31A4CC7AC687}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {1A10C624-48E5-425D-938E-31A4CC7AC687}.Debug|Any CPU.Build.0 = Debug|Any CPU {1A10C624-48E5-425D-938E-31A4CC7AC687}.Debug|x64.ActiveCfg = Debug|Any CPU @@ -200,54 +98,6 @@ Global {9BC56B40-64E3-4A8F-AD49-C52857A35026}.Release|x64.Build.0 = Release|Any CPU {9BC56B40-64E3-4A8F-AD49-C52857A35026}.Release|x86.ActiveCfg = Release|Any CPU {9BC56B40-64E3-4A8F-AD49-C52857A35026}.Release|x86.Build.0 = Release|Any CPU - {CA2873D8-BD0B-4583-818D-B94A3C2ABBA3}.Debug|Any CPU.ActiveCfg = Debug|x64 - {CA2873D8-BD0B-4583-818D-B94A3C2ABBA3}.Debug|Any CPU.Build.0 = Debug|x64 - {CA2873D8-BD0B-4583-818D-B94A3C2ABBA3}.Debug|x64.ActiveCfg = Debug|x64 - {CA2873D8-BD0B-4583-818D-B94A3C2ABBA3}.Debug|x64.Build.0 = Debug|x64 - {CA2873D8-BD0B-4583-818D-B94A3C2ABBA3}.Debug|x86.ActiveCfg = Debug|Win32 - {CA2873D8-BD0B-4583-818D-B94A3C2ABBA3}.Debug|x86.Build.0 = Debug|Win32 - {CA2873D8-BD0B-4583-818D-B94A3C2ABBA3}.Release|Any CPU.ActiveCfg = Release|x64 - {CA2873D8-BD0B-4583-818D-B94A3C2ABBA3}.Release|Any CPU.Build.0 = Release|x64 - {CA2873D8-BD0B-4583-818D-B94A3C2ABBA3}.Release|x64.ActiveCfg = Release|x64 - {CA2873D8-BD0B-4583-818D-B94A3C2ABBA3}.Release|x64.Build.0 = Release|x64 - {CA2873D8-BD0B-4583-818D-B94A3C2ABBA3}.Release|x86.ActiveCfg = Release|Win32 - {CA2873D8-BD0B-4583-818D-B94A3C2ABBA3}.Release|x86.Build.0 = Release|Win32 - {5D351C91-C631-40F6-82D2-F8D68468B076}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {5D351C91-C631-40F6-82D2-F8D68468B076}.Debug|Any CPU.Build.0 = Debug|Any CPU - {5D351C91-C631-40F6-82D2-F8D68468B076}.Debug|x64.ActiveCfg = Debug|Any CPU - {5D351C91-C631-40F6-82D2-F8D68468B076}.Debug|x64.Build.0 = Debug|Any CPU - {5D351C91-C631-40F6-82D2-F8D68468B076}.Debug|x86.ActiveCfg = Debug|Any CPU - {5D351C91-C631-40F6-82D2-F8D68468B076}.Debug|x86.Build.0 = Debug|Any CPU - {5D351C91-C631-40F6-82D2-F8D68468B076}.Release|Any CPU.ActiveCfg = Release|Any CPU - {5D351C91-C631-40F6-82D2-F8D68468B076}.Release|Any CPU.Build.0 = Release|Any CPU - {5D351C91-C631-40F6-82D2-F8D68468B076}.Release|x64.ActiveCfg = Release|Any CPU - {5D351C91-C631-40F6-82D2-F8D68468B076}.Release|x64.Build.0 = Release|Any CPU - {5D351C91-C631-40F6-82D2-F8D68468B076}.Release|x86.ActiveCfg = Release|Any CPU - {5D351C91-C631-40F6-82D2-F8D68468B076}.Release|x86.Build.0 = Release|Any CPU - {7B68DE7D-159B-42A7-8CF8-69F156CD04DE}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {7B68DE7D-159B-42A7-8CF8-69F156CD04DE}.Debug|Any CPU.Build.0 = Debug|Any CPU - {7B68DE7D-159B-42A7-8CF8-69F156CD04DE}.Debug|x64.ActiveCfg = Debug|Any CPU - {7B68DE7D-159B-42A7-8CF8-69F156CD04DE}.Debug|x64.Build.0 = Debug|Any CPU - {7B68DE7D-159B-42A7-8CF8-69F156CD04DE}.Debug|x86.ActiveCfg = Debug|Any CPU - {7B68DE7D-159B-42A7-8CF8-69F156CD04DE}.Debug|x86.Build.0 = Debug|Any CPU - {7B68DE7D-159B-42A7-8CF8-69F156CD04DE}.Release|Any CPU.ActiveCfg = Release|Any CPU - {7B68DE7D-159B-42A7-8CF8-69F156CD04DE}.Release|Any CPU.Build.0 = Release|Any CPU - {7B68DE7D-159B-42A7-8CF8-69F156CD04DE}.Release|x64.ActiveCfg = Release|Any CPU - {7B68DE7D-159B-42A7-8CF8-69F156CD04DE}.Release|x64.Build.0 = Release|Any CPU - {7B68DE7D-159B-42A7-8CF8-69F156CD04DE}.Release|x86.ActiveCfg = Release|Any CPU - {7B68DE7D-159B-42A7-8CF8-69F156CD04DE}.Release|x86.Build.0 = Release|Any CPU - {BC0DCD32-E917-4187-8CF3-970D17301ED3}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {BC0DCD32-E917-4187-8CF3-970D17301ED3}.Debug|Any CPU.Build.0 = Debug|Any CPU - {BC0DCD32-E917-4187-8CF3-970D17301ED3}.Debug|x64.ActiveCfg = Debug|Any CPU - {BC0DCD32-E917-4187-8CF3-970D17301ED3}.Debug|x64.Build.0 = Debug|Any CPU - {BC0DCD32-E917-4187-8CF3-970D17301ED3}.Debug|x86.ActiveCfg = Debug|Any CPU - {BC0DCD32-E917-4187-8CF3-970D17301ED3}.Debug|x86.Build.0 = Debug|Any CPU - {BC0DCD32-E917-4187-8CF3-970D17301ED3}.Release|Any CPU.ActiveCfg = Release|Any CPU - {BC0DCD32-E917-4187-8CF3-970D17301ED3}.Release|Any CPU.Build.0 = Release|Any CPU - {BC0DCD32-E917-4187-8CF3-970D17301ED3}.Release|x64.ActiveCfg = Release|Any CPU - {BC0DCD32-E917-4187-8CF3-970D17301ED3}.Release|x64.Build.0 = Release|Any CPU - {BC0DCD32-E917-4187-8CF3-970D17301ED3}.Release|x86.ActiveCfg = Release|Any CPU - {BC0DCD32-E917-4187-8CF3-970D17301ED3}.Release|x86.Build.0 = Release|Any CPU {86B4ED0C-CD28-4C6C-B58E-B4B1F7AAD683}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {86B4ED0C-CD28-4C6C-B58E-B4B1F7AAD683}.Debug|Any CPU.Build.0 = Debug|Any CPU {86B4ED0C-CD28-4C6C-B58E-B4B1F7AAD683}.Debug|x64.ActiveCfg = Debug|Any CPU @@ -272,55 +122,18 @@ Global {CF03BCEA-EB5B-427F-8576-7DA7EB869BDC}.Release|x64.Build.0 = Release|Any CPU {CF03BCEA-EB5B-427F-8576-7DA7EB869BDC}.Release|x86.ActiveCfg = Release|Any CPU {CF03BCEA-EB5B-427F-8576-7DA7EB869BDC}.Release|x86.Build.0 = Release|Any CPU - {7DC7FC22-EFA6-4EB0-8E75-99F746E50F6E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {7DC7FC22-EFA6-4EB0-8E75-99F746E50F6E}.Debug|Any CPU.Build.0 = Debug|Any CPU - {7DC7FC22-EFA6-4EB0-8E75-99F746E50F6E}.Debug|x64.ActiveCfg = Debug|Any CPU - {7DC7FC22-EFA6-4EB0-8E75-99F746E50F6E}.Debug|x64.Build.0 = Debug|Any CPU - {7DC7FC22-EFA6-4EB0-8E75-99F746E50F6E}.Debug|x86.ActiveCfg = Debug|Any CPU - {7DC7FC22-EFA6-4EB0-8E75-99F746E50F6E}.Debug|x86.Build.0 = Debug|Any CPU - {7DC7FC22-EFA6-4EB0-8E75-99F746E50F6E}.Release|Any CPU.ActiveCfg = Release|Any CPU - {7DC7FC22-EFA6-4EB0-8E75-99F746E50F6E}.Release|Any CPU.Build.0 = Release|Any CPU - {7DC7FC22-EFA6-4EB0-8E75-99F746E50F6E}.Release|x64.ActiveCfg = Release|Any CPU - {7DC7FC22-EFA6-4EB0-8E75-99F746E50F6E}.Release|x64.Build.0 = Release|Any CPU - {7DC7FC22-EFA6-4EB0-8E75-99F746E50F6E}.Release|x86.ActiveCfg = Release|Any CPU - {7DC7FC22-EFA6-4EB0-8E75-99F746E50F6E}.Release|x86.Build.0 = Release|Any CPU - {A3BCC882-6DCD-4326-8BC2-A5C78AD10361}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {A3BCC882-6DCD-4326-8BC2-A5C78AD10361}.Debug|Any CPU.Build.0 = Debug|Any CPU - {A3BCC882-6DCD-4326-8BC2-A5C78AD10361}.Debug|x64.ActiveCfg = Debug|Any CPU - {A3BCC882-6DCD-4326-8BC2-A5C78AD10361}.Debug|x64.Build.0 = Debug|Any CPU - {A3BCC882-6DCD-4326-8BC2-A5C78AD10361}.Debug|x86.ActiveCfg = Debug|Any CPU - {A3BCC882-6DCD-4326-8BC2-A5C78AD10361}.Debug|x86.Build.0 = Debug|Any CPU - {A3BCC882-6DCD-4326-8BC2-A5C78AD10361}.Release|Any CPU.ActiveCfg = Release|Any CPU - {A3BCC882-6DCD-4326-8BC2-A5C78AD10361}.Release|Any CPU.Build.0 = Release|Any CPU - {A3BCC882-6DCD-4326-8BC2-A5C78AD10361}.Release|x64.ActiveCfg = Release|Any CPU - {A3BCC882-6DCD-4326-8BC2-A5C78AD10361}.Release|x64.Build.0 = Release|Any CPU - {A3BCC882-6DCD-4326-8BC2-A5C78AD10361}.Release|x86.ActiveCfg = Release|Any CPU - {A3BCC882-6DCD-4326-8BC2-A5C78AD10361}.Release|x86.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE EndGlobalSection GlobalSection(NestedProjects) = preSolution {8CCDB0CD-DFB2-492E-B1A2-8DD030F923D3} = {01B5E872-271F-4D30-A1AA-AD48D81840C5} - {19666500-4636-4400-8855-496317F4A7F7} = {01B5E872-271F-4D30-A1AA-AD48D81840C5} - {46D0A205-CA30-41CC-9A80-10B543FBD344} = {6078AE6E-7CD0-48E4-84E0-EB164D8881DA} - {06F03B1F-F68A-4C5B-B7FE-128A7CE1A1D7} = {01B5E872-271F-4D30-A1AA-AD48D81840C5} - {4017A4F4-5E59-48AA-A7D0-A8518148933A} = {9025731C-084E-4E82-8CD4-0F52D3AA1F54} - {F96F3AA0-131E-4B6B-AB21-BBE2DEBCEF3A} = {9025731C-084E-4E82-8CD4-0F52D3AA1F54} - {9025731C-084E-4E82-8CD4-0F52D3AA1F54} = {F20FE754-FDEA-4F3A-93D4-0750CB9EBB33} {1A10C624-48E5-425D-938E-31A4CC7AC687} = {C6A8760D-92CB-4307-88A7-36CCAEBA4AD1} {9BC56B40-64E3-4A8F-AD49-C52857A35026} = {C6A8760D-92CB-4307-88A7-36CCAEBA4AD1} - {CA2873D8-BD0B-4583-818D-B94A3C2ABBA3} = {6078AE6E-7CD0-48E4-84E0-EB164D8881DA} - {5D351C91-C631-40F6-82D2-F8D68468B076} = {6078AE6E-7CD0-48E4-84E0-EB164D8881DA} - {7B68DE7D-159B-42A7-8CF8-69F156CD04DE} = {6078AE6E-7CD0-48E4-84E0-EB164D8881DA} - {18A62EF6-ADDA-4224-90AB-2D5DCFC95D3E} = {F20FE754-FDEA-4F3A-93D4-0750CB9EBB33} - {BC0DCD32-E917-4187-8CF3-970D17301ED3} = {6078AE6E-7CD0-48E4-84E0-EB164D8881DA} {C61EBDB6-053C-48C3-B896-58642639C93F} = {54A49AC2-55B3-4156-8023-41C56719EBB5} {C4DAFD83-C6DC-4597-AA1F-BA2F3ABB612C} = {54A49AC2-55B3-4156-8023-41C56719EBB5} {86B4ED0C-CD28-4C6C-B58E-B4B1F7AAD683} = {54A49AC2-55B3-4156-8023-41C56719EBB5} {CF03BCEA-EB5B-427F-8576-7DA7EB869BDC} = {54A49AC2-55B3-4156-8023-41C56719EBB5} - {7DC7FC22-EFA6-4EB0-8E75-99F746E50F6E} = {6078AE6E-7CD0-48E4-84E0-EB164D8881DA} - {A3BCC882-6DCD-4326-8BC2-A5C78AD10361} = {F20FE754-FDEA-4F3A-93D4-0750CB9EBB33} EndGlobalSection GlobalSection(ExtensibilityGlobals) = postSolution SolutionGuid = {C5F46653-4DEC-429B-8580-4ED18ED9B4CA} diff --git a/Samples/ExternalBrowser/ExternalBrowser.csproj b/Samples/ExternalBrowser/ExternalBrowser.csproj deleted file mode 100644 index 5ca9b4cdccfd69250caf1de7c2aa4d2c5f90bbc3..0000000000000000000000000000000000000000 --- a/Samples/ExternalBrowser/ExternalBrowser.csproj +++ /dev/null @@ -1,15 +0,0 @@ - - - - Exe - net6.0 - enable - enable - - - - - - - - diff --git a/Samples/ExternalBrowser/Program.cs b/Samples/ExternalBrowser/Program.cs deleted file mode 100644 index 175157bf3383ac1dfd62490831d675bd8d747a75..0000000000000000000000000000000000000000 --- a/Samples/ExternalBrowser/Program.cs +++ /dev/null @@ -1,75 +0,0 @@ -// -// Program.cs -// -// Copyright (c) František Boháček. All rights reserved. -// Licensed under the MIT license. See LICENSE file in the project root for full license information. - -using System.Diagnostics; -using NosSmooth.Core.Extensions; -using NosSmooth.LocalBinding; -using NosSmooth.LocalBinding.Options; - -namespace ExternalBrowser; - -/// -/// The entrypoint class for ExternalBrowser. -/// -public class Program -{ - /// - /// The entrypoint method for ExternalBrowser. - /// - /// The arguments. - public static void Main(string[] arguments) - { - var playerManagerOptions = new PlayerManagerOptions(); - var sceneManagerOptions = new SceneManagerOptions(); - var petManagerOptions = new PetManagerOptions(); - - foreach (var argument in arguments) - { - Process[] processes; - - if (int.TryParse(argument, out var processId)) - { - processes = new[] { Process.GetProcessById(processId) }; - } - else - { - processes = Process - .GetProcesses() - .Where(x => x.ProcessName.Contains(argument)) - .ToArray(); - } - - foreach (var process in processes) - { - var externalBrowser = new NosBrowserManager - (process, playerManagerOptions, sceneManagerOptions, petManagerOptions); - - if (!externalBrowser.IsNostaleProcess) - { - Console.Error.WriteLine($"Process {process.Id} is not a nostale process."); - continue; - } - - var initializationResult = externalBrowser.Initialize(); - if (!initializationResult.IsSuccess) - { - Console.Error.WriteLine(initializationResult.ToFullString()); - } - - var length = externalBrowser.PetManagerList.Length; - Console.WriteLine(length); - - if (!externalBrowser.IsInGame) - { - Console.Error.WriteLine("The player is not in game, cannot get the name of the player."); - continue; - } - - Console.WriteLine($"Player in process {process.Id} is named {externalBrowser.PlayerManager.Player.Name}"); - } - } - } -} \ No newline at end of file diff --git a/Samples/InterceptNameChanger/DllMain.cs b/Samples/InterceptNameChanger/DllMain.cs deleted file mode 100644 index 48a5c08878390a52af9d90effd183f60b71d51bb..0000000000000000000000000000000000000000 --- a/Samples/InterceptNameChanger/DllMain.cs +++ /dev/null @@ -1,45 +0,0 @@ -// -// DllMain.cs -// -// Copyright (c) František Boháček. All rights reserved. -// Licensed under the MIT license. See LICENSE file in the project root for full license information. - -using System; -using System.Runtime.InteropServices; -using System.Threading; - -namespace InterceptNameChanger -{ - /// - /// The main entrypoint class of the dll. - /// - public class DllMain - { - [DllImport("kernel32")] -#pragma warning disable SA1600 - public static extern bool AllocConsole(); -#pragma warning restore SA1600 - - /// - /// The main entrypoint method of the dll. - /// - [UnmanagedCallersOnly(EntryPoint = "Main")] - public static void Main() - { - AllocConsole(); - Console.WriteLine("Hello from InterceptNameChanger DllMain entry point."); - - new Thread(() => - { - try - { - new NameChanger().RunAsync().GetAwaiter().GetResult(); - } - catch (Exception e) - { - Console.WriteLine(e.ToString()); - } - }).Start(); - } - } -} \ No newline at end of file diff --git a/Samples/InterceptNameChanger/FodyWeavers.xml b/Samples/InterceptNameChanger/FodyWeavers.xml deleted file mode 100644 index f1dea8fce9bddae509f2662795dd13fd40a5ee75..0000000000000000000000000000000000000000 --- a/Samples/InterceptNameChanger/FodyWeavers.xml +++ /dev/null @@ -1,3 +0,0 @@ - - - \ No newline at end of file diff --git a/Samples/InterceptNameChanger/InterceptNameChanger.csproj b/Samples/InterceptNameChanger/InterceptNameChanger.csproj deleted file mode 100644 index cf0aef008da73c1af71750ba1d86ebc4217b8108..0000000000000000000000000000000000000000 --- a/Samples/InterceptNameChanger/InterceptNameChanger.csproj +++ /dev/null @@ -1,25 +0,0 @@ - - - net6.0 - enable - 10 - true - - - - all - runtime; build; native; contentfiles; analyzers; buildtransitive - - - all - runtime; build; native; contentfiles; analyzers; buildtransitive - - - - - - - - - - \ No newline at end of file diff --git a/Samples/InterceptNameChanger/NameChangeInterceptor.cs b/Samples/InterceptNameChanger/NameChangeInterceptor.cs deleted file mode 100644 index c519de071c22272fae47b2965594e76ebc35486b..0000000000000000000000000000000000000000 --- a/Samples/InterceptNameChanger/NameChangeInterceptor.cs +++ /dev/null @@ -1,81 +0,0 @@ -// -// NameChangeInterceptor.cs -// -// Copyright (c) František Boháček. All rights reserved. -// Licensed under the MIT license. See LICENSE file in the project root for full license information. - -using Microsoft.Extensions.Logging; -using NosSmooth.Core.Client; -using NosSmooth.LocalClient; -using NosSmooth.Packets.Enums; -using NosSmooth.Packets.Enums.Chat; -using NosSmooth.Packets.Server.Chat; - -namespace InterceptNameChanger -{ - /// - /// Intercepts the packets so name in c_info may be replaced. - /// - public class NameChangeInterceptor : IPacketInterceptor - { - private readonly INostaleClient _client; - private readonly ILogger _logger; - private string _name = "Intercept"; - - /// - /// Initializes a new instance of the class. - /// - /// The nostale client. - /// The logger. - public NameChangeInterceptor(INostaleClient client, ILogger logger) - { - _client = client; - _logger = logger; - } - - /// - public bool InterceptSend(ref string packet) - { - if (packet.StartsWith("say #")) - { - _name = packet.Substring(5).Replace(" ", "⠀"); // Mind the symbols! - _logger.LogInformation("Name changed to {Name}", _name); - _client.ReceivePacketAsync - ( - new SayPacket - ( - EntityType.Map, - 1, - SayColor.Red, - $"Name changed to {_name}, change map for it to take effect." - ) - ) - .GetAwaiter() - .GetResult(); - return false; - } - - return true; // Accept the packet - } - - /// - public bool InterceptReceive(ref string packet) - { - if (packet.StartsWith("c_info")) - { - var oldPart = packet.Substring(packet.IndexOf(' ', 7)); - var result = _client.ReceivePacketAsync($"c_info {_name} " + oldPart) - .GetAwaiter().GetResult(); // Change the name - - if (!result.IsSuccess) - { - _logger.LogError("Could not send the c_info packet: {Reason}", result.Error.Message); - return true; // Accept the packet so client is not confused - } - return false; // Reject the packet - } - - return true; // Accept the packet - } - } -} \ No newline at end of file diff --git a/Samples/InterceptNameChanger/NameChanger.cs b/Samples/InterceptNameChanger/NameChanger.cs deleted file mode 100644 index 14780cb13e64a67aa0fbd4c0c3de019d71cc0530..0000000000000000000000000000000000000000 --- a/Samples/InterceptNameChanger/NameChanger.cs +++ /dev/null @@ -1,86 +0,0 @@ -// -// NameChanger.cs -// -// Copyright (c) František Boháček. All rights reserved. -// Licensed under the MIT license. See LICENSE file in the project root for full license information. - -using System.Threading.Tasks; -using Microsoft.Extensions.DependencyInjection; -using Microsoft.Extensions.Logging; -using NosSmooth.Core.Client; -using NosSmooth.Core.Extensions; -using NosSmooth.LocalBinding; -using NosSmooth.LocalClient; -using NosSmooth.LocalClient.Extensions; -using NosSmooth.Packets.Enums; -using NosSmooth.Packets.Enums.Chat; -using NosSmooth.Packets.Extensions; -using NosSmooth.Packets.Packets; -using NosSmooth.Packets.Server.Chat; - -namespace InterceptNameChanger -{ - /// - /// Main class of name changer. - /// - public class NameChanger - { - /// - /// Run the name changer. - /// - /// A task that may or may not have succeeded. - public async Task RunAsync() - { - var provider = new ServiceCollection() - .AddLocalClient() - - // .AddPacketResponder() - .AddLogging - ( - b => - { - b.ClearProviders(); - b.AddConsole(); - b.SetMinimumLevel(LogLevel.Debug); - } - ) - .Configure(o => o.AllowIntercept = true) - .AddSingleton() - .BuildServiceProvider(); - - var logger = provider.GetRequiredService>(); - logger.LogInformation("Hello world from NameChanger!"); - - var bindingManager = provider.GetRequiredService(); - var initializeResult = bindingManager.Initialize(); - if (!initializeResult.IsSuccess) - { - logger.LogError($"Could not initialize NosBindingManager."); - logger.LogResultError(initializeResult); - } - - var packetTypesRepository = provider.GetRequiredService(); - var packetAddResult = packetTypesRepository.AddDefaultPackets(); - if (!packetAddResult.IsSuccess) - { - logger.LogError("Could not initialize default packet serializers correctly"); - logger.LogResultError(packetAddResult); - } - - var client = provider.GetRequiredService(); - - var sayResult = await client.ReceivePacketAsync - ( - new SayPacket - (EntityType.Map, 1, SayColor.Red, "The name may be changed by typing #{NewName} into the chat.") - ); - - if (!sayResult.IsSuccess) - { - logger.LogError("Could not send say packet"); - } - - await client.RunAsync(); - } - } -} \ No newline at end of file diff --git a/Samples/InterceptNameChanger/Properties/AssemblyInfo.cs b/Samples/InterceptNameChanger/Properties/AssemblyInfo.cs deleted file mode 100644 index 2501ebf48230410892d8f498b9482e89694e5f59..0000000000000000000000000000000000000000 --- a/Samples/InterceptNameChanger/Properties/AssemblyInfo.cs +++ /dev/null @@ -1,41 +0,0 @@ -// -// AssemblyInfo.cs -// -// Copyright (c) František Boháček. All rights reserved. -// Licensed under the MIT license. See LICENSE file in the project root for full license information. - -using System.Reflection; -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("InterceptNameChanger")] -[assembly: AssemblyDescription("")] -[assembly: AssemblyConfiguration("")] -[assembly: AssemblyCompany("")] -[assembly: AssemblyProduct("InterceptNameChanger")] -[assembly: AssemblyCopyright("Copyright © 2021")] -[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("F96F3AA0-131E-4B6B-AB21-BBE2DEBCEF3A")] - -// 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")] \ No newline at end of file diff --git a/Samples/SimpleChat/DllMain.cs b/Samples/SimpleChat/DllMain.cs deleted file mode 100644 index b263595315dfc895a4aa394cab762181a52bc204..0000000000000000000000000000000000000000 --- a/Samples/SimpleChat/DllMain.cs +++ /dev/null @@ -1,32 +0,0 @@ -// -// DllMain.cs -// -// Copyright (c) František Boháček. All rights reserved. -// Licensed under the MIT license. See LICENSE file in the project root for full license information. - -using System.Runtime.InteropServices; - -namespace SimpleChat; - -/// -/// The main entrypoint class of the dll. -/// -public class DllMain -{ - [DllImport("kernel32")] -#pragma warning disable SA1600 - public static extern bool AllocConsole(); -#pragma warning restore SA1600 - - /// - /// The main entrypoint method of the dll. - /// - [UnmanagedCallersOnly(EntryPoint = "Main")] - public static void Main() - { - AllocConsole(); - Console.WriteLine("Hello from SimpleChat DllMain entry point."); - - new Thread(() => new SimpleChat().RunAsync().GetAwaiter().GetResult()).Start(); - } -} \ No newline at end of file diff --git a/Samples/SimpleChat/FodyWeavers.xml b/Samples/SimpleChat/FodyWeavers.xml deleted file mode 100644 index f00ec6d1ae0c919786c9e6a6e86f69d34bf8ead7..0000000000000000000000000000000000000000 --- a/Samples/SimpleChat/FodyWeavers.xml +++ /dev/null @@ -1,4 +0,0 @@ - - - - \ No newline at end of file diff --git a/Samples/SimpleChat/SayResponder.cs b/Samples/SimpleChat/SayResponder.cs deleted file mode 100644 index 88609ab1e9761ce2ff6e19a9f250256f0037ed10..0000000000000000000000000000000000000000 --- a/Samples/SimpleChat/SayResponder.cs +++ /dev/null @@ -1,51 +0,0 @@ -// -// SayResponder.cs -// -// Copyright (c) František Boháček. All rights reserved. -// Licensed under the MIT license. See LICENSE file in the project root for full license information. - -using NosSmooth.Core.Client; -using NosSmooth.Core.Packets; -using NosSmooth.Packets.Enums; -using NosSmooth.Packets.Enums.Chat; -using NosSmooth.Packets.Server.Chat; -using Remora.Results; - -namespace SimpleChat; - -/// -/// Responds to . -/// -public class SayResponder : IPacketResponder, IPacketResponder -{ - private readonly INostaleClient _client; - - /// - /// Initializes a new instance of the class. - /// - /// The nostale client. - public SayResponder(INostaleClient client) - { - _client = client; - } - - /// - public Task Respond(PacketEventArgs packet, CancellationToken ct = default) - { - return _client.ReceivePacketAsync - ( - new SayPacket(EntityType.Map, 1, SayColor.Red, "Hello world from NosSmooth!"), - ct - ); - } - - /// - public Task Respond(PacketEventArgs packet, CancellationToken ct = default) - { - return _client.ReceivePacketAsync - ( - new SayPacket(EntityType.Map, 1, SayColor.Red, "Hello world from NosSmooth!"), - ct - ); - } -} \ No newline at end of file diff --git a/Samples/SimpleChat/SimpleChat.cs b/Samples/SimpleChat/SimpleChat.cs deleted file mode 100644 index 72d95c7c5f3e92a7469eb3edf0fd7fe16ba76cb2..0000000000000000000000000000000000000000 --- a/Samples/SimpleChat/SimpleChat.cs +++ /dev/null @@ -1,74 +0,0 @@ -// -// SimpleChat.cs -// -// Copyright (c) František Boháček. All rights reserved. -// Licensed under the MIT license. See LICENSE file in the project root for full license information. - -using Microsoft.Extensions.DependencyInjection; -using Microsoft.Extensions.Logging; -using NosSmooth.Core.Client; -using NosSmooth.Core.Extensions; -using NosSmooth.LocalBinding; -using NosSmooth.LocalClient.Extensions; -using NosSmooth.Packets.Enums; -using NosSmooth.Packets.Enums.Chat; -using NosSmooth.Packets.Extensions; -using NosSmooth.Packets.Packets; -using NosSmooth.Packets.Server.Chat; - -namespace SimpleChat; - -/// -/// The main simple chat class. -/// -public class SimpleChat -{ - /// - /// Run the client. - /// - /// The task that may or may not have succeeded. - public async Task RunAsync() - { - var provider = new ServiceCollection() - .AddLocalClient() - .AddPacketResponder() - .AddLogging - ( - b => - { - b.ClearProviders(); - b.AddConsole(); - b.SetMinimumLevel(LogLevel.Debug); - } - ) - .BuildServiceProvider(); - - var logger = provider.GetRequiredService>(); - logger.LogInformation("Hello world from SimpleChat!"); - - var bindingManager = provider.GetRequiredService(); - var initializeResult = bindingManager.Initialize(); - if (!initializeResult.IsSuccess) - { - logger.LogError($"Could not initialize NosBindingManager."); - logger.LogResultError(initializeResult); - } - - var packetTypesRepository = provider.GetRequiredService(); - var packetAddResult = packetTypesRepository.AddDefaultPackets(); - if (!packetAddResult.IsSuccess) - { - logger.LogError("Could not initialize default packet serializers correctly"); - logger.LogResultError(packetAddResult); - } - - var client = provider.GetRequiredService(); - - await client.ReceivePacketAsync - ( - new SayPacket(EntityType.Map, 1, SayColor.Red, "Hello world from NosSmooth!") - ); - - await client.RunAsync(); - } -} \ No newline at end of file diff --git a/Samples/SimpleChat/SimpleChat.csproj b/Samples/SimpleChat/SimpleChat.csproj deleted file mode 100644 index 2907d996ce5ed7b7001bc4f257ff5f3b2d7f434a..0000000000000000000000000000000000000000 --- a/Samples/SimpleChat/SimpleChat.csproj +++ /dev/null @@ -1,26 +0,0 @@ - - - net6.0 - enable - enable - 10 - true - - - - all - runtime; build; native; contentfiles; analyzers; buildtransitive - - - all - runtime; build; native; contentfiles; analyzers; buildtransitive - - - - - - - - - - \ No newline at end of file diff --git a/Samples/WalkCommands/Commands/CombatCommands.cs b/Samples/WalkCommands/Commands/CombatCommands.cs deleted file mode 100644 index 3ab9867269335cae85ed58857ac0819d9a1639d1..0000000000000000000000000000000000000000 --- a/Samples/WalkCommands/Commands/CombatCommands.cs +++ /dev/null @@ -1,92 +0,0 @@ -// -// CombatCommands.cs -// -// Copyright (c) František Boháček. All rights reserved. -// Licensed under the MIT license. See LICENSE file in the project root for full license information. - -using NosSmooth.ChatCommands; -using NosSmooth.Core.Client; -using NosSmooth.LocalBinding; -using NosSmooth.LocalBinding.Objects; -using NosSmooth.LocalBinding.Structs; -using Remora.Commands.Attributes; -using Remora.Commands.Groups; -using Remora.Results; - -namespace WalkCommands.Commands; - -/// -/// Represents command group for combat commands. -/// -public class CombatCommands : CommandGroup -{ - private readonly UnitManagerBinding _unitManagerBinding; - private readonly SceneManager _sceneManager; - private readonly PlayerManagerBinding _playerManagerBinding; - private readonly FeedbackService _feedbackService; - - /// - /// Initializes a new instance of the class. - /// - /// The scene manager binding. - /// The scene manager. - /// The character binding. - /// The feedback service. - public CombatCommands - ( - UnitManagerBinding unitManagerBinding, - SceneManager sceneManager, - PlayerManagerBinding playerManagerBinding, - FeedbackService feedbackService - ) - { - _unitManagerBinding = unitManagerBinding; - _sceneManager = sceneManager; - _playerManagerBinding = playerManagerBinding; - _feedbackService = feedbackService; - } - - /// - /// Focus the given entity. - /// - /// The entity id to focus. - /// A task that may or may not have succeeded. - [Command("focus")] - public Task HandleFocusAsync(int entityId) - { - var entityResult = _sceneManager.FindEntity(entityId); - if (!entityResult.IsSuccess) - { - return Task.FromResult(Result.FromError(entityResult)); - } - - return Task.FromResult(_unitManagerBinding.FocusEntity(entityResult.Entity)); - } - - /// - /// Follow the given entity. - /// - /// The entity id to follow. - /// A task that may or may not have succeeded. - [Command("follow")] - public Task HandleFollowAsync(int entityId) - { - var entityResult = _sceneManager.FindEntity(entityId); - if (!entityResult.IsSuccess) - { - return Task.FromResult(Result.FromError(entityResult)); - } - - return Task.FromResult(_playerManagerBinding.FollowEntity(entityResult.Entity)); - } - - /// - /// Stop following an entity. - /// - /// A task that may or may not have succeeded. - [Command("unfollow")] - public Task HandleUnfollowAsync() - { - return Task.FromResult(_playerManagerBinding.UnfollowEntity()); - } -} \ No newline at end of file diff --git a/Samples/WalkCommands/Commands/DetachCommand.cs b/Samples/WalkCommands/Commands/DetachCommand.cs deleted file mode 100644 index e423b0bee47e761f28157db9b3c6d5e7c44a949c..0000000000000000000000000000000000000000 --- a/Samples/WalkCommands/Commands/DetachCommand.cs +++ /dev/null @@ -1,52 +0,0 @@ -// -// DetachCommand.cs -// -// Copyright (c) František Boháček. All rights reserved. -// Licensed under the MIT license. See LICENSE file in the project root for full license information. - -using NosSmooth.ChatCommands; -using NosSmooth.Core.Client; -using NosSmooth.Packets.Enums; -using NosSmooth.Packets.Enums.Chat; -using NosSmooth.Packets.Server.Chat; -using Remora.Commands.Groups; -using Remora.Results; - -namespace WalkCommands.Commands; - -/// -/// Group for detaching command that detaches the dll. -/// -public class DetachCommand : CommandGroup -{ - private readonly CancellationTokenSource _dllStop; - private readonly FeedbackService _feedbackService; - - /// - /// Initializes a new instance of the class. - /// - /// The cancellation token source to stop the client. - /// The feedback service. - public DetachCommand(CancellationTokenSource dllStop, FeedbackService feedbackService) - { - _dllStop = dllStop; - _feedbackService = feedbackService; - } - - /// - /// Detach the dll. - /// - /// A result that may or may not have succeeded. - public async Task HandleDetach() - { - var receiveResult = await _feedbackService.SendInfoMessageAsync("Going to detach!", CancellationToken); - - if (!receiveResult.IsSuccess) - { - return receiveResult; - } - - _dllStop.Cancel(); - return Result.FromSuccess(); - } -} diff --git a/Samples/WalkCommands/Commands/WalkCommands.cs b/Samples/WalkCommands/Commands/WalkCommands.cs deleted file mode 100644 index 203f5b126229b143e6fcfdba154d124fd24edba1..0000000000000000000000000000000000000000 --- a/Samples/WalkCommands/Commands/WalkCommands.cs +++ /dev/null @@ -1,87 +0,0 @@ -// -// WalkCommands.cs -// -// Copyright (c) František Boháček. All rights reserved. -// Licensed under the MIT license. See LICENSE file in the project root for full license information. - -using NosSmooth.ChatCommands; -using NosSmooth.Core.Client; -using NosSmooth.Core.Commands; -using NosSmooth.Core.Commands.Walking; -using NosSmooth.Core.Extensions; -using NosSmooth.Packets.Enums; -using NosSmooth.Packets.Enums.Chat; -using NosSmooth.Packets.Server.Chat; -using Remora.Commands.Attributes; -using Remora.Commands.Groups; -using Remora.Results; - -namespace WalkCommands.Commands; - -/// -/// Represents command group for walking. -/// -public class WalkCommands : CommandGroup -{ - private readonly INostaleClient _client; - private readonly FeedbackService _feedbackService; - - /// - /// Initializes a new instance of the class. - /// - /// The nostale client. - /// The feedback service. - public WalkCommands(INostaleClient client, FeedbackService feedbackService) - { - _client = client; - _feedbackService = feedbackService; - } - - /// - /// Attempts to walk the character to the specified lcoation. - /// - /// The x coordinate. - /// The y coordinate. - /// Whether the user can cancel the operation. - /// The pet selectors indices. - /// A result that may or may not have succeeded. - [Command("walk")] - public async Task HandleWalkToAsync - ( - ushort x, - ushort y, - bool isCancellable = true, - [Option('p', "pet")] params int[] petSelectors - ) - { - var receiveResult = await _client.ReceivePacketAsync - ( - new SayPacket(EntityType.Map, 1, SayColor.Red, $"Going to walk to {x} {y}."), - CancellationToken - ); - - if (!receiveResult.IsSuccess) - { - return receiveResult; - } - - var command = new WalkCommand(x, y, petSelectors, AllowUserCancel: isCancellable); - var walkResult = await _client.SendCommandAsync(command, CancellationToken); - if (!walkResult.IsSuccess) - { - await _feedbackService.SendErrorMessageAsync($"Could not finish walking. {walkResult.ToFullString()}", CancellationToken); - await _client.ReceivePacketAsync - ( - new SayPacket(EntityType.Map, 1, SayColor.Red, "Could not finish walking."), - CancellationToken - ); - return walkResult; - } - - return await _client.ReceivePacketAsync - ( - new SayPacket(EntityType.Map, 1, SayColor.Red, "Walk has finished successfully."), - CancellationToken - ); - } -} diff --git a/Samples/WalkCommands/DllMain.cs b/Samples/WalkCommands/DllMain.cs deleted file mode 100644 index 56e71dea5be8e53d3c4fc336dab7768a2a99a0cc..0000000000000000000000000000000000000000 --- a/Samples/WalkCommands/DllMain.cs +++ /dev/null @@ -1,40 +0,0 @@ -// -// DllMain.cs -// -// Copyright (c) František Boháček. All rights reserved. -// Licensed under the MIT license. See LICENSE file in the project root for full license information. - -using System.Runtime.InteropServices; - -namespace WalkCommands; - -/// -/// Represents the dll entrypoint class. -/// -public class DllMain -{ - [DllImport("kernel32")] -#pragma warning disable SA1600 - public static extern bool AllocConsole(); -#pragma warning restore SA1600 - - /// - /// Represents the dll entrypoint method. - /// - [UnmanagedCallersOnly(EntryPoint = "Main")] - public static void Main() - { - AllocConsole(); - new Thread(() => - { - try - { - new Startup().RunAsync().GetAwaiter().GetResult(); - } - catch (Exception e) - { - Console.WriteLine(e.ToString()); - } - }).Start(); - } -} \ No newline at end of file diff --git a/Samples/WalkCommands/FodyWeavers.xml b/Samples/WalkCommands/FodyWeavers.xml deleted file mode 100644 index f1dea8fce9bddae509f2662795dd13fd40a5ee75..0000000000000000000000000000000000000000 --- a/Samples/WalkCommands/FodyWeavers.xml +++ /dev/null @@ -1,3 +0,0 @@ - - - \ No newline at end of file diff --git a/Samples/WalkCommands/Startup.cs b/Samples/WalkCommands/Startup.cs deleted file mode 100644 index ca39e722e3c566348d40230dcc9cdb2fe1bd9f30..0000000000000000000000000000000000000000 --- a/Samples/WalkCommands/Startup.cs +++ /dev/null @@ -1,82 +0,0 @@ -// -// Startup.cs -// -// Copyright (c) František Boháček. All rights reserved. -// Licensed under the MIT license. See LICENSE file in the project root for full license information. - -using Microsoft.Extensions.DependencyInjection; -using Microsoft.Extensions.Logging; -using NosSmooth.ChatCommands; -using NosSmooth.Core.Client; -using NosSmooth.Core.Extensions; -using NosSmooth.LocalBinding; -using NosSmooth.LocalClient; -using NosSmooth.LocalClient.Extensions; -using NosSmooth.Packets.Extensions; -using NosSmooth.Packets.Packets; -using Remora.Commands.Extensions; -using WalkCommands.Commands; - -namespace WalkCommands; - -/// -/// Startup class of WalkCommands. -/// -public class Startup -{ - private IServiceProvider BuildServices() - { - var collection = new ServiceCollection() - .AddLocalClient() - .AddScoped() - .AddScoped() - .AddSingleton() - .Configure(o => o.AllowIntercept = true) - .AddNostaleChatCommands() - .AddLogging - ( - b => - { - b.ClearProviders(); - b.AddConsole(); - b.SetMinimumLevel(LogLevel.Debug); - } - ); - - collection.AddCommandTree() - .WithCommandGroup() - .WithCommandGroup() - .WithCommandGroup(); - return collection.BuildServiceProvider(); - } - - /// - /// Run the MoveToMiniland. - /// - /// A task that may or may not have succeeded. - public async Task RunAsync() - { - var provider = BuildServices(); - var bindingManager = provider.GetRequiredService(); - var logger = provider.GetRequiredService>(); - var initializeResult = bindingManager.Initialize(); - if (!initializeResult.IsSuccess) - { - logger.LogError($"Could not initialize NosBindingManager."); - logger.LogResultError(initializeResult); - } - - var packetTypesRepository = provider.GetRequiredService(); - var packetAddResult = packetTypesRepository.AddDefaultPackets(); - if (!packetAddResult.IsSuccess) - { - logger.LogError("Could not initialize default packet serializers correctly"); - logger.LogResultError(packetAddResult); - } - - var mainCancellation = provider.GetRequiredService(); - - var client = provider.GetRequiredService(); - await client.RunAsync(mainCancellation.Token); - } -} \ No newline at end of file diff --git a/Samples/WalkCommands/WalkCommands.csproj b/Samples/WalkCommands/WalkCommands.csproj deleted file mode 100644 index dfa20e408ca077666fb433bc360cf81b4bd64dd5..0000000000000000000000000000000000000000 --- a/Samples/WalkCommands/WalkCommands.csproj +++ /dev/null @@ -1,42 +0,0 @@ - - - net6.0 - enable - enable - WalkCommands - WalkCommands - 10 - true - true - true - PackageReference - - - - 5.7.0 - all - runtime; build; native; contentfiles; analyzers; buildtransitive - - - 6.6.0 - all - runtime; build; native; contentfiles; analyzers; buildtransitive - - - 6.0.0 - - - 6.0.0 - - - 6.0.0 - - - 7.1.0 - - - - - - - \ No newline at end of file