dos2unix (this time really)

This commit is contained in:
Christopher Roy Bratusek 2012-03-14 17:56:36 +01:00
parent 6f81bce911
commit 066f93eee2
9 changed files with 912 additions and 912 deletions

View File

@ -1,11 +1,11 @@
#include <gccore.h>
int main(int argc, char **argv)
{
VIDEO_Init();
WII_LaunchTitle(0x0001000154484246);
return 0;
#include <gccore.h>
int main(int argc, char **argv)
{
VIDEO_Init();
WII_LaunchTitle(0x0001000154484246);
return 0;
}

View File

@ -1,187 +1,187 @@
/***************************************************************************
* Copyright (C) 2009
* by Dimok
*
* This software is provided 'as-is', without any express or implied
* warranty. In no event will the authors be held liable for any
* damages arising from the use of this software.
*
* Permission is granted to anyone to use this software for any
* purpose, including commercial applications, and to alter it and
* redistribute it freely, subject to the following restrictions:
*
* 1. The origin of this software must not be misrepresented; you
* must not claim that you wrote the original software. If you use
* this software in a product, an acknowledgment in the product
* documentation would be appreciated but is not required.
*
* 2. Altered source versions must be plainly marked as such, and
* must not be misrepresented as being the original software.
*
* 3. This notice may not be removed or altered from any source
* distribution.
*
* networkops.cpp
*
* Network operations
* for Wii-Xplorer 2009
***************************************************************************/
#include <stdio.h>
#include <string.h>
#include <ogcsys.h>
#include <ogc/machine/processor.h>
/***************************************************************************
* Copyright (C) 2009
* by Dimok
*
* This software is provided 'as-is', without any express or implied
* warranty. In no event will the authors be held liable for any
* damages arising from the use of this software.
*
* Permission is granted to anyone to use this software for any
* purpose, including commercial applications, and to alter it and
* redistribute it freely, subject to the following restrictions:
*
* 1. The origin of this software must not be misrepresented; you
* must not claim that you wrote the original software. If you use
* this software in a product, an acknowledgment in the product
* documentation would be appreciated but is not required.
*
* 2. Altered source versions must be plainly marked as such, and
* must not be misrepresented as being the original software.
*
* 3. This notice may not be removed or altered from any source
* distribution.
*
* networkops.cpp
*
* Network operations
* for Wii-Xplorer 2009
***************************************************************************/
#include <stdio.h>
#include <string.h>
#include <ogcsys.h>
#include <ogc/machine/processor.h>
#include "http.h"
#include <malloc.h>
#include <string>
#include <malloc.h>
#include <string>
#include <vector>
//static NetReceiver Receiver;
static bool networkinit = false;
static bool networkerror = false;
static char IP[16];
static u8 * ThreadStack = NULL;
static bool firstRun = false;
static lwp_t networkthread = LWP_THREAD_NULL;
static bool networkHalt = true;
static bool exitRequested = false;
/****************************************************************************
* Initialize_Network
***************************************************************************/
void Initialize_Network(void)
{
if(networkinit)
return;
s32 result;
result = if_config(IP, NULL, NULL, true);
if(result < 0) {
networkinit = false;
networkerror = true;
return;
}
networkinit = true;
networkerror = false;
return;
}
/****************************************************************************
* DeInit_Network
***************************************************************************/
void DeInit_Network(void)
{
net_deinit();
}
/****************************************************************************
* Check if network was initialised
***************************************************************************/
bool IsNetworkInit(void)
{
return networkinit;
}
/****************************************************************************
* Check that network has error
***************************************************************************/
bool IsNetworkError(void)
{
return networkerror;
}
/****************************************************************************
* Get network IP
***************************************************************************/
char * GetNetworkIP(void)
{
return IP;
}
/****************************************************************************
* HaltNetwork
***************************************************************************/
void HaltNetworkThread()
{
networkHalt = true;
// wait for thread to finish
while(!LWP_ThreadIsSuspended(networkthread))
{
usleep(100);
}
}
/****************************************************************************
* ResumeNetworkThread
***************************************************************************/
void ResumeNetworkThread()
{
networkHalt = false;
LWP_ResumeThread(networkthread);
}
/*********************************************************************************
* Networkthread for background network initialize and update check with idle prio
*********************************************************************************/
static void * networkinitcallback(void *arg)
{
while(!exitRequested)
{
if(networkHalt)
{
LWP_SuspendThread(networkthread);
usleep(100);
continue;
}
if(!networkinit)
Initialize_Network();
if(!firstRun)
{
LWP_SetThreadPriority(networkthread, 0);
firstRun = true;
}
usleep(200000);
}
return NULL;
}
/****************************************************************************
* InitNetworkThread with priority 0 (idle)
***************************************************************************/
void InitNetworkThread()
{
ThreadStack = (u8 *) memalign(32, 16384);
if(!ThreadStack)
return;
LWP_CreateThread (&networkthread, networkinitcallback, NULL, ThreadStack, 16384, 30);
ResumeNetworkThread();
}
/****************************************************************************
* ShutdownThread
***************************************************************************/
void ShutdownNetworkThread()
{
exitRequested = true;
networkinit = false;
networkerror = false;
if(networkthread != LWP_THREAD_NULL)
{
ResumeNetworkThread();
LWP_JoinThread (networkthread, NULL);
networkthread = LWP_THREAD_NULL;
}
if(ThreadStack)
free(ThreadStack);
ThreadStack = NULL;
}
//static NetReceiver Receiver;
static bool networkinit = false;
static bool networkerror = false;
static char IP[16];
static u8 * ThreadStack = NULL;
static bool firstRun = false;
static lwp_t networkthread = LWP_THREAD_NULL;
static bool networkHalt = true;
static bool exitRequested = false;
/****************************************************************************
* Initialize_Network
***************************************************************************/
void Initialize_Network(void)
{
if(networkinit)
return;
s32 result;
result = if_config(IP, NULL, NULL, true);
if(result < 0) {
networkinit = false;
networkerror = true;
return;
}
networkinit = true;
networkerror = false;
return;
}
/****************************************************************************
* DeInit_Network
***************************************************************************/
void DeInit_Network(void)
{
net_deinit();
}
/****************************************************************************
* Check if network was initialised
***************************************************************************/
bool IsNetworkInit(void)
{
return networkinit;
}
/****************************************************************************
* Check that network has error
***************************************************************************/
bool IsNetworkError(void)
{
return networkerror;
}
/****************************************************************************
* Get network IP
***************************************************************************/
char * GetNetworkIP(void)
{
return IP;
}
/****************************************************************************
* HaltNetwork
***************************************************************************/
void HaltNetworkThread()
{
networkHalt = true;
// wait for thread to finish
while(!LWP_ThreadIsSuspended(networkthread))
{
usleep(100);
}
}
/****************************************************************************
* ResumeNetworkThread
***************************************************************************/
void ResumeNetworkThread()
{
networkHalt = false;
LWP_ResumeThread(networkthread);
}
/*********************************************************************************
* Networkthread for background network initialize and update check with idle prio
*********************************************************************************/
static void * networkinitcallback(void *arg)
{
while(!exitRequested)
{
if(networkHalt)
{
LWP_SuspendThread(networkthread);
usleep(100);
continue;
}
if(!networkinit)
Initialize_Network();
if(!firstRun)
{
LWP_SetThreadPriority(networkthread, 0);
firstRun = true;
}
usleep(200000);
}
return NULL;
}
/****************************************************************************
* InitNetworkThread with priority 0 (idle)
***************************************************************************/
void InitNetworkThread()
{
ThreadStack = (u8 *) memalign(32, 16384);
if(!ThreadStack)
return;
LWP_CreateThread (&networkthread, networkinitcallback, NULL, ThreadStack, 16384, 30);
ResumeNetworkThread();
}
/****************************************************************************
* ShutdownThread
***************************************************************************/
void ShutdownNetworkThread()
{
exitRequested = true;
networkinit = false;
networkerror = false;
if(networkthread != LWP_THREAD_NULL)
{
ResumeNetworkThread();
LWP_JoinThread (networkthread, NULL);
networkthread = LWP_THREAD_NULL;
}
if(ThreadStack)
free(ThreadStack);
ThreadStack = NULL;
}

View File

@ -1,39 +1,39 @@
/****************************************************************************
* Copyright (C) 2010
* by Dimok
*
* This software is provided 'as-is', without any express or implied
* warranty. In no event will the authors be held liable for any
* damages arising from the use of this software.
*
* Permission is granted to anyone to use this software for any
* purpose, including commercial applications, and to alter it and
* redistribute it freely, subject to the following restrictions:
*
* 1. The origin of this software must not be misrepresented; you
* must not claim that you wrote the original software. If you use
* this software in a product, an acknowledgment in the product
* documentation would be appreciated but is not required.
*
* 2. Altered source versions must be plainly marked as such, and
* must not be misrepresented as being the original software.
*
* 3. This notice may not be removed or altered from any source
* distribution.
*
* for WiiXplorer 2010
***************************************************************************/
#ifndef _NETWORKOPS_H_
#define _NETWORKOPS_H_
void Initialize_Network(void);
void DeInit_Network(void);
bool IsNetworkInit(void);
bool IsNetworkError(void);
char * GetNetworkIP(void);
void HaltNetworkThread();
void ResumeNetworkThread();
void InitNetworkThread();
void ShutdownNetworkThread();
#endif
/****************************************************************************
* Copyright (C) 2010
* by Dimok
*
* This software is provided 'as-is', without any express or implied
* warranty. In no event will the authors be held liable for any
* damages arising from the use of this software.
*
* Permission is granted to anyone to use this software for any
* purpose, including commercial applications, and to alter it and
* redistribute it freely, subject to the following restrictions:
*
* 1. The origin of this software must not be misrepresented; you
* must not claim that you wrote the original software. If you use
* this software in a product, an acknowledgment in the product
* documentation would be appreciated but is not required.
*
* 2. Altered source versions must be plainly marked as such, and
* must not be misrepresented as being the original software.
*
* 3. This notice may not be removed or altered from any source
* distribution.
*
* for WiiXplorer 2010
***************************************************************************/
#ifndef _NETWORKOPS_H_
#define _NETWORKOPS_H_
void Initialize_Network(void);
void DeInit_Network(void);
bool IsNetworkInit(void);
bool IsNetworkError(void);
char * GetNetworkIP(void);
void HaltNetworkThread();
void ResumeNetworkThread();
void InitNetworkThread();
void ShutdownNetworkThread();
#endif

View File

@ -1,69 +1,69 @@
#include <gccore.h>
#include <ogc/machine/processor.h>
#include <stdio.h>
#include <string.h>
#include <unistd.h>
#include "RuntimeIOSPatch.h"
#define MEM_PROT 0xD8B420A
const u8 isfs_permissions_old[] = { 0x42, 0x8B, 0xD0, 0x01, 0x25, 0x66 };
const u8 isfs_permissions_patch[] = { 0x42, 0x8B, 0xE0, 0x01, 0x25, 0x66 };
const u8 setuid_old[] = { 0xD1, 0x2A, 0x1C, 0x39 };
const u8 setuid_patch[] = { 0x46, 0xC0 };
const u8 es_identify_old[] = { 0x28, 0x03, 0xD1, 0x23 };
const u8 es_identify_patch[] = { 0x00, 0x00 };
const u8 hash_old[] = { 0x20, 0x07, 0x4B, 0x0B };
const u8 hash_patch[] = { 0x00 };
const u8 addticket_vers_check[] = { 0xD2, 0x01, 0x4E, 0x56 };
const u8 addticket_patch[] = { 0xE0 };
u32 apply_patch(const char *name, const u8 *old, u32 old_size, const u8 *patch, u32 patch_size, u32 patch_offset)
{
// printf("Applying patch %s.....", name);
u8 *ptr = (u8 *) 0x93400000;
u32 i, found = 0;
u8 *start;
while ((u32) ptr < (0x94000000 - old_size))
{
if(!memcmp(ptr, old, old_size))
{
found++;
start = ptr + patch_offset;
for (i = 0; i < patch_size; i++)
*(start + i) = patch[i];
ptr += patch_size;
DCFlushRange((u8 *) (((u32) start) >> 5 << 5), (patch_size >> 5 << 5) + 64);
}
ptr++;
}
// if(found)
// printf("Patched\n");
// else
// printf("\n");
return found;
}
u32 runtimePatchApply()
{
u32 count = 0;
write16(MEM_PROT, 0);
count += apply_patch("Trucha", hash_old,
sizeof(hash_old), hash_patch, sizeof(hash_patch), 1);
count += apply_patch("ES_Identify", es_identify_old,
sizeof(es_identify_old), es_identify_patch, sizeof(es_identify_patch),
2);
count += apply_patch("NAND Permissions", isfs_permissions_old,
sizeof(isfs_permissions_old), isfs_permissions_patch,
sizeof(isfs_permissions_patch), 0);
count += apply_patch("add ticket patch", addticket_vers_check,
sizeof(addticket_vers_check), addticket_patch, sizeof(addticket_patch),
0);
count += apply_patch("ES_SetUID", setuid_old, sizeof(setuid_old),
setuid_patch, sizeof(setuid_patch), 0);
write16(MEM_PROT, 1);
return count;
}
#include <gccore.h>
#include <ogc/machine/processor.h>
#include <stdio.h>
#include <string.h>
#include <unistd.h>
#include "RuntimeIOSPatch.h"
#define MEM_PROT 0xD8B420A
const u8 isfs_permissions_old[] = { 0x42, 0x8B, 0xD0, 0x01, 0x25, 0x66 };
const u8 isfs_permissions_patch[] = { 0x42, 0x8B, 0xE0, 0x01, 0x25, 0x66 };
const u8 setuid_old[] = { 0xD1, 0x2A, 0x1C, 0x39 };
const u8 setuid_patch[] = { 0x46, 0xC0 };
const u8 es_identify_old[] = { 0x28, 0x03, 0xD1, 0x23 };
const u8 es_identify_patch[] = { 0x00, 0x00 };
const u8 hash_old[] = { 0x20, 0x07, 0x4B, 0x0B };
const u8 hash_patch[] = { 0x00 };
const u8 addticket_vers_check[] = { 0xD2, 0x01, 0x4E, 0x56 };
const u8 addticket_patch[] = { 0xE0 };
u32 apply_patch(const char *name, const u8 *old, u32 old_size, const u8 *patch, u32 patch_size, u32 patch_offset)
{
// printf("Applying patch %s.....", name);
u8 *ptr = (u8 *) 0x93400000;
u32 i, found = 0;
u8 *start;
while ((u32) ptr < (0x94000000 - old_size))
{
if(!memcmp(ptr, old, old_size))
{
found++;
start = ptr + patch_offset;
for (i = 0; i < patch_size; i++)
*(start + i) = patch[i];
ptr += patch_size;
DCFlushRange((u8 *) (((u32) start) >> 5 << 5), (patch_size >> 5 << 5) + 64);
}
ptr++;
}
// if(found)
// printf("Patched\n");
// else
// printf("\n");
return found;
}
u32 runtimePatchApply()
{
u32 count = 0;
write16(MEM_PROT, 0);
count += apply_patch("Trucha", hash_old,
sizeof(hash_old), hash_patch, sizeof(hash_patch), 1);
count += apply_patch("ES_Identify", es_identify_old,
sizeof(es_identify_old), es_identify_patch, sizeof(es_identify_patch),
2);
count += apply_patch("NAND Permissions", isfs_permissions_old,
sizeof(isfs_permissions_old), isfs_permissions_patch,
sizeof(isfs_permissions_patch), 0);
count += apply_patch("add ticket patch", addticket_vers_check,
sizeof(addticket_vers_check), addticket_patch, sizeof(addticket_patch),
0);
count += apply_patch("ES_SetUID", setuid_old, sizeof(setuid_old),
setuid_patch, sizeof(setuid_patch), 0);
write16(MEM_PROT, 1);
return count;
}

View File

@ -1,14 +1,14 @@
#ifndef _RUNTIMEIOSPATCH_H_
#define _RUNTIMEIOSPATCH_H_
#ifdef __cplusplus
extern "C" {
#endif
u32 runtimePatchApply();
#ifdef __cplusplus
}
#endif
#endif
#ifndef _RUNTIMEIOSPATCH_H_
#define _RUNTIMEIOSPATCH_H_
#ifdef __cplusplus
extern "C" {
#endif
u32 runtimePatchApply();
#ifdef __cplusplus
}
#endif
#endif

View File

@ -1,143 +1,143 @@
#include <ogcsys.h>
#include <stdio.h>
#include <string.h>
#include <malloc.h>
#include <string>
#include <vector>
std::vector<int> ioslist;
// Check if this is an IOS stub (according to WiiBrew.org)
bool IsKnownStub(u32 noIOS, s32 noRevision)
{
/*
if (noIOS == 3 && noRevision == 65280) return true;
if (noIOS == 4 && noRevision == 65280) return true;
if (noIOS == 10 && noRevision == 768) return true;
if (noIOS == 11 && noRevision == 256) return true;
if (noIOS == 16 && noRevision == 512) return true;
if (noIOS == 20 && noRevision == 256) return true;
if (noIOS == 30 && noRevision == 2816) return true;
if (noIOS == 40 && noRevision == 3072) return true;
if (noIOS == 50 && noRevision == 5120) return true;
if (noIOS == 51 && noRevision == 4864) return true;
if (noIOS == 52 && noRevision == 5888) return true;
if (noIOS == 60 && noRevision == 6400) return true;
if (noIOS == 70 && noRevision == 6912) return true;
if (noIOS == 222 && noRevision == 65280) return true;
if (noIOS == 223 && noRevision == 65280) return true;
if (noIOS == 249 && noRevision == 65280) return true;
if (noIOS == 250 && noRevision == 65280) return true;*/
if (noIOS == 254 && noRevision == 2) return true;
if (noIOS == 254 && noRevision == 3) return true;
if (noIOS == 254 && noRevision == 260) return true;
if (noIOS == 254 && noRevision == 65280) return true;
// BootMii As IOS is installed on IOS254 rev 31338
if (noIOS == 254 && noRevision == 31338) return true;
// NAND Emu
if (noIOS == 253 && noRevision == 65535) return true;
return false;
}
bool listIOS()
{
ioslist.clear();
u32 nbTitles;
if (ES_GetNumTitles(&nbTitles) < 0)
return false;
// Allocate the memory for titles
u64 *titles = (u64*)memalign(32, nbTitles*sizeof(u64));
if (titles == NULL)
return false;
if (ES_GetTitles(titles, nbTitles) < 0)
return false;
int i;
u32 titleID;
// For each titles found
for (i = 0; i < (signed)nbTitles; i++)
{
// Skip non-system titles
if (titles[i] >> 32 != 1) continue;
// Skip the system menu
titleID = titles[i] & 0xFFFFFFFF;
if (titleID == 2) continue;
// Skip BC, MIOS and possible other non-IOS titles
if (titleID > 0xFF) continue;
// Skip the running IOS
if (titleID == 0) continue;
// Skip nandemu IOS
//if (titleID == 253) continue;
// Skip bootmii IOS
if (titleID == 254) continue;
// Check if this title is an IOS stub
u32 tmdSize;
tmd *iosTMD ATTRIBUTE_ALIGN(32);
// Get the stored TMD size for the title
if (ES_GetStoredTMDSize(0x0000000100000000ULL | titleID, &tmdSize) < 0)
return false;
signed_blob *iosTMDBuffer = (signed_blob *)memalign(32, (tmdSize+32)&(~31));
memset(iosTMDBuffer, 0, tmdSize);
// Get the stored TMD for the title
if (ES_GetStoredTMD(0x0000000100000000ULL | titleID, iosTMDBuffer, tmdSize) < 0)
return false;
iosTMD = (tmd *)SIGNATURE_PAYLOAD(iosTMDBuffer);
free(iosTMDBuffer);
// Get the title version
u8 noVersion = iosTMD->title_version;
bool isStub = false;
// Check if this is an IOS stub (according to WiiBrew.org)
if (IsKnownStub(titleID, iosTMD->title_version))
isStub = true;
else
{
// If the version is 00, it's probably a stub
//
// Stubs have these things in common:
// - Title version is mostly 65280, or even better, the last 2 hexadecimal digits are 0;
// - Stub have one app of their own (type 0x1) and 2 shared apps (type 0x8001).
if (noVersion == 0)
isStub = ((iosTMD->num_contents == 3) && (iosTMD->contents[0].type == 1 && iosTMD->contents[1].type == 0x8001 && iosTMD->contents[2].type == 0x8001));
else
isStub = false;
}
if(!isStub)
ioslist.push_back(titleID);
}
return true;
}
bool getIOS(int ios)
{
for(int i = 0; i < (signed)ioslist.size(); i++)
{
if(ioslist[i] == ios)
return true;
}
return false;
}
#include <ogcsys.h>
#include <stdio.h>
#include <string.h>
#include <malloc.h>
#include <string>
#include <vector>
std::vector<int> ioslist;
// Check if this is an IOS stub (according to WiiBrew.org)
bool IsKnownStub(u32 noIOS, s32 noRevision)
{
/*
if (noIOS == 3 && noRevision == 65280) return true;
if (noIOS == 4 && noRevision == 65280) return true;
if (noIOS == 10 && noRevision == 768) return true;
if (noIOS == 11 && noRevision == 256) return true;
if (noIOS == 16 && noRevision == 512) return true;
if (noIOS == 20 && noRevision == 256) return true;
if (noIOS == 30 && noRevision == 2816) return true;
if (noIOS == 40 && noRevision == 3072) return true;
if (noIOS == 50 && noRevision == 5120) return true;
if (noIOS == 51 && noRevision == 4864) return true;
if (noIOS == 52 && noRevision == 5888) return true;
if (noIOS == 60 && noRevision == 6400) return true;
if (noIOS == 70 && noRevision == 6912) return true;
if (noIOS == 222 && noRevision == 65280) return true;
if (noIOS == 223 && noRevision == 65280) return true;
if (noIOS == 249 && noRevision == 65280) return true;
if (noIOS == 250 && noRevision == 65280) return true;*/
if (noIOS == 254 && noRevision == 2) return true;
if (noIOS == 254 && noRevision == 3) return true;
if (noIOS == 254 && noRevision == 260) return true;
if (noIOS == 254 && noRevision == 65280) return true;
// BootMii As IOS is installed on IOS254 rev 31338
if (noIOS == 254 && noRevision == 31338) return true;
// NAND Emu
if (noIOS == 253 && noRevision == 65535) return true;
return false;
}
bool listIOS()
{
ioslist.clear();
u32 nbTitles;
if (ES_GetNumTitles(&nbTitles) < 0)
return false;
// Allocate the memory for titles
u64 *titles = (u64*)memalign(32, nbTitles*sizeof(u64));
if (titles == NULL)
return false;
if (ES_GetTitles(titles, nbTitles) < 0)
return false;
int i;
u32 titleID;
// For each titles found
for (i = 0; i < (signed)nbTitles; i++)
{
// Skip non-system titles
if (titles[i] >> 32 != 1) continue;
// Skip the system menu
titleID = titles[i] & 0xFFFFFFFF;
if (titleID == 2) continue;
// Skip BC, MIOS and possible other non-IOS titles
if (titleID > 0xFF) continue;
// Skip the running IOS
if (titleID == 0) continue;
// Skip nandemu IOS
//if (titleID == 253) continue;
// Skip bootmii IOS
if (titleID == 254) continue;
// Check if this title is an IOS stub
u32 tmdSize;
tmd *iosTMD ATTRIBUTE_ALIGN(32);
// Get the stored TMD size for the title
if (ES_GetStoredTMDSize(0x0000000100000000ULL | titleID, &tmdSize) < 0)
return false;
signed_blob *iosTMDBuffer = (signed_blob *)memalign(32, (tmdSize+32)&(~31));
memset(iosTMDBuffer, 0, tmdSize);
// Get the stored TMD for the title
if (ES_GetStoredTMD(0x0000000100000000ULL | titleID, iosTMDBuffer, tmdSize) < 0)
return false;
iosTMD = (tmd *)SIGNATURE_PAYLOAD(iosTMDBuffer);
free(iosTMDBuffer);
// Get the title version
u8 noVersion = iosTMD->title_version;
bool isStub = false;
// Check if this is an IOS stub (according to WiiBrew.org)
if (IsKnownStub(titleID, iosTMD->title_version))
isStub = true;
else
{
// If the version is 00, it's probably a stub
//
// Stubs have these things in common:
// - Title version is mostly 65280, or even better, the last 2 hexadecimal digits are 0;
// - Stub have one app of their own (type 0x1) and 2 shared apps (type 0x8001).
if (noVersion == 0)
isStub = ((iosTMD->num_contents == 3) && (iosTMD->contents[0].type == 1 && iosTMD->contents[1].type == 0x8001 && iosTMD->contents[2].type == 0x8001));
else
isStub = false;
}
if(!isStub)
ioslist.push_back(titleID);
}
return true;
}
bool getIOS(int ios)
{
for(int i = 0; i < (signed)ioslist.size(); i++)
{
if(ioslist[i] == ios)
return true;
}
return false;
}

View File

@ -1,7 +1,7 @@
#ifndef _GETIOS_H_
#define _GETIOS_H_
bool listIOS();
bool getIOS(int ios);
#ifndef _GETIOS_H_
#define _GETIOS_H_
bool listIOS();
bool getIOS(int ios);
#endif

View File

@ -1,429 +1,429 @@
#include <stdio.h>
#include <stdlib.h>
#include <gccore.h>
#include <sstream>
#include <vector>
#include <wiiuse/wpad.h>
#include "getios.h"
#include "menu.h"
#include "video.h"
#include "wad.h"
#include "../../svnrev/svnrev.h"
using namespace std;
std::vector<string> text1, text2, text3;
int startpos_x = 6;
int startpos_y = 12;
int menu_main_choice;
void show_menu_head()
{
Con_FgColor(6, 1);
printf("\x1b[%i;%iH", startpos_x, startpos_y);
printf("HBF installer v0.2");
Con_FgColor(7, 1);
printf("\t\t\t\t\t(C) 2011");
Con_FgColor(6, 1);
printf(" hamachi-mp");
}
void fill_menu_main()
{
text1.clear();
stringstream buffer;
buffer << "Install The Homebrew Filter rev" << SvnRev();
text1.push_back(buffer.str());
if(CheckAppFound(GetTitleID()))
text1.push_back("Uninstall The Homebrew Filter");
else
text1.push_back("");
text1.push_back("");
text1.push_back("Copyright");
text1.push_back("");
text1.push_back("Exit");
}
void fill_menu_install_uninstall()
{
text2.push_back("Yes, continue");
text2.push_back("No, take me back");
}
void fill_menu_copyright()
{
text3.push_back("Copyright (C) hamachi-mp");
text3.push_back("");
text3.push_back("Thanks to:");
text3.push_back("\tTeam Twiizers");
text3.push_back("\tdevkitPRO");
text3.push_back("\tWaninkoko (WAD Manager)");
text3.push_back("\tWiiCrazy/I.R.on (Crap Installer)");
}
void menu()
{
mopen();
ISFS_Initialize();
listIOS();
fill_menu_main();
fill_menu_install_uninstall();
fill_menu_copyright();
menu_main_choice = text1.size() -1;
/*
int fgcolor = 3;
int fgbold = 1;
printf("\x1b[1;0H");
printf("fgcolor %i\n", fgcolor);
printf("fgbold %i\n", fgbold);
Con_FgColor(fgcolor, fgbold);
printf("test");
while(1)
{
WPAD_ScanPads();
u32 pressed = WPAD_ButtonsDown(0);
if(pressed & WPAD_BUTTON_UP)
{
printf("test");
}
else if(pressed & WPAD_BUTTON_1)
{
fgcolor--;
printf("\x1b[1;0H");
Con_FgColor(7, 1);
printf("fgcolor %i\n\n", fgcolor);
Con_FgColor(fgcolor, fgbold);
printf("test");
}
else if(pressed & WPAD_BUTTON_2)
{
fgcolor++;
printf("\x1b[1;0H");
Con_FgColor(7, 1);
printf("fgcolor %i\n\n", fgcolor);
Con_FgColor(fgcolor, fgbold);
printf("test");
}
else if(pressed & WPAD_BUTTON_MINUS)
{
fgbold--;
printf("\x1b[2;0H");
Con_FgColor(7, 1);
printf("fgbold %i\n", fgbold);
Con_FgColor(fgcolor, fgbold);
printf("test");
}
else if(pressed & WPAD_BUTTON_PLUS)
{
fgbold++;
printf("\x1b[2;0H");
Con_FgColor(7, 1);
printf("fgbold %i\n", fgbold);
Con_FgColor(fgcolor, fgbold);
printf("test");
}
else if(pressed & WPAD_BUTTON_HOME)
exit(0);
}
*/
int currentMenu = 0;
while(currentMenu != MENU_EXIT)
{
switch (currentMenu)
{
case MENU_MAIN:
currentMenu = menu_main(menu_main_choice);
break;
case MENU_INSTALL:
currentMenu = menu_install_uninstall(1);
break;
case MENU_UNINSTALL:
currentMenu = menu_install_uninstall(0);
break;
case MENU_INSTALLING:
currentMenu = menu_install();
break;
case MENU_UNINSTALLING:
currentMenu = menu_uninstall();
break;
case MENU_COPYRIGHT:
currentMenu = menu_copyright();
break;
}
}
ISFS_Deinitialize();
}
int menu_main(int scrollpos)
{
Con_Clear();
show_menu_head();
fill_menu_main();
if(text1[scrollpos] == "")
scrollpos = text1.size() -1;
Con_FgColor(3, 1);
printf("\x1b[%i;%iH", startpos_x +2, startpos_y);
printf("Main Menu");
Con_FgColor(7, 1);
for(int i=0; i < (signed)text1.size(); i++)
{
printf("\x1b[%i;%iH", startpos_x +4 +i, startpos_y +3);
printf("%s", text1[i].c_str());
}
bool scroll = true;
while(1)
{
WPAD_ScanPads();
u32 pressed = WPAD_ButtonsDown(0);
if ( pressed & WPAD_BUTTON_DOWN && scrollpos < (signed)text1.size() -1)
{
scrollpos++;
while(text1[scrollpos] == "")
scrollpos++;
scroll = true;
}
else if ( pressed & WPAD_BUTTON_UP && scrollpos != 0)
{
scrollpos--;
while(text1[scrollpos] == "")
scrollpos--;
scroll = true;
}
if(scroll)
{
for(int i=0; i < (signed)text1.size(); i++)
{
printf("\x1b[%i;%iH", startpos_x +4 +i, startpos_y);
if(i == scrollpos)
printf(">>");
else
printf(" ");
}
scroll = false;
}
if( pressed & WPAD_BUTTON_A )
{
menu_main_choice = scrollpos;
switch(scrollpos)
{
case 0:
return MENU_INSTALL;
case 1:
return MENU_UNINSTALL;
case 3:
return MENU_COPYRIGHT;
default:
return MENU_EXIT;
}
}
}
}
int menu_install_uninstall(int install)
{
Con_Clear();
show_menu_head();
Con_FgColor(7, 1);
printf("\x1b[%i;%iH", startpos_x +2, startpos_y);
if(install)
printf("Install The Homebrew Filter now");
else
printf("Uninstall The Homebrew Filter now");
for(int i=0; i < (signed)text2.size(); i++)
{
printf("\x1b[%i;%iH", startpos_x +4 +i, startpos_y +3);
printf("%s", text2[i].c_str());
}
int scrollpos = 1;
bool scroll = true;
while(1)
{
WPAD_ScanPads();
u32 pressed = WPAD_ButtonsDown(0);
if ( pressed & WPAD_BUTTON_DOWN && scrollpos < (signed)text2.size() -1)
{
scrollpos++;
scroll = true;
}
else if ( pressed & WPAD_BUTTON_UP && scrollpos != 0)
{
scrollpos--;
scroll = true;
}
if(scroll)
{
for(int i=0; i < (signed)text2.size(); i++)
{
printf("\x1b[%d;12H", startpos_x +4 +i);
if(i == scrollpos)
printf(">>");
else
printf(" ");
}
scroll = false;
}
if( pressed & WPAD_BUTTON_A )
{
switch(scrollpos)
{
case 0:
if(install)
return MENU_INSTALLING;
else
return MENU_UNINSTALLING;
break;
case 1:
return MENU_MAIN;
}
}
}
}
int menu_install()
{
Con_Clear();
show_menu_head();
Con_FgColor(7, 1);
printf("\x1b[%i;%iH", startpos_x +2, startpos_y);
printf("Installing The Homebrew Filter");
printf("\x1b[%i;%iH", startpos_x +4, startpos_y);
if(Wad_InstallFromMemory(startpos_x, startpos_y) >= 0)
{
if(!getIOS(58))
{
s32 fd;
u32 high = (u32)(GetTitleID() >> 32);
u32 low = (u32)(GetTitleID() & 0xFFFFFFFF);
char filepath[ISFS_MAXPATH];
sprintf(filepath, "/title/%08x/%08x/content/title.tmd", high, low);
static fstats filestats ATTRIBUTE_ALIGN(32);
static u8 filearray[1024] ATTRIBUTE_ALIGN(32);
fd = ISFS_Open(filepath, ISFS_OPEN_READ);
if (fd <= 0)
ISFS_Close(fd);
ISFS_GetFileStats(fd, &filestats);
ISFS_Read(fd, filearray, filestats.file_length);
ISFS_Close(fd);
if(filestats.file_length >= 0)
{
fd = ISFS_Open(filepath, ISFS_OPEN_RW);
if(getIOS(61))
filearray[395] = 61;
else
filearray[395] = IOS_GetVersion();
ISFS_Write(fd, filearray, sizeof( filearray ));
ISFS_Close(fd);
}
}
}
Con_FgColor(7, 1);
printf("\x1b[%i;%iH", startpos_x +8, startpos_y);
printf(">> Continue");
while(1)
{
WPAD_ScanPads();
u32 pressed = WPAD_ButtonsDown(0);
if( pressed & WPAD_BUTTON_A )
return MENU_MAIN;
}
}
int menu_uninstall()
{
Con_Clear();
show_menu_head();
Con_FgColor(7, 1);
printf("\x1b[%i;%iH", startpos_x +2, startpos_y);
printf("Uninstalling The Homebrew Filter");
Wad_UninstallFromMemory(startpos_x, startpos_y);
Con_FgColor(7, 1);
printf("\x1b[%i;%iH", startpos_x +8, startpos_y);
printf(">> Continue");
while(1)
{
WPAD_ScanPads();
u32 pressed = WPAD_ButtonsDown(0);
if( pressed & WPAD_BUTTON_A )
return MENU_MAIN;
}
}
int menu_copyright()
{
Con_Clear();
show_menu_head();
Con_FgColor(7, 1);
for(int i=0; i < (signed)text3.size(); i++)
{
printf("\x1b[%i;%iH", startpos_x +2 +i, startpos_y);
printf("%s", text3[i].c_str());
}
printf("\x1b[%i;%iH", startpos_x + text3.size() +3, startpos_y);
printf(">> Continue");
while(1)
{
WPAD_ScanPads();
u32 pressed = WPAD_ButtonsDown(0);
if( pressed & WPAD_BUTTON_A )
return MENU_MAIN;
}
#include <stdio.h>
#include <stdlib.h>
#include <gccore.h>
#include <sstream>
#include <vector>
#include <wiiuse/wpad.h>
#include "getios.h"
#include "menu.h"
#include "video.h"
#include "wad.h"
#include "../../svnrev/svnrev.h"
using namespace std;
std::vector<string> text1, text2, text3;
int startpos_x = 6;
int startpos_y = 12;
int menu_main_choice;
void show_menu_head()
{
Con_FgColor(6, 1);
printf("\x1b[%i;%iH", startpos_x, startpos_y);
printf("HBF installer v0.2");
Con_FgColor(7, 1);
printf("\t\t\t\t\t(C) 2011");
Con_FgColor(6, 1);
printf(" hamachi-mp");
}
void fill_menu_main()
{
text1.clear();
stringstream buffer;
buffer << "Install The Homebrew Filter rev" << SvnRev();
text1.push_back(buffer.str());
if(CheckAppFound(GetTitleID()))
text1.push_back("Uninstall The Homebrew Filter");
else
text1.push_back("");
text1.push_back("");
text1.push_back("Copyright");
text1.push_back("");
text1.push_back("Exit");
}
void fill_menu_install_uninstall()
{
text2.push_back("Yes, continue");
text2.push_back("No, take me back");
}
void fill_menu_copyright()
{
text3.push_back("Copyright (C) hamachi-mp");
text3.push_back("");
text3.push_back("Thanks to:");
text3.push_back("\tTeam Twiizers");
text3.push_back("\tdevkitPRO");
text3.push_back("\tWaninkoko (WAD Manager)");
text3.push_back("\tWiiCrazy/I.R.on (Crap Installer)");
}
void menu()
{
mopen();
ISFS_Initialize();
listIOS();
fill_menu_main();
fill_menu_install_uninstall();
fill_menu_copyright();
menu_main_choice = text1.size() -1;
/*
int fgcolor = 3;
int fgbold = 1;
printf("\x1b[1;0H");
printf("fgcolor %i\n", fgcolor);
printf("fgbold %i\n", fgbold);
Con_FgColor(fgcolor, fgbold);
printf("test");
while(1)
{
WPAD_ScanPads();
u32 pressed = WPAD_ButtonsDown(0);
if(pressed & WPAD_BUTTON_UP)
{
printf("test");
}
else if(pressed & WPAD_BUTTON_1)
{
fgcolor--;
printf("\x1b[1;0H");
Con_FgColor(7, 1);
printf("fgcolor %i\n\n", fgcolor);
Con_FgColor(fgcolor, fgbold);
printf("test");
}
else if(pressed & WPAD_BUTTON_2)
{
fgcolor++;
printf("\x1b[1;0H");
Con_FgColor(7, 1);
printf("fgcolor %i\n\n", fgcolor);
Con_FgColor(fgcolor, fgbold);
printf("test");
}
else if(pressed & WPAD_BUTTON_MINUS)
{
fgbold--;
printf("\x1b[2;0H");
Con_FgColor(7, 1);
printf("fgbold %i\n", fgbold);
Con_FgColor(fgcolor, fgbold);
printf("test");
}
else if(pressed & WPAD_BUTTON_PLUS)
{
fgbold++;
printf("\x1b[2;0H");
Con_FgColor(7, 1);
printf("fgbold %i\n", fgbold);
Con_FgColor(fgcolor, fgbold);
printf("test");
}
else if(pressed & WPAD_BUTTON_HOME)
exit(0);
}
*/
int currentMenu = 0;
while(currentMenu != MENU_EXIT)
{
switch (currentMenu)
{
case MENU_MAIN:
currentMenu = menu_main(menu_main_choice);
break;
case MENU_INSTALL:
currentMenu = menu_install_uninstall(1);
break;
case MENU_UNINSTALL:
currentMenu = menu_install_uninstall(0);
break;
case MENU_INSTALLING:
currentMenu = menu_install();
break;
case MENU_UNINSTALLING:
currentMenu = menu_uninstall();
break;
case MENU_COPYRIGHT:
currentMenu = menu_copyright();
break;
}
}
ISFS_Deinitialize();
}
int menu_main(int scrollpos)
{
Con_Clear();
show_menu_head();
fill_menu_main();
if(text1[scrollpos] == "")
scrollpos = text1.size() -1;
Con_FgColor(3, 1);
printf("\x1b[%i;%iH", startpos_x +2, startpos_y);
printf("Main Menu");
Con_FgColor(7, 1);
for(int i=0; i < (signed)text1.size(); i++)
{
printf("\x1b[%i;%iH", startpos_x +4 +i, startpos_y +3);
printf("%s", text1[i].c_str());
}
bool scroll = true;
while(1)
{
WPAD_ScanPads();
u32 pressed = WPAD_ButtonsDown(0);
if ( pressed & WPAD_BUTTON_DOWN && scrollpos < (signed)text1.size() -1)
{
scrollpos++;
while(text1[scrollpos] == "")
scrollpos++;
scroll = true;
}
else if ( pressed & WPAD_BUTTON_UP && scrollpos != 0)
{
scrollpos--;
while(text1[scrollpos] == "")
scrollpos--;
scroll = true;
}
if(scroll)
{
for(int i=0; i < (signed)text1.size(); i++)
{
printf("\x1b[%i;%iH", startpos_x +4 +i, startpos_y);
if(i == scrollpos)
printf(">>");
else
printf(" ");
}
scroll = false;
}
if( pressed & WPAD_BUTTON_A )
{
menu_main_choice = scrollpos;
switch(scrollpos)
{
case 0:
return MENU_INSTALL;
case 1:
return MENU_UNINSTALL;
case 3:
return MENU_COPYRIGHT;
default:
return MENU_EXIT;
}
}
}
}
int menu_install_uninstall(int install)
{
Con_Clear();
show_menu_head();
Con_FgColor(7, 1);
printf("\x1b[%i;%iH", startpos_x +2, startpos_y);
if(install)
printf("Install The Homebrew Filter now");
else
printf("Uninstall The Homebrew Filter now");
for(int i=0; i < (signed)text2.size(); i++)
{
printf("\x1b[%i;%iH", startpos_x +4 +i, startpos_y +3);
printf("%s", text2[i].c_str());
}
int scrollpos = 1;
bool scroll = true;
while(1)
{
WPAD_ScanPads();
u32 pressed = WPAD_ButtonsDown(0);
if ( pressed & WPAD_BUTTON_DOWN && scrollpos < (signed)text2.size() -1)
{
scrollpos++;
scroll = true;
}
else if ( pressed & WPAD_BUTTON_UP && scrollpos != 0)
{
scrollpos--;
scroll = true;
}
if(scroll)
{
for(int i=0; i < (signed)text2.size(); i++)
{
printf("\x1b[%d;12H", startpos_x +4 +i);
if(i == scrollpos)
printf(">>");
else
printf(" ");
}
scroll = false;
}
if( pressed & WPAD_BUTTON_A )
{
switch(scrollpos)
{
case 0:
if(install)
return MENU_INSTALLING;
else
return MENU_UNINSTALLING;
break;
case 1:
return MENU_MAIN;
}
}
}
}
int menu_install()
{
Con_Clear();
show_menu_head();
Con_FgColor(7, 1);
printf("\x1b[%i;%iH", startpos_x +2, startpos_y);
printf("Installing The Homebrew Filter");
printf("\x1b[%i;%iH", startpos_x +4, startpos_y);
if(Wad_InstallFromMemory(startpos_x, startpos_y) >= 0)
{
if(!getIOS(58))
{
s32 fd;
u32 high = (u32)(GetTitleID() >> 32);
u32 low = (u32)(GetTitleID() & 0xFFFFFFFF);
char filepath[ISFS_MAXPATH];
sprintf(filepath, "/title/%08x/%08x/content/title.tmd", high, low);
static fstats filestats ATTRIBUTE_ALIGN(32);
static u8 filearray[1024] ATTRIBUTE_ALIGN(32);
fd = ISFS_Open(filepath, ISFS_OPEN_READ);
if (fd <= 0)
ISFS_Close(fd);
ISFS_GetFileStats(fd, &filestats);
ISFS_Read(fd, filearray, filestats.file_length);
ISFS_Close(fd);
if(filestats.file_length >= 0)
{
fd = ISFS_Open(filepath, ISFS_OPEN_RW);
if(getIOS(61))
filearray[395] = 61;
else
filearray[395] = IOS_GetVersion();
ISFS_Write(fd, filearray, sizeof( filearray ));
ISFS_Close(fd);
}
}
}
Con_FgColor(7, 1);
printf("\x1b[%i;%iH", startpos_x +8, startpos_y);
printf(">> Continue");
while(1)
{
WPAD_ScanPads();
u32 pressed = WPAD_ButtonsDown(0);
if( pressed & WPAD_BUTTON_A )
return MENU_MAIN;
}
}
int menu_uninstall()
{
Con_Clear();
show_menu_head();
Con_FgColor(7, 1);
printf("\x1b[%i;%iH", startpos_x +2, startpos_y);
printf("Uninstalling The Homebrew Filter");
Wad_UninstallFromMemory(startpos_x, startpos_y);
Con_FgColor(7, 1);
printf("\x1b[%i;%iH", startpos_x +8, startpos_y);
printf(">> Continue");
while(1)
{
WPAD_ScanPads();
u32 pressed = WPAD_ButtonsDown(0);
if( pressed & WPAD_BUTTON_A )
return MENU_MAIN;
}
}
int menu_copyright()
{
Con_Clear();
show_menu_head();
Con_FgColor(7, 1);
for(int i=0; i < (signed)text3.size(); i++)
{
printf("\x1b[%i;%iH", startpos_x +2 +i, startpos_y);
printf("%s", text3[i].c_str());
}
printf("\x1b[%i;%iH", startpos_x + text3.size() +3, startpos_y);
printf(">> Continue");
while(1)
{
WPAD_ScanPads();
u32 pressed = WPAD_ButtonsDown(0);
if( pressed & WPAD_BUTTON_A )
return MENU_MAIN;
}
}

View File

@ -1,18 +1,18 @@
void menu();
int menu_main(int);
int menu_install_uninstall(int);
int menu_install();
int menu_uninstall();
int menu_copyright();
enum
{
MENU_EXIT = -1,
MENU_MAIN,
MENU_INSTALL,
MENU_UNINSTALL,
MENU_INSTALLING,
MENU_UNINSTALLING,
MENU_COPYRIGHT
};
void menu();
int menu_main(int);
int menu_install_uninstall(int);
int menu_install();
int menu_uninstall();
int menu_copyright();
enum
{
MENU_EXIT = -1,
MENU_MAIN,
MENU_INSTALL,
MENU_UNINSTALL,
MENU_INSTALLING,
MENU_UNINSTALLING,
MENU_COPYRIGHT
};