Skip to content

Commit

Permalink
Init
Browse files Browse the repository at this point in the history
  • Loading branch information
DartPower committed Dec 12, 2020
1 parent 84290c3 commit 220c669
Show file tree
Hide file tree
Showing 6 changed files with 207 additions and 2 deletions.
25 changes: 25 additions & 0 deletions Cyberpunk2077_SMTPatcher.sln
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 16
VisualStudioVersion = 16.0.30717.126
MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Cyberpunk2077_AVXPatcher", "Cyberpunk2077_AVXPatcher\Cyberpunk2077_AVXPatcher.csproj", "{547095D2-8DF3-434C-85BA-1529D5E7B613}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{547095D2-8DF3-434C-85BA-1529D5E7B613}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{547095D2-8DF3-434C-85BA-1529D5E7B613}.Debug|Any CPU.Build.0 = Debug|Any CPU
{547095D2-8DF3-434C-85BA-1529D5E7B613}.Release|Any CPU.ActiveCfg = Release|Any CPU
{547095D2-8DF3-434C-85BA-1529D5E7B613}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {8DAAB0FA-1D25-4FD2-A784-3C4CD9A98D5C}
EndGlobalSection
EndGlobal
56 changes: 56 additions & 0 deletions Cyberpunk2077_SMTPatcher/Cyberpunk2077_SMTPatcher.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<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>{547095D2-8DF3-434C-85BA-1529D5E7B613}</ProjectGuid>
<OutputType>Exe</OutputType>
<RootNamespace>Cyberpunk2077_SMTPatcher</RootNamespace>
<AssemblyName>Cyberpunk2077_SMTPatcher</AssemblyName>
<TargetFrameworkVersion>v4.8</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<Deterministic>true</Deterministic>
<TargetFrameworkProfile />
</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>
<Prefer32Bit>false</Prefer32Bit>
</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>
<Prefer32Bit>false</Prefer32Bit>
</PropertyGroup>
<PropertyGroup>
<StartupObject>Cyberpunk2077_SMTPatcher.Program</StartupObject>
</PropertyGroup>
<ItemGroup>
<Reference Include="System" />
<Reference Include="System.Core" />
<Reference Include="System.Xml.Linq" />
<Reference Include="System.Data.DataSetExtensions" />
<Reference Include="System.Data" />
<Reference Include="System.Xml" />
</ItemGroup>
<ItemGroup>
<Compile Include="Program.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
</ItemGroup>
<ItemGroup>
<None Include="app.config" />
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
</Project>
90 changes: 90 additions & 0 deletions Cyberpunk2077_SMTPatcher/Program.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,90 @@
using System;
using System.IO;
using System.Reflection;

namespace Cyberpunk2077_SMTPatcher
{
public static class Program
{
static void Main(string[] args)
{
string assemblyPath = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location);
string cp77exe = "Cyberpunk2077.exe";
if (File.Exists(cp77exe + ".smt-patcher-bak"))
{
Console.WriteLine("Backup found. Already patched?");
Console.ReadKey();
}
File.Copy(assemblyPath + Path.DirectorySeparatorChar + cp77exe, assemblyPath + Path.DirectorySeparatorChar + cp77exe + ".smt-patcher-bak", false);
Console.WriteLine("Backup created");
byte[] sourceBytes = StringHexToByteArray("753033C9B8010000000FA28BC8C1F908");
byte[] targetBytes = StringHexToByteArray("743033C9B8010000000FA28BC8C1F908");
BinaryReplace(cp77exe + ".smt-patcher-bak", sourceBytes, cp77exe, targetBytes);
Console.WriteLine("SMT Pattern found and replaced. Cyberpunk 2077 patched successful.");
Console.ReadKey();
}

public static void BinaryReplace(string sourceFile, byte[] sourceSeq, string targetFile, byte[] targetSeq)
{
FileStream sourceStream = File.OpenRead(sourceFile);
FileStream targetStream = File.Create(targetFile);

try
{
int b;
long foundSeqOffset = -1;
int searchByteCursor = 0;

while ((b = sourceStream.ReadByte()) != -1)
{
if (sourceSeq[searchByteCursor] == b)
{
if (searchByteCursor == sourceSeq.Length - 1)
{
targetStream.Write(targetSeq, 0, targetSeq.Length);
searchByteCursor = 0;
foundSeqOffset = -1;
}
else
{
if (searchByteCursor == 0)
{
foundSeqOffset = sourceStream.Position - 1;
}

++searchByteCursor;
}
}
else
{
if (searchByteCursor == 0)
{
targetStream.WriteByte((byte)b);
}
else
{
targetStream.WriteByte(sourceSeq[0]);
sourceStream.Position = foundSeqOffset + 1;
searchByteCursor = 0;
foundSeqOffset = -1;
}
}
}
}
finally
{
sourceStream.Dispose();
targetStream.Dispose();
}
}

public static byte[] StringHexToByteArray(String hex)
{
int NumberChars = hex.Length;
byte[] bytes = new byte[NumberChars / 2];
for (int i = 0; i < NumberChars; i += 2)
bytes[i / 2] = Convert.ToByte(hex.Substring(i, 2), 16);
return bytes;
}
}
}
16 changes: 16 additions & 0 deletions Cyberpunk2077_SMTPatcher/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;

[assembly: AssemblyTitle("SMTPatcher")]
[assembly: AssemblyDescription("SMT Patcher for Cyberpunk 2077")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("SMTPatcher")]
[assembly: AssemblyCopyright("DartPower Team LLC © 2020")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]
[assembly: ComVisible(false)]
[assembly: Guid("2fcb228c-139f-40f3-b266-019aeae9d681")]
[assembly: AssemblyVersion("1.0.0.0")]
[assembly: AssemblyFileVersion("1.0.0.0")]
3 changes: 3 additions & 0 deletions Cyberpunk2077_SMTPatcher/app.config
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<startup><supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.8"/></startup></configuration>
19 changes: 17 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,2 +1,17 @@
# Cyberpunk2077_SMTPatcher
SMT Instructions Fix Patcher for Cyberpunk 2077
# Cyberpunk2077 SMT Patcher

Simultaneous Multi-Threading Fix Patcher for Cyberpunk 2077

Usage:

1. Put "Cyberpunk2077_SMTPatcher.exe" in <Cyberpunk 2077 Install Folder>\bin\x64

2. Run patcher

3. If patching is successful, launch game.

Uninstall patch:

1. Remove Cyberpunk2077.exe

2. Rename Cyberpunk2077.exe.bak to Cyberpunk2077.exe

0 comments on commit 220c669

Please sign in to comment.