Skip to content

Commit

Permalink
DISMTools 0.5.1 Update 2 (#182)
Browse files Browse the repository at this point in the history
* Update assembly information

* [PE Helper] Improvements for 0.6 Preview 4 (#173)

Backported from 0.6 Preview 4

* [Requirement] Require .NET 4.8

* [AppEvent] Stop detector temporarily

* [Mounted image detector] Fixed exception

* [AppEvent] Restart detector a second time

* [AppEvent] Delay image detector restart

* [ISO Creator] Improve reliability of API

* [AppEvent] Improve reporting

* [PE Helper] Add custom restart countdown dialog

Source code for dialog will be available in a separate repo

* [PE Helper] Add README to ISOs

* Use correct version info

* [Library] Update Scintilla.NET to 5.6.2

* [REL] Update What's New section and new Update Info files
  • Loading branch information
CodingWonders authored Oct 26, 2024
1 parent 8f2a1f4 commit b26a55b
Show file tree
Hide file tree
Showing 38 changed files with 1,170 additions and 612 deletions.
39 changes: 39 additions & 0 deletions ApplicationEvents.vb
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,18 @@ Namespace My
" - Preview release? " & If(DISMTools.MainForm.dtBranch.Contains("preview"), "Yes", "No") & CrLf &
" - Branch: " & DISMTools.MainForm.dtBranch & CrLf &
" - Build time: " & DISMTools.PrgAbout.RetrieveLinkerTimestamp(My.Application.Info.DirectoryPath & "\" & My.Application.Info.AssemblyName & ".exe").ToString("yyMMdd-HHmm"))
' Get image information if a project has been loaded
If DISMTools.MainForm.isProjectLoaded And Not DISMTools.MainForm.OnlineManagement Then
Try
ExceptionForm.ErrorText.AppendText(CrLf &
"Information about the image loaded in this project:" & CrLf &
" - Image name: " & DISMTools.MainForm.Label46.Text & CrLf &
" - Image description: " & DISMTools.MainForm.Label47.Text & CrLf &
" - Image version: " & DISMTools.MainForm.Label48.Text)
Catch ex As Exception
' Don't get this info
End Try
End If
' Get basic information about the system. This does not include any personally identifiable information (PII) or
' serial numbers that can identify the computer this program is run on
Dim CS_Searcher As ManagementObjectSearcher = New ManagementObjectSearcher("SELECT Manufacturer, Model FROM Win32_ComputerSystem")
Expand Down Expand Up @@ -90,6 +102,33 @@ Namespace My

Private Sub SysEvts_UserPreferenceChanged(sender As Object, e As Microsoft.Win32.UserPreferenceChangedEventArgs)
Debug.WriteLine(Date.UtcNow & " UTC - User Preference Category: " & e.Category.ToString())

' Prevent the program from freezing. This is a fix for a very long-standing bug that was introduced with the mounted image detector,
' where the program would randomly freeze and never come back. And, even while the program itself was still responding, its UI thread
' wasn't.
'
' This is a problem with Windows Forms that has been present since .NET Framework 2.0. More on that here:
' https://www.ikriv.com/dev/dotnet/MysteriousHang
'
' Even though this bug took a year and a half to fix, a lot was gathered from previous attempts at fixing this problem:
' 1. It's random
' 2. It affects all versions of Windows supported by this program (Win8.1-Win11, incl. servers)
' 3. It happens when the following conditions occur:
' - The mounted image detector is running
' - This event is triggered
'
' This fixes the problem by temporarily stopping the mounted image detector, doing the event code, and restarting it afterward.
' It hasn't caused any freezes for me yet, but I may be proven wrong.
If DISMTools.MainForm.MountedImageDetectorBW.IsBusy Then
DISMTools.MainForm.MountedImageDetectorBW.CancelAsync()
End If
Try
Threading.Thread.Sleep(1000)
Call DISMTools.MainForm.MountedImageDetectorBW.RunWorkerAsync()
Threading.Thread.Sleep(250)
Catch ex As Exception
DISMTools.MainForm.MountedImageDetectorBWRestarterTimer.Enabled = True
End Try
End Sub

Private Sub SysEvts_DisplaySettingsChanged(sender As Object, e As EventArgs)
Expand Down
29 changes: 25 additions & 4 deletions DISMTools.vbproj
Original file line number Diff line number Diff line change
Expand Up @@ -80,8 +80,8 @@
<Reference Include="Microsoft.Dism, Version=1.0.0.0, Culture=neutral, PublicKeyToken=5bba90053b345501, processorArchitecture=MSIL">
<HintPath>packages\Microsoft.Dism.3.1.0\lib\net40\Microsoft.Dism.dll</HintPath>
</Reference>
<Reference Include="Scintilla.NET, Version=5.6.1.0, Culture=neutral, processorArchitecture=MSIL">
<HintPath>packages\Scintilla5.NET.5.6.1\lib\net462\Scintilla.NET.dll</HintPath>
<Reference Include="Scintilla.NET, Version=5.6.2.0, Culture=neutral, PublicKeyToken=0221e70ba618311e, processorArchitecture=MSIL">
<HintPath>packages\Scintilla5.NET.5.6.2\lib\net462\Scintilla.NET.dll</HintPath>
</Reference>
<Reference Include="System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089, processorArchitecture=MSIL">
<Private>True</Private>
Expand Down Expand Up @@ -1322,12 +1322,21 @@
<Content Include="Helpers\extps1\PE_Helper\backgrounds\winpe_x86.jpg">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</Content>
<Content Include="Helpers\extps1\PE_Helper\files\README1ST.TXT">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</Content>
<Content Include="Helpers\extps1\PE_Helper\tools\DIM\amd64\DT-DIM.exe">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</Content>
<Content Include="Helpers\extps1\PE_Helper\tools\DIM\i386\DT-DIM.exe">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</Content>
<Content Include="Helpers\extps1\PE_Helper\tools\RestartDialog\amd64\DTPE-RestartDialog.exe">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</Content>
<Content Include="Helpers\extps1\PE_Helper\tools\RestartDialog\i386\DTPE-RestartDialog.exe">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</Content>
<Content Include="Installer\dt.iss" />
<Content Include="Installer\ISCC.exe" />
<Content Include="Installer\ISCmplr.dll" />
Expand Down Expand Up @@ -1742,6 +1751,9 @@ ECHO Generating program structure...
IF EXIST "$(SolutionDir)portable" (
COPY "$(SolutionDir)portable" . /Y
)
IF EXIST "$(SolutionDir)Helpers\extps1\PE_Helper\Compile.ps1" (
"\Windows\system32\WindowsPowerShell\v1.0\powershell.exe" -executionpolicy bypass -noprofile -nologo -file "$(SolutionDir)Helpers\extps1\PE_Helper\Compile.ps1"
)
IF NOT EXIST bin (
md "bin"
md "bin\exthelpers"
Expand All @@ -1753,6 +1765,15 @@ IF NOT EXIST bin (
move "helpers\extps1\*.*" "bin\extps1"
md "bin\extps1\PE_Helper"
xcopy "helpers\extps1\PE_Helper\*.*" "bin\extps1\PE_Helper" /cehyi
IF EXIST "$(SolutionDir)helpers\extps1\PE_Helper\Compile.ps1" (
:: Compile the script with CTT's compilation script (license in source code and About section)
ECHO Invoking pre-processing...
COPY "$(SolutionDir)helpers\extps1\PE_Helper\Compile.ps1" "$(TargetDir)bin\extps1\PE_Helper\Compile.ps1"
COPY "$(SolutionDir)helpers\extps1\PE_Helper\tools\Invoke-Preprocessing.ps1" "$(TargetDir)bin\extps1\PE_Helper\tools\Invoke-Preprocessing.ps1"
"\Windows\system32\WindowsPowerShell\v1.0\powershell.exe" -executionpolicy bypass -noprofile -nologo -file "$(TargetDir)bin\extps1\PE_Helper\Compile.ps1"
DEL "$(TargetDir)bin\extps1\PE_Helper\Compile.ps1" /F /Q
DEL "$(TargetDir)bin\extps1\PE_Helper\tools\Invoke-Preprocessing.ps1" /F /Q
)
IF EXIST HELPERS (
rd HELPERS /s /q
)
Expand Down Expand Up @@ -1860,12 +1881,12 @@ IF EXIST tools (
rd tools /s /q
)</PreBuildEvent>
</PropertyGroup>
<Import Project="packages\Scintilla5.NET.5.6.1\build\scintilla5.net.targets" Condition="Exists('packages\Scintilla5.NET.5.6.1\build\scintilla5.net.targets')" />
<Import Project="packages\Scintilla5.NET.5.6.2\build\scintilla5.net.targets" Condition="Exists('packages\Scintilla5.NET.5.6.2\build\scintilla5.net.targets')" />
<Target Name="EnsureNuGetPackageBuildImports" BeforeTargets="PrepareForBuild">
<PropertyGroup>
<ErrorText>Este proyecto hace referencia a los paquetes NuGet que faltan en este equipo. Use la restauración de paquetes NuGet para descargarlos. Para obtener más información, consulte http://go.microsoft.com/fwlink/?LinkID=322105. El archivo que falta es {0}.</ErrorText>
</PropertyGroup>
<Error Condition="!Exists('packages\Scintilla5.NET.5.6.1\build\scintilla5.net.targets')" Text="$([System.String]::Format('$(ErrorText)', 'packages\Scintilla5.NET.5.6.1\build\scintilla5.net.targets'))" />
<Error Condition="!Exists('packages\Scintilla5.NET.5.6.2\build\scintilla5.net.targets')" Text="$([System.String]::Format('$(ErrorText)', 'packages\Scintilla5.NET.5.6.2\build\scintilla5.net.targets'))" />
</Target>
<!-- 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.
Expand Down
61 changes: 61 additions & 0 deletions Helpers/extps1/PE_Helper/Compile.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
# This is a heavily modified compilation script for the Preinstallation Environment Helper, originally from the Windows Utility (WinUtil)
#
# Original license (affects both this script and the pre-processor):
#
# MIT License
#
# Copyright (c) 2022 CT Tech Group LLC
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:
#
# The above copyright notice and this permission notice shall be included in all
# copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
# SOFTWARE.

$workingdir = $PSScriptRoot

Push-Location
Set-Location $workingdir

# Variable to sync between runspaces
$sync = [Hashtable]::Synchronized(@{})
$sync.PSScriptRoot = $workingdir
$sync.configs = @{}

function Update-Progress {
param (
[Parameter(Mandatory, position=0)]
[string]$StatusMessage,

[Parameter(Mandatory, position=1)]
[ValidateRange(0,100)]
[int]$Percent,

[Parameter(position=2)]
[string]$Activity = "Compiling"
)

Write-Progress -Activity $Activity -Status $StatusMessage -PercentComplete $Percent
}

Update-Progress "Pre-req: Running Preprocessor..." 0

# Dot source the 'Invoke-Preprocessing' Function from 'tools/Invoke-Preprocessing.ps1' Script
$preprocessingFilePath = ".\tools\Invoke-Preprocessing.ps1"
. $preprocessingFilePath

$excludedFiles = @('.\tools\DIM\', "$preprocessingFilePath", '*.png', '*.exe')
$msg = "Pre-req: Code Formatting"
Invoke-Preprocessing -WorkingDir "$workingdir" -ExcludedFiles $excludedFiles -ProgressStatusMessage $msg -ThrowExceptionOnEmptyFilesList
Loading

0 comments on commit b26a55b

Please sign in to comment.