diff --git a/.editorconfig b/.editorconfig new file mode 100644 index 0000000..d8aba40 --- /dev/null +++ b/.editorconfig @@ -0,0 +1,7 @@ +# indicate this is the root of the project +root = true + +[*] +trim_trailing_whitespace = true +insert_final_newline = true +charset = utf-8 diff --git a/.gitattributes b/.gitattributes index 1ff0c42..4160f58 100644 --- a/.gitattributes +++ b/.gitattributes @@ -1,63 +1,2 @@ -############################################################################### -# Set default behavior to automatically normalize line endings. -############################################################################### * text=auto - -############################################################################### -# Set default behavior for command prompt diff. -# -# This is need for earlier builds of msysgit that does not have it on by -# default for csharp files. -# Note: This is only used by command line -############################################################################### -#*.cs diff=csharp - -############################################################################### -# Set the merge driver for project and solution files -# -# Merging from the command prompt will add diff markers to the files if there -# are conflicts (Merging from VS is not affected by the settings below, in VS -# the diff markers are never inserted). Diff markers may cause the following -# file extensions to fail to load in VS. An alternative would be to treat -# these files as binary and thus will always conflict and require user -# intervention with every merge. To do so, just uncomment the entries below -############################################################################### -#*.sln merge=binary -#*.csproj merge=binary -#*.vbproj merge=binary -#*.vcxproj merge=binary -#*.vcproj merge=binary -#*.dbproj merge=binary -#*.fsproj merge=binary -#*.lsproj merge=binary -#*.wixproj merge=binary -#*.modelproj merge=binary -#*.sqlproj merge=binary -#*.wwaproj merge=binary - -############################################################################### -# behavior for image files -# -# image files are treated as binary by default. -############################################################################### -#*.jpg binary -#*.png binary -#*.gif binary - -############################################################################### -# diff behavior for common document formats -# -# Convert binary document formats to text before diffing them. This feature -# is only available from the command line. Turn it on by uncommenting the -# entries below. -############################################################################### -#*.doc diff=astextplain -#*.DOC diff=astextplain -#*.docx diff=astextplain -#*.DOCX diff=astextplain -#*.dot diff=astextplain -#*.DOT diff=astextplain -#*.pdf diff=astextplain -#*.PDF diff=astextplain -#*.rtf diff=astextplain -#*.RTF diff=astextplain +*.ps1 eol=crlf diff --git a/Frida.ps1 b/Frida.ps1 index 9fcdb02..a954872 100644 --- a/Frida.ps1 +++ b/Frida.ps1 @@ -1,4 +1,4 @@ -# +# # Frida - The Full Retail ISO Download Application # Copyright © 2019 Pete Batard # ConvertTo-ImageSource: Copyright © 2016 Chris Carter @@ -17,6 +17,9 @@ # along with this program. If not, see . # +# NB: You need a BOM on your .ps1 if you want Powershell to actually +# realise it should use Unicode for the UI controls and not ISO-8859-1 + # Parameters param( # (Optional) Name of a pipe the download URL should be sent to. @@ -28,9 +31,12 @@ param( # (Optional) Path to the file that should be used for the UI icon. [string]$Icon, # (Optional) The title to display on the application window - [string]$AppTitle = "Frida - Full Retail ISO Downloads" + [string]$AppTitle = "Frida - Full Retail ISO Downloader" + # TODO: Add a -NoHide param ) +Write-Host Please Wait... + # Custom Assembly Types $code = @" [DllImport("kernel32.dll", CharSet = CharSet.Auto, SetLastError = true, BestFitMapping = false, ThrowOnUnmappableChar = true)] @@ -39,6 +45,8 @@ $code = @" internal static extern int LoadString(IntPtr hInstance, uint wID, StringBuilder lpBuffer, int nBufferMax); [DllImport("Shell32.dll", CharSet = CharSet.Auto, SetLastError = true, BestFitMapping = false, ThrowOnUnmappableChar = true)] internal static extern int ExtractIconEx(string sFile, int iIndex, out IntPtr piLargeVersion, out IntPtr piSmallVersion, int amountIcons); +[DllImport("user32.dll")] + public static extern bool ShowWindow(int handle, int state); // Returns a localized MUI string from the specified DLL public static string GetMuiString(string dll, uint index) @@ -70,6 +78,8 @@ $code = @" Add-Type -MemberDefinition $code -Namespace Gui -UsingNamespace "System.IO", "System.Text", "System.Drawing", "System.Globalization" -ReferencedAssemblies System.Drawing -Name Utils -ErrorAction Stop Add-Type -AssemblyName PresentationFramework +# Hide the powershell window: https://stackoverflow.com/a/27992426/1069307 +$null = [Gui.Utils]::ShowWindow(([System.Diagnostics.Process]::GetCurrentProcess() | Get-Process).MainWindowHandle, 0) # Data $WindowsVersions = @( @@ -116,6 +126,32 @@ $WindowsVersions = @( ) ) +# Translated messages. Empty string means same as English +$Translations = @( + @( + "en-US", + "Windows version", + "Release", + "Edition", + "Language" + "Arch" + "Download" + "Confirm" + "Cancel" + ), + @( + "fr-FR", + "Version de Windows" + "", + "Édition", + "Langue de produit" + "Arch" + "Télécharger" + "Confirmer" + "Abandonner" + ) +) + # Functions function Add-Title([string]$Name) { @@ -152,6 +188,7 @@ function Send-Message([string]$PipeName, [string]$Message) [System.Text.Encoding]$Encoding = [System.Text.Encoding]::UTF8 $Pipe = New-Object -TypeName System.IO.Pipes.NamedPipeClientStream -ArgumentList ".", $PipeName, ([System.IO.Pipes.PipeDirection]::Out), ([System.IO.Pipes.PipeOptions]::None), ([System.Security.Principal.TokenImpersonationLevel]::Impersonation) try { + Write-Host Connecting to $PipeName $Pipe.Connect(1000) } catch { Write-Host $_.Exception.Message @@ -184,6 +221,27 @@ function ConvertTo-ImageSource } } +# Translate a message string +function Get-Translation([string]$Text) +{ + if (-not $Translations[0].Contains($Text)) { + Write-Host "Error: '$Text' is not a translatable string" + return "(Untranslated)" + } + foreach($Translation in $Translations) { + if ($Translation[0].StartsWith($ShortLocale)) { + for ($i = 1; $i -lt $Translation.Length; $i++) { + if ($Translations[0][$i] -eq $Text) { + if ($Translation[$i]) { + return $Translation[$i] + } + } + } + } + } + return $Text +} + function Exit-App([int]$ExitCode) { $script:ExitCode = $ExitCode @@ -191,13 +249,12 @@ function Exit-App([int]$ExitCode) } # XAML Form -# TODO: Add FlowDirection = "RightToLeft" to for RTL mode [xml]$Form = @" - + -