├── .gitattributes ├── .gitignore ├── BitmaskDecode.bat ├── BitmaskDecode.command ├── BitmaskDecode.py ├── LICENSE ├── README.md └── data.json /.gitattributes: -------------------------------------------------------------------------------- 1 | # Ensure all .bat scripts use CRLF line endings 2 | # This can prevent a number of odd batch issues 3 | *.bat text eol=crlf 4 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # Byte-compiled / optimized / DLL files 2 | __pycache__/ 3 | *.py[cod] 4 | *$py.class 5 | 6 | # C extensions 7 | *.so 8 | 9 | # Distribution / packaging 10 | .Python 11 | build/ 12 | develop-eggs/ 13 | dist/ 14 | downloads/ 15 | eggs/ 16 | .eggs/ 17 | lib/ 18 | lib64/ 19 | parts/ 20 | sdist/ 21 | var/ 22 | wheels/ 23 | pip-wheel-metadata/ 24 | share/python-wheels/ 25 | *.egg-info/ 26 | .installed.cfg 27 | *.egg 28 | MANIFEST 29 | 30 | # PyInstaller 31 | # Usually these files are written by a python script from a template 32 | # before PyInstaller builds the exe, so as to inject date/other infos into it. 33 | *.manifest 34 | *.spec 35 | 36 | # Installer logs 37 | pip-log.txt 38 | pip-delete-this-directory.txt 39 | 40 | # Unit test / coverage reports 41 | htmlcov/ 42 | .tox/ 43 | .nox/ 44 | .coverage 45 | .coverage.* 46 | .cache 47 | nosetests.xml 48 | coverage.xml 49 | *.cover 50 | *.py,cover 51 | .hypothesis/ 52 | .pytest_cache/ 53 | 54 | # Translations 55 | *.mo 56 | *.pot 57 | 58 | # Django stuff: 59 | *.log 60 | local_settings.py 61 | db.sqlite3 62 | db.sqlite3-journal 63 | 64 | # Flask stuff: 65 | instance/ 66 | .webassets-cache 67 | 68 | # Scrapy stuff: 69 | .scrapy 70 | 71 | # Sphinx documentation 72 | docs/_build/ 73 | 74 | # PyBuilder 75 | target/ 76 | 77 | # Jupyter Notebook 78 | .ipynb_checkpoints 79 | 80 | # IPython 81 | profile_default/ 82 | ipython_config.py 83 | 84 | # pyenv 85 | .python-version 86 | 87 | # pipenv 88 | # According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control. 89 | # However, in case of collaboration, if having platform-specific dependencies or dependencies 90 | # having no cross-platform support, pipenv may install dependencies that don't work, or not 91 | # install all needed dependencies. 92 | #Pipfile.lock 93 | 94 | # PEP 582; used by e.g. github.com/David-OConnor/pyflow 95 | __pypackages__/ 96 | 97 | # Celery stuff 98 | celerybeat-schedule 99 | celerybeat.pid 100 | 101 | # SageMath parsed files 102 | *.sage.py 103 | 104 | # Environments 105 | .env 106 | .venv 107 | env/ 108 | venv/ 109 | ENV/ 110 | env.bak/ 111 | venv.bak/ 112 | 113 | # Spyder project settings 114 | .spyderproject 115 | .spyproject 116 | 117 | # Rope project settings 118 | .ropeproject 119 | 120 | # mkdocs documentation 121 | /site 122 | 123 | # mypy 124 | .mypy_cache/ 125 | .dmypy.json 126 | dmypy.json 127 | 128 | # Pyre type checker 129 | .pyre/ 130 | -------------------------------------------------------------------------------- /BitmaskDecode.bat: -------------------------------------------------------------------------------- 1 | @echo off 2 | REM Get our local path before delayed expansion - allows ! in path 3 | set "thisDir=%~dp0" 4 | 5 | setlocal enableDelayedExpansion 6 | REM Setup initial vars 7 | set "script_name=" 8 | set /a tried=0 9 | set "toask=yes" 10 | set "pause_on_error=yes" 11 | set "py2v=" 12 | set "py2path=" 13 | set "py3v=" 14 | set "py3path=" 15 | set "pypath=" 16 | set "targetpy=3" 17 | 18 | REM use_py3: 19 | REM TRUE = Use if found, use py2 otherwise 20 | REM FALSE = Use py2 21 | REM FORCE = Use py3 22 | set "use_py3=TRUE" 23 | 24 | REM We'll parse if the first argument passed is 25 | REM --install-python and if so, we'll just install 26 | set "just_installing=FALSE" 27 | 28 | REM Get the system32 (or equivalent) path 29 | call :getsyspath "syspath" 30 | 31 | REM Make sure the syspath exists 32 | if "!syspath!" == "" ( 33 | if exist "%SYSTEMROOT%\system32\cmd.exe" ( 34 | if exist "%SYSTEMROOT%\system32\reg.exe" ( 35 | if exist "%SYSTEMROOT%\system32\where.exe" ( 36 | REM Fall back on the default path if it exists 37 | set "ComSpec=%SYSTEMROOT%\system32\cmd.exe" 38 | set "syspath=%SYSTEMROOT%\system32\" 39 | ) 40 | ) 41 | ) 42 | if "!syspath!" == "" ( 43 | cls 44 | echo ### ### 45 | echo # Warning # 46 | echo ### ### 47 | echo. 48 | echo Could not locate cmd.exe, reg.exe, or where.exe 49 | echo. 50 | echo Please ensure your ComSpec environment variable is properly configured and 51 | echo points directly to cmd.exe, then try again. 52 | echo. 53 | echo Current CompSpec Value: "%ComSpec%" 54 | echo. 55 | echo Press [enter] to quit. 56 | pause > nul 57 | exit /b 1 58 | ) 59 | ) 60 | 61 | if "%~1" == "--install-python" ( 62 | set "just_installing=TRUE" 63 | goto installpy 64 | ) 65 | 66 | goto checkscript 67 | 68 | :checkscript 69 | REM Check for our script first 70 | set "looking_for=!script_name!" 71 | if "!script_name!" == "" ( 72 | set "looking_for=%~n0.py or %~n0.command" 73 | set "script_name=%~n0.py" 74 | if not exist "!thisDir!\!script_name!" ( 75 | set "script_name=%~n0.command" 76 | ) 77 | ) 78 | if not exist "!thisDir!\!script_name!" ( 79 | echo Could not find !looking_for!. 80 | echo Please make sure to run this script from the same directory 81 | echo as !looking_for!. 82 | echo. 83 | echo Press [enter] to quit. 84 | pause > nul 85 | exit /b 1 86 | ) 87 | goto checkpy 88 | 89 | :checkpy 90 | call :updatepath 91 | for /f "USEBACKQ tokens=*" %%x in (`!syspath!where.exe python 2^> nul`) do ( call :checkpyversion "%%x" "py2v" "py2path" "py3v" "py3path" ) 92 | for /f "USEBACKQ tokens=*" %%x in (`!syspath!where.exe python3 2^> nul`) do ( call :checkpyversion "%%x" "py2v" "py2path" "py3v" "py3path" ) 93 | for /f "USEBACKQ tokens=*" %%x in (`!syspath!where.exe py 2^> nul`) do ( call :checkpylauncher "%%x" "py2v" "py2path" "py3v" "py3path" ) 94 | REM Walk our returns to see if we need to install 95 | if /i "!use_py3!" == "FALSE" ( 96 | set "targetpy=2" 97 | set "pypath=!py2path!" 98 | ) else if /i "!use_py3!" == "FORCE" ( 99 | set "pypath=!py3path!" 100 | ) else if /i "!use_py3!" == "TRUE" ( 101 | set "pypath=!py3path!" 102 | if "!pypath!" == "" set "pypath=!py2path!" 103 | ) 104 | if not "!pypath!" == "" ( 105 | goto runscript 106 | ) 107 | if !tried! lss 1 ( 108 | if /i "!toask!"=="yes" ( 109 | REM Better ask permission first 110 | goto askinstall 111 | ) else ( 112 | goto installpy 113 | ) 114 | ) else ( 115 | cls 116 | echo ### ### 117 | echo # Warning # 118 | echo ### ### 119 | echo. 120 | REM Couldn't install for whatever reason - give the error message 121 | echo Python is not installed or not found in your PATH var. 122 | echo Please install it from https://www.python.org/downloads/windows/ 123 | echo. 124 | echo Make sure you check the box labeled: 125 | echo. 126 | echo "Add Python X.X to PATH" 127 | echo. 128 | echo Where X.X is the py version you're installing. 129 | echo. 130 | echo Press [enter] to quit. 131 | pause > nul 132 | exit /b 1 133 | ) 134 | goto runscript 135 | 136 | :checkpylauncher 137 | REM Attempt to check the latest python 2 and 3 versions via the py launcher 138 | for /f "USEBACKQ tokens=*" %%x in (`%~1 -2 -c "import sys; print(sys.executable)" 2^> nul`) do ( call :checkpyversion "%%x" "%~2" "%~3" "%~4" "%~5" ) 139 | for /f "USEBACKQ tokens=*" %%x in (`%~1 -3 -c "import sys; print(sys.executable)" 2^> nul`) do ( call :checkpyversion "%%x" "%~2" "%~3" "%~4" "%~5" ) 140 | goto :EOF 141 | 142 | :checkpyversion 143 | set "version="&for /f "tokens=2* USEBACKQ delims= " %%a in (`"%~1" -V 2^>^&1`) do ( 144 | REM Ensure we have a version number 145 | call :isnumber "%%a" 146 | if not "!errorlevel!" == "0" goto :EOF 147 | set "version=%%a" 148 | ) 149 | if not defined version goto :EOF 150 | if "!version:~0,1!" == "2" ( 151 | REM Python 2 152 | call :comparepyversion "!version!" "!%~2!" 153 | if "!errorlevel!" == "1" ( 154 | set "%~2=!version!" 155 | set "%~3=%~1" 156 | ) 157 | ) else ( 158 | REM Python 3 159 | call :comparepyversion "!version!" "!%~4!" 160 | if "!errorlevel!" == "1" ( 161 | set "%~4=!version!" 162 | set "%~5=%~1" 163 | ) 164 | ) 165 | goto :EOF 166 | 167 | :isnumber 168 | set "var="&for /f "delims=0123456789." %%i in ("%~1") do set var=%%i 169 | if defined var (exit /b 1) 170 | exit /b 0 171 | 172 | :comparepyversion 173 | REM Exits with status 0 if equal, 1 if v1 gtr v2, 2 if v1 lss v2 174 | for /f "tokens=1,2,3 delims=." %%a in ("%~1") do ( 175 | set a1=%%a 176 | set a2=%%b 177 | set a3=%%c 178 | ) 179 | for /f "tokens=1,2,3 delims=." %%a in ("%~2") do ( 180 | set b1=%%a 181 | set b2=%%b 182 | set b3=%%c 183 | ) 184 | if not defined a1 set a1=0 185 | if not defined a2 set a2=0 186 | if not defined a3 set a3=0 187 | if not defined b1 set b1=0 188 | if not defined b2 set b2=0 189 | if not defined b3 set b3=0 190 | if %a1% gtr %b1% exit /b 1 191 | if %a1% lss %b1% exit /b 2 192 | if %a2% gtr %b2% exit /b 1 193 | if %a2% lss %b2% exit /b 2 194 | if %a3% gtr %b3% exit /b 1 195 | if %a3% lss %b3% exit /b 2 196 | exit /b 0 197 | 198 | :askinstall 199 | cls 200 | echo ### ### 201 | echo # Python Not Found # 202 | echo ### ### 203 | echo. 204 | echo Python !targetpy! was not found on the system or in the PATH var. 205 | echo. 206 | set /p "menu=Would you like to install it now? [y/n]: " 207 | if /i "!menu!"=="y" ( 208 | REM We got the OK - install it 209 | goto installpy 210 | ) else if "!menu!"=="n" ( 211 | REM No OK here... 212 | set /a tried=!tried!+1 213 | goto checkpy 214 | ) 215 | REM Incorrect answer - go back 216 | goto askinstall 217 | 218 | :installpy 219 | REM This will attempt to download and install python 220 | REM First we get the html for the python downloads page for Windows 221 | set /a tried=!tried!+1 222 | cls 223 | echo ### ### 224 | echo # Installing Python # 225 | echo ### ### 226 | echo. 227 | echo Gathering info from https://www.python.org/downloads/windows/... 228 | powershell -command "[Net.ServicePointManager]::SecurityProtocol=[Net.SecurityProtocolType]::Tls12;(new-object System.Net.WebClient).DownloadFile('https://www.python.org/downloads/windows/','%TEMP%\pyurl.txt')" 229 | REM Extract it if it's gzip compressed 230 | powershell -command "$infile='%TEMP%\pyurl.txt';$outfile='%TEMP%\pyurl.temp';try{$input=New-Object System.IO.FileStream $infile,([IO.FileMode]::Open),([IO.FileAccess]::Read),([IO.FileShare]::Read);$output=New-Object System.IO.FileStream $outfile,([IO.FileMode]::Create),([IO.FileAccess]::Write),([IO.FileShare]::None);$gzipStream=New-Object System.IO.Compression.GzipStream $input,([IO.Compression.CompressionMode]::Decompress);$buffer=New-Object byte[](1024);while($true){$read=$gzipstream.Read($buffer,0,1024);if($read -le 0){break};$output.Write($buffer,0,$read)};$gzipStream.Close();$output.Close();$input.Close();Move-Item -Path $outfile -Destination $infile -Force}catch{}" 231 | if not exist "%TEMP%\pyurl.txt" ( 232 | if /i "!just_installing!" == "TRUE" ( 233 | echo Failed to get info 234 | exit /b 1 235 | ) else ( 236 | goto checkpy 237 | ) 238 | ) 239 | echo Parsing for latest... 240 | pushd "%TEMP%" 241 | :: Version detection code slimmed by LussacZheng (https://github.com/corpnewt/gibMacOS/issues/20) 242 | for /f "tokens=9 delims=< " %%x in ('findstr /i /c:"Latest Python !targetpy! Release" pyurl.txt') do ( set "release=%%x" ) 243 | popd 244 | if "!release!" == "" ( 245 | if /i "!just_installing!" == "TRUE" ( 246 | echo Failed to get python version 247 | exit /b 1 248 | ) else ( 249 | goto checkpy 250 | ) 251 | ) 252 | echo Found Python !release! - Downloading... 253 | REM Let's delete our txt file now - we no longer need it 254 | del "%TEMP%\pyurl.txt" 255 | REM At this point - we should have the version number. 256 | REM We can build the url like so: "https://www.python.org/ftp/python/[version]/python-[version]-amd64.exe" 257 | set "url=https://www.python.org/ftp/python/!release!/python-!release!-amd64.exe" 258 | set "pytype=exe" 259 | if "!targetpy!" == "2" ( 260 | set "url=https://www.python.org/ftp/python/!release!/python-!release!.amd64.msi" 261 | set "pytype=msi" 262 | ) 263 | REM Now we download it with our slick powershell command 264 | powershell -command "[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12; (new-object System.Net.WebClient).DownloadFile('!url!','%TEMP%\pyinstall.!pytype!')" 265 | REM If it doesn't exist - we bail 266 | if not exist "%TEMP%\pyinstall.!pytype!" ( 267 | if /i "!just_installing!" == "TRUE" ( 268 | echo Failed to download installer 269 | exit /b 1 270 | ) else ( 271 | goto checkpy 272 | ) 273 | ) 274 | REM It should exist at this point - let's run it to install silently 275 | echo Installing... 276 | pushd "%TEMP%" 277 | if /i "!pytype!" == "exe" ( 278 | echo pyinstall.exe /quiet PrependPath=1 Include_test=0 Shortcuts=0 Include_launcher=0 279 | pyinstall.exe /quiet PrependPath=1 Include_test=0 Shortcuts=0 Include_launcher=0 280 | ) else ( 281 | set "foldername=!release:.=!" 282 | echo msiexec /i pyinstall.msi /qb ADDLOCAL=ALL TARGETDIR="%LocalAppData%\Programs\Python\Python!foldername:~0,2!" 283 | msiexec /i pyinstall.msi /qb ADDLOCAL=ALL TARGETDIR="%LocalAppData%\Programs\Python\Python!foldername:~0,2!" 284 | ) 285 | popd 286 | echo Installer finished with %ERRORLEVEL% status. 287 | REM Now we should be able to delete the installer and check for py again 288 | del "%TEMP%\pyinstall.!pytype!" 289 | REM If it worked, then we should have python in our PATH 290 | REM this does not get updated right away though - let's try 291 | REM manually updating the local PATH var 292 | call :updatepath 293 | if /i "!just_installing!" == "TRUE" ( 294 | echo. 295 | echo Done. 296 | ) else ( 297 | goto checkpy 298 | ) 299 | exit /b 300 | 301 | :runscript 302 | REM Python found 303 | cls 304 | set "args=%*" 305 | set "args=!args:"=!" 306 | if "!args!"=="" ( 307 | "!pypath!" "!thisDir!!script_name!" 308 | ) else ( 309 | "!pypath!" "!thisDir!!script_name!" %* 310 | ) 311 | if /i "!pause_on_error!" == "yes" ( 312 | if not "%ERRORLEVEL%" == "0" ( 313 | echo. 314 | echo Script exited with error code: %ERRORLEVEL% 315 | echo. 316 | echo Press [enter] to exit... 317 | pause > nul 318 | ) 319 | ) 320 | goto :EOF 321 | 322 | :undouble 323 | REM Helper function to strip doubles of a single character out of a string recursively 324 | set "string_value=%~2" 325 | :undouble_continue 326 | set "check=!string_value:%~3%~3=%~3!" 327 | if not "!check!" == "!string_value!" ( 328 | set "string_value=!check!" 329 | goto :undouble_continue 330 | ) 331 | set "%~1=!check!" 332 | goto :EOF 333 | 334 | :updatepath 335 | set "spath=" 336 | set "upath=" 337 | for /f "USEBACKQ tokens=2* delims= " %%i in (`!syspath!reg.exe query "HKCU\Environment" /v "Path" 2^> nul`) do ( if not "%%j" == "" set "upath=%%j" ) 338 | for /f "USEBACKQ tokens=2* delims= " %%i in (`!syspath!reg.exe query "HKLM\SYSTEM\CurrentControlSet\Control\Session Manager\Environment" /v "Path" 2^> nul`) do ( if not "%%j" == "" set "spath=%%j" ) 339 | if not "%spath%" == "" ( 340 | REM We got something in the system path 341 | set "PATH=%spath%" 342 | if not "%upath%" == "" ( 343 | REM We also have something in the user path 344 | set "PATH=%PATH%;%upath%" 345 | ) 346 | ) else if not "%upath%" == "" ( 347 | set "PATH=%upath%" 348 | ) 349 | REM Remove double semicolons from the adjusted PATH 350 | call :undouble "PATH" "%PATH%" ";" 351 | goto :EOF 352 | 353 | :getsyspath 354 | REM Helper method to return a valid path to cmd.exe, reg.exe, and where.exe by 355 | REM walking the ComSpec var - will also repair it in memory if need be 356 | REM Strip double semi-colons 357 | call :undouble "temppath" "%ComSpec%" ";" 358 | 359 | REM Dirty hack to leverage the "line feed" approach - there are some odd side 360 | REM effects with this. Do not use this variable name in comments near this 361 | REM line - as it seems to behave erradically. 362 | (set LF=^ 363 | %=this line is empty=% 364 | ) 365 | REM Replace instances of semi-colons with a line feed and wrap 366 | REM in parenthesis to work around some strange batch behavior 367 | set "testpath=%temppath:;=!LF!%" 368 | 369 | REM Let's walk each path and test if cmd.exe, reg.exe, and where.exe exist there 370 | set /a found=0 371 | for /f "tokens=* delims=" %%i in ("!testpath!") do ( 372 | REM Only continue if we haven't found it yet 373 | if not "%%i" == "" ( 374 | if !found! lss 1 ( 375 | set "checkpath=%%i" 376 | REM Remove "cmd.exe" from the end if it exists 377 | if /i "!checkpath:~-7!" == "cmd.exe" ( 378 | set "checkpath=!checkpath:~0,-7!" 379 | ) 380 | REM Pad the end with a backslash if needed 381 | if not "!checkpath:~-1!" == "\" ( 382 | set "checkpath=!checkpath!\" 383 | ) 384 | REM Let's see if cmd, reg, and where exist there - and set it if so 385 | if EXIST "!checkpath!cmd.exe" ( 386 | if EXIST "!checkpath!reg.exe" ( 387 | if EXIST "!checkpath!where.exe" ( 388 | set /a found=1 389 | set "ComSpec=!checkpath!cmd.exe" 390 | set "%~1=!checkpath!" 391 | ) 392 | ) 393 | ) 394 | ) 395 | ) 396 | ) 397 | goto :EOF 398 | -------------------------------------------------------------------------------- /BitmaskDecode.command: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | # Get the curent directory, the script name 4 | # and the script name with "py" substituted for the extension. 5 | args=( "$@" ) 6 | dir="$(cd -- "$(dirname "$0")" >/dev/null 2>&1; pwd -P)" 7 | script="${0##*/}" 8 | target="${script%.*}.py" 9 | 10 | # use_py3: 11 | # TRUE = Use if found, use py2 otherwise 12 | # FALSE = Use py2 13 | # FORCE = Use py3 14 | use_py3="TRUE" 15 | 16 | # We'll parse if the first argument passed is 17 | # --install-python and if so, we'll just install 18 | just_installing="FALSE" 19 | 20 | tempdir="" 21 | 22 | compare_to_version () { 23 | # Compares our OS version to the passed OS version, and 24 | # return a 1 if we match the passed compare type, or a 0 if we don't. 25 | # $1 = 0 (equal), 1 (greater), 2 (less), 3 (gequal), 4 (lequal) 26 | # $2 = OS version to compare ours to 27 | if [ -z "$1" ] || [ -z "$2" ]; then 28 | # Missing info - bail. 29 | return 30 | fi 31 | local current_os= comp= 32 | current_os="$(sw_vers -productVersion)" 33 | comp="$(vercomp "$current_os" "$2")" 34 | # Check gequal and lequal first 35 | if [[ "$1" == "3" && ("$comp" == "1" || "$comp" == "0") ]] || [[ "$1" == "4" && ("$comp" == "2" || "$comp" == "0") ]] || [[ "$comp" == "$1" ]]; then 36 | # Matched 37 | echo "1" 38 | else 39 | # No match 40 | echo "0" 41 | fi 42 | } 43 | 44 | set_use_py3_if () { 45 | # Auto sets the "use_py3" variable based on 46 | # conditions passed 47 | # $1 = 0 (equal), 1 (greater), 2 (less), 3 (gequal), 4 (lequal) 48 | # $2 = OS version to compare 49 | # $3 = TRUE/FALSE/FORCE in case of match 50 | if [ -z "$1" ] || [ -z "$2" ] || [ -z "$3" ]; then 51 | # Missing vars - bail with no changes. 52 | return 53 | fi 54 | if [ "$(compare_to_version "$1" "$2")" == "1" ]; then 55 | use_py3="$3" 56 | fi 57 | } 58 | 59 | get_remote_py_version () { 60 | local pyurl= py_html= py_vers= py_num="3" 61 | pyurl="https://www.python.org/downloads/macos/" 62 | py_html="$(curl -L $pyurl --compressed 2>&1)" 63 | if [ -z "$use_py3" ]; then 64 | use_py3="TRUE" 65 | fi 66 | if [ "$use_py3" == "FALSE" ]; then 67 | py_num="2" 68 | fi 69 | py_vers="$(echo "$py_html" | grep -i "Latest Python $py_num Release" | awk '{print $8}' | cut -d'<' -f1)" 70 | echo "$py_vers" 71 | } 72 | 73 | download_py () { 74 | local vers="$1" url= 75 | clear 76 | echo " ### ###" 77 | echo " # Downloading Python #" 78 | echo "### ###" 79 | echo 80 | if [ -z "$vers" ]; then 81 | echo "Gathering latest version..." 82 | vers="$(get_remote_py_version)" 83 | fi 84 | if [ -z "$vers" ]; then 85 | # Didn't get it still - bail 86 | print_error 87 | fi 88 | echo "Located Version: $vers" 89 | echo 90 | echo "Building download url..." 91 | url="$(curl -L https://www.python.org/downloads/release/python-${vers//./}/ --compressed 2>&1 | grep -iE "python-$vers-macos.*.pkg\"" | awk -F'"' '{ print $2 }')" 92 | if [ -z "$url" ]; then 93 | # Couldn't get the URL - bail 94 | print_error 95 | fi 96 | echo " - $url" 97 | echo 98 | echo "Downloading..." 99 | echo 100 | # Create a temp dir and download to it 101 | tempdir="$(mktemp -d 2>/dev/null || mktemp -d -t 'tempdir')" 102 | curl "$url" -o "$tempdir/python.pkg" 103 | if [ "$?" != "0" ]; then 104 | echo 105 | echo " - Failed to download python installer!" 106 | echo 107 | exit $? 108 | fi 109 | echo 110 | echo "Running python install package..." 111 | echo 112 | sudo installer -pkg "$tempdir/python.pkg" -target / 113 | if [ "$?" != "0" ]; then 114 | echo 115 | echo " - Failed to install python!" 116 | echo 117 | exit $? 118 | fi 119 | # Now we expand the package and look for a shell update script 120 | pkgutil --expand "$tempdir/python.pkg" "$tempdir/python" 121 | if [ -e "$tempdir/python/Python_Shell_Profile_Updater.pkg/Scripts/postinstall" ]; then 122 | # Run the script 123 | echo 124 | echo "Updating PATH..." 125 | echo 126 | "$tempdir/python/Python_Shell_Profile_Updater.pkg/Scripts/postinstall" 127 | fi 128 | vers_folder="Python $(echo "$vers" | cut -d'.' -f1 -f2)" 129 | if [ -f "/Applications/$vers_folder/Install Certificates.command" ]; then 130 | # Certs script exists - let's execute that to make sure our certificates are updated 131 | echo 132 | echo "Updating Certificates..." 133 | echo 134 | "/Applications/$vers_folder/Install Certificates.command" 135 | fi 136 | echo 137 | echo "Cleaning up..." 138 | cleanup 139 | echo 140 | if [ "$just_installing" == "TRUE" ]; then 141 | echo "Done." 142 | else 143 | # Now we check for py again 144 | echo "Rechecking py..." 145 | downloaded="TRUE" 146 | clear 147 | main 148 | fi 149 | } 150 | 151 | cleanup () { 152 | if [ -d "$tempdir" ]; then 153 | rm -Rf "$tempdir" 154 | fi 155 | } 156 | 157 | print_error() { 158 | clear 159 | cleanup 160 | echo " ### ###" 161 | echo " # Python Not Found #" 162 | echo "### ###" 163 | echo 164 | echo "Python is not installed or not found in your PATH var." 165 | echo 166 | if [ "$kernel" == "Darwin" ]; then 167 | echo "Please go to https://www.python.org/downloads/macos/ to" 168 | echo "download and install the latest version, then try again." 169 | else 170 | echo "Please install python through your package manager and" 171 | echo "try again." 172 | fi 173 | echo 174 | exit 1 175 | } 176 | 177 | print_target_missing() { 178 | clear 179 | cleanup 180 | echo " ### ###" 181 | echo " # Target Not Found #" 182 | echo "### ###" 183 | echo 184 | echo "Could not locate $target!" 185 | echo 186 | exit 1 187 | } 188 | 189 | format_version () { 190 | local vers="$1" 191 | echo "$(echo "$1" | awk -F. '{ printf("%d%03d%03d%03d\n", $1,$2,$3,$4); }')" 192 | } 193 | 194 | vercomp () { 195 | # Modified from: https://apple.stackexchange.com/a/123408/11374 196 | local ver1="$(format_version "$1")" ver2="$(format_version "$2")" 197 | if [ $ver1 -gt $ver2 ]; then 198 | echo "1" 199 | elif [ $ver1 -lt $ver2 ]; then 200 | echo "2" 201 | else 202 | echo "0" 203 | fi 204 | } 205 | 206 | get_local_python_version() { 207 | # $1 = Python bin name (defaults to python3) 208 | # Echoes the path to the highest version of the passed python bin if any 209 | local py_name="$1" max_version= python= python_version= python_path= 210 | if [ -z "$py_name" ]; then 211 | py_name="python3" 212 | fi 213 | py_list="$(which -a "$py_name" 2>/dev/null)" 214 | # Walk that newline separated list 215 | while read python; do 216 | if [ -z "$python" ]; then 217 | # Got a blank line - skip 218 | continue 219 | fi 220 | if [ "$check_py3_stub" == "1" ] && [ "$python" == "/usr/bin/python3" ]; then 221 | # See if we have a valid developer path 222 | xcode-select -p > /dev/null 2>&1 223 | if [ "$?" != "0" ]; then 224 | # /usr/bin/python3 path - but no valid developer dir 225 | continue 226 | fi 227 | fi 228 | python_version="$(get_python_version $python)" 229 | if [ -z "$python_version" ]; then 230 | # Didn't find a py version - skip 231 | continue 232 | fi 233 | # Got the py version - compare to our max 234 | if [ -z "$max_version" ] || [ "$(vercomp "$python_version" "$max_version")" == "1" ]; then 235 | # Max not set, or less than the current - update it 236 | max_version="$python_version" 237 | python_path="$python" 238 | fi 239 | done <<< "$py_list" 240 | echo "$python_path" 241 | } 242 | 243 | get_python_version() { 244 | local py_path="$1" py_version= 245 | # Get the python version by piping stderr into stdout (for py2), then grepping the output for 246 | # the word "python", getting the second element, and grepping for an alphanumeric version number 247 | py_version="$($py_path -V 2>&1 | grep -i python | cut -d' ' -f2 | grep -E "[A-Za-z\d\.]+")" 248 | if [ ! -z "$py_version" ]; then 249 | echo "$py_version" 250 | fi 251 | } 252 | 253 | prompt_and_download() { 254 | if [ "$downloaded" != "FALSE" ] || [ "$kernel" != "Darwin" ]; then 255 | # We already tried to download, or we're not on macOS - just bail 256 | print_error 257 | fi 258 | clear 259 | echo " ### ###" 260 | echo " # Python Not Found #" 261 | echo "### ###" 262 | echo 263 | target_py="Python 3" 264 | printed_py="Python 2 or 3" 265 | if [ "$use_py3" == "FORCE" ]; then 266 | printed_py="Python 3" 267 | elif [ "$use_py3" == "FALSE" ]; then 268 | target_py="Python 2" 269 | printed_py="Python 2" 270 | fi 271 | echo "Could not locate $printed_py!" 272 | echo 273 | echo "This script requires $printed_py to run." 274 | echo 275 | while true; do 276 | read -p "Would you like to install the latest $target_py now? (y/n): " yn 277 | case $yn in 278 | [Yy]* ) download_py;break;; 279 | [Nn]* ) print_error;; 280 | esac 281 | done 282 | } 283 | 284 | main() { 285 | local python= version= 286 | # Verify our target exists 287 | if [ ! -f "$dir/$target" ]; then 288 | # Doesn't exist 289 | print_target_missing 290 | fi 291 | if [ -z "$use_py3" ]; then 292 | use_py3="TRUE" 293 | fi 294 | if [ "$use_py3" != "FALSE" ]; then 295 | # Check for py3 first 296 | python="$(get_local_python_version python3)" 297 | fi 298 | if [ "$use_py3" != "FORCE" ] && [ -z "$python" ]; then 299 | # We aren't using py3 explicitly, and we don't already have a path 300 | python="$(get_local_python_version python2)" 301 | if [ -z "$python" ]; then 302 | # Try just looking for "python" 303 | python="$(get_local_python_version python)" 304 | fi 305 | fi 306 | if [ -z "$python" ]; then 307 | # Didn't ever find it - prompt 308 | prompt_and_download 309 | return 1 310 | fi 311 | # Found it - start our script and pass all args 312 | "$python" "$dir/$target" "${args[@]}" 313 | } 314 | 315 | # Keep track of whether or not we're on macOS to determine if 316 | # we can download and install python for the user as needed. 317 | kernel="$(uname -s)" 318 | # Check to see if we need to force based on 319 | # macOS version. 10.15 has a dummy python3 version 320 | # that can trip up some py3 detection in other scripts. 321 | # set_use_py3_if "3" "10.15" "FORCE" 322 | downloaded="FALSE" 323 | # Check for the aforementioned /usr/bin/python3 stub if 324 | # our OS version is 10.15 or greater. 325 | check_py3_stub="$(compare_to_version "3" "10.15")" 326 | trap cleanup EXIT 327 | if [ "$1" == "--install-python" ] && [ "$kernel" == "Darwin" ]; then 328 | just_installing="TRUE" 329 | download_py 330 | else 331 | main 332 | fi 333 | -------------------------------------------------------------------------------- /BitmaskDecode.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | import sys, os, re, json 3 | if 2/3==0: input=raw_input 4 | 5 | # Load our settings 6 | os.chdir(os.path.dirname(os.path.realpath(__file__))) 7 | data_file = "data.json" 8 | if not os.path.exists(data_file): 9 | print("Could not locate {} - aborting!".format(data_file)) 10 | print("") 11 | input("Press [enter] to exit...") 12 | exit() 13 | try: 14 | data_list = json.load(open(data_file)) 15 | assert isinstance(data_list,list) 16 | except Exception as e: 17 | print("Could not load {}, or the data was not a list - aborting!".format(data_file)) 18 | if len(str(e)): print(" - {}".format(str(e))) 19 | print("") 20 | input("Press [enter] to exit...") 21 | exit() 22 | 23 | def cls(): 24 | os.system('cls' if os.name=='nt' else 'clear') 25 | 26 | def get_binstr(number,block=8): 27 | dec = get_decimal(number) 28 | binstr = "{0:08b}".format(dec) 29 | if block == 0: return binstr # Not breaking into chunks 30 | # Format into chunks separated by space 31 | if len(binstr)%block: binstr = "0"*(block-(len(binstr)%block))+binstr 32 | return " ".join([binstr[i:i+block] for i in range(0, len(binstr), block)]) 33 | 34 | def get_str_rep(number,show_hex=True,show_dec=True,show_bin=False,bin_block=8): 35 | dec = get_decimal(number) 36 | str_rep = "" 37 | if show_hex: str_rep += "0x{} ".format(hex(dec)[2:].upper()) 38 | if show_dec: str_rep += "({:,}) ".format(dec) 39 | if show_bin: str_rep += "[{}] ".format(get_binstr(dec,bin_block)) 40 | return str_rep 41 | 42 | def get_decimal(number): 43 | if isinstance(number,(float,int)): return number 44 | try: return int(number,16) if str(number).lower().startswith("0x") else int(number.replace(",","")) 45 | except: return 0 46 | 47 | def num_to_vals(number,bit_dict): 48 | # Convert the hex to decimal string - then start with a reversed list 49 | # and find out which values we have enabled 50 | dec = get_decimal(number) 51 | if not dec: return [] 52 | return [(bit_dict[x],get_str_rep(x)) for x in sorted(bit_dict) if x & dec] 53 | 54 | def main(self_name,bit_dict): 55 | while True: 56 | cls() 57 | print("# {} Decode #".format(self_name)) 58 | print("") 59 | print("1. Number To Values") 60 | print("2. Values to Number") 61 | print("") 62 | print("M. Return To Selection Menu") 63 | print("Q. Quit") 64 | print("") 65 | menu = input("Please select an option: ").lower() 66 | if not len(menu): 67 | continue 68 | if menu == "q": 69 | exit() 70 | elif menu == "m": 71 | return 72 | elif menu == "1": 73 | n_to_v(self_name,bit_dict) 74 | elif menu == "2": 75 | v_to_n(self_name,bit_dict) 76 | 77 | def n_to_v(self_name,bit_dict): 78 | cls() 79 | print("# {} Number To Values #".format(self_name)) 80 | print("") 81 | print("M. Main Menu") 82 | print("Q. Quit") 83 | print("") 84 | while True: 85 | h = input("Please type a {} value (use 0x prefix for hex): ".format(self_name)) 86 | if not h: continue 87 | if h.lower() == "m": return 88 | elif h.lower() == "q": exit() 89 | has = num_to_vals(h,bit_dict) 90 | if not len(has): print("\nNo values found.\n") 91 | else: 92 | pad_to = max((len(x[0]) for x in has)) 93 | print("\nActive values for {}:\n\n{}\n".format(get_str_rep(h),"\n".join(["{} - {}".format(x[0].ljust(pad_to),x[1]) for x in has]))) 94 | 95 | def v_to_n(self_name,bit_dict): 96 | # Create a dict with all values unchecked 97 | toggle_list = [{"value":x,"enabled":False,"name":bit_dict[x]} for x in sorted(bit_dict)] 98 | while True: 99 | cls() 100 | print("# {} Values To Number #".format(self_name)) 101 | print("") 102 | # Print them out 103 | if not len(toggle_list): print(" - None found :(") 104 | else: 105 | pad_to = max((len(x["name"]) for x in toggle_list)) 106 | for x,y in enumerate(toggle_list,1): 107 | print("[{}] {}. {} - {}".format("#" if y["enabled"] else " ", str(x).rjust(2), y["name"].ljust(pad_to),get_str_rep(y["value"]))) 108 | print("") 109 | # Add the values of the enabled together 110 | curr = sum([x["value"] for x in toggle_list if x["enabled"]]) 111 | print("Current: {}".format(get_str_rep(curr))) 112 | print("") 113 | print("A. Select All") 114 | print("N. Select None") 115 | print("M. Main Menu") 116 | print("Q. Quit") 117 | print("") 118 | print("Select options to toggle with comma-delimited lists (eg. 1,2,3,4,5)") 119 | print("") 120 | menu = input("Please make your selection: ").lower() 121 | if not len(menu): continue 122 | if menu == "m": return 123 | elif menu == "q": exit() 124 | elif menu == "a": 125 | for x in toggle_list: x["enabled"] = True 126 | continue 127 | elif menu == "n": 128 | for x in toggle_list: x["enabled"] = False 129 | continue 130 | # Should be numbers 131 | try: 132 | nums = [int(x) for x in menu.replace(" ","").split(",")] 133 | for x in nums: 134 | if not 0 < x <= len(toggle_list): continue 135 | toggle_list[x-1]["enabled"] ^= True 136 | except: continue 137 | 138 | def top_menu(): 139 | # Let's load the data file and serve up the options 140 | while True: 141 | cls() 142 | print("# Select The Value To Decode #") 143 | print("") 144 | # Print them out 145 | if not len(data_list): print(" - None found :(") 146 | else: 147 | for x,y in enumerate(data_list,1): 148 | print("{}. {}".format(str(x).rjust(2), y.get("name","Unknown"))) 149 | print("") 150 | print("Q. Quit") 151 | print("") 152 | menu = input("Please select an option: ").lower() 153 | if not len(menu): continue 154 | if menu == "q": exit() 155 | try: menu = int(menu) 156 | except: continue 157 | if not 0 < menu <= len(data_list): continue 158 | # Should have a valid entry here 159 | selected = data_list[menu-1] 160 | bit_dict = {} 161 | self_name = selected.get("name","Unknown") 162 | # Build a dict with the keys being the addresses, and the values being the names 163 | for x in selected.get("values",[]): 164 | if not all((y in x for y in ("value","name"))): continue # Malformed 165 | try: key = int(x["value"],16 if selected.get("is_hex",False) else 10) 166 | except: continue 167 | bit_dict[key] = x["name"] 168 | main(self_name,bit_dict) 169 | 170 | if __name__ == '__main__': 171 | top_menu() 172 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2020 CorpNewt 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # BitmaskDecode 2 | Python script to help demystify a number of known bitmasks. 3 | -------------------------------------------------------------------------------- /data.json: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "name": "CsrActiveConfig", 4 | "values": [ 5 | { 6 | "name": "CSR_ALLOW_UNTRUSTED_KEXTS", 7 | "value": "0x1" 8 | }, 9 | { 10 | "name": "CSR_ALLOW_UNRESTRICTED_FS", 11 | "value": "0x2" 12 | }, 13 | { 14 | "name": "CSR_ALLOW_TASK_FOR_PID", 15 | "value": "0x4" 16 | }, 17 | { 18 | "name": "CSR_ALLOW_KERNEL_DEBUGGER", 19 | "value": "0x8" 20 | }, 21 | { 22 | "name": "CSR_ALLOW_APPLE_INTERNAL", 23 | "value": "0x10" 24 | }, 25 | { 26 | "name": "CSR_ALLOW_UNRESTRICTED_DTRACE", 27 | "value": "0x20" 28 | }, 29 | { 30 | "name": "CSR_ALLOW_UNRESTRICTED_NVRAM", 31 | "value": "0x40" 32 | }, 33 | { 34 | "name": "CSR_ALLOW_DEVICE_CONFIGURATION", 35 | "value": "0x80" 36 | }, 37 | { 38 | "name": "CSR_ALLOW_ANY_RECOVERY_OS", 39 | "value": "0x100" 40 | }, 41 | { 42 | "name": "CSR_ALLOW_UNAPPROVED_KEXTS", 43 | "value": "0x200" 44 | }, 45 | { 46 | "name": "CSR_ALLOW_EXECUTABLE_POLICY_OVERRIDE", 47 | "value": "0x400" 48 | }, 49 | { 50 | "name": "CSR_ALLOW_UNAUTHENTICATED_ROOT", 51 | "value": "0x800" 52 | } 53 | ], 54 | "is_hex": true 55 | }, 56 | { 57 | "name": "PickerAttributes", 58 | "values": [ 59 | { 60 | "name": "OC_ATTR_USE_VOLUME_ICON", 61 | "value": "0x1" 62 | }, 63 | { 64 | "name": "OC_ATTR_USE_DISK_LABEL_FILE", 65 | "value": "0x2" 66 | }, 67 | { 68 | "name": "OC_ATTR_USE_GENERIC_LABEL_IMAGE", 69 | "value": "0x4" 70 | }, 71 | { 72 | "name": "OC_ATTR_HIDE_THEMED_ICONS", 73 | "value": "0x8" 74 | }, 75 | { 76 | "name": "OC_ATTR_USE_POINTER_CONTROL", 77 | "value": "0x10" 78 | }, 79 | { 80 | "name": "OC_ATTR_SHOW_DEBUG_DISPLAY", 81 | "value": "0x20" 82 | }, 83 | { 84 | "name": "OC_ATTR_USE_MINIMAL_UI", 85 | "value": "0x40" 86 | }, 87 | { 88 | "name": "OC_ATTR_USE_FLAVOUR_ICON", 89 | "value": "0x80" 90 | }, 91 | { 92 | "name": "OC_ATTR_USE_REVERSED_UI", 93 | "value": "0x100" 94 | }, 95 | { 96 | "name": "OC_ATTR_REDUCE_MOTION", 97 | "value": "0x200" 98 | } 99 | ], 100 | "is_hex": true 101 | }, 102 | { 103 | "name": "DisplayLevel", 104 | "values": [ 105 | { 106 | "name": "DEBUG_WARN in DEBUG, NOOPT, RELEASE", 107 | "value": "0x2" 108 | }, 109 | { 110 | "name": "DEBUG_INFO in DEBUG, NOOPT", 111 | "value": "0x40" 112 | }, 113 | { 114 | "name": "DEBUG_VERBOSE in custom builds", 115 | "value": "0x400000" 116 | }, 117 | { 118 | "name": "DEBUG_ERROR in DEBUG, NOOPT, RELEASE", 119 | "value": "0x80000000" 120 | } 121 | ], 122 | "is_hex": true 123 | }, 124 | { 125 | "name": "Target", 126 | "values": [ 127 | { 128 | "name": "Enable Logging", 129 | "value": "0x1" 130 | }, 131 | { 132 | "name": "Enable basic console (onscreen) logging", 133 | "value": "0x2" 134 | }, 135 | { 136 | "name": "Enable logging to Data Hub", 137 | "value": "0x4" 138 | }, 139 | { 140 | "name": "Enable serial port logging", 141 | "value": "0x8" 142 | }, 143 | { 144 | "name": "Enable UEFI variable logging", 145 | "value": "0x10" 146 | }, 147 | { 148 | "name": "Enable non-volatile UEFI variable logging", 149 | "value": "0x20" 150 | }, 151 | { 152 | "name": "Enable logging to file", 153 | "value": "0x40" 154 | }, 155 | { 156 | "name": "In combination with 0x40, enable faster but unsafe file logging", 157 | "value": "0x80" 158 | } 159 | ], 160 | "is_hex": true 161 | }, 162 | { 163 | "name": "ExposeSensitiveData", 164 | "values": [ 165 | { 166 | "name": "Expose printable booter path as UEFI variable", 167 | "value": "0x1" 168 | }, 169 | { 170 | "name": "Expose OpenCore version as UEFI variable", 171 | "value": "0x2" 172 | }, 173 | { 174 | "name": "Expose OpenCore version in boot picker menu title", 175 | "value": "0x4" 176 | }, 177 | { 178 | "name": "Expose OEM information as a set of UEFI variables", 179 | "value": "0x8" 180 | } 181 | ], 182 | "is_hex": true 183 | }, 184 | { 185 | "name": "ScanPolicy", 186 | "values": [ 187 | { 188 | "name": "OC_SCAN_FILE_SYSTEM_LOCK", 189 | "value": "0x1" 190 | }, 191 | { 192 | "name": "OC_SCAN_DEVICE_LOCK", 193 | "value": "0x2" 194 | }, 195 | { 196 | "name": "OC_SCAN_ALLOW_FS_APFS", 197 | "value": "0x100" 198 | }, 199 | { 200 | "name": "OC_SCAN_ALLOW_FS_HFS", 201 | "value": "0x200" 202 | }, 203 | { 204 | "name": "OC_SCAN_ALLOW_FS_ESP", 205 | "value": "0x400" 206 | }, 207 | { 208 | "name": "OC_SCAN_ALLOW_FS_NTFS", 209 | "value": "0x800" 210 | }, 211 | { 212 | "name": "OC_SCAN_ALLOW_FS_LINUX_ROOT", 213 | "value": "0x1000" 214 | }, 215 | { 216 | "name": "OC_SCAN_ALLOW_FS_LINUX_DATA", 217 | "value": "0x2000" 218 | }, 219 | { 220 | "name": "OC_SCAN_ALLOW_FS_XBOOTLDR", 221 | "value": "0x4000" 222 | }, 223 | { 224 | "name": "OC_SCAN_ALLOW_DEVICE_SATA", 225 | "value": "0x10000" 226 | }, 227 | { 228 | "name": "OC_SCAN_ALLOW_DEVICE_SASEX", 229 | "value": "0x20000" 230 | }, 231 | { 232 | "name": "OC_SCAN_ALLOW_DEVICE_SCSI", 233 | "value": "0x40000" 234 | }, 235 | { 236 | "name": "OC_SCAN_ALLOW_DEVICE_NVME", 237 | "value": "0x80000" 238 | }, 239 | { 240 | "name": "OC_SCAN_ALLOW_DEVICE_ATAPI", 241 | "value": "0x100000" 242 | }, 243 | { 244 | "name": "OC_SCAN_ALLOW_DEVICE_USB", 245 | "value": "0x200000" 246 | }, 247 | { 248 | "name": "OC_SCAN_ALLOW_DEVICE_FIREWIRE", 249 | "value": "0x400000" 250 | }, 251 | { 252 | "name": "OC_SCAN_ALLOW_DEVICE_SDCARD", 253 | "value": "0x800000" 254 | }, 255 | { 256 | "name": "OC_SCAN_ALLOW_DEVICE_PCI", 257 | "value": "0x1000000" 258 | } 259 | ], 260 | "is_hex": true 261 | }, 262 | { 263 | "name": "StartupPowerEvents", 264 | "values": [ 265 | { 266 | "name": "Shutdown cause was a PWROK event (GEN_PMCON_2 bit 0)", 267 | "value": "0x1" 268 | }, 269 | { 270 | "name": "Shutdown cause was a SYS_PWROK event (GEN_PMCON_2 bit 1)", 271 | "value": "0x2" 272 | }, 273 | { 274 | "name": "Shutdown cause was a THRMTRIP# event (GEN_PMCON_2 bit 3)", 275 | "value": "0x4" 276 | }, 277 | { 278 | "name": "Rebooted due to a SYS_RESET# event (GEN_PMCON_2 bit 4)", 279 | "value": "0x8" 280 | }, 281 | { 282 | "name": "Power Failure (GEN_PMCON_3 bit 1, PWR_FLR)", 283 | "value": "0x10" 284 | }, 285 | { 286 | "name": "Loss of RTC Well Power (GEN_PMCON_3 bit 2, RTC_PWR_STS)", 287 | "value": "0x20" 288 | }, 289 | { 290 | "name": "General Reset Status (GEN_PMCON_3 bit 9, GEN_RST_STS)", 291 | "value": "0x40" 292 | }, 293 | { 294 | "name": "SUS Well Power Loss - 0xffffff80 (GEN_PMCON_3 bit 14)", 295 | "value": "0xFFFFFF80" 296 | }, 297 | { 298 | "name": "ME Wake Event (PRSTS bit 0, ME_WAKE_STS)", 299 | "value": "0x10000" 300 | }, 301 | { 302 | "name": "ME Cold Reboot (PRSTS bit 1, ME_HRST_COLD_STS)", 303 | "value": "0x20000" 304 | }, 305 | { 306 | "name": "ME Warm Reboot (PRSTS bit 2, ME_HRST_WARM_STS)", 307 | "value": "0x40000" 308 | }, 309 | { 310 | "name": "ME Shutdown (PRSTS bit 3, ME_HOST_PWRDN)", 311 | "value": "0x80000" 312 | }, 313 | { 314 | "name": "Global reset ME Watchdog Timer (PRSTS bit 6)", 315 | "value": "0x100000" 316 | }, 317 | { 318 | "name": "Global reset PowerManagement Watchdog Timer (PRSTS bit 15)", 319 | "value": "0x200000" 320 | } 321 | ], 322 | "is_hex": true 323 | }, 324 | { 325 | "name": "Memory TypeDetail", 326 | "values": [ 327 | { 328 | "name": "Reserved, set to 0", 329 | "value": "0x1" 330 | }, 331 | { 332 | "name": "Other", 333 | "value": "0x2" 334 | }, 335 | { 336 | "name": "Unknown", 337 | "value": "0x4" 338 | }, 339 | { 340 | "name": "Fast-paged", 341 | "value": "0x8" 342 | }, 343 | { 344 | "name": "Static column", 345 | "value": "0x10" 346 | }, 347 | { 348 | "name": "Pseudo-static", 349 | "value": "0x20" 350 | }, 351 | { 352 | "name": "RAMBUS", 353 | "value": "0x40" 354 | }, 355 | { 356 | "name": "Synchronous", 357 | "value": "0x80" 358 | }, 359 | { 360 | "name": "CMOS", 361 | "value": "0x100" 362 | }, 363 | { 364 | "name": "EDO", 365 | "value": "0x200" 366 | }, 367 | { 368 | "name": "Window DRAM", 369 | "value": "0x400" 370 | }, 371 | { 372 | "name": "Cache DRAM", 373 | "value": "0x800" 374 | }, 375 | { 376 | "name": "Non-volatile", 377 | "value": "0x1000" 378 | }, 379 | { 380 | "name": "Registered (Buffered)", 381 | "value": "0x2000" 382 | }, 383 | { 384 | "name": "Unbuffred (Unregistered)", 385 | "value": "0x4000" 386 | }, 387 | { 388 | "name": "Reserved, set to 0", 389 | "value": "0x8000" 390 | } 391 | ], 392 | "is_hex": true 393 | } 394 | ] 395 | --------------------------------------------------------------------------------