mirror of
https://github.com/wiiu-env/MochaPayload.git
synced 2024-11-21 23:49:15 +01:00
Format the code via clang-format
This commit is contained in:
parent
77c31bd0fe
commit
8015a18f24
67
.clang-format
Normal file
67
.clang-format
Normal file
@ -0,0 +1,67 @@
|
||||
# Generated from CLion C/C++ Code Style settings
|
||||
BasedOnStyle: LLVM
|
||||
AccessModifierOffset: -4
|
||||
AlignAfterOpenBracket: Align
|
||||
AlignConsecutiveAssignments: Consecutive
|
||||
AlignConsecutiveMacros: AcrossEmptyLinesAndComments
|
||||
AlignOperands: Align
|
||||
AllowAllArgumentsOnNextLine: false
|
||||
AllowAllConstructorInitializersOnNextLine: false
|
||||
AllowAllParametersOfDeclarationOnNextLine: false
|
||||
AllowShortBlocksOnASingleLine: Always
|
||||
AllowShortCaseLabelsOnASingleLine: false
|
||||
AllowShortFunctionsOnASingleLine: All
|
||||
AllowShortIfStatementsOnASingleLine: Always
|
||||
AllowShortLambdasOnASingleLine: All
|
||||
AllowShortLoopsOnASingleLine: true
|
||||
AlwaysBreakAfterReturnType: None
|
||||
AlwaysBreakTemplateDeclarations: Yes
|
||||
BreakBeforeBraces: Custom
|
||||
BraceWrapping:
|
||||
AfterCaseLabel: false
|
||||
AfterClass: false
|
||||
AfterControlStatement: Never
|
||||
AfterEnum: false
|
||||
AfterFunction: false
|
||||
AfterNamespace: false
|
||||
AfterUnion: false
|
||||
BeforeCatch: false
|
||||
BeforeElse: false
|
||||
IndentBraces: false
|
||||
SplitEmptyFunction: false
|
||||
SplitEmptyRecord: true
|
||||
BreakBeforeBinaryOperators: None
|
||||
BreakBeforeTernaryOperators: true
|
||||
BreakConstructorInitializers: BeforeColon
|
||||
BreakInheritanceList: BeforeColon
|
||||
ColumnLimit: 0
|
||||
CompactNamespaces: false
|
||||
ContinuationIndentWidth: 8
|
||||
IndentCaseLabels: true
|
||||
IndentPPDirectives: None
|
||||
IndentWidth: 4
|
||||
KeepEmptyLinesAtTheStartOfBlocks: true
|
||||
MaxEmptyLinesToKeep: 2
|
||||
NamespaceIndentation: All
|
||||
ObjCSpaceAfterProperty: false
|
||||
ObjCSpaceBeforeProtocolList: true
|
||||
PointerAlignment: Right
|
||||
ReflowComments: false
|
||||
SpaceAfterCStyleCast: true
|
||||
SpaceAfterLogicalNot: false
|
||||
SpaceAfterTemplateKeyword: false
|
||||
SpaceBeforeAssignmentOperators: true
|
||||
SpaceBeforeCpp11BracedList: false
|
||||
SpaceBeforeCtorInitializerColon: true
|
||||
SpaceBeforeInheritanceColon: true
|
||||
SpaceBeforeParens: ControlStatements
|
||||
SpaceBeforeRangeBasedForLoopColon: true
|
||||
SpaceInEmptyParentheses: false
|
||||
SpacesBeforeTrailingComments: 1
|
||||
SpacesInAngles: false
|
||||
SpacesInCStyleCastParentheses: false
|
||||
SpacesInContainerLiterals: false
|
||||
SpacesInParentheses: false
|
||||
SpacesInSquareBrackets: false
|
||||
TabWidth: 4
|
||||
UseTab: Never
|
10
.github/workflows/ci.yml
vendored
10
.github/workflows/ci.yml
vendored
@ -6,8 +6,16 @@ on:
|
||||
- master
|
||||
|
||||
jobs:
|
||||
clang-format:
|
||||
runs-on: ubuntu-18.04
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
- name: clang-format
|
||||
run: |
|
||||
docker run --rm -v ${PWD}:/src wiiuenv/clang-format:13.0.0-2 -r ./source
|
||||
build-binary:
|
||||
runs-on: ubuntu-18.04
|
||||
needs: clang-format
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
- name: build binary
|
||||
@ -54,4 +62,4 @@ jobs:
|
||||
upload_url: ${{ steps.create_release.outputs.upload_url }} # This pulls from the CREATE RELEASE step above, referencing it's ID to get its outputs object, which include a `upload_url`. See this blog post for more info: https://jasonet.co/posts/new-features-of-github-actions/#passing-data-to-future-steps
|
||||
asset_path: ./${{ env.REPOSITORY_NAME }}_${{ env.DATETIME }}.zip
|
||||
asset_name: ${{ env.REPOSITORY_NAME }}_${{ env.DATETIME }}.zip
|
||||
asset_content_type: application/unknown
|
||||
asset_content_type: application/zip
|
8
.github/workflows/pr.yml
vendored
8
.github/workflows/pr.yml
vendored
@ -3,8 +3,16 @@ name: CI-PR
|
||||
on: [pull_request]
|
||||
|
||||
jobs:
|
||||
clang-format:
|
||||
runs-on: ubuntu-18.04
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
- name: clang-format
|
||||
run: |
|
||||
docker run --rm -v ${PWD}:/src wiiuenv/clang-format:13.0.0-2 -r ./source
|
||||
build-binary:
|
||||
runs-on: ubuntu-18.04
|
||||
needs: clang-format
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
- name: build binary
|
||||
|
@ -1,5 +1,7 @@
|
||||
[![CI-Release](https://github.com/wiiu-env/MochaPayload/actions/workflows/ci.yml/badge.svg)](https://github.com/wiiu-env/MochaPayload/actions/workflows/ci.yml)
|
||||
|
||||
# MochaPayload - a simple custom firmware
|
||||
This a lite version of the [original mocha](https://github.com/dimok789/mocha) to be used with the [EnvironmentLoader](https://github.com/wiiu-env/EnvironmentLoader).
|
||||
This a version of the [original mocha](https://github.com/dimok789/mocha) to be used with the [EnvironmentLoader](https://github.com/wiiu-env/EnvironmentLoader).
|
||||
|
||||
## Usage
|
||||
Place the `00_mocha.rpx` in the `[ENVIRONMENT]/modules/setup` folder and run the [EnvironmentLoader](https://github.com/wiiu-env/EnvironmentLoader).
|
||||
@ -15,7 +17,6 @@ Place the `00_mocha.rpx` in the `[ENVIRONMENT]/modules/setup` folder and run the
|
||||
|
||||
For building you just need [wut](https://github.com/devkitPro/wut/) installed, then use the `make` command.
|
||||
|
||||
|
||||
## Building using the Dockerfile
|
||||
|
||||
It's possible to use a docker image for building. This way you don't need anything installed on your host system.
|
||||
@ -31,6 +32,10 @@ docker run -it --rm -v ${PWD}:/project mochapayload-builder make
|
||||
docker run -it --rm -v ${PWD}:/project mochapayload-builder make clean
|
||||
```
|
||||
|
||||
## Format the code via docker
|
||||
|
||||
`docker run --rm -v ${PWD}:/src wiiuenv/clang-format:13.0.0-2 -r ./source -i`
|
||||
|
||||
## Credits
|
||||
dimok
|
||||
Maschell
|
||||
|
@ -2,6 +2,7 @@
|
||||
|
||||
#include <assert.h>
|
||||
#include <stddef.h>
|
||||
#include <stdint.h>
|
||||
|
||||
#define CHECK_SIZE(Type, Size) \
|
||||
static_assert(sizeof(Type) == Size, \
|
||||
|
@ -1,9 +1,9 @@
|
||||
#include <string.h>
|
||||
#include <coreinit/cache.h>
|
||||
#include <coreinit/thread.h>
|
||||
#include <coreinit/ios.h>
|
||||
#include <stdint.h>
|
||||
#include "ios_exploit.h"
|
||||
#include <coreinit/cache.h>
|
||||
#include <coreinit/ios.h>
|
||||
#include <coreinit/thread.h>
|
||||
#include <stdint.h>
|
||||
#include <string.h>
|
||||
|
||||
#define ALIGN4(x) (((x) + 3) & ~3)
|
||||
|
||||
@ -34,8 +34,8 @@ typedef struct __attribute__((packed)) {
|
||||
|
||||
/* YOUR ARM CODE HERE (starts at ARM_CODE_BASE) */
|
||||
#include "ios_kernel/ios_kernel.bin.h"
|
||||
#include "ios_usb/ios_usb.bin.h"
|
||||
#include "ios_mcp/ios_mcp.bin.h"
|
||||
#include "ios_usb/ios_usb.bin.h"
|
||||
|
||||
/* ROP CHAIN STARTS HERE (0x1015BD78) */
|
||||
static const int final_chain[] = {
|
||||
|
@ -1,3 +1,4 @@
|
||||
// clang-format off
|
||||
/*
|
||||
* Copyright (c) 1995, 1996, 2001, 2002
|
||||
* Erik Theisen. All rights reserved.
|
||||
|
@ -21,16 +21,14 @@
|
||||
* 3. This notice may not be removed or altered from any source
|
||||
* distribution.
|
||||
***************************************************************************/
|
||||
#include "types.h"
|
||||
#include "elf_abi.h"
|
||||
#include "types.h"
|
||||
#include "utils.h"
|
||||
|
||||
static Elf32_Phdr *get_section(u32 data, u32 vaddr) {
|
||||
Elf32_Ehdr *ehdr = (Elf32_Ehdr *) data;
|
||||
|
||||
if (!IS_ELF (*ehdr)
|
||||
|| (ehdr->e_type != ET_EXEC)
|
||||
|| (ehdr->e_machine != EM_ARM)) {
|
||||
if (!IS_ELF(*ehdr) || (ehdr->e_type != ET_EXEC) || (ehdr->e_machine != EM_ARM)) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -26,10 +26,10 @@
|
||||
|
||||
#include "types.h"
|
||||
|
||||
#define ARM_B(addr, func) (0xEA000000 | ((((u32)(func) - (u32)(addr) - 8) >> 2) & 0x00FFFFFF)) // +-32MB
|
||||
#define ARM_BL(addr, func) (0xEB000000 | ((((u32)(func) - (u32)(addr) - 8) >> 2) & 0x00FFFFFF)) // +-32MB
|
||||
#define THUMB_B(addr, func) ((0xE000 | ((((u32)(func) - (u32)(addr) - 4) >> 1) & 0x7FF))) // +-2KB
|
||||
#define THUMB_BL(addr, func) ((0xF000F800 | ((((u32)(func) - (u32)(addr) - 4) >> 1) & 0x0FFF)) | ((((u32)(func) - (u32)(addr) - 4) << 4) & 0x7FFF000)) // +-4MB
|
||||
#define ARM_B(addr, func) (0xEA000000 | ((((u32) (func) - (u32) (addr) -8) >> 2) & 0x00FFFFFF)) // +-32MB
|
||||
#define ARM_BL(addr, func) (0xEB000000 | ((((u32) (func) - (u32) (addr) -8) >> 2) & 0x00FFFFFF)) // +-32MB
|
||||
#define THUMB_B(addr, func) ((0xE000 | ((((u32) (func) - (u32) (addr) -4) >> 1) & 0x7FF))) // +-2KB
|
||||
#define THUMB_BL(addr, func) ((0xF000F800 | ((((u32) (func) - (u32) (addr) -4) >> 1) & 0x0FFF)) | ((((u32) (func) - (u32) (addr) -4) << 4) & 0x7FFF000)) // +-4MB
|
||||
|
||||
typedef struct {
|
||||
u32 address;
|
||||
|
@ -24,13 +24,13 @@
|
||||
#include "types.h"
|
||||
#include "utils.h"
|
||||
|
||||
#define svcAlloc ((void *(*)(u32 heapid, u32 size))0x081234E4)
|
||||
#define svcAllocAlign ((void *(*)(u32 heapid, u32 size, u32 align))0x08123464)
|
||||
#define svcFree ((void *(*)(u32 heapid, void *ptr))0x08123830)
|
||||
#define svcOpen ((int (*)(const char* name, int mode))0x0812940C)
|
||||
#define svcClose ((int (*)(int fd))0x08129368)
|
||||
#define svcIoctl ((int (*)(int fd, u32 request, void* input_buffer, u32 input_buffer_len, void* output_buffer, u32 output_buffer_len))0x081290E0)
|
||||
#define svcIoctlv ((int (*)(int fd, u32 request, u32 vector_count_in, u32 vector_count_out, iovec_s* vector))0x0812903C)
|
||||
#define svcAlloc ((void *(*) (u32 heapid, u32 size)) 0x081234E4)
|
||||
#define svcAllocAlign ((void *(*) (u32 heapid, u32 size, u32 align)) 0x08123464)
|
||||
#define svcFree ((void *(*) (u32 heapid, void *ptr)) 0x08123830)
|
||||
#define svcOpen ((int (*)(const char *name, int mode)) 0x0812940C)
|
||||
#define svcClose ((int (*)(int fd)) 0x08129368)
|
||||
#define svcIoctl ((int (*)(int fd, u32 request, void *input_buffer, u32 input_buffer_len, void *output_buffer, u32 output_buffer_len)) 0x081290E0)
|
||||
#define svcIoctlv ((int (*)(int fd, u32 request, u32 vector_count_in, u32 vector_count_out, iovec_s *vector)) 0x0812903C)
|
||||
|
||||
typedef struct {
|
||||
void *ptr;
|
||||
@ -218,4 +218,3 @@ int FSA_SDWriteRawSectors(const void *buffer, u32 sector, u32 num_sectors) {
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
|
@ -21,12 +21,12 @@
|
||||
* 3. This notice may not be removed or altered from any source
|
||||
* distribution.
|
||||
***************************************************************************/
|
||||
#include "utils.h"
|
||||
#include "types.h"
|
||||
#include "elf_patcher.h"
|
||||
#include "kernel_patches.h"
|
||||
#include "ios_mcp_patches.h"
|
||||
#include "../../ios_mcp/ios_mcp_syms.h"
|
||||
#include "elf_patcher.h"
|
||||
#include "ios_mcp_patches.h"
|
||||
#include "kernel_patches.h"
|
||||
#include "types.h"
|
||||
#include "utils.h"
|
||||
|
||||
typedef struct {
|
||||
u32 paddr;
|
||||
@ -37,9 +37,9 @@ typedef struct {
|
||||
u32 cached;
|
||||
} ios_map_shared_info_t;
|
||||
|
||||
#define mcp_rodata_phys(addr) ((u32)(addr) - 0x05060000 + 0x08220000)
|
||||
#define mcp_data_phys(addr) ((u32)(addr) - 0x05074000 + 0x08234000)
|
||||
#define acp_phys(addr) ((u32)(addr) - 0xE0000000 + 0x12900000)
|
||||
#define mcp_rodata_phys(addr) ((u32) (addr) -0x05060000 + 0x08220000)
|
||||
#define mcp_data_phys(addr) ((u32) (addr) -0x05074000 + 0x08234000)
|
||||
#define acp_phys(addr) ((u32) (addr) -0xE0000000 + 0x12900000)
|
||||
|
||||
void instant_patches_setup(void) {
|
||||
// apply IOS ELF launch hook
|
||||
|
@ -21,11 +21,11 @@
|
||||
* 3. This notice may not be removed or altered from any source
|
||||
* distribution.
|
||||
***************************************************************************/
|
||||
#include "types.h"
|
||||
#include "elf_patcher.h"
|
||||
#include "ios_mcp_patches.h"
|
||||
#include "../../ios_mcp/ios_mcp.bin.h"
|
||||
#include "../../ios_mcp/ios_mcp_syms.h"
|
||||
#include "elf_patcher.h"
|
||||
#include "types.h"
|
||||
|
||||
#define MCP_CODE_BASE_PHYS_ADDR (-0x05100000 + 0x13D80000)
|
||||
|
||||
|
@ -24,6 +24,8 @@
|
||||
#ifndef _MCP_PATCHES_H_
|
||||
#define _MCP_PATCHES_H_
|
||||
|
||||
#include "types.h"
|
||||
|
||||
#define MCP_LAUNCH_IMG_PHYS_ADDR (0x27000000)
|
||||
|
||||
u32 mcp_get_phys_code_base(void);
|
||||
|
@ -21,14 +21,14 @@
|
||||
* 3. This notice may not be removed or altered from any source
|
||||
* distribution.
|
||||
***************************************************************************/
|
||||
#include "types.h"
|
||||
#include "kernel_patches.h"
|
||||
#include "../../common/kernel_commands.h"
|
||||
#include "elf_patcher.h"
|
||||
#include "ios_mcp_patches.h"
|
||||
#include "kernel_patches.h"
|
||||
#include "fsa.h"
|
||||
#include "utils.h"
|
||||
#include "ios_mcp_patches.h"
|
||||
#include "thread.h"
|
||||
#include "types.h"
|
||||
#include "utils.h"
|
||||
|
||||
extern void __KERNEL_CODE_START(void);
|
||||
|
||||
@ -43,17 +43,17 @@ static const u32 mcpIoMappings_patch[] =
|
||||
0x0D000000, 0x0D000000, 0x001C0000, 0x00000000, 0x00000003, 0x00000000, // mapping 1
|
||||
0x0D800000, 0x0D800000, 0x001C0000, 0x00000000, 0x00000003, 0x00000000, // mapping 2
|
||||
0x0C200000, 0x0C200000, 0x00100000, 0x00000000, 0x00000003, 0x00000000 // mapping 3
|
||||
};
|
||||
};
|
||||
|
||||
static const u32 KERNEL_MCP_IOMAPPINGS_STRUCT[] =
|
||||
{
|
||||
(u32) mcpIoMappings_patch, // ptr to iomapping structs
|
||||
0x00000003, // number of iomappings
|
||||
0x00000001 // pid (MCP)
|
||||
};
|
||||
};
|
||||
|
||||
ThreadContext_t** currentThreadContext = (ThreadContext_t**) 0x08173ba0;
|
||||
uint32_t* domainAccessPermissions = (uint32_t*) 0x081a4000;
|
||||
ThreadContext_t **currentThreadContext = (ThreadContext_t **) 0x08173ba0;
|
||||
uint32_t *domainAccessPermissions = (uint32_t *) 0x081a4000;
|
||||
|
||||
int kernel_syscall_0x81(u32 command, u32 arg1, u32 arg2, u32 arg3) {
|
||||
int result = 0;
|
||||
@ -78,8 +78,8 @@ int kernel_syscall_0x81(u32 command, u32 arg1, u32 arg2, u32 arg3) {
|
||||
break;
|
||||
}
|
||||
case KERNEL_READ_OTP: {
|
||||
int (*read_otp_internal)(int index, void* out_buf, u32 size) = (int (*)(int, void*, u32)) 0x08120248;
|
||||
read_otp_internal(0, (void*)(arg1), 0x400);
|
||||
int (*read_otp_internal)(int index, void *out_buf, u32 size) = (int (*)(int, void *, u32)) 0x08120248;
|
||||
read_otp_internal(0, (void *) (arg1), 0x400);
|
||||
break;
|
||||
}
|
||||
default: {
|
||||
@ -154,4 +154,3 @@ void kernel_run_patches(u32 ios_elf_start) {
|
||||
u32 patch_count = (u32) (((u8 *) kernel_patches_table_end) - ((u8 *) kernel_patches_table)) / sizeof(patch_table_t);
|
||||
patch_table_entries(ios_elf_start, kernel_patches_table, patch_count);
|
||||
}
|
||||
|
||||
|
@ -24,6 +24,8 @@
|
||||
#ifndef _KERNEL_PATCHES_H
|
||||
#define _KERNEL_PATCHES_H
|
||||
|
||||
#include "types.h"
|
||||
|
||||
int kernel_init_otp_buffer(u32 sd_sector, int tagValid);
|
||||
|
||||
int kernel_syscall_0x81(u32 command, u32 arg1, u32 arg2, u32 arg3);
|
||||
|
@ -21,10 +21,10 @@
|
||||
* 3. This notice may not be removed or altered from any source
|
||||
* distribution.
|
||||
***************************************************************************/
|
||||
#include "instant_patches.h"
|
||||
#include "ios_mcp_patches.h"
|
||||
#include "types.h"
|
||||
#include "utils.h"
|
||||
#include "ios_mcp_patches.h"
|
||||
#include "instant_patches.h"
|
||||
|
||||
#define USB_PHYS_CODE_BASE 0x101312D0
|
||||
|
||||
@ -33,6 +33,7 @@ typedef struct {
|
||||
u8 data[0];
|
||||
} payload_info_t;
|
||||
|
||||
// clang-format off
|
||||
static const char repairData_set_fault_behavior[] = {
|
||||
0xE1, 0x2F, 0xFF, 0x1E, 0xE9, 0x2D, 0x40, 0x30, 0xE5, 0x93, 0x20, 0x00, 0xE1, 0xA0, 0x40, 0x00,
|
||||
0xE5, 0x92, 0x30, 0x54, 0xE1, 0xA0, 0x50, 0x01, 0xE3, 0x53, 0x00, 0x01, 0x0A, 0x00, 0x00, 0x02,
|
||||
@ -56,6 +57,7 @@ static const char repairData_usb_root_thread[] = {
|
||||
0xE2, 0x4D, 0xDE, 0x17, 0xEB, 0x00, 0xB9, 0x92, 0xE3, 0xA0, 0x10, 0x00, 0xE3, 0xA0, 0x20, 0x03,
|
||||
0xE5, 0x9F, 0x0E, 0x68, 0xEB, 0x00, 0xB3, 0x20,
|
||||
};
|
||||
// clang-format on
|
||||
|
||||
int _main() {
|
||||
void (*invalidate_icache)() = (void (*)()) 0x0812DCF0;
|
||||
|
@ -1,14 +1,14 @@
|
||||
#pragma once
|
||||
|
||||
#include <stdint.h>
|
||||
#include <assert.h>
|
||||
#include <stdint.h>
|
||||
|
||||
typedef struct ThreadContext {
|
||||
uint32_t cspr;
|
||||
uint32_t gpr[14];
|
||||
uint32_t lr;
|
||||
uint32_t pc;
|
||||
struct ThreadContext* threadQueueNext;
|
||||
struct ThreadContext *threadQueueNext;
|
||||
uint32_t maxPriority;
|
||||
uint32_t priority;
|
||||
uint32_t state;
|
||||
@ -16,18 +16,18 @@ typedef struct ThreadContext {
|
||||
uint32_t id;
|
||||
uint32_t flags;
|
||||
uint32_t exitValue;
|
||||
struct ThreadContext** joinQueue;
|
||||
struct ThreadContext** threadQueue;
|
||||
struct ThreadContext **joinQueue;
|
||||
struct ThreadContext **threadQueue;
|
||||
uint8_t unk1[56];
|
||||
void* stackPointer;
|
||||
void *stackPointer;
|
||||
uint8_t unk2[8];
|
||||
void* sysStackAddr;
|
||||
void* userStackAddr;
|
||||
void *sysStackAddr;
|
||||
void *userStackAddr;
|
||||
uint32_t userStackSize;
|
||||
void* threadLocalStorage;
|
||||
void *threadLocalStorage;
|
||||
uint32_t profileCount;
|
||||
uint32_t profileTime;
|
||||
} ThreadContext_t;
|
||||
static_assert(sizeof(ThreadContext_t) == 0xC8, "ThreadContext_t: different size than expected");
|
||||
|
||||
extern ThreadContext_t** currentThreadContext;
|
||||
extern ThreadContext_t **currentThreadContext;
|
||||
|
@ -26,28 +26,35 @@
|
||||
|
||||
#define ALIGN4(x) (((x) + 3) & ~3)
|
||||
|
||||
#define kernel_memcpy ((void * (*)(void*, const void*, int))0x08131D04)
|
||||
#define kernel_memset ((void *(*)(void*, int, unsigned int))0x08131DA0)
|
||||
#define kernel_strncpy ((char *(*)(char*, const char*, unsigned int))0x081329B8)
|
||||
#define disable_interrupts ((int(*)())0x0812E778)
|
||||
#define enable_interrupts ((int(*)(int))0x0812E78C)
|
||||
#define kernel_bsp_command_5 ((int (*)(const char*, int offset, const char*, int size, void *buffer))0x0812EC40)
|
||||
#define kernel_memcpy ((void *(*) (void *, const void *, int) ) 0x08131D04)
|
||||
#define kernel_memset ((void *(*) (void *, int, unsigned int) ) 0x08131DA0)
|
||||
#define kernel_strncpy ((char *(*) (char *, const char *, unsigned int) ) 0x081329B8)
|
||||
#define disable_interrupts ((int (*)()) 0x0812E778)
|
||||
#define enable_interrupts ((int (*)(int)) 0x0812E78C)
|
||||
#define kernel_bsp_command_5 ((int (*)(const char *, int offset, const char *, int size, void *buffer)) 0x0812EC40)
|
||||
|
||||
void reverse_memcpy(void *dest, const void *src, unsigned int size);
|
||||
|
||||
static inline unsigned int disable_mmu(void) {
|
||||
unsigned int control_register = 0;
|
||||
asm volatile("MRC p15, 0, %0, c1, c0, 0" : "=r" (control_register));
|
||||
asm volatile("MCR p15, 0, %0, c1, c0, 0" : : "r" (control_register & 0xFFFFEFFA));
|
||||
asm volatile("MRC p15, 0, %0, c1, c0, 0"
|
||||
: "=r"(control_register));
|
||||
asm volatile("MCR p15, 0, %0, c1, c0, 0"
|
||||
:
|
||||
: "r"(control_register & 0xFFFFEFFA));
|
||||
return control_register;
|
||||
}
|
||||
|
||||
static inline void restore_mmu(unsigned int control_register) {
|
||||
asm volatile("MCR p15, 0, %0, c1, c0, 0" : : "r" (control_register));
|
||||
asm volatile("MCR p15, 0, %0, c1, c0, 0"
|
||||
:
|
||||
: "r"(control_register));
|
||||
}
|
||||
|
||||
static inline void set_domain_register(unsigned int domain_register) {
|
||||
asm volatile("MCR p15, 0, %0, c3, c0, 0" : : "r" (domain_register));
|
||||
asm volatile("MCR p15, 0, %0, c3, c0, 0"
|
||||
:
|
||||
: "r"(domain_register));
|
||||
}
|
||||
|
||||
#endif
|
||||
|
@ -1,9 +1,9 @@
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include "svc.h"
|
||||
#include "imports.h"
|
||||
#include "fsa.h"
|
||||
#include "imports.h"
|
||||
#include "svc.h"
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
static void *allocIobuf() {
|
||||
void *ptr = svcAlloc(0xCAFF, 0x828);
|
||||
@ -193,7 +193,8 @@ int _FSA_ReadWriteFile(int fd, void *data, u32 size, u32 cnt, int fileHandle, u3
|
||||
|
||||
int ret;
|
||||
if (read) ret = svcIoctlv(fd, 0x0F, 1, 2, iovec);
|
||||
else ret = svcIoctlv(fd, 0x10, 2, 1, iovec);
|
||||
else
|
||||
ret = svcIoctlv(fd, 0x10, 2, 1, iovec);
|
||||
|
||||
freeIobuf(iobuf);
|
||||
return ret;
|
||||
|
@ -1,6 +1,8 @@
|
||||
#ifndef FSA_H
|
||||
#define FSA_H
|
||||
|
||||
#include "types.h"
|
||||
|
||||
typedef struct {
|
||||
u32 flag;
|
||||
u32 permission;
|
||||
|
@ -1,11 +1,11 @@
|
||||
#ifndef IMPORTS_H
|
||||
#define IMPORTS_H
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <stdarg.h>
|
||||
#include "types.h"
|
||||
#include <stdarg.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
#define MCP_SVC_BASE ((void*)0x050567EC)
|
||||
#define MCP_SVC_BASE ((void *) 0x050567EC)
|
||||
|
||||
void usleep(u32 time);
|
||||
|
||||
|
@ -21,16 +21,15 @@
|
||||
* 3. This notice may not be removed or altered from any source
|
||||
* distribution.
|
||||
***************************************************************************/
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include "imports.h"
|
||||
#include "fsa.h"
|
||||
#include "svc.h"
|
||||
#include "logger.h"
|
||||
#include "fsa.h"
|
||||
#include "wupserver.h"
|
||||
#include "../../common/kernel_commands.h"
|
||||
#include "fsa.h"
|
||||
#include "imports.h"
|
||||
#include "logger.h"
|
||||
#include "svc.h"
|
||||
#include "wupserver.h"
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
#define IOS_ERROR_UNKNOWN_VALUE 0xFFFFFFD6
|
||||
#define IOS_ERROR_INVALID_ARG 0xFFFFFFE3
|
||||
@ -110,7 +109,7 @@ static int ipc_ioctl(ipcmessage *message) {
|
||||
memcpy(arguments, message->ioctl.buffer_in + 1, (size_arguments < 8 * 4) ? size_arguments : (8 * 4));
|
||||
|
||||
// return error code as data
|
||||
message->ioctl.buffer_io[0] = ((int (*const)(u32, u32, u32, u32, u32, u32, u32, u32)) (MCP_SVC_BASE + svc_id * 8))(arguments[0], arguments[1], arguments[2], arguments[3], arguments[4],
|
||||
message->ioctl.buffer_io[0] = ((int (*const)(u32, u32, u32, u32, u32, u32, u32, u32))(MCP_SVC_BASE + svc_id * 8))(arguments[0], arguments[1], arguments[2], arguments[3], arguments[4],
|
||||
arguments[5], arguments[6], arguments[7]);
|
||||
}
|
||||
break;
|
||||
@ -451,5 +450,4 @@ void ipc_deinit(void) {
|
||||
svcIoctl(fd, IOCTL_KILL_SERVER, &dummy, sizeof(dummy), &dummy, sizeof(dummy));
|
||||
svcClose(fd);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -1,16 +1,16 @@
|
||||
#include <stdarg.h>
|
||||
#include <string.h>
|
||||
#include "types.h"
|
||||
#include "logger.h"
|
||||
#include "imports.h"
|
||||
#include "socket.h"
|
||||
#include "logger.h"
|
||||
#include "types.h"
|
||||
#include <stdarg.h>
|
||||
#include <string.h>
|
||||
|
||||
#ifdef LOG_IP
|
||||
static int log_socket = 0;
|
||||
|
||||
int log_init(unsigned int ipAddress){
|
||||
int log_init(unsigned int ipAddress) {
|
||||
log_socket = socket(AF_INET, SOCK_DGRAM, IPPROTO_UDP);
|
||||
if (log_socket < 0){
|
||||
if (log_socket < 0) {
|
||||
return log_socket;
|
||||
}
|
||||
|
||||
@ -20,8 +20,7 @@ int log_init(unsigned int ipAddress){
|
||||
connect_addr.sin_port = 4405;
|
||||
connect_addr.sin_addr.s_addr = ipAddress;
|
||||
|
||||
if(connect(log_socket, (struct sockaddr*)&connect_addr, sizeof(connect_addr)) < 0)
|
||||
{
|
||||
if (connect(log_socket, (struct sockaddr *) &connect_addr, sizeof(connect_addr)) < 0) {
|
||||
closesocket(log_socket);
|
||||
log_socket = -1;
|
||||
}
|
||||
@ -29,25 +28,22 @@ int log_init(unsigned int ipAddress){
|
||||
return log_socket;
|
||||
}
|
||||
|
||||
void log_deinit()
|
||||
{
|
||||
if(log_socket >= 0)
|
||||
{
|
||||
void log_deinit() {
|
||||
if (log_socket >= 0) {
|
||||
closesocket(log_socket);
|
||||
log_socket = -1;
|
||||
}
|
||||
}
|
||||
|
||||
static void log_print(const char *str, int len)
|
||||
{
|
||||
if(log_socket < 0) {
|
||||
static void log_print(const char *str, int len) {
|
||||
if (log_socket < 0) {
|
||||
return;
|
||||
}
|
||||
int ret;
|
||||
while (len > 0) {
|
||||
int block = len < 1400 ? len : 1400; // take max 1400 bytes per UDP packet
|
||||
ret = send(log_socket, str, block, 0);
|
||||
if(ret < 0)
|
||||
if (ret < 0)
|
||||
break;
|
||||
|
||||
len -= ret;
|
||||
@ -55,9 +51,8 @@ static void log_print(const char *str, int len)
|
||||
}
|
||||
}
|
||||
|
||||
void log_printf(const char *format, ...)
|
||||
{
|
||||
if(log_socket < 0) {
|
||||
void log_printf(const char *format, ...) {
|
||||
if (log_socket < 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -15,8 +15,9 @@ void log_printf(const char *format, ...);
|
||||
#define log_printf(x, ...)
|
||||
#endif
|
||||
|
||||
#define DEBUG_FUNCTION_LINE(FMT, ARGS...)do { \
|
||||
log_printf("[%23s]%30s@L%04d: " FMT "",__FILE__,__FUNCTION__, __LINE__, ## ARGS); \
|
||||
#define DEBUG_FUNCTION_LINE(FMT, ARGS...) \
|
||||
do { \
|
||||
log_printf("[%23s]%30s@L%04d: " FMT "", __FILE__, __FUNCTION__, __LINE__, ##ARGS); \
|
||||
} while (0)
|
||||
|
||||
|
||||
|
@ -1,5 +1,5 @@
|
||||
#include "wupserver.h"
|
||||
#include "ipc.h"
|
||||
#include "wupserver.h"
|
||||
|
||||
static int threadsStarted = 0;
|
||||
|
||||
|
@ -16,10 +16,10 @@
|
||||
* - each request routes here where we can do whatever
|
||||
*/
|
||||
|
||||
#include "logger.h"
|
||||
#include "ipc_types.h"
|
||||
#include "../../common/ipc_defs.h"
|
||||
#include "fsa.h"
|
||||
#include "ipc_types.h"
|
||||
#include "logger.h"
|
||||
#include "svc.h"
|
||||
#include <string.h>
|
||||
|
||||
@ -161,7 +161,7 @@ static int MCP_LoadCustomFile(int target, char *path, int filesize, int fileoffs
|
||||
}
|
||||
|
||||
int _MCP_ReadCOSXml_patch(uint32_t u1, uint32_t u2, MCPPPrepareTitleInfo *xmlData) {
|
||||
int (*const real_MCP_ReadCOSXml_patch)(uint32_t u1, uint32_t u2, MCPPPrepareTitleInfo *xmlData) = (void *) 0x050024ec + 1; //+1 for thumb
|
||||
int (*const real_MCP_ReadCOSXml_patch)(uint32_t u1, uint32_t u2, MCPPPrepareTitleInfo * xmlData) = (void *) 0x050024ec + 1; //+1 for thumb
|
||||
|
||||
int res = real_MCP_ReadCOSXml_patch(u1, u2, xmlData);
|
||||
|
||||
|
@ -1,8 +1,8 @@
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include "net_ifmgr_ncl.h"
|
||||
#include "imports.h"
|
||||
#include "svc.h"
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
static int ifmgrncl_handle = 0;
|
||||
|
||||
|
@ -1,9 +1,9 @@
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include "socket.h"
|
||||
#include "svc.h"
|
||||
#include "imports.h"
|
||||
#include "svc.h"
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
static int socket_handle = 0;
|
||||
|
||||
|
@ -1,8 +1,8 @@
|
||||
#ifndef TYPES_H
|
||||
#define TYPES_H
|
||||
|
||||
#include <stdint.h>
|
||||
#include <stdbool.h>
|
||||
#include <stdint.h>
|
||||
|
||||
#define U64_MAX UINT64_MAX
|
||||
|
||||
|
@ -1,13 +1,13 @@
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include "fsa.h"
|
||||
#include "imports.h"
|
||||
#include "ipc.h"
|
||||
#include "logger.h"
|
||||
#include "net_ifmgr_ncl.h"
|
||||
#include "socket.h"
|
||||
#include "fsa.h"
|
||||
#include "svc.h"
|
||||
#include "logger.h"
|
||||
#include "ipc.h"
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
static int serverKilled;
|
||||
static int serverSocket;
|
||||
@ -54,7 +54,7 @@ static int serverCommandHandler(u32 *command_buffer, u32 length) {
|
||||
|
||||
// return error code as data
|
||||
out_length = 8;
|
||||
command_buffer[1] = ((int (*const)(u32, u32, u32, u32, u32, u32, u32, u32)) (MCP_SVC_BASE + svc_id * 8))(arguments[0], arguments[1], arguments[2], arguments[3], arguments[4], arguments[5],
|
||||
command_buffer[1] = ((int (*const)(u32, u32, u32, u32, u32, u32, u32, u32))(MCP_SVC_BASE + svc_id * 8))(arguments[0], arguments[1], arguments[2], arguments[3], arguments[4], arguments[5],
|
||||
arguments[6], arguments[7]);
|
||||
}
|
||||
break;
|
||||
|
@ -19,6 +19,4 @@ void _main() {
|
||||
"newlr: .word 0x1012EACC\n"
|
||||
"newr0: .word 0x10146080\n"
|
||||
"newpc: .word 0x10111164\n");
|
||||
|
||||
|
||||
}
|
||||
|
@ -1,7 +1,7 @@
|
||||
#include <cstring>
|
||||
#include <cstdio>
|
||||
#include <coreinit/cache.h>
|
||||
#include <coreinit/ios.h>
|
||||
#include <cstdio>
|
||||
#include <cstring>
|
||||
#include <sysapp/title.h>
|
||||
|
||||
#include <whb/log.h>
|
||||
|
Loading…
Reference in New Issue
Block a user