Metick / CheatEngine-DMA

Cheat Engine Plugin for DMA users
MIT License
208 stars 50 forks source link

Cant select process with Cheat Engine #17

Closed hsiegersma closed 3 months ago

hsiegersma commented 3 months ago

Whenever i try to open/attach to a process , Cheat Engine just freezes over and doesnt respond anymore. I have noticed that im getting the message VMMDLL_ConfigGet ID = 4 VERSION 0.0, should the version not be higher ? And is there any way of updating the version ?

Metick commented 3 months ago

When attaching it's usually memory reading the process. which can take some time if you're on a 35T.

If you just wait it should solve itself (:

hsiegersma commented 3 months ago

I cant even select a process, it doesnt open the process list.

hsiegersma commented 3 months ago

it also states 'Could not get PID from name'

hsiegersma commented 3 months ago

initializing initializing Initialize DMA in advance (Required for Set Thread Context) inizializing... dumping memory map to file... Dumped memory map! FPGA ID: 4 DEVICE ID: 9472 success! [+] VMMDLL_ConfigGet ID = 4 VERSION = 0.0 [!] Could not get PID from name! Hooking Open Process 0x0000000001450D20 Hooking Read 0x0000000001450CC0 Hooking Write 0x0000000001450CD0 Hooking Virtual Query 0x0000000001450E80 Hooking CreateToolhelp32Snapshot 0x0000000001450D80 Hooking Process32First 0x0000000001450D90 Hooking Process32Next 0x0000000001450DA0 Hooking Module32First 0x0000000001450DD0 Hooking Module32Next 0x0000000001450DE0 Hooking Thread32First 0x0000000001450DB0 Hooking Thread32Next 0x0000000001450DC0 Initialized Methicc's CE DMA plugin

Is there anything in here that could tell me whats wrong ?

Metick commented 3 months ago

You can ignore that first "Could not get PID from name"

Can you make a video for me where you can't select the process / doesnt open process list?

hsiegersma commented 3 months ago

yeah ofcourse, making video now :)

hsiegersma commented 3 months ago

https://github.com/Metick/CheatEngine-DMA/assets/10972617/fed6adf1-ccdb-43f7-9a51-ff893c074990

hsiegersma commented 3 months ago

Maybe found a solution , i enabled process list to be shown in main menu in settings , then a 'process' tab appears in the menu bar up top.

hsiegersma commented 3 months ago

To where is the memory map file dumped ?

Metick commented 3 months ago

Maybe found a solution , i enabled process list to be shown in main menu in settings , then a 'process' tab appears in the menu bar up top.

Did this solve your issue?

Also the MMap is dumped to %temp%/mmap.txt

hsiegersma commented 3 months ago

Maybe found a solution , i enabled process list to be shown in main menu in settings , then a 'process' tab appears in the menu bar up top.

Did this solve your issue?

Also the MMap is dumped to %temp%/mmap.txt

Unfortunately not, attaching to process still freezes everything up

Metick commented 3 months ago

can you put some debug prints here

https://github.com/Metick/CheatEngine-DMA/blob/Master/plugin/Hooks/process.cpp#L15

and in the function below it, and see what's happening for you?

hsiegersma commented 3 months ago

Here is the output with debug statements , its in the attachment initializing.txt

Metick commented 3 months ago

And it just freezes after it finished reading through all the processes right?

hsiegersma commented 3 months ago

Yes, it iterates through all processes and prints the message that you've reached the end and then cheat engine freezes without actually showing the process list.

hsiegersma commented 3 months ago

Okay i managed to fix things a little bit by not opening the process list window but using the solution i mentioned before and using a revised main.c file, code for the revised main.c file can be found below for you to inspect. So now i am able to succesfully attach to a process by using the cheat engine setting under 'General Settings -> show main menu enabled -> show process list in main menu' and then selecting the process to attach to from there.

// example-c.cpp : Defines the entry point for the DLL application.
//

//#define WIN32_LEAN_AND_MEAN       // Exclude rarely-used stuff from Windows headers
// Windows Header Files:

#include <windows.h>
#include <stdio.h>
#include "CheatEngine/cepluginsdk.h"

#include <DMALibrary/Memory/Memory.h>

#include "Hooks/hooks.h"
#include "Memory/vad.h"
#include "Memory/memmy.h"

int PointerReassignmentPluginID = -1;
int MainMenuPluginID = -1;

ExportedFunctions Exported;

void __stdcall mainmenuplugin(void)
{
    Exported.ShowMessage("Main menu plugin");
    return;
}

void __stdcall PointersReassigned(int reserved)
{
    printf("Pointers got modified");
}

BOOL APIENTRY DllMain(HANDLE hModule,
    DWORD ul_reason_for_call,
    LPVOID lpReserved
)
{
    switch (ul_reason_for_call)
    {
    case DLL_PROCESS_ATTACH:
        break;
    case DLL_THREAD_ATTACH:
    case DLL_THREAD_DETACH:
    case DLL_PROCESS_DETACH:
        break;
    }

    return TRUE;
}

BOOL __stdcall CEPlugin_GetVersion(PPluginVersion pv, int sizeofpluginversion)
{
    pv->version = CESDK_VERSION;
    pv->pluginname = "Methicc's DMA plugin";
    return TRUE;
}

BOOL __stdcall CEPlugin_InitializePlugin(PExportedFunctions ef, int pluginid)
{
    MAINMENUPLUGIN_INIT init1;
    POINTERREASSIGNMENTPLUGIN_INIT init4;

    //open console
    FILE* std_in = NULL, * std_out = NULL, * std_err = NULL;
    AllocConsole();
    freopen_s(&std_in, "conin$", "r", stdin);
    freopen_s(&std_out, "conout$", "w", stdout);
    freopen_s(&std_err, "conout$", "w", stderr);
    printf("initializing\n");

    auto open_process = ef->OpenProcess;
    auto read_process_memory = ef->ReadProcessMemory;
    auto write_process_memory = ef->WriteProcessMemory;
    auto virtual_query = ef->VirtualQueryEx;
    auto create_tool_help32 = ef->CreateToolhelp32Snapshot;
    auto process_32_first = ef->Process32First;
    auto process_32_next = ef->Process32Next;
    auto module_32_first = ef->Module32First;
    auto module_32_next = ef->Module32Next;
    auto thread_32_first = ef->Thread32First;
    auto thread_32_next = ef->Thread32Next;

    printf("Initialize DMA in advance (Required for Set Thread Context)\n");
    mem.Init("", true);

    printf("Hooking Open Process 0x%p\n", open_process);
    *(uintptr_t*)(open_process) = (uintptr_t)&Hooks::hk_open_process;

    printf("Hooking Read 0x%p\n", read_process_memory);
    *(uintptr_t*)(read_process_memory) = (uintptr_t)&Hooks::hk_read;

    printf("Hooking Write 0x%p\n", write_process_memory);
    *(uintptr_t*)(write_process_memory) = (uintptr_t)&Hooks::hk_write;

    printf("Hooking Virtual Query 0x%p\n", virtual_query);
    *(uintptr_t*)(virtual_query) = (uintptr_t)&Hooks::hk_virtual_query;

    printf("Hooking CreateToolhelp32Snapshot 0x%p\n", create_tool_help32);
    *(uintptr_t*)(create_tool_help32) = (uintptr_t)&Hooks::hk_create_tool_help_32_snapshot;

    printf("Hooking Process32First 0x%p\n", process_32_first);
    *(uintptr_t*)(process_32_first) = (uintptr_t)&Hooks::hk_process_32_first;

    printf("Hooking Process32Next 0x%p\n", process_32_next);
    *(uintptr_t*)(process_32_next) = (uintptr_t)&Hooks::hk_process_32_next;

    printf("Hooking Module32First 0x%p\n", module_32_first);
    *(uintptr_t*)(module_32_first) = (uintptr_t)&Hooks::hk_module_32_first;

    printf("Hooking Module32Next 0x%p\n", module_32_next);
    *(uintptr_t*)(module_32_next) = (uintptr_t)&Hooks::hk_module_32_next;

    printf("Hooking Thread32First 0x%p\n", thread_32_first);
    *(uintptr_t*)(thread_32_first) = (uintptr_t)&Hooks::hk_thread_32_first;

    printf("Hooking Thread32Next 0x%p\n", thread_32_next);
    *(uintptr_t*)(thread_32_next) = (uintptr_t)&Hooks::hk_thread_32_next;

    //Check comment in Hooks.h for why this is commented out.
    /*
     printf("Hooking OpenThread 0x%p\n", open_thread);
    *(uintptr_t*)(open_thread) = (uintptr_t)&Hooks::hk_open_thread;

     printf("Hooking GetThreadContext 0x%p\n", get_thread_context);
    *(uintptr_t*)(get_thread_context) = (uintptr_t)&Hooks::hk_get_thread_context;

    printf("Hooking SetThreadContext 0x%p\n", set_thread_context);
    *(uintptr_t*)(set_thread_context) = (uintptr_t)&Hooks::hk_set_thread_context;

    printf("Hooking SuspendThread 0x%p\n", suspend_thread);
    *(uintptr_t*)(suspend_thread) = (uintptr_t)&Hooks::hk_suspend_thread;

    printf("Hooking ResumeThread 0x%p\n", resume_thread);
    *(uintptr_t*)(resume_thread) = (uintptr_t)&Hooks::hk_resume_thread;*/

    init4.callbackroutine = PointersReassigned;
    PointerReassignmentPluginID = Exported.RegisterFunction(pluginid, ptFunctionPointerchange, &init4); //adds a plugin menu item to the memory view
    if (PointerReassignmentPluginID == -1)
    {
        Exported.ShowMessage("Failure to register the pointer reassignment plugin");
        return FALSE;
    }

    init1.name = "DMA Methicc CE Plugin";
    init1.callbackroutine = mainmenuplugin;
    ef->RegisterFunction(pluginid, ptMainMenu, &init1);
    printf("Initialized Methicc's CE DMA plugin\n");
    Exported = *ef;
    return TRUE;
}

BOOL __stdcall CEPlugin_DisablePlugin(void)
{
    exit(0);
    return TRUE;
}
hsiegersma commented 3 months ago

managed to complete resolve the issue by disabling icons for the process list window in general settings of cheat engine, closing this issue.