Created a Dialog for the injection

save the folder strcuture:
dumps: /saviine_root/dump/game_id/8000000x/
injections: /saviine_root/inject/game_id/8000000x/

didn't tested it. So probably this won't work.

need to and the dialog option to overwrite the common folder on wiiU
This commit is contained in:
Maschell 2015-10-24 22:45:12 +02:00
parent c525e2546e
commit 7356f4029c
10 changed files with 398 additions and 42 deletions

6
.gitignore vendored
View File

@ -52,3 +52,9 @@ saviine/server/src/obj/x86/Debug/saviine_server.pdb
saviine/server/src/bin/saviine_server.vshost.exe saviine/server/src/bin/saviine_server.vshost.exe
saviine/server/src/bin/saviine_server.exe.config saviine/server/src/bin/saviine_server.exe.config
saviine/server/src/bin/saviine_server.vshost.exe.config saviine/server/src/bin/saviine_server.vshost.exe.config
saviine/server/src/obj/x86/Debug/DesignTimeResolveAssemblyReferences.cache
saviine/server/src/obj/x86/Debug/DesignTimeResolveAssemblyReferencesInput.cache
saviine/server/src/obj/x86/Debug/saviine_server.csprojResolveAssemblyReference.cache
saviine/server/src/obj/x86/Debug/saviine_server.csproj.FileListAbsolute.txt
saviine/server/src/obj/x86/Debug/saviine_server.csproj.GenerateResource.Cache
saviine/server/src/obj/x86/Debug/saviine_server.Form1.resources

View File

