Skip to content

Commit

Permalink
Add cheats for Fallout 4
Browse files Browse the repository at this point in the history
  • Loading branch information
visuve committed Mar 31, 2024
1 parent a16a9c3 commit b9d7d43
Show file tree
Hide file tree
Showing 3 changed files with 66 additions and 0 deletions.
6 changes: 6 additions & 0 deletions Fallout4/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
file(GLOB SourceFiles "*.cpp" "*.asm")

set(Executable "Fallout4Trainer")
add_executable(${Executable} ${SourceFiles})
target_precompile_headers(${Executable} REUSE_FROM HackLib)
target_link_libraries(${Executable} LINK_PRIVATE HackLib EntryPoint)
25 changes: 25 additions & 0 deletions Fallout4/Fallout4.asm
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
.CODE

InfAmmoFirearms PROC
mov [rsp + 000001E0h], r13 ; stolen
mov [rsp + 000001A0h], r15 ; stolen

mov r15, [rbp] ; "loan" *

cmp r15, 0
je TheEnd
xor r12, r12 ; r12 will be subtracted from the clip ammo
jmp TheEnd
IsEnemy:
; For some odd reason, this do not seem to have any effect
; on the enemies, even though it should.
; mov r12, 255
TheEnd:
mov r15, [rsp+000001A0h] ; * put back

int 3
int 3
int 3
InfAmmoFirearms ENDP

END
35 changes: 35 additions & 0 deletions Fallout4/Fallout4.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
#include "HackLib.hpp"

extern "C" void InfAmmoFirearms();

int IWillNotUseHackLibForEvil(const std::vector<std::string>& givenArguments)
{
const CommandLine args(givenArguments,
{
{ "infammo", typeid(std::nullopt), "Infinite ammo" },
});

DWORD pid = System::WaitForWindow(L"Fallout4");

Process process(pid);

if (!process.Verify("55f57947db9e05575122fae1088f0b0247442f11e566b56036caa0ac93329c36"))
{
LogError << "Expected Fallout 4 (Steam)";
System::BeepBurst();
return ERROR_REVISION_MISMATCH;
}

process.WaitForIdle();
System::BeepUp();

if (args.Contains("infammo"))
{
auto infAmmo = Process::ReadFunction(InfAmmoFirearms);
process.InjectX64(0xDFD8EC, 2, infAmmo);
}

process.WairForExit();

return 0;
}

0 comments on commit b9d7d43

Please sign in to comment.