Minor documentation improvements

This commit is contained in:
mid-kid 2025-04-28 22:37:17 +02:00
parent d7ba4588a0
commit 7d29e79f3e
3 changed files with 21 additions and 5 deletions

View File

@ -9,7 +9,12 @@
//
// Unfortunately, the reallocated memory contains pointers, which differ
// depending on the OS and ASLR. This code tries to allow control over it.
//
// The saving grace to this, is that this UB seems to only affect builds
// without optimizations enabled (-O0). Unfortunately, some of the standard
// libraries (mw-libraries) are built like this.
// Enable the code that allows controlling the behavior
#define SKREW_HACK01
void bitarr_cpy(uint32_t *dst, uint32_t *src, int len); // 0x00581750
@ -29,17 +34,20 @@ void FUN_00505340(void)
uint32_t *curbits = prog_malloc(wordlen * sizeof(**DAT_0063ccf0));
#ifdef SKREW_HACK01
// Keep track of which entries have been initialized
uint8_t _init[DAT_0063a798]; (void)_init;
memset(_init, 0, DAT_0063a798);
_init[DAT_0063a828->unk_1c] = 1;
#endif
bitarr_set(DAT_0063ccf0[DAT_0063a828->unk_1c], DAT_0063a798, 0);
DAT_0063ccf0[DAT_0063a828->unk_1c][0] |= 1;
for (struct STRUC_0063a828 *listptr = DAT_0063a828->next;
listptr; listptr = listptr->next) {
#ifdef SKREW_HACK01
_init[listptr->unk_1c] = 1;
#endif
bitarr_set(DAT_0063ccf0[listptr->unk_1c], DAT_0063a798, -1);
}

View File

@ -16,6 +16,7 @@
// WSL1, or some cygwin/msys environment). Additionally, backslashes are used
// as a path separator on linux, where they shouldn't be.
// Enables the depfile fix
#define SKREW_FIX_DEPFILES
#ifdef SKREW_FIX_DEPFILES
@ -194,6 +195,9 @@ char *relpath(const char *cwd, const char *dst)
}
#endif
// Struct offsets for a specific version of metrowerks
// Can't make it a real struct since it differs between versions
// Generated using scan.c
extern const int depfile_struct__source;
extern const int depfile_struct__targets;
extern const int depfile_struct__num_headers;

View File

@ -53,14 +53,18 @@ incbin patch.end, (pe_text_off + pe_text_len - patch.end)
wjmp patch_getenv
.endm
.macro patch_FUN_00505340
wjmp FUN_00505340
.endm
# Patch the depfile (-M/-MM/-MD/-MMD) output
# See depfile_build.c
.macro patch_depfile_build
wjmp depfile_build
.endm
# Allow controlling undefined behavior affecting compiler output
# See FUN_00505340.c
.macro patch_FUN_00505340
wjmp FUN_00505340
.endm
# The actual code
.section .patch_pe_text, "ax"
pe_text: