Skip to content

Commit

Permalink
配置文件写入完毕
Browse files Browse the repository at this point in the history
  • Loading branch information
Micah123321 committed May 6, 2023
1 parent e95c91a commit a599355
Show file tree
Hide file tree
Showing 4 changed files with 125 additions and 33 deletions.
1 change: 1 addition & 0 deletions OpenCorepiAndBypass/OpenCorepiAndBypass.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@
<Reference Include="System.Xml" />
</ItemGroup>
<ItemGroup>
<Compile Include="src\IniFile.cs" />
<Compile Include="src\Program.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
</ItemGroup>
Expand Down
38 changes: 38 additions & 0 deletions OpenCorepiAndBypass/src/IniFile.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.IO;
using System.Runtime.InteropServices;

namespace OpenCorepiAndBypass.src
{
class IniFile
{
string path;

[DllImport("kernel32")]
private static extern long WritePrivateProfileString(string section, string key, string val, string filePath);

[DllImport("kernel32")]
private static extern int GetPrivateProfileString(string section, string key, string def, StringBuilder retVal, int size, string filePath);

public IniFile(string INIPath)
{
path = INIPath;
}

public void WriteValue(string Section, string Key, string Value)
{
WritePrivateProfileString(Section, Key, Value, this.path);
}

public string ReadValue(string Section, string Key)
{
StringBuilder temp = new StringBuilder(255);
int i = GetPrivateProfileString(Section, Key, "", temp, 255, this.path);
return temp.ToString();
}
}
}
103 changes: 73 additions & 30 deletions OpenCorepiAndBypass/src/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ static void OpenFile(string fileName)
}

