Ask Question

Name:
Title:
Your Question:

Answer Question

Name:
Your Answer:
User Submitted Source Code!


Description:
  1
Language: C/C++
Code:
#include <thread>
#include <iostream>
#include <Windows.h>
#include <TlHelp32.h>
 
DWORD GetSigOffset(HANDLE pHandle, DWORD64 mBase, DWORD mSize, BYTE *Sig, const char *Mask, int Len);
bool RPM(HANDLE pHandle, DWORD64 src, void *dst, size_t Size);
bool WPM(HANDLE pHandle, DWORD64 dst, void *src, size_t Size);
DWORD64 AllocEx(HANDLE pHandle, size_t Size);
bool FreeEx(HANDLE pHandle, DWORD64 src);
bool Valid(DWORD64 ptr);
 
class ProcessData
{
public:
     CHAR* pName;
     CHAR* mName;
     BYTE *mBase;
     DWORD mSize;
     DWORD pPid;
     HANDLE pHandle;
};
 
#define WEAPON_INVALID                         0x00000001UL//Default
#define WEAPON_SPEED_FAST                    0x00000002UL//Ranged, melee
#define WEAPON_SPEED_NORMAL                    0x00000004UL//Ranged, melee
#define WEAPON_RELOAD_SPEED_FAST          0x00000008UL//Ranged
#define WEAPON_RELOAD_SPEED_NORMAL          0x00000010UL//Ranged
#define WEAPON_AUTOMATIC_ENABLED          0x00000020UL//Ranged, melee
#define WEAPON_AUTOMATIC_DISABLED          0x00000040UL//Ranged, melee
#define WEAPON_CHARGING_ENABLED               0x00000080UL//Ranged
#define WEAPON_CHARGING_DISABLED          0x00000100UL//Ranged
#define WEAPON_HOLD_TO_FIRE_ENABLED          0x00000200UL//Ranged
#define WEAPON_HOLD_TO_FIRE_DISABLED     0x00000400UL//Ranged
#define WEAPON_REACH_FAR                    0x00000800UL//Ranged, melee
#define WEAPON_REACH_NORMAL                    0x00001000UL//Ranged, melee
#define WEAPON_VATS_COST_ZERO               0x00002000UL//Ranged, melee
#define WEAPON_CAPACITY_HIGH               0x00004000UL//Ranged
#define WEAPON_SWAP_AMMO                    0x00008000UL//Ranged
#define WEAPON_DISABLE_AMMO                    0x00010000UL//Ranged
#define WEAPON_PLAYABLE_MELEE               0x00020000UL//Melee
#define WEAPON_PLAYABLE_RANGED               0x00040000UL//Ranged
#define WEAPON_PROJECTILES_ONE               0x00080000UL//Ranged, grenades
#define WEAPON_PROJECTILES_EIGHT          0x00100000UL//Ranged, greandes
#define WEAPON_PROJECTILES_MAX               0x00280000UL//Ranged, grenades
#define WEAPON_RECOIL_ZERO                    0x00400000UL//Ranged
#define WEAPON_SPREAD_ZERO                    0x00800000UL//Ranged
#define WEAPON_SWAY_ZERO                    0x01000000UL//Ranged
 
DWORD WeaponSource = 0x0030CB79;//Playable ranged weapons get data copied from this weapon
DWORD WeaponList[]
{
     0x004F4A84,//Honey Beast Bee Swarm Spawn
     0x00107BD6,//Baseball Grenade
     0x000EEBED,//Fragmentation Grenade
     0x004E5566,//Mothman AoE Attack
     0x000FC3EC,//Sonic Attack
     0x0010D80A,//Liberator Laser
     0x00004117,//Flatwoods Monster Laser
     0x0014245D,//Bomb
     0x000DF621,//Fire Hydrant Bat
     0x000D1EB0,//Gauss Rifle
     0x0010FAA7,//Salvaged Assaultron Head
     0x0012DBB3,//Pump Action Shotgun
     0x00004822,//10mm Pistol
     0x00113854,//Handmade Rifle
     0x0046D2A1,//The Fixer
     0x000FE268,//Railway Rifle
     0x0005C250,//Board
};
 
