The following is NOT a complete C program. It is intended to provide an idea of how to use DosDebug to control another process.

This example illustrates how to modify a word in the process being controlled. It assumes that all the steps have been taken so that the caller controls the other process. It also assumes that the TargetPID, TargetAddr, and NewValue fields have been set appropriately for the operation. */

 #define INCL_DOSPROCESS   /* Process and thread values */
 #define INCL_DOSERRORS    /* Error values */
 #include <os2.h>
 #include <stdio.h>

 uDB_t   DebugBuf   = {0};        /* Debug buffer */
 ULONG   TargetPID  = 0;          /* Process ID of controlled process */
 ULONG   TargetAddr = 0;          /* Address within the controlled process */
 LONG    NewValue   = 0;          /* Value to be substituted */
 APIRET  rc         =  NO_ERROR;  /* Return code */

    DebugBuf.Cmd = DBG_C_WriteMem;  /* Perform WRITE WORD command */

    DebugBuf.Pid = TargetPID;       /* Target process to control */

    DebugBuf.Addr = TargetAddr;     /* Target address for command */

    DebugBuf.Value = NewValue;      /* Value to change in other process */

    rc = DosDebug ( &DebugBuf );
    if (rc != NO_ERROR) {
        printf("DosDebug error: return code = %u\n", rc);
        return 1;
    }


[Back] [Next]