Skip to content
This repository has been archived by the owner on Dec 6, 2022. It is now read-only.

Commit

Permalink
Merge pull request #2 from klauspost/add-threadripper-v1-patch
Browse files Browse the repository at this point in the history
Add Threadripper alternative patch

Patch by @neoKushan
  • Loading branch information
klauspost authored May 31, 2020
2 parents d7c6a21 + 17fd621 commit 4ee1248
Show file tree
Hide file tree
Showing 2 changed files with 43 additions and 7 deletions.
5 changes: 2 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# ryzen-master-vbs-patch

AMD Ryzen Master VBS patcher allows AMD Ryzen Master to run while Virtualization is enabled.
AMD Ryzen Master VBS patcher allows AMD Ryzen Master to run while Hyper-V Virtualization is enabled.


Thanks to [@TOM_RUS](https://twitter.com/TOM_RUS/status/1204867886197755904) for finding this.
Expand All @@ -18,8 +18,7 @@ Confirmed versions:
* v2.1.1.1472 (2020)
* v2.2.0.1543 (2020)

Note that on Threadripper CPUs the actually installed version may be different and the installed executable therefore cannot be patched.
The version in the "About" page in the software should reflect the actual version.
Threadripper patch was supplied by [@neoKushan](https://github.com/neoKushan).

# Running

Expand Down
45 changes: 41 additions & 4 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package main

import (
"bytes"
"errors"
"flag"
"fmt"
"io/ioutil"
Expand Down Expand Up @@ -29,27 +30,40 @@ func main() {
for _, f := range args {
dir, file := filepath.Split(f)
err := patch(filepath.Join(dir, file), filepath.Join(dir, *prefix+file))
if err != nil {
switch err {
case nil:
case errCannotPatch:
fmt.Println(err)
err = patchAlt(filepath.Join(dir, file), filepath.Join(dir, *prefix+file))
if err == errCannotPatch {
fmt.Println(err)
fmt.Println("Skipping file...")
} else if err != nil {
fmt.Println(err)
os.Exit(1)
}
default:
fmt.Println(err)
os.Exit(1)
}
}
}

var errCannotPatch = errors.New("byte sequence not found")

var search = []byte{0x44, 0x39, 0x6D, 0xA8, 0x0F, 0x84, 0xF7}
var replace = []byte{0x44, 0x39, 0x6D, 0xA8, 0x90, 0xe9, 0xf7}

func patch(in string, out string) error {
fmt.Println("Patching", in)
fmt.Println("Applying v2 patch on", in)
b, err := ioutil.ReadFile(in)
if err != nil {
return err
}
c := bytes.Count(b, search)
fmt.Println("Matching byte sequences:", c, "(should be 1)")
if c != 1 {
fmt.Println("Skipping file...")
return nil
return errCannotPatch
}
b = bytes.Replace(b, search, replace, -1)
fmt.Println("Writing to", out)
Expand All @@ -60,6 +74,29 @@ func patch(in string, out string) error {
return nil
}

var searchAlt = []byte{0x00, 0x39, 0x7D, 0x90, 0x0F, 0x84, 0xE8, 0x00}
var replaceAlt = []byte{0x00, 0x39, 0x7D, 0x90, 0x90, 0xE9, 0xE8, 0x00}

func patchAlt(in string, out string) error {
fmt.Println("Applying alternative patch on", in)
b, err := ioutil.ReadFile(in)
if err != nil {
return err
}
c := bytes.Count(b, searchAlt)
fmt.Println("Matching byte sequences:", c, "(should be 1)")
if c != 1 {
return errCannotPatch
}
b = bytes.Replace(b, searchAlt, replaceAlt, -1)
fmt.Println("Writing to", out)
err = ioutil.WriteFile(out, b, 0)
if err != nil {
return err
}
return nil
}

/*
The MIT License (MIT)
Expand Down

0 comments on commit 4ee1248

Please sign in to comment.