From 54acd931da40f3dc8f1a6247a57896f3ec2dee9b Mon Sep 17 00:00:00 2001 From: Martin Michelsen Date: Mon, 9 Jun 2025 10:00:11 -0700 Subject: [PATCH] use .label/.address in xbox client functions --- src/CommandFormats.hh | 18 ++++++++------- .../Decoction/Decoction.4___.patch.s | 10 ++++---- .../DisableIdleDisconnect.4___.patch.s | 3 ++- .../DrawDistance/DrawDistance.4___.patch.s | 23 ++++++++++++++----- 4 files changed, 34 insertions(+), 20 deletions(-) diff --git a/src/CommandFormats.hh b/src/CommandFormats.hh index 2c1859d4..b242b10a 100644 --- a/src/CommandFormats.hh +++ b/src/CommandFormats.hh @@ -4012,17 +4012,19 @@ struct G_SymbolChat_6x07 { // 6x08: Invalid subcommand -// 6x09: Unknown +// 6x09: Kill enemy (broken/unused) // header.entity_id is expected to be an enemy ID, but is also expected to be -// in the range [0x00, 0x80) since it writes to an array of 0x80 entries. This -// duality makes no sense because enemy IDs are greater than or equal to -// 0x1000, so any valid enemy ID would be far outside the array's range, and -// the write is not bounds-checked. For this reason, newserv unconditionally -// blocks this command. +// in the range [0x00, 0x80) since the command handler writes to an array of +// 0x80 entries. This duality is nonsense because enemy IDs are greater than or +// equal to 0x1000, so any valid enemy ID would be far outside the array's +// range. newserv unconditionally blocks this command because it appears never +// to be used, and the array write is not bounds-checked, so it could be used +// to cause undefined behavior on other clients. It seems that this broken +// logic predates even DC NTE. -struct G_Unknown_6x09 { +struct G_LegacyKillEnemy_6x09 { G_EntityIDHeader header; -} __packed_ws__(G_Unknown_6x09, 4); +} __packed_ws__(G_LegacyKillEnemy_6x09, 4); // 6x0A: Update enemy state // In Ultimate mode, the low 6 bits of game_flags are ignored, and 6x9C is used diff --git a/system/client-functions/Decoction/Decoction.4___.patch.s b/system/client-functions/Decoction/Decoction.4___.patch.s index 233a3e05..a4adb079 100644 --- a/system/client-functions/Decoction/Decoction.4___.patch.s +++ b/system/client-functions/Decoction/Decoction.4___.patch.s @@ -14,8 +14,11 @@ start: .include WriteCodeBlocksXB .data .deltaof code_start, code_end + .address code_start: - mov eax, 0x88888888 # eax = &player_compute_implied_stats (the value is overwritten by the including patch) + + .label player_compute_implied_stats, + lea edx, [ecx + 0x78] cmp byte [edx + 0x76], 11 # this->data1[2] (item+0xEE) ?= 0x0B jne skip_all @@ -43,7 +46,7 @@ next_stat: jne next_stat mov ecx, ebx - call eax # player_compute_implied_stats + call player_compute_implied_stats lea ecx, [ebx + 0x0330] @@ -62,8 +65,5 @@ skip_all: ret code_end: - .data - .data 0x00000004 - .data .data 0x00000000 .data 0x00000000 diff --git a/system/client-functions/DisableIdleDisconnect/DisableIdleDisconnect.4___.patch.s b/system/client-functions/DisableIdleDisconnect/DisableIdleDisconnect.4___.patch.s index d4dd8aac..de77fa33 100644 --- a/system/client-functions/DisableIdleDisconnect/DisableIdleDisconnect.4___.patch.s +++ b/system/client-functions/DisableIdleDisconnect/DisableIdleDisconnect.4___.patch.s @@ -11,7 +11,8 @@ start: .data .data 0x00000004 - .binary 31C9EB03 + xor ecx, ecx + jmp +3 .data 0x00000000 .data 0x00000000 diff --git a/system/client-functions/DrawDistance/DrawDistance.4___.patch.s b/system/client-functions/DrawDistance/DrawDistance.4___.patch.s index 82a08162..40e25dd0 100644 --- a/system/client-functions/DrawDistance/DrawDistance.4___.patch.s +++ b/system/client-functions/DrawDistance/DrawDistance.4___.patch.s @@ -15,12 +15,14 @@ start: .data # From 3OE1:80100B8C .deltaof p1_1s, p1_1e + .address # From 3OE1:80100B8C p1_1s: - .binary E87B020000 # call p1_2s + call p1_2s nop p1_1e: .data .deltaof p1_2s, p1_2e + .address p1_2s: fld st0, dword [esp + 0x1C] fadd st0, st0 @@ -30,11 +32,13 @@ p1_2e: .data # From 3OE1:80156AD8 .deltaof p2_1s, p2_1e + .address # From 3OE1:80156AD8 p2_1s: - .binary E844000000 # call p2_2s + call p2_2s p2_1e: .data .deltaof p2_2s, p2_2e + .address p2_2s: fld st0, dword [ecx + 0x1C] fadd st0, st0 @@ -44,12 +48,14 @@ p2_2e: .data # From 3OE1:801A2040 .deltaof p3_1s, p3_1e + .address # From 3OE1:801A2040 p3_1s: - .binary E8DA000000 # call p3_2s + call p3_2s nop p3_1e: .data .deltaof p3_2s, p3_2e + .address p3_2s: fld st0, dword [esp + 0x24] fadd st0, st0 @@ -59,12 +65,14 @@ p3_2e: .data # From 3OE1:801A2240 .deltaof p4_1s, p4_1e + .address # From 3OE1:801A2240 p4_1s: - .binary # call p4_2s + call p4_2s nop p4_1e: .data .deltaof p4_2s, p4_2e + .address p4_2s: fld st0, dword [esp + 0x28] fadd st0, st0 @@ -74,16 +82,19 @@ p4_2e: .data # From 3OE1:80205840 .deltaof p5_1s, p5_1e + .address # From 3OE1:80205840 p5_1s: - .binary # call p5_3s + call p5_3s p5_1e: .data # From 3OE1:80205FE4 .deltaof p5_2s, p5_2e + .address # From 3OE1:80205FE4 p5_2s: - .binary # call p5_3s + call p5_3s p5_2e: .data .deltaof p5_3s, p5_3e + .address p5_3s: fld st0, dword [eax + 0x0C] fadd st0, st0