Skip to content

Commit

Permalink
Game Patch: add nullptr checks
Browse files Browse the repository at this point in the history
  • Loading branch information
illusion0001 committed Oct 23, 2023
1 parent 6c3a06f commit 91c6260
Show file tree
Hide file tree
Showing 6 changed files with 253 additions and 216 deletions.
19 changes: 2 additions & 17 deletions .github/workflows/CI.yml
Original file line number Diff line number Diff line change
Expand Up @@ -40,34 +40,19 @@ jobs:
uses: actions/checkout@v3
with:
repository: illusion0001/mxml
ref: patch-1
ref: clang-14
path: mxml

- name: Setup variables
run: |
echo "llvm_ver=12.0" >> $GITHUB_ENV
echo "llvm_path=$RUNNER_TOOL_CACHE/llvm" >> $GITHUB_ENV
sudo apt install llvm lld
echo "OO_PS4_TOOLCHAIN=$GITHUB_WORKSPACE/OpenOrbis/PS4Toolchain" >> $GITHUB_ENV
echo "commit_ver=1.$(git rev-list HEAD --count)" >> $GITHUB_ENV
echo "commit_hash=$(echo ${GITHUB_SHA} | cut -c1-8)" >> $GITHUB_ENV
- name: Download OpenOrbis Toolchain
run: curl -sL https://github.com/illusion0001/OpenOrbis-PS4-Toolchain/releases/latest/download/toolchain.tar.gz | tar xz -C ./

- name: Cache LLVM and Clang (${{ env.llvm_ver }})
id: cache-llvm
uses: actions/cache@v3
with:
path: ${{ env.llvm_path }}
key: llvm-${{ env.llvm_ver }}

- name: Install LLVM and Clang (${{ env.llvm_ver }})
uses: KyleMayes/install-llvm-action@v1
with:
version: ${{ env.llvm_ver }}
directory: ${{ env.llvm_path }}
cached: ${{ steps.cache-llvm.outputs.cache-hit }}

- name: Install mini xml
working-directory: mxml/ps4
run: |
Expand Down
2 changes: 1 addition & 1 deletion common/plugin_common.h
Original file line number Diff line number Diff line change
Expand Up @@ -50,4 +50,4 @@ void NotifyStatic(const char* IconUri, const char *text);
void Notify(const char* IconUri, const char *FMT, ...);
// Takes hardcoded input string 2 to strlen against during compile time.
// startsWith(input_1, "input 2");
#define startsWith(str1, str2) strncmp(str1, str2, strlen(str2))
#define startsWith(str1, str2) (strncmp(str1, str2, __builtin_strlen(str2)) == 0)
16 changes: 8 additions & 8 deletions plugin_src/game_patch/source/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -110,16 +110,16 @@ void get_key_init(void)
s32 ret_cmp = strcmp(g_game_ver, AppVerData);
if (!ret_cmp)
{
debug_printf("App ver %s == %s\n", g_game_ver, AppVerData);
final_printf("App ver %s == %s\n", g_game_ver, AppVerData);
}
else if (!startsWith(AppVerData, "mask") || !startsWith(AppVerData, "all"))
else if (startsWith(AppVerData, "mask") || startsWith(AppVerData, "all"))
{
debug_printf("App ver masked: %s\n", AppVerData);
final_printf("App ver masked: %s\n", AppVerData);
}
else if (ret_cmp)
{
debug_printf("App ver %s != %s\n", g_game_ver, AppVerData);
debug_printf("Skipping patch entry\n");
final_printf("App ver %s != %s\n", g_game_ver, AppVerData);
final_printf("Skipping patch entry\n");
continue;
}
patch_items++;
Expand All @@ -136,13 +136,13 @@ void get_key_init(void)
const char *gameValue = GetXMLAttr(Line_node, "Value");
const char *gameOffset = nullptr;
// starts with `mask`
if (!startsWith(gameType, "mask"))
if (startsWith(gameType, "mask"))
{
use_mask = true;
}
if (use_mask)
{
if (!startsWith(gameType, "mask_jump32"))
if (startsWith(gameType, "mask_jump32"))
{
const char* gameJumpTarget = GetXMLAttr(Line_node, "Target");
const char* gameJumpSize = GetXMLAttr(Line_node, "Size");
Expand Down Expand Up @@ -260,7 +260,7 @@ s32 attr_public plugin_load(s32 argc, const char* argv[]) {
CurrentModuleInfo.size = sizeof(OrbisKernelModuleInfo);
if(!get_module_info(CurrentModuleInfo, "0", &g_module_base, &g_module_size) && (!g_module_base || !g_module_size))
{
final_printf("Could not find module info for current process\n");
NotifyStatic(TEX_ICON_SYSTEM, "Could not find module info for current process");
return -1;
}
final_printf("Module start: 0x%lx 0x%x\n", g_module_base, g_module_size);
Expand Down
Loading

0 comments on commit 91c6260

Please sign in to comment.