Results 1 to 3 of 3
  1. #1
    fluffybananas22's Avatar
    Join Date
    Oct 2015
    Gender
    male
    Posts
    44
    Reputation
    10
    Thanks
    485
    My Mood
    Buzzed

    Need Help with FindWindow

    So Here is some code i found online and i was wanting to use it for call of duty but for some reason it always says that the game cannot be found for some reason and i dont know why. Can anyone help me with this??


    #include <iostream>
    #include <Windows.h>
    #include <string>
    #include <ctime>

    std::string GameStatus;
    bool IsGameAvailable;
    bool UpdateOnNextRun;

    //////////////////////////////
    // Params //
    //////////////////////////////

    // Game window title
    LPCSTR LGameWindow = "BlackOps3";

    // Feature 1
    std::string sFeature1Status = "OFF";
    bool Feature1Status;
    int iFeature1Key = VK_F1;
    std::string sFeature1Key = "F1";
    std::string sFeature1Desc = "GOD MODE"; /
    BYTE Feature1Value[] = { 0x1, 0x8, 0x6, 0xA, 0x0 };
    DWORD Feature1BaseAddress = { 0x147621428 };
    int iFeature1Levels = 0;
    DWORD Feature1Offsets[] = { 0x0, 0x0 };

    // Feature 2
    std::string sFeature2Status = "OFF";
    bool Feature2Status;
    int iFeature2Key = VK_F2;
    std::string sFeature2Key = "F2";
    std::string sFeature2Desc = "UNLIMITED AMMO";
    BYTE Feature2Value[] = { 0x0, 0x0, 0x3, 0x2 };
    DWORD Feature2BaseAddress = { 0x147B7FB98 };
    int iFeature2Levels = 2;
    DWORD Feature2Offsets[] = { 0x0, 0x0 };

    // Feature 3
    std::string sFeature3Status = "OFF";
    bool Feature3Status;
    int iFeature3Key = VK_F3;
    std::string sFeature3Key = "F3";
    std::string sFeature3Desc = "Feature 3";
    BYTE Feature3Value[] = { 0xF, 0xF, 0x0, 0x0 };
    DWORD Feature3BaseAddress = { 0x00000000 };
    int iFeature3Levels = 2;
    DWORD Feature3Offsets[] = { 0x0, 0x0 };

    DWORD findDmaAddress(HANDLE hProcHandle, int levelNumber, DWORD Offsets[], DWORD BaseAddress)
    {
    DWORD pointer = BaseAddress;
    DWORD pTemp;
    DWORD pointerAddress;

    for (int i = 0; i<levelNumber; i++)
    {
    if (i == 0)
    {
    ReadProcessMemory(hProcHandle, (LPCVOID)pointer, &pTemp, sizeof(pTemp), NULL);
    }

    pointerAddress = pTemp + Offsets[i];
    ReadProcessMemory(hProcHandle, (LPCVOID)pointerAddress, &pTemp, sizeof(pTemp), NULL);
    }

    return pointerAddress;
    }

    int main()
    {
    HWND hGameWindow = NULL;
    int iTimeSinceLastUpdate = clock();
    int iGameAvailableTMR = clock();
    int iOnePressTMR = clock();
    DWORD dwProcID = NULL;
    HANDLE hProcHandle = NULL;
    UpdateOnNextRun = true;

    while (!GetAsyncKeyState(VK_INSERT))
    {
    if (clock() - iGameAvailableTMR > 100)
    {
    iGameAvailableTMR = clock();
    IsGameAvailable = false;
    hGameWindow = FindWindow("Call of Duty®: BlackOps3", NULL);
    if (hGameWindow)
    {
    GetWindowThreadProcessId(hGameWindow, &dwProcID);
    if (dwProcID != 0)
    {
    hProcHandle = OpenProcess(PROCESS_ALL_ACCESS, FALSE, dwProcID);
    if (hProcHandle == INVALID_HANDLE_VALUE || hProcHandle == NULL)
    {
    GameStatus = "[ERROR] Failed to open process for valid handle";
    }
    else
    {
    GameStatus = "[SUCCESS] Game is ready to hack";
    IsGameAvailable = true;
    }
    }
    else
    {
    GameStatus = "[ERROR] Failed to get process ID";
    }
    }
    else
    {
    GameStatus = "[ERROR] Game cannot be found";
    }
    }

    if (UpdateOnNextRun || clock() - iTimeSinceLastUpdate > 5000)
    {
    system("cls");
    system("color a");
    std::cout << "--------------------------------------------" << std::endl;
    std::cout << " Black Ops 3 Trainer" << std::endl;
    std::cout << "--------------------------------------------" << std::endl << std::endl;
    std::cout << "Status: " << GameStatus << std::endl << std::endl;
    std::cout << "[" << sFeature1Key << "] " << sFeature1Desc << " ->" << sFeature1Status << "<-" << std::endl;
    std::cout << "[" << sFeature2Key << "] " << sFeature2Desc << " ->" << sFeature2Status << "<-" << std::endl;
    std::cout << "[" << sFeature3Key << "] " << sFeature3Desc << " ->" << sFeature3Status << "<-" << std::endl;
    std::cout << std::endl << "[INSERT] Exit" << std::endl;

    UpdateOnNextRun = false;
    iTimeSinceLastUpdate = clock();
    }

    if (IsGameAvailable)
    {
    DWORD AddressToWrite;

    // Memory hacking
    if (Feature1Status)
    {
    AddressToWrite = findDmaAddress(hProcHandle, iFeature1Levels, Feature1Offsets, Feature1BaseAddress);
    WriteProcessMemory(hProcHandle, (BYTE*)AddressToWrite, &Feature1Value, sizeof(Feature1Value), NULL);
    }
    else if (Feature2Status)
    {
    AddressToWrite = findDmaAddress(hProcHandle, iFeature2Levels, Feature2Offsets, Feature2BaseAddress);
    WriteProcessMemory(hProcHandle, (BYTE*)AddressToWrite, &Feature2Value, sizeof(Feature2Value), NULL);
    }
    else if (Feature3Status)
    {
    AddressToWrite = findDmaAddress(hProcHandle, iFeature3Levels, Feature3Offsets, Feature3BaseAddress);
    WriteProcessMemory(hProcHandle, (BYTE*)AddressToWrite, &Feature3Value, sizeof(Feature3Value), NULL);
    }
    }

    if (IsGameAvailable && clock() - iOnePressTMR > 400)
    {
    // Key pressed
    if (GetAsyncKeyState(iFeature1Key))
    {
    iOnePressTMR = clock();
    Feature1Status = !Feature1Status;
    UpdateOnNextRun = true;
    sFeature1Status = Feature1Status ? "ON" : "OFF";
    }
    else if (GetAsyncKeyState(iFeature2Key))
    {
    iOnePressTMR = clock();
    Feature2Status = !Feature2Status;
    UpdateOnNextRun = true;
    sFeature2Status = Feature2Status ? "ON" : "OFF";
    }
    else if (GetAsyncKeyState(iFeature3Key))
    {
    iOnePressTMR = clock();
    Feature3Status = !Feature3Status;
    UpdateOnNextRun = true;
    sFeature3Status = Feature3Status ? "ON" : "OFF";
    }
    }
    }

    CloseHandle(hProcHandle);
    CloseHandle(hGameWindow);

    return ERROR_SUCCESS;
    }

  2. #2
    KingX735's Avatar
    Join Date
    Nov 2012
    Gender
    male
    Location
    New Point(22, 4)
    Posts
    589
    Reputation
    36
    Thanks
    4,318
    My Mood
    Cheerful
    The window name of Black Ops III is set as follow:

    Code:
    Call of Duty® - ship - + Username
    Since there is a registered mark, you'll need to use FindWindowW in order to get it work.

    Code:
    Code:
    wstring Username;
    wcin >> Username;
    
    Username = L"Call of Duty®  - ship - " + Username;
    
    HWND Handle = FindWindowW(NULL, Username.c_str());
    Last edited by KingX735; 05-22-2016 at 05:22 AM.

  3. The Following User Says Thank You to KingX735 For This Useful Post:

    iL33T (08-27-2016)

  4. #3
    fluffybananas22's Avatar
    Join Date
    Oct 2015
    Gender
    male
    Posts
    44
    Reputation
    10
    Thanks
    485
    My Mood
    Buzzed
    it says that wstring and wcin are undefined

Similar Threads

  1. [Solved] Need Help with FindWindow() function
    By fluffybananas22 in forum Call of Duty: Black Ops 3 Help
    Replies: 1
    Last Post: 05-29-2016, 03:14 AM
  2. [Help] Need Help With FindWindow()
    By fluffybananas22 in forum C++/C Programming
    Replies: 1
    Last Post: 05-26-2016, 12:11 PM
  3. [Help Request] Need help with numpad while recording macro !
    By JonathanTBM in forum Vindictus Help
    Replies: 2
    Last Post: 05-10-2011, 08:37 PM
  4. [Help Request] need help with mod
    By .:MUS1CFR34K:. in forum Call of Duty Modern Warfare 2 GSC Modding Help/Discussion
    Replies: 4
    Last Post: 05-01-2011, 01:40 PM
  5. [Help Request] need help with modding
    By BayBee Alyn in forum Combat Arms Help
    Replies: 0
    Last Post: 04-27-2011, 10:06 PM