+169
Cargo.lock
+169
Cargo.lock
···
1
+
# This file is automatically @generated by Cargo.
2
+
# It is not intended for manual editing.
3
+
version = 4
4
+
5
+
[[package]]
6
+
name = "amd-brand-string-edit"
7
+
version = "0.1.0"
8
+
dependencies = [
9
+
"log",
10
+
"uefi",
11
+
"x86",
12
+
]
13
+
14
+
[[package]]
15
+
name = "bit_field"
16
+
version = "0.10.2"
17
+
source = "registry+https://github.com/rust-lang/crates.io-index"
18
+
checksum = "dc827186963e592360843fb5ba4b973e145841266c1357f7180c43526f2e5b61"
19
+
20
+
[[package]]
21
+
name = "bitflags"
22
+
version = "1.3.2"
23
+
source = "registry+https://github.com/rust-lang/crates.io-index"
24
+
checksum = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a"
25
+
26
+
[[package]]
27
+
name = "bitflags"
28
+
version = "2.9.3"
29
+
source = "registry+https://github.com/rust-lang/crates.io-index"
30
+
checksum = "34efbcccd345379ca2868b2b2c9d3782e9cc58ba87bc7d79d5b53d9c9ae6f25d"
31
+
32
+
[[package]]
33
+
name = "cfg-if"
34
+
version = "1.0.3"
35
+
source = "registry+https://github.com/rust-lang/crates.io-index"
36
+
checksum = "2fd1289c04a9ea8cb22300a459a72a385d7c73d3259e2ed7dcb2af674838cfa9"
37
+
38
+
[[package]]
39
+
name = "log"
40
+
version = "0.4.27"
41
+
source = "registry+https://github.com/rust-lang/crates.io-index"
42
+
checksum = "13dc2df351e3202783a1fe0d44375f7295ffb4049267b0f3018346dc122a1d94"
43
+
44
+
[[package]]
45
+
name = "proc-macro2"
46
+
version = "1.0.101"
47
+
source = "registry+https://github.com/rust-lang/crates.io-index"
48
+
checksum = "89ae43fd86e4158d6db51ad8e2b80f313af9cc74f5c0e03ccb87de09998732de"
49
+
dependencies = [
50
+
"unicode-ident",
51
+
]
52
+
53
+
[[package]]
54
+
name = "ptr_meta"
55
+
version = "0.3.0"
56
+
source = "registry+https://github.com/rust-lang/crates.io-index"
57
+
checksum = "fe9e76f66d3f9606f44e45598d155cb13ecf09f4a28199e48daf8c8fc937ea90"
58
+
dependencies = [
59
+
"ptr_meta_derive",
60
+
]
61
+
62
+
[[package]]
63
+
name = "ptr_meta_derive"
64
+
version = "0.3.0"
65
+
source = "registry+https://github.com/rust-lang/crates.io-index"
66
+
checksum = "ca414edb151b4c8d125c12566ab0d74dc9cdba36fb80eb7b848c15f495fd32d1"
67
+
dependencies = [
68
+
"proc-macro2",
69
+
"quote",
70
+
"syn",
71
+
]
72
+
73
+
[[package]]
74
+
name = "quote"
75
+
version = "1.0.40"
76
+
source = "registry+https://github.com/rust-lang/crates.io-index"
77
+
checksum = "1885c039570dc00dcb4ff087a89e185fd56bae234ddc7f056a945bf36467248d"
78
+
dependencies = [
79
+
"proc-macro2",
80
+
]
81
+
82
+
[[package]]
83
+
name = "raw-cpuid"
84
+
version = "10.7.0"
85
+
source = "registry+https://github.com/rust-lang/crates.io-index"
86
+
checksum = "6c297679cb867470fa8c9f67dbba74a78d78e3e98d7cf2b08d6d71540f797332"
87
+
dependencies = [
88
+
"bitflags 1.3.2",
89
+
]
90
+
91
+
[[package]]
92
+
name = "syn"
93
+
version = "2.0.106"
94
+
source = "registry+https://github.com/rust-lang/crates.io-index"
95
+
checksum = "ede7c438028d4436d71104916910f5bb611972c5cfd7f89b8300a8186e6fada6"
96
+
dependencies = [
97
+
"proc-macro2",
98
+
"quote",
99
+
"unicode-ident",
100
+
]
101
+
102
+
[[package]]
103
+
name = "ucs2"
104
+
version = "0.3.3"
105
+
source = "registry+https://github.com/rust-lang/crates.io-index"
106
+
checksum = "df79298e11f316400c57ec268f3c2c29ac3c4d4777687955cd3d4f3a35ce7eba"
107
+
dependencies = [
108
+
"bit_field",
109
+
]
110
+
111
+
[[package]]
112
+
name = "uefi"
113
+
version = "0.35.0"
114
+
source = "registry+https://github.com/rust-lang/crates.io-index"
115
+
checksum = "da7569ceafb898907ff764629bac90ac24ba4203c38c33ef79ee88c74aa35b11"
116
+
dependencies = [
117
+
"bitflags 2.9.3",
118
+
"cfg-if",
119
+
"log",
120
+
"ptr_meta",
121
+
"ucs2",
122
+
"uefi-macros",
123
+
"uefi-raw",
124
+
"uguid",
125
+
]
126
+
127
+
[[package]]
128
+
name = "uefi-macros"
129
+
version = "0.18.1"
130
+
source = "registry+https://github.com/rust-lang/crates.io-index"
131
+
checksum = "b3dad47b3af8f99116c0f6d4d669c439487d9aaf1c8d9480d686cda6f3a8aa23"
132
+
dependencies = [
133
+
"proc-macro2",
134
+
"quote",
135
+
"syn",
136
+
]
137
+
138
+
[[package]]
139
+
name = "uefi-raw"
140
+
version = "0.11.0"
141
+
source = "registry+https://github.com/rust-lang/crates.io-index"
142
+
checksum = "7cad96b8baaf1615d3fdd0f03d04a0b487d857c1b51b19dcbfe05e2e3c447b78"
143
+
dependencies = [
144
+
"bitflags 2.9.3",
145
+
"uguid",
146
+
]
147
+
148
+
[[package]]
149
+
name = "uguid"
150
+
version = "2.2.0"
151
+
source = "registry+https://github.com/rust-lang/crates.io-index"
152
+
checksum = "ab14ea9660d240e7865ce9d54ecdbd1cd9fa5802ae6f4512f093c7907e921533"
153
+
154
+
[[package]]
155
+
name = "unicode-ident"
156
+
version = "1.0.18"
157
+
source = "registry+https://github.com/rust-lang/crates.io-index"
158
+
checksum = "5a5f39404a5da50712a4c1eecf25e90dd62b613502b7e925fd4e4d19b5c96512"
159
+
160
+
[[package]]
161
+
name = "x86"
162
+
version = "0.52.0"
163
+
source = "registry+https://github.com/rust-lang/crates.io-index"
164
+
checksum = "2781db97787217ad2a2845c396a5efe286f87467a5810836db6d74926e94a385"
165
+
dependencies = [
166
+
"bit_field",
167
+
"bitflags 1.3.2",
168
+
"raw-cpuid",
169
+
]
+9
Cargo.toml
+9
Cargo.toml
+19
README.md
+19
README.md
···
1
+
# amd-brand-string-edit
2
+
3
+
UEFI utility to edit the brand string of AMD processors (Family 10h through
4
+
Family 19h) via the `Core::X86::Msr::ProcNameString` Machine State Registers.
5
+
6
+
This is temporary and doesn't modify the CPU in any way, and the change is
7
+
purely aesthetic. This does not work on Intel, TransMeta, WinChip, or VIA CPUs.
8
+
9
+