DWORD GetWeaponFlags(DWORD Formid)
{
     switch (Formid)
     {
     case 0x004F4A84://Honey Beast Bee Swarm Spawn
          return WEAPON_PLAYABLE_RANGED | WEAPON_VATS_COST_ZERO | WEAPON_SPEED_FAST;
     case 0x00107BD6://Baseball Grenade
          return WEAPON_PROJECTILES_MAX;
     case 0x000EEBED://Fragmentation Grenade
          return WEAPON_PROJECTILES_MAX;
     case 0x004E5566://Mothman AoE Attack
          return WEAPON_PLAYABLE_RANGED | WEAPON_VATS_COST_ZERO | WEAPON_SPEED_FAST;
     case 0x000FC3EC://Sonic Attack
          return WEAPON_PLAYABLE_RANGED | WEAPON_VATS_COST_ZERO | WEAPON_SPEED_FAST | WEAPON_PROJECTILES_EIGHT;
     case 0x0010D80A://Liberator Laser
          return WEAPON_VATS_COST_ZERO | WEAPON_SPEED_FAST;
     case 0x00004117://Flatwoods Monster Laser
          return WEAPON_PLAYABLE_RANGED | WEAPON_VATS_COST_ZERO | WEAPON_SPEED_FAST | WEAPON_AUTOMATIC_ENABLED | WEAPON_RECOIL_ZERO | WEAPON_SPREAD_ZERO;
     case 0x0014245D://Bomb
          return WEAPON_PLAYABLE_MELEE | WEAPON_SPEED_FAST | WEAPON_REACH_FAR | WEAPON_VATS_COST_ZERO | WEAPON_AUTOMATIC_ENABLED;
     case 0x000DF621://Fire Hydrant Bat
          return WEAPON_PLAYABLE_MELEE | WEAPON_SPEED_FAST | WEAPON_REACH_FAR | WEAPON_VATS_COST_ZERO | WEAPON_AUTOMATIC_ENABLED;
     case 0x000D1EB0://Gauss Rifle
          WEAPON_HOLD_TO_FIRE_DISABLED | WEAPON_SWAY_ZERO | WEAPON_RECOIL_ZERO | WEAPON_SPREAD_ZERO | WEAPON_RELOAD_SPEED_FAST | WEAPON_VATS_COST_ZERO | WEAPON_SPEED_FAST;
     case 0x0010FAA7://Salvaged Assaultron Head
          WEAPON_CHARGING_DISABLED | WEAPON_SWAY_ZERO | WEAPON_RECOIL_ZERO | WEAPON_SPREAD_ZERO | WEAPON_RELOAD_SPEED_FAST | WEAPON_VATS_COST_ZERO | WEAPON_SPEED_FAST;
     case 0x0012DBB3://Pump Action Shotgun
          return  WEAPON_SWAY_ZERO | WEAPON_RECOIL_ZERO | WEAPON_RELOAD_SPEED_FAST | WEAPON_VATS_COST_ZERO | WEAPON_SPEED_FAST | WEAPON_AUTOMATIC_ENABLED;
     case 0x00004822://10mm Pistol
          return  WEAPON_SWAY_ZERO | WEAPON_RECOIL_ZERO | WEAPON_SPREAD_ZERO | WEAPON_RELOAD_SPEED_FAST | WEAPON_VATS_COST_ZERO | WEAPON_SPEED_FAST | WEAPON_AUTOMATIC_ENABLED;
     case 0x00113854://Handmade Rifle
          return  WEAPON_SWAY_ZERO | WEAPON_RECOIL_ZERO | WEAPON_SPREAD_ZERO | WEAPON_RELOAD_SPEED_FAST | WEAPON_VATS_COST_ZERO | WEAPON_SPEED_FAST | WEAPON_AUTOMATIC_ENABLED;
     case 0x0046D2A1://The Fixer
          return  WEAPON_SWAY_ZERO | WEAPON_RECOIL_ZERO | WEAPON_SPREAD_ZERO | WEAPON_RELOAD_SPEED_FAST | WEAPON_VATS_COST_ZERO | WEAPON_SPEED_FAST | WEAPON_AUTOMATIC_ENABLED;
     case 0x000FE268://Railway Rifle
          return WEAPON_SWAY_ZERO | WEAPON_RECOIL_ZERO | WEAPON_SPREAD_ZERO | WEAPON_RELOAD_SPEED_FAST | WEAPON_VATS_COST_ZERO | WEAPON_SPEED_FAST | WEAPON_AUTOMATIC_ENABLED;
     case 0x0005C250://Board
          return WEAPON_SPEED_FAST | WEAPON_REACH_FAR | WEAPON_VATS_COST_ZERO | WEAPON_AUTOMATIC_ENABLED;
     default:
          return WEAPON_INVALID;
     }
}
 
class Weapon
{
public:
     char PaddingA[0x20];
     DWORD Formid;//0x20
     char PaddingB[0x74];
     DWORD64 NamePtr;//0x98
     char PaddingC[0xB0];
     DWORD64 EquipTypePtrA;//0x150
     char PaddingD[0x68];
     DWORD64 KeywordArrayPtr;//0x1C0
     DWORD KeywordArraySize;//0x1C8
     char PaddingE[0xC4];
     DWORD64 AmmoPtr;//0x290
     DWORD64 EquipTypePtrB;//0x298
     char PaddingF[0x10];
     DWORD64 AimModelPtr;//0x2B0
     char PaddingG[0x10];
     DWORD64 WeaponMiscPtr;//0x2C8
     char PaddingH[0x2C];
     float ReloadSpeed;//0x2FC
     char PaddingI[0x4];
     float Speed;//0x304
     float Reach;//0x308
     char PaddingJ[0x2C];
     float ActionPointCost;//0x338
     float FullPowerSeconds;//0x33C
     float MinPowerPerShot;//0x340
     char PaddingK[0x1C];
     BYTE FlagA;//0x360
     BYTE FlagB;//0x361
     BYTE FlagC;//0x362
     BYTE FlagD;//0x363
     char PaddingL[0x1C];
     short Capacity;//0x380
};
 
class Ammo
{
public:
     char PaddingA[0x20];
     DWORD Formid;//0x20
     char PaddingB[0x1B0];
     BYTE FlagA;//0x1D4
     BYTE FlagB;//0x1D5
     BYTE FlagC;//0x1D6
     BYTE FlagD;//0x1D7
};
 
class AimModel
{
public:
     char PaddingA[0x20];
     DWORD Formid;//0x20
     char PaddingB[0x4];
     float ConeOfFireMinAngle;//0x28
     float ConeOfFireMaxAngle;//0x2C
     float ConeOfFireIncreasePerShot;//0x30
     float ConeOfFireDecreasePerShot;//0x34
     int ConeOfFireDecreaseDelayMS;//0x38
     float ConeOfFireSneakMult;//0x3C
     float RecoilDiminishSpringForce;//0x40
     float RecoilDiminishSightsMult;//0x44
     float RecoilMaxPerShot;//0x48
     float RecoilMinPerShot;//0x4C
     float RecoilHipMult;//0x50
     int RunawayRecoilShots;//0x54
     float RecoilArc;//0x58
     float RecoilArcRotate;//0x5C
     float ConeOfFireIronSightsMult;//0x60
     float StabilityBaseStability;//0x64
};
 
class WeaponMisc
{
public:
     char PaddingA[0x34];
     BYTE ProjectileCount;
};
 
class Keyword
{
public:
     char PaddingA[0x20];
     DWORD Formid;//0x20
};
 
DWORD GetPtrAOffset = 0;
BYTE GetPtrASig[] = { 0x90, 0x89, 0x5C, 0x24, 0x40, 0x48, 0x8B, 0x05, 0x00, 0x00, 0x00, 0x00, 0x48, 0x85, 0xC0 };
const char GetPtrAMask[sizeof(GetPtrASig) + 1] = "xxxxxxxx????xxx";
 
DWORD GetPtrBOffset = 0;
BYTE GetPtrBSig[] = { 0x41, 0x8B, 0xC0, 0x4C, 0x8D, 0x1D, 0x00, 0x00, 0x00, 0x00, 0x41, 0xC1, 0xE8, 0x08 };
const char GetPtrBMask[sizeof(GetPtrBSig) + 1] = "xxxxxx????xxxx";
 
