public bool ChangeLodingIco(bool isShow) { IntPtr ptr = default(IntPtr); try { DiyHelper.Wow64DisableWow64FsRedirection(ref ptr); string text = ""; text = ((!isShow) ? "bcdedit.exe -set {globalsettings} bootuxdisabled on" : "bcdedit.exe -set {globalsettings} bootuxdisabled off"); Console.WriteLine(text); LogoDiy.LogHelper.Info(text); Process process = new Process(); process.StartInfo.FileName = "cmd.exe"; process.StartInfo.UseShellExecute = false; process.StartInfo.RedirectStandardInput = true; process.StartInfo.RedirectStandardOutput = true; process.StartInfo.RedirectStandardError = true; process.StartInfo.CreateNoWindow = true; process.Start(); process.StandardInput.WriteLine(text + "&exit"); process.StandardInput.AutoFlush = true; process.WaitForExit(); process.Close(); return(true); } catch (Exception ex) { LogoDiy.LogHelper.Error(ex); return(false); } finally { DiyHelper.Wow64RevertWow64FsRedirection(ptr); } }
private void GetLogoInfo() { uint format = 0u; byte enable = 0; int logoDIYInfo = DiyHelper.GetLogoDIYInfo(ref enable, ref format, ref defaultHeight, ref defaultWidth); LogoDiy.LogHelper.Info($"ret1 = {logoDIYInfo}; Height = {defaultHeight}; Width = {defaultWidth}"); if (logoDIYInfo != 0) { ChangeSupportingFormat(format); if (defaultHeight < 0 || defaultWidth < 0) { LogoDiy.LogHelper.Info("get height/width error, set default 1920*1080"); DefaultWidth = 1920; DefaultHeight = 1080; } LogoDiy.LogHelper.Info($"get logoinfo -> enable = {enable}; type = {format}; "); bool flag = enable == 0; SetImagePath(flag); CanRecovery = !flag; FunEnable = !flag; UIIsEnable = true; } else { GetBitmapImage(defaultpath); LogoDiy.LogHelper.Info("get logo_info error:"); UIIsEnable = false; FunEnable = false; CanRecovery = false; } }
public void ToRecovery() { try { name = ChangeEFIDisk(mount: true); string text = ""; text = Path.Combine(name + ":\\", "EFI\\Lenovo\\Logo"); DeleteOtherDirectory(text); } catch (Exception ex) { LogoDiy.LogHelper.Error(ex); } finally { ChangeEFIDisk(mount: false); } int num = DiyHelper.SetLogoDIYInfo(0); LogoDiy.LogHelper.Info($"set logoinfo ret = {num}"); if (num == 0) { LogoDiy.LogHelper.Info($"set logoinfo error: ret = {num}"); return; } ShowSuccessText = "*默认设置恢复成功"; ShowSuccessTip = true; FunEnable = false; }
public void SaveLogoClick() { try { Console.WriteLine("SaveLogoClick"); int num = DiyHelper.SetLogoDIYInfo(1); LogoDiy.LogHelper.Info($"set logoinfo ret = {num}"); if (num == 0) { ShowSuccessTip = false; LogoDiy.LogHelper.Info($"set logoinfo error: ret = {num}"); return; } LogoDiy.LogHelper.Info($"set logoinfo success: ret = {num}"); name = ChangeEFIDisk(mount: true); string text = ""; try { string extension = Path.GetExtension(ImagePath1); if (!string.IsNullOrWhiteSpace(fileExtension) && extension != fileExtension) { extension = fileExtension; } text = Path.Combine(name + ":\\", "EFI\\Lenovo\\Logo", $"mylogo_{DefaultWidth}x{DefaultHeight}" + extension); LogoDiy.LogHelper.Info($"path = {text}"); DeleteOtherFile(text); LogoDiy.LogHelper.Info($"source path = {ImagePath1}; dest path = {text}"); File.Copy(ImagePath1, text); } catch (Exception ex) { LogoDiy.LogHelper.Info("copy file error:" + ex.Message); return; } if (DiyHelper.SetLogDIYCRC(text) > 0) { LogoDiy.LogHelper.Info("Set CRC success"); ChangeEFIDisk(mount: false); ShowSuccessText = "*设置成功,请重启电脑查看效果"; ShowSuccessTip = true; } else { LogoDiy.LogHelper.Info("Set CRC ERROR"); ShowSuccessTip = false; } } catch (Exception ex2) { LogoDiy.LogHelper.Error(ex2); ShowSuccessTip = false; } finally { CanRecovery = true; ChangeEFIDisk(mount: false); } }
private void GetShowLodingIco() { IntPtr ptr = default(IntPtr); try { DiyHelper.Wow64DisableWow64FsRedirection(ref ptr); string text = "bcdedit /enum all"; Process process = new Process(); process.StartInfo.FileName = "cmd.exe"; process.StartInfo.UseShellExecute = false; process.StartInfo.RedirectStandardInput = true; process.StartInfo.RedirectStandardOutput = true; process.StartInfo.RedirectStandardError = true; process.StartInfo.CreateNoWindow = true; process.Start(); process.StandardInput.WriteLine(text + "&exit"); process.StandardInput.AutoFlush = true; StreamReader standardOutput = process.StandardOutput; string text2 = standardOutput.ReadLine(); bool flag = false; while (!standardOutput.EndOfStream) { text2 = standardOutput.ReadLine(); if ((text2.Contains("标识符") || text2.Contains("identifier")) && text2.Contains("{globalsettings}")) { flag = true; } if (flag && text2.Contains("bootuxdisabled")) { Console.WriteLine("gobalsettings: " + text2); string text3 = text2.Replace("bootuxdisabled", "").Trim(); IsShowLodingIco = text3.Contains("No"); LogoDiy.LogHelper.Info($"{text2}; 加载系统图标 = {IsShowLodingIco}"); flag = false; } } process.WaitForExit(); process.Close(); } catch (Exception) { } finally { DiyHelper.Wow64RevertWow64FsRedirection(ptr); } }
private bool GetLoadingCircle() { int build = Environment.OSVersion.Version.Build; LogoDiy.LogHelper.Info($"ostype = {build}"); if (build > 14393) { int num = DiyHelper.IsEditionCircle(); LogoDiy.LogHelper.Info($"IsEditionCircle = {num}"); if (num != 0) { return(true); } return(false); } return(false); }