10
+
11
+

12
+
13
+
## Usage
14
+
15
+
Replace the brand string in `src/main.rs` with your desired brand string, then
16
+
run `cargo build --release --target x86_64-unknown-uefi`. Run the output .efi
17
+
file (`target/x86_64-unknown-uefi/amd-brand-string-edit.efi`) on the computer
18
+
via either an EFI shell or with the boot picker and the file located at
19
+
`EFI/Boot/bootx64.efi` on removable storage.
media/uefi_output.png
media/uefi_output.png
This is a binary file and will not be displayed.
media/windows_display.png
media/windows_display.png
This is a binary file and will not be displayed.
+78
src/main.rs
+78
src/main.rs
···
1
+
#![no_main]
2
+
#![no_std]
3
+
4
+
// CHANGE ME!
5
+
// new brand string must be EXACTLY 48 characters (pad with spaces)
6
+
static NEW_BRAND_STRING: &'static str = "Lappy 486 ";
7
+
// 48 character reference: ------------------------------------------------
8
+
9
+
use uefi::print;
10
+
use uefi::prelude::*;
11
+
use x86::cpuid::CpuId;
12
+
use core::arch::asm;
13
+
use core::convert::TryInto;
14
+
15
+
unsafe fn wrmsr_amd(msr: u32, value: u64) {
16
+
let low = value as u32;
17
+
let high = (value >> 32) as u32;
18
+
// wrmsr with the AMD "secret" key - not necessary for these MSRs
19
+
let secret = 0x9c5a203a as u32;
20
+
unsafe {
21
+
asm!("wrmsr", in("ecx") msr, in("eax") low, in("edx") high, in("edi") secret);
22
+
}
23
+
}
24
+
25
+
pub fn brand_string_to_int64(brand_str: &str) -> Option<[u64; 6]> {
26
+
// make sure we have exactly 48 characters for the brand string
27
+
if brand_str.len() != 48 {
28
+
return None
29
+
}
30
+
let str_bytes = brand_str.as_bytes();
31
+
let mut out = [0u64; 6];
32
+
// convert it to an array of 6 LE integers
33
+
// does rust seriously not support for loops
34
+
let mut i = 0;
35
+
while i < 6 {
36
+
let start = i * 8;
37
+
let chunk: [u8; 8] = str_bytes[start..start + 8].try_into().unwrap();
38
+
out[i] = u64::from_le_bytes(chunk);
39
+
i += 1;
40
+
}
41
+
Some(out)
42
+
}
43
+
44
+
#[entry]
45
+
fn main() -> Status {
46
+
uefi::helpers::init().unwrap();
47
+
// get the vendor (we only work on AMD)
48
+
let cpu_id = CpuId::new();
49
+
let vendor_name = cpu_id.get_vendor_info().unwrap();
50
+
print!("CPU vendor: {}\n", vendor_name.as_str());
51
+
if vendor_name.as_str() == "AuthenticAMD" {
52
+
// get the current CPU brand string
53
+
let old_brand_string = cpu_id.get_processor_brand_string().unwrap();
54
+
print!("Current brand: \"{}\"\n", old_brand_string.as_str());
55
+
// convert to integers to set in the MSRs
56
+
match brand_string_to_int64(NEW_BRAND_STRING) {
57
+
None => print!("Invalid format for brand string\n\"{}\".\n", NEW_BRAND_STRING),
58
+
Some(ints) => {
59
+
// set the Core::X86::Msr::ProcNameString registers to our new string
60
+
let mut i = 0;
61
+
while i < 6 {
62
+
unsafe {
63
+
wrmsr_amd(0xC0010030 + i, ints[i as usize]);
64
+
}
65
+
i += 1;
66
+
}
67
+
// verify that the string has actually changed
68
+
let verify_brand_string = cpu_id.get_processor_brand_string().unwrap();
69
+
print!("New brand: \"{}\"\n", verify_brand_string.as_str());
70
+
}
71
+
}
72
+
} else {
73
+
print!("This program only supports AuthenticAMD.\n");
74
+
}
75
+
// stall for 7 seconds to let you read the console output
76
+
boot::stall(7_000_000);
77
+
Status::SUCCESS
78
+
}