-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
bd8a8a8
commit 294de3d
Showing
4 changed files
with
83 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |