Bonjour,

je cherche à récupérer les valeurs des variables utilisées par un autre processus (processus appelé ici "FT").

Voici le code :
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
int main()
{
    // Variables
    STARTUPINFO startupInfo; // Information about the FT startup
    PROCESS_INFORMATION processInformation; // Information about the FT process
    MEMORY_BASIC_INFORMATION memoryBasicInformation; // Basic information about the memory of the FT process

    // Initialize the STARTUPINFO structure for the FT process
    memset(&startupInfo, 0, sizeof(startupInfo));
    startupInfo.cb = sizeof(startupInfo);

    // Create the FT process
    if(
        CreateProcess(NULL,
            "FT_Client.exe 0",
            NULL,
            NULL,
            TRUE,
            CREATE_BREAKAWAY_FROM_JOB,
            NULL,
            NULL,
            &startupInfo,
            &processInformation
        )
    ==0){
        cout << "Unable to create the FT process : " << GetLastError() << endl;
        return(-1);
    }

    // Display the FT process Id
    cout << "FT process Id : " << processInformation.dwProcessId << endl;

    // Get basic information about the memory of the FT process
    if(
        VirtualQueryEx(processInformation.hProcess,
            NULL,
            &memoryBasicInformation,
            sizeof(memoryBasicInformation)
        )
    == 0){
        cout << "Unable to get basic information about the memory of the FT process :" << GetLastError();
        return(-1);
    }

    // Read the FT process memory
    if(
        ReadProcessMemory(processInformation.hProcess,
            &memoryBasicInformation.BaseAddress,
            &memoryBasicInformation,
            sizeof(memoryBasicInformation),
            NULL
        )
    ==0){
        cout << "Unable to read the FT process memory : " << GetLastError() << endl;
        return(-1);
    }

    // Close the FT process handle
    if(CloseHandle(processInformation.hProcess)==0){
        cout << "Unable to close the FT process handle : " << GetLastError() << endl;
        return(-1);
    }

    return 0;
}
Le résultat sur le flux de sortie standard est le suivant :
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
FT process Id : 2008
Unable to read the FT process memory : 299
L'erreur 299 signifie :
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
ERROR_PARTIAL_COPY 
299 (0x12B) Only part of a ReadProcessMemory or WriteProcessMemory request was completed.
Donc il semble y avoir un problème au moment de la lecture de la mémoire utilisée par le processus FT.

Voyez-vous une (ou plusieurs) erreur dans mon code?

Merci bien.