Skip to content

Commit 41120d7

Browse files
author
noctuelles
committed
Updated PDFs, added OC Utilities folder containing tools included with OpenCorePkg
1 parent 0543b00 commit 41120d7

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

42 files changed

+1461
-0
lines changed

Other/OC Utilities/ACPIe/ACPIe

435 KB
Binary file not shown.

Other/OC Utilities/ACPIe/ACPIe.exe

447 KB
Binary file not shown.

Other/OC Utilities/ACPIe/ACPIe.linux

456 KB
Binary file not shown.
15.2 KB
Binary file not shown.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
#!/bin/bash
2+
3+
# create_vault.sh
4+
#
5+
#
6+
# Created by Rodion Shingarev on 13.04.19.
7+
#
8+
OCPath="$1"
9+
10+
if [ "${OCPath}" = "" ]; then
11+
echo "Usage ./create_vault.sh path/to/EFI/OC"
12+
exit 1
13+
fi
14+
15+
if [ ! -d "${OCPath}" ]; then
16+
echo "Path $OCPath is missing!"
17+
exit 1
18+
fi
19+
20+
if [ ! -x /usr/bin/find ] || [ ! -x /bin/rm ] || [ ! -x /usr/bin/sed ] || [ ! -x /usr/bin/xxd ]; then
21+
echo "Unix environment is broken!"
22+
exit 1
23+
fi
24+
25+
if [ ! -x /usr/libexec/PlistBuddy ]; then
26+
echo "PlistBuddy is missing!"
27+
exit 1
28+
fi
29+
30+
if [ ! -x /usr/bin/shasum ]; then
31+
echo "shasum is missing!"
32+
exit 1
33+
fi
34+
35+
abort() {
36+
/bin/rm -rf vault.plist vault.sig /tmp/vault_hash
37+
echo "Fatal error: ${1}!"
38+
exit 1
39+
}
40+
41+
echo "Chose ${OCPath} for hashing..."
42+
43+
cd "${OCPath}" || abort "Failed to reach ${OCPath}"
44+
/bin/rm -rf vault.plist vault.sig || abort "Failed to cleanup"
45+
/usr/libexec/PlistBuddy -c "Add Version integer 1" vault.plist || abort "Failed to set vault.plist version"
46+
47+
echo "Hashing files in ${OCPath}..."
48+
49+
/usr/bin/find . -not -path '*/\.*' -type f \
50+
\( ! -iname ".*" \) \
51+
\( ! -iname "vault.*" \) \
52+
\( ! -iname "OpenCore.efi" \) | while read -r fname; do
53+
fname="${fname#"./"}"
54+
wname="${fname//\//\\\\}"
55+
shasum=$(/usr/bin/shasum -a 256 "${fname}") || abort "Failed to hash ${fname}"
56+
sha=$(echo "$shasum" | /usr/bin/sed 's/^\([a-f0-9]\{64\}\).*/\1/') || abort "Illegit hashsum"
57+
if [ "${#sha}" != 64 ] || [ "$(echo "$sha"| /usr/bin/sed 's/^[a-f0-9]*$//')" ]; then
58+
abort "Got invalid hash: ${sha}!"
59+
fi
60+
61+
echo "${wname}: ${sha}"
62+
63+
echo "${sha}" | /usr/bin/xxd -r -p > /tmp/vault_hash || abort "Hashing failure"
64+
/usr/libexec/PlistBuddy -c "Import Files:'${wname}' /tmp/vault_hash" vault.plist || abort "Failed to append vault.plist!"
65+
done
66+
67+
/bin/rm -rf /tmp/vault_hash
68+
69+
echo "All done!"
70+
exit 0
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,88 @@
1+
#!/bin/sh
2+
3+
abort() {
4+
echo "Fatal error: ${1}!"
5+
exit 1
6+
}
7+
8+
cleanup() {
9+
echo "Cleaning up keys"
10+
rm -rf "${KeyPath}"
11+
}
12+
13+
if [ ! -x /usr/bin/dirname ] || [ ! -x /bin/chmod ] || [ ! -x /bin/mkdir ] || [ ! -x /usr/bin/openssl ] || [ ! -x /bin/rm ] || [ ! -x /usr/bin/strings ] || [ ! -x /usr/bin/grep ] || [ ! -x /usr/bin/cut ] || [ ! -x /bin/dd ] || [ ! -x /usr/bin/uuidgen ] ; then
14+
abort "Unix environment is broken!"
15+
fi
16+
17+
cd "$(/usr/bin/dirname "$0")" || abort "Failed to enter working directory!"
18+
19+
OCPath="$1"
20+
21+
if [ "$OCPath" = "" ]; then
22+
OCPath=../../EFI/OC
23+
fi
24+
25+
KeyPath="/tmp/Keys-$(/usr/bin/uuidgen)"
26+
OCBin="${OCPath}/OpenCore.efi"
27+
RootCA="${KeyPath}/ca.pem"
28+
PrivKey="${KeyPath}/privatekey.cer"
29+
PubKey="${KeyPath}/vault.pub"
30+
31+
if [ ! -d "${OCPath}" ]; then
32+
abort "Path ${OCPath} is missing!"
33+
fi
34+
35+
if [ ! -f "${OCBin}" ]; then
36+
abort "OpenCore.efi is missing!"
37+
fi
38+
39+
if [ ! -x ./RsaTool ] || [ ! -x ./create_vault.sh ]; then
40+
if [ -f ./RsaTool ]; then
41+
/bin/chmod a+x ./RsaTool || abort "Failed to set permission for RsaTool"
42+
else
43+
abort "Failed to find RsaTool!"
44+
fi
45+
46+
if [ -f ./create_vault.sh ]; then
47+
/bin/chmod a+x ./create_vault.sh || abort "Failed to set permission for create_vault.sh"
48+
else
49+
abort "Failed to find create_vault.sh!"
50+
fi
51+
fi
52+
53+
trap cleanup EXIT INT TERM
54+
55+
if [ ! -d "${KeyPath}" ]; then
56+
/bin/mkdir -p "${KeyPath}" || abort "Failed to create path ${KeyPath}"
57+
fi
58+
59+
./create_vault.sh "${OCPath}" || abort "create_vault.sh returns errors!"
60+
61+
if [ ! -f "${RootCA}" ]; then
62+
/usr/bin/openssl genrsa -out "${RootCA}" 2048 || abort "Failed to generate CA"
63+
if [ -f "${PrivKey}" ]; then
64+
echo "WARNING: Private key exists without CA"
65+
fi
66+
fi
67+
68+
/bin/rm -fP "${PrivKey}" || abort "Failed to remove ${PrivKey}"
69+
echo "Issuing a new private key..."
70+
/usr/bin/openssl req -new -x509 -key "${RootCA}" -out "${PrivKey}" -days 1825 -subj "/C=WO/L=127.0.0.1/O=Acidanthera/OU=Acidanthera OpenCore/CN=Greetings from Acidanthera and WWHC" || abort "Failed to issue private key!"
71+
72+
/bin/rm -fP "${PubKey}" || abort "Failed to remove ${PubKey}"
73+
echo "Getting public key based off private key..."
74+
./RsaTool -cert "${PrivKey}" > "${PubKey}" || abort "Failed to get public key"
75+
76+
echo "Signing ${OCBin}..."
77+
./RsaTool -sign "${OCPath}/vault.plist" "${OCPath}/vault.sig" "${PubKey}" || abort "Failed to patch ${PubKey}"
78+
79+
echo "Bin-patching ${OCBin}..."
80+
off=$(($(/usr/bin/strings -a -t d "${OCBin}" | /usr/bin/grep "=BEGIN OC VAULT=" | /usr/bin/cut -f1 -d' ') + 16))
81+
if [ "${off}" -le 16 ]; then
82+
abort "${OCBin} is borked"
83+
fi
84+
85+
/bin/dd of="${OCBin}" if="${PubKey}" bs=1 seek="${off}" count=528 conv=notrunc || abort "Failed to bin-patch ${OCBin}"
86+
87+
echo "All done!"
88+
exit 0
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
#!/bin/bash
2+
3+
# Install booter on physical disk.
4+
5+
cd "$(dirname "$0")" || exit 1
6+
7+
if [ ! -f "boot${ARCHS}" ] || [ ! -f boot0 ] || [ ! -f boot1f32 ]; then
8+
echo "Boot files are missing from this package!"
9+
echo "You probably forgot to build DuetPkg first."
10+
exit 1
11+
fi
12+
13+
diskutil list
14+
echo "Disable SIP in the case of any problems with installation!!!"
15+
echo "Enter disk number to install to:"
16+
read -r N
17+
18+
if ! diskutil info disk"${N}" | grep -q "/dev/disk"
19+
then
20+
echo Disk "$N" not found
21+
exit 1
22+
fi
23+
24+
if ! diskutil info disk"${N}"s1 | grep -q -e FAT_32 -e EFI
25+
then
26+
echo "No FAT32 partition to install"
27+
exit 1
28+
fi
29+
30+
# Write MBR
31+
sudo fdisk -uy -f boot0 /dev/rdisk"${N}" || exit 1
32+
33+
diskutil umount disk"${N}"s1
34+
sudo dd if=/dev/rdisk"${N}"s1 count=1 of=origbs
35+
cp -v boot1f32 newbs
36+
sudo dd if=origbs of=newbs skip=3 seek=3 bs=1 count=87 conv=notrunc
37+
dd if=/dev/random of=newbs skip=496 seek=496 bs=1 count=14 conv=notrunc
38+
sudo dd if=newbs of=/dev/rdisk"${N}"s1
39+
#if [[ "$(sudo diskutil mount disk"${N}"s1)" == *"mounted" ]]
40+
if sudo diskutil mount disk"${N}"s1 | grep -q mounted
41+
then
42+
cp -v "boot${ARCHS}" "$(diskutil info disk"${N}"s1 | sed -n 's/.*Mount Point: *//p')/boot"
43+
else
44+
p=/tmp/$(uuidgen)/EFI
45+
mkdir -p "${p}" || exit 1
46+
sudo mount_msdos /dev/disk"${N}"s1 "${p}" || exit 1
47+
cp -v "boot${ARCHS}" "${p}/boot" || exit 1
48+
open "${p}"
49+
fi
50+
51+
if diskutil info disk"${N}" | grep -q FDisk_partition_scheme
52+
then
53+
sudo fdisk -e /dev/rdisk"$N" <<-MAKEACTIVE
54+
p
55+
f 1
56+
w
57+
y
58+
q
59+
MAKEACTIVE
60+
fi
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
#!/bin/bash
2+
3+
cd "$(dirname "$0")" || exit 1
4+
export ARCHS=IA32
5+
source BootInstallBase.sh
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
#!/bin/bash
2+
3+
cd "$(dirname "$0")" || exit 1
4+
export ARCHS=X64
5+
source BootInstallBase.sh
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,80 @@
1+
#!/bin/bash
2+
3+
# Build QEMU image, example:
4+
# qemu-system-x86_64 -drive file=$QEMU_IMAGE/OpenCore.RO.raw -serial stdio \
5+
# -usb -device usb-kbd -device usb-mouse -s -m 8192
6+
7+
cd "$(dirname "$0")" || exit 1
8+
9+
if [ ! -f boot ] || [ ! -f boot0 ] || [ ! -f boot1f32 ]; then
10+
echo "Boot files are missing from this package!"
11+
echo "You probably forgot to build DuetPkg first."
12+
exit 1
13+
fi
14+
15+
if [ "$(which qemu-img)" = "" ]; then
16+
echo "QEMU installation missing"
17+
exit 1
18+
fi
19+
20+
if [ ! -d ROOT ]; then
21+
echo "No ROOT directory with ESP partition contents"
22+
exit 1
23+
fi
24+
25+
rm -f OpenCore.dmg.sparseimage OpenCore.RO.raw OpenCore.RO.dmg
26+
hdiutil create -size 200m -layout "UNIVERSAL HD" -type SPARSE -o OpenCore.dmg
27+
newDevice=$(hdiutil attach -nomount OpenCore.dmg.sparseimage |head -n 1 | awk '{print $1}')
28+
echo newdevice "$newDevice"
29+
30+
diskutil partitionDisk "${newDevice}" 1 MBR fat32 TEST R
31+
32+
# boot install script
33+
diskutil list
34+
N=$(echo "$newDevice" | tr -dc '0-9')
35+
echo "Will be installed to Disk ${N}"
36+
37+
38+
if [[ ! $(diskutil info disk"${N}" | sed -n 's/.*Device Node: *//p') ]]
39+
then
40+
echo Disk "$N" not found
41+
exit 1
42+
fi
43+
44+
FS=$(diskutil info disk"${N}"s1 | sed -n 's/.*File System Personality: *//p')
45+
echo "$FS"
46+
47+
if [ "$FS" != "MS-DOS FAT32" ]
48+
then
49+
echo "No FAT32 partition to install"
50+
exit 1
51+
fi
52+
53+
# Write MBR
54+
sudo fdisk -f boot0 -u /dev/rdisk"${N}"
55+
56+
diskutil umount disk"${N}"s1
57+
sudo dd if=/dev/rdisk"${N}"s1 count=1 of=origbs
58+
cp -v boot1f32 newbs
59+
sudo dd if=origbs of=newbs skip=3 seek=3 bs=1 count=87 conv=notrunc
60+
dd if=/dev/random of=newbs skip=496 seek=496 bs=1 count=14 conv=notrunc
61+
sudo dd if=newbs of=/dev/rdisk"${N}"s1
62+
diskutil mount disk"${N}"s1
63+
64+
cp -v boot "$(diskutil info disk"${N}"s1 | sed -n 's/.*Mount Point: *//p')"
65+
cp -rv ROOT/* "$(diskutil info disk"${N}"s1 | sed -n 's/.*Mount Point: *//p')"
66+
67+
if [ "$(diskutil info disk"${N}" | sed -n 's/.*Content (IOContent): *//p')" == "FDisk_partition_scheme" ]
68+
then
69+
sudo fdisk -e /dev/rdisk"$N" <<-MAKEACTIVE
70+
p
71+
f 1
72+
w
73+
y
74+
q
75+
MAKEACTIVE
76+
fi
77+
78+
hdiutil detach "$newDevice"
79+
hdiutil convert -format UDRO OpenCore.dmg.sparseimage -o OpenCore.RO.dmg
80+
qemu-img convert -f dmg -O raw OpenCore.RO.dmg OpenCore.RO.raw

