שיתוף | קוד #C לזיהוי גרסת Videoff המותקנת במחשב
-
הקוד הבא מחזיר את גרסת הדרייבר של videoff המותקנת במחשב.
public static class VideoffDetector { private const string VideoffPortName = "\\msdtghPort"; public static bool TryGetVersion(out int? version) { return TryGetVersionByCommunicationPort(out version); } private static bool TryGetVersionByCommunicationPort(out int? version) { version = null; var hResult = FltLib.FilterConnectCommunicationPort(VideoffPortName, 0, 0, 0, 0, out var hPort); if (hResult != 0) { return false; } try { var input = BitConverter.GetBytes(1); var output = new byte[4]; hResult = FltLib.FilterSendMessage(hPort, input, output); if (hResult != 0) { return false; } version = BitConverter.ToInt32(output); return true; } finally { Kernel32.CloseHandle(hPort); } } } internal static partial class FltLib { private const string LibraryName = "FltLib"; [LibraryImport(LibraryName, StringMarshalling = StringMarshalling.Utf16)] public static partial int FilterConnectCommunicationPort(string lpPortName, int dwOptions, nint lpContext, short wSizeOfContext, nint lpSecurityAttributes, out nint hPort); [LibraryImport(LibraryName, EntryPoint = "FilterSendMessage")] public static partial int FilterSendMessage(nint hPort, ReadOnlySpan<byte> lpInBuffer, int dwInBufferSize, ReadOnlySpan<byte> lpOutBuffer, int dwOutBufferSize, out uint lpBytesReturned); public static int FilterSendMessage(nint hPort, ReadOnlySpan<byte> lpInBuffer, ReadOnlySpan<byte> lpOutBuffer) { return FilterSendMessage(hPort, lpInBuffer, lpInBuffer.Length, lpOutBuffer, lpOutBuffer.Length, out _); } } internal static partial class Kernel32 { private const string LibraryName = "Kernel32"; [LibraryImport(LibraryName)] [return: MarshalAs(UnmanagedType.Bool)] public static partial bool CloseHandle(nint hObject); }
שלום! נראה שהשיחה הזו מעניינת אותך, אבל עדיין אין לך חשבון.
נמאס לכם לגלול בין אותם הפוסטים בכל ביקור? כשנרשמים לחשבון, תמיד תחזרו בדיוק למקום שבו הייתם קודם, ותוכלו לבחור לקבל התראות על תגובות חדשות (בין אם במייל, ובין אם בהתראת פוש). תוכלו גם לשמור סימניות ולפרגן ב-upvote לפוסטים כדי להביע הערכה לחברי קהילה אחרים.
בעזרת התרומה שלך, הפוסט הזה יכול להיות אפילו טוב יותר 💗
הרשמה התחברות