//获取文件路径
static string GetFilePath(string title,string filter)
static string GetFilePath(string title, string filter)
{
string filePath = "";
Thread t = new Thread((ThreadStart)(() =>
Expand All @@ -56,54 +56,97 @@ static void Main(string[] args)
{

//TODO
//判断是否存在配置文件
//判断是否开启账号切换器/3dm/注入器/bypass/同时启动的辅助
//判断是否存在配置文件 初始化配置待完成

Program.OpenFile(GetFilePath("选择账号切换器", "GenshinAccount.exe|GenshinAccount.exe"));
System.Console.WriteLine("打开账户切换文件");

src.IniFile ini = new src.IniFile(@Environment.CurrentDirectory+@"\config.ini");

// 暂停5秒
Thread.Sleep(5000);
string genshinAccount = ini.ReadValue("Settings", "GenshinAccount");
if (genshinAccount.Contains("true"))
{
string genshinAccountPath = ini.ReadValue("Settings", "GenshinAccountPath");
Program.OpenFile(@genshinAccountPath);
System.Console.WriteLine("打开账户切换文件");

// 暂停5秒
Thread.Sleep(5000);
}


string ThreeDM = ini.ReadValue("Settings", "ThreeDM");
if (ThreeDM.Contains("true"))
{
string ThreeDMPath = ini.ReadValue("Settings", "ThreeDMPath");
Program.OpenFile(ThreeDMPath);
System.Console.WriteLine("打开3dm");

// 暂停1秒
Thread.Sleep(1000);
}

string ByPass = ini.ReadValue("Settings", "ByPass");
if (ByPass.Contains("true"))
{
string GamePath = ini.ReadValue("Settings", "GamePath");

Program.OpenFile(@"C:\Users\Administrator\Desktop\genshinhack\3dmigoto\play\3DMigoto Loader.exe");
System.Console.WriteLine("打开3dm");
System.Console.WriteLine("bypass");

Program.ChangeFileName(@GamePath + "HoYoKProtect.sys", @GamePath + "HoYoKProtect.sys.bak");
Program.ChangeFileName(@GamePath + "mhypbase.dll", @GamePath + "mhypbase.dll.bak");
Program.ChangeFileName(@GamePath + "mhyprot3.Sys", @GamePath + "mhyprot3.Sys.bak");

// 暂停1秒
Thread.Sleep(1000);

// 暂停1秒
Thread.Sleep(1000);
}

//bypass
System.Console.WriteLine("bypass");
Program.ChangeFileName(@"G:\Genshin Impact\Genshin Impact Game\HoYoKProtect.sys", @"G:\Genshin Impact\Genshin Impact Game\HoYoKProtect.sys.bak");
Program.ChangeFileName(@"G:\Genshin Impact\Genshin Impact Game\mhypbase.dll", @"G:\Genshin Impact\Genshin Impact Game\mhypbase.dll.bak");
Program.ChangeFileName(@"G:\Genshin Impact\Genshin Impact Game\mhyprot3.Sys", @"G:\Genshin Impact\Genshin Impact Game\mhyprot3.Sys.bak");
// 暂停1秒
Thread.Sleep(1000);
//打开注入器
System.Console.WriteLine("打开注入器");
Program.OpenFile(@"C:\Users\Administrator\Desktop\genshinhack\injector.exe");
string Injector = ini.ReadValue("Settings", "Injector");
if (Injector.Contains("true"))
{
string InjectorPath = ini.ReadValue("Settings", "InjectorPath");
Program.OpenFile(InjectorPath);
System.Console.WriteLine("打开注入器");

System.Console.WriteLine("暂停15秒");
// 暂停20秒
Thread.Sleep(20000);
// 暂停15秒
System.Console.WriteLine("暂停15秒");
Thread.Sleep(20000);
}


//取消bypass
System.Console.WriteLine("取消bypass");
Program.ChangeFileName(@"G:\Genshin Impact\Genshin Impact Game\HoYoKProtect.sys.bak", @"G:\Genshin Impact\Genshin Impact Game\HoYoKProtect.sys");
Program.ChangeFileName(@"G:\Genshin Impact\Genshin Impact Game\mhypbase.dll.bak", @"G:\Genshin Impact\Genshin Impact Game\mhypbase.dll");
Program.ChangeFileName(@"G:\Genshin Impact\Genshin Impact Game\mhyprot3.Sys.bak", @"G:\Genshin Impact\Genshin Impact Game\mhyprot3.Sys");
if (ByPass.Contains("true"))
{
string GamePath = ini.ReadValue("Settings", "GamePath");

// 暂停1秒
Thread.Sleep(1000);
System.Console.WriteLine("取消bypass");

Program.ChangeFileName(@GamePath + "HoYoKProtect.sys.bak", @GamePath + "HoYoKProtect.sys");
Program.ChangeFileName(@GamePath + "mhypbase.dll.bak", @GamePath + "mhypbase.dll");
Program.ChangeFileName(@GamePath + "mhyprot3.Sys.bak", @GamePath + "mhyprot3.Sys");


// 暂停1秒
Thread.Sleep(1000);
}



//打开cb
System.Console.WriteLine("打开cb");
Program.OpenFile(@"C:\Users\Administrator\Desktop\genshinhack\Cotton Buds 3.6 - Stable.CETRAINER");


string CB = ini.ReadValue("Settings", "CB");
if (CB.Contains("true"))
{
string CBPath = ini.ReadValue("Settings", "CBPath");
Program.OpenFile(CBPath);
System.Console.WriteLine("打开CB");

}



System.Console.WriteLine("程序完成,回车退出");
System.Console.Read();
}
Expand Down
16 changes: 13 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,11 +1,21 @@
# 自动启动应用程序

本项目是一个使用C#编写的自动启动应用程序的示例,可以在Windows系统上实现开机自动启动指定的应用程序。
本项目是一个使用C#编写的自动启动应用程序,可定制化的绕过原神bypass 并且同时启动任意dll注入器 并且可同时启动3dm原神模型修改工具



# 运行效果

![](https://www.ake1.com/oss/2023-05-06/227966ba.png)





## 如何使用

1. 克隆或下载本项目的代码到本地计算机。
2. 待续
1. 打开release下载[Releases · Micah123321/AutoOpenCAK --- 发布 · Micah123321/AutoOpenCAK (github.com)](https://github.com/Micah123321/AutoOpenCAK/releases)
2. 查看使用说明运行

## 注意事项

Expand Down

0 comments on commit a599355

Please sign in to comment.