├── .gitignore
├── Examples
├── 2560x1600.jpg
├── 2560x1600.psd
├── BIOSLogo_surface.bmp
└── Credit.txt
├── LogoDiy.sln
├── LogoDiy
├── AIToolAPI.dll
├── App.config
├── DiyHelper.cs
├── EnumDisplayAttribute.cs
├── EnumExtentions.cs
├── Form1.Designer.cs
├── Form1.cs
├── Form1.resx
├── LogHelper.cs
├── LogoDiy.csproj
├── LogoDiyViewModel.cs
├── Program.cs
├── Properties
│ ├── AssemblyInfo.cs
│ ├── Resources.Designer.cs
│ ├── Resources.resx
│ ├── Settings.Designer.cs
│ └── Settings.settings
└── app.manifest
├── README.md
└── README.zh.md
/.gitignore:
--------------------------------------------------------------------------------
1 | ## Ignore Visual Studio temporary files, build results, and
2 | ## files generated by popular Visual Studio add-ons.
3 | ##
4 | ## Get latest from https://github.com/github/gitignore/blob/master/VisualStudio.gitignore
5 |
6 | # User-specific files
7 | *.rsuser
8 | *.suo
9 | *.user
10 | *.userosscache
11 | *.sln.docstates
12 |
13 | # User-specific files (MonoDevelop/Xamarin Studio)
14 | *.userprefs
15 |
16 | # Mono auto generated files
17 | mono_crash.*
18 |
19 | # Build results
20 | [Dd]ebug/
21 | [Dd]ebugPublic/
22 | [Rr]elease/
23 | [Rr]eleases/
24 | x64/
25 | x86/
26 | [Aa][Rr][Mm]/
27 | [Aa][Rr][Mm]64/
28 | bld/
29 | [Bb]in/
30 | [Oo]bj/
31 | [Ll]og/
32 | [Ll]ogs/
33 |
34 | # Visual Studio 2015/2017 cache/options directory
35 | .vs/
36 | # Uncomment if you have tasks that create the project's static files in wwwroot
37 | #wwwroot/
38 |
39 | # Visual Studio 2017 auto generated files
40 | Generated\ Files/
41 |
42 | # MSTest test Results
43 | [Tt]est[Rr]esult*/
44 | [Bb]uild[Ll]og.*
45 |
46 | # NUnit
47 | *.VisualState.xml
48 | TestResult.xml
49 | nunit-*.xml
50 |
51 | # Build Results of an ATL Project
52 | [Dd]ebugPS/
53 | [Rr]eleasePS/
54 | dlldata.c
55 |
56 | # Benchmark Results
57 | BenchmarkDotNet.Artifacts/
58 |
59 | # .NET Core
60 | project.lock.json
61 | project.fragment.lock.json
62 | artifacts/
63 |
64 | # StyleCop
65 | StyleCopReport.xml
66 |
67 | # Files built by Visual Studio
68 | *_i.c
69 | *_p.c
70 | *_h.h
71 | *.ilk
72 | *.meta
73 | *.obj
74 | *.iobj
75 | *.pch
76 | *.pdb
77 | *.ipdb
78 | *.pgc
79 | *.pgd
80 | *.rsp
81 | *.sbr
82 | *.tlb
83 | *.tli
84 | *.tlh
85 | *.tmp
86 | *.tmp_proj
87 | *_wpftmp.csproj
88 | *.log
89 | *.vspscc
90 | *.vssscc
91 | .builds
92 | *.pidb
93 | *.svclog
94 | *.scc
95 |
96 | # Chutzpah Test files
97 | _Chutzpah*
98 |
99 | # Visual C++ cache files
100 | ipch/
101 | *.aps
102 | *.ncb
103 | *.opendb
104 | *.opensdf
105 | *.sdf
106 | *.cachefile
107 | *.VC.db
108 | *.VC.VC.opendb
109 |
110 | # Visual Studio profiler
111 | *.psess
112 | *.vsp
113 | *.vspx
114 | *.sap
115 |
116 | # Visual Studio Trace Files
117 | *.e2e
118 |
119 | # TFS 2012 Local Workspace
120 | $tf/
121 |
122 | # Guidance Automation Toolkit
123 | *.gpState
124 |
125 | # ReSharper is a .NET coding add-in
126 | _ReSharper*/
127 | *.[Rr]e[Ss]harper
128 | *.DotSettings.user
129 |
130 | # TeamCity is a build add-in
131 | _TeamCity*
132 |
133 | # DotCover is a Code Coverage Tool
134 | *.dotCover
135 |
136 | # AxoCover is a Code Coverage Tool
137 | .axoCover/*
138 | !.axoCover/settings.json
139 |
140 | # Visual Studio code coverage results
141 | *.coverage
142 | *.coveragexml
143 |
144 | # NCrunch
145 | _NCrunch_*
146 | .*crunch*.local.xml
147 | nCrunchTemp_*
148 |
149 | # MightyMoose
150 | *.mm.*
151 | AutoTest.Net/
152 |
153 | # Web workbench (sass)
154 | .sass-cache/
155 |
156 | # Installshield output folder
157 | [Ee]xpress/
158 |
159 | # DocProject is a documentation generator add-in
160 | DocProject/buildhelp/
161 | DocProject/Help/*.HxT
162 | DocProject/Help/*.HxC
163 | DocProject/Help/*.hhc
164 | DocProject/Help/*.hhk
165 | DocProject/Help/*.hhp
166 | DocProject/Help/Html2
167 | DocProject/Help/html
168 |
169 | # Click-Once directory
170 | publish/
171 |
172 | # Publish Web Output
173 | *.[Pp]ublish.xml
174 | *.azurePubxml
175 | # Note: Comment the next line if you want to checkin your web deploy settings,
176 | # but database connection strings (with potential passwords) will be unencrypted
177 | *.pubxml
178 | *.publishproj
179 |
180 | # Microsoft Azure Web App publish settings. Comment the next line if you want to
181 | # checkin your Azure Web App publish settings, but sensitive information contained
182 | # in these scripts will be unencrypted
183 | PublishScripts/
184 |
185 | # NuGet Packages
186 | *.nupkg
187 | # NuGet Symbol Packages
188 | *.snupkg
189 | # The packages folder can be ignored because of Package Restore
190 | **/[Pp]ackages/*
191 | # except build/, which is used as an MSBuild target.
192 | !**/[Pp]ackages/build/
193 | # Uncomment if necessary however generally it will be regenerated when needed
194 | #!**/[Pp]ackages/repositories.config
195 | # NuGet v3's project.json files produces more ignorable files
196 | *.nuget.props
197 | *.nuget.targets
198 |
199 | # Microsoft Azure Build Output
200 | csx/
201 | *.build.csdef
202 |
203 | # Microsoft Azure Emulator
204 | ecf/
205 | rcf/
206 |
207 | # Windows Store app package directories and files
208 | AppPackages/
209 | BundleArtifacts/
210 | Package.StoreAssociation.xml
211 | _pkginfo.txt
212 | *.appx
213 | *.appxbundle
214 | *.appxupload
215 |
216 | # Visual Studio cache files
217 | # files ending in .cache can be ignored
218 | *.[Cc]ache
219 | # but keep track of directories ending in .cache
220 | !?*.[Cc]ache/
221 |
222 | # Others
223 | ClientBin/
224 | ~$*
225 | *~
226 | *.dbmdl
227 | *.dbproj.schemaview
228 | *.jfm
229 | *.pfx
230 | *.publishsettings
231 | orleans.codegen.cs
232 |
233 | # Including strong name files can present a security risk
234 | # (https://github.com/github/gitignore/pull/2483#issue-259490424)
235 | #*.snk
236 |
237 | # Since there are multiple workflows, uncomment next line to ignore bower_components
238 | # (https://github.com/github/gitignore/pull/1529#issuecomment-104372622)
239 | #bower_components/
240 |
241 | # RIA/Silverlight projects
242 | Generated_Code/
243 |
244 | # Backup & report files from converting an old project file
245 | # to a newer Visual Studio version. Backup files are not needed,
246 | # because we have git ;-)
247 | _UpgradeReport_Files/
248 | Backup*/
249 | UpgradeLog*.XML
250 | UpgradeLog*.htm
251 | ServiceFabricBackup/
252 | *.rptproj.bak
253 |
254 | # SQL Server files
255 | *.mdf
256 | *.ldf
257 | *.ndf
258 |
259 | # Business Intelligence projects
260 | *.rdl.data
261 | *.bim.layout
262 | *.bim_*.settings
263 | *.rptproj.rsuser
264 | *- [Bb]ackup.rdl
265 | *- [Bb]ackup ([0-9]).rdl
266 | *- [Bb]ackup ([0-9][0-9]).rdl
267 |
268 | # Microsoft Fakes
269 | FakesAssemblies/
270 |
271 | # GhostDoc plugin setting file
272 | *.GhostDoc.xml
273 |
274 | # Node.js Tools for Visual Studio
275 | .ntvs_analysis.dat
276 | node_modules/
277 |
278 | # Visual Studio 6 build log
279 | *.plg
280 |
281 | # Visual Studio 6 workspace options file
282 | *.opt
283 |
284 | # Visual Studio 6 auto-generated workspace file (contains which files were open etc.)
285 | *.vbw
286 |
287 | # Visual Studio LightSwitch build output
288 | **/*.HTMLClient/GeneratedArtifacts
289 | **/*.DesktopClient/GeneratedArtifacts
290 | **/*.DesktopClient/ModelManifest.xml
291 | **/*.Server/GeneratedArtifacts
292 | **/*.Server/ModelManifest.xml
293 | _Pvt_Extensions
294 |
295 | # Paket dependency manager
296 | .paket/paket.exe
297 | paket-files/
298 |
299 | # FAKE - F# Make
300 | .fake/
301 |
302 | # CodeRush personal settings
303 | .cr/personal
304 |
305 | # Python Tools for Visual Studio (PTVS)
306 | __pycache__/
307 | *.pyc
308 |
309 | # Cake - Uncomment if you are using it
310 | # tools/**
311 | # !tools/packages.config
312 |
313 | # Tabs Studio
314 | *.tss
315 |
316 | # Telerik's JustMock configuration file
317 | *.jmconfig
318 |
319 | # BizTalk build output
320 | *.btp.cs
321 | *.btm.cs
322 | *.odx.cs
323 | *.xsd.cs
324 |
325 | # OpenCover UI analysis results
326 | OpenCover/
327 |
328 | # Azure Stream Analytics local run output
329 | ASALocalRun/
330 |
331 | # MSBuild Binary and Structured Log
332 | *.binlog
333 |
334 | # NVidia Nsight GPU debugger configuration file
335 | *.nvuser
336 |
337 | # MFractors (Xamarin productivity tool) working folder
338 | .mfractor/
339 |
340 | # Local History for Visual Studio
341 | .localhistory/
342 |
343 | # BeatPulse healthcheck temp database
344 | healthchecksdb
345 |
346 | # Backup folder for Package Reference Convert tool in Visual Studio 2017
347 | MigrationBackup/
348 |
349 | # Ionide (cross platform F# VS Code tools) working folder
350 | .ionide/
351 |
--------------------------------------------------------------------------------
/Examples/2560x1600.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Coxxs/LogoDiy/e80d6cff1d2ea9812b284c7b5e9f5f6e664ec48e/Examples/2560x1600.jpg
--------------------------------------------------------------------------------
/Examples/2560x1600.psd:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Coxxs/LogoDiy/e80d6cff1d2ea9812b284c7b5e9f5f6e664ec48e/Examples/2560x1600.psd
--------------------------------------------------------------------------------
/Examples/BIOSLogo_surface.bmp:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Coxxs/LogoDiy/e80d6cff1d2ea9812b284c7b5e9f5f6e664ec48e/Examples/BIOSLogo_surface.bmp
--------------------------------------------------------------------------------
/Examples/Credit.txt:
--------------------------------------------------------------------------------
1 | https://www.deviantart.com/ncoll36/art/Ayase-Aragaki-Oreimo-614404759
--------------------------------------------------------------------------------
/LogoDiy.sln:
--------------------------------------------------------------------------------
1 |
2 | Microsoft Visual Studio Solution File, Format Version 12.00
3 | # Visual Studio Version 16
4 | VisualStudioVersion = 16.0.30621.155
5 | MinimumVisualStudioVersion = 10.0.40219.1
6 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "LogoDiy", "LogoDiy\LogoDiy.csproj", "{3DF19333-D9AA-4CFD-8B0F-21DF0916508C}"
7 | EndProject
8 | Global
9 | GlobalSection(SolutionConfigurationPlatforms) = preSolution
10 | Debug|Any CPU = Debug|Any CPU
11 | Release|Any CPU = Release|Any CPU
12 | EndGlobalSection
13 | GlobalSection(ProjectConfigurationPlatforms) = postSolution
14 | {3DF19333-D9AA-4CFD-8B0F-21DF0916508C}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
15 | {3DF19333-D9AA-4CFD-8B0F-21DF0916508C}.Debug|Any CPU.Build.0 = Debug|Any CPU
16 | {3DF19333-D9AA-4CFD-8B0F-21DF0916508C}.Release|Any CPU.ActiveCfg = Release|Any CPU
17 | {3DF19333-D9AA-4CFD-8B0F-21DF0916508C}.Release|Any CPU.Build.0 = Release|Any CPU
18 | EndGlobalSection
19 | GlobalSection(SolutionProperties) = preSolution
20 | HideSolutionNode = FALSE
21 | EndGlobalSection
22 | GlobalSection(ExtensibilityGlobals) = postSolution
23 | SolutionGuid = {6278FE5B-0A18-4BFF-B6BF-9F6146BDAB45}
24 | EndGlobalSection
25 | EndGlobal
26 |
--------------------------------------------------------------------------------
/LogoDiy/AIToolAPI.dll:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Coxxs/LogoDiy/e80d6cff1d2ea9812b284c7b5e9f5f6e664ec48e/LogoDiy/AIToolAPI.dll
--------------------------------------------------------------------------------
/LogoDiy/App.config:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
--------------------------------------------------------------------------------
/LogoDiy/DiyHelper.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Runtime.InteropServices;
3 |
4 | namespace LogoDiy
5 | {
6 | public class DiyHelper
7 | {
8 | [DllImport("User32.dll")]
9 | public static extern IntPtr FindWindow(string lpClassName, string lpWindowName);
10 |
11 | [DllImport("User32.dll")]
12 | public static extern IntPtr SendMessage(int hWnd, int msg, IntPtr wParam, IntPtr lParam);
13 |
14 | [DllImport("AIToolAPI.dll", CallingConvention = CallingConvention.Cdecl)]
15 | public static extern int GetLogoDIYInfo(ref byte enable, ref uint format, ref int height, ref int width);
16 |
17 | [DllImport("AIToolAPI.dll", CallingConvention = CallingConvention.Cdecl)]
18 | public static extern int SetLogoDIYInfo(byte enable);
19 |
20 | [DllImport("AIToolAPI.dll", CallingConvention = CallingConvention.Cdecl)]
21 | public static extern int SetLogDIYCRC(string filepath);
22 |
23 | [DllImport("AIToolAPI.dll", CallingConvention = CallingConvention.Cdecl)]
24 | public static extern int IsEditionCircle();
25 |
26 | [DllImport("Kernel32.dll", CharSet = CharSet.Auto, SetLastError = true)]
27 | public static extern bool Wow64DisableWow64FsRedirection(ref IntPtr ptr);
28 |
29 | [DllImport("Kernel32.dll", CharSet = CharSet.Auto, SetLastError = true)]
30 | public static extern bool Wow64RevertWow64FsRedirection(IntPtr ptr);
31 | }
32 | }
33 |
--------------------------------------------------------------------------------
/LogoDiy/EnumDisplayAttribute.cs:
--------------------------------------------------------------------------------
1 | using System;
2 |
3 | [AttributeUsage(AttributeTargets.Field)]
4 | public class EnumDisplayAttribute : Attribute
5 | {
6 | public string Display
7 | {
8 | get;
9 | private set;
10 | }
11 |
12 | public EnumDisplayAttribute(string displayStr)
13 | {
14 | Display = displayStr;
15 | }
16 | }
17 |
--------------------------------------------------------------------------------
/LogoDiy/EnumExtentions.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Linq;
3 |
4 | public static class EnumExtentions
5 | {
6 | public static string Display(this Enum t)
7 | {
8 | Type type = t.GetType();
9 | string name = Enum.GetName(type, t);
10 | EnumDisplayAttribute enumDisplayAttribute = type.GetField(name).GetCustomAttributes(inherit: false).FirstOrDefault((object p) => p.GetType().Equals(typeof(EnumDisplayAttribute))) as EnumDisplayAttribute;
11 | if (enumDisplayAttribute != null)
12 | {
13 | return enumDisplayAttribute.Display;
14 | }
15 | return name;
16 | }
17 | }
18 |
--------------------------------------------------------------------------------
/LogoDiy/Form1.Designer.cs:
--------------------------------------------------------------------------------
1 | namespace LogoDiy
2 | {
3 | partial class Form1
4 | {
5 | ///
6 | /// Required designer variable.
7 | ///
8 | private System.ComponentModel.IContainer components = null;
9 |
10 | ///
11 | /// Clean up any resources being used.
12 | ///
13 | /// true if managed resources should be disposed; otherwise, false.
14 | protected override void Dispose(bool disposing)
15 | {
16 | if (disposing && (components != null))
17 | {
18 | components.Dispose();
19 | }
20 | base.Dispose(disposing);
21 | }
22 |
23 | #region Windows Form Designer generated code
24 |
25 | ///
26 | /// Required method for Designer support - do not modify
27 | /// the contents of this method with the code editor.
28 | ///
29 | private void InitializeComponent()
30 | {
31 | this.SelectImage = new System.Windows.Forms.Button();
32 | this.Apply = new System.Windows.Forms.Button();
33 | this.Recovery = new System.Windows.Forms.Button();
34 | this.checkBox1 = new System.Windows.Forms.CheckBox();
35 | this.label1 = new System.Windows.Forms.Label();
36 | this.label2 = new System.Windows.Forms.Label();
37 | this.SuspendLayout();
38 | //
39 | // SelectImage
40 | //
41 | this.SelectImage.Location = new System.Drawing.Point(24, 22);
42 | this.SelectImage.Name = "SelectImage";
43 | this.SelectImage.Size = new System.Drawing.Size(199, 69);
44 | this.SelectImage.TabIndex = 0;
45 | this.SelectImage.Text = "Select Image";
46 | this.SelectImage.UseVisualStyleBackColor = true;
47 | this.SelectImage.Click += new System.EventHandler(this.button1_Click);
48 | //
49 | // Apply
50 | //
51 | this.Apply.Enabled = false;
52 | this.Apply.Location = new System.Drawing.Point(244, 22);
53 | this.Apply.Name = "Apply";
54 | this.Apply.Size = new System.Drawing.Size(199, 69);
55 | this.Apply.TabIndex = 1;
56 | this.Apply.Text = "Apply";
57 | this.Apply.UseVisualStyleBackColor = true;
58 | this.Apply.Click += new System.EventHandler(this.button2_Click);
59 | //
60 | // Recovery
61 | //
62 | this.Recovery.Location = new System.Drawing.Point(771, 22);
63 | this.Recovery.Name = "Recovery";
64 | this.Recovery.Size = new System.Drawing.Size(199, 69);
65 | this.Recovery.TabIndex = 2;
66 | this.Recovery.Text = "Reset to default";
67 | this.Recovery.UseVisualStyleBackColor = true;
68 | this.Recovery.Click += new System.EventHandler(this.button1_Click_1);
69 | //
70 | // checkBox1
71 | //
72 | this.checkBox1.AutoSize = true;
73 | this.checkBox1.Enabled = false;
74 | this.checkBox1.Location = new System.Drawing.Point(495, 43);
75 | this.checkBox1.Name = "checkBox1";
76 | this.checkBox1.Size = new System.Drawing.Size(226, 29);
77 | this.checkBox1.TabIndex = 3;
78 | this.checkBox1.Text = "Show Loading Icon";
79 | this.checkBox1.UseVisualStyleBackColor = true;
80 | this.checkBox1.CheckedChanged += new System.EventHandler(this.checkBox1_CheckedChanged);
81 | //
82 | // label1
83 | //
84 | this.label1.AutoSize = true;
85 | this.label1.ForeColor = System.Drawing.Color.DarkRed;
86 | this.label1.Location = new System.Drawing.Point(763, 117);
87 | this.label1.Name = "label1";
88 | this.label1.Size = new System.Drawing.Size(207, 25);
89 | this.label1.TabIndex = 4;
90 | this.label1.Text = "Use at your own risk";
91 | //
92 | // label2
93 | //
94 | this.label2.AutoSize = true;
95 | this.label2.ForeColor = System.Drawing.Color.DarkRed;
96 | this.label2.Location = new System.Drawing.Point(19, 117);
97 | this.label2.Name = "label2";
98 | this.label2.Size = new System.Drawing.Size(156, 25);
99 | this.label2.TabIndex = 5;
100 | this.label2.Text = "Format: , Max: ";
101 | //
102 | // Form1
103 | //
104 | this.AutoScaleDimensions = new System.Drawing.SizeF(12F, 25F);
105 | this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
106 | this.ClientSize = new System.Drawing.Size(997, 169);
107 | this.Controls.Add(this.label2);
108 | this.Controls.Add(this.label1);
109 | this.Controls.Add(this.checkBox1);
110 | this.Controls.Add(this.Recovery);
111 | this.Controls.Add(this.Apply);
112 | this.Controls.Add(this.SelectImage);
113 | this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedSingle;
114 | this.MaximizeBox = false;
115 | this.Name = "Form1";
116 | this.Text = "LogoDiy";
117 | this.Load += new System.EventHandler(this.Form1_Load);
118 | this.ResumeLayout(false);
119 | this.PerformLayout();
120 |
121 | }
122 |
123 | #endregion
124 |
125 | private System.Windows.Forms.Button SelectImage;
126 | private System.Windows.Forms.Button Apply;
127 | private System.Windows.Forms.Button Recovery;
128 | private System.Windows.Forms.CheckBox checkBox1;
129 | private System.Windows.Forms.Label label1;
130 | private System.Windows.Forms.Label label2;
131 | }
132 | }
133 |
134 |
--------------------------------------------------------------------------------
/LogoDiy/Form1.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.ComponentModel;
4 | using System.Data;
5 | using System.Drawing;
6 | using System.Linq;
7 | using System.Text;
8 | using System.Threading.Tasks;
9 | using System.Windows.Forms;
10 |
11 | namespace LogoDiy
12 | {
13 | public partial class Form1 : Form
14 | {
15 | public Form1()
16 | {
17 | InitializeComponent();
18 | }
19 |
20 | private void Form1_Load(object sender, EventArgs e)
21 | {
22 | LogoDiyViewModel.Instance.CreateViewData();
23 | if (!LogoDiyViewModel.Instance.UIIsEnable)
24 | {
25 | MessageBox.Show("Unsupported BIOS!\nThis application only supports Lenovo computers with newer BIOS versions.");
26 | Application.Exit();
27 | return;
28 | }
29 | if (LogoDiyViewModel.Instance.VidibalyLodingIco)
30 | {
31 | checkBox1.Checked = LogoDiyViewModel.Instance.IsShowLodingIco;
32 | checkBox1.Enabled = true;
33 | }
34 | label2.Text = "Format: " + LogoDiyViewModel.Instance.Filter + " / Max: " + LogoDiyViewModel.Instance.DefaultWidth.ToString() + "x" + LogoDiyViewModel.Instance.DefaultHeight.ToString();
35 | }
36 |
37 | private void button1_Click(object sender, EventArgs e)
38 | {
39 | LogoDiyViewModel.Instance.SelectedImageClick();
40 | showTip();
41 | }
42 |
43 | private void button2_Click(object sender, EventArgs e)
44 | {
45 | LogoDiyViewModel.Instance.SaveLogoClick();
46 | showTip();
47 | }
48 |
49 | private void showTip()
50 | {
51 | if (LogoDiyViewModel.Instance.ShowWarning)
52 | {
53 | MessageBox.Show(LogoDiyViewModel.Instance.ShowWarnInfo);
54 | LogoDiyViewModel.Instance.ShowWarning = false;
55 | }
56 | if (LogoDiyViewModel.Instance.ShowSuccessTip)
57 | {
58 | MessageBox.Show(LogoDiyViewModel.Instance.ShowSuccessText);
59 | LogoDiyViewModel.Instance.ShowSuccessTip = false;
60 | }
61 | Apply.Enabled = LogoDiyViewModel.Instance.FunEnable;
62 | Recovery.Enabled = LogoDiyViewModel.Instance.CanRecovery;
63 | }
64 |
65 | private void button1_Click_1(object sender, EventArgs e)
66 | {
67 | LogoDiyViewModel.Instance.ToRecovery();
68 | showTip();
69 | }
70 |
71 | private void checkBox1_CheckedChanged(object sender, EventArgs e)
72 | {
73 | if (!checkBox1.Enabled)
74 | {
75 | return;
76 | }
77 | if (LogoDiyViewModel.Instance.ChangeLodingIco(checkBox1.Checked))
78 | {
79 | MessageBox.Show("Done!");
80 | } else
81 | {
82 | MessageBox.Show("Failed!");
83 | }
84 | }
85 | }
86 | }
87 |
--------------------------------------------------------------------------------
/LogoDiy/Form1.resx:
--------------------------------------------------------------------------------
1 |
2 |
3 |
62 |
63 |
64 |
65 |
66 |
67 |
68 |
69 |
70 |
71 |
72 |
73 |
74 |
75 |
76 |
77 |
78 |
79 |
80 |
81 |
82 |
83 |
84 |
85 |
86 |
87 |
88 |
89 |
90 |
91 |
92 |
93 |
94 |
95 |
96 |
97 |
98 |
99 |
100 |
101 |
102 |
103 |
104 |
105 |
106 |
107 |
108 |
109 | text/microsoft-resx
110 |
111 |
112 | 2.0
113 |
114 |
115 | System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
116 |
117 |
118 | System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
119 |
120 |
--------------------------------------------------------------------------------
/LogoDiy/LogHelper.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 | using System.Threading.Tasks;
6 | using System.Diagnostics;
7 |
8 | namespace LogoDiy
9 | {
10 | class LogHelper
11 | {
12 | public static void Info(string info)
13 | {
14 | Console.WriteLine(info);
15 | Debug.WriteLine(info);
16 | }
17 |
18 | public static void Error(string info)
19 | {
20 | Info(info);
21 | }
22 |
23 | public static void Error(Exception ex)
24 | {
25 | Info(ex.ToString());
26 | }
27 | }
28 | }
29 |
--------------------------------------------------------------------------------
/LogoDiy/LogoDiy.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | Debug
6 | AnyCPU
7 | {3DF19333-D9AA-4CFD-8B0F-21DF0916508C}
8 | WinExe
9 | LogoDIY
10 | LogoDIY
11 | v4.7.2
12 | 512
13 | true
14 | true
15 |
16 |
17 | AnyCPU
18 | true
19 | full
20 | false
21 | bin\Debug\
22 | DEBUG;TRACE
23 | prompt
24 | 4
25 |
26 |
27 | AnyCPU
28 | pdbonly
29 | true
30 | bin\Release\
31 | TRACE
32 | prompt
33 | 4
34 |
35 |
36 | app.manifest
37 |
38 |
39 |
40 |
41 |
42 |
43 |
44 |
45 |
46 |
47 |
48 |
49 |
50 |
51 |
52 |
53 |
54 |
55 |
56 |
57 |
58 |
59 |
60 |
61 | Form
62 |
63 |
64 | Form1.cs
65 |
66 |
67 |
68 |
69 |
70 | Form1.cs
71 |
72 |
73 | ResXFileCodeGenerator
74 | Resources.Designer.cs
75 | Designer
76 |
77 |
78 | True
79 | Resources.resx
80 | True
81 |
82 |
83 |
84 | SettingsSingleFileGenerator
85 | Settings.Designer.cs
86 |
87 |
88 | True
89 | Settings.settings
90 | True
91 |
92 |
93 |
94 |
95 |
96 |
97 |
98 | Always
99 |
100 |
101 |
102 |
--------------------------------------------------------------------------------
/LogoDiy/LogoDiyViewModel.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Diagnostics;
3 | using System.Drawing;
4 | using System.IO;
5 | using System.Linq;
6 | using System.Text;
7 | using System.Windows.Input;
8 | using System.Windows.Media.Imaging;
9 | using System.Windows.Forms;
10 |
11 | namespace LogoDiy
12 | {
13 | public class LogoDiyViewModel
14 | {
15 | public enum FileExtension
16 | {
17 | [EnumDisplay(".jpg")]
18 | JPG = 255216,
19 | [EnumDisplay(".gif")]
20 | GIF = 7173,
21 | [EnumDisplay(".png")]
22 | PNG = 13780,
23 | [EnumDisplay(".bmp")]
24 | BMP = 19778,
25 | [EnumDisplay(".bmp")]
26 | BMP2 = 6677,
27 | [EnumDisplay(".jpeg")]
28 | JPEG = 65496
29 | }
30 |
31 | private enum ButtonStyle
32 | {
33 | JPG = 1,
34 | TGA = 2,
35 | PCX = 4,
36 | GIF = 8,
37 | BMP = 0x10,
38 | PNG = 0x20
39 | }
40 |
41 | private static LogoDiyViewModel _instance;
42 |
43 | private bool _IsShowLodingIco = true;
44 |
45 | private bool vidibalyLodingIco;
46 |
47 | private string _SupportingFormat = "jpg、jepg、bmp";
48 |
49 | private double _ImageHeight = 140.0;
50 |
51 | private double _ImageWidth = 224.0;
52 |
53 | private bool _ShowWarning;
54 |
55 | private string _ShowWarnInfo;
56 |
57 | private bool _ShowSuccessTip;
58 |
59 | private string showSuccessText = "";
60 |
61 | private BitmapImage imageSource;
62 |
63 | private bool _UIIsEnable = true;
64 |
65 | private bool funEnable = true;
66 |
67 | private long diskFreeSpace = 54525952L;
68 |
69 | private bool canRecovery;
70 |
71 | private string name;
72 |
73 | private int defaultHeight = 1080;
74 |
75 | private int defaultWidth = 1920;
76 |
77 | private string imagePath1;
78 |
79 | private string defaultpath = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "Images/pc.png");
80 |
81 | private string fileExtension = "";
82 |
83 | private string filter1 = "*.png,*.jpg,*.bmp";
84 |
85 | private string filter2 = "*.png;*.jpg;*.bmp";
86 |
87 | public static LogoDiyViewModel Instance
88 | {
89 | get
90 | {
91 | if (_instance == null)
92 | {
93 | _instance = new LogoDiyViewModel();
94 | }
95 | return _instance;
96 | }
97 | }
98 |
99 | public bool IsShowLodingIco
100 | {
101 | get
102 | {
103 | return _IsShowLodingIco;
104 | }
105 | set
106 | {
107 | _IsShowLodingIco = value;
108 | // RaisePropertyChanged(() => IsShowLodingIco);
109 | }
110 | }
111 |
112 | public bool VidibalyLodingIco
113 | {
114 | get
115 | {
116 | return vidibalyLodingIco;
117 | }
118 | set
119 | {
120 | vidibalyLodingIco = value;
121 | // RaisePropertyChanged(() => VidibalyLodingIco);
122 | }
123 | }
124 |
125 | public string Filter
126 | {
127 | get
128 | {
129 | return filter1;
130 | }
131 | }
132 |
133 | public string SupportingFormat
134 | {
135 | get
136 | {
137 | return _SupportingFormat;
138 | }
139 | set
140 | {
141 | _SupportingFormat = value;
142 | // RaisePropertyChanged(() => SupportingFormat);
143 | }
144 | }
145 |
146 | public double ImageHeight
147 | {
148 | get
149 | {
150 | return _ImageHeight;
151 | }
152 | set
153 | {
154 | _ImageHeight = value;
155 | // RaisePropertyChanged(() => ImageHeight);
156 | }
157 | }
158 |
159 | public double ImageWidth
160 | {
161 | get
162 | {
163 | return _ImageWidth;
164 | }
165 | set
166 | {
167 | _ImageWidth = value;
168 | // RaisePropertyChanged(() => ImageWidth);
169 | }
170 | }
171 |
172 | public bool ShowWarning
173 | {
174 | get
175 | {
176 | return _ShowWarning;
177 | }
178 | set
179 | {
180 | _ShowWarning = value;
181 | // RaisePropertyChanged(() => ShowWarning);
182 | }
183 | }
184 |
185 | public string ShowWarnInfo
186 | {
187 | get
188 | {
189 | return _ShowWarnInfo;
190 | }
191 | set
192 | {
193 | _ShowWarnInfo = value;
194 | // RaisePropertyChanged(() => ShowWarnInfo);
195 | }
196 | }
197 |
198 | public bool ShowSuccessTip
199 | {
200 | get
201 | {
202 | return _ShowSuccessTip;
203 | }
204 | set
205 | {
206 | _ShowSuccessTip = value;
207 | // RaisePropertyChanged(() => ShowSuccessTip);
208 | }
209 | }
210 |
211 | public string ShowSuccessText
212 | {
213 | get
214 | {
215 | return showSuccessText;
216 | }
217 | set
218 | {
219 | showSuccessText = value;
220 | // RaisePropertyChanged(() => ShowSuccessText);
221 | }
222 | }
223 |
224 | public BitmapImage ImageSource
225 | {
226 | get
227 | {
228 | return imageSource;
229 | }
230 | set
231 | {
232 | imageSource = value;
233 | // RaisePropertyChanged(() => ImageSource);
234 | }
235 | }
236 |
237 | public bool UIIsEnable
238 | {
239 | get
240 | {
241 | return _UIIsEnable;
242 | }
243 | set
244 | {
245 | _UIIsEnable = value;
246 | // RaisePropertyChanged(() => UIIsEnable);
247 | }
248 | }
249 |
250 | public bool FunEnable
251 | {
252 | get
253 | {
254 | return funEnable;
255 | }
256 | set
257 | {
258 | funEnable = value;
259 | // RaisePropertyChanged(() => FunEnable);
260 | }
261 | }
262 |
263 | public long DiskFreeSpace => diskFreeSpace;
264 |
265 | public bool CanRecovery
266 | {
267 | get
268 | {
269 | return canRecovery;
270 | }
271 | set
272 | {
273 | canRecovery = value;
274 | // RaisePropertyChanged(() => CanRecovery);
275 | }
276 | }
277 |
278 | public int DefaultHeight
279 | {
280 | get
281 | {
282 | return defaultHeight;
283 | }
284 | set
285 | {
286 | value = defaultHeight;
287 | // RaisePropertyChanged(() => DefaultHeight);
288 | }
289 | }
290 |
291 | public int DefaultWidth
292 | {
293 | get
294 | {
295 | return defaultWidth;
296 | }
297 | set
298 | {
299 | defaultWidth = value;
300 | // RaisePropertyChanged(() => DefaultWidth);
301 | }
302 | }
303 |
304 | public string ImagePath1
305 | {
306 | get
307 | {
308 | return imagePath1;
309 | }
310 | set
311 | {
312 | imagePath1 = value;
313 | // RaisePropertyChanged(() => ImagePath1);
314 | }
315 | }
316 |
317 | private LogoDiyViewModel()
318 | {
319 | }
320 |
321 | public void CreateViewData()
322 | {
323 | ImageHeight = 140.0;
324 | ImageWidth = 224.0;
325 | ShowSuccessTip = false;
326 | ShowWarning = false;
327 | GetLogoInfo();
328 | VidibalyLodingIco = GetLoadingCircle();
329 | if (VidibalyLodingIco)
330 | {
331 | GetShowLodingIco();
332 | }
333 | }
334 |
335 | private bool GetLoadingCircle()
336 | {
337 | int build = Environment.OSVersion.Version.Build;
338 | LogoDiy.LogHelper.Info($"ostype = {build}");
339 | if (build > 14393)
340 | {
341 | int num = DiyHelper.IsEditionCircle();
342 | LogoDiy.LogHelper.Info($"IsEditionCircle = {num}");
343 | if (num != 0)
344 | {
345 | return true;
346 | }
347 | return false;
348 | }
349 | return false;
350 | }
351 |
352 | private void GetShowLodingIco()
353 | {
354 | IntPtr ptr = default(IntPtr);
355 | try
356 | {
357 | DiyHelper.Wow64DisableWow64FsRedirection(ref ptr);
358 | string text = "bcdedit /enum all";
359 | Process process = new Process();
360 | process.StartInfo.FileName = "cmd.exe";
361 | process.StartInfo.UseShellExecute = false;
362 | process.StartInfo.RedirectStandardInput = true;
363 | process.StartInfo.RedirectStandardOutput = true;
364 | process.StartInfo.RedirectStandardError = true;
365 | process.StartInfo.CreateNoWindow = true;
366 | process.Start();
367 | process.StandardInput.WriteLine(text + "&exit");
368 | process.StandardInput.AutoFlush = true;
369 | StreamReader standardOutput = process.StandardOutput;
370 | string text2 = standardOutput.ReadLine();
371 | bool flag = false;
372 | while (!standardOutput.EndOfStream)
373 | {
374 | text2 = standardOutput.ReadLine();
375 | if ((text2.Contains("标识符") || text2.Contains("identifier")) && text2.Contains("{globalsettings}"))
376 | {
377 | flag = true;
378 | }
379 | if (flag && text2.Contains("bootuxdisabled"))
380 | {
381 | Console.WriteLine("gobalsettings: " + text2);
382 | string text3 = text2.Replace("bootuxdisabled", "").Trim();
383 | IsShowLodingIco = text3.Contains("No");
384 | LogoDiy.LogHelper.Info($"{text2}; 載入系統圖示 = {IsShowLodingIco}");
385 | flag = false;
386 | }
387 | }
388 | process.WaitForExit();
389 | process.Close();
390 | }
391 | catch (Exception)
392 | {
393 | }
394 | finally
395 | {
396 | DiyHelper.Wow64RevertWow64FsRedirection(ptr);
397 | }
398 | }
399 |
400 | private long GetHardDiskFreeSpace(string str_HardDiskName)
401 | {
402 | try
403 | {
404 | str_HardDiskName += ":\\";
405 | DriveInfo[] drives = DriveInfo.GetDrives();
406 | foreach (DriveInfo driveInfo in drives)
407 | {
408 | Console.WriteLine($"{driveInfo.Name}");
409 | if (driveInfo.Name == str_HardDiskName)
410 | {
411 | return driveInfo.TotalFreeSpace;
412 | }
413 | }
414 | }
415 | catch (Exception)
416 | {
417 | }
418 | return 0L;
419 | }
420 |
421 | private void GetDiskFree(long freeM)
422 | {
423 | try
424 | {
425 | long num = 33554432L;
426 | diskFreeSpace = freeM - num;
427 | LogoDiy.LogHelper.Info($"diskFreeSpace = {diskFreeSpace}; freeTotal = {freeM}; _32M = {num} ");
428 | }
429 | catch (Exception ex)
430 | {
431 | LogoDiy.LogHelper.Error(ex);
432 | }
433 | }
434 |
435 | private bool IsSizeExceed(string path)
436 | {
437 | Image image = null;
438 | try
439 | {
440 | Path.GetExtension(path);
441 | image = Image.FromFile(path);
442 | double num = image.Width;
443 | double num2 = image.Height;
444 | if (num > (double)DefaultWidth || num2 > (double)DefaultHeight)
445 | {
446 | return true;
447 | }
448 | return false;
449 | }
450 | catch (Exception)
451 | {
452 | return false;
453 | }
454 | finally
455 | {
456 | image?.Dispose();
457 | }
458 | }
459 |
460 | private bool SetImageSize(string path)
461 | {
462 | Image image = null;
463 | try
464 | {
465 | Path.GetExtension(path);
466 | image = Image.FromFile(path);
467 | double num = image.Width;
468 | double num2 = image.Height;
469 | LogoDiy.LogHelper.Info($"img h = {num2}; w = {num}");
470 | ImageHeight = 140.0 * num2 / (double)defaultHeight;
471 | ImageWidth = 224.0 * num / (double)defaultWidth;
472 | return true;
473 | }
474 | catch (Exception)
475 | {
476 | return false;
477 | }
478 | finally
479 | {
480 | image?.Dispose();
481 | }
482 | }
483 |
484 | private void SetImagePath(bool defaultImage)
485 | {
486 | string tempPath = Path.GetTempPath();
487 | try
488 | {
489 | string text = ChangeEFIDisk(mount: true);
490 | long hardDiskFreeSpace = GetHardDiskFreeSpace(text);
491 | string path = Path.Combine(text + ":", "EFI\\Lenovo\\Logo");
492 | if (!defaultImage && Directory.Exists(path))
493 | {
494 | string[] files = Directory.GetFiles(path);
495 | if (files.Length != 0)
496 | {
497 | string text2 = files[0];
498 | tempPath = Path.Combine(tempPath, Path.GetFileName(text2));
499 | File.Copy(text2, tempPath, overwrite: true);
500 | SetImageSize(tempPath);
501 | GetBitmapImage(tempPath);
502 | }
503 | }
504 | else
505 | {
506 | GetBitmapImage(defaultpath);
507 | }
508 | GetDiskFree(hardDiskFreeSpace);
509 | }
510 | catch (Exception ex)
511 | {
512 | LogoDiy.LogHelper.Info($"SetImagePath error {ex.Message}");
513 | }
514 | finally
515 | {
516 | ChangeEFIDisk(mount: false);
517 | }
518 | }
519 |
520 | public void ToRecovery()
521 | {
522 | try
523 | {
524 | name = ChangeEFIDisk(mount: true);
525 | string text = "";
526 | text = Path.Combine(name + ":\\", "EFI\\Lenovo\\Logo");
527 | DeleteOtherDirectory(text);
528 | }
529 | catch (Exception ex)
530 | {
531 | LogoDiy.LogHelper.Error(ex);
532 | }
533 | finally
534 | {
535 | ChangeEFIDisk(mount: false);
536 | }
537 | int num = DiyHelper.SetLogoDIYInfo(0);
538 | LogoDiy.LogHelper.Info($"set logoinfo ret = {num}");
539 | if (num == 0)
540 | {
541 | LogoDiy.LogHelper.Info($"set logoinfo error: ret = {num}");
542 | return;
543 | }
544 | ShowSuccessText = "Done! Restored to default settings.\n預設設定恢復成功";
545 | ShowSuccessTip = true;
546 | FunEnable = false;
547 | }
548 |
549 | private void GetLogoInfo()
550 | {
551 | uint format = 0u;
552 | byte enable = 0;
553 | int logoDIYInfo = DiyHelper.GetLogoDIYInfo(ref enable, ref format, ref defaultHeight, ref defaultWidth);
554 |
555 | LogoDiy.LogHelper.Info($"ret1 = {logoDIYInfo}; Height = {defaultHeight}; Width = {defaultWidth}");
556 | if (logoDIYInfo != 0)
557 | {
558 | ChangeSupportingFormat(format);
559 | if (defaultHeight < 0 || defaultWidth < 0)
560 | {
561 | LogoDiy.LogHelper.Info("get height/width error, set default 1920*1080");
562 | DefaultWidth = 1920;
563 | DefaultHeight = 1080;
564 | }
565 | LogoDiy.LogHelper.Info($"get logoinfo -> enable = {enable}; type = {format}; ");
566 | bool flag = enable == 0;
567 | SetImagePath(flag);
568 | CanRecovery = !flag;
569 | FunEnable = !flag;
570 | UIIsEnable = true;
571 | }
572 | else
573 | {
574 | GetBitmapImage(defaultpath);
575 | LogoDiy.LogHelper.Info("get logo_info error:");
576 | UIIsEnable = false;
577 | FunEnable = false;
578 | CanRecovery = false;
579 | }
580 | }
581 |
582 | public void SaveLogoClick()
583 | {
584 | try
585 | {
586 | Console.WriteLine("SaveLogoClick");
587 | int num = DiyHelper.SetLogoDIYInfo(1);
588 | LogoDiy.LogHelper.Info($"set logoinfo ret = {num}");
589 | if (num == 0)
590 | {
591 | ShowSuccessTip = false;
592 | LogoDiy.LogHelper.Info($"set logoinfo error: ret = {num}");
593 | return;
594 | }
595 | LogoDiy.LogHelper.Info($"set logoinfo success: ret = {num}");
596 | name = ChangeEFIDisk(mount: true);
597 | string text = "";
598 | try
599 | {
600 | string extension = Path.GetExtension(ImagePath1);
601 | if (!string.IsNullOrWhiteSpace(fileExtension) && extension != fileExtension)
602 | {
603 | extension = fileExtension;
604 | }
605 | text = Path.Combine(name + ":\\", "EFI\\Lenovo\\Logo", $"mylogo_{DefaultWidth}x{DefaultHeight}" + extension);
606 | LogoDiy.LogHelper.Info($"path = {text}");
607 | DeleteOtherFile(text);
608 | LogoDiy.LogHelper.Info($"source path = {ImagePath1}; dest path = {text}");
609 | File.Copy(ImagePath1, text);
610 | }
611 | catch (Exception ex)
612 | {
613 | LogoDiy.LogHelper.Info("copy file error:" + ex.Message);
614 | return;
615 | }
616 | if (DiyHelper.SetLogDIYCRC(text) > 0)
617 | {
618 | LogoDiy.LogHelper.Info("Set CRC success");
619 | ChangeEFIDisk(mount: false);
620 | ShowSuccessText = "Success! You can restart to view the new boot logo now.\n設定成功,請重新啟動電腦檢視效果";
621 | ShowSuccessTip = true;
622 | }
623 | else
624 | {
625 | LogoDiy.LogHelper.Info("Set CRC ERROR");
626 | ShowSuccessTip = false;
627 | }
628 | }
629 | catch (Exception ex2)
630 | {
631 | LogoDiy.LogHelper.Error(ex2);
632 | ShowSuccessTip = false;
633 | }
634 | finally
635 | {
636 | CanRecovery = true;
637 | ChangeEFIDisk(mount: false);
638 | }
639 | }
640 |
641 | private void DeleteOtherDirectory(string path)
642 | {
643 | if (Directory.Exists(path))
644 | {
645 | Directory.Delete(path, recursive: true);
646 | }
647 | }
648 |
649 | private void DeleteOtherFile(string path)
650 | {
651 | string directoryName = Path.GetDirectoryName(path);
652 | LogoDiy.LogHelper.Info($"delete directory {directoryName}");
653 | if (Directory.Exists(directoryName))
654 | {
655 | LogoDiy.LogHelper.Info("Delete directory error, to delete file");
656 | string[] files = Directory.GetFiles(directoryName);
657 | foreach (string text in files)
658 | {
659 | LogoDiy.LogHelper.Info($"delete other file {text}");
660 | File.Delete(text);
661 | }
662 | }
663 | else
664 | {
665 | LogoDiy.LogHelper.Info($"Create new directory {directoryName}");
666 | Directory.CreateDirectory(directoryName);
667 | }
668 | }
669 |
670 | private string GetDiskName()
671 | {
672 | string[] logicalDrives = Directory.GetLogicalDrives();
673 | for (int i = 65; i < 91; i++)
674 | {
675 | ASCIIEncoding aSCIIEncoding = new ASCIIEncoding();
676 | byte[] bytes = new byte[1]
677 | {
678 | (byte)i
679 | };
680 | string @string = aSCIIEncoding.GetString(bytes);
681 | if (!logicalDrives.Contains(@string))
682 | {
683 | return @string;
684 | }
685 | }
686 | return "";
687 | }
688 |
689 | private string ChangeEFIDisk(bool mount)
690 | {
691 | string diskName = GetDiskName();
692 | try
693 | {
694 | string arg = (mount ? "/s" : "/d");
695 | string text = $"mountvol {diskName}: {arg}";
696 | LogoDiy.LogHelper.Info(text);
697 | Process process = new Process();
698 | process.StartInfo.FileName = "cmd.exe";
699 | process.StartInfo.UseShellExecute = false;
700 | process.StartInfo.RedirectStandardInput = true;
701 | process.StartInfo.RedirectStandardOutput = true;
702 | process.StartInfo.RedirectStandardError = true;
703 | process.StartInfo.CreateNoWindow = true;
704 | process.Start();
705 | process.StandardInput.WriteLine(text + "&exit");
706 | process.StandardInput.AutoFlush = true;
707 | process.WaitForExit();
708 | process.Close();
709 | return diskName;
710 | }
711 | catch (Exception ex)
712 | {
713 | LogoDiy.LogHelper.Error(ex);
714 | return diskName;
715 | }
716 | }
717 |
718 | public bool ChangeLodingIco(bool isShow)
719 | {
720 | IntPtr ptr = default(IntPtr);
721 | try
722 | {
723 | DiyHelper.Wow64DisableWow64FsRedirection(ref ptr);
724 | string text = "";
725 | text = ((!isShow) ? "bcdedit.exe -set {globalsettings} bootuxdisabled on" : "bcdedit.exe -set {globalsettings} bootuxdisabled off");
726 | Console.WriteLine(text);
727 | LogoDiy.LogHelper.Info(text);
728 | Process process = new Process();
729 | process.StartInfo.FileName = "cmd.exe";
730 | process.StartInfo.UseShellExecute = false;
731 | process.StartInfo.RedirectStandardInput = true;
732 | process.StartInfo.RedirectStandardOutput = true;
733 | process.StartInfo.RedirectStandardError = true;
734 | process.StartInfo.CreateNoWindow = true;
735 | process.Start();
736 | process.StandardInput.WriteLine(text + "&exit");
737 | process.StandardInput.AutoFlush = true;
738 | process.WaitForExit();
739 | process.Close();
740 | return true;
741 | }
742 | catch (Exception ex)
743 | {
744 | LogoDiy.LogHelper.Error(ex);
745 | return false;
746 | }
747 | finally
748 | {
749 | DiyHelper.Wow64RevertWow64FsRedirection(ptr);
750 | }
751 | }
752 |
753 | public bool ImageCheck(string path)
754 | {
755 | FileStream fileStream = new FileStream(path, FileMode.Open, FileAccess.Read);
756 | BinaryReader binaryReader = new BinaryReader(fileStream);
757 | string empty = string.Empty;
758 | bool flag = false;
759 | flag = IsImage(path);
760 | if (!flag)
761 | {
762 | return flag;
763 | }
764 | try
765 | {
766 | Path.GetExtension(path);
767 | empty += binaryReader.ReadByte();
768 | empty += binaryReader.ReadByte();
769 | try
770 | {
771 | FileExtension fileExtension = (FileExtension)Enum.Parse(typeof(FileExtension), empty);
772 | switch (fileExtension)
773 | {
774 | case FileExtension.BMP2:
775 | case FileExtension.PNG:
776 | case FileExtension.BMP:
777 | case FileExtension.JPEG:
778 | case FileExtension.JPG:
779 | this.fileExtension = fileExtension.Display();
780 | flag = true;
781 | return flag;
782 | default:
783 | flag = false;
784 | return flag;
785 | }
786 | }
787 | catch (Exception ex)
788 | {
789 | LogoDiy.LogHelper.Error(ex);
790 | return flag;
791 | }
792 | }
793 | catch (Exception ex2)
794 | {
795 | LogoDiy.LogHelper.Error(ex2);
796 | return flag;
797 | }
798 | finally
799 | {
800 | if (fileStream != null)
801 | {
802 | fileStream.Close();
803 | binaryReader.Close();
804 | }
805 | }
806 | }
807 |
808 | private bool IsImage(string path)
809 | {
810 | Image image = null;
811 | try
812 | {
813 | string text = Path.GetExtension(path).ToLower();
814 | if (!(text == ".tga") && !(text == ".pcx"))
815 | {
816 | image = Image.FromFile(path);
817 | image.Dispose();
818 | }
819 | return true;
820 | }
821 | catch (Exception)
822 | {
823 | return false;
824 | }
825 | finally
826 | {
827 | image?.Dispose();
828 | }
829 | }
830 |
831 | public void SelectedImageClick()
832 | {
833 | ShowSuccessTip = false;
834 | OpenFileDialog openFileDialog = new OpenFileDialog();
835 | openFileDialog.Multiselect = false;
836 | openFileDialog.Title = "Please select an image / 請選擇圖片";
837 | openFileDialog.Filter = $"Image({filter1})|{filter2}";
838 | var res = openFileDialog.ShowDialog();
839 | if (res == DialogResult.OK)
840 | {
841 | CanRecovery = false;
842 | FunEnable = false;
843 | string fileName = openFileDialog.FileName;
844 | FileInfo fileInfo = new FileInfo(fileName);
845 | if (!ImageCheck(fileName))
846 | {
847 | ShowWarning = true;
848 | ShowWarnInfo = "The selected file is not an image!\n當前選擇的檔案不是圖片,請重試!";
849 | return;
850 | }
851 | if (fileInfo.Length > DiskFreeSpace)
852 | {
853 | int num = (int)(DiskFreeSpace / 1024 / 1024);
854 | ShowWarnInfo = $"Image must not exceed {num}MB!\n圖片不得超過{num}MB,請重新選擇!";
855 | ShowWarning = true;
856 | return;
857 | }
858 | if (IsSizeExceed(fileName))
859 | {
860 | ShowWarnInfo = "The image exceeds the maximum resolution!\n圖片超出最大解析度,請重新選擇!";
861 | ShowWarning = true;
862 | return;
863 | }
864 | GetBitmapImage(fileName);
865 | SetImageSize(fileName);
866 | FunEnable = true;
867 | ShowWarning = false;
868 | LogoDiy.LogHelper.Info($"介面圖片大小>>height = {ImageHeight}; width = {ImageWidth};");
869 | }
870 | }
871 |
872 | public void GetBitmapImage(string imagePath)
873 | {
874 | try
875 | {
876 | imagePath1 = imagePath;
877 | BitmapImage bitmapImage = new BitmapImage();
878 | bitmapImage.BeginInit();
879 | bitmapImage.CacheOption = BitmapCacheOption.OnLoad;
880 | bitmapImage.UriSource = new Uri(imagePath);
881 | bitmapImage.EndInit();
882 | ImageSource = bitmapImage.Clone();
883 | bitmapImage.Freeze();
884 | }
885 | catch (Exception ex)
886 | {
887 | LogoDiy.LogHelper.Error(ex);
888 | }
889 | }
890 |
891 | private void ChangeSupportingFormat(uint format)
892 | {
893 | filter1 = "";
894 | filter2 = "";
895 | if ((1u & format) != 0)
896 | {
897 | filter1 += "*.jpg,";
898 | filter2 += "*.jpg;";
899 | }
900 | if ((0x10u & format) != 0)
901 | {
902 | filter1 += "*.bmp,";
903 | filter2 += "*.bmp;";
904 | }
905 | if ((0x20u & format) != 0)
906 | {
907 | filter1 += "*.png,";
908 | filter2 += "*.png;";
909 | }
910 | filter1 = filter1.Substring(0, filter1.Length - 1);
911 | filter2 = filter2.Substring(0, filter2.Length - 1);
912 | SupportingFormat = filter2;
913 | }
914 | }
915 | }
--------------------------------------------------------------------------------
/LogoDiy/Program.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Threading.Tasks;
5 | using System.Windows.Forms;
6 |
7 | namespace LogoDiy
8 | {
9 | static class Program
10 | {
11 | ///
12 | /// The main entry point for the application.
13 | ///
14 | [STAThread]
15 | static void Main()
16 | {
17 | Application.EnableVisualStyles();
18 | Application.SetCompatibleTextRenderingDefault(false);
19 | Application.Run(new Form1());
20 | }
21 | }
22 | }
23 |
--------------------------------------------------------------------------------
/LogoDiy/Properties/AssemblyInfo.cs:
--------------------------------------------------------------------------------
1 | using System.Reflection;
2 | using System.Runtime.CompilerServices;
3 | using System.Runtime.InteropServices;
4 |
5 | // General Information about an assembly is controlled through the following
6 | // set of attributes. Change these attribute values to modify the information
7 | // associated with an assembly.
8 | [assembly: AssemblyTitle("LogoDIY")]
9 | [assembly: AssemblyDescription("")]
10 | [assembly: AssemblyConfiguration("")]
11 | [assembly: AssemblyCompany("")]
12 | [assembly: AssemblyProduct("LogoDIY")]
13 | [assembly: AssemblyCopyright("Copyright © 2020")]
14 | [assembly: AssemblyTrademark("")]
15 | [assembly: AssemblyCulture("")]
16 |
17 | // Setting ComVisible to false makes the types in this assembly not visible
18 | // to COM components. If you need to access a type in this assembly from
19 | // COM, set the ComVisible attribute to true on that type.
20 | [assembly: ComVisible(false)]
21 |
22 | // The following GUID is for the ID of the typelib if this project is exposed to COM
23 | [assembly: Guid("3df19333-d9aa-4cfd-8b0f-21df0916508c")]
24 |
25 | // Version information for an assembly consists of the following four values:
26 | //
27 | // Major Version
28 | // Minor Version
29 | // Build Number
30 | // Revision
31 | //
32 | // You can specify all the values or you can default the Build and Revision Numbers
33 | // by using the '*' as shown below:
34 | // [assembly: AssemblyVersion("1.0.*")]
35 | [assembly: AssemblyVersion("1.0.0.0")]
36 | [assembly: AssemblyFileVersion("1.0.0.0")]
37 |
--------------------------------------------------------------------------------
/LogoDiy/Properties/Resources.Designer.cs:
--------------------------------------------------------------------------------
1 | //------------------------------------------------------------------------------
2 | //
3 | // This code was generated by a tool.
4 | // Runtime Version:4.0.30319.42000
5 | //
6 | // Changes to this file may cause incorrect behavior and will be lost if
7 | // the code is regenerated.
8 | //
9 | //------------------------------------------------------------------------------
10 |
11 | namespace LogoDIY.Properties {
12 | using System;
13 |
14 |
15 | ///
16 | /// A strongly-typed resource class, for looking up localized strings, etc.
17 | ///
18 | // This class was auto-generated by the StronglyTypedResourceBuilder
19 | // class via a tool like ResGen or Visual Studio.
20 | // To add or remove a member, edit your .ResX file then rerun ResGen
21 | // with the /str option, or rebuild your VS project.
22 | [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "16.0.0.0")]
23 | [global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
24 | [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
25 | internal class Resources {
26 |
27 | private static global::System.Resources.ResourceManager resourceMan;
28 |
29 | private static global::System.Globalization.CultureInfo resourceCulture;
30 |
31 | [global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")]
32 | internal Resources() {
33 | }
34 |
35 | ///
36 | /// Returns the cached ResourceManager instance used by this class.
37 | ///
38 | [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
39 | internal static global::System.Resources.ResourceManager ResourceManager {
40 | get {
41 | if (object.ReferenceEquals(resourceMan, null)) {
42 | global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("LogoDIY.Properties.Resources", typeof(Resources).Assembly);
43 | resourceMan = temp;
44 | }
45 | return resourceMan;
46 | }
47 | }
48 |
49 | ///
50 | /// Overrides the current thread's CurrentUICulture property for all
51 | /// resource lookups using this strongly typed resource class.
52 | ///
53 | [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
54 | internal static global::System.Globalization.CultureInfo Culture {
55 | get {
56 | return resourceCulture;
57 | }
58 | set {
59 | resourceCulture = value;
60 | }
61 | }
62 | }
63 | }
64 |
--------------------------------------------------------------------------------
/LogoDiy/Properties/Resources.resx:
--------------------------------------------------------------------------------
1 |
2 |
3 |
62 |
63 |
64 |
65 |
66 |
67 |
68 |
69 |
70 |
71 |
72 |
73 |
74 |
75 |
76 |
77 |
78 |
79 |
80 |
81 |
82 |
83 |
84 |
85 |
86 |
87 |
88 |
89 |
90 |
91 |
92 |
93 |
94 |
95 |
96 |
97 |
98 |
99 |
100 |
101 |
102 |
103 |
104 |
105 |
106 |
107 |
108 |
109 | text/microsoft-resx
110 |
111 |
112 | 2.0
113 |
114 |
115 | System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
116 |
117 |
118 | System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
119 |
120 |
--------------------------------------------------------------------------------
/LogoDiy/Properties/Settings.Designer.cs:
--------------------------------------------------------------------------------
1 | //------------------------------------------------------------------------------
2 | //
3 | // This code was generated by a tool.
4 | // Runtime Version:4.0.30319.42000
5 | //
6 | // Changes to this file may cause incorrect behavior and will be lost if
7 | // the code is regenerated.
8 | //
9 | //------------------------------------------------------------------------------
10 |
11 | namespace LogoDIY.Properties
12 | {
13 |
14 |
15 | [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
16 | [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "11.0.0.0")]
17 | internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase
18 | {
19 |
20 | private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings())));
21 |
22 | public static Settings Default
23 | {
24 | get
25 | {
26 | return defaultInstance;
27 | }
28 | }
29 | }
30 | }
31 |
--------------------------------------------------------------------------------
/LogoDiy/Properties/Settings.settings:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
--------------------------------------------------------------------------------
/LogoDiy/app.manifest:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
39 |
40 |
41 |
42 |
43 |
44 |
45 |
46 |
47 |
48 |
52 |
53 |
54 | true
55 |
56 |
57 |
58 |
59 |
73 |
74 |
75 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # Boot Logo Customization
2 |
3 | **EN** | [ZH](README.zh.md)
4 |
5 | Customize Lenovo PC boot logo (screen) without installing "Lenovo PC Manager".
6 |
7 | **This program will modify BIOS settings, use at your own risk.** The copyright of the code and binary files used belongs to the original manufacturer.
8 |
9 | ## Supported models
10 |
11 | ***Only Lenovo computers (Ideapad / Xiaoxin, Legion, Yoga, etc.) are supported.***
12 |
13 | - Xiaoxin Pro 14 2021 Intel
14 |
15 | - Xiaoxin Pro 13 Ryzen
16 |
17 | - Xiaoxin Air 14 2020 Intel
18 |
19 | - ThinkBook 14 G4+ IAP
20 |
21 | - ThinkBook 15 Gen 3
22 |
23 | - Legion Y9000P 2022
24 |
25 | - Yoga 7 16IAP7
26 |
27 | - IdeaPad Gaming 3 15ACH6
28 |
29 | - IdeaPad 3 15ITL6
30 |
31 | - Feel free to test and add to this list
32 |
33 | ## FAQ
34 |
35 | ### New boot logo does not take effect / corrupted logo
36 |
37 | This may happen when using `.jpg` format files saved with Photoshop. You can save the image as `.bmp` format, or resave it to `.jpg` format with other software (e.g. Microsoft Paint).
38 |
39 | ### User interface of this utility is too ugly 🤯
40 |
41 | This is actually just something I wanted to use for myself and quickly build ;).
42 |
43 | ### Any recommendations for boot logo design?
44 |
45 | [Here](https://github.com/Coxxs/LogoDiy/tree/master/Examples) are some examples.
46 |
--------------------------------------------------------------------------------
/README.zh.md:
--------------------------------------------------------------------------------
1 | # 開機 Logo 自訂
2 |
3 | [EN](README.md) | **ZH**
4 |
5 | 自訂 Lenovo 電腦開機 Logo(畫面),無需安裝「聯想電腦管家」軟體。
6 |
7 | **涉及修改 BIOS 設置,一切風險自負。** 代碼及二進制檔案著作權歸其原開發商所有。
8 |
9 | ## 測試可用機型
10 |
11 | **僅支援 Lenovo 電腦(Ideapad / Xiaoxin、Legion、Yoga 等)。**
12 |
13 | - Xiaoxin Pro 14 2021 Intel
14 |
15 | - Xiaoxin Pro 13 Ryzen
16 |
17 | - Xiaoxin Air 14 2020 Intel
18 |
19 | - ThinkBook 14 G4+ IAP
20 |
21 | - ThinkBook 15 Gen 3
22 |
23 | - Legion Y9000P 2022
24 |
25 | - Yoga 7 16IAP7
26 |
27 | - IdeaPad Gaming 3 15ACH6
28 |
29 | - IdeaPad 3 15ITL6
30 |
31 | - 歡迎測試添加
32 |
33 | ## 常見問題
34 |
35 | ### 設定成功後,重新啟動未生效 / 顯示錯誤
36 |
37 | Photoshop 儲存的 `.jpg` 格式檔案可能會出現這樣的情況。可以儲存為 `.bmp` 格式後直接使用,或用其他軟體(如小畫家)轉換為 `.jpg` 格式。
38 |
39 | ### 軟體介面太醜了 🤯
40 |
41 | 這個其實只是我自己要用而快速糊出來的東西 ;)
42 |
43 | ### 換成什麼圖案好呢
44 |
45 | [這裡](https://github.com/Coxxs/LogoDiy/tree/master/Examples) 有一些例子可供參考。
46 |
--------------------------------------------------------------------------------