Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions FileInspectorX/Win32/EtlNative.cs
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ private struct EVENT_TRACE_LOGFILEW_CALLBACKS
{
// Temporarily disabled: OpenTraceW can AV on some large/corrupted ETL files.
// Returning null avoids native calls while preserving existing caller semantics.
// This method is kept for API compatibility; callers fall back to tracerpt-based validation.
return null;
}
}
7 changes: 6 additions & 1 deletion FileInspectorX/Win32/EtlProbe.cs
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,12 @@ public static class EtlProbe
var waitMs = Math.Max(1000, timeoutMs);
if (!p.WaitForExit(waitMs))
{
try { p.Kill(); } catch { }
try
{
p.Kill();
p.WaitForExit(1000);
}
catch { }
Copy link

Copilot AI Jan 20, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Poor error handling: empty catch block.

Suggested change
catch { }
catch (Exception ex)
{
Debug.WriteLine($"EtlProbe: failed to kill timed-out tracerpt.exe process: {ex}");
}

Copilot uses AI. Check for mistakes.
return null; // timeout
}
// tracerpt returns 0 on success; non-zero on failures to parse the ETL
Expand Down
33 changes: 10 additions & 23 deletions FileInspectorX/Win32/PropertySystemNative.cs
Original file line number Diff line number Diff line change
Expand Up @@ -133,9 +133,9 @@ internal string GetVarTypeString()
switch (baseType)
{
case VarEnum.VT_LPWSTR:
return ReadStringVector(calpwstr, useBstr: false);
return ReadStringVector(calpwstr.cElems, calpwstr.pElems, Marshal.PtrToStringUni);
case VarEnum.VT_BSTR:
return ReadStringVector(cabstr, useBstr: true);
return ReadStringVector(cabstr.cElems, cabstr.pElems, Marshal.PtrToStringBSTR);
default:
return null;
}
Expand Down Expand Up @@ -180,35 +180,22 @@ internal string GetVarTypeString()
}
}

private static string[] ReadStringVector(CALPWSTR ca, bool useBstr)
private static string[] ReadStringVector(uint count, IntPtr elems, Func<IntPtr, string?> converter)
{
if (ca.cElems == 0 || ca.pElems == IntPtr.Zero) return Array.Empty<string>();
if (ca.cElems > MaxVectorElements) return Array.Empty<string>();
var arr = new string[ca.cElems];
for (var i = 0; i < ca.cElems; i++)
if (count == 0 || elems == IntPtr.Zero) return Array.Empty<string>();
if (count > MaxVectorElements) return Array.Empty<string>();
var arr = new string[count];
for (var i = 0; i < count; i++)
{
var ptr = Marshal.ReadIntPtr(ca.pElems, i * IntPtr.Size);
arr[i] = useBstr ? (Marshal.PtrToStringBSTR(ptr) ?? string.Empty) : (Marshal.PtrToStringUni(ptr) ?? string.Empty);
}
return arr;
}

private static string[] ReadStringVector(CABSTR ca, bool useBstr)
{
if (ca.cElems == 0 || ca.pElems == IntPtr.Zero) return Array.Empty<string>();
if (ca.cElems > MaxVectorElements) return Array.Empty<string>();
var arr = new string[ca.cElems];
for (var i = 0; i < ca.cElems; i++)
{
var ptr = Marshal.ReadIntPtr(ca.pElems, i * IntPtr.Size);
arr[i] = useBstr ? (Marshal.PtrToStringBSTR(ptr) ?? string.Empty) : (Marshal.PtrToStringUni(ptr) ?? string.Empty);
var ptr = Marshal.ReadIntPtr(elems, i * IntPtr.Size);
arr[i] = converter(ptr) ?? string.Empty;
}
return arr;
}

private static DateTime? FileTimeToDateTime(ComTypes.FILETIME ft)
{
long ticks = ((long)ft.dwHighDateTime << 32) | (uint)ft.dwLowDateTime;
long ticks = ((long)ft.dwHighDateTime << 32) | ((long)(uint)ft.dwLowDateTime);
if (ticks <= 0) return null;
try
{
Expand Down
Loading