Skip to content

Commit

Permalink
Remove the file_size_patch breakpoint.
Browse files Browse the repository at this point in the history
  • Loading branch information
nmlgc committed May 26, 2014
1 parent f6fa4cb commit 68f18ef
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 46 deletions.
28 changes: 5 additions & 23 deletions thcrap/src/bp_file.c
Original file line number Diff line number Diff line change
Expand Up @@ -107,34 +107,16 @@ int BP_file_size(x86_reg_t *regs, json_t *bp_info)
// Parameters
// ----------
size_t *file_size = json_object_get_register(bp_info, regs, "file_size");
int set_patch_size = !(json_is_false(json_object_get(bp_info, "set_patch_size")));
// ----------
// Other breakpoints
// -----------------
BP_file_name(regs, bp_info);
// -----------------
if(file_size && !fr->pre_json_size) {
fr->pre_json_size = *file_size;
}
if(set_patch_size) {
BP_file_size_patch(regs, bp_info);
}
return 1;
}

int BP_file_size_patch(x86_reg_t *regs, json_t *bp_info)
{
file_rep_t *fr = fr_tls_get();

// Parameters
// ----------
size_t *file_size = json_object_get_register(bp_info, regs, "file_size");
// ----------
size_t post_json_size = POST_JSON_SIZE(fr);
// Yes, these checks are necessary because th08 needs to place this
// breakpoint on a generic memory allocation call.
if(file_size && fr->pre_json_size && fr->pre_json_size != post_json_size) {
*file_size = post_json_size;
if(file_size && (fr->pre_json_size || fr->patch_size || fr->hooks) ) {
if(!fr->pre_json_size) {
fr->pre_json_size = *file_size;
}
*file_size = POST_JSON_SIZE(fr);
}
return 1;
}
Expand Down
22 changes: 0 additions & 22 deletions thcrap/src/bp_file.h
Original file line number Diff line number Diff line change
Expand Up @@ -76,34 +76,12 @@ int BP_file_name(x86_reg_t *regs, json_t *bp_info);
* Register that contains the size of the file to load.
* Type: register
*
* [set_patch_size]
* Set to false to skip the call to BP_file_size().
* Type: bool
*
* Other breakpoints called
* ------------------------
* BP_file_name
*/
int BP_file_size(x86_reg_t *regs, json_t *bp_info);

/**
* Writes the post-JSON file size to the game's memory. This is a separate
* breakpoint because th08's archive decompression algorithm produces bogus
* data after the end of the original file in case a larger than expected
* file size is written at BP_file_size().
*
* Own JSON parameters
* -------------------
* [file_size]
* Register to write the patch size to.
* Type: register
*
* Other breakpoints called
* ------------------------
* None
*/
int BP_file_size_patch(x86_reg_t *regs, json_t *bp_info);

/**
* Reads the file buffer address and stores it in the local file_rep_t object.
*
Expand Down
1 change: 0 additions & 1 deletion thcrap/thcrap.def
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ EXPORTS

BP_file_name
BP_file_size
BP_file_size_patch
BP_file_buffer
BP_file_load
BP_file_loaded
Expand Down

0 comments on commit 68f18ef

Please # to comment.