summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLudovic Pouzenc <lpouzenc@gmail.com>2013-09-15 14:27:20 +0200
committerLudovic Pouzenc <lpouzenc@gmail.com>2013-09-15 14:27:20 +0200
commitca1e187d31d6a1e49722542b6f525ad45ce32526 (patch)
treeff6fbc2b674f0e61d765761707fa30fd3d7bbf33
parente6e4e0ea3c6b615a8b77db66f3a0f0821b9620ba (diff)
downloadmplemmings-ca1e187d31d6a1e49722542b6f525ad45ce32526.tar.gz
mplemmings-ca1e187d31d6a1e49722542b6f525ad45ce32526.tar.bz2
mplemmings-ca1e187d31d6a1e49722542b6f525ad45ce32526.zip
Ajout du second breakpoint et des struct pour faire le avant/apres
-rw-r--r--reverse-engineering/dosbox_snif/main_validate_code.c40
1 files changed, 28 insertions, 12 deletions
diff --git a/reverse-engineering/dosbox_snif/main_validate_code.c b/reverse-engineering/dosbox_snif/main_validate_code.c
index 44728ce..fb76c0b 100644
--- a/reverse-engineering/dosbox_snif/main_validate_code.c
+++ b/reverse-engineering/dosbox_snif/main_validate_code.c
@@ -15,9 +15,10 @@ int main(int argc, char *argv[]) {
int rv, i, end=0, byte, loops;
struct rsp_state rsp;
char ds_si[10], command[16], hex_byte[3];
- unsigned int addr, bs, size, offset;
+ unsigned int addr, size, offset;
+ unsigned int bs=0x100; /* RSP memdump block size */
- struct game_data g;
+ struct game_data g_before, g_after, g_simulated, *g;
struct _lemm_data *lemm;
hex_byte[2]='\0';
@@ -28,6 +29,12 @@ int main(int argc, char *argv[]) {
return 1;
}
+ rsp_query(&rsp, "Z0,2F7B,1"); // Set execution breakpoint at 0208:0EFB (0x2F7B, return point of move_lemmings() )
+ if ( rsp_check_and_clear(&rsp, "OK") != 0 ) {
+ printf("Error when setting addition breakpoint\n");
+ return 1;
+ }
+
loops=0;
while (!end) {
loops++;
@@ -42,10 +49,13 @@ int main(int argc, char *argv[]) {
continue;
}
- //if ( loops % 10 != 0 ) continue;
+ rsp_query(&rsp, "p8"); // Read $eip
+ if ( rsp_check_and_clear(&rsp, "c4380000") ) {
+ g = &g_before;
+ } else {
+ g = &g_after;
+ }
- // From the beginning of the ds segment
- bs = 0x100;
//printf("sizeof(struct game_data) == %i\n", sizeof(struct game_data) );
for (offset=0 ; offset < sizeof(struct game_data) ; offset += size) {
@@ -66,18 +76,24 @@ int main(int argc, char *argv[]) {
printf("Bug decode\n");
break;
}
- ((char *)&g)[offset+i] = byte;
+ ((char *)g)[offset+i] = byte;
//printf("((char *)&g)[0x%02x] = 0x%02x\n", offset+i, byte);
}
}
//printf("\n");
- lemm = g.lemmings;
- //printf("g.paused == %x (off %02x)\n", g.paused, (void *)&g.paused - (void *)&g);
- printf("g.lemm_spawned_count == %x (off %02x)\n", g.lemm_spawned_count, (void *)&g.lemm_spawned_count - (void *)&g);
- //printf("g.lemm_out_count == %x (off %02x)\n", g.lemm_out_count, (void *)&g.lemm_out_count - (void *)&g);
- //printf("g.lemm_level_count == %x (off %02x)\n", g.lemm_level_count, (void *)&g.lemm_level_count - (void *)&g);
- //printf("lemm->draw_hint == %x (off %02x)\n", lemm->draw_hint, (void *)&lemm->draw_hint - (void *)&g);
+ if ( g == &g_before ) {
+ //TODO : exec local func
+ } else {
+ //TODO : exec comparison on states
+ lemm = g_after.lemmings;
+ //printf("g_after.paused == %x (off %02x)\n", g_after.paused, (void *)&g_after.paused - (void *)&g);
+ printf("g_after.lemm_spawned_count == %x (off %02x)\n", g_after.lemm_spawned_count, (void *)&g_after.lemm_spawned_count - (void *)&g_after);
+ printf("g_after.lemm_out_count == %x (off %02x)\n", g_after.lemm_out_count, (void *)&g_after.lemm_out_count - (void *)&g_after);
+ printf("g_after.lemm_level_count == %x (off %02x)\n", g_after.lemm_level_count, (void *)&g_after.lemm_level_count - (void *)&g_after);
+ printf("lemm->draw_hint == %x (off %02x)\n", lemm->draw_hint, (void *)&lemm->draw_hint - (void *)&g_after);
+ }
+
}
rsp_quit(&rsp);