1 | /* $Id: OS2KPTDA.c,v 1.5 2001-07-08 03:09:51 bird Exp $
|
---|
2 | *
|
---|
3 | * PTDA access functions.
|
---|
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 | * Defined Constants And Macros *
|
---|
13 | *******************************************************************************/
|
---|
14 | #define INCL_OS2KRNL_SEM
|
---|
15 | #define INCL_OS2KRNL_PTDA
|
---|
16 |
|
---|
17 | /*******************************************************************************
|
---|
18 | * Header Files *
|
---|
19 | *******************************************************************************/
|
---|
20 | #include <os2.h>
|
---|
21 | #include <OS2Krnl.h>
|
---|
22 |
|
---|
23 |
|
---|
24 | /*******************************************************************************
|
---|
25 | * External Data *
|
---|
26 | *******************************************************************************/
|
---|
27 | /*
|
---|
28 | * Requires the following imports:
|
---|
29 | * pPTDACur
|
---|
30 | * ptda_start
|
---|
31 | * ptda_environ
|
---|
32 | */
|
---|
33 | extern ULONG pptda_start;
|
---|
34 | extern ULONG pptda_environ;
|
---|
35 | extern ULONG pptda_ptdasem;
|
---|
36 | extern ULONG pptda_handle;
|
---|
37 | extern ULONG pptda_module;
|
---|
38 | extern ULONG pptda_pBeginLIBPATH;
|
---|
39 |
|
---|
40 |
|
---|
41 | /**
|
---|
42 | * Gets the ptda_environ PTDA member. This member holds the memory object handle
|
---|
43 | * for the environment block of the processes.
|
---|
44 | * @returns Content of the pPTDA->ptda_environ member.
|
---|
45 | * @param pPTDA PTDA Pointer. (NULL is not allowed!)
|
---|
46 | */
|
---|
47 | USHORT ptdaGet_ptda_environ(PPTDA pPTDA)
|
---|
48 | {
|
---|
49 | return *(PUSHORT)(void*)(((char*)(void*)pPTDA) + (pptda_environ - pptda_start));
|
---|
50 | }
|
---|
51 |
|
---|
52 |
|
---|
53 | /**
|
---|
54 | * Gets the ptda_handle PTDA member. This member holds the PTDA handle for the
|
---|
55 | * given PTDA.
|
---|
56 | * @returns Content of the pPTDA->ptda_handle member.
|
---|
57 | * @param pPTDA PTDA Pointer. (NULL is not allowed!)
|
---|
58 | */
|
---|
59 | HPTDA ptdaGet_ptda_handle(PPTDA pPTDA)
|
---|
60 | {
|
---|
61 | return *(PHPTDA)(void*)(((char*)(void*)pPTDA) + (pptda_handle - pptda_start));
|
---|
62 | }
|
---|
63 |
|
---|
64 |
|
---|
65 | /**
|
---|
66 | * Gets the ptda_module PTDA member. This member holds the MTE handle of the process's
|
---|
67 | * executable image.
|
---|
68 | * @returns Content of the pPTDA->ptda_module member.
|
---|
69 | * @param pPTDA PTDA Pointer. (NULL is not allowed!)
|
---|
70 | */
|
---|
71 | USHORT ptdaGet_ptda_module(PPTDA pPTDA)
|
---|
72 | {
|
---|
73 | return *(PUSHORT)(void*)(((char*)(void*)pPTDA) + (pptda_module - pptda_start));
|
---|
74 | }
|
---|
75 |
|
---|
76 |
|
---|
77 | /**
|
---|
78 | * Gets the ptda_ptdasem PTDA member. This member holds the intra-process semaphore which
|
---|
79 | * for example is used to serialize _LDRQAppType.
|
---|
80 | * @returns Content of the pPTDA->ptda_ptdasem member.
|
---|
81 | * @param pPTDA PTDA Pointer. (NULL is not allowed!)
|
---|
82 | */
|
---|
83 | HKSEMMTX ptda_ptda_ptdasem(PPTDA pPTDA)
|
---|
84 | {
|
---|
85 | return (HKSEMMTX)(void*)(((char*)(void*)pPTDA) + (pptda_ptdasem - pptda_start));
|
---|
86 | }
|
---|
87 |
|
---|
88 |
|
---|
89 | /**
|
---|
90 | * Gets the ptda_pBeginLIBPATH PTDA member. This member may hold the begin libpath
|
---|
91 | * extention for this process.
|
---|
92 | * @returns beginlibpath string pointer.
|
---|
93 | * NULL if member is NULL or not supported by kernel.
|
---|
94 | * @param pPTDA PTDA Pointer. (NULL is not allowed!)
|
---|
95 | */
|
---|
96 | PSZ ptdaGet_ptda_pBeginLIBPATH(PPTDA pPTDA)
|
---|
97 | {
|
---|
98 | if (!pptda_pBeginLIBPATH)
|
---|
99 | return NULL;
|
---|
100 | return *(PSZ*)(void*)(((char*)(void*)pPTDA) + (pptda_pBeginLIBPATH - pptda_start));
|
---|
101 | }
|
---|
102 |
|
---|
103 |
|
---|
104 | /**
|
---|
105 | * Gets the ptda_pEndLIBPATH PTDA member. This member might hold the end libpath
|
---|
106 | * extention for this process.
|
---|
107 | * @returns endlibpath string pointer.
|
---|
108 | * NULL if member is NULL or not supported by kernel.
|
---|
109 | * @param pPTDA PTDA Pointer. (NULL is not allowed!)
|
---|
110 | */
|
---|
111 | PSZ ptdaGet_ptda_pEndLIBPATH(PPTDA pPTDA)
|
---|
112 | {
|
---|
113 | if (!pptda_pBeginLIBPATH)
|
---|
114 | return NULL;
|
---|
115 | return *(PSZ*)(void*)(((char*)(void*)pPTDA) + (pptda_pBeginLIBPATH + 4 - pptda_start));
|
---|
116 | }
|
---|
117 |
|
---|
118 |
|
---|
119 |
|
---|
120 |
|
---|