Untitled

mail@pastecode.io avatar
unknown
c_cpp
a year ago
1.9 kB
21
Indexable
Never
//Works, Direct reads:
    struct ScatterTemps {
        __m128 temp_2;
        __m128i temp_0;
        __m128 temp_1;
    };

    std::map<uint32_t, std::unique_ptr<ScatterTemps>> mp;

    for (auto chainVal : indexChain) {
        std::unique_ptr<ScatterTemps> stPtr(new ScatterTemps());
        DWORD_PTR offset = (6 * chainVal) * 8;
        printf("relation_index (6 * chainVal): %d\n", 6 * chainVal);
        DMA::MemRead(relation_array + offset, stPtr.get(), 48);
        mp[chainVal] = std::move(stPtr);
    }

    auto getScatterTemps = [&](int ind) -> ScatterTemps* {
        if (mp.find(ind) != mp.end()) {
            return mp[ind].get();
        }
        return nullptr;
    };

//Doesn't work, Scatter reads:
    struct ScatterTemps { // Unchanged
        __m128 temp_2;
        __m128i temp_0;
        __m128 temp_1;
    };

    std::map<uint32_t, std::unique_ptr<ScatterTemps>> mp; // Unchanged

    VMMDLL_Scatter_Clear(sharedData.hS, DMA::dwAttachedProcessId, VMMDLL_FLAG_NOCACHE | VMMDLL_FLAG_NOPAGING_IO);

    for (auto chainVal : indexChain) { // Unchanged
        std::unique_ptr<ScatterTemps> stPtr(new ScatterTemps()); // Unchanged
        DWORD cbRead;
        DWORD_PTR offset = (6 * chainVal) * 8; // Unchanged

        if (!VMMDLL_Scatter_PrepareEx(sharedData.hS, relation_array + offset, 48, reinterpret_cast<BYTE*>(stPtr.get()), &cbRead)) {
            printf("Failed to prepare scatter read for relation_index (6 * chainVal): %d\n", 6 * chainVal);
            return Vector3();
        }

        mp[chainVal] = std::move(stPtr); // Unchanged
    }

    if (!VMMDLL_Scatter_Execute(sharedData.hS)) {
        printf("Failed to execute scatter read for ScatterTemps\n");
        return Vector3();
    }

    auto getScatterTemps = [&](int ind) -> ScatterTemps* { // Unchanged
        if (mp.find(ind) != mp.end()) {
            return mp[ind].get();
        }
        return nullptr;
    };