Simple Lua-scriptable runtime binary patcher
building
$ cargo build --release
usage
Copy target/release/bitfix.dll next to the exe to be patched and name it something that will get loaded, such as d3d9.dll or x3daudio1_7.dll.
Lua patches will be loaded from a bitfix/ directory.
examples
Increasing MaxAttackers to 200 in DRG:
-- bitfix/max_attackers.lua return { { --- UPlayerAttackPositionComponent::GetScore pattern = '48 89 5C 24 08 48 89 6C 24 10 48 89 74 24 18 57 48 83 EC 30 48 8B 01 41 0F', match = function(ctx) ctx[ctx:address() + 89] = 200 ctx[ctx:address() + 187] = 200 end }, { --- UAttackerPositioningComponent::UAttackerPositioningComponent pattern = '48 89 5C 24 08 48 89 6C 24 10 48 89 74 24 18 48 89 7C 24 20 41 56 48 81 EC D0 00 00 00 48 8B F9 E8 ?? ?? ?? ?? 48 8B D0 48 8B CF E8 ?? ?? ?? ?? 33 DB', match = function(ctx) ctx[ctx:address() + 56] = 200 end } }
Allow sticky flames to stick to any actor, not just terrain:
-- bitfix/stickier_flame.lua local patch = function(offset, distance) return function(ctx) ctx[ctx:address() + offset] = 0xEB ctx[ctx:address() + offset + 1] = distance end end return { --- UStickyFlameSpawner::TrySpawnStickyFlameHit { pattern = '48 89 5c 24 08 48 89 6c 24 10 48 89 74 24 18 57 48 83 ec 70 48 8b f9 48 8b f2 48 8d 4a 68', match = patch(0x2C, 0x32) }, { pattern = '48 89 5c 24 08 48 89 6c 24 10 48 89 74 24 18 57 48 83 ec 40 48 8b e9 48 8b fa 48 8d 4a 68', match = patch(0x28, 0x2A) }, }
Stop the drop pod from eating flares. (why does it do this?)
-- bitfix/non_flare_devouring_drop_pod.lua return { { pattern = '3B 51 ?? 7F ?? 48 8B 49 ?? 48 39 04 D1 75 ?? 48 8B D3 48 8B CF E8 ?? ?? ?? ?? 48 8B 5C 24', match = function(ctx) ctx[ctx:address() + 13] = 0xEB end }, }
Fix game crashing if more than 8 players are in the lobby during mission load
-- bitfix/increased_players_fix.lua return { { pattern = '48 8b c4 48 89 48 08 55 57 48 8d a8 58 ff ff ff 48 81 ec 98 01 00 00 48 83 79 30 00 48 8b f9 0f 84', match = function(ctx) ctx[ctx:address()] = 0xC3 end } }
Allow scaling beyond hard coded limit of 4 players in a lobby. NOTE: Make sure all player count based arrays in difficulty settings have enough values for the number of players or bad things will happen!
-- bitfix/increased_players_difficulty_scaling_fix.lua local patch = function(ctx) ctx[ctx:address() + 1] = 0xff end return { { match = patch, pattern = 'ba 04 00 00 00 3b c2 0f 4e d0' }, { match = patch, pattern = 'b9 04 00 00 00 3b c1 0f 4e c8' }, { match = patch, pattern = 'b9 04 00 00 00 8b 80 ?? ?? 00 00 3b c1 0f 4d c1' }, { match = patch, pattern = 'b9 04 00 00 00 8b 40 08 3b c1 0f 4d c1' }, }
Show normal terrain on terrain scanner instead of scanner material.
-- bitfix/normal_terrain_scanner_mat.lua return { { pattern = '74 ?? 49 8B 4C 24 ?? EB ?? 49 8B 0C 24', match = function(ctx) ctx[ctx:address()] = 0x75 end } }
Prevent explosions from scattering minerals.
-- bitfix/no-scatter.lua return { { --- FGrenadeExplodeOperation::FGrenadeExplodeOperation pattern = 'f3 0f 11 43 ?? 76 14 f3', match = function(ctx) ctx[ctx:address() + 0x00] = 0x90 ctx[ctx:address() + 0x01] = 0x90 ctx[ctx:address() + 0x02] = 0x90 ctx[ctx:address() + 0x03] = 0x90 ctx[ctx:address() + 0x04] = 0x90 end } }