DWORD64 GetAddress(HANDLE pHandle, DWORD64 mBase, DWORD Formid)
{
     DWORD64 v1;
     if (!RPM(pHandle, mBase + GetPtrAOffset, &v1, sizeof(v1))) return 0;
     if (!Valid(v1)) return 0;
 
     DWORD v2;
     if (!RPM(pHandle, v1 + 0x8 + 0x18, &v2, sizeof(v2))) return 0;
     if (v2 == 0) return 0;
 
     DWORD v3 = 0;
 
     for (int i = 0; i < sizeof(Formid); i++)
     {
          DWORD v4 = ((v3 ^ (Formid >> (i * 0x8))) & 0xFF);
 
          DWORD v5;
          if (!RPM(pHandle, mBase + GetPtrBOffset + v4 * 0x4, &v5, sizeof(v5))) return 0;
 
          v3 = ((v3 >> 0x8) ^ v5);
     }
 
     DWORD v6 = (v3 & (v2 - 1));
 
     DWORD64 v7;
     if (!RPM(pHandle, v1 + 0x8 + 0x10, &v7, sizeof(v7))) return 0;
     if (!Valid(v7)) return 0;
 
     DWORD v8;
     if (!RPM(pHandle, v7 + (v6 + v6 * 2) * 0x8 + 0x10, &v8, sizeof(v8))) return 0;
     if (v8 == 0xFFFFFFFF) return 0;
 
     DWORD v9 = v2;
 
     for (int i = 0; i < 100; i++)
     {
          DWORD v10;
          if (!RPM(pHandle, v7 + (v6 + v6 * 2) * 0x8, &v10, sizeof(v10))) return 0;
          if (v10 == Formid)
          {
               v9 = v6;
               if (v9 != v2) break;
          }
          else
          {
               if (!RPM(pHandle, v7 + (v6 + v6 * 2) * 0x8 + 0x10, &v6, sizeof(v6))) return 0;
               if (v6 == v2) break;
          }
     }
 
     if (v9 == v2) return 0;
 
     return v7 + (v9 + v9 * 2) * 0x8 + 0x8;
}
 
DWORD64 GetPtr(HANDLE pHandle, DWORD64 mBase, DWORD Formid)
{
     DWORD64 Address = GetAddress(pHandle, mBase, Formid);
     if (Address == 0) return 0;
 
     DWORD64 Ptr;
     if (!RPM(pHandle, Address, &Ptr, sizeof(Ptr))) return 0;
 
     return Ptr;
}
 
