mirror of
https://github.com/wiiu-env/PayloadLoaderPayload.git
synced 2025-02-17 08:56:23 +01:00
Format the code via clang-format
This commit is contained in:
parent
6098af25eb
commit
a3c549c0da
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:
|
|||||||
- main
|
- main
|
||||||
|
|
||||||
jobs:
|
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 ./src
|
||||||
build-binary:
|
build-binary:
|
||||||
runs-on: ubuntu-18.04
|
runs-on: ubuntu-18.04
|
||||||
|
needs: clang-format
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v2
|
- uses: actions/checkout@v2
|
||||||
- name: build binary
|
- name: build binary
|
||||||
@ -55,4 +63,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
|
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_path: ./${{ env.REPOSITORY_NAME }}_${{ env.DATETIME }}.zip
|
||||||
asset_name: ${{ 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]
|
on: [pull_request]
|
||||||
|
|
||||||
jobs:
|
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 ./src
|
||||||
build-binary:
|
build-binary:
|
||||||
runs-on: ubuntu-18.04
|
runs-on: ubuntu-18.04
|
||||||
|
needs: clang-format
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v2
|
- uses: actions/checkout@v2
|
||||||
- name: build binary
|
- name: build binary
|
||||||
|
@ -1,3 +1,3 @@
|
|||||||
FROM wiiuenv/devkitppc:20210414
|
FROM wiiuenv/devkitppc:20211229
|
||||||
|
|
||||||
WORKDIR project
|
WORKDIR project
|
@ -34,6 +34,10 @@ docker run -it --rm -v ${PWD}:/project payloadloaderpayload-builder make
|
|||||||
docker run -it --rm -v ${PWD}:/project payloadloaderpayload-builder make clean
|
docker run -it --rm -v ${PWD}:/project payloadloaderpayload-builder make clean
|
||||||
```
|
```
|
||||||
|
|
||||||
|
## Format the code via docker
|
||||||
|
|
||||||
|
`docker run --rm -v ${PWD}:/src wiiuenv/clang-format:13.0.0-2 -r ./src -i`
|
||||||
|
|
||||||
## Credits
|
## Credits
|
||||||
- Maschell
|
- Maschell
|
||||||
- orboditilt
|
- orboditilt
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
#include <coreinit/dynload.h>
|
|
||||||
#include <coreinit/debug.h>
|
#include <coreinit/debug.h>
|
||||||
|
#include <coreinit/dynload.h>
|
||||||
|
|
||||||
#define IMPORT(name) void* addr_##name
|
#define IMPORT(name) void *addr_##name
|
||||||
#define IMPORT_BEGIN(lib)
|
#define IMPORT_BEGIN(lib)
|
||||||
#define IMPORT_END()
|
#define IMPORT_END()
|
||||||
|
|
||||||
@ -11,7 +11,10 @@
|
|||||||
#undef IMPORT_BEGIN
|
#undef IMPORT_BEGIN
|
||||||
#undef IMPORT_END
|
#undef IMPORT_END
|
||||||
|
|
||||||
#define IMPORT(name) do{if(OSDynLoad_FindExport(handle, 0, #name, &addr_##name) < 0)OSFatal("Function " # name " is NULL");} while(0)
|
#define IMPORT(name) \
|
||||||
|
do { \
|
||||||
|
if (OSDynLoad_FindExport(handle, 0, #name, &addr_##name) < 0) OSFatal("Function " #name " is NULL"); \
|
||||||
|
} while (0)
|
||||||
#define IMPORT_BEGIN(lib) OSDynLoad_Acquire(#lib ".rpl", &handle)
|
#define IMPORT_BEGIN(lib) OSDynLoad_Acquire(#lib ".rpl", &handle)
|
||||||
/* #define IMPORT_END() OSDynLoad_Release(handle) */
|
/* #define IMPORT_END() OSDynLoad_Release(handle) */
|
||||||
#define IMPORT_END()
|
#define IMPORT_END()
|
||||||
|
@ -15,11 +15,11 @@
|
|||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
|
#include <coreinit/cache.h>
|
||||||
|
#include <coreinit/memorymap.h>
|
||||||
#include <cstdint>
|
#include <cstdint>
|
||||||
#include <cstdio>
|
#include <cstdio>
|
||||||
#include <cstring>
|
#include <cstring>
|
||||||
#include <coreinit/cache.h>
|
|
||||||
#include <coreinit/memorymap.h>
|
|
||||||
|
|
||||||
#include "kernel.h"
|
#include "kernel.h"
|
||||||
|
|
||||||
@ -28,7 +28,7 @@ extern "C" void Syscall_0x36(void);
|
|||||||
extern "C" void KernelPatchesRevertHook(void);
|
extern "C" void KernelPatchesRevertHook(void);
|
||||||
extern "C" void KernelPatches(void);
|
extern "C" void KernelPatches(void);
|
||||||
|
|
||||||
void __attribute__ ((noinline)) kern_write(void *addr, uint32_t value);
|
void __attribute__((noinline)) kern_write(void *addr, uint32_t value);
|
||||||
|
|
||||||
|
|
||||||
void doKernelSetup() {
|
void doKernelSetup() {
|
||||||
@ -52,8 +52,8 @@ void revertKernelHook() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* Write a 32-bit word with kernel permissions */
|
/* Write a 32-bit word with kernel permissions */
|
||||||
void __attribute__ ((noinline)) kern_write(void *addr, uint32_t value) {
|
void __attribute__((noinline)) kern_write(void *addr, uint32_t value) {
|
||||||
asm volatile (
|
asm volatile(
|
||||||
"li 3,1\n"
|
"li 3,1\n"
|
||||||
"li 4,0\n"
|
"li 4,0\n"
|
||||||
"mr 5,%1\n"
|
"mr 5,%1\n"
|
||||||
@ -69,6 +69,5 @@ void __attribute__ ((noinline)) kern_write(void *addr, uint32_t value) {
|
|||||||
:
|
:
|
||||||
: "r"(addr), "r"(value)
|
: "r"(addr), "r"(value)
|
||||||
: "memory", "ctr", "lr", "0", "3", "4", "5", "6", "7", "8", "9", "10",
|
: "memory", "ctr", "lr", "0", "3", "4", "5", "6", "7", "8", "9", "10",
|
||||||
"11", "12"
|
"11", "12");
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
36
src/main.cpp
36
src/main.cpp
@ -15,25 +15,25 @@
|
|||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
#include <malloc.h>
|
|
||||||
#include <cstdint>
|
|
||||||
#include <coreinit/dynload.h>
|
#include <coreinit/dynload.h>
|
||||||
#include <coreinit/screen.h>
|
|
||||||
#include <coreinit/memexpheap.h>
|
#include <coreinit/memexpheap.h>
|
||||||
|
#include <coreinit/screen.h>
|
||||||
|
#include <cstdint>
|
||||||
|
#include <malloc.h>
|
||||||
|
|
||||||
#include "utils/ElfUtils.h"
|
|
||||||
#include "utils/logger.h"
|
|
||||||
#include "dynamic.h"
|
#include "dynamic.h"
|
||||||
#include "kernel.h"
|
#include "kernel.h"
|
||||||
#include <whb/log_udp.h>
|
#include "utils/ElfUtils.h"
|
||||||
|
#include "utils/logger.h"
|
||||||
#include <coreinit/filesystem.h>
|
#include <coreinit/filesystem.h>
|
||||||
#include <whb/sdcard.h>
|
|
||||||
#include <sys/stat.h>
|
|
||||||
#include <string>
|
|
||||||
#include <vpad/input.h>
|
|
||||||
#include <vector>
|
|
||||||
#include <map>
|
#include <map>
|
||||||
|
#include <string>
|
||||||
|
#include <sys/stat.h>
|
||||||
#include <utils/StringTools.h>
|
#include <utils/StringTools.h>
|
||||||
|
#include <vector>
|
||||||
|
#include <vpad/input.h>
|
||||||
|
#include <whb/log_udp.h>
|
||||||
|
#include <whb/sdcard.h>
|
||||||
|
|
||||||
std::map<std::string, std::string> get_all_payloads(const char *relativefilepath);
|
std::map<std::string, std::string> get_all_payloads(const char *relativefilepath);
|
||||||
|
|
||||||
@ -100,7 +100,7 @@ extern "C" int _start(int argc, char **argv) {
|
|||||||
curUsedBlock = curUsedBlock->prev;
|
curUsedBlock = curUsedBlock->prev;
|
||||||
free(&curUsedBlock[1]);
|
free(&curUsedBlock[1]);
|
||||||
|
|
||||||
if(((uint32_t) &curUsedBlock[1]) == memory_start){
|
if (((uint32_t) &curUsedBlock[1]) == memory_start) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -154,7 +154,7 @@ std::map<std::string, std::string> get_all_payloads(const char *relativefilepath
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
exit:
|
exit:
|
||||||
WHBUnmountSdCard();
|
WHBUnmountSdCard();
|
||||||
if (clientAdded) {
|
if (clientAdded) {
|
||||||
FSDelClient(&client, FS_ERROR_FLAG_ALL);
|
FSDelClient(&client, FS_ERROR_FLAG_ALL);
|
||||||
@ -194,9 +194,9 @@ std::string PayloadSelectionScreen(const std::map<std::string, std::string> &pay
|
|||||||
OSScreenInit();
|
OSScreenInit();
|
||||||
uint32_t screen_buf0_size = OSScreenGetBufferSizeEx(SCREEN_TV);
|
uint32_t screen_buf0_size = OSScreenGetBufferSizeEx(SCREEN_TV);
|
||||||
uint32_t screen_buf1_size = OSScreenGetBufferSizeEx(SCREEN_DRC);
|
uint32_t screen_buf1_size = OSScreenGetBufferSizeEx(SCREEN_DRC);
|
||||||
uint8_t * screenBuffer = (uint8_t*) memalign(0x100, screen_buf0_size + screen_buf1_size);
|
uint8_t *screenBuffer = (uint8_t *) memalign(0x100, screen_buf0_size + screen_buf1_size);
|
||||||
OSScreenSetBufferEx(SCREEN_TV, (void *)screenBuffer);
|
OSScreenSetBufferEx(SCREEN_TV, (void *) screenBuffer);
|
||||||
OSScreenSetBufferEx(SCREEN_DRC, (void *)(screenBuffer + screen_buf0_size));
|
OSScreenSetBufferEx(SCREEN_DRC, (void *) (screenBuffer + screen_buf0_size));
|
||||||
|
|
||||||
OSScreenEnableEx(SCREEN_TV, 1);
|
OSScreenEnableEx(SCREEN_TV, 1);
|
||||||
OSScreenEnableEx(SCREEN_DRC, 1);
|
OSScreenEnableEx(SCREEN_DRC, 1);
|
||||||
@ -226,7 +226,7 @@ std::string PayloadSelectionScreen(const std::map<std::string, std::string> &pay
|
|||||||
pos += 2;
|
pos += 2;
|
||||||
|
|
||||||
int i = 0;
|
int i = 0;
|
||||||
for (auto const&[key, val] : payloads) {
|
for (auto const &[key, val] : payloads) {
|
||||||
std::string text = StringTools::strfmt("%s %s", i == selected ? "> " : " ", key.c_str());
|
std::string text = StringTools::strfmt("%s %s", i == selected ? "> " : " ", key.c_str());
|
||||||
OSScreenPutFontEx(SCREEN_TV, 0, pos, text.c_str());
|
OSScreenPutFontEx(SCREEN_TV, 0, pos, text.c_str());
|
||||||
OSScreenPutFontEx(SCREEN_DRC, 0, pos, text.c_str());
|
OSScreenPutFontEx(SCREEN_DRC, 0, pos, text.c_str());
|
||||||
@ -257,7 +257,7 @@ std::string PayloadSelectionScreen(const std::map<std::string, std::string> &pay
|
|||||||
OSSleepTicks(OSMillisecondsToTicks(16));
|
OSSleepTicks(OSMillisecondsToTicks(16));
|
||||||
}
|
}
|
||||||
int i = 0;
|
int i = 0;
|
||||||
for (auto const&[key, val] : payloads) {
|
for (auto const &[key, val] : payloads) {
|
||||||
if (i == selected) {
|
if (i == selected) {
|
||||||
return val;
|
return val;
|
||||||
}
|
}
|
||||||
|
@ -1,14 +1,14 @@
|
|||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
|
||||||
#include <coreinit/debug.h>
|
|
||||||
#include <coreinit/cache.h>
|
#include <coreinit/cache.h>
|
||||||
|
#include <coreinit/debug.h>
|
||||||
#include <coreinit/memdefaultheap.h>
|
#include <coreinit/memdefaultheap.h>
|
||||||
#include <whb/sdcard.h>
|
#include <stdbool.h>
|
||||||
|
#include <utils/logger.h>
|
||||||
#include <whb/file.h>
|
#include <whb/file.h>
|
||||||
#include <whb/log.h>
|
#include <whb/log.h>
|
||||||
#include <utils/logger.h>
|
#include <whb/sdcard.h>
|
||||||
#include <stdbool.h>
|
|
||||||
|
|
||||||
#include "elf_abi.h"
|
#include "elf_abi.h"
|
||||||
|
|
||||||
@ -34,7 +34,7 @@ int32_t LoadFileToMem(const char *relativefilepath, char **fileOut, uint32_t *si
|
|||||||
goto exit;
|
goto exit;
|
||||||
}
|
}
|
||||||
|
|
||||||
exit:
|
exit:
|
||||||
WHBUnmountSdCard();
|
WHBUnmountSdCard();
|
||||||
WHBDeInitFileSystem();
|
WHBDeInitFileSystem();
|
||||||
return result;
|
return result;
|
||||||
@ -102,10 +102,7 @@ static bool CheckElfLoadedBetween(void *data_elf, uint32_t start_address, uint32
|
|||||||
static unsigned int get_section(void *data, const char *name, unsigned int *size, unsigned int *addr, int fail_on_not_found) {
|
static unsigned int get_section(void *data, const char *name, unsigned int *size, unsigned int *addr, int fail_on_not_found) {
|
||||||
Elf32_Ehdr *ehdr = (Elf32_Ehdr *) data;
|
Elf32_Ehdr *ehdr = (Elf32_Ehdr *) data;
|
||||||
|
|
||||||
if (!data
|
if (!data || !IS_ELF(*ehdr) || (ehdr->e_type != ET_EXEC) || (ehdr->e_machine != EM_PPC)) {
|
||||||
|| !IS_ELF (*ehdr)
|
|
||||||
|| (ehdr->e_type != ET_EXEC)
|
|
||||||
|| (ehdr->e_machine != EM_PPC)) {
|
|
||||||
OSFatal("Invalid elf file");
|
OSFatal("Invalid elf file");
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -139,7 +136,7 @@ static void InstallMain(void *data_elf) {
|
|||||||
unsigned int main_text_addr = 0;
|
unsigned int main_text_addr = 0;
|
||||||
unsigned int main_text_len = 0;
|
unsigned int main_text_len = 0;
|
||||||
unsigned int section_offset = get_section(data_elf, ".text", &main_text_len, &main_text_addr, 1);
|
unsigned int section_offset = get_section(data_elf, ".text", &main_text_len, &main_text_addr, 1);
|
||||||
unsigned char *main_text = (unsigned char *)((uint32_t) data_elf + section_offset);
|
unsigned char *main_text = (unsigned char *) ((uint32_t) data_elf + section_offset);
|
||||||
/* Copy main .text to memory */
|
/* Copy main .text to memory */
|
||||||
if (section_offset > 0) {
|
if (section_offset > 0) {
|
||||||
DEBUG_FUNCTION_LINE("Copy section to %08X from %08X (size: %d)", main_text_addr, main_text, main_text_len);
|
DEBUG_FUNCTION_LINE("Copy section to %08X from %08X (size: %d)", main_text_addr, main_text, main_text_len);
|
||||||
@ -154,12 +151,11 @@ static void InstallMain(void *data_elf) {
|
|||||||
unsigned int main_rodata_len = 0;
|
unsigned int main_rodata_len = 0;
|
||||||
section_offset = get_section(data_elf, ".rodata", &main_rodata_len, &main_rodata_addr, 0);
|
section_offset = get_section(data_elf, ".rodata", &main_rodata_len, &main_rodata_addr, 0);
|
||||||
if (section_offset > 0) {
|
if (section_offset > 0) {
|
||||||
unsigned char *main_rodata = (unsigned char *)((uint32_t) data_elf + section_offset);
|
unsigned char *main_rodata = (unsigned char *) ((uint32_t) data_elf + section_offset);
|
||||||
/* Copy main rodata to memory */
|
/* Copy main rodata to memory */
|
||||||
memcpy((void *) (main_rodata_addr), (void *) main_rodata, main_rodata_len);
|
memcpy((void *) (main_rodata_addr), (void *) main_rodata, main_rodata_len);
|
||||||
DCFlushRange((void *) main_rodata_addr, main_rodata_len);
|
DCFlushRange((void *) main_rodata_addr, main_rodata_len);
|
||||||
ICInvalidateRange((void *) main_rodata_addr, main_rodata_len);
|
ICInvalidateRange((void *) main_rodata_addr, main_rodata_len);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// get the .data section
|
// get the .data section
|
||||||
@ -167,7 +163,7 @@ static void InstallMain(void *data_elf) {
|
|||||||
unsigned int main_data_len = 0;
|
unsigned int main_data_len = 0;
|
||||||
section_offset = get_section(data_elf, ".data", &main_data_len, &main_data_addr, 0);
|
section_offset = get_section(data_elf, ".data", &main_data_len, &main_data_addr, 0);
|
||||||
if (section_offset > 0) {
|
if (section_offset > 0) {
|
||||||
unsigned char *main_data = (unsigned char *)((uint32_t) data_elf + section_offset);
|
unsigned char *main_data = (unsigned char *) ((uint32_t) data_elf + section_offset);
|
||||||
/* Copy main data to memory */
|
/* Copy main data to memory */
|
||||||
memcpy((void *) (main_data_addr), (void *) main_data, main_data_len);
|
memcpy((void *) (main_data_addr), (void *) main_data, main_data_len);
|
||||||
DCFlushRange((void *) main_data_addr, main_data_len);
|
DCFlushRange((void *) main_data_addr, main_data_len);
|
||||||
@ -179,11 +175,10 @@ static void InstallMain(void *data_elf) {
|
|||||||
unsigned int main_bss_len = 0;
|
unsigned int main_bss_len = 0;
|
||||||
section_offset = get_section(data_elf, ".bss", &main_bss_len, &main_bss_addr, 0);
|
section_offset = get_section(data_elf, ".bss", &main_bss_len, &main_bss_addr, 0);
|
||||||
if (section_offset > 0) {
|
if (section_offset > 0) {
|
||||||
unsigned char *main_bss = (unsigned char *)((uint32_t) data_elf + section_offset);
|
unsigned char *main_bss = (unsigned char *) ((uint32_t) data_elf + section_offset);
|
||||||
/* Copy main data to memory */
|
/* Copy main data to memory */
|
||||||
memcpy((void *) (main_bss_addr), (void *) main_bss, main_bss_len);
|
memcpy((void *) (main_bss_addr), (void *) main_bss, main_bss_len);
|
||||||
DCFlushRange((void *) main_bss_addr, main_bss_len);
|
DCFlushRange((void *) main_bss_addr, main_bss_len);
|
||||||
ICInvalidateRange((void *) main_bss_addr, main_bss_len);
|
ICInvalidateRange((void *) main_bss_addr, main_bss_len);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -4,4 +4,3 @@
|
|||||||
|
|
||||||
extern "C" int32_t LoadFileToMem(const char *relativefilepath, char **fileOut, uint32_t *sizeOut);
|
extern "C" int32_t LoadFileToMem(const char *relativefilepath, char **fileOut, uint32_t *sizeOut);
|
||||||
extern "C" uint32_t load_loader_elf_from_sd(unsigned char *baseAddress, const char *relativePath);
|
extern "C" uint32_t load_loader_elf_from_sd(unsigned char *baseAddress, const char *relativePath);
|
||||||
|
|
||||||
|
@ -23,17 +23,16 @@
|
|||||||
*
|
*
|
||||||
* for WiiXplorer 2010
|
* for WiiXplorer 2010
|
||||||
***************************************************************************/
|
***************************************************************************/
|
||||||
#include <vector>
|
|
||||||
#include <string>
|
|
||||||
#include <string.h>
|
|
||||||
#include <stdarg.h>
|
#include <stdarg.h>
|
||||||
|
#include <stdio.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <stdio.h>
|
#include <string.h>
|
||||||
#include <wchar.h>
|
#include <string>
|
||||||
#include <strings.h>
|
#include <strings.h>
|
||||||
#include <wut_types.h>
|
|
||||||
#include <stdio.h>
|
|
||||||
#include <utils/StringTools.h>
|
#include <utils/StringTools.h>
|
||||||
|
#include <vector>
|
||||||
|
#include <wchar.h>
|
||||||
|
#include <wut_types.h>
|
||||||
|
|
||||||
|
|
||||||
BOOL StringTools::EndsWith(const std::string &a, const std::string &b) {
|
BOOL StringTools::EndsWith(const std::string &a, const std::string &b) {
|
||||||
|
@ -25,8 +25,8 @@
|
|||||||
***************************************************************************/
|
***************************************************************************/
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include <vector>
|
|
||||||
#include <string>
|
#include <string>
|
||||||
|
#include <vector>
|
||||||
#include <wut_types.h>
|
#include <wut_types.h>
|
||||||
|
|
||||||
class StringTools {
|
class StringTools {
|
||||||
|
@ -103,7 +103,7 @@ typedef unsigned short Elf32_Half; /* Unsigned medium integer */
|
|||||||
(ehdr).e_ident[EI_MAG3] == ELFMAG3)
|
(ehdr).e_ident[EI_MAG3] == ELFMAG3)
|
||||||
|
|
||||||
/* ELF Header */
|
/* ELF Header */
|
||||||
typedef struct elfhdr{
|
typedef struct elfhdr {
|
||||||
unsigned char e_ident[EI_NIDENT]; /* ELF Identification */
|
unsigned char e_ident[EI_NIDENT]; /* ELF Identification */
|
||||||
Elf32_Half e_type; /* object file type */
|
Elf32_Half e_type; /* object file type */
|
||||||
Elf32_Half e_machine; /* machine */
|
Elf32_Half e_machine; /* machine */
|
||||||
@ -307,7 +307,7 @@ typedef struct {
|
|||||||
#define ELF_SHSTRTAB ".shstrtab" /* section header string table */
|
#define ELF_SHSTRTAB ".shstrtab" /* section header string table */
|
||||||
#define ELF_STRTAB ".strtab" /* string table */
|
#define ELF_STRTAB ".strtab" /* string table */
|
||||||
#define ELF_SYMTAB ".symtab" /* symbol table */
|
#define ELF_SYMTAB ".symtab" /* symbol table */
|
||||||
#define ELF_SYMTAB_SHNDX ".symtab_shndx"/* symbol table section index */
|
#define ELF_SYMTAB_SHNDX ".symtab_shndx" /* symbol table section index */
|
||||||
#define ELF_TBSS ".tbss" /* thread local uninit data */
|
#define ELF_TBSS ".tbss" /* thread local uninit data */
|
||||||
#define ELF_TDATA ".tdata" /* thread local init data */
|
#define ELF_TDATA ".tdata" /* thread local init data */
|
||||||
#define ELF_TDATA1 ".tdata1" /* thread local init data */
|
#define ELF_TDATA1 ".tdata1" /* thread local init data */
|
||||||
@ -349,8 +349,8 @@ typedef struct elf32_sym {
|
|||||||
/* Extract symbol info - st_info */
|
/* Extract symbol info - st_info */
|
||||||
#define ELF32_ST_BIND(x) ((x) >> 4)
|
#define ELF32_ST_BIND(x) ((x) >> 4)
|
||||||
#define ELF32_ST_TYPE(x) (((unsigned int) x) & 0xf)
|
#define ELF32_ST_TYPE(x) (((unsigned int) x) & 0xf)
|
||||||
#define ELF32_ST_INFO(b,t) (((b) << 4) + ((t) & 0xf))
|
#define ELF32_ST_INFO(b, t) (((b) << 4) + ((t) &0xf))
|
||||||
#define ELF32_ST_VISIBILITY(x) ((x) & 0x3)
|
#define ELF32_ST_VISIBILITY(x) ((x) &0x3)
|
||||||
|
|
||||||
/* Symbol Binding - ELF32_ST_BIND - st_info */
|
/* Symbol Binding - ELF32_ST_BIND - st_info */
|
||||||
#define STB_LOCAL 0 /* Local symbol */
|
#define STB_LOCAL 0 /* Local symbol */
|
||||||
@ -400,7 +400,7 @@ typedef struct
|
|||||||
/* Extract relocation info - r_info */
|
/* Extract relocation info - r_info */
|
||||||
#define ELF32_R_SYM(i) ((i) >> 8)
|
#define ELF32_R_SYM(i) ((i) >> 8)
|
||||||
#define ELF32_R_TYPE(i) ((unsigned char) (i))
|
#define ELF32_R_TYPE(i) ((unsigned char) (i))
|
||||||
#define ELF32_R_INFO(s,t) (((s) << 8) + (unsigned char)(t))
|
#define ELF32_R_INFO(s, t) (((s) << 8) + (unsigned char) (t))
|
||||||
|
|
||||||
/* Program Header */
|
/* Program Header */
|
||||||
typedef struct {
|
typedef struct {
|
||||||
@ -440,8 +440,7 @@ typedef struct {
|
|||||||
typedef struct
|
typedef struct
|
||||||
{
|
{
|
||||||
Elf32_Sword d_tag; /* controls meaning of d_val */
|
Elf32_Sword d_tag; /* controls meaning of d_val */
|
||||||
union
|
union {
|
||||||
{
|
|
||||||
Elf32_Word d_val; /* Multiple meanings - see d_tag */
|
Elf32_Word d_val; /* Multiple meanings - see d_tag */
|
||||||
Elf32_Addr d_ptr; /* program virtual address */
|
Elf32_Addr d_ptr; /* program virtual address */
|
||||||
} d_un;
|
} d_un;
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include <whb/log.h>
|
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
#include <whb/log.h>
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
extern "C" {
|
extern "C" {
|
||||||
@ -10,8 +10,9 @@ extern "C" {
|
|||||||
#define __FILENAME_X__ (strrchr(__FILE__, '\\') ? strrchr(__FILE__, '\\') + 1 : __FILE__)
|
#define __FILENAME_X__ (strrchr(__FILE__, '\\') ? strrchr(__FILE__, '\\') + 1 : __FILE__)
|
||||||
#define __FILENAME__ (strrchr(__FILE__, '/') ? strrchr(__FILE__, '/') + 1 : __FILENAME_X__)
|
#define __FILENAME__ (strrchr(__FILE__, '/') ? strrchr(__FILE__, '/') + 1 : __FILENAME_X__)
|
||||||
|
|
||||||
#define DEBUG_FUNCTION_LINE(FMT, ARGS...)do { \
|
#define DEBUG_FUNCTION_LINE(FMT, ARGS...) \
|
||||||
WHBLogPrintf("[%23s]%30s@L%04d: " FMT "",__FILENAME__,__FUNCTION__, __LINE__, ## ARGS); \
|
do { \
|
||||||
|
WHBLogPrintf("[%23s]%30s@L%04d: " FMT "", __FILENAME__, __FUNCTION__, __LINE__, ##ARGS); \
|
||||||
} while (0)
|
} while (0)
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
|
Loading…
x
Reference in New Issue
Block a user