Skip to content

Commit ba58d07

Browse files
Library reference and methods
1 parent fa06511 commit ba58d07

File tree

5 files changed

+11
-21
lines changed

5 files changed

+11
-21
lines changed

src/Files.App.CsWin32/NativeMethods.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -268,3 +268,4 @@ WINTRUST_DATA
268268
HCERTSTORE
269269
HCRYPTMSG
270270
CERT_QUERY_ENCODING_TYPE
271+
CertGetNameString

src/Files.App/Helpers/Win32/Win32PInvoke.Methods.cs

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
using System.Runtime.InteropServices;
66
using System.Text;
77
using Windows.Win32.Foundation;
8-
using Windows.Win32.Security.Cryptography;
98
using Windows.Win32.System.Com;
109

1110
namespace Files.App.Helpers
@@ -348,17 +347,6 @@ public static extern int SHGetKnownFolderPath(
348347
out IntPtr pszPath
349348
);
350349

351-
// crypt32.dll
352-
[DllImport("crypt32.dll", SetLastError = true, CharSet = CharSet.Unicode)]
353-
public unsafe static extern uint CertGetNameStringA(
354-
CERT_CONTEXT* pCertContext,
355-
uint dwType,
356-
uint dwFlags,
357-
void* pvTypePara,
358-
PCSTR pszNameString,
359-
uint cchNameString
360-
);
361-
362350
// cryptui.dll
363351
[DllImport("cryptui.dll", SetLastError = true, CharSet = CharSet.Auto)]
364352
public unsafe static extern bool CryptUIDlgViewSignerInfo(CRYPTUI_VIEWSIGNERINFO_STRUCT* pViewInfo);

src/Files.App/Utils/Signatures/DigitalSignaturesUtil.cs

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -681,34 +681,34 @@ ref lengthFound
681681

682682
private unsafe static bool GetStringFromCertContext(CERT_CONTEXT* pCertContext, uint dwType, uint flag, CertNodeInfoItem info)
683683
{
684-
var data = CertGetNameStringA(pCertContext, dwType, flag, null, (PCSTR)null, 0);
684+
var data = PInvoke.CertGetNameString(pCertContext, dwType, flag, null, (PWSTR)null, 0);
685685
if (data == 0)
686686
{
687687
PInvoke.CertFreeCertificateContext(pCertContext);
688688
return false;
689689
}
690690

691-
var pszTempName = (PCSTR)NativeMemory.Alloc(data);
691+
var pszTempName = (PWSTR)NativeMemory.Alloc(data * sizeof(char));
692692
if (pszTempName.Value is null)
693693
{
694694
PInvoke.CertFreeCertificateContext(pCertContext);
695+
NativeMemory.Free(pszTempName);
695696
return false;
696697
}
697698

698-
data = CertGetNameStringA(pCertContext, dwType, flag, null, pszTempName, data);
699+
data = PInvoke.CertGetNameString(pCertContext, dwType, flag, null, pszTempName, data);
699700
if (data == 0)
700701
{
701702
NativeMemory.Free(pszTempName);
702703
return false;
703704
}
704705

705-
var tmpName = new string((sbyte*)(byte*)pszTempName);
706+
var name = pszTempName.AsSpan().ToString();
707+
NativeMemory.Free(pszTempName);
706708
if (flag == 0)
707-
info.IssuedTo = StripString(tmpName);
709+
info.IssuedTo = StripString(name);
708710
else
709-
info.IssuedBy = StripString(tmpName);
710-
711-
NativeMemory.Free(pszTempName);
711+
info.IssuedBy = StripString(name);
712712

713713
return true;
714714
}

src/Files.App/ViewModels/Settings/AboutViewModel.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,7 @@ public AboutViewModel()
7979
new ("https://github.com/microsoft/CsWinRT", "CsWinRT"),
8080
new ("https://github.com/GihanSoft/NaturalStringComparer", "NaturalStringComparer"),
8181
new ("https://github.com/dongle-the-gadget/GuidRVAGen", "Dongle.GuidRVAGen"),
82+
new ("https://github.com/leeqwind/PESignAnalyzer", "PESignAnalyzer"),
8283
];
8384

8485
CopyAppVersionCommand = new RelayCommand(CopyAppVersion);

src/Files.App/Views/Settings/AboutPage.xaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -188,7 +188,7 @@
188188
<ItemsRepeater.Layout>
189189
<UniformGridLayout
190190
ItemsStretch="Fill"
191-
MaximumRowsOrColumns="6"
191+
MaximumRowsOrColumns="4"
192192
MinColumnSpacing="8"
193193
MinItemWidth="200"
194194
MinRowSpacing="8"

0 commit comments

Comments
 (0)