mirror of https://github.com/Nonannet/copapy.git
c code updated with discrete type conversions
This commit is contained in:
parent
2bbe6ad0ce
commit
8b69fa8ce7
|
|
@ -53,7 +53,7 @@ int main(int argc, char *argv[]) {
|
|||
fprintf(stderr, "Usage: %s <code_file> <memory_dump_file>\n", argv[0]);
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
FILE *f = fopen(argv[2], "wb");
|
||||
f = fopen(argv[2], "wb");
|
||||
fwrite(executable_memory, 1, (size_t)executable_memory_len, f);
|
||||
fclose(f);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -28,9 +28,9 @@ void patch(uint8_t *patch_addr, uint32_t patch_mask, int32_t value) {
|
|||
uint32_t *val_ptr = (uint32_t*)patch_addr;
|
||||
uint32_t original = *val_ptr;
|
||||
|
||||
int32_t shift_factor = patch_mask & -patch_mask;
|
||||
uint32_t shift_factor = patch_mask & -patch_mask;
|
||||
|
||||
uint32_t new_value = (original & ~patch_mask) | ((uint32_t)(value * shift_factor) & patch_mask);
|
||||
uint32_t new_value = (original & ~patch_mask) | (((uint32_t)value * shift_factor) & patch_mask);
|
||||
|
||||
*val_ptr = new_value;
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue