[Core] netstandard support, drop PInvokeDelegateFactory and replace with direct dll calls in ADL.cs, NVAPI.cs, FTD2XX.cs, create project and solution file for netstandard, add compiler option in KernelDriver.cs and Ring0.cs - These options are not required for library mode. netstandard is not default for library - If compiled as usual anything works as in previous versions
This commit is contained in:
+36
-135
@@ -100,125 +100,40 @@ namespace OpenHardwareMonitor.Hardware.ATI {
|
||||
|
||||
public const int ATI_VENDOR_ID = 0x1002;
|
||||
|
||||
private delegate int ADL_Main_Control_CreateDelegate(
|
||||
ADL_Main_Memory_AllocDelegate callback, int enumConnectedAdapters);
|
||||
private delegate int ADL_Adapter_AdapterInfo_GetDelegate(IntPtr info,
|
||||
int size);
|
||||
|
||||
public delegate int ADL_Main_Control_DestroyDelegate();
|
||||
public delegate int ADL_Adapter_NumberOfAdapters_GetDelegate(
|
||||
ref int numAdapters);
|
||||
public delegate int ADL_Adapter_ID_GetDelegate(int adapterIndex,
|
||||
out int adapterID);
|
||||
public delegate int ADL_Display_AdapterID_GetDelegate(int adapterIndex,
|
||||
out int adapterID);
|
||||
public delegate int ADL_Adapter_Active_GetDelegate(int adapterIndex,
|
||||
out int status);
|
||||
public delegate int ADL_Overdrive5_CurrentActivity_GetDelegate(
|
||||
int iAdapterIndex, ref ADLPMActivity activity);
|
||||
public delegate int ADL_Overdrive5_Temperature_GetDelegate(int adapterIndex,
|
||||
int thermalControllerIndex, ref ADLTemperature temperature);
|
||||
public delegate int ADL_Overdrive5_FanSpeed_GetDelegate(int adapterIndex,
|
||||
int thermalControllerIndex, ref ADLFanSpeedValue fanSpeedValue);
|
||||
public delegate int ADL_Overdrive5_FanSpeedInfo_GetDelegate(
|
||||
int adapterIndex, int thermalControllerIndex,
|
||||
ref ADLFanSpeedInfo fanSpeedInfo);
|
||||
public delegate int ADL_Overdrive5_FanSpeedToDefault_SetDelegate(
|
||||
int adapterIndex, int thermalControllerIndex);
|
||||
public delegate int ADL_Overdrive5_FanSpeed_SetDelegate(int adapterIndex,
|
||||
int thermalControllerIndex, ref ADLFanSpeedValue fanSpeedValue);
|
||||
|
||||
private static ADL_Main_Control_CreateDelegate
|
||||
_ADL_Main_Control_Create;
|
||||
private static ADL_Adapter_AdapterInfo_GetDelegate
|
||||
_ADL_Adapter_AdapterInfo_Get;
|
||||
|
||||
public static ADL_Main_Control_DestroyDelegate
|
||||
ADL_Main_Control_Destroy;
|
||||
public static ADL_Adapter_NumberOfAdapters_GetDelegate
|
||||
ADL_Adapter_NumberOfAdapters_Get;
|
||||
public static ADL_Adapter_ID_GetDelegate
|
||||
_ADL_Adapter_ID_Get;
|
||||
public static ADL_Display_AdapterID_GetDelegate
|
||||
_ADL_Display_AdapterID_Get;
|
||||
public static ADL_Adapter_Active_GetDelegate
|
||||
ADL_Adapter_Active_Get;
|
||||
public static ADL_Overdrive5_CurrentActivity_GetDelegate
|
||||
ADL_Overdrive5_CurrentActivity_Get;
|
||||
public static ADL_Overdrive5_Temperature_GetDelegate
|
||||
ADL_Overdrive5_Temperature_Get;
|
||||
public static ADL_Overdrive5_FanSpeed_GetDelegate
|
||||
ADL_Overdrive5_FanSpeed_Get;
|
||||
public static ADL_Overdrive5_FanSpeedInfo_GetDelegate
|
||||
ADL_Overdrive5_FanSpeedInfo_Get;
|
||||
public static ADL_Overdrive5_FanSpeedToDefault_SetDelegate
|
||||
ADL_Overdrive5_FanSpeedToDefault_Set;
|
||||
public static ADL_Overdrive5_FanSpeed_SetDelegate
|
||||
ADL_Overdrive5_FanSpeed_Set;
|
||||
|
||||
private static string dllName;
|
||||
|
||||
private static void GetDelegate<T>(string entryPoint, out T newDelegate)
|
||||
where T : class
|
||||
{
|
||||
DllImportAttribute attribute = new DllImportAttribute(dllName);
|
||||
attribute.CallingConvention = CallingConvention.Cdecl;
|
||||
attribute.PreserveSig = true;
|
||||
attribute.EntryPoint = entryPoint;
|
||||
PInvokeDelegateFactory.CreateDelegate(attribute, out newDelegate);
|
||||
}
|
||||
|
||||
private static void CreateDelegates(string name) {
|
||||
int p = (int)Environment.OSVersion.Platform;
|
||||
if ((p == 4) || (p == 128))
|
||||
dllName = name + ".so";
|
||||
else
|
||||
dllName = name + ".dll";
|
||||
|
||||
GetDelegate("ADL_Main_Control_Create",
|
||||
out _ADL_Main_Control_Create);
|
||||
GetDelegate("ADL_Adapter_AdapterInfo_Get",
|
||||
out _ADL_Adapter_AdapterInfo_Get);
|
||||
GetDelegate("ADL_Main_Control_Destroy",
|
||||
out ADL_Main_Control_Destroy);
|
||||
GetDelegate("ADL_Adapter_NumberOfAdapters_Get",
|
||||
out ADL_Adapter_NumberOfAdapters_Get);
|
||||
GetDelegate("ADL_Adapter_ID_Get",
|
||||
out _ADL_Adapter_ID_Get);
|
||||
GetDelegate("ADL_Display_AdapterID_Get",
|
||||
out _ADL_Display_AdapterID_Get);
|
||||
GetDelegate("ADL_Adapter_Active_Get",
|
||||
out ADL_Adapter_Active_Get);
|
||||
GetDelegate("ADL_Overdrive5_CurrentActivity_Get",
|
||||
out ADL_Overdrive5_CurrentActivity_Get);
|
||||
GetDelegate("ADL_Overdrive5_Temperature_Get",
|
||||
out ADL_Overdrive5_Temperature_Get);
|
||||
GetDelegate("ADL_Overdrive5_FanSpeed_Get",
|
||||
out ADL_Overdrive5_FanSpeed_Get);
|
||||
GetDelegate("ADL_Overdrive5_FanSpeedInfo_Get",
|
||||
out ADL_Overdrive5_FanSpeedInfo_Get);
|
||||
GetDelegate("ADL_Overdrive5_FanSpeedToDefault_Set",
|
||||
out ADL_Overdrive5_FanSpeedToDefault_Set);
|
||||
GetDelegate("ADL_Overdrive5_FanSpeed_Set",
|
||||
out ADL_Overdrive5_FanSpeed_Set);
|
||||
}
|
||||
|
||||
static ADL() {
|
||||
CreateDelegates("atiadlxx");
|
||||
}
|
||||
|
||||
private ADL() { }
|
||||
internal const string Atiadlxx_FileName = "atiadlxx.dll";
|
||||
[DllImport(Atiadlxx_FileName, CallingConvention = CallingConvention.Cdecl)]
|
||||
public static extern int ADL_Main_Control_Create(ADL_Main_Memory_AllocDelegate callback, int enumConnectedAdapters);
|
||||
[DllImport(Atiadlxx_FileName, CallingConvention = CallingConvention.Cdecl)]
|
||||
public static extern int ADL_Main_Control_Destroy();
|
||||
[DllImport(Atiadlxx_FileName, CallingConvention = CallingConvention.Cdecl)]
|
||||
public static extern int ADL_Adapter_AdapterInfo_Get(IntPtr info, int size);
|
||||
[DllImport(Atiadlxx_FileName, CallingConvention = CallingConvention.Cdecl)]
|
||||
public static extern int ADL_Adapter_NumberOfAdapters_Get();
|
||||
[DllImport(Atiadlxx_FileName, CallingConvention = CallingConvention.Cdecl)]
|
||||
public static extern int ADL_Adapter_NumberOfAdapters_Get(ref int numAdapters);
|
||||
[DllImport(Atiadlxx_FileName, CallingConvention = CallingConvention.Cdecl)]
|
||||
public static extern int ADL_Adapter_ID_Get(int adapterIndex, out int adapterID);
|
||||
[DllImport(Atiadlxx_FileName, CallingConvention = CallingConvention.Cdecl)]
|
||||
public static extern int ADL_Display_AdapterID_Get(int adapterIndex, out int adapterID);
|
||||
[DllImport(Atiadlxx_FileName, CallingConvention = CallingConvention.Cdecl)]
|
||||
public static extern int ADL_Adapter_Active_Get(int adapterIndex, out int status);
|
||||
[DllImport(Atiadlxx_FileName, CallingConvention = CallingConvention.Cdecl)]
|
||||
public static extern int ADL_Overdrive5_CurrentActivity_Get(int iAdapterIndex, ref ADLPMActivity activity);
|
||||
[DllImport(Atiadlxx_FileName, CallingConvention = CallingConvention.Cdecl)]
|
||||
public static extern int ADL_Overdrive5_Temperature_Get(int adapterIndex, int thermalControllerIndex, ref ADLTemperature temperature);
|
||||
[DllImport(Atiadlxx_FileName, CallingConvention = CallingConvention.Cdecl)]
|
||||
public static extern int ADL_Overdrive5_FanSpeed_Get(int adapterIndex, int thermalControllerIndex, ref ADLFanSpeedValue fanSpeedValue);
|
||||
[DllImport(Atiadlxx_FileName, CallingConvention = CallingConvention.Cdecl)]
|
||||
public static extern int ADL_Overdrive5_FanSpeedInfo_Get(int adapterIndex, int thermalControllerIndex, ref ADLFanSpeedInfo fanSpeedInfo);
|
||||
[DllImport(Atiadlxx_FileName, CallingConvention = CallingConvention.Cdecl)]
|
||||
public static extern int ADL_Overdrive5_FanSpeedToDefault_Set(int adapterIndex, int thermalControllerIndex);
|
||||
[DllImport(Atiadlxx_FileName, CallingConvention = CallingConvention.Cdecl)]
|
||||
public static extern int ADL_Overdrive5_FanSpeed_Set(int adapterIndex, int thermalControllerIndex, ref ADLFanSpeedValue fanSpeedValue);
|
||||
|
||||
public static int ADL_Main_Control_Create(int enumConnectedAdapters) {
|
||||
try {
|
||||
try {
|
||||
return _ADL_Main_Control_Create(Main_Memory_Alloc,
|
||||
enumConnectedAdapters);
|
||||
} catch {
|
||||
CreateDelegates("atiadlxy");
|
||||
return _ADL_Main_Control_Create(Main_Memory_Alloc,
|
||||
enumConnectedAdapters);
|
||||
}
|
||||
return ADL_Main_Control_Create(Main_Memory_Alloc,
|
||||
enumConnectedAdapters);
|
||||
} catch {
|
||||
return ADL_ERR;
|
||||
}
|
||||
@@ -228,7 +143,7 @@ namespace OpenHardwareMonitor.Hardware.ATI {
|
||||
int elementSize = Marshal.SizeOf(typeof(ADLAdapterInfo));
|
||||
int size = info.Length * elementSize;
|
||||
IntPtr ptr = Marshal.AllocHGlobal(size);
|
||||
int result = _ADL_Adapter_AdapterInfo_Get(ptr, size);
|
||||
int result = ADL_Adapter_AdapterInfo_Get(ptr, size);
|
||||
for (int i = 0; i < info.Length; i++)
|
||||
info[i] = (ADLAdapterInfo)
|
||||
Marshal.PtrToStructure((IntPtr)((long)ptr + i * elementSize),
|
||||
@@ -254,29 +169,15 @@ namespace OpenHardwareMonitor.Hardware.ATI {
|
||||
return result;
|
||||
}
|
||||
|
||||
public static int ADL_Adapter_ID_Get(int adapterIndex,
|
||||
out int adapterID) {
|
||||
try {
|
||||
return _ADL_Adapter_ID_Get(adapterIndex, out adapterID);
|
||||
} catch (EntryPointNotFoundException) {
|
||||
try {
|
||||
return _ADL_Display_AdapterID_Get(adapterIndex, out adapterID);
|
||||
} catch (EntryPointNotFoundException) {
|
||||
adapterID = 1;
|
||||
return ADL_OK;
|
||||
}
|
||||
}
|
||||
}
|
||||
public delegate IntPtr ADL_Main_Memory_AllocDelegate(int size);
|
||||
|
||||
private delegate IntPtr ADL_Main_Memory_AllocDelegate(int size);
|
||||
|
||||
// create a Main_Memory_Alloc delegate and keep it alive
|
||||
private static ADL_Main_Memory_AllocDelegate Main_Memory_Alloc =
|
||||
// create a Main_Memory_Alloc delegate and keep it alive
|
||||
public static ADL_Main_Memory_AllocDelegate Main_Memory_Alloc =
|
||||
delegate(int size) {
|
||||
return Marshal.AllocHGlobal(size);
|
||||
};
|
||||
|
||||
private static void Main_Memory_Free(IntPtr buffer) {
|
||||
public static void Main_Memory_Free(IntPtr buffer) {
|
||||
if (IntPtr.Zero != buffer)
|
||||
Marshal.FreeHGlobal(buffer);
|
||||
}
|
||||
|
||||
@@ -64,7 +64,8 @@ namespace OpenHardwareMonitor.Hardware {
|
||||
|
||||
NativeMethods.CloseServiceHandle(service);
|
||||
NativeMethods.CloseServiceHandle(manager);
|
||||
|
||||
|
||||
#if !NETSTANDARD2_0
|
||||
try {
|
||||
// restrict the driver access to system (SY) and builtin admins (BA)
|
||||
// TODO: replace with a call to IoCreateDeviceSecure in the driver
|
||||
@@ -77,6 +78,7 @@ namespace OpenHardwareMonitor.Hardware {
|
||||
errorMessage = null;
|
||||
return true;
|
||||
}
|
||||
#endif
|
||||
|
||||
public bool Open() {
|
||||
device = new SafeFileHandle(NativeMethods.CreateFile(@"\\.\" + id,
|
||||
|
||||
@@ -277,7 +277,7 @@ namespace OpenHardwareMonitor.Hardware.Nvidia {
|
||||
out uint revisionId, out uint extDeviceId);
|
||||
|
||||
private static readonly bool available;
|
||||
private static readonly nvapi_QueryInterfaceDelegate nvapi_QueryInterface;
|
||||
[DllImport(@"nvapi.dll", EntryPoint = @"nvapi_QueryInterface", CallingConvention = CallingConvention.Cdecl, PreserveSig = true)]
private static extern IntPtr NvAPI32_QueryInterface(uint interfaceId);
[DllImport(@"nvapi64.dll", EntryPoint = @"nvapi_QueryInterface", CallingConvention = CallingConvention.Cdecl, PreserveSig = true)]
private static extern IntPtr NvAPI64_QueryInterface(uint interfaceId);
|
||||
private static readonly NvAPI_InitializeDelegate NvAPI_Initialize;
|
||||
private static readonly NvAPI_GPU_GetFullNameDelegate
|
||||
_NvAPI_GPU_GetFullName;
|
||||
@@ -346,7 +346,15 @@ namespace OpenHardwareMonitor.Hardware.Nvidia {
|
||||
|
||||
private static void GetDelegate<T>(uint id, out T newDelegate)
|
||||
where T : class {
|
||||
IntPtr ptr = nvapi_QueryInterface(id);
|
||||
IntPtr ptr;
|
||||
if (IntPtr.Size == 4)
|
||||
{
|
||||
ptr = NvAPI32_QueryInterface(id);
|
||||
}
|
||||
else
|
||||
{
|
||||
ptr = NvAPI64_QueryInterface(id);
|
||||
}
|
||||
if (ptr != IntPtr.Zero) {
|
||||
newDelegate =
|
||||
Marshal.GetDelegateForFunctionPointer(ptr, typeof(T)) as T;
|
||||
@@ -356,13 +364,6 @@ namespace OpenHardwareMonitor.Hardware.Nvidia {
|
||||
}
|
||||
|
||||
static NVAPI() {
|
||||
DllImportAttribute attribute = new DllImportAttribute(GetDllName());
|
||||
attribute.CallingConvention = CallingConvention.Cdecl;
|
||||
attribute.PreserveSig = true;
|
||||
attribute.EntryPoint = "nvapi_QueryInterface";
|
||||
PInvokeDelegateFactory.CreateDelegate(attribute,
|
||||
out nvapi_QueryInterface);
|
||||
|
||||
try {
|
||||
GetDelegate(0x0150E828, out NvAPI_Initialize);
|
||||
} catch (DllNotFoundException) { return; }
|
||||
|
||||
@@ -1,82 +0,0 @@
|
||||
/*
|
||||
|
||||
This Source Code Form is subject to the terms of the Mozilla Public
|
||||
License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||
|
||||
Copyright (C) 2009-2012 Michael Möller <mmoeller@openhardwaremonitor.org>
|
||||
|
||||
*/
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Reflection;
|
||||
using System.Reflection.Emit;
|
||||
using System.Runtime.InteropServices;
|
||||
using OpenHardwareMonitor.Collections;
|
||||
|
||||
namespace OpenHardwareMonitor.Hardware {
|
||||
|
||||
internal static class PInvokeDelegateFactory {
|
||||
|
||||
private static readonly ModuleBuilder moduleBuilder =
|
||||
AppDomain.CurrentDomain.DefineDynamicAssembly(
|
||||
new AssemblyName("PInvokeDelegateFactoryInternalAssembly"),
|
||||
AssemblyBuilderAccess.Run).DefineDynamicModule(
|
||||
"PInvokeDelegateFactoryInternalModule");
|
||||
|
||||
private static readonly IDictionary<Pair<DllImportAttribute, Type>, Type> wrapperTypes =
|
||||
new Dictionary<Pair<DllImportAttribute, Type>, Type>();
|
||||
|
||||
public static void CreateDelegate<T>(DllImportAttribute dllImportAttribute,
|
||||
out T newDelegate) where T : class
|
||||
{
|
||||
Type wrapperType;
|
||||
Pair<DllImportAttribute, Type> key =
|
||||
new Pair<DllImportAttribute, Type>(dllImportAttribute, typeof(T));
|
||||
wrapperTypes.TryGetValue(key, out wrapperType);
|
||||
|
||||
if (wrapperType == null) {
|
||||
wrapperType = CreateWrapperType(typeof(T), dllImportAttribute);
|
||||
wrapperTypes.Add(key, wrapperType);
|
||||
}
|
||||
|
||||
newDelegate = Delegate.CreateDelegate(typeof(T), wrapperType,
|
||||
dllImportAttribute.EntryPoint) as T;
|
||||
}
|
||||
|
||||
|
||||
private static Type CreateWrapperType(Type delegateType,
|
||||
DllImportAttribute dllImportAttribute) {
|
||||
|
||||
TypeBuilder typeBuilder = moduleBuilder.DefineType(
|
||||
"PInvokeDelegateFactoryInternalWrapperType" + wrapperTypes.Count);
|
||||
|
||||
MethodInfo methodInfo = delegateType.GetMethod("Invoke");
|
||||
|
||||
ParameterInfo[] parameterInfos = methodInfo.GetParameters();
|
||||
int parameterCount = parameterInfos.GetLength(0);
|
||||
|
||||
Type[] parameterTypes = new Type[parameterCount];
|
||||
for (int i = 0; i < parameterCount; i++)
|
||||
parameterTypes[i] = parameterInfos[i].ParameterType;
|
||||
|
||||
MethodBuilder methodBuilder = typeBuilder.DefinePInvokeMethod(
|
||||
dllImportAttribute.EntryPoint, dllImportAttribute.Value,
|
||||
MethodAttributes.Public | MethodAttributes.Static |
|
||||
MethodAttributes.PinvokeImpl, CallingConventions.Standard,
|
||||
methodInfo.ReturnType, parameterTypes,
|
||||
dllImportAttribute.CallingConvention,
|
||||
dllImportAttribute.CharSet);
|
||||
|
||||
foreach (ParameterInfo parameterInfo in parameterInfos)
|
||||
methodBuilder.DefineParameter(parameterInfo.Position + 1,
|
||||
parameterInfo.Attributes, parameterInfo.Name);
|
||||
|
||||
if (dllImportAttribute.PreserveSig)
|
||||
methodBuilder.SetImplementationFlags(MethodImplAttributes.PreserveSig);
|
||||
|
||||
return typeBuilder.CreateType();
|
||||
}
|
||||
}
|
||||
}
|
||||
+5
-1
@@ -202,8 +202,12 @@ namespace OpenHardwareMonitor.Hardware {
|
||||
isaBusMutex = new Mutex(false, mutexName);
|
||||
} catch (UnauthorizedAccessException) {
|
||||
try {
|
||||
#if NETSTANDARD2_0
|
||||
isaBusMutex = Mutex.OpenExisting(mutexName);
|
||||
#else
|
||||
isaBusMutex = Mutex.OpenExisting(mutexName, MutexRights.Synchronize);
|
||||
} catch { }
|
||||
#endif
|
||||
} catch { }
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -78,69 +78,33 @@ namespace OpenHardwareMonitor.Hardware.TBalancer {
|
||||
|
||||
internal class FTD2XX {
|
||||
|
||||
public delegate FT_STATUS FT_CreateDeviceInfoListDelegate(
|
||||
out uint numDevices);
|
||||
public delegate FT_STATUS FT_GetDeviceInfoListDelegate(
|
||||
[Out] FT_DEVICE_INFO_NODE[] deviceInfoNodes, ref uint length);
|
||||
public delegate FT_STATUS FT_OpenDelegate(int device, out FT_HANDLE handle);
|
||||
public delegate FT_STATUS FT_CloseDelegate(FT_HANDLE handle);
|
||||
public delegate FT_STATUS FT_SetBaudRateDelegate(FT_HANDLE handle,
|
||||
uint baudRate);
|
||||
public delegate FT_STATUS FT_SetDataCharacteristicsDelegate(
|
||||
FT_HANDLE handle, byte wordLength, byte stopBits, byte parity);
|
||||
public delegate FT_STATUS FT_SetFlowControlDelegate(FT_HANDLE handle,
|
||||
FT_FLOW_CONTROL flowControl, byte xon, byte xoff);
|
||||
public delegate FT_STATUS FT_SetTimeoutsDelegate(FT_HANDLE handle,
|
||||
uint readTimeout, uint writeTimeout);
|
||||
public delegate FT_STATUS FT_WriteDelegate(FT_HANDLE handle, byte[] buffer,
|
||||
uint bytesToWrite, out uint bytesWritten);
|
||||
public delegate FT_STATUS FT_PurgeDelegate(FT_HANDLE handle, FT_PURGE mask);
|
||||
public delegate FT_STATUS FT_GetStatusDelegate(FT_HANDLE handle,
|
||||
out uint amountInRxQueue, out uint amountInTxQueue, out uint eventStatus);
|
||||
public delegate FT_STATUS FT_ReadDelegate(FT_HANDLE handle,
|
||||
[Out] byte[] buffer, uint bytesToRead, out uint bytesReturned);
|
||||
public delegate FT_STATUS FT_ReadByteDelegate(FT_HANDLE handle,
|
||||
out byte buffer, uint bytesToRead, out uint bytesReturned);
|
||||
|
||||
public static readonly FT_CreateDeviceInfoListDelegate
|
||||
FT_CreateDeviceInfoList = CreateDelegate<
|
||||
FT_CreateDeviceInfoListDelegate>("FT_CreateDeviceInfoList");
|
||||
public static readonly FT_GetDeviceInfoListDelegate
|
||||
FT_GetDeviceInfoList = CreateDelegate<
|
||||
FT_GetDeviceInfoListDelegate>("FT_GetDeviceInfoList");
|
||||
public static readonly FT_OpenDelegate
|
||||
FT_Open = CreateDelegate<
|
||||
FT_OpenDelegate>("FT_Open");
|
||||
public static readonly FT_CloseDelegate
|
||||
FT_Close = CreateDelegate<
|
||||
FT_CloseDelegate>("FT_Close");
|
||||
public static readonly FT_SetBaudRateDelegate
|
||||
FT_SetBaudRate = CreateDelegate<
|
||||
FT_SetBaudRateDelegate>("FT_SetBaudRate");
|
||||
public static readonly FT_SetDataCharacteristicsDelegate
|
||||
FT_SetDataCharacteristics = CreateDelegate<
|
||||
FT_SetDataCharacteristicsDelegate>("FT_SetDataCharacteristics");
|
||||
public static readonly FT_SetFlowControlDelegate
|
||||
FT_SetFlowControl = CreateDelegate<
|
||||
FT_SetFlowControlDelegate>("FT_SetFlowControl");
|
||||
public static readonly FT_SetTimeoutsDelegate
|
||||
FT_SetTimeouts = CreateDelegate<
|
||||
FT_SetTimeoutsDelegate>("FT_SetTimeouts");
|
||||
public static readonly FT_WriteDelegate
|
||||
FT_Write = CreateDelegate<
|
||||
FT_WriteDelegate>("FT_Write");
|
||||
public static readonly FT_PurgeDelegate
|
||||
FT_Purge = CreateDelegate<
|
||||
FT_PurgeDelegate>("FT_Purge");
|
||||
public static readonly FT_GetStatusDelegate
|
||||
FT_GetStatus = CreateDelegate<
|
||||
FT_GetStatusDelegate>("FT_GetStatus");
|
||||
public static readonly FT_ReadDelegate
|
||||
FT_Read = CreateDelegate<
|
||||
FT_ReadDelegate>("FT_Read");
|
||||
public static readonly FT_ReadByteDelegate
|
||||
FT_ReadByte = CreateDelegate<
|
||||
FT_ReadByteDelegate>("FT_Read");
|
||||
private const string FtdAssemblyName = "FTD2XX.dll";
|
||||
[DllImport(FtdAssemblyName)]
|
||||
public static extern FT_STATUS FT_CreateDeviceInfoList(out uint numDevices);
|
||||
[DllImport(FtdAssemblyName)]
|
||||
public static extern FT_STATUS FT_GetDeviceInfoList([Out] FT_DEVICE_INFO_NODE[] deviceInfoNodes, ref uint length);
|
||||
[DllImport(FtdAssemblyName)]
|
||||
public static extern FT_STATUS FT_Open(int device, out FT_HANDLE handle);
|
||||
[DllImport(FtdAssemblyName)]
|
||||
public static extern FT_STATUS FT_Close(FT_HANDLE handle);
|
||||
[DllImport(FtdAssemblyName)]
|
||||
public static extern FT_STATUS FT_SetBaudRate(FT_HANDLE handle, uint baudRate);
|
||||
[DllImport(FtdAssemblyName)]
|
||||
public static extern FT_STATUS FT_SetDataCharacteristics(FT_HANDLE handle, byte wordLength, byte stopBits, byte parity);
|
||||
[DllImport(FtdAssemblyName)]
|
||||
public static extern FT_STATUS FT_SetFlowControl(FT_HANDLE handle, FT_FLOW_CONTROL flowControl, byte xon, byte xoff);
|
||||
[DllImport(FtdAssemblyName)]
|
||||
public static extern FT_STATUS FT_SetTimeouts(FT_HANDLE handle, uint readTimeout, uint writeTimeout);
|
||||
[DllImport(FtdAssemblyName)]
|
||||
public static extern FT_STATUS FT_Write(FT_HANDLE handle, byte[] buffer, uint bytesToWrite, out uint bytesWritten);
|
||||
[DllImport(FtdAssemblyName)]
|
||||
public static extern FT_STATUS FT_Purge(FT_HANDLE handle, FT_PURGE mask);
|
||||
[DllImport(FtdAssemblyName)]
|
||||
public static extern FT_STATUS FT_GetStatus(FT_HANDLE handle, out uint amountInRxQueue, out uint amountInTxQueue, out uint eventStatus);
|
||||
[DllImport(FtdAssemblyName)]
|
||||
public static extern FT_STATUS FT_Read(FT_HANDLE handle, [Out] byte[] buffer, uint bytesToRead, out uint bytesReturned);
|
||||
[DllImport(FtdAssemblyName)]
|
||||
public static extern FT_STATUS FT_ReadByte(FT_HANDLE handle, out byte buffer, uint bytesToRead, out uint bytesReturned);
|
||||
|
||||
private FTD2XX() { }
|
||||
|
||||
@@ -183,23 +147,5 @@ namespace OpenHardwareMonitor.Hardware.TBalancer {
|
||||
throw new InvalidOperationException();
|
||||
}
|
||||
|
||||
private static string GetDllName() {
|
||||
int p = (int)Environment.OSVersion.Platform;
|
||||
if ((p == 4) || (p == 128))
|
||||
return "libftd2xx.so";
|
||||
else
|
||||
return "ftd2xx.dll";
|
||||
}
|
||||
|
||||
private static T CreateDelegate<T>(string entryPoint)
|
||||
where T : class {
|
||||
DllImportAttribute attribute = new DllImportAttribute(GetDllName());
|
||||
attribute.CallingConvention = CallingConvention.StdCall;
|
||||
attribute.PreserveSig = true;
|
||||
attribute.EntryPoint = entryPoint;
|
||||
T newDelegate;
|
||||
PInvokeDelegateFactory.CreateDelegate(attribute, out newDelegate);
|
||||
return newDelegate;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -140,7 +140,6 @@
|
||||
<Compile Include="Hardware\HexStringArray.cs" />
|
||||
<Compile Include="Collections\IReadOnlyArray.cs" />
|
||||
<Compile Include="Collections\ListSet.cs" />
|
||||
<Compile Include="Hardware\PInvokeDelegateFactory.cs" />
|
||||
<Compile Include="Collections\ReadOnlyArray.cs" />
|
||||
<Compile Include="Properties\AssemblyLibInfo.cs" />
|
||||
<Compile Include="Properties\AssemblyVersion.cs" />
|
||||
|
||||
@@ -0,0 +1,117 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFramework>netstandard2.0</TargetFramework>
|
||||
<EnableDefaultCompileItems>false</EnableDefaultCompileItems>
|
||||
</PropertyGroup>
|
||||
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'">
|
||||
<GenerateSerializationAssemblies>Auto</GenerateSerializationAssemblies>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="System.IO.FileSystem.AccessControl" Version="4.4.0" />
|
||||
<PackageReference Include="System.IO.Ports" Version="4.4.0" />
|
||||
<PackageReference Include="System.Management" Version="4.5.0-preview1-25825-08" />
|
||||
<PackageReference Include="Microsoft.Win32.Registry" Version="4.5.0-preview2-25707-02" />
|
||||
<PackageReference Include="System.Reflection.Emit" Version="4.3.0" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<Compile Include="Collections\Pair.cs" />
|
||||
<Compile Include="Collections\RingCollection.cs" />
|
||||
<Compile Include="Hardware\ATI\ADL.cs" />
|
||||
<Compile Include="Hardware\ATI\ATIGPU.cs" />
|
||||
<Compile Include="Hardware\ATI\ATIGroup.cs" />
|
||||
<Compile Include="Hardware\Control.cs" />
|
||||
<Compile Include="Hardware\CPU\AMD17CPU.cs" />
|
||||
<Compile Include="Hardware\FirmwareTable.cs" />
|
||||
<Compile Include="Hardware\HDD\DebugSmart.cs" />
|
||||
<Compile Include="Hardware\HDD\DriveAttributeValue.cs" />
|
||||
<Compile Include="Hardware\HDD\DriveThresholdValue.cs" />
|
||||
<Compile Include="Hardware\HDD\HDDGeneric.cs" />
|
||||
<Compile Include="Hardware\HDD\ISmart.cs" />
|
||||
<Compile Include="Hardware\HDD\SmartAttribute.cs" />
|
||||
<Compile Include="Hardware\HDD\SmartNames.cs" />
|
||||
<Compile Include="Hardware\HDD\RequireSmartAttribute.cs" />
|
||||
<Compile Include="Hardware\HDD\NamePrefixAttribute.cs" />
|
||||
<Compile Include="Hardware\HDD\SSDIndilinx.cs" />
|
||||
<Compile Include="Hardware\HDD\SSDIntel.cs" />
|
||||
<Compile Include="Hardware\HDD\SSDMicron.cs" />
|
||||
<Compile Include="Hardware\HDD\SSDPlextor.cs" />
|
||||
<Compile Include="Hardware\HDD\SSDSamsung.cs" />
|
||||
<Compile Include="Hardware\HDD\SSDSandforce.cs" />
|
||||
<Compile Include="Hardware\IControl.cs" />
|
||||
<Compile Include="Hardware\IOControlCode.cs" />
|
||||
<Compile Include="Hardware\Computer.cs" />
|
||||
<Compile Include="Hardware\CPU\AMDCPU.cs" />
|
||||
<Compile Include="Hardware\CPU\GenericCPU.cs" />
|
||||
<Compile Include="Hardware\CPU\AMD0FCPU.cs" />
|
||||
<Compile Include="Hardware\CPU\AMD10CPU.cs" />
|
||||
<Compile Include="Hardware\CPU\CPUGroup.cs" />
|
||||
<Compile Include="Hardware\CPU\CPUID.cs" />
|
||||
<Compile Include="Hardware\CPU\CPULoad.cs" />
|
||||
<Compile Include="Hardware\CPU\IntelCPU.cs" />
|
||||
<Compile Include="Hardware\LPC\LPCPort.cs" />
|
||||
<Compile Include="Hardware\LPC\NCT677X.cs" />
|
||||
<Compile Include="Hardware\Mainboard\GigabyteTAMG.cs" />
|
||||
<Compile Include="Hardware\Mainboard\Identification.cs" />
|
||||
<Compile Include="Hardware\Opcode.cs" />
|
||||
<Compile Include="Hardware\OperatingSystem.cs" />
|
||||
<Compile Include="Hardware\RAM\GenericRAM.cs" />
|
||||
<Compile Include="Hardware\RAM\RAMGroup.cs" />
|
||||
<Compile Include="Hardware\Ring0.cs" />
|
||||
<Compile Include="Hardware\KernelDriver.cs" />
|
||||
<Compile Include="Hardware\Hardware.cs" />
|
||||
<Compile Include="Hardware\HDD\AbstractHarddrive.cs" />
|
||||
<Compile Include="Hardware\HDD\HarddriveGroup.cs" />
|
||||
<Compile Include="Hardware\HDD\WindowsSmart.cs" />
|
||||
<Compile Include="Hardware\Heatmaster\Heatmaster.cs" />
|
||||
<Compile Include="Hardware\Heatmaster\HeatmasterGroup.cs" />
|
||||
<Compile Include="Hardware\IComputer.cs" />
|
||||
<Compile Include="Hardware\Identifier.cs" />
|
||||
<Compile Include="Hardware\IElement.cs" />
|
||||
<Compile Include="Hardware\IGroup.cs" />
|
||||
<Compile Include="Hardware\IHardware.cs" />
|
||||
<Compile Include="Hardware\IParameter.cs" />
|
||||
<Compile Include="Hardware\ISensor.cs" />
|
||||
<Compile Include="Hardware\IVisitor.cs" />
|
||||
<Compile Include="Hardware\LPC\Chip.cs" />
|
||||
<Compile Include="Hardware\LPC\F718XX.cs" />
|
||||
<Compile Include="Hardware\LPC\ISuperIO.cs" />
|
||||
<Compile Include="Hardware\LPC\IT87XX.cs" />
|
||||
<Compile Include="Hardware\LPC\LMSensors.cs" />
|
||||
<Compile Include="Hardware\LPC\LPCIO.cs" />
|
||||
<Compile Include="Hardware\LPC\W836XX.cs" />
|
||||
<Compile Include="Hardware\Mainboard\Mainboard.cs" />
|
||||
<Compile Include="Hardware\Mainboard\MainboardGroup.cs" />
|
||||
<Compile Include="Hardware\Mainboard\Manufacturer.cs" />
|
||||
<Compile Include="Hardware\Mainboard\Model.cs" />
|
||||
<Compile Include="Hardware\SMBIOS.cs" />
|
||||
<Compile Include="Hardware\Mainboard\SuperIOHardware.cs" />
|
||||
<Compile Include="Hardware\Nvidia\NVAPI.cs" />
|
||||
<Compile Include="Hardware\Nvidia\NvidiaGPU.cs" />
|
||||
<Compile Include="Hardware\Nvidia\NvidiaGroup.cs" />
|
||||
<Compile Include="Hardware\Parameter.cs" />
|
||||
<Compile Include="Hardware\Sensor.cs" />
|
||||
<Compile Include="Hardware\SensorVisitor.cs" />
|
||||
<Compile Include="Hardware\TBalancer\FTD2XX.cs" />
|
||||
<Compile Include="Hardware\TBalancer\TBalancer.cs" />
|
||||
<Compile Include="Hardware\TBalancer\TBalancerGroup.cs" />
|
||||
<Compile Include="Hardware\ISettings.cs" />
|
||||
<Compile Include="Hardware\HexStringArray.cs" />
|
||||
<Compile Include="Collections\IReadOnlyArray.cs" />
|
||||
<Compile Include="Collections\ListSet.cs" />
|
||||
<Compile Include="Collections\ReadOnlyArray.cs" />
|
||||
<Compile Include="Hardware\ThreadAffinity.cs" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<EmbeddedResource Include="Hardware\WinRing0.sys" />
|
||||
<EmbeddedResource Include="Hardware\WinRing0x64.sys" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<Folder Include="Properties\" />
|
||||
</ItemGroup>
|
||||
</Project>
|
||||
@@ -0,0 +1,57 @@
|
||||
|
||||
Microsoft Visual Studio Solution File, Format Version 11.00
|
||||
# Visual Studio 2010
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "OpenHardwareMonitorLib", "OpenHardwareMonitorLibNetStandard.csproj", "{B0397530-545A-471D-BB74-027AE456DF1A}"
|
||||
EndProject
|
||||
Global
|
||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||
Debug|Any CPU = Debug|Any CPU
|
||||
Release|Any CPU = Release|Any CPU
|
||||
EndGlobalSection
|
||||
GlobalSection(ProjectConfigurationPlatforms) = postSolution
|
||||
{B0397530-545A-471D-BB74-027AE456DF1A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{B0397530-545A-471D-BB74-027AE456DF1A}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{B0397530-545A-471D-BB74-027AE456DF1A}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{B0397530-545A-471D-BB74-027AE456DF1A}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{F5E0C1F7-9E9B-46F2-AC88-8C9C1C923880}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{F5E0C1F7-9E9B-46F2-AC88-8C9C1C923880}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{F5E0C1F7-9E9B-46F2-AC88-8C9C1C923880}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{F5E0C1F7-9E9B-46F2-AC88-8C9C1C923880}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{E73BB233-D88B-44A7-A98F-D71EE158381D}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{E73BB233-D88B-44A7-A98F-D71EE158381D}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{E73BB233-D88B-44A7-A98F-D71EE158381D}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{E73BB233-D88B-44A7-A98F-D71EE158381D}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{BCC43E58-E473-403E-A84D-63FEDC723040}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{BCC43E58-E473-403E-A84D-63FEDC723040}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{BCC43E58-E473-403E-A84D-63FEDC723040}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{BCC43E58-E473-403E-A84D-63FEDC723040}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{D4554296-094E-4CAC-8EAE-44EB250666C6}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{D4554296-094E-4CAC-8EAE-44EB250666C6}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{D4554296-094E-4CAC-8EAE-44EB250666C6}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{D4554296-094E-4CAC-8EAE-44EB250666C6}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
EndGlobalSection
|
||||
GlobalSection(SolutionProperties) = preSolution
|
||||
HideSolutionNode = FALSE
|
||||
EndGlobalSection
|
||||
GlobalSection(MonoDevelopProperties) = preSolution
|
||||
StartupItem = OpenHardwareMonitor.csproj
|
||||
Policies = $0
|
||||
$0.DotNetNamingPolicy = $1
|
||||
$1.DirectoryNamespaceAssociation = None
|
||||
$1.ResourceNamePolicy = FileFormatDefault
|
||||
$0.TextStylePolicy = $2
|
||||
$2.FileWidth = 120
|
||||
$2.TabWidth = 2
|
||||
$2.NoTabsAfterNonTabs = True
|
||||
$2.inheritsSet = VisualStudio
|
||||
$2.inheritsScope = text/plain
|
||||
$2.scope = text/plain
|
||||
$0.TextStylePolicy = $3
|
||||
$3.inheritsSet = null
|
||||
$3.scope = text/x-csharp
|
||||
$0.CSharpFormattingPolicy = $4
|
||||
$4.inheritsSet = Mono
|
||||
$4.inheritsScope = text/x-csharp
|
||||
$4.scope = text/x-csharp
|
||||
EndGlobalSection
|
||||
EndGlobal
|
||||
Reference in New Issue
Block a user