qol: simplify calls

This commit is contained in:
Gary Sharp
2025-07-20 15:20:22 +10:00
parent 1add4ee0f5
commit 9656c15c4b
61 changed files with 214 additions and 214 deletions
+1 -1
View File
@@ -232,7 +232,7 @@ namespace Disco.ClientBootstrapper
{
if (!string.IsNullOrWhiteSpace(e.Data))
{
System.Diagnostics.Debug.WriteLine($"OUTPUT: {e.Data}");
Debug.WriteLine($"OUTPUT: {e.Data}");
var data = e.Data.Substring(1).Split(new char[] { ',' });
switch (e.Data[0])
{
@@ -248,9 +248,9 @@ namespace Disco.ClientBootstrapper.Interop
Program.Status.UpdateStatus(null, "Mounting WIM", $"Mounting WIM Image to '{wimMountPath}'");
Program.SleepThread(500, false);
m_MessageCallback = new WIMInterop.WindowsImageContainer.NativeMethods.MessageCallback(WimImageEventMessagePump);
Interop.WIMInterop.WindowsImageContainer.NativeMethods.RegisterCallback(m_MessageCallback);
WIMInterop.WindowsImageContainer.NativeMethods.RegisterCallback(m_MessageCallback);
Interop.WIMInterop.WindowsImageContainer.NativeMethods.MountImage(wimMountPath, InstallLocation, wimImageIndex, wimTempMountPath);
WIMInterop.WindowsImageContainer.NativeMethods.MountImage(wimMountPath, InstallLocation, wimImageIndex, wimTempMountPath);
// Load Local Machine Registry
var wimHivePath = Path.Combine(wimMountPath, "Windows\\System32\\config\\SOFTWARE");
@@ -283,11 +283,11 @@ namespace Disco.ClientBootstrapper.Interop
// Unmount WIM
Program.Status.UpdateStatus(null, "Unmounting WIM", $"Unmounting WIM Image at '{wimMountPath}'");
Program.SleepThread(500, false);
Interop.WIMInterop.WindowsImageContainer.NativeMethods.DismountImage(wimMountPath, InstallLocation, wimImageIndex, wimCommitChanges);
WIMInterop.WindowsImageContainer.NativeMethods.DismountImage(wimMountPath, InstallLocation, wimImageIndex, wimCommitChanges);
if (m_MessageCallback != null)
{
Interop.WIMInterop.WindowsImageContainer.NativeMethods.UnregisterMessageCallback(m_MessageCallback);
WIMInterop.WindowsImageContainer.NativeMethods.UnregisterMessageCallback(m_MessageCallback);
m_MessageCallback = null;
}
@@ -321,7 +321,7 @@ namespace Disco.ClientBootstrapper.Interop
IntPtr UserData
)
{
uint status = (uint)Interop.WIMInterop.WindowsImageContainer.NativeMethods.WIMMessage.WIM_MSG_SUCCESS;
uint status = (uint)WIMInterop.WindowsImageContainer.NativeMethods.WIMMessage.WIM_MSG_SUCCESS;
WIMInterop.DefaultImageEventArgs eventArgs = new WIMInterop.DefaultImageEventArgs(wParam, lParam, UserData);
//System.Diagnostics.Debug.WriteLine(MessageId);
@@ -329,8 +329,8 @@ namespace Disco.ClientBootstrapper.Interop
switch ((WIMInterop.WindowsImageContainer.ImageEventMessage)MessageId)
{
case Interop.WIMInterop.WindowsImageContainer.ImageEventMessage.Progress:
case Interop.WIMInterop.WindowsImageContainer.ImageEventMessage.MountCleanupProgress:
case WIMInterop.WindowsImageContainer.ImageEventMessage.Progress:
case WIMInterop.WindowsImageContainer.ImageEventMessage.MountCleanupProgress:
var timeRemainingMil = eventArgs.LeftParameter.ToInt32();
string timeRemainingMessage;
if (timeRemainingMil > 0)
@@ -224,7 +224,7 @@ namespace Disco.ClientBootstrapper.Interop
finally
{
if (wlanHandle != IntPtr.Zero)
NetworkInterop.WlanCloseHandle(wlanHandle, IntPtr.Zero);
WlanCloseHandle(wlanHandle, IntPtr.Zero);
}
}
@@ -277,7 +277,7 @@ namespace Disco.ClientBootstrapper.Interop
WlanGetProfileList(WlanHandle, ref pInterfaceGuid, new IntPtr(), ref ppProfileList);
WLAN_PROFILE_INFO_LIST wlanProfileInfoList = new WLAN_PROFILE_INFO_LIST(ppProfileList);
NetworkInterop.WlanFreeMemory(ppProfileList);
WlanFreeMemory(ppProfileList);
return wlanProfileInfoList;
}
+15 -15
View File
@@ -163,7 +163,7 @@ namespace Disco.ClientBootstrapper.Interop.WIMInterop
//Set the temporary path so that we can write to an image. This
//cannot be %TEMP% as it does not exist on Windows PE
//
string tempDirectory = System.Environment.GetEnvironmentVariable("systemdrive");
string tempDirectory = Environment.GetEnvironmentVariable("systemdrive");
NativeMethods.SetTemporaryPath(m_ImageContainerHandle, tempDirectory);
}
@@ -596,7 +596,7 @@ namespace Disco.ClientBootstrapper.Interop.WIMInterop
//Mount the image
//
m_MountedPath = pathToMountTo;
NativeMethods.MountImage(pathToMountTo, m_ParentWindowsImageFilePath, m_Index, System.IO.Path.GetTempPath());
NativeMethods.MountImage(pathToMountTo, m_ParentWindowsImageFilePath, m_Index, Path.GetTempPath());
m_Mounted = true;
}
@@ -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 _);
windowsImageHandle = WimCreateFile(imageFile, access, mode, 0, 0, out _);
rc = Marshal.GetLastWin32Error();
if (windowsImageHandle == IntPtr.Zero)
{
@@ -721,7 +721,7 @@ namespace Disco.ClientBootstrapper.Interop.WIMInterop
void
CloseHandle(IntPtr handle)
{
bool status = NativeMethods.WimCloseHandle(handle);
bool status = WimCloseHandle(handle);
int rc = Marshal.GetLastWin32Error();
if (status == false)
{
@@ -757,7 +757,7 @@ namespace Disco.ClientBootstrapper.Interop.WIMInterop
void
SetTemporaryPath(IntPtr handle, string temporaryPath)
{
bool status = NativeMethods.WimSetTemporaryPath(handle, temporaryPath);
bool status = WimSetTemporaryPath(handle, temporaryPath);
int rc = Marshal.GetLastWin32Error();
if (status == false)
{
@@ -794,7 +794,7 @@ namespace Disco.ClientBootstrapper.Interop.WIMInterop
{
//Load the image data based on the .wim handle
//
IntPtr hWim = NativeMethods.WimLoadImage(handle, (uint)imageIndex);
IntPtr hWim = WimLoadImage(handle, (uint)imageIndex);
int rc = Marshal.GetLastWin32Error();
if (hWim == IntPtr.Zero)
{
@@ -832,7 +832,7 @@ namespace Disco.ClientBootstrapper.Interop.WIMInterop
IntPtr
CaptureImage(IntPtr handle, string path)
{
IntPtr hImage = NativeMethods.WimCaptureImage(handle, path, 0);
IntPtr hImage = WimCaptureImage(handle, path, 0);
int rc = Marshal.GetLastWin32Error();
if (hImage == IntPtr.Zero)
{
@@ -873,7 +873,7 @@ namespace Disco.ClientBootstrapper.Interop.WIMInterop
int
GetImageCount(IntPtr windowsImageHandle)
{
int count = NativeMethods.WimGetImageCount(windowsImageHandle);
int count = WimGetImageCount(windowsImageHandle);
int rc = Marshal.GetLastWin32Error();
if (count == -1)
{
@@ -971,7 +971,7 @@ namespace Disco.ClientBootstrapper.Interop.WIMInterop
try
{
status = NativeMethods.WimMountImage(mountPath,
status = WimMountImage(mountPath,
windowsImageFileName,
(uint)imageIndex,
temporaryPath);
@@ -1022,7 +1022,7 @@ namespace Disco.ClientBootstrapper.Interop.WIMInterop
//
//Call WimApplyImage always with the Index flag for performance reasons.
//
bool status = NativeMethods.WimApplyImage(imageHandle, applicationPath, NativeMethods.WIM_FLAG_INDEX);
bool status = WimApplyImage(imageHandle, applicationPath, WIM_FLAG_INDEX);
int rc = Marshal.GetLastWin32Error();
if (status == false)
{
@@ -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 _);
status = WimGetImageInformation(handle, out info, out _);
int rc = Marshal.GetLastWin32Error();
if (status == false)
@@ -1112,7 +1112,7 @@ namespace Disco.ClientBootstrapper.Interop.WIMInterop
IntPtr xmlBuffer = Marshal.AllocHGlobal(byteBufferSize);
Marshal.Copy(byteBuffer, 0, xmlBuffer, byteBufferSize);
bool status = NativeMethods.WimSetImageInformation(handle, xmlBuffer, (uint)byteBufferSize);
bool status = WimSetImageInformation(handle, xmlBuffer, (uint)byteBufferSize);
int rc = Marshal.GetLastWin32Error();
if (status == false)
{
@@ -1153,7 +1153,7 @@ namespace Disco.ClientBootstrapper.Interop.WIMInterop
try
{
status = NativeMethods.WimUnmountImage(mountPath, wimdowsImageFileName, (uint)imageIndex, commitChanges);
status = WimUnmountImage(mountPath, wimdowsImageFileName, (uint)imageIndex, commitChanges);
rc = Marshal.GetLastWin32Error();
}
catch (System.StackOverflowException ex)
@@ -1221,7 +1221,7 @@ namespace Disco.ClientBootstrapper.Interop.WIMInterop
void
RegisterCallback(MessageCallback callback)
{
NativeMethods.WimRegisterMessageCallback(IntPtr.Zero, callback, IntPtr.Zero);
WimRegisterMessageCallback(IntPtr.Zero, callback, IntPtr.Zero);
int rc = Marshal.GetLastWin32Error();
if (rc != 0)
{
@@ -1253,7 +1253,7 @@ namespace Disco.ClientBootstrapper.Interop.WIMInterop
void
UnregisterMessageCallback(MessageCallback registeredCallback)
{
bool status = NativeMethods.WimUnregisterMessageCallback(IntPtr.Zero, registeredCallback);
bool status = WimUnregisterMessageCallback(IntPtr.Zero, registeredCallback);
_ = Marshal.GetLastWin32Error();
if (status != true)
{
+2 -2
View File
@@ -153,11 +153,11 @@ namespace Disco.ClientBootstrapper
{
if (BootstrapperLoop.LoopThread != null)
{
if (BootstrapperLoop.LoopThread.ThreadState == System.Threading.ThreadState.WaitSleepJoin)
if (BootstrapperLoop.LoopThread.ThreadState == ThreadState.WaitSleepJoin)
{
BootstrapperLoop.LoopThread.Interrupt();
}
if (BootstrapperLoop.LoopThread.ThreadState == System.Threading.ThreadState.Running)
if (BootstrapperLoop.LoopThread.ThreadState == ThreadState.Running)
{
BootstrapperLoop.LoopThread.Abort();
}