diff --git a/.gitignore b/.gitignore
index 1a97e94..cf15d48 100644
--- a/.gitignore
+++ b/.gitignore
@@ -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.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
diff --git a/saviine/server/src/Program.cs b/saviine/server/src/Program.cs
index cd09473..06fd765 100644
--- a/saviine/server/src/Program.cs
+++ b/saviine/server/src/Program.cs
@@ -1,6 +1,7 @@
using System;
using System.IO;
using System.Net;
+using System.Windows.Forms;
using System.Net.Sockets;
using System.Runtime.InteropServices;
using System.Text;
@@ -83,6 +84,7 @@ namespace saviine_server
const uint BUFFER_SIZE = 64 * 1024;
static Boolean fastmode = false;
static byte op_mode = BYTE_MODE_D;
+ [STAThread]
static void Main(string[] args)
{
if (args.Length > 1)
@@ -198,6 +200,30 @@ namespace saviine_server
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)
{
string name = Thread.CurrentThread.Name;
@@ -217,10 +243,12 @@ namespace saviine_server
uint[] ids = reader.ReadUInt32s(4);
-
- 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"))
{
writer.Write(BYTE_NORMAL);
@@ -228,9 +256,13 @@ namespace saviine_server
}
else
{
- if (!Directory.Exists(LocalRoot))
+ if (!Directory.Exists(LocalRootDump))
{
- Directory.CreateDirectory(LocalRoot);
+ Directory.CreateDirectory(LocalRootDump);
+ }
+ if (!Directory.Exists(LocalRootInject))
+ {
+ Directory.CreateDirectory(LocalRootInject);
}
}
// Log connection
@@ -240,7 +272,8 @@ namespace saviine_server
// 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.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);
@@ -253,17 +286,19 @@ namespace saviine_server
case BYTE_OPEN:
{
//Log(log, "BYTE_OPEN");
- bool request_slow = false;
+ Boolean failed = false;
int len_path = reader.ReadInt32();
int len_mode = reader.ReadInt32();
string path = reader.ReadString(Encoding.ASCII, len_path - 1);
if (reader.ReadByte() != 0) throw new InvalidDataException();
string mode = reader.ReadString(Encoding.ASCII, len_mode - 1);
- if (reader.ReadByte() != 0) throw new InvalidDataException();
+ if (reader.ReadByte() != 0) throw new InvalidDataException();
-
- if (File.Exists(LocalRoot + path))
+ path = getRealPathCurrent(path, title_id);
+ if (path.Length == 0) failed = true;
+
+ if (File.Exists(path) && !failed)
{
int handle = -1;
for (int i = 1; i < files.Length; i++)
@@ -284,18 +319,16 @@ namespace saviine_server
}
//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(0);
writer.Write(handle);
-
+ break;
}
- else { writer.Write(BYTE_NORMAL); }
-
- // Log(log, "No request found: " + LocalRoot + path);
-
-
+ //else on error:
+ writer.Write(BYTE_NORMAL);
+
break;
}
case BYTE_SETPOS:
@@ -326,21 +359,18 @@ namespace saviine_server
}
case BYTE_GET_FILES:
{
+ Boolean failed = false;
int len_path = reader.ReadInt32();
string path = reader.ReadString(Encoding.ASCII, len_path-1);
if (reader.ReadByte() != 0) throw new InvalidDataException();
int x = 0;
- if (path[0] == '/' && path[1] == '/')
+
+ currentPersistentID = getPersistentIDFromPath(path);
+ path = getRealPath(path, title_id);
+ if(path.Length == 0)failed = true;
+
+ if (Directory.Exists(path) && !failed)
{
- path = path.Substring(2);
- }
- else if (path[0] == '/')
- {
- path = path.Substring(1);
- }
- path = LocalRoot + path;
-
- if(Directory.Exists(path)) {
x = countDirectory(path);
if (x > 0)
{
@@ -391,26 +421,19 @@ namespace saviine_server
}
writer.Write(BYTE_SPECIAL); //
//Console.Write("file sent, wrote special byte \n");
+ break;
}
else
{
- writer.Write(BYTE_END); //
- //Console.Write("list was empty return BYTE_END \n");
+
dir_files.Remove(path);
//Console.Write("removed \"" + path + "\" from dic \n");
}
}
- else
- {
- //Console.Write(path + "empty \n");
- writer.Write(BYTE_END); //
- }
- }
- else
- {
- //Console.Write(path + " is not found\n");
- writer.Write(BYTE_END); //
}
+ writer.Write(BYTE_END); //
+ //Console.Write("list was empty return BYTE_END \n");
+
//Console.Write("in break \n");
break;
}
@@ -420,7 +443,6 @@ namespace saviine_server
int size = reader.ReadInt32();
int fd = reader.ReadInt32();
-
FileStream f = files[fd];
byte[] buffer = new byte[size];
@@ -464,13 +486,13 @@ namespace saviine_server
int len_path = reader.ReadInt32();
string path = reader.ReadString(Encoding.ASCII, len_path - 1);
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
- 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
if (fastmode) {
writer.Write(BYTE_REQUEST);
@@ -629,5 +651,43 @@ namespace saviine_server
}
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;
+ }
}
}
diff --git a/saviine/server/src/SaveSelectorDialog.Designer.cs b/saviine/server/src/SaveSelectorDialog.Designer.cs
new file mode 100644
index 0000000..f69b463
--- /dev/null
+++ b/saviine/server/src/SaveSelectorDialog.Designer.cs
@@ -0,0 +1,86 @@
+namespace saviine_server
+{
+ partial class SaveSelectorDialog
+ {
+ ///
+ /// Required designer variable.
+ ///
+ private System.ComponentModel.IContainer components = null;
+
+ ///
+ /// Clean up any resources being used.
+ ///
+ /// true if managed resources should be disposed; otherwise, false.
+ protected override void Dispose(bool disposing)
+ {
+ if (disposing && (components != null))
+ {
+ components.Dispose();
+ }
+ base.Dispose(disposing);
+ }
+
+ #region Windows Form Designer generated code
+
+ ///
+ /// Required method for Designer support - do not modify
+ /// the contents of this method with the code editor.
+ ///
+ 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;
+ }
+}
\ No newline at end of file
diff --git a/saviine/server/src/SaveSelectorDialog.cs b/saviine/server/src/SaveSelectorDialog.cs
new file mode 100644
index 0000000..be599b5
--- /dev/null
+++ b/saviine/server/src/SaveSelectorDialog.cs
@@ -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)
+ {
+
+ }
+
+
+ }
+}
diff --git a/saviine/server/src/SaveSelectorDialog.resx b/saviine/server/src/SaveSelectorDialog.resx
new file mode 100644
index 0000000..1af7de1
--- /dev/null
+++ b/saviine/server/src/SaveSelectorDialog.resx
@@ -0,0 +1,120 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ text/microsoft-resx
+
+
+ 2.0
+
+
+ System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
+
+
+ System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
+
+
\ No newline at end of file
diff --git a/saviine/server/src/bin/saviine_server.exe b/saviine/server/src/bin/saviine_server.exe
index ae95be6..6ea09a5 100644
Binary files a/saviine/server/src/bin/saviine_server.exe and b/saviine/server/src/bin/saviine_server.exe differ
diff --git a/saviine/server/src/obj/x86/Debug/saviine_server.csproj.FileListAbsolute.txt b/saviine/server/src/obj/x86/Debug/saviine_server.csproj.FileListAbsolute.txt
index c08aa6f..ef3b3e3 100644
--- a/saviine/server/src/obj/x86/Debug/saviine_server.csproj.FileListAbsolute.txt
+++ b/saviine/server/src/obj/x86/Debug/saviine_server.csproj.FileListAbsolute.txt
@@ -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.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.Form1.resources
+G:\Programmieren\libwiiu-master\saviinet\saviine\saviine\server\src\obj\x86\Debug\saviine_server.csproj.GenerateResource.Cache
diff --git a/saviine/server/src/obj/x86/Debug/saviine_server.csprojResolveAssemblyReference.cache b/saviine/server/src/obj/x86/Debug/saviine_server.csprojResolveAssemblyReference.cache
index 62c1799..7b16748 100644
Binary files a/saviine/server/src/obj/x86/Debug/saviine_server.csprojResolveAssemblyReference.cache and b/saviine/server/src/obj/x86/Debug/saviine_server.csprojResolveAssemblyReference.cache differ
diff --git a/saviine/server/src/saviine_server.csproj b/saviine/server/src/saviine_server.csproj
index f5cb490..b8f286a 100644
--- a/saviine/server/src/saviine_server.csproj
+++ b/saviine/server/src/saviine_server.csproj
@@ -51,8 +51,18 @@
+
+
+
+
+
+ Form
+
+
+ SaveSelectorDialog.cs
+
@@ -83,6 +93,11 @@
true
+
+
+ SaveSelectorDialog.cs
+
+