bool EditWeapon(HANDLE pHandle, Weapon WeaponSourceData, DWORD64 WeaponPtr, DWORD WeaponFlags)
{
     Weapon WeaponData;
     if (!RPM(pHandle, WeaponPtr, &WeaponData, sizeof(WeaponData))) return false;
 
     if (WeaponFlags & WEAPON_INVALID) return false;
     if (WeaponFlags & WEAPON_SPEED_FAST) WeaponData.Speed = 100.0f;
     if (WeaponFlags & WEAPON_SPEED_NORMAL) WeaponData.Speed = 1.0f;
     if (WeaponFlags & WEAPON_RELOAD_SPEED_FAST) WeaponData.ReloadSpeed = 100.0f;
     if (WeaponFlags & WEAPON_RELOAD_SPEED_NORMAL)  WeaponData.ReloadSpeed = 1.0f;
     if (WeaponFlags & WEAPON_AUTOMATIC_ENABLED) WeaponData.FlagB |= 1 << 7;
     if (WeaponFlags & WEAPON_AUTOMATIC_DISABLED) WeaponData.FlagC &= ~(1 << 7);
     if (WeaponFlags & WEAPON_CHARGING_ENABLED) WeaponData.FlagA |= 1 << 3;
     if (WeaponFlags & WEAPON_CHARGING_DISABLED) WeaponData.FlagA &= ~(1 << 3);
     if (WeaponFlags & WEAPON_HOLD_TO_FIRE_ENABLED) WeaponData.FlagB |= 1 << 3;
     if (WeaponFlags & WEAPON_HOLD_TO_FIRE_DISABLED) WeaponData.FlagB &= ~(1 << 3);
     if (WeaponFlags & WEAPON_REACH_FAR) WeaponData.Reach = 999.0f;
     if (WeaponFlags & WEAPON_REACH_NORMAL) WeaponData.Reach = 1.0f;
     if (WeaponFlags & WEAPON_VATS_COST_ZERO) WeaponData.ActionPointCost = 0.0f;
     if (WeaponFlags & WEAPON_CAPACITY_HIGH) WeaponData.Capacity = 999;
     if (WeaponFlags & WEAPON_SWAP_AMMO) WeaponData.AmmoPtr = WeaponSourceData.AmmoPtr;
     if (WeaponFlags & WEAPON_DISABLE_AMMO) WeaponData.AmmoPtr = 0;
 
     if (WeaponFlags & WEAPON_PLAYABLE_MELEE)
     {
          WeaponData.FlagC &= ~(1 << 1);
          WeaponData.FlagC &= ~(1 << 4);
 
          if (Valid(WeaponSourceData.NamePtr) && !Valid(WeaponData.NamePtr))
          {
               WeaponData.NamePtr = WeaponSourceData.NamePtr;
          }
     }
 
     if (WeaponFlags & WEAPON_PLAYABLE_RANGED)
     {
          WeaponData.FlagC &= ~(1 << 1);
          WeaponData.FlagC &= ~(1 << 4);
 
          if (Valid(WeaponSourceData.NamePtr) && !Valid(WeaponData.NamePtr))
          {
               WeaponData.NamePtr = WeaponSourceData.NamePtr;
          }
 
          if (Valid(WeaponSourceData.EquipTypePtrA) && Valid(WeaponSourceData.EquipTypePtrB))
          {
               WeaponData.EquipTypePtrA = WeaponSourceData.EquipTypePtrA;
               WeaponData.EquipTypePtrB = WeaponSourceData.EquipTypePtrB;
          }
 
          if (Valid(WeaponSourceData.KeywordArrayPtr) && WeaponSourceData.KeywordArraySize > 0)
          {
               WeaponData.KeywordArrayPtr = WeaponSourceData.KeywordArrayPtr;
               WeaponData.KeywordArraySize = WeaponSourceData.KeywordArraySize;
          }
 
          if (Valid(WeaponData.AmmoPtr))
          {
               Ammo AmmoData;
               if (RPM(pHandle, WeaponData.AmmoPtr, &AmmoData, sizeof(AmmoData)))
               {
                    if (((AmmoData.FlagA >> 1) & 1) == 1) AmmoData.FlagA &= ~(1 << 1);
                    WPM(pHandle, WeaponData.AmmoPtr, &AmmoData, sizeof(AmmoData));
               }
          }
     }
 
     if (WeaponFlags & WEAPON_PROJECTILES_ONE)
     {
          if (Valid(WeaponData.WeaponMiscPtr))
          {
               WeaponMisc WeaponMiscData;
               if (RPM(pHandle, WeaponData.WeaponMiscPtr, &WeaponMiscData, sizeof(WeaponMiscData)))
               {
                    WeaponMiscData.ProjectileCount = 1;
                    WPM(pHandle, WeaponData.WeaponMiscPtr, &WeaponMiscData, sizeof(WeaponMiscData));
               }
          }
     }
 
     if (WeaponFlags & WEAPON_PROJECTILES_EIGHT)
     {
          if (Valid(WeaponData.WeaponMiscPtr))
          {
               WeaponMisc WeaponMiscData;
               if (RPM(pHandle, WeaponData.WeaponMiscPtr, &WeaponMiscData, sizeof(WeaponMiscData)))
               {
                    WeaponMiscData.ProjectileCount = 8;
                    WPM(pHandle, WeaponData.WeaponMiscPtr, &WeaponMiscData, sizeof(WeaponMiscData));
               }
          }
     }
 
     if (WeaponFlags & WEAPON_PROJECTILES_MAX)
     {
          if (Valid(WeaponData.WeaponMiscPtr))
          {
               WeaponMisc WeaponMiscData;
               if (RPM(pHandle, WeaponData.WeaponMiscPtr, &WeaponMiscData, sizeof(WeaponMiscData)))
               {
                    WeaponMiscData.ProjectileCount = MAXBYTE;
                    WPM(pHandle, WeaponData.WeaponMiscPtr, &WeaponMiscData, sizeof(WeaponMiscData));
               }
          }
     }
 
     if (WeaponFlags & WEAPON_RECOIL_ZERO)
     {
          if (Valid(WeaponData.AimModelPtr))
          {
               AimModel AimModelData;
               if (RPM(pHandle, WeaponData.AimModelPtr, &AimModelData, sizeof(AimModelData)))
               {
                    AimModelData.RecoilDiminishSpringForce = 0.0f;
                    AimModelData.RecoilDiminishSightsMult = 0.0f;
                    AimModelData.RecoilMaxPerShot = 0.0f;
                    AimModelData.RecoilMinPerShot = 0.0f;
                    AimModelData.RecoilHipMult = 0.0f;
                    AimModelData.RunawayRecoilShots = 0;
                    AimModelData.RecoilArc = 0.0f;
                    AimModelData.RecoilArcRotate = 0.0f;
                    WPM(pHandle, WeaponData.AimModelPtr, &AimModelData, sizeof(AimModelData));
               }
          }
     }
 
     if (WeaponFlags & WEAPON_SPREAD_ZERO)
     {
          if (Valid(WeaponData.AimModelPtr))
          {
               AimModel AimModelData;
               if (RPM(pHandle, WeaponData.AimModelPtr, &AimModelData, sizeof(AimModelData)))
               {
                    AimModelData.ConeOfFireMinAngle = 0.0f;
                    AimModelData.ConeOfFireMaxAngle = 0.0f;
                    AimModelData.ConeOfFireIncreasePerShot = 0.0f;
                    AimModelData.ConeOfFireDecreasePerShot = 0.0f;
                    AimModelData.ConeOfFireDecreaseDelayMS = 0;
                    AimModelData.ConeOfFireSneakMult = 0.0f;
                    AimModelData.ConeOfFireIronSightsMult = 0.0f;
                    WPM(pHandle, WeaponData.AimModelPtr, &AimModelData, sizeof(AimModelData));
               }
          }
     }
 
     if (WeaponFlags & WEAPON_SWAY_ZERO)
     {
          if (Valid(WeaponData.AimModelPtr))
          {
               AimModel AimModelData;
               if (RPM(pHandle, WeaponData.AimModelPtr, &AimModelData, sizeof(AimModelData)))
               {
                    AimModelData.StabilityBaseStability = 100.0f;
                    WPM(pHandle, WeaponData.AimModelPtr, &AimModelData, sizeof(AimModelData));
               }
          }
     }
 
     return WPM(pHandle, WeaponPtr, &WeaponData, sizeof(WeaponData));
}
 
