Skip to content

Commit

Permalink
File attributes fix
Browse files Browse the repository at this point in the history
  • Loading branch information
ClusterM committed Jan 14, 2017
1 parent d1a35aa commit ba803d7
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 12 deletions.
7 changes: 3 additions & 4 deletions FelLib/WinUSBNet/API/DeviceManagement.cs
Original file line number Diff line number Diff line change
Expand Up @@ -243,16 +243,16 @@ public static DeviceDetails[] FindDevices(UInt16 vid, UInt16 pid)
try
{
#if DEBUG
Fel.DebugLog("Trying to parse device: "+ pathName);
Fel.DebugLog("Trying to parse device: " + pathName);
#endif
DeviceDetails details = GetDeviceDetails(pathName, deviceInfoSet, da);
if (details.VID == vid && details.PID == pid)
deviceList.Add(details);
}
catch (APIException)
catch (APIException ex)
{
#if DEBUG
Fel.DebugLog("Can't parse this device");
Fel.DebugLog("Can't parse this device: " + ex.Message + ex.StackTrace);
#endif
continue;
}
Expand All @@ -267,7 +267,6 @@ public static DeviceDetails[] FindDevices(UInt16 vid, UInt16 pid)
}
memberIndex++;
}
}
finally
{
if (deviceInfoSet != IntPtr.Zero && deviceInfoSet != FileIO.INVALID_HANDLE_VALUE)
Expand Down
23 changes: 18 additions & 5 deletions WorkerForm.cs
Original file line number Diff line number Diff line change
Expand Up @@ -183,10 +183,15 @@ void ShowError(Exception ex)
Invoke(new Action<Exception>(ShowError), new object[] { ex });
return;
}
#if DEBUG
var stackTrace = ex.StackTrace;
#else
var stackTrace = "";
#endif
if (ex is MadWizard.WinUSBNet.USBException)
MessageBox.Show(this, ex.Message + "\r\n" + Resources.PleaseTryAgain + "\r\n" + Resources.PleaseTryAgainUSB, Resources.Error, MessageBoxButtons.OK, MessageBoxIcon.Error);
MessageBox.Show(this, ex.Message + stackTrace + "\r\n" + Resources.PleaseTryAgain + "\r\n" + Resources.PleaseTryAgainUSB, Resources.Error, MessageBoxButtons.OK, MessageBoxIcon.Error);
else
MessageBox.Show(this, ex.Message + "\r\n" + Resources.PleaseTryAgain, Resources.Error, MessageBoxButtons.OK, MessageBoxIcon.Error);
MessageBox.Show(this, ex.Message + stackTrace + "\r\n" + Resources.PleaseTryAgain, Resources.Error, MessageBoxButtons.OK, MessageBoxIcon.Error);
thread = null;
Close();
}
Expand Down Expand Up @@ -237,7 +242,7 @@ public void DoKernelDump()
if (MessageBox.Show(Resources.MD5Failed + " " + hash + "\r\n" + Resources.MD5Failed2 + "\r\n" + Resources.DoYouWantToContinue, Resources.Warning, MessageBoxButtons.YesNo, MessageBoxIcon.Warning)
== DialogResult.No)
{
DialogResult = System.Windows.Forms.DialogResult.Abort;
DialogResult = DialogResult.Abort;
return;
}
}
Expand Down Expand Up @@ -419,6 +424,14 @@ private byte[] CreatePatchedKernel()
if (!ExecuteTool("xcopy", string.Format("\"{0}\" /h /y /c /r /s /q",
Path.Combine(modsDirectory, Mod)), ramfsDirectory, true))
throw new Exception("Can't copy mod directory");
var ramfsFiles = Directory.GetFiles(ramfsDirectory, "*.*", SearchOption.AllDirectories);
foreach (var file in ramfsFiles)
{
var fInfo = new FileInfo(file);
if (fInfo.Length < 100 && ((fInfo.Attributes & FileAttributes.System) == 0) &&
(Encoding.ASCII.GetString(File.ReadAllBytes(file), 0, 10)) == "!<symlink>")
fInfo.Attributes |= FileAttributes.System;
}
if (CreateConfig)
{
var config = string.Format("hakchi_enabled=y\nhakchi_remove_games=y\nhakchi_original_games={0}\nhakchi_title_font={1}\n", OriginalGames ? "y" : "n", UseFont ? "y" : "n");
Expand All @@ -444,7 +457,7 @@ private byte[] CreatePatchedKernel()
File.WriteAllText(hiddenPath, h.ToString());
}
ExecuteTool("upx.exe", "--best sbin\\cryptsetup", ramfsDirectory);

byte[] ramdisk;
if (!ExecuteTool("mkbootfs.exe", string.Format("\"{0}\"", ramfsDirectory), out ramdisk))
throw new Exception("Can't repack ramdisk");
Expand Down Expand Up @@ -489,7 +502,7 @@ private bool ExecuteTool(string tool, string args, out byte[] output, string dir
process.StartInfo.UseShellExecute = false;
process.StartInfo.CreateNoWindow = true;
process.StartInfo.StandardOutputEncoding = Encoding.GetEncoding(1251);
process.StartInfo.RedirectStandardOutput = true;
process.StartInfo.RedirectStandardOutput = true;
process.Start();
string outputStr = process.StandardOutput.ReadToEnd();
process.WaitForExit();
Expand Down
3 changes: 0 additions & 3 deletions hakchi_gui.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -307,9 +307,6 @@
<None Include="mods\mod_uninstall\sbin\init">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
<None Include="tools\mkbootfs.bat">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
</ItemGroup>
<ItemGroup>
<None Include="images\blank.jpg" />
Expand Down

0 comments on commit ba803d7

Please sign in to comment.