This repository has been archived by the owner on Aug 28, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
11 changed files
with
633 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,114 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> | ||
<Import Project="..\packages\Costura.Fody.3.2.1\build\Costura.Fody.props" Condition="Exists('..\packages\Costura.Fody.3.2.1\build\Costura.Fody.props')" /> | ||
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" /> | ||
<PropertyGroup> | ||
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration> | ||
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform> | ||
<ProjectGuid>{2500CE45-FCD7-4C8C-9BC2-8E8C05EC3FAA}</ProjectGuid> | ||
<OutputType>Exe</OutputType> | ||
<RootNamespace>_2DXTicker</RootNamespace> | ||
<AssemblyName>2DXTicker</AssemblyName> | ||
<TargetFrameworkVersion>v4.5</TargetFrameworkVersion> | ||
<FileAlignment>512</FileAlignment> | ||
<Deterministic>true</Deterministic> | ||
<NuGetPackageImportStamp> | ||
</NuGetPackageImportStamp> | ||
</PropertyGroup> | ||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' "> | ||
<PlatformTarget>AnyCPU</PlatformTarget> | ||
<DebugSymbols>true</DebugSymbols> | ||
<DebugType>full</DebugType> | ||
<Optimize>false</Optimize> | ||
<OutputPath>bin\Debug\</OutputPath> | ||
<DefineConstants>DEBUG;TRACE</DefineConstants> | ||
<ErrorReport>prompt</ErrorReport> | ||
<WarningLevel>4</WarningLevel> | ||
<LangVersion>7.3</LangVersion> | ||
</PropertyGroup> | ||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' "> | ||
<PlatformTarget>AnyCPU</PlatformTarget> | ||
<DebugType>pdbonly</DebugType> | ||
<Optimize>true</Optimize> | ||
<OutputPath>bin\Release\</OutputPath> | ||
<DefineConstants>TRACE</DefineConstants> | ||
<ErrorReport>prompt</ErrorReport> | ||
<WarningLevel>4</WarningLevel> | ||
</PropertyGroup> | ||
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|x64'"> | ||
<DebugSymbols>true</DebugSymbols> | ||
<OutputPath>bin\x64\Debug\</OutputPath> | ||
<DefineConstants>DEBUG;TRACE</DefineConstants> | ||
<DebugType>full</DebugType> | ||
<PlatformTarget>x64</PlatformTarget> | ||
<LangVersion>default</LangVersion> | ||
<ErrorReport>prompt</ErrorReport> | ||
<CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet> | ||
<Prefer32Bit>true</Prefer32Bit> | ||
</PropertyGroup> | ||
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release|x64'"> | ||
<OutputPath>bin\x64\Release\</OutputPath> | ||
<DefineConstants>TRACE</DefineConstants> | ||
<Optimize>true</Optimize> | ||
<DebugType>pdbonly</DebugType> | ||
<PlatformTarget>x64</PlatformTarget> | ||
<ErrorReport>prompt</ErrorReport> | ||
<CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet> | ||
<Prefer32Bit>true</Prefer32Bit> | ||
</PropertyGroup> | ||
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|x86'"> | ||
<DebugSymbols>true</DebugSymbols> | ||
<OutputPath>bin\x86\Debug\</OutputPath> | ||
<DefineConstants>DEBUG;TRACE</DefineConstants> | ||
<DebugType>full</DebugType> | ||
<PlatformTarget>x86</PlatformTarget> | ||
<LangVersion>7.3</LangVersion> | ||
<ErrorReport>prompt</ErrorReport> | ||
<CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet> | ||
<Prefer32Bit>true</Prefer32Bit> | ||
</PropertyGroup> | ||
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release|x86'"> | ||
<OutputPath>bin\x86\Release\</OutputPath> | ||
<DefineConstants>TRACE</DefineConstants> | ||
<Optimize>true</Optimize> | ||
<DebugType>pdbonly</DebugType> | ||
<PlatformTarget>x86</PlatformTarget> | ||
<ErrorReport>prompt</ErrorReport> | ||
<CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet> | ||
<Prefer32Bit>true</Prefer32Bit> | ||
</PropertyGroup> | ||
<ItemGroup> | ||
<Reference Include="Costura, Version=3.2.1.0, Culture=neutral, PublicKeyToken=9919ef960d84173d, processorArchitecture=MSIL"> | ||
<HintPath>..\packages\Costura.Fody.3.2.1\lib\net40\Costura.dll</HintPath> | ||
</Reference> | ||
<Reference Include="Newtonsoft.Json, Version=12.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL"> | ||
<HintPath>..\packages\Newtonsoft.Json.12.0.1\lib\net45\Newtonsoft.Json.dll</HintPath> | ||
</Reference> | ||
<Reference Include="System" /> | ||
<Reference Include="System.Core" /> | ||
<Reference Include="System.Xml.Linq" /> | ||
<Reference Include="System.Data.DataSetExtensions" /> | ||
<Reference Include="Microsoft.CSharp" /> | ||
<Reference Include="System.Data" /> | ||
<Reference Include="System.Net.Http" /> | ||
<Reference Include="System.Xml" /> | ||
</ItemGroup> | ||
<ItemGroup> | ||
<Compile Include="memoryUtilities.cs" /> | ||
<Compile Include="Program.cs" /> | ||
<Compile Include="Properties\AssemblyInfo.cs" /> | ||
</ItemGroup> | ||
<ItemGroup> | ||
<None Include="App.config" /> | ||
<None Include="packages.config" /> | ||
</ItemGroup> | ||
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" /> | ||
<Import Project="..\packages\Fody.3.3.3\build\Fody.targets" Condition="Exists('..\packages\Fody.3.3.3\build\Fody.targets')" /> | ||
<Target Name="EnsureNuGetPackageBuildImports" BeforeTargets="PrepareForBuild"> | ||
<PropertyGroup> | ||
<ErrorText>This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}.</ErrorText> | ||
</PropertyGroup> | ||
<Error Condition="!Exists('..\packages\Fody.3.3.3\build\Fody.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\Fody.3.3.3\build\Fody.targets'))" /> | ||
<Error Condition="!Exists('..\packages\Costura.Fody.3.2.1\build\Costura.Fody.props')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\Costura.Fody.3.2.1\build\Costura.Fody.props'))" /> | ||
</Target> | ||
</Project> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
<?xml version="1.0" encoding="utf-8" ?> | ||
<configuration> | ||
<startup> | ||
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5" /> | ||
</startup> | ||
</configuration> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<Weavers xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="FodyWeavers.xsd"> | ||
<Costura /> | ||
</Weavers> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,111 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"> | ||
<!-- This file was generated by Fody. Manual changes to this file will be lost when your project is rebuilt. --> | ||
<xs:element name="Weavers"> | ||
<xs:complexType> | ||
<xs:all> | ||
<xs:element name="Costura" minOccurs="0" maxOccurs="1"> | ||
<xs:complexType> | ||
<xs:all> | ||
<xs:element minOccurs="0" maxOccurs="1" name="ExcludeAssemblies" type="xs:string"> | ||
<xs:annotation> | ||
<xs:documentation>A list of assembly names to exclude from the default action of "embed all Copy Local references", delimited with line breaks</xs:documentation> | ||
</xs:annotation> | ||
</xs:element> | ||
<xs:element minOccurs="0" maxOccurs="1" name="IncludeAssemblies" type="xs:string"> | ||
<xs:annotation> | ||
<xs:documentation>A list of assembly names to include from the default action of "embed all Copy Local references", delimited with line breaks.</xs:documentation> | ||
</xs:annotation> | ||
</xs:element> | ||
<xs:element minOccurs="0" maxOccurs="1" name="Unmanaged32Assemblies" type="xs:string"> | ||
<xs:annotation> | ||
<xs:documentation>A list of unmanaged 32 bit assembly names to include, delimited with line breaks.</xs:documentation> | ||
</xs:annotation> | ||
</xs:element> | ||
<xs:element minOccurs="0" maxOccurs="1" name="Unmanaged64Assemblies" type="xs:string"> | ||
<xs:annotation> | ||
<xs:documentation>A list of unmanaged 64 bit assembly names to include, delimited with line breaks.</xs:documentation> | ||
</xs:annotation> | ||
</xs:element> | ||
<xs:element minOccurs="0" maxOccurs="1" name="PreloadOrder" type="xs:string"> | ||
<xs:annotation> | ||
<xs:documentation>The order of preloaded assemblies, delimited with line breaks.</xs:documentation> | ||
</xs:annotation> | ||
</xs:element> | ||
</xs:all> | ||
<xs:attribute name="CreateTemporaryAssemblies" type="xs:boolean"> | ||
<xs:annotation> | ||
<xs:documentation>This will copy embedded files to disk before loading them into memory. This is helpful for some scenarios that expected an assembly to be loaded from a physical file.</xs:documentation> | ||
</xs:annotation> | ||
</xs:attribute> | ||
<xs:attribute name="IncludeDebugSymbols" type="xs:boolean"> | ||
<xs:annotation> | ||
<xs:documentation>Controls if .pdbs for reference assemblies are also embedded.</xs:documentation> | ||
</xs:annotation> | ||
</xs:attribute> | ||
<xs:attribute name="DisableCompression" type="xs:boolean"> | ||
<xs:annotation> | ||
<xs:documentation>Embedded assemblies are compressed by default, and uncompressed when they are loaded. You can turn compression off with this option.</xs:documentation> | ||
</xs:annotation> | ||
</xs:attribute> | ||
<xs:attribute name="DisableCleanup" type="xs:boolean"> | ||
<xs:annotation> | ||
<xs:documentation>As part of Costura, embedded assemblies are no longer included as part of the build. This cleanup can be turned off.</xs:documentation> | ||
</xs:annotation> | ||
</xs:attribute> | ||
<xs:attribute name="LoadAtModuleInit" type="xs:boolean"> | ||
<xs:annotation> | ||
<xs:documentation>Costura by default will load as part of the module initialization. This flag disables that behavior. Make sure you call CosturaUtility.Initialize() somewhere in your code.</xs:documentation> | ||
</xs:annotation> | ||
</xs:attribute> | ||
<xs:attribute name="IgnoreSatelliteAssemblies" type="xs:boolean"> | ||
<xs:annotation> | ||
<xs:documentation>Costura will by default use assemblies with a name like 'resources.dll' as a satellite resource and prepend the output path. This flag disables that behavior.</xs:documentation> | ||
</xs:annotation> | ||
</xs:attribute> | ||
<xs:attribute name="ExcludeAssemblies" type="xs:string"> | ||
<xs:annotation> | ||
<xs:documentation>A list of assembly names to exclude from the default action of "embed all Copy Local references", delimited with |</xs:documentation> | ||
</xs:annotation> | ||
</xs:attribute> | ||
<xs:attribute name="IncludeAssemblies" type="xs:string"> | ||
<xs:annotation> | ||
<xs:documentation>A list of assembly names to include from the default action of "embed all Copy Local references", delimited with |.</xs:documentation> | ||
</xs:annotation> | ||
</xs:attribute> | ||
<xs:attribute name="Unmanaged32Assemblies" type="xs:string"> | ||
<xs:annotation> | ||
<xs:documentation>A list of unmanaged 32 bit assembly names to include, delimited with |.</xs:documentation> | ||
</xs:annotation> | ||
</xs:attribute> | ||
<xs:attribute name="Unmanaged64Assemblies" type="xs:string"> | ||
<xs:annotation> | ||
<xs:documentation>A list of unmanaged 64 bit assembly names to include, delimited with |.</xs:documentation> | ||
</xs:annotation> | ||
</xs:attribute> | ||
<xs:attribute name="PreloadOrder" type="xs:string"> | ||
<xs:annotation> | ||
<xs:documentation>The order of preloaded assemblies, delimited with |.</xs:documentation> | ||
</xs:annotation> | ||
</xs:attribute> | ||
</xs:complexType> | ||
</xs:element> | ||
</xs:all> | ||
<xs:attribute name="VerifyAssembly" type="xs:boolean"> | ||
<xs:annotation> | ||
<xs:documentation>'true' to run assembly verification (PEVerify) on the target assembly after all weavers have been executed.</xs:documentation> | ||
</xs:annotation> | ||
</xs:attribute> | ||
<xs:attribute name="VerifyIgnoreCodes" type="xs:string"> | ||
<xs:annotation> | ||
<xs:documentation>A comma-separated list of error codes that can be safely ignored in assembly verification.</xs:documentation> | ||
</xs:annotation> | ||
</xs:attribute> | ||
<xs:attribute name="GenerateXsd" type="xs:boolean"> | ||
<xs:annotation> | ||
<xs:documentation>'false' to turn off automatic generation of the XML Schema file.</xs:documentation> | ||
</xs:annotation> | ||
</xs:attribute> | ||
</xs:complexType> | ||
</xs:element> | ||
</xs:schema> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,144 @@ | ||
using Newtonsoft.Json.Linq; | ||
using System.Threading; | ||
using System.IO; | ||
using System.Diagnostics; | ||
using System; | ||
using System.Text; | ||
using System.IO.Ports; | ||
|
||
namespace _2DXTicker | ||
{ | ||
class Program | ||
{ | ||
static readonly SerialPort serialPort = new SerialPort(); | ||
static readonly MemoryUtilities memUtils = new MemoryUtilities(); | ||
|
||
static readonly int _buildDate = 12142018; | ||
static readonly int _version = IntPtr.Size * 8; | ||
|
||
static readonly string _jsonPath = (Environment.CurrentDirectory + "\\Ticker.json"); | ||
static dynamic _jsonData; | ||
|
||
static bool _waitForProcess = true; | ||
|
||
static IntPtr _hwnd, _pHandle; | ||
static uint _processID; | ||
static Process _process; | ||
|
||
static string _windowTitle, _moduleName; | ||
static int _tickerAddress; | ||
static IntPtr _memoryAddress; | ||
|
||
static void Main() | ||
{ | ||
Console.Clear(); | ||
Console.Title = "2DXTicker"; | ||
Console.Write("-------------------------\nCreated by GHYAKIMA#4310\n-------------------------\nBuild: {0}\nVersion: {1}x\n-------------------------\n", _buildDate,_version); | ||
|
||
// Parse the json file | ||
try { _jsonData = JObject.Parse(File.ReadAllText(_jsonPath)); } | ||
catch (FileNotFoundException ex) { throw ex; } | ||
|
||
// Wait for beatmania process | ||
while (_waitForProcess) | ||
{ | ||
foreach (dynamic _json in _jsonData.Titles) | ||
{ | ||
// Get hwnd | ||
if (_hwnd == IntPtr.Zero) { _hwnd = memUtils.FindWindow((string)_json.windowTitle); _windowTitle = (string)_json.windowTitle; } | ||
else if (_hwnd != IntPtr.Zero && _windowTitle == (string)_json.windowTitle) | ||
{ | ||
_moduleName = (string)_json.moduleName; | ||
_tickerAddress = (int)_json.tickerAddress; | ||
} | ||
} | ||
|
||
// Get process id | ||
if (_processID == 0) { _processID = memUtils.GetWindowPID(_hwnd); } | ||
else | ||
{ | ||
// Get process handle | ||
if (_pHandle == IntPtr.Zero) { _pHandle = memUtils.OpenProcess(_processID); } | ||
|
||
// Get base address of '_moduleName' | ||
_memoryAddress = IntPtr.Add(memUtils.GetModuleAddress(_processID, _moduleName), _tickerAddress); | ||
_waitForProcess = false; | ||
} | ||
|
||
/* */ | ||
Thread.Sleep(1000); | ||
} | ||
|
||
/* debug info */ | ||
if ((bool)_jsonData.Ticker.debug) | ||
{ | ||
Console.Write("_windowTitle: {0}\n_moduleName: {1}\n_tickerAddress: {2}\n-------------------------", _windowTitle, _moduleName, "0x" + _tickerAddress.ToString("X")); | ||
Console.Write("\n_hwnd: {0}\n_processID: {1}\n_pHandle: {2}\n_memoryAddress: {3}\n-------------------------\n", _hwnd, _processID, _pHandle, "0x" + _memoryAddress.ToString("X")); | ||
} | ||
|
||
/* Create event handler */ | ||
_process = Process.GetProcessById((int)_processID); | ||
_process.EnableRaisingEvents = true; | ||
_process.Exited += new EventHandler(process_Exited); | ||
|
||
/* Open serial connection */ | ||
setupConnection(); | ||
|
||
/* Start reading ticker bytes */ | ||
if (serialPort.IsOpen) { | ||
readTickerBytes(); | ||
} | ||
|
||
Thread.Sleep(-1); | ||
} | ||
|
||
private static void setupConnection() | ||
{ | ||
try | ||
{ | ||
serialPort.PortName = _jsonData.Ticker.COM; | ||
serialPort.BaudRate = _jsonData.Ticker.baud; | ||
serialPort.Parity = Parity.None; | ||
serialPort.StopBits = StopBits.One; | ||
serialPort.DtrEnable = true; | ||
serialPort.RtsEnable = true; | ||
serialPort.Open(); | ||
} | ||
catch (Exception ex) | ||
{ | ||
if (ex is UnauthorizedAccessException || ex is IOException) | ||
{ | ||
throw ex; | ||
} | ||
} | ||
} | ||
|
||
private static void readTickerBytes() | ||
{ | ||
/* Read 10 bytes from _memoryAddress & convert to string */ | ||
while (!_waitForProcess && serialPort.IsOpen) | ||
{ | ||
byte[] bytes = memUtils.ReadProcessMemory(_pHandle, _memoryAddress, 9, out int bytesRead); | ||
Console.Write("\rTicker: {0}", Encoding.ASCII.GetString(bytes).Replace("m", " ").Replace("ggggggggg", "*********")); | ||
serialPort.Write(Encoding.ASCII.GetString(bytes).Replace("m", " ").Replace("ggggggggg", "*********")); | ||
Thread.Sleep(1); | ||
} | ||
} | ||
|
||
private static void process_Exited(object sender, EventArgs e) | ||
{ | ||
// Close serialport | ||
serialPort.Close(); | ||
serialPort.Dispose(); | ||
|
||
// Clear & return to main() | ||
_windowTitle = null; _moduleName = null; _hwnd = IntPtr.Zero; | ||
_processID = 0; | ||
_pHandle = IntPtr.Zero; | ||
_tickerAddress = 0; _memoryAddress = IntPtr.Zero; | ||
_waitForProcess = true; | ||
Program.Main(); | ||
} | ||
|
||
} | ||
} |
Oops, something went wrong.