Skip to content

Commit

Permalink
Added ability to view driver signer
Browse files Browse the repository at this point in the history
  • Loading branch information
CodingWonders committed May 3, 2024
1 parent bd8a8a8 commit 294de3d
Show file tree
Hide file tree
Showing 4 changed files with 83 additions and 0 deletions.
1 change: 1 addition & 0 deletions DISMTools.vbproj
Original file line number Diff line number Diff line change
Expand Up @@ -711,6 +711,7 @@
<Compile Include="Panels\Unattend_Files\Management\UnattendMgr.vb">
<SubType>Form</SubType>
</Compile>
<Compile Include="Utilities\DriverSignerViewer.vb" />
<Compile Include="Utilities\DT_Utils.vb" />
<Compile Include="Utilities\ImageWatcher.vb" />
<Compile Include="Utilities\PriReader.vb" />
Expand Down
Binary file modified Installer/Output/dt_setup.exe
Binary file not shown.
25 changes: 25 additions & 0 deletions Panels/Get_Ops/Drivers/GetDriverInfo.vb
Original file line number Diff line number Diff line change
Expand Up @@ -1038,6 +1038,31 @@ Public Class GetDriverInfo
Label42.Text = drv.ClassGuid
Label44.Text = Casters.CastDismSignatureStatus(drv.DriverSignature, True)
Label46.Text = drv.CatalogFile
Dim signer As String = DriverSignerViewer.GetSignerInfo(drv.OriginalFileName)
If Not (signer Is Nothing OrElse signer = "") Then
Debug.WriteLine("Driver file: {0} ; Signer: {1}", Path.GetFileName(drv.OriginalFileName), signer)
Select Case MainForm.Language
Case 0
Select Case My.Computer.Info.InstalledUICulture.ThreeLetterWindowsLanguageName
Case "ENU", "ENG"
Label44.Text &= " by " & signer
Case "ESN"
Label44.Text &= " por " & signer
Case "FRA"
Label44.Text &= " par " & signer
Case "PTB", "PTG"
Label44.Text &= " por " & signer
End Select
Case 1
Label44.Text &= " by " & signer
Case 2
Label44.Text &= " por " & signer
Case 3
Label44.Text &= " par " & signer
Case 4
Label44.Text &= " por " & signer
End Select
End If
Else
Panel4.Visible = False
Panel7.Visible = True
Expand Down
57 changes: 57 additions & 0 deletions Utilities/DriverSignerViewer.vb
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
Imports System.IO
Imports System.Runtime.InteropServices
Imports Microsoft.Win32
Imports FILETIME = System.Runtime.InteropServices.ComTypes.FILETIME

Namespace Utilities

Public Class DriverSignerViewer

Friend NotInheritable Class NativeMethods

Public Sub New()
End Sub

<DllImport("setupapi.dll", CharSet:=CharSet.Unicode, SetLastError:=True)>
Shared Function SetupVerifyInfFile(infName As String, altPlatformInfo As IntPtr, ByRef infSignerInfo As SP_INF_SIGNER_INFO) As Boolean
End Function

End Class

Friend Const MAX_PATH As Integer = 260

<StructLayout(LayoutKind.Sequential, CharSet:=CharSet.Unicode)>
Friend Structure SP_INF_SIGNER_INFO
Public cbSize As Integer
<MarshalAs(UnmanagedType.ByValTStr, SizeConst:=MAX_PATH)>
Public CatalogFile As String
<MarshalAs(UnmanagedType.ByValTStr, SizeConst:=MAX_PATH)>
Public DigitalSigner As String
<MarshalAs(UnmanagedType.ByValTStr, SizeConst:=MAX_PATH)>
Public DigitalSignerVersion As String
Public SignerScore As Integer
End Structure

Public Shared Function GetSignerInfo(drvPath As String) As String
Const ERROR_AUTHENTICODE_TRUSTED_PUBLISHER As Integer = CInt(&HE0000241)
Const ERROR_AUTHENTICODE_TRUST_NOT_ESTABLISHED As Integer = CInt(&HE0000242)

Dim signerInfo As SP_INF_SIGNER_INFO = New SP_INF_SIGNER_INFO With {
.cbSize = Marshal.SizeOf(GetType(SP_INF_SIGNER_INFO))
}

If NativeMethods.SetupVerifyInfFile(drvPath, IntPtr.Zero, signerInfo) OrElse
(Marshal.GetLastWin32Error() = ERROR_AUTHENTICODE_TRUSTED_PUBLISHER OrElse
Marshal.GetLastWin32Error() = ERROR_AUTHENTICODE_TRUST_NOT_ESTABLISHED) AndAlso
Not String.IsNullOrEmpty(signerInfo.DigitalSigner) Then
Return signerInfo.DigitalSigner
Else
Return String.Empty
End If

Return Nothing
End Function

End Class

End Namespace

0 comments on commit 294de3d

Please sign in to comment.