Skip to content

Commit

Permalink
No commit message
Browse files Browse the repository at this point in the history
  • Loading branch information
DavidXanatos committed Dec 10, 2019
1 parent 7780680 commit 4136aa8
Show file tree
Hide file tree
Showing 55 changed files with 3,148 additions and 433 deletions.
26 changes: 26 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,32 @@
All notable changes to this project will be documented in this file.
This project adheres to [Semantic Versioning](http://semver.org/).

## [0.65.1] - 2019-12-10

### Added
- added a propper setup
- added setting for using reverse DNS

### Changed
- changed drive letter resolcong cache strategy

### Fixed
- fixed service not proeprly terminating
- fixed issues with service status querying
- fixed issue with notification window oppening unnececerly on a delayed hostname update


## [0.65] - 2019-12-04

### Added
- added new program view mode a verbose program tree, that auto enables when the program column ist stretched wider
- added program context menu
- added additional program options to the ribbon toolbar
- added view modes fill screan, full height, full screen
- dns query log context menu with options to whitelist and blacklist entries
- double clicking a domain in the whitelist/blacklist view copys it to the entry edit for editing



## [0.65] - 2019-12-04

Expand Down
6 changes: 6 additions & 0 deletions PrivateSetup/App.config
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5" />
</startup>
</configuration>
9 changes: 9 additions & 0 deletions PrivateSetup/App.xaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<Application x:Class="PrivateSetup.App"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="clr-namespace:PrivateSetup"
Startup="Application_Startup">
<Application.Resources>

</Application.Resources>
</Application>
244 changes: 244 additions & 0 deletions PrivateSetup/App.xaml.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,244 @@
using System;
using System.Collections.Generic;
using System.Configuration;
using System.Data;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Runtime.ExceptionServices;
using System.Runtime.InteropServices;
using System.Security.Principal;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Resources;
using System.Windows.Threading;

namespace PrivateSetup
{
/// <summary>
/// Interaction logic for App.xaml
/// </summary>
public partial class App : Application
{
public static string Title = "Private Win10 - Setup";
public static string[] args = null;
public static bool HasConsole = false;
public static string exePath = "";
public static string appPath = "";
public static string exeName = "PrivateSetup.exe";
public static Packer packer;


protected override void OnStartup(StartupEventArgs e)
{
// Class "ReflectionContext" exists from .NET 4.5 onwards.
if (Type.GetType("System.Reflection.ReflectionContext", false) == null)
{
MessageBox.Show(string.Format("{0} requirers .NET Framework 4.5 or newer. In order to run {0} please update your .NET installation.", App.Title) , App.Title, MessageBoxButton.OK, MessageBoxImage.Stop);
Environment.Exit(0);
}

args = Environment.GetCommandLineArgs();

HasConsole = WinConsole.Initialize(TestArg("-console"));

if (TestArg("-dbg_wait"))
MessageBox.Show("Waiting for debugger. (press ok when attached)");

if (TestArg("-dbg_log"))
AppDomain.CurrentDomain.FirstChanceException += FirstChanceExceptionHandler;

App.exePath = Assembly.GetExecutingAssembly().Location;
App.appPath = Path.GetDirectoryName(exePath);
//App.exeName = Path.GetFileName(exePath);
//FileVersionInfo fvi = FileVersionInfo.GetVersionInfo(exePath);
//App.Title = fvi.FileDescription; // PrivateWin10 - Setup
//App.exeName = fvi.OriginalFilename; // PrivateSetup.exe

base.OnStartup(e);
}

static private void FirstChanceExceptionHandler(object source, FirstChanceExceptionEventArgs e)
{
Console.WriteLine("FirstChanceException event raised in {0}: {1}\r\n{2}", AppDomain.CurrentDomain.FriendlyName, e.Exception.Message, e.Exception.StackTrace);
}

private void Application_Startup(object sender, StartupEventArgs e)
{
if(HasConsole)
Console.WriteLine("\r\n\r\n{0} Starting...", Title);

packer = new Packer();

string prepare = GetArg("-prepare");
if (prepare != null)
{
bool ret = packer.PrepareSetup(prepare);
Environment.Exit(ret ? 0 : -1);
}

string target = GetArg("-extract");
if (target != null)
{
bool ret = packer.Extract(target);
Environment.Exit(ret ? 0 : -1);
}


if (packer.IsValid())
{
bool ret = packer.Test();
if (!ret)
{
ShowMessage("{0} file is corrupted! Please download a working copy.", App.Title);
Environment.Exit(-1);
}
}
/*else if(!App.TestArg("-uninstall"))
{
ShowMessage("Setup is empty, please run PrivateSetup.exe -prepare");
Environment.Exit(-1);
}*/

#if DEBUG
if (TestArg("-test"))
{
bool ret = packer.Test();
Environment.Exit(ret ? 0 : -1);
}

if (TestArg("-enum"))
{
packer.Enum();
Environment.Exit(0);
}
#endif

/*if (TestArg("-empty"))
{
installer.Empty();
Environment.Exit(0);
}*/


SetupData Data = SetupData.FromArgs();
bool Uninstaller = App.TestArg("-uninstall") || !packer.IsValid(false);

SetupWindow wnd = new SetupWindow(Data, Uninstaller);
wnd.Show();
}

public static void LogMessage(string message, params object[] args)
{
Console.WriteLine(message, args);
}

public static void ShowMessage(string message, params object[] args)
{
Console.WriteLine(message, args);
if (!HasConsole)
MessageBox.Show(string.Format(message, args), App.Title, MessageBoxButton.OK, MessageBoxImage.Exclamation);
}

public static bool IsAdministrator()
{
WindowsIdentity identity = WindowsIdentity.GetCurrent();
WindowsPrincipal principal = new WindowsPrincipal(identity);
return principal.IsInRole(WindowsBuiltInRole.Administrator);
}

public static bool Restart(string[] args, bool bFromTemp = false)
{
string arguments = "\"" + string.Join("\" \"", args) + "\"";
string fileName = exePath;
if (bFromTemp)
{
arguments += " \"-temp\"";

fileName = Path.Combine(Path.GetTempPath(), Guid.NewGuid() + "_" + App.exeName);
File.Copy(exePath, fileName);
}

ProcessStartInfo startInfo = new ProcessStartInfo(fileName, arguments);
startInfo.UseShellExecute = true;
startInfo.Verb = "runas";
try
{
Process.Start(startInfo);
Environment.Exit(0);
return true;
}
catch
{
//MessageBox.Show("Failed to restart with administrative privilegs, setup aborted", App.Title);
//Environment.Exit(-1);
return false;
}
}

static public bool TestArg(string name)
{
for (int i = 0; i < App.args.Length; i++)
{
if (App.args[i].Equals(name, StringComparison.OrdinalIgnoreCase))
return true;
}
return false;
}

static public string GetArg(string name, string def = null)
{
for (int i = 0; i < App.args.Length; i++)
{
if (App.args[i].Equals(name, StringComparison.OrdinalIgnoreCase))
{
string temp = App.args.Length <= (i + 1) ? "" : App.args[i + 1];
if (temp.Length > 0 && temp[0] != '-')
return temp;
return "";
}
}
return def;
}

/////////////////////////////////////////////////////////////////////////////////////////////////////////
// Config

[DllImport("kernel32")]
private static extern long WritePrivateProfileString(string section, string key, string val, string filePath);
public static void IniWriteValue(string INIPath, string Section, string Key, string Value)
{
WritePrivateProfileString(Section, Key, Value, INIPath);
}

public static void IniDeleteSection(string INIPath, string Section)
{
WritePrivateProfileString(Section, null, null, INIPath);
}

[DllImport("kernel32")]
private static extern int GetPrivateProfileString(string section, string key, string def, [In, Out] char[] retVal, int size, string filePath);
public static string IniReadValue(string INIPath, string Section, string Key, string Default = "")
{
char[] chars = new char[8193];
int size = GetPrivateProfileString(Section, Key, Default, chars, 8193, INIPath);
/*int size = GetPrivateProfileString(Section, Key, "\xff", chars, 8193, INIPath);
if (size == 1 && chars[0] == '\xff')
{
WritePrivateProfileString(Section, Key, Default, INIPath != null ? INIPath : GetINIPath());
return Default;
}*/
return new String(chars, 0, size);
}

public static List<string> IniEnumSections(string INIPath)
{
char[] chars = new char[8193];
int size = GetPrivateProfileString(null, null, null, chars, 8193, INIPath);
return new String(chars, 0, size).Split('\0').ToList();
}

}
}

Loading

0 comments on commit 4136aa8

Please sign in to comment.