summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorIru Cai <mytbk920423@gmail.com>2018-09-29 01:24:49 +0800
committerIru Cai <mytbk920423@gmail.com>2018-09-29 01:24:49 +0800
commit09ffedb60dc6d2e8abca77ecf3bebcaefa483c1b (patch)
tree773187d9df11c41f50c8780cd8ae846ad38474e2
parent6a45c9381f9af9e201bf421fa11b65cba1e2ba95 (diff)
downloadrich4-09ffedb60dc6d2e8abca77ecf3bebcaefa483c1b.tar.xz
[WIP] 0x455040
it doesn't crash, but the data is different
-rw-r--r--csrc/mkf_asm.asm2
-rw-r--r--csrc/mkf_asm_data.c47
2 files changed, 49 insertions, 0 deletions
diff --git a/csrc/mkf_asm.asm b/csrc/mkf_asm.asm
index 05a0154..2a9d9b1 100644
--- a/csrc/mkf_asm.asm
+++ b/csrc/mkf_asm.asm
@@ -8,8 +8,10 @@ extern cfcn_45511b
extern cfcn_004550cc
extern cfcn_00455109
extern cfcn_004551bb
+extern cfcn_00455040
fcn_00455040:
+;jmp cfcn_00455040
push ebp
mov ebp, esp
push ebx
diff --git a/csrc/mkf_asm_data.c b/csrc/mkf_asm_data.c
index 95b4364..032034a 100644
--- a/csrc/mkf_asm_data.c
+++ b/csrc/mkf_asm_data.c
@@ -628,3 +628,50 @@ void cfcn_004551bb(uint16_t *esi, uint32_t *ecx, uint32_t *ebx)
bx >>= 1;
*ebx = bx;
}
+
+void cfcn_00455040(void *arg1, void *arg2)
+{
+ uint32_t bx;
+ uint32_t eax, ecx, edx;
+
+ memcpy(&gtables, data_483630, sizeof(gtables));
+ ecx = 0; /* after a rep movsd */
+ void *edi = arg1;
+ void *esi = arg2;
+ edx = 0;
+
+ while (1) {
+ cfcn_004551bb(esi, &ecx, &bx);
+ if ((bx & 0xff00) == 0) {
+ *(char*)edi = bx & 0xff;
+ edi++;
+ continue;
+ }
+ eax = ecx;
+ uint32_t old_ecx = ecx;/* push ecx */
+ eax >>= 3;
+ ecx &= 7;
+ eax = *(uint32_t*)(esi + eax);
+ eax >>= ecx;
+ size_t ebp = eax & 0xff;
+ uint8_t cl = table_483530[ebp];
+ uint8_t dh = table_483430[ebp];
+ eax >>= cl;
+ uint8_t dl = eax << 2;
+ uint16_t dx = (((uint16_t)dh << 8) | dl) >> 2;
+ cl += 6;
+ eax = cl;
+ /* pop ecx */
+ ecx = old_ecx + eax;
+ if (dx == 0xfff)
+ return;
+ old_ecx = ecx; /* backup ecx */
+ bx -= 0xfd;
+ void *old_esi = esi; /* push esi */
+ esi = edi - 1 - dx;
+ memcpy(edi, esi, bx); /* using rep movsb */
+ edi += bx; /* by movsb */
+ esi = old_esi; /* pop esi */
+ ecx = old_ecx; /* restore ecx */
+ }
+}