Other/OC Utilities/LegacyBoot/boot0

512 Bytes
Binary file not shown.
512 Bytes
Binary file not shown.
232 KB
Binary file not shown.

Other/OC Utilities/LegacyBoot/bootX64

244 KB
Binary file not shown.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
#!/bin/sh
2+
3+
#
4+
# Copyright © 2020 Rodion Shingarev. All rights reserved.
5+
# Slight optimizations by PMheart and vit9696.
6+
#
7+
8+
if [ "$1" = "install" ]; then
9+
SELFNAME=$(basename "$0")
10+
SELFDIR=$(dirname "$0")
11+
cd "$SELFDIR" || exit 1
12+
sudo defaults write com.apple.loginwindow LogoutHook "$(pwd)/${SELFNAME}"
13+
exit 0
14+
fi
15+
16+
if [ ! -x /usr/bin/dirname ] || [ ! -x /usr/sbin/nvram ] || [ ! -x /bin/rm ] || [ ! -x /usr/sbin/diskutil ] || [ ! -x /bin/cp ] ; then
17+
abort "Unix environment is broken!"
18+
fi
19+
20+
thisDir="$(/usr/bin/dirname "${0}")"
21+
cd "${thisDir}" || abort "Failed to enter working directory!"
22+
23+
if [ ! -x ./nvramdump ]; then
24+
abort "nvramdump is not found!"
25+
fi
26+
27+
abort() {
28+
echo "Fatal error: ${1}"
29+
# echo "Fatal error: ${1}" >> error.log
30+
exit 1
31+
}
32+
33+
rm -f /tmp/nvram.plist
34+
./nvramdump || abort "failed to save nvram.plist!"
35+
36+
UUID="$(nvram 4D1FDA02-38C7-4A6A-9CC6-4BCCA8B30102:boot-path | /usr/bin/sed 's/.*GPT,\([^,]*\),.*/\1/')"
37+
if [ "$(printf '%s' "${UUID}" | /usr/bin/wc -c)" -eq 36 ] && [ -z "$(echo "${UUID}" | /usr/bin/sed 's/[-0-9A-F]//g')" ]; then
38+
/usr/sbin/diskutil mount "${UUID}" || abort "Failed to mount ${UUID}!"
39+
p="$(/usr/sbin/diskutil info "${UUID}" | /usr/bin/sed -n 's/.*Mount Point: *//p')"
40+
if ! cmp -s /tmp/nvram.plist "${p}/nvram.plist"
41+
then
42+
/bin/cp /tmp/nvram.plist "${p}/nvram.plist" || abort "Failed to copy nvram.plist!"
43+
fi
44+
/usr/sbin/diskutil unmount "${UUID}" || abort "Failed to unmount ${UUID}!"
45+
exit 0
46+
else
47+
abort "Illegal UUID or unknown loader!"
48+
fi
35.1 KB
Binary file not shown.

0 commit comments

Comments
 (0)