@ -1,6 +1,7 @@
using System; using System;
using System.IO; using System.IO;
using System.Net; using System.Net;
using System.Windows.Forms;
using System.Net.Sockets; using System.Net.Sockets;
using System.Runtime.InteropServices; using System.Runtime.InteropServices;
using System.Text; using System.Text;
@ -83,6 +84,7 @@ namespace saviine_server
const uint BUFFER_SIZE = 64 * 1024; const uint BUFFER_SIZE = 64 * 1024;
static Boolean fastmode = false; static Boolean fastmode = false;
static byte op_mode = BYTE_MODE_D; static byte op_mode = BYTE_MODE_D;
[STAThread]
static void Main(string[] args) static void Main(string[] args)
{ {
if (args.Length > 1) if (args.Length > 1)
@ -198,6 +200,30 @@ namespace saviine_server
return x; return x;
} }
static string getRealPath(string path,string title_id){
SaveSelectorDialog ofd = new SaveSelectorDialog(path, title_id);
try
{
DialogResult result = ofd.ShowDialog();
if (result == System.Windows.Forms.DialogResult.OK)
{
Console.WriteLine("selected: " + ofd.NewPath);
return ofd.NewPath;
}
else
{
Console.WriteLine("nothing selected");
}
}
catch(Exception e)
{
Console.WriteLine("No saves found to inject");
}
return "";
}
static void Handle(object client_obj) static void Handle(object client_obj)
{ {
string name = Thread.CurrentThread.Name; string name = Thread.CurrentThread.Name;
@ -220,7 +246,9 @@ namespace saviine_server
string LocalRoot = root + "\\" + ids[0].ToString("X8") + "-" + ids[1].ToString("X8") + "\\"; string LocalRootDump = root + "\\" + "dump" + "\\" + ids[0].ToString("X8") + "-" + ids[1].ToString("X8") + "\\";
string LocalRootInject = root + "\\" + "inject" + "\\" + ids[0].ToString("X8") + "-" + ids[1].ToString("X8") + "\\";
if (!ids[0].ToString("X8").Equals("00050000")) if (!ids[0].ToString("X8").Equals("00050000"))
{ {
writer.Write(BYTE_NORMAL); writer.Write(BYTE_NORMAL);
@ -228,9 +256,13 @@ namespace saviine_server
} }
else else
{ {
if (!Directory.Exists(LocalRoot)) if (!Directory.Exists(LocalRootDump))
{ {
Directory.CreateDirectory(LocalRoot); Directory.CreateDirectory(LocalRootDump);
}
if (!Directory.Exists(LocalRootInject))
{
Directory.CreateDirectory(LocalRootInject);
} }
} }
// Log connection // Log connection
@ -240,7 +272,8 @@ namespace saviine_server
// Create log file for current thread // Create log file for current thread
log = new StreamWriter(logs_root + "\\" + DateTime.Now.ToString("yyyy-MM-dd") + "-" + name + "-" + ids[0].ToString("X8") + "-" + ids[1].ToString("X8") + ".txt", true, Encoding.ASCII, 1024*64); log = new StreamWriter(logs_root + "\\" + DateTime.Now.ToString("yyyy-MM-dd") + "-" + name + "-" + ids[0].ToString("X8") + "-" + ids[1].ToString("X8") + ".txt", true, Encoding.ASCII, 1024*64);
log.WriteLine(name + " Accepted connection from client " + client.Client.RemoteEndPoint.ToString()); log.WriteLine(name + " Accepted connection from client " + client.Client.RemoteEndPoint.ToString());
log.WriteLine(name + " TitleID: " + ids[0].ToString("X8") + "-" + ids[1].ToString("X8")); string title_id = ids[0].ToString("X8") + "-" + ids[1].ToString("X8");
log.WriteLine(name + " TitleID: " + title_id);
writer.Write(BYTE_SPECIAL); writer.Write(BYTE_SPECIAL);
@ -253,7 +286,7 @@ namespace saviine_server
case BYTE_OPEN: case BYTE_OPEN:
{ {
//Log(log, "BYTE_OPEN"); //Log(log, "BYTE_OPEN");
bool request_slow = false; Boolean failed = false;
int len_path = reader.ReadInt32(); int len_path = reader.ReadInt32();
int len_mode = reader.ReadInt32(); int len_mode = reader.ReadInt32();
@ -262,8 +295,10 @@ namespace saviine_server
string mode = reader.ReadString(Encoding.ASCII, len_mode - 1); string mode = reader.ReadString(Encoding.ASCII, len_mode - 1);
if (reader.ReadByte() != 0) throw new InvalidDataException(); if (reader.ReadByte() != 0) throw new InvalidDataException();
path = getRealPathCurrent(path, title_id);
if (path.Length == 0) failed = true;
if (File.Exists(LocalRoot + path)) if (File.Exists(path) && !failed)
{ {
int handle = -1; int handle = -1;
for (int i = 1; i < files.Length; i++) for (int i = 1; i < files.Length; i++)
@ -284,17 +319,15 @@ namespace saviine_server
} }
//Log(log, name + " -> fopen(\"" + path + "\", \"" + mode + "\") = " + handle.ToString()); //Log(log, name + " -> fopen(\"" + path + "\", \"" + mode + "\") = " + handle.ToString());
files[handle] = new FileStream(LocalRoot + path, FileMode.Open, FileAccess.Read, FileShare.Read); files[handle] = new FileStream(path, FileMode.Open, FileAccess.Read, FileShare.Read);
writer.Write(BYTE_SPECIAL); writer.Write(BYTE_SPECIAL);
writer.Write(0); writer.Write(0);
writer.Write(handle); writer.Write(handle);
break;
} }
else { writer.Write(BYTE_NORMAL); } //else on error:
writer.Write(BYTE_NORMAL);
// Log(log, "No request found: " + LocalRoot + path);
break; break;
} }
@ -326,21 +359,18 @@ namespace saviine_server
} }
case BYTE_GET_FILES: case BYTE_GET_FILES:
{ {
Boolean failed = false;
int len_path = reader.ReadInt32(); int len_path = reader.ReadInt32();
string path = reader.ReadString(Encoding.ASCII, len_path-1); string path = reader.ReadString(Encoding.ASCII, len_path-1);
if (reader.ReadByte() != 0) throw new InvalidDataException(); if (reader.ReadByte() != 0) throw new InvalidDataException();
int x = 0; int x = 0;
if (path[0] == '/' && path[1] == '/')
{
path = path.Substring(2);
}
else if (path[0] == '/')
{
path = path.Substring(1);
}
path = LocalRoot + path;
if(Directory.Exists(path)) { currentPersistentID = getPersistentIDFromPath(path);
path = getRealPath(path, title_id);
if(path.Length == 0)failed = true;
if (Directory.Exists(path) && !failed)
{
x = countDirectory(path); x = countDirectory(path);
if (x > 0) if (x > 0)
{ {
@ -391,26 +421,19 @@ namespace saviine_server
} }
writer.Write(BYTE_SPECIAL); // writer.Write(BYTE_SPECIAL); //
//Console.Write("file sent, wrote special byte \n"); //Console.Write("file sent, wrote special byte \n");
break;
} }
else else
{ {
writer.Write(BYTE_END); //
//Console.Write("list was empty return BYTE_END \n");
dir_files.Remove(path); dir_files.Remove(path);
//Console.Write("removed \"" + path + "\" from dic \n"); //Console.Write("removed \"" + path + "\" from dic \n");
} }
} }
else }
{
//Console.Write(path + "empty \n");
writer.Write(BYTE_END); // writer.Write(BYTE_END); //
} //Console.Write("list was empty return BYTE_END \n");
}
else
{
//Console.Write(path + " is not found\n");
writer.Write(BYTE_END); //
}
//Console.Write("in break \n"); //Console.Write("in break \n");
break; break;
} }
@ -420,7 +443,6 @@ namespace saviine_server
int size = reader.ReadInt32(); int size = reader.ReadInt32();
int fd = reader.ReadInt32(); int fd = reader.ReadInt32();
FileStream f = files[fd]; FileStream f = files[fd];
byte[] buffer = new byte[size]; byte[] buffer = new byte[size];
@ -464,13 +486,13 @@ namespace saviine_server
int len_path = reader.ReadInt32(); int len_path = reader.ReadInt32();
string path = reader.ReadString(Encoding.ASCII, len_path - 1); string path = reader.ReadString(Encoding.ASCII, len_path - 1);
if (reader.ReadByte() != 0) throw new InvalidDataException(); if (reader.ReadByte() != 0) throw new InvalidDataException();
if (!Directory.Exists(LocalRoot + "dump" + path)) if (!Directory.Exists(LocalRootDump + path))
{ {
Directory.CreateDirectory(Path.GetDirectoryName(LocalRoot + "dump" + path)); Directory.CreateDirectory(Path.GetDirectoryName(LocalRootDump + path));
} }
// Add new file for incoming data // Add new file for incoming data
files_request.Add(fd, new FileStream(LocalRoot + "dump" + path, FileMode.OpenOrCreate, FileAccess.Write, FileShare.Write)); files_request.Add(fd, new FileStream(LocalRootDump + path, FileMode.OpenOrCreate, FileAccess.Write, FileShare.Write));
// Send response // Send response
if (fastmode) { if (fastmode) {
writer.Write(BYTE_REQUEST); writer.Write(BYTE_REQUEST);
@ -629,5 +651,43 @@ namespace saviine_server
} }
Console.WriteLine(name + " Exit"); Console.WriteLine(name + " Exit");
} }
private static string getPersistentIDFromPath(string path)
{
string[] stringSeparators = new string[] { "vol/save/", "vol\\save\\" };
string[] result;
string resultstr = "";
result = path.Split(stringSeparators, StringSplitOptions.None);
if (result.Length < 2) return "";
resultstr = result[result.Length-1];
stringSeparators = new string[] { "/", "\\" };
result = resultstr.Split(stringSeparators, StringSplitOptions.None);
if (result.Length < 1) return "";
return result[0];
}
private static string currentPersistentID = "80000009";
private static string getRealPathCurrent(string path, string title_id)
{
if (currentPersistentID.Length == 0) return "";
string[] stringSeparators = new string[] { "vol/save/", "vol\\save\\" };
string[] result;
string resultstr = "";
result = path.Split(stringSeparators, StringSplitOptions.None);
if (result.Length < 2) return "";
resultstr = result[result.Length-1];
stringSeparators = new string[] { "/", "\\" };
result = resultstr.Split(stringSeparators, StringSplitOptions.None);
if (result.Length < 2) return "";
resultstr = "";
for (int i = 1; i < result.Length; i++)
{
resultstr += "/" + result[i];
}
string savePath = Program.root + "/" + "inject" + "/" + title_id + "/" + currentPersistentID + resultstr;
return savePath;
}
} }
} }

View File

@ -0,0 +1,86 @@
namespace saviine_server
{
partial class SaveSelectorDialog
{
/// <summary>
/// Required designer variable.
/// </summary>
private System.ComponentModel.IContainer components = null;
/// <summary>
/// Clean up any resources being used.
/// </summary>
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
{
components.Dispose();
}
base.Dispose(disposing);
}
#region Windows Form Designer generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
this.btn_ok = new System.Windows.Forms.Button();
this.btn_cancel = new System.Windows.Forms.Button();
this.listBox_saves = new System.Windows.Forms.ListBox();
this.SuspendLayout();
//
// btn_ok
//
this.btn_ok.DialogResult = System.Windows.Forms.DialogResult.OK;
this.btn_ok.Location = new System.Drawing.Point(167, 266);
this.btn_ok.Name = "btn_ok";
this.btn_ok.Size = new System.Drawing.Size(105, 33);
this.btn_ok.TabIndex = 0;
this.btn_ok.Text = "OK";
this.btn_ok.UseVisualStyleBackColor = true;
this.btn_ok.Click += new System.EventHandler(this.btn_ok_Click);
//
// btn_cancel
//
this.btn_cancel.DialogResult = System.Windows.Forms.DialogResult.Cancel;
this.btn_cancel.Location = new System.Drawing.Point(332, 269);
this.btn_cancel.Name = "btn_cancel";
this.btn_cancel.Size = new System.Drawing.Size(130, 29);
this.btn_cancel.TabIndex = 1;
this.btn_cancel.Text = "Cancel";
this.btn_cancel.UseVisualStyleBackColor = true;
//
// listBox_saves
//
this.listBox_saves.FormattingEnabled = true;
this.listBox_saves.Location = new System.Drawing.Point(54, 48);
this.listBox_saves.Name = "listBox_saves";
this.listBox_saves.Size = new System.Drawing.Size(408, 160);
this.listBox_saves.TabIndex = 2;
//
// Form1
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(499, 314);
this.Controls.Add(this.listBox_saves);
this.Controls.Add(this.btn_cancel);
this.Controls.Add(this.btn_ok);
this.Name = "Form1";
this.Text = "Form1";
this.Load += new System.EventHandler(this.Form1_Load);
this.ResumeLayout(false);
}
#endregion
private System.Windows.Forms.Button btn_ok;
private System.Windows.Forms.Button btn_cancel;
private System.Windows.Forms.ListBox listBox_saves;
}
}

