OmsiHook 2.5.3
dotnet add package OmsiHook --version 2.5.3
NuGet\Install-Package OmsiHook -Version 2.5.3
<PackageReference Include="OmsiHook" Version="2.5.3" />
paket add OmsiHook --version 2.5.3
#r "nuget: OmsiHook, 2.5.3"
// Install OmsiHook as a Cake Addin #addin nuget:?package=OmsiHook&version=2.5.3 // Install OmsiHook as a Cake Tool #tool nuget:?package=OmsiHook&version=2.5.3
Omsi-Extensions
Omsi hooking and modding sdk.
The dead simple way to hook into Omsi and fiddle with it's memory. In it's current state we only have mappings for a limited number of Omsi objects, but it's easy to extend. Allows both reading and writing data from Omsi in real time, but currently doesn't allow for anything that requires memory allocation (eg: adding elements to arrays).
The library makes use of C# properties and classes to wrap native Omsi objects making them simple to interact with in a managed environment.
See the documentation for details on the API.
Usage Example
Here's a quick example of how to use it.
using OmsiHook;
class Program
{
static void Main(string[] args)
{
// Create an OmsiHook and attach to any running instance of OMSI
OmsiHook.OmsiHook omsi = new();
omsi.AttachToOMSI().Wait();
while (true)
{
// Get the PlayerVehicle and get its position
var pos = omsi.Globals.PlayerVehicle.Position;
// Print the position to the console
Console.WriteLine($"Player vehicle pos: {pos}");
Thread.Sleep(500);
}
}
}
See the OmsiExtensionsCLI
Program.cs for more examples using OmsiHook.
Project Structure
This repository contains the source for the OmsiHook and OmsiHookInvoker libraries as well as template projects using OmsiHook which run under various frameworks.
Here's a summary of the project structure:
\Omsi-Extensions\
┃
┠─► \_OmsiHookExamples\ -> A collection of sample projects demonstrating various OmsiHook
┃ features.
┠─► \OmsiHook\ -> Base library containing all the Omsi hooking code and
┃ exposing Omsi's internal data.
┠─► \OmsiHookInvoker\ -> C++ plugin for invoking native Omsi methods from OmsiHook,
┃ only used by OmsiHook.
┠─► \OmsiHookRPCPlugin\ -> An Omsi plugin which exposes native methods from OmsiHookInvoker
┃ to other processes using OmsiHook.
┠─► \OmsiExtensionsCLI\ -> Example command line application that uses OmsiHook; runs
┃ outside of Omsi.
┠─► \OmsiExtensionsUI\ -> Example Avalonia UI (similar to WPF) application that uses
┃ OmsiHook; runs outside of Omsi.
┖─► \OmsiHookPlugin\ -> Example plugin that uses OmsiHook and compiles to a native
Omsi plugin by using DNNE.
Building
The project requires .NET 6 SDK to build and only works on Windows x86_32. Because of the nature of the project dependencies, sometimes Visual Studio gets the build order wrong (especially for projects depending on OmsiHookInvoker). When updating to a new version of OmsiHook or if you make changes to OmsiHookInvoker you may need to clean and rebuild the solution; if you're really struggling delete the contents of the following directories:
Omsi-Extensions\Debug
Omsi-Extensions\Release
Omsi-Extensions\OmsiExtensionsCLI\bin\
Omsi-Extensions\OmsiHookPlugin\bin\
The project can be configured to automatically copy binaries to your Omsi directory. To do so set the
OmsiDir
environment variable to your Omsi directory (eg: set "OmsiDir=C:\Program Files\OMSI 2\"
).
You can also set it by editing the Post-build event action in the OmsiHookRPCPlugin.csproj
and
OmsiHookPlugin.csproj
project files. Note that the binaries are only copied when OmsiHookRPCPlugin
or OmsiHookPlugin
is rebuilt.
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | net6.0-windows7.0 is compatible. net7.0-windows was computed. net8.0-windows was computed. |
-
net6.0-windows7.0
- memberpage (>= 2.59.4)
- OmsiHookRPCPlugin (>= 1.3.11)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.