qol: inline variable declaration
This commit is contained in:
@@ -34,7 +34,7 @@ namespace Disco.ClientBootstrapper.Interop
|
||||
Name = (string)wmiObject.GetPropertyValue("Name");
|
||||
NetConnectionID = (string)wmiObject.GetPropertyValue("NetConnectionID");
|
||||
Speed = (UInt64)wmiObject.GetPropertyValue("Speed");
|
||||
var connectionStatus = ConnectionStatus;
|
||||
_ = ConnectionStatus;
|
||||
IsWireless = true;
|
||||
try
|
||||
{
|
||||
@@ -53,19 +53,17 @@ namespace Disco.ClientBootstrapper.Interop
|
||||
if (IsWireless)
|
||||
{
|
||||
IntPtr handle = IntPtr.Zero;
|
||||
uint negotiatedVersion;
|
||||
try
|
||||
{
|
||||
if (NetworkInterop.WlanOpenHandle(1, IntPtr.Zero, out negotiatedVersion, ref handle) != 0)
|
||||
if (NetworkInterop.WlanOpenHandle(1, IntPtr.Zero, out var negotiatedVersion, ref handle) != 0)
|
||||
throw new NotSupportedException("This network adapter does not support Wireless");
|
||||
|
||||
IntPtr ptr = new IntPtr();
|
||||
|
||||
uint dataSize;
|
||||
|
||||
var interfaceGuid = Guid;
|
||||
|
||||
if (NetworkInterop.WlanQueryInterface(handle, ref interfaceGuid, NetworkInterop.WLAN_INTF_OPCODE.wlan_intf_opcode_interface_state, IntPtr.Zero, out dataSize, ref ptr, IntPtr.Zero) != 0)
|
||||
if (NetworkInterop.WlanQueryInterface(handle, ref interfaceGuid, NetworkInterop.WLAN_INTF_OPCODE.wlan_intf_opcode_interface_state, IntPtr.Zero, out var dataSize, ref ptr, IntPtr.Zero) != 0)
|
||||
throw new NotSupportedException("This network adapter does not support Wireless");
|
||||
|
||||
LastWirelessConnectionStatus = Marshal.ReadInt32(ptr);
|
||||
|
||||
@@ -196,11 +196,10 @@ namespace Disco.ClientBootstrapper.Interop
|
||||
{
|
||||
|
||||
IntPtr wlanHandle = IntPtr.Zero;
|
||||
uint negotiatedVersion;
|
||||
|
||||
try
|
||||
{
|
||||
if (WlanOpenHandle(1, IntPtr.Zero, out negotiatedVersion, ref wlanHandle) != 0)
|
||||
if (WlanOpenHandle(1, IntPtr.Zero, out var negotiatedVersion, ref wlanHandle) != 0)
|
||||
throw new NotSupportedException("This device does not support Wireless");
|
||||
|
||||
// Add Profile to Each Wireless Adapter
|
||||
@@ -241,8 +240,7 @@ namespace Disco.ClientBootstrapper.Interop
|
||||
var pInterfaceGuid = interfaceGuid;
|
||||
var pProfileXml = ProfileXml;
|
||||
uint pFlag = 0;
|
||||
uint failReason;
|
||||
return (WlanSetProfile(WlanHandle, ref pInterfaceGuid, pFlag, pProfileXml, null, true, IntPtr.Zero, out failReason) == 0);
|
||||
return WlanSetProfile(WlanHandle, ref pInterfaceGuid, pFlag, pProfileXml, null, true, IntPtr.Zero, out _) == 0;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -58,16 +58,15 @@ namespace Disco.ClientBootstrapper.Interop
|
||||
public RegistryInterop(RegistryHives hive, string subKey, string filePath)
|
||||
{
|
||||
int token = 0;
|
||||
int retval = 0;
|
||||
|
||||
TOKEN_PRIVILEGES TP = new TOKEN_PRIVILEGES();
|
||||
TOKEN_PRIVILEGES TP2 = new TOKEN_PRIVILEGES();
|
||||
LUID RestoreLuid = new LUID();
|
||||
LUID BackupLuid = new LUID();
|
||||
|
||||
retval = OpenProcessToken(GetCurrentProcess(), TOKEN_ADJUST_PRIVILEGES | TOKEN_QUERY, ref token);
|
||||
retval = LookupPrivilegeValue(null, SE_RESTORE_NAME, ref RestoreLuid);
|
||||
retval = LookupPrivilegeValue(null, SE_BACKUP_NAME, ref BackupLuid);
|
||||
OpenProcessToken(GetCurrentProcess(), TOKEN_ADJUST_PRIVILEGES | TOKEN_QUERY, ref token);
|
||||
LookupPrivilegeValue(null, SE_RESTORE_NAME, ref RestoreLuid);
|
||||
LookupPrivilegeValue(null, SE_BACKUP_NAME, ref BackupLuid);
|
||||
TP.PrivilegeCount = 1;
|
||||
TP.Attributes = SE_PRIVILEGE_ENABLED;
|
||||
TP.Luid = RestoreLuid;
|
||||
@@ -75,8 +74,8 @@ namespace Disco.ClientBootstrapper.Interop
|
||||
TP2.Attributes = SE_PRIVILEGE_ENABLED;
|
||||
TP2.Luid = BackupLuid;
|
||||
|
||||
retval = AdjustTokenPrivileges(token, 0, ref TP, 1024, 0, 0);
|
||||
retval = AdjustTokenPrivileges(token, 0, ref TP2, 1024, 0, 0);
|
||||
AdjustTokenPrivileges(token, 0, ref TP, 1024, 0, 0);
|
||||
AdjustTokenPrivileges(token, 0, ref TP2, 1024, 0, 0);
|
||||
|
||||
uint regHive = (uint)hive;
|
||||
|
||||
|
||||
@@ -39,21 +39,20 @@ namespace Disco.ClientBootstrapper.Interop
|
||||
// End Removed 2012-11-23 G#
|
||||
|
||||
// Added 2012-11-23 G# - Migrate to Win32 PInvoke Shutdown
|
||||
bool result;
|
||||
TokPriv1Luid tp;
|
||||
|
||||
IntPtr hproc = GetCurrentProcess();
|
||||
IntPtr htok = IntPtr.Zero;
|
||||
|
||||
result = OpenProcessToken(hproc, TOKEN_ADJUST_PRIVILEGES | TOKEN_QUERY, ref htok);
|
||||
OpenProcessToken(hproc, TOKEN_ADJUST_PRIVILEGES | TOKEN_QUERY, ref htok);
|
||||
|
||||
tp.Count = 1;
|
||||
tp.Luid = 0;
|
||||
tp.Attr = SE_PRIVILEGE_ENABLED;
|
||||
|
||||
result = LookupPrivilegeValue(null, SE_SHUTDOWN_NAME, ref tp.Luid);
|
||||
result = AdjustTokenPrivileges(htok, false, ref tp, 0, IntPtr.Zero, IntPtr.Zero);
|
||||
result = ExitWindowsEx(flag, 0);
|
||||
LookupPrivilegeValue(null, SE_SHUTDOWN_NAME, ref tp.Luid);
|
||||
AdjustTokenPrivileges(htok, false, ref tp, 0, IntPtr.Zero, IntPtr.Zero);
|
||||
ExitWindowsEx(flag, 0);
|
||||
// End Added 2012-11-23 G#
|
||||
}
|
||||
|
||||
|
||||
@@ -684,7 +684,7 @@ namespace Disco.ClientBootstrapper.Interop.WIMInterop
|
||||
IntPtr windowsImageHandle = IntPtr.Zero;
|
||||
int rc = -1;
|
||||
|
||||
windowsImageHandle = NativeMethods.WimCreateFile(imageFile, access, mode, 0, 0, out creationResult);
|
||||
windowsImageHandle = NativeMethods.WimCreateFile(imageFile, access, mode, 0, 0, out _);
|
||||
rc = Marshal.GetLastWin32Error();
|
||||
if (windowsImageHandle == IntPtr.Zero)
|
||||
{
|
||||
@@ -1062,7 +1062,7 @@ namespace Disco.ClientBootstrapper.Interop.WIMInterop
|
||||
IntPtr info = IntPtr.Zero, sizeOfInfo = IntPtr.Zero;
|
||||
bool status;
|
||||
|
||||
status = NativeMethods.WimGetImageInformation(handle, out info, out sizeOfInfo);
|
||||
status = NativeMethods.WimGetImageInformation(handle, out info, out _);
|
||||
int rc = Marshal.GetLastWin32Error();
|
||||
|
||||
if (status == false)
|
||||
@@ -1221,7 +1221,7 @@ namespace Disco.ClientBootstrapper.Interop.WIMInterop
|
||||
void
|
||||
RegisterCallback(MessageCallback callback)
|
||||
{
|
||||
uint callbackZeroBasedIndex = NativeMethods.WimRegisterMessageCallback(IntPtr.Zero, callback, IntPtr.Zero);
|
||||
NativeMethods.WimRegisterMessageCallback(IntPtr.Zero, callback, IntPtr.Zero);
|
||||
int rc = Marshal.GetLastWin32Error();
|
||||
if (rc != 0)
|
||||
{
|
||||
@@ -1254,7 +1254,7 @@ namespace Disco.ClientBootstrapper.Interop.WIMInterop
|
||||
UnregisterMessageCallback(MessageCallback registeredCallback)
|
||||
{
|
||||
bool status = NativeMethods.WimUnregisterMessageCallback(IntPtr.Zero, registeredCallback);
|
||||
int rc = Marshal.GetLastWin32Error();
|
||||
_ = Marshal.GetLastWin32Error();
|
||||
if (status != true)
|
||||
{
|
||||
//
|
||||
|
||||
Reference in New Issue
Block a user