View File

@ -0,0 +1,67 @@
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.IO;
using System.Linq;
using System.Text;
using System.Windows.Forms;
namespace saviine_server
{
public partial class SaveSelectorDialog : Form
{
private string newPath = "";
public string NewPath
{
get { return newPath; }
}
private static string savePath = Program.root + "/" + "inject";
public SaveSelectorDialog(string path,string title_id)
{
InitializeComponent();
string[] stringSeparators = new string[] { "vol/save/", "vol\\save\\" };
string[] result;
result = path.Split(stringSeparators, StringSplitOptions.None);
if (result.Length < 2) this.Close();
string resultPath = result[result.Length-2];
Console.WriteLine(title_id);
savePath += "/" + title_id;
if (Directory.Exists(savePath))
{
// Recurse into subdirectories of this directory.
string[] subdirectoryEntries = Directory.GetDirectories(savePath);
foreach (string subdirectory in subdirectoryEntries)
{
this.listBox_saves.Items.Add(Path.GetFileName(subdirectory));
}
}
else
{
Console.WriteLine("dir not found! " + savePath);
this.Close();
}
}
private void Form1_Load(object sender, EventArgs e)
{
}
private void btn_ok_Click(object sender, EventArgs e)
{
newPath = savePath + "/" + this.listBox_saves.SelectedItem.ToString();
}
private void btn_cancel_Click(object sender, EventArgs e)
{
}
}
}

View File

