1. Do not share user accounts! Any account that is shared by another person will be blocked and closed. This means: we will close not only the account that is shared, but also the main account of the user who uses another person's account. We have the ability to detect account sharing, so please do not try to cheat the system. This action will take place on 04/18/2023. Read all forum rules.
    Dismiss Notice
  2. For downloading SimTools plugins you need a Download Package. Get it with virtual coins that you receive for forum activity or Buy Download Package - We have a zero Spam tolerance so read our forum rules first.

    Buy Now a Download Plan!
  3. Do not try to cheat our system and do not post an unnecessary amount of useless posts only to earn credits here. We have a zero spam tolerance policy and this will cause a ban of your user account. Otherwise we wish you a pleasant stay here! Read the forum rules
  4. We have a few rules which you need to read and accept before posting anything here! Following these rules will keep the forum clean and your stay pleasant. Do not follow these rules can lead to permanent exclusion from this website: Read the forum rules.
    Are you a company? Read our company rules

Trying to learn how to get a data stream into flypt mover (Custom HOOK)

Discussion in 'DIY Motion Simulator Building Q&A / FAQ' started by cfischer, Oct 1, 2023.

  1. cfischer

    cfischer Active Member Gold Contributor

    Joined:
    Sep 7, 2015
    Messages:
    372
    Location:
    Colorado
    Balance:
    2,688Coins
    Ratings:
    +259 / 1 / -0
    Hello everyone,

    I have spent quite a number of hours trying to understand how to get a custom hook to work and I feel like I've exhausted the clues before me.
    I am writing my own c++ program that will interface with a 14 bit encoder. As a stepping stone I am just trying to get the memory hook setup.
    From my research it seems all I need to do is come up with the offset for my variable from the base memory address of my program.

    After lots of trial and error I am left with a program that chatGPT helped me create with some addresses that dont line up with anything I can see in mover or cheat engine.
    On top of that I cant use cheat engine to find any variables Ive created in my code (I use the cheat engine tutorials to increment or decrement my variable(i tried float, double, int). This leaves me to think I am fundamentally doing this wrong.

    The code I will show below even gets the base address to be the same in mover for all digits except the last two(5 units difference). Super confusing.

    Can anybody point me in the right direction to learn how this works? An example or some keyword to research and read up on? Any help would be much apprecieated.


    Code:
    #include <iostream>
    
    // Declare and initialize global variables
    int localVar = 42;
    float findMe = 0;
    
    int main() {
        // Calculate the memory address (base address) of the code
        uintptr_t codeBaseAddress = reinterpret_cast<uintptr_t>(&main);
    
        // Obtain pointers to the variables
        int* localVarPtr = &localVar;
        float* findMePtr = &findMe;
    
        // Calculate the offsets
        uintptr_t localVarOffset = reinterpret_cast<uintptr_t>(localVarPtr) - codeBaseAddress;
        uintptr_t findMeOffset = reinterpret_cast<uintptr_t>(findMePtr) - codeBaseAddress;
    
        std::cout << "Memory Address (Base Address of Code): 0x" << std::hex << codeBaseAddress << std::endl;
        std::cout << "Offset for localVar: 0x" << localVarOffset << std::endl;
        std::cout << "Offset for findMe: 0x" << findMeOffset << std::endl;
    
        std::cout << "localVar Value: " << localVar << std::endl;
        std::cout << "findMe Value: " << findMe << std::endl;
    
        // Read and display memory address of findMe while it's greater than or equal to zero
        while (findMe >= 0) {
            // Display the memory address of findMe
            std::cout << "Memory Address of findMe: 0x" << std::hex << reinterpret_cast<uintptr_t>(findMePtr) << std::endl;
            std::cout << "findMe is still greater than 0. Enter a new value: ";
            std::cin >> findMe;
        }
    
        return 0;
    }


    upload_2023-9-30_21-59-14.png
    • Like Like x 1