1 | /* $Id: libW32kProcessReadWrite.c,v 1.1 2000-10-01 02:58:20 bird Exp $
|
---|
2 | *
|
---|
3 | * libW32kProcessReadWrite - Read or write to another process.
|
---|
4 | *
|
---|
5 | * Copyright (c) 2000 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 |
|
---|
26 |
|
---|
27 | /*******************************************************************************
|
---|
28 | * Global Variables *
|
---|
29 | *******************************************************************************/
|
---|
30 | extern BOOL fInited;
|
---|
31 | extern HFILE hWin32k;
|
---|
32 |
|
---|
33 |
|
---|
34 |
|
---|
35 | /**
|
---|
36 | * Reads or write memory in another process.
|
---|
37 | * @returns OS2 returncode.
|
---|
38 | * @param pid Process ID which is to be written to.
|
---|
39 | * @param cb Number of bytes to write.
|
---|
40 | * @param pvSource Pointer to data to read.
|
---|
41 | * @param pvTarget Pointer to where to write.
|
---|
42 | * @param fRead TRUE: pvSource is within pid while pvTarget is ours.
|
---|
43 | * FALSE: pvTarget is within pid while pvSource is ours.
|
---|
44 | * @status completely implelemented.
|
---|
45 | * @author knut st. osmundsen (knut.stange.osmundsen@mynd.no)
|
---|
46 | */
|
---|
47 | APIRET APIENTRY W32kProcessReadWrite(PID pid, ULONG cb, PVOID pvSource, PVOID pvTarget, BOOL fRead)
|
---|
48 | {
|
---|
49 | APIRET rc;
|
---|
50 |
|
---|
51 | if (fInited)
|
---|
52 | {
|
---|
53 | K32PROCESSREADWRITE Param;
|
---|
54 | ULONG cbParam = sizeof(Param);
|
---|
55 | ULONG cbData = 0UL;
|
---|
56 |
|
---|
57 | Param.pid = pid;
|
---|
58 | Param.cb = cb;
|
---|
59 | Param.pvSource = pvSource;
|
---|
60 | Param.pvTarget = pvTarget;
|
---|
61 | Param.fRead = fRead;
|
---|
62 | Param.rc = ERROR_INVALID_PARAMETER;
|
---|
63 |
|
---|
64 | rc = DosDevIOCtl(hWin32k,
|
---|
65 | IOCTL_W32K_K32,
|
---|
66 | K32_PROCESSREADWRITE,
|
---|
67 | &Param, sizeof(Param), &cbParam,
|
---|
68 | "", 1, &cbData);
|
---|
69 |
|
---|
70 | if (rc == NO_ERROR)
|
---|
71 | rc = Param.rc;
|
---|
72 | }
|
---|
73 | else
|
---|
74 | rc = ERROR_INIT_ROUTINE_FAILED;
|
---|
75 |
|
---|
76 | return rc;
|
---|
77 | }
|
---|
78 |
|
---|