@ -0,0 +1,120 @@
<?xml version="1.0" encoding="utf-8"?>
<root>
<!--
Microsoft ResX Schema
Version 2.0
The primary goals of this format is to allow a simple XML format
that is mostly human readable. The generation and parsing of the
various data types are done through the TypeConverter classes
associated with the data types.
Example:
... ado.net/XML headers & schema ...
<resheader name="resmimetype">text/microsoft-resx</resheader>
<resheader name="version">2.0</resheader>
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
<value>[base64 mime encoded serialized .NET Framework object]</value>
</data>
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
<comment>This is a comment</comment>
</data>
There are any number of "resheader" rows that contain simple
name/value pairs.
Each data row contains a name, and value. The row also contains a
type or mimetype. Type corresponds to a .NET class that support
text/value conversion through the TypeConverter architecture.
Classes that don't support this are serialized and stored with the
mimetype set.
The mimetype is used for serialized objects, and tells the
ResXResourceReader how to depersist the object. This is currently not
extensible. For a given mimetype the value must be set accordingly:
Note - application/x-microsoft.net.object.binary.base64 is the format
that the ResXResourceWriter will generate, however the reader can
read any of the formats listed below.
mimetype: application/x-microsoft.net.object.binary.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.soap.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.bytearray.base64
value : The object must be serialized into a byte array
: using a System.ComponentModel.TypeConverter
: and then encoded with base64 encoding.
-->
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
<xsd:element name="root" msdata:IsDataSet="true">
<xsd:complexType>
<xsd:choice maxOccurs="unbounded">
<xsd:element name="metadata">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" />
</xsd:sequence>
<xsd:attribute name="name" use="required" type="xsd:string" />
<xsd:attribute name="type" type="xsd:string" />
<xsd:attribute name="mimetype" type="xsd:string" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="assembly">
<xsd:complexType>
<xsd:attribute name="alias" type="xsd:string" />
<xsd:attribute name="name" type="xsd:string" />
</xsd:complexType>
</xsd:element>
<xsd:element name="data">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="resheader">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" />
</xsd:complexType>
</xsd:element>
</xsd:choice>
</xsd:complexType>
</xsd:element>
</xsd:schema>
<resheader name="resmimetype">
<value>text/microsoft-resx</value>
</resheader>
<resheader name="version">
<value>2.0</value>
</resheader>
<resheader name="reader">
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
</root>

View File

@ -4,3 +4,5 @@ G:\Programmieren\libwiiu-master\saviinet\saviine\saviine\server\src\bin\saviine_
G:\Programmieren\libwiiu-master\saviinet\saviine\saviine\server\src\obj\x86\Debug\saviine_server.csprojResolveAssemblyReference.cache G:\Programmieren\libwiiu-master\saviinet\saviine\saviine\server\src\obj\x86\Debug\saviine_server.csprojResolveAssemblyReference.cache
G:\Programmieren\libwiiu-master\saviinet\saviine\saviine\server\src\obj\x86\Debug\saviine_server.exe G:\Programmieren\libwiiu-master\saviinet\saviine\saviine\server\src\obj\x86\Debug\saviine_server.exe
G:\Programmieren\libwiiu-master\saviinet\saviine\saviine\server\src\obj\x86\Debug\saviine_server.pdb G:\Programmieren\libwiiu-master\saviinet\saviine\saviine\server\src\obj\x86\Debug\saviine_server.pdb
G:\Programmieren\libwiiu-master\saviinet\saviine\saviine\server\src\obj\x86\Debug\saviine_server.Form1.resources
G:\Programmieren\libwiiu-master\saviinet\saviine\saviine\server\src\obj\x86\Debug\saviine_server.csproj.GenerateResource.Cache

View File

@ -51,8 +51,18 @@
<ItemGroup> <ItemGroup>
<Reference Include="System" /> <Reference Include="System" />
<Reference Include="System.configuration" /> <Reference Include="System.configuration" />
<Reference Include="System.Data" />
<Reference Include="System.Drawing" />
<Reference Include="System.Windows.Forms" />
<Reference Include="System.Xml" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<Compile Include="SaveSelectorDialog.cs">
<SubType>Form</SubType>
</Compile>
<Compile Include="SaveSelectorDialog.Designer.cs">
<DependentUpon>SaveSelectorDialog.cs</DependentUpon>
</Compile>
<Compile Include="Program.cs" /> <Compile Include="Program.cs" />
<Compile Include="Properties\AssemblyInfo.cs" /> <Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="System\IO\EndianBinaryReader.cs" /> <Compile Include="System\IO\EndianBinaryReader.cs" />
@ -83,6 +93,11 @@
<Install>true</Install> <Install>true</Install>
</BootstrapperPackage> </BootstrapperPackage>
</ItemGroup> </ItemGroup>
<ItemGroup>
<EmbeddedResource Include="SaveSelectorDialog.resx">
<DependentUpon>SaveSelectorDialog.cs</DependentUpon>
</EmbeddedResource>
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" /> <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<!-- To modify your build process, add your task inside one of the targets below and uncomment it. <!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets. Other similar extension points exist, see Microsoft.Common.targets.