Skip to content

Instantly share code, notes, and snippets.

@KatelynHaworth
Created July 3, 2019 01:54
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save KatelynHaworth/2850071b8d22a38936b75ad92d75ab23 to your computer and use it in GitHub Desktop.
Save KatelynHaworth/2850071b8d22a38936b75ad92d75ab23 to your computer and use it in GitHub Desktop.

GUID Converter

When MSIs are installed on a Windows system, the GUID of a UpgradeCode or ProductCode are "formated" and then stored in the registry, this makes it difficult to locate related registry keys.

This gist provides a simple Golang script (with provided play link) to convert a GUID into a formated version that can be searched.

For the record, to convert a guid to the format used in the registry

e.g. for {D0F23C3F-CA74-460F-9ADB-49CBD57F9688}

  1. Reverse first 8 characters F3C32F0D
  2. Reverse next 4 characters 47AC
  3. Reverse next 4 characters F064
  4. Reverse next 2 characters A9
  5. Reverse next 2 characters BD
  6. Reverse next 2 characters 94
  7. Reverse next 2 characters BC
  8. Reverse next 2 characters 5D
  9. Reverse next 2 characters F7
  10. Reverse next 2 characters 69
  11. Reverse next 2 characters 88

thus {D0F23C3F-CA74-460F-9ADB-49CBD57F9688} becomes F3C32F0D47ACF064A9BD94BC5DF76988

package main
import (
"fmt"
"strings"
)
func main() {
// Change this value to the GUID to
// be formated
upgradeCode := "{96272B69-938E-4C50-9068-88EB1CEA08B6}"
upgradeCode = strings.Replace(upgradeCode, "{", "", -1)
upgradeCode = strings.Replace(upgradeCode, "}", "", -1)
upgradeCode = strings.Replace(upgradeCode, "-", "", -1)
formatedCode := ""
for i := 7; i > -1; i-- {
formatedCode = formatedCode + string([]byte{upgradeCode[i]})
}
for i := 11; i > 7; i-- {
formatedCode = formatedCode + string([]byte{upgradeCode[i]})
}
for i := 15; i > 11; i-- {
formatedCode = formatedCode + string([]byte{upgradeCode[i]})
}
for i := 17; i > 15; i-- {
formatedCode = formatedCode + string([]byte{upgradeCode[i]})
}
for i := 19; i > 17; i-- {
formatedCode = formatedCode + string([]byte{upgradeCode[i]})
}
for i := 21; i > 19; i-- {
formatedCode = formatedCode + string([]byte{upgradeCode[i]})
}
for i := 23; i > 21; i-- {
formatedCode = formatedCode + string([]byte{upgradeCode[i]})
}
for i := 25; i > 23; i-- {
formatedCode = formatedCode + string([]byte{upgradeCode[i]})
}
for i := 27; i > 25; i-- {
formatedCode = formatedCode + string([]byte{upgradeCode[i]})
}
for i := 29; i > 27; i-- {
formatedCode = formatedCode + string([]byte{upgradeCode[i]})
}
for i := 31; i > 29; i-- {
formatedCode = formatedCode + string([]byte{upgradeCode[i]})
}
fmt.Println(formatedCode)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment