mirror of
https://github.com/wiiu-env/HBLInstallerWrapper.git
synced 2025-02-16 12:59:12 +01:00
Fix USB usage
This commit is contained in:
parent
f05f1a2420
commit
27418f035c
@ -1,5 +1,5 @@
|
||||
#include <stdint.h>
|
||||
#include <string.h>
|
||||
#include <cstdint>
|
||||
#include <cstring>
|
||||
#include <malloc.h>
|
||||
#include <coreinit/dynload.h>
|
||||
#include <coreinit/debug.h>
|
||||
@ -34,6 +34,7 @@ extern "C" void SC_0x25_KernelCopyData(unsigned int addr, unsigned int src, unsi
|
||||
|
||||
|
||||
void __attribute__ ((noinline)) kern_write(void *addr, uint32_t value);
|
||||
|
||||
static void InstallPatches();
|
||||
|
||||
static unsigned int load_elf_image(const uint8_t *elfstart) {
|
||||
@ -73,7 +74,7 @@ static unsigned int load_elf_image(const uint8_t *elfstart) {
|
||||
}
|
||||
|
||||
//! clear BSS
|
||||
Elf32_Shdr *shdr = (Elf32_Shdr *) (elfstart + ehdr->e_shoff);
|
||||
auto *shdr = (Elf32_Shdr *) (elfstart + ehdr->e_shoff);
|
||||
for (i = 0; i < ehdr->e_shnum; i++) {
|
||||
const char *section_name = ((const char *) elfstart) + shdr[ehdr->e_shstrndx].sh_offset + shdr[i].sh_name;
|
||||
if (section_name[0] == '.' && section_name[1] == 'b' && section_name[2] == 's' && section_name[3] == 's') {
|
||||
@ -92,8 +93,8 @@ void KernelWriteU32(uint32_t addr, uint32_t value) {
|
||||
ICInvalidateRange(&value, 4);
|
||||
DCFlushRange(&value, 4);
|
||||
|
||||
uint32_t dst = (uint32_t) OSEffectiveToPhysical((uint32_t) addr);
|
||||
uint32_t src = (uint32_t) OSEffectiveToPhysical((uint32_t) &value);
|
||||
auto dst = (uint32_t) OSEffectiveToPhysical((uint32_t) addr);
|
||||
auto src = (uint32_t) OSEffectiveToPhysical((uint32_t) &value);
|
||||
|
||||
SC_0x25_KernelCopyData(dst, src, 4);
|
||||
|
||||
@ -118,7 +119,7 @@ void InstallHBL() {
|
||||
|
||||
InstallPatches();
|
||||
|
||||
unsigned char *pElfBuffer = (unsigned char *) sd_loader_elf; // use this address as temporary to load the elf
|
||||
auto *pElfBuffer = (unsigned char *) sd_loader_elf; // use this address as temporary to load the elf
|
||||
unsigned int mainEntryPoint = load_elf_image(pElfBuffer);
|
||||
|
||||
if (mainEntryPoint == 0) {
|
||||
|
@ -1,4 +1,4 @@
|
||||
#include <stdint.h>
|
||||
#include <cstdint>
|
||||
#include <malloc.h>
|
||||
#include <cstring>
|
||||
#include <proc_ui/procui.h>
|
||||
@ -6,12 +6,10 @@
|
||||
#include <sysapp/title.h>
|
||||
#include <coreinit/mcp.h>
|
||||
#include <coreinit/debug.h>
|
||||
#include <nn/acp/title.h>
|
||||
#include <nn/sl/common.h>
|
||||
#include <nn/sl/FileStream.h>
|
||||
#include <nn/sl/LaunchInfoDatabase.h>
|
||||
#include <nn/acp.h>
|
||||
#include <nn/spm.h>
|
||||
#include <nn/sl.h>
|
||||
#include <nn/ccr/sys_caffeine.h>
|
||||
|
||||
#include <coreinit/dynload.h>
|
||||
|
||||
#include <nn/act/client_cpp.h>
|
||||
@ -28,7 +26,7 @@ bool getQuickBoot() {
|
||||
if (bootCheck == 0) {
|
||||
nn::sl::Initialize(MEMAllocFromDefaultHeapEx, MEMFreeToDefaultHeap);
|
||||
char path[0x80];
|
||||
nn::sl::GetDefaultDatabasePath(path, 0x80, 0x00050010, 0x10066000);
|
||||
nn::sl::GetDefaultDatabasePath(path, 0x80, 0x0005001010066000L); // ECO process
|
||||
FSCmdBlock cmdBlock;
|
||||
FSInitCmdBlock(&cmdBlock);
|
||||
|
||||
@ -81,7 +79,7 @@ bool getQuickBoot() {
|
||||
nn::act::Initialize();
|
||||
for (int i = 0; i < 13; i++) {
|
||||
char uuid[16];
|
||||
auto result = nn::act::GetUuidEx(uuid, i);
|
||||
result = nn::act::GetUuidEx(uuid, i);
|
||||
if (result.IsSuccess()) {
|
||||
if (memcmp(uuid, data.uuid, 8) == 0) {
|
||||
DEBUG_FUNCTION_LINE("Load Console account %d", i);
|
||||
@ -104,39 +102,19 @@ bool getQuickBoot() {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
struct WUT_PACKED VolumeInfo
|
||||
{
|
||||
WUT_UNKNOWN_BYTES(0xAC);
|
||||
char volumeId[16];
|
||||
WUT_UNKNOWN_BYTES(0x100);
|
||||
};
|
||||
WUT_CHECK_OFFSET(VolumeInfo, 0xAC, volumeId);
|
||||
WUT_CHECK_SIZE(VolumeInfo, 444);
|
||||
|
||||
|
||||
extern "C" uint32_t FSGetVolumeInfo(FSClient*, FSCmdBlock*, const char* path, VolumeInfo* data, FSErrorFlag errorMask);
|
||||
|
||||
extern "C" void Initialize__Q2_2nn3spmFv();
|
||||
extern "C" void SetAutoFatal__Q2_2nn3spmFb(bool);
|
||||
extern "C" void SetExtendedStorage__Q2_2nn3spmFQ3_2nn3spm12StorageIndex(uint64_t*);
|
||||
extern "C" void SetDefaultExtendedStorageVolumeId__Q2_2nn3spmFRCQ3_2nn3spm8VolumeId(char *);
|
||||
extern "C" uint32_t FindStorageByVolumeId__Q2_2nn3spmFPQ3_2nn3spm12StorageIndexRCQ3_2nn3spm8VolumeId(uint64_t *, char *);
|
||||
|
||||
static void initExternalStorage(void) {
|
||||
Initialize__Q2_2nn3spmFv();
|
||||
static void initExternalStorage() {
|
||||
nn::spm::Initialize();
|
||||
|
||||
FSCmdBlock cmdBlock;
|
||||
FSInitCmdBlock(&cmdBlock);
|
||||
|
||||
VolumeInfo volumeInfo;
|
||||
FSVolumeInfo volumeInfo;
|
||||
|
||||
auto *fsClient = (FSClient *) memalign(0x40, sizeof(FSClient));
|
||||
memset(fsClient, 0, sizeof(*fsClient));
|
||||
FSAddClient(fsClient, FS_ERROR_FLAG_NONE);
|
||||
|
||||
char volumePaths[][19] =
|
||||
{ "/vol/storage_usb01",
|
||||
char volumePaths[][19] = {"/vol/storage_usb01",
|
||||
"/vol/storage_usb02",
|
||||
"/vol/storage_usb03",
|
||||
};
|
||||
@ -145,37 +123,38 @@ static void initExternalStorage(void) {
|
||||
for (auto path: volumePaths) {
|
||||
DEBUG_FUNCTION_LINE("Check if %s is connected", path);
|
||||
if (FSGetVolumeInfo(fsClient, &cmdBlock, path, &volumeInfo, FS_ERROR_FLAG_ALL) == 0) {
|
||||
nn::spm::StorageIndex storageIndex = 0;
|
||||
if (nn::spm::FindStorageByVolumeId(&storageIndex, (nn::spm::VolumeId *) volumeInfo.volumeId)) {
|
||||
DEBUG_FUNCTION_LINE("Set DefaultExtendedStorage to %s", volumeInfo.volumeId);
|
||||
SetDefaultExtendedStorageVolumeId__Q2_2nn3spmFRCQ3_2nn3spm8VolumeId(volumeInfo.volumeId);
|
||||
uint64_t storageIndex = 0;
|
||||
FindStorageByVolumeId__Q2_2nn3spmFPQ3_2nn3spm12StorageIndexRCQ3_2nn3spm8VolumeId(&storageIndex, volumeInfo.volumeId);
|
||||
SetExtendedStorage__Q2_2nn3spmFQ3_2nn3spm12StorageIndex(&storageIndex);
|
||||
nn::spm::SetDefaultExtendedStorageVolumeId((nn::spm::VolumeId *) volumeInfo.volumeId);
|
||||
nn::spm::SetExtendedStorage(&storageIndex);
|
||||
ACPMountExternalStorage();
|
||||
found = true;
|
||||
break;
|
||||
} else {
|
||||
DEBUG_FUNCTION_LINE("Failed to find Storage by VolumeId(%s)", volumeInfo.volumeId);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (!found) {
|
||||
DEBUG_FUNCTION_LINE("Fallback to empty ExtendedStorage");
|
||||
char empty[16];
|
||||
empty[0] = '\0';
|
||||
SetDefaultExtendedStorageVolumeId__Q2_2nn3spmFRCQ3_2nn3spm8VolumeId(empty);
|
||||
nn::spm::VolumeId empty{};
|
||||
nn::spm::SetDefaultExtendedStorageVolumeId(&empty);
|
||||
|
||||
uint64_t storageIndex = 0;
|
||||
SetExtendedStorage__Q2_2nn3spmFQ3_2nn3spm12StorageIndex(&storageIndex);
|
||||
nn::spm::StorageIndex storageIndex = 0;
|
||||
nn::spm::SetExtendedStorage(&storageIndex);
|
||||
}
|
||||
|
||||
FSDelClient(fsClient, FS_ERROR_FLAG_ALL);
|
||||
|
||||
nn::spm::Finalize();
|
||||
}
|
||||
|
||||
|
||||
void bootHomebrewLauncher(void) {
|
||||
void bootHomebrewLauncher() {
|
||||
uint64_t titleId = _SYSGetSystemApplicationTitleId(SYSTEM_APP_ID_MII_MAKER);
|
||||
_SYSLaunchTitleWithStdArgsInNoSplash(titleId, nullptr);
|
||||
}
|
||||
|
||||
|
||||
extern "C" void _SYSLaunchMenuWithCheckingAccount(nn::act::SlotNo slot);
|
||||
|
||||
int main(int argc, char **argv) {
|
||||
if (!WHBLogModuleInit()) {
|
||||
WHBLogCafeInit();
|
||||
|
Loading…
x
Reference in New Issue
Block a user