Last active
May 21, 2020 11:03
-
-
Save CodeAsm/5fd79e6bdbc43838c5cf67eeaf1884d0 to your computer and use it in GitHub Desktop.
testing for dev kernel on xbox or not, use nxdk, based on Luke Ushers code example and nxdk hello sample.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <hal/debug.h> | |
#include <hal/video.h> | |
#include <hal/xbox.h> | |
#include <nxdk/mount.h> | |
#include <windows.h> | |
#include <stdio.h> | |
#include <string.h> | |
int main(void) | |
{ | |
XVideoSetMode(640, 480, 32, REFRESH_DEFAULT); | |
debugPrint("Insignia Setup Assistant\n"); | |
// Hardware Detection (Retail vs Debug bios) | |
if (XboxHardwareInfo.Flags & XBOX_HW_FLAG_DEVKIT_KERNEL) { | |
debugPrint("\nDebug Bios Detected\n"); | |
debugPrint("Patching XboxHardwareInfo to retail mode.\n"); | |
debugPrint("Please note that this is temporary.\n"); | |
debugPrint("You WILL need to re-run this program after rebooting.\n"); | |
XboxHardwareInfo.Flags &= ~XBOX_HW_FLAG_DEVKIT_KERNEL; | |
} | |
// Sanity check: Make sure the HDD key is not all zeroes | |
int valid_hdd_key = 0; | |
for(int i = 0; i < 16; i++) { | |
if (XboxHDKey[i] != 0) { | |
valid_hdd_key = 1; | |
break; | |
} | |
} | |
if (!valid_hdd_key) { | |
debugPrint("Nulled HDD keys are not supported!\n"); | |
debugPrint("This is a limitation of Microsoft's Xbox Live implementation.\n"); | |
debugPrint("Please don't NULL your HDD key.\n"); | |
debugPrint("\nSetup assistant will exit shortly...\n"); | |
Sleep(5000); | |
XReboot(); | |
} | |
bool saveFile = false; | |
if (!nxMountDrive('C', "\\Device\\Harddisk0\\Partition2")) { | |
debugPrint("Mounting error: Could not mount drive C: - No file will be saved.\n"); | |
saveFile = false; | |
} | |
// We detected a retail unit, so capture the keys | |
DWORD dwType; | |
DWORD cbResultLength; | |
UCHAR SerialNumber[12]; | |
UCHAR OnlineKey[16]; | |
ExQueryNonVolatileSetting(0x100, &dwType, SerialNumber, sizeof(SerialNumber), &cbResultLength); | |
ExQueryNonVolatileSetting(0x102, &dwType, OnlineKey, sizeof(OnlineKey), &cbResultLength); | |
debugPrint("\n\nPlease use the following information to register your Xbox:\n\n\n"); | |
// We good, dump keys | |
// TODO: Clean this up to be less ugly/hacky | |
char buffer[4096] = {}; | |
sprintf(buffer, "Serial Number: %c%c%c%c%c%c%c%c%c%c%c%c\n\nOnline Key: %02X%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X\n\nHDD Key: %02X%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X\n\n", | |
SerialNumber[0], SerialNumber[1], SerialNumber[2], SerialNumber[3], | |
SerialNumber[4], SerialNumber[5], SerialNumber[6], SerialNumber[7], | |
SerialNumber[8], SerialNumber[9], SerialNumber[10], SerialNumber[11], | |
OnlineKey[0], OnlineKey[1], OnlineKey[2], OnlineKey[3], | |
OnlineKey[4], OnlineKey[5], OnlineKey[6], OnlineKey[7], | |
OnlineKey[8], OnlineKey[9], OnlineKey[10], OnlineKey[11], | |
OnlineKey[12], OnlineKey[13], OnlineKey[14], OnlineKey[15], | |
XboxHDKey[0], XboxHDKey[1], XboxHDKey[2], XboxHDKey[3], | |
XboxHDKey[4], XboxHDKey[5], XboxHDKey[6], XboxHDKey[7], | |
XboxHDKey[8], XboxHDKey[9], XboxHDKey[10], XboxHDKey[11], | |
XboxHDKey[12], XboxHDKey[13], XboxHDKey[14], XboxHDKey[15] | |
); | |
debugPrint(buffer); | |
debugPrint("\n\n"); | |
debugPrint("These keys are Xbox-unique\nSharing them WILL allow people to impersonate you online\n"); | |
debugPrint("PLEASE keep them private! We will ban shared keys.\n"); | |
if (saveFile) { | |
const char *filePath = "C:\\XBL_info.txt"; | |
HANDLE fHandle = CreateFile(filePath, GENERIC_WRITE, | |
0, NULL, CREATE_ALWAYS, | |
FILE_ATTRIBUTE_NORMAL, NULL); | |
if (fHandle != INVALID_HANDLE_VALUE) { | |
DWORD bytesWritten; | |
WriteFile(fHandle, buffer, strlen(buffer), &bytesWritten, NULL); | |
if (bytesWritten == strlen(buffer)) { | |
debugPrint("\nFile successfully written to %s!\n", filePath); | |
} | |
else { | |
debugPrint("\nFile writing failed.\n"); | |
} | |
} | |
else { | |
debugPrint("Couldn't open file.\n"); | |
} | |
} | |
for (;;) { | |
Sleep(1000); | |
} | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment