Fixed ADL dll loading. The name of the dll is always atiadlxx, except when running as 32-bit app on 64-bit systems (atiadlxy in that case).
1.1 --- a/Hardware/ATI/ADL.cs Thu Jan 28 23:29:39 2010 +0000
1.2 +++ b/Hardware/ATI/ADL.cs Fri Jan 29 19:20:44 2010 +0000
1.3 @@ -171,60 +171,62 @@
1.4 public static ADL_Overdrive5_FanSpeedInfo_GetDelegate
1.5 ADL_Overdrive5_FanSpeedInfo_Get;
1.6
1.7 - private static string GetDllName() {
1.8 - int p = (int)System.Environment.OSVersion.Platform;
1.9 - if ((p == 4) || (p == 128)) {
1.10 - if (IntPtr.Size == 4) {
1.11 - return "atiadlxy.so";
1.12 - } else {
1.13 - return "atiadlxx.so";
1.14 - }
1.15 - } else {
1.16 - if (IntPtr.Size == 4) {
1.17 - return "atiadlxy.dll";
1.18 - } else {
1.19 - return "atiadlxx.dll";
1.20 - }
1.21 - }
1.22 - }
1.23 + private static string dllName;
1.24
1.25 private static void GetDelegate<T>(string entryPoint, out T newDelegate)
1.26 where T : class
1.27 {
1.28 - DllImportAttribute attribute = new DllImportAttribute(GetDllName());
1.29 + DllImportAttribute attribute = new DllImportAttribute(dllName);
1.30 attribute.CallingConvention = CallingConvention.StdCall;
1.31 attribute.PreserveSig = true;
1.32 attribute.EntryPoint = entryPoint;
1.33 PInvokeDelegateFactory.CreateDelegate(attribute, out newDelegate);
1.34 }
1.35
1.36 + private static void CreateDelegates(string name) {
1.37 + int p = (int)System.Environment.OSVersion.Platform;
1.38 + if ((p == 4) || (p == 128))
1.39 + dllName = name + ".so";
1.40 + else
1.41 + dllName = name + ".dll";
1.42 +
1.43 + GetDelegate("ADL_Main_Control_Create",
1.44 + out _ADL_Main_Control_Create);
1.45 + GetDelegate("ADL_Adapter_AdapterInfo_Get",
1.46 + out _ADL_Adapter_AdapterInfo_Get);
1.47 + GetDelegate("ADL_Main_Control_Destroy",
1.48 + out ADL_Main_Control_Destroy);
1.49 + GetDelegate("ADL_Adapter_NumberOfAdapters_Get",
1.50 + out ADL_Adapter_NumberOfAdapters_Get);
1.51 + GetDelegate("ADL_Adapter_ID_Get",
1.52 + out ADL_Adapter_ID_Get);
1.53 + GetDelegate("ADL_Adapter_Active_Get",
1.54 + out ADL_Adapter_Active_Get);
1.55 + GetDelegate("ADL_Overdrive5_CurrentActivity_Get",
1.56 + out ADL_Overdrive5_CurrentActivity_Get);
1.57 + GetDelegate("ADL_Overdrive5_Temperature_Get",
1.58 + out ADL_Overdrive5_Temperature_Get);
1.59 + GetDelegate("ADL_Overdrive5_FanSpeed_Get",
1.60 + out ADL_Overdrive5_FanSpeed_Get);
1.61 + GetDelegate("ADL_Overdrive5_FanSpeedInfo_Get",
1.62 + out ADL_Overdrive5_FanSpeedInfo_Get);
1.63 + }
1.64 +
1.65 static ADL() {
1.66 - GetDelegate("ADL_Main_Control_Create",
1.67 - out _ADL_Main_Control_Create);
1.68 - GetDelegate("ADL_Adapter_AdapterInfo_Get",
1.69 - out _ADL_Adapter_AdapterInfo_Get);
1.70 - GetDelegate("ADL_Main_Control_Destroy",
1.71 - out ADL_Main_Control_Destroy);
1.72 - GetDelegate("ADL_Adapter_NumberOfAdapters_Get",
1.73 - out ADL_Adapter_NumberOfAdapters_Get);
1.74 - GetDelegate("ADL_Adapter_ID_Get",
1.75 - out ADL_Adapter_ID_Get);
1.76 - GetDelegate("ADL_Adapter_Active_Get",
1.77 - out ADL_Adapter_Active_Get);
1.78 - GetDelegate("ADL_Overdrive5_CurrentActivity_Get",
1.79 - out ADL_Overdrive5_CurrentActivity_Get);
1.80 - GetDelegate("ADL_Overdrive5_Temperature_Get",
1.81 - out ADL_Overdrive5_Temperature_Get);
1.82 - GetDelegate("ADL_Overdrive5_FanSpeed_Get",
1.83 - out ADL_Overdrive5_FanSpeed_Get);
1.84 - GetDelegate("ADL_Overdrive5_FanSpeedInfo_Get",
1.85 - out ADL_Overdrive5_FanSpeedInfo_Get);
1.86 + CreateDelegates("atiadlxx");
1.87 }
1.88
1.89 private ADL() { }
1.90
1.91 public static int ADL_Main_Control_Create(int enumConnectedAdapters) {
1.92 - return _ADL_Main_Control_Create(Main_Memory_Alloc, enumConnectedAdapters);
1.93 + try {
1.94 + return _ADL_Main_Control_Create(Main_Memory_Alloc,
1.95 + enumConnectedAdapters);
1.96 + } catch (DllNotFoundException) {
1.97 + CreateDelegates("atiadlxy");
1.98 + return _ADL_Main_Control_Create(Main_Memory_Alloc,
1.99 + enumConnectedAdapters);
1.100 + }
1.101 }
1.102
1.103 public static int ADL_Adapter_AdapterInfo_Get(ADLAdapterInfo[] info) {
2.1 --- a/Hardware/SMBIOS/SMBIOSGroup.cs Thu Jan 28 23:29:39 2010 +0000
2.2 +++ b/Hardware/SMBIOS/SMBIOSGroup.cs Fri Jan 29 19:20:44 2010 +0000
2.3 @@ -1,4 +1,4 @@
2.4 -/*
2.5 +/*
2.6
2.7 Version: MPL 1.1/GPL 2.0/LGPL 2.1
2.8
2.9 @@ -54,55 +54,59 @@
2.10 int p = (int)System.Environment.OSVersion.Platform;
2.11 if ((p == 4) || (p == 128))
2.12 return;
2.13 -
2.14 - ManagementObjectCollection collection = new ManagementObjectSearcher(
2.15 - "root\\WMI", "SELECT SMBiosData FROM MSSMBios_RawSMBiosTables").Get();
2.16 -
2.17 - byte[] raw = null;
2.18 - foreach (ManagementObject mo in collection) {
2.19 - raw = (byte[])mo["SMBiosData"];
2.20 - break;
2.21 - }
2.22 -
2.23 +
2.24 List<Structure> structureList = new List<Structure>();
2.25 - if (raw != null && raw.Length > 0) {
2.26 - int offset = 0;
2.27 - byte type = raw[offset];
2.28 - while (offset < raw.Length && type != 127) {
2.29 -
2.30 - type = raw[offset]; offset++;
2.31 - int length = raw[offset]; offset++;
2.32 - ushort handle = (ushort)((raw[offset] << 8) | raw[offset + 1]);
2.33 - offset += 2;
2.34 -
2.35 - byte[] data = new byte[length];
2.36 - Array.Copy(raw, offset - 4, data, 0, length); offset += length - 4;
2.37 -
2.38 - List<string> stringsList = new List<string>();
2.39 - if (raw[offset] == 0)
2.40 - offset++;
2.41 - while (raw[offset] != 0) {
2.42 - StringBuilder sb = new StringBuilder();
2.43 - while (raw[offset] != 0) {
2.44 - sb.Append((char)raw[offset]); offset++;
2.45 +
2.46 + try {
2.47 + ManagementObjectCollection collection = new ManagementObjectSearcher(
2.48 + "root\\WMI", "SELECT SMBiosData FROM MSSMBios_RawSMBiosTables").Get();
2.49 +
2.50 + byte[] raw = null;
2.51 + foreach (ManagementObject mo in collection) {
2.52 + raw = (byte[])mo["SMBiosData"];
2.53 + break;
2.54 + }
2.55 +
2.56 + if (raw != null && raw.Length > 0) {
2.57 + int offset = 0;
2.58 + byte type = raw[offset];
2.59 + while (offset < raw.Length && type != 127) {
2.60 +
2.61 + type = raw[offset]; offset++;
2.62 + int length = raw[offset]; offset++;
2.63 + ushort handle = (ushort)((raw[offset] << 8) | raw[offset + 1]);
2.64 + offset += 2;
2.65 +
2.66 + byte[] data = new byte[length];
2.67 + Array.Copy(raw, offset - 4, data, 0, length); offset += length - 4;
2.68 +
2.69 + List<string> stringsList = new List<string>();
2.70 + if (raw[offset] == 0)
2.71 + offset++;
2.72 + while (raw[offset] != 0) {
2.73 + StringBuilder sb = new StringBuilder();
2.74 + while (raw[offset] != 0) {
2.75 + sb.Append((char)raw[offset]); offset++;
2.76 + }
2.77 + offset++;
2.78 + stringsList.Add(sb.ToString());
2.79 }
2.80 offset++;
2.81 - stringsList.Add(sb.ToString());
2.82 - }
2.83 - offset++;
2.84 - switch (type) {
2.85 - case 0x00:
2.86 - this.biosInformation = new BIOSInformation(
2.87 - type, handle, data, stringsList.ToArray());
2.88 - structureList.Add(this.biosInformation); break;
2.89 - case 0x02: this.baseBoardInformation = new BaseBoardInformation(
2.90 - type, handle, data, stringsList.ToArray());
2.91 - structureList.Add(this.baseBoardInformation); break;
2.92 - default: structureList.Add(new Structure(
2.93 - type, handle, data, stringsList.ToArray())); break;
2.94 + switch (type) {
2.95 + case 0x00:
2.96 + this.biosInformation = new BIOSInformation(
2.97 + type, handle, data, stringsList.ToArray());
2.98 + structureList.Add(this.biosInformation); break;
2.99 + case 0x02: this.baseBoardInformation = new BaseBoardInformation(
2.100 + type, handle, data, stringsList.ToArray());
2.101 + structureList.Add(this.baseBoardInformation); break;
2.102 + default: structureList.Add(new Structure(
2.103 + type, handle, data, stringsList.ToArray())); break;
2.104 + }
2.105 }
2.106 }
2.107 - }
2.108 + } catch (NotImplementedException) { }
2.109 +
2.110 table = structureList.ToArray();
2.111 }
2.112