bool IterateWeapons(HANDLE pHandle, DWORD64 mBase, DWORD mSize)
{
     DWORD GetPtrABuffer = GetSigOffset(pHandle, mBase, mSize, GetPtrASig, GetPtrAMask, sizeof(GetPtrASig));
     if (GetPtrABuffer == 0 || !RPM(pHandle, mBase + GetPtrABuffer + 0x8, &GetPtrAOffset, sizeof(GetPtrAOffset))) return false;
     GetPtrAOffset += GetPtrABuffer + 0xC;
 
     DWORD GetPtrBBuffer = GetSigOffset(pHandle, mBase, mSize, GetPtrBSig, GetPtrBMask, sizeof(GetPtrBSig));
     if (GetPtrBBuffer == 0 || !RPM(pHandle, mBase + GetPtrBBuffer + 0x6, &GetPtrBOffset, sizeof(GetPtrBOffset))) return false;
     GetPtrBOffset += GetPtrBBuffer + 0xA;
 
     DWORD64 WeaponSourcePtr = GetPtr(pHandle, mBase, WeaponSource);
     if (WeaponSourcePtr == 0) return false;
 
     Weapon WeaponSourceData;
     if (!RPM(pHandle, WeaponSourcePtr, &WeaponSourceData, sizeof(WeaponSourceData))) return false;
 
     for (int i = 0; i < sizeof(WeaponList) / sizeof(DWORD); i++)
     {
          DWORD WeaponFlags = GetWeaponFlags(WeaponList[i]);
          if (WeaponFlags == 0) continue;
 
          DWORD64 WeaponPtr = GetPtr(pHandle, mBase, WeaponList[i]);
          if (WeaponPtr == 0) continue;
 
          EditWeapon(pHandle, WeaponSourceData, WeaponPtr, WeaponFlags);
     }
 
     return true;
}
 
void ProcessMain(ProcessData pData)
{
     IterateWeapons(pData.pHandle, DWORD64(pData.mBase), pData.mSize);
}
 
DWORD GetSigOffset(HANDLE pHandle, DWORD64 mBase, DWORD mSize, BYTE *Sig, const char *Mask, int Len)
{
     DWORD SigOffset = 0;
     BYTE *ModuleArray = new BYTE[mSize];
 
     if (ReadProcessMemory(pHandle, (void*)(mBase), &*ModuleArray, mSize, NULL))
     {
          for (DWORD i = 0; i < mSize; i++)
          {
               if (i + Len >= mSize) break;
               for (int c = 0; c < Len; c++)
               {
                    if (ModuleArray[i + c] != Sig[c] && Mask[c] != '?') break;
                    if (c == Len - 1)
                    {
                         delete[]ModuleArray;
                         return i;
                    }
               }
          }
     }
 
     delete[]ModuleArray;
     return SigOffset;
}
 
bool RPM(HANDLE pHandle, DWORD64 src, void *dst, size_t Size)
{
     return ReadProcessMemory(pHandle, (void*)(src), dst, Size, NULL);
}
 
bool WPM(HANDLE pHandle, DWORD64 dst, void *src, size_t Size)
{
     return WriteProcessMemory(pHandle, (void*)(dst), src, Size, NULL);
}
 
DWORD64 AllocEx(HANDLE pHandle, size_t Size)
{
     return DWORD64(VirtualAllocEx(pHandle, NULL, Size, MEM_RESERVE | MEM_COMMIT, PAGE_EXECUTE_READWRITE));
}
 
bool FreeEx(HANDLE pHandle, DWORD64 src)
{
     return VirtualFreeEx(pHandle, LPVOID(src), 0, MEM_RELEASE);
}
 
bool Valid(DWORD64 ptr)
{
     if (ptr < 0x7FFF || ptr > 0x7FFFFFFFFFFF) return false;
     else return true;
}
 
bool GetModuleData(ProcessData *pData)
{
     HANDLE hSnapshot = CreateToolhelp32Snapshot(TH32CS_SNAPMODULE, pData->pPid);
     if (hSnapshot == INVALID_HANDLE_VALUE) return false;
 
     MODULEENTRY32 lpme;
     lpme.dwSize = sizeof(lpme);
 
     while (Module32Next(hSnapshot, &lpme))
     {
          if (!strcmp(lpme.szModule, pData->mName))
          {
               pData->mBase = lpme.modBaseAddr;
               pData->mSize = lpme.modBaseSize;
               CloseHandle(hSnapshot);
               return true;
          }
     }
 
     CloseHandle(hSnapshot);
     return false;
}
 
int GetProcessData(ProcessData *BaseData, ProcessData *pData = nullptr, int pCount = 0)
{
     HANDLE hSnapshot = CreateToolhelp32Snapshot(TH32CS_SNAPPROCESS, NULL);
     if (hSnapshot == INVALID_HANDLE_VALUE) return 0;
 
     PROCESSENTRY32 lppe;
     lppe.dwSize = sizeof(lppe);
 
     int ProcessCount = 0;
     while (Process32Next(hSnapshot, &lppe))
     {
          if (!strcmp(lppe.szExeFile, BaseData->pName))
          {
               if (pData != nullptr && pCount > 0 && ProcessCount < pCount)
               {
                    pData[ProcessCount].pPid = lppe.th32ProcessID;
               }
 
               ProcessCount++;
          }
     }
 
     CloseHandle(hSnapshot);
     return ProcessCount;
}
 
int main()
{
     ProcessData BaseData;
     BaseData.pName = (CHAR*)("Fallout76.exe");//Process
     BaseData.mName = (CHAR*)("Fallout76.exe");//Module
 
     int pCount = GetProcessData(&BaseData);
     if (pCount == 0) return 1;
 
     ProcessData *pData = new ProcessData[pCount];
     for (int i = 0; i < pCount; i++) memcpy(&pData[i], &BaseData, sizeof(ProcessData));
 
     if (GetProcessData(&BaseData, pData, pCount) != pCount)
     {
          delete[]pData;
          return 2;
     }
 
     int Index = 0;
     if (pCount > 1)
     {
          for (int i = 0; i < pCount; i++)
          {
               printf("%08lX - %s - Index: %d\n", pData[i].pPid, pData[i].pName, i + 1);
          }
 
          printf("Enter target process index: ");
          std::cin >> Index;
          printf("--------------------------------\n");
 
          if (Index == 0 || Index > pCount)
          {
               delete[]pData;
               return 3;
          }
          else
          {
               Index--;
          }
     }
 
     if (!GetModuleData(&pData[Index]))
     {
          delete[]pData;
          return 4;
     }
 
     pData[Index].pHandle = OpenProcess(PROCESS_ALL_ACCESS, false, pData[Index].pPid);
     if (pData[Index].pHandle == NULL)
     {
          delete[]pData;
          return 5;
     }
 
     ProcessMain(pData[Index]);
 
     CloseHandle(pData[Index].pHandle);
     delete[]pData;
     return 0;
}
Comments: