| 1 | /* $Id: libW32kProcessReadWrite.c,v 1.2 2001-02-21 07:47:58 bird Exp $
|
|---|
| 2 | *
|
|---|
| 3 | * libW32kProcessReadWrite - Read or write to another process.
|
|---|
| 4 | *
|
|---|
| 5 | * Copyright (c) 2000-2001 knut st. osmundsen (knut.stange.osmundsen@mynd.no)
|
|---|
| 6 | *
|
|---|
| 7 | * Project Odin Software License can be found in LICENSE.TXT
|
|---|
| 8 | *
|
|---|
| 9 | */
|
|---|
| 10 |
|
|---|
| 11 |
|
|---|
| 12 | /*******************************************************************************
|
|---|
| 13 | * Header Files *
|
|---|
| 14 | *******************************************************************************/
|
|---|
| 15 | #define INCL_DOSERRORS
|
|---|
| 16 | #define INCL_DOSFILEMGR
|
|---|
| 17 | #define INCL_DOSDEVICES
|
|---|
| 18 |
|
|---|
| 19 |
|
|---|
| 20 | /*******************************************************************************
|
|---|
| 21 | * Internal Functions *
|
|---|
| 22 | *******************************************************************************/
|
|---|
| 23 | #include <os2.h>
|
|---|
| 24 | #include "win32k.h"
|
|---|
| 25 | #include "libPrivate.h"
|
|---|
| 26 |
|
|---|
| 27 |
|
|---|
| 28 | /**
|
|---|
| 29 | * Reads or write memory in another process.
|
|---|
| 30 | * @returns OS2 returncode.
|
|---|
| 31 | * @param pid Process ID which is to be written to.
|
|---|
| 32 | * @param cb Number of bytes to write.
|
|---|
| 33 | * @param pvSource Pointer to data to read.
|
|---|
| 34 | * @param pvTarget Pointer to where to write.
|
|---|
| 35 | * @param fRead TRUE: pvSource is within pid while pvTarget is ours.
|
|---|
| 36 | * FALSE: pvTarget is within pid while pvSource is ours.
|
|---|
| 37 | * @status completely implelemented.
|
|---|
| 38 | * @author knut st. osmundsen (knut.stange.osmundsen@mynd.no)
|
|---|
| 39 | */
|
|---|
| 40 | APIRET APIENTRY W32kProcessReadWrite(PID pid, ULONG cb, PVOID pvSource, PVOID pvTarget, BOOL fRead)
|
|---|
| 41 | {
|
|---|
| 42 | APIRET rc;
|
|---|
| 43 |
|
|---|
| 44 | if (fInited)
|
|---|
| 45 | {
|
|---|
| 46 | K32PROCESSREADWRITE Param;
|
|---|
| 47 | ULONG cbParam = sizeof(Param);
|
|---|
| 48 | ULONG cbData = 0UL;
|
|---|
| 49 |
|
|---|
| 50 | Param.hdr.cb = sizeof(Param);
|
|---|
| 51 | Param.hdr.rc = ERROR_NOT_SUPPORTED;
|
|---|
| 52 | Param.pid = pid;
|
|---|
| 53 | Param.cb = cb;
|
|---|
| 54 | Param.pvSource = pvSource;
|
|---|
| 55 | Param.pvTarget = pvTarget;
|
|---|
| 56 | Param.fRead = fRead;
|
|---|
| 57 |
|
|---|
| 58 | if (usCGSelector)
|
|---|
| 59 | return libCallThruCallGate(K32_PROCESSREADWRITE, &Param);
|
|---|
| 60 | rc = DosDevIOCtl(hWin32k,
|
|---|
| 61 | IOCTL_W32K_K32,
|
|---|
| 62 | K32_PROCESSREADWRITE,
|
|---|
| 63 | &Param, sizeof(Param), &cbParam,
|
|---|
| 64 | "", 1, &cbData);
|
|---|
| 65 |
|
|---|
| 66 | if (rc == NO_ERROR)
|
|---|
| 67 | rc = Param.hdr.rc;
|
|---|
| 68 | }
|
|---|
| 69 | else
|
|---|
| 70 | rc = ERROR_INIT_ROUTINE_FAILED;
|
|---|
| 71 |
|
|---|
| 72 | return rc;
|
|---|
| 73 | }
|
|---|
| 74 |
|
|---|