mirror of
https://github.com/Metabolix/HackBGRT.git
synced 2025-12-07 09:36:10 -08:00
Fix member naming
This commit is contained in:
26
src/Efi.cs
26
src/Efi.cs
@@ -39,9 +39,9 @@ public class Efi {
|
|||||||
* Information about an EFI variable.
|
* Information about an EFI variable.
|
||||||
*/
|
*/
|
||||||
public class Variable {
|
public class Variable {
|
||||||
public string name, guid;
|
public string Name, Guid;
|
||||||
public UInt32 attributes;
|
public UInt32 Attributes;
|
||||||
public byte[] data;
|
public byte[] Data;
|
||||||
}
|
}
|
||||||
|
|
||||||
public const string EFI_GLOBAL_GUID = "{8be4df61-93ca-11d2-aa0d-00e098032b8c}";
|
public const string EFI_GLOBAL_GUID = "{8be4df61-93ca-11d2-aa0d-00e098032b8c}";
|
||||||
@@ -83,19 +83,19 @@ public class Efi {
|
|||||||
*/
|
*/
|
||||||
private static Variable GetVariable(string name, string guid = EFI_GLOBAL_GUID) {
|
private static Variable GetVariable(string name, string guid = EFI_GLOBAL_GUID) {
|
||||||
Variable result = new Variable();
|
Variable result = new Variable();
|
||||||
result.name = name;
|
result.Name = name;
|
||||||
result.guid = guid;
|
result.Guid = guid;
|
||||||
result.data = null;
|
result.Data = null;
|
||||||
result.attributes = 0;
|
result.Attributes = 0;
|
||||||
for (UInt32 i = 4096; i <= 1024*1024; i *= 2) {
|
for (UInt32 i = 4096; i <= 1024*1024; i *= 2) {
|
||||||
byte[] buf = new byte[i];
|
byte[] buf = new byte[i];
|
||||||
UInt32 len = GetFirmwareEnvironmentVariableEx(name, guid, buf, (UInt32) buf.Length, out result.attributes);
|
UInt32 len = GetFirmwareEnvironmentVariableEx(name, guid, buf, (UInt32) buf.Length, out result.Attributes);
|
||||||
if (len == buf.Length) {
|
if (len == buf.Length) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if (len > 0 || Marshal.GetLastWin32Error() == 0) {
|
if (len > 0 || Marshal.GetLastWin32Error() == 0) {
|
||||||
result.data = new byte[len];
|
result.Data = new byte[len];
|
||||||
Array.Copy(buf, 0, result.data, 0, len);
|
Array.Copy(buf, 0, result.Data, 0, len);
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
switch (len != 0 ? 0 : Marshal.GetLastWin32Error()) {
|
switch (len != 0 ? 0 : Marshal.GetLastWin32Error()) {
|
||||||
@@ -119,7 +119,7 @@ public class Efi {
|
|||||||
* @param v Information of the variable.
|
* @param v Information of the variable.
|
||||||
*/
|
*/
|
||||||
private static void SetVariable(Variable v) {
|
private static void SetVariable(Variable v) {
|
||||||
UInt32 r = SetFirmwareEnvironmentVariableEx(v.name, v.guid, v.data, (UInt32) v.data.Length, v.attributes);
|
UInt32 r = SetFirmwareEnvironmentVariableEx(v.Name, v.Guid, v.Data, (UInt32) v.Data.Length, v.Attributes);
|
||||||
if (r == 0) {
|
if (r == 0) {
|
||||||
switch (Marshal.GetLastWin32Error()) {
|
switch (Marshal.GetLastWin32Error()) {
|
||||||
case 87:
|
case 87:
|
||||||
@@ -159,7 +159,7 @@ public class Efi {
|
|||||||
public static bool CanBootToFW() {
|
public static bool CanBootToFW() {
|
||||||
try {
|
try {
|
||||||
Variable tmp = GetVariable("OsIndicationsSupported");
|
Variable tmp = GetVariable("OsIndicationsSupported");
|
||||||
return tmp.data != null && (tmp.data[0] & 1) != 0;
|
return tmp.Data != null && (tmp.Data[0] & 1) != 0;
|
||||||
} catch {
|
} catch {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@@ -170,7 +170,7 @@ public class Efi {
|
|||||||
*/
|
*/
|
||||||
public static void SetBootToFW() {
|
public static void SetBootToFW() {
|
||||||
Variable tmp = GetVariable("OsIndications");
|
Variable tmp = GetVariable("OsIndications");
|
||||||
tmp.data[0] |= 1;
|
tmp.Data[0] |= 1;
|
||||||
SetVariable(tmp);
|
SetVariable(tmp);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user