Wrapping function call in ASM with C++ function via Detours

  • Thread starter Thread starter FiftyTifty
  • Start date Start date
F

FiftyTifty

Guest
Using X86DBG and IDA, I've found a function that's called every frame in Fallout: New Vegas, that displays the player's menu screen. There is an API called New Vegas Script Extender, which allows me to write directly to the process' memory through C++, with access to the game's pointers, records, classes, and such.

The function being called in the game's assembly code is TryToOpenPipboy. I've located the address where it's called in the game's main loop 0x0070E913, as well as the address of the function itself 0x0070F4E0. If I were to use CheatEngine, it would be trivial to wrap the function call and inject the custom code, as all that is abstracted away; type in the code, and it takes care of everything else. I was informed that Microsoft Detours trivializes this, so I've got it included.

I think I've done it properly in C++, but the compiler throws the following five errors:

Error LNK2019 unresolved external symbol "public: unsigned long __thiscall TESObjectREFR::GetItemCount(class TESForm *)" (?GetItemCount@TESObjectREFR@@QAEKPAVTESForm@@@Z) referenced in function "void __cdecl EquipPlayerPipboy(void)" (?EquipPlayerPipboy@@YAXXZ)
Error LNK2019 unresolved external symbol _DetourTransactionBegin@0 referenced in function "void __cdecl MessageHandler(struct NVSEMessagingInterface::Message *)" (?MessageHandler@@YAXPAUMessage@NVSEMessagingInterface@@@Z)
Error LNK2019 unresolved external symbol _DetourTransactionCommit@0 referenced in function "void __cdecl MessageHandler(struct NVSEMessagingInterface::Message *)" (?MessageHandler@@YAXPAUMessage@NVSEMessagingInterface@@@Z)
Error LNK2019 unresolved external symbol _DetourUpdateThread@4 referenced in function "void __cdecl MessageHandler(struct NVSEMessagingInterface::Message *)" (?MessageHandler@@YAXPAUMessage@NVSEMessagingInterface@@@Z)
Error LNK2019 unresolved external symbol _DetourAttach@8 referenced in function "void __cdecl MessageHandler(struct NVSEMessagingInterface::Message *)" (?MessageHandler@@YAXPAUMessage@NVSEMessagingInterface@@@Z)
Error LNK1120 5 unresolved externals aaafyty_pipboy_remover S:\Games\Fallout New Vegas\Data\nvse\plugins\aaafyty_pipboy_remover.dll 1


Archive of the project (requires 2013 toolset to compile): MEGA

Why are these errors being thrown?

Continue reading...
 
Back
Top