Guest User

Call of Duty

a guest
May 31st, 2025
5,795
1
Never
1
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 5.40 KB | None | 1 0
  1. /*
  2.  
  3.     In the spirit of Call of Duty preservation, this source is being provided to help others in cracking Call of Duty builds.
  4.     Only about a week was spent figuring this out with the initial focus being for Campaign and Zombies builds as they're both
  5.     enjoyable without LAN, but seeing the community's broader ambitions, this code is being released rather than gatekept,
  6.     and hope others will follow suit to hopefully help create an open-source, drama-free community for all recent
  7.     IW-based CODs.
  8.    
  9.     This is a very basic demonstration, but shows how easy offline is to achieve in these Call of Duty titles. The provided
  10.     offsets are for the latest battle net build of Call of Duty Vanguard, but the same functions and concepts apply across
  11.     other recent IW-based COD titles, with only minor differences. Everything provided is tailored for battle net authentication;
  12.     authentication methods for other platforms may vary.
  13.    
  14.     For builds with arxan integrity checks, recommend referring to this github repo: https://github.com/mallgrab/CWHook
  15.     Hooking utils were taken from this github repo: https://github.com/auroramod/h1-mod/tree/develop/src/common/utils
  16.  
  17.     It was also very saddening to learn some ego-driven narcissists were lashing out over our previous releases, praying they can
  18.     get the help they require.
  19.    
  20.     Enjoy!
  21.    
  22. */
  23.  
  24. struct lua_State {
  25.  
  26. };
  27.  
  28. enum StatsSource : __int8
  29. {
  30.     STATS_ONLINE = 0x0,
  31.     STATS_OFFLINE = 0x1,
  32.     STATS_COUNT = 0x2,
  33. };
  34.  
  35. struct CoDUserData {
  36.     int signinState;
  37.     char gamertag[36];
  38.     int gamertagSuffix;
  39.     int hashOfGamertag;
  40.     char platformGamertag[64];
  41.     char fullGamertag[36];
  42.     uint64_t xuid;
  43.     char xuidString[21];
  44.     uint64_t platformId;
  45.     char platformIdString[21];
  46. };
  47.  
  48. CoDUserData* GetUserData(int controllerIndex) {
  49.     return reinterpret_cast<CoDUserData*(*)(int)>(0x277B8D0_b)(controllerIndex);
  50. }
  51.  
  52. void GamerProfile_LogInProfile(int controller) {
  53.     reinterpret_cast<void(*)(int)>(0x3DA1780_b)(controller);
  54. }
  55.  
  56. void LoadSavedAchievements() {
  57.     reinterpret_cast<void(*)()>(0x2133940_b)();
  58. }
  59.  
  60. void lua_pushboolean(lua_State* luaVM, int b) {
  61.     reinterpret_cast<void(*)(lua_State*, int)>(0x7473710_b)(luaVM, b);
  62. }
  63.  
  64. void LiveStorage_StatsInit(const int controllerIndex, bool clear, bool freshStart, StatsSource statsSource) {
  65.     reinterpret_cast<void(*)(const int, bool, bool, StatsSource)>(0x2A0D0D0_b)(controllerIndex, clear, freshStart, statsSource);
  66. }
  67.  
  68. int Lua_ReturnTrue(lua_State* luaVM) {
  69.     lua_pushboolean(luaVM, 1);
  70.     return 1;
  71. }
  72.  
  73. bool AlwaysTrue() {
  74.     return true;
  75. }
  76.  
  77. void PlatformPatches() {
  78.     uintptr_t platformData = 0x9AD1DD8_b;
  79.     utils::hook::set<int>(platformData, 2);
  80.     utils::hook::set<bool>(platformData + 0x2D0, true);
  81.  
  82.     /*
  83.         these two patches are optional, but prevent battle net connectivity issues if previous account info is stored,
  84.         alternatively, clearing the registry keys on game startup using winreg functions is also an option
  85.         Computer\HKEY_CURRENT_USER\SOFTWARE\Blizzard Entertainment\Battle.net\Launch Options\FORE
  86.     */
  87.     utils::hook::nop(0x4129A7E_b, 5);
  88.     utils::hook::nop(0x41298D5_b, 5);
  89.  
  90.     // allow playing without internet connected
  91.     utils::hook::jump(0x412B400_b, AlwaysTrue);
  92. }
  93.  
  94. void ProfilePatches() {
  95.  
  96.     /*
  97.         XUID and XUID string must be set to enter matches, otherwise you'll be kicked when entering a match
  98.         for providing a bad userinfo string
  99.     */
  100.  
  101.     uint64_t xuidValue = 0x12345678;
  102.     const char* xuid_string = va("%Iu", xuidValue);
  103.  
  104.     CoDUserData* profile = GetUserData(0);
  105.     profile->signinState = 2;
  106.  
  107.     const char* username = "Player";
  108.  
  109.     strncpy_s(profile->gamertag, sizeof(profile->gamertag), username, _TRUNCATE);
  110.     strncpy_s(profile->platformGamertag, sizeof(profile->platformGamertag), username, _TRUNCATE);
  111.     strncpy_s(profile->fullGamertag, sizeof(profile->fullGamertag), username, _TRUNCATE);
  112.  
  113.     // since this is local only, theres no need for this to be unique
  114.     profile->xuid = xuidValue;
  115.     strncpy_s(profile->xuidString, xuid_string, sizeof(profile->xuidString));
  116.  
  117.     // should always be the same as this is used for loading settings in 'Documents/GAME/players'
  118.     profile->platformId = xuidValue;
  119.     strncpy_s(profile->platformIdString, xuid_string, sizeof(profile->platformIdString));
  120.  
  121.     // initializes gamerprofile settings and SP DDL
  122.     GamerProfile_LogInProfile(0);
  123.     LoadSavedAchievements();
  124. }
  125.  
  126. // apply near game start
  127. void LaunchPatches() {
  128.     // IsPremiumPlayer
  129.     utils::hook::jump(0x6795230_b, Lua_ReturnTrue);
  130.     // OfflineDataFetched
  131.     utils::hook::jump(0x72FDE00_b, Lua_ReturnTrue);
  132.     // 2C8B174B6BF663C4
  133.     utils::hook::jump(0x6795FE0_b, Lua_ReturnTrue);
  134.  
  135.     /*
  136.         force the force_offline_menus dvar to register as true,
  137.         alternatively can either patch "ui/utils/bootutils.lua" to enable the "Go Offline" button,
  138.         or use LUI_OpenMenu function to open "MainMenuOffline"
  139.     */
  140.     memcpy((void*)0x2A7C246_b, "\xB2\x01", 2);
  141.     // patch Live_IsInSystemlinkLobby (needed for maps to load/start)
  142.     memcpy((void*)0x38BC6A0_b, "\xB0\x01", 2);
  143. }
  144.  
  145. // best to call after platform initialization
  146. void GeneralPatches() {
  147.     PlatformPatches();
  148.     ProfilePatches();
  149.  
  150.     // online stats
  151.     utils::hook::set<char>(0x107693D8_b, 1);
  152.     // offline stats
  153.     utils::hook::set<char>(0x107693D8_b + 0x2585C, 1);
  154.     // init stats
  155.     LiveStorage_StatsInit(0, 1, 0, STATS_ONLINE);
  156.  
  157.     // fix sp launch
  158.     utils::hook::set<int>(0x11BA1894_b, 0);
  159.  
  160. }
Advertisement
Comments
  • yalli12712
    1 year (edited)
    # text 0.13 KB | 0 0
    1. Hi I am a noob but I downloaded the file and where do I put the file for it to connect to the game.
    2. sorry for the stupid question
Add Comment
Please, Sign In to add comment