source: trunk/src/win32k/k32/k32AllocMemEx.cpp@ 4787

Last change on this file since 4787 was 4787, checked in by bird, 25 years ago

Changed email address... (may some dll fixes changes too.)

File size: 4.1 KB
Line 
1/* $Id: k32AllocMemEx.cpp,v 1.4 2000-12-11 06:53:52 bird Exp $
2 *
3 * k32AllocMemEx - Equivalent to DosAllocMem, but this one
4 * uses the address in ppv.
5 *
6 * Copyright (c) 2000 knut st. osmundsen (knut.stange.osmundsen@mynd.no)
7 *
8 * Project Odin Software License can be found in LICENSE.TXT
9 *
10 */
11
12
13/*******************************************************************************
14* Defined Constants And Macros *
15*******************************************************************************/
16#define INCL_DOSMEMMGR
17#define INCL_DOSERRORS
18#define INCL_OS2KRNL_VM
19
20#define NO_WIN32K_LIB_FUNCTIONS
21
22#ifndef OBJ_SELMAPALL
23#define OBJ_SELMAPALL 0x00000800UL
24#endif
25
26
27/*******************************************************************************
28* Header Files *
29*******************************************************************************/
30#include <os2.h>
31#include "devSegDf.h" /* Win32k segment definitions. */
32#include "OS2Krnl.h"
33#include "win32k.h"
34#include "k32.h"
35#include "options.h"
36#include "dev32.h"
37#include "log.h"
38#include "macros.h"
39
40
41/* nasty! These should be imported from the kernel later! */
42
43ULONG vmApiF0[] =
44{
45 0,
46 VMA_READ,
47 VMA_WRITE | VMA_READ,
48 VMA_WRITE | VMA_READ,
49 VMA_EXECUTE,
50 VMA_EXECUTE | VMA_READ,
51 VMA_WRITE | VMA_EXECUTE | VMA_READ,
52 VMA_WRITE | VMA_EXECUTE | VMA_READ,
53 VMA_GUARD,
54 VMA_READ | VMA_GUARD,
55 VMA_WRITE | VMA_READ | VMA_GUARD,
56 VMA_WRITE | VMA_READ | VMA_GUARD,
57 VMA_EXECUTE | VMA_GUARD,
58 VMA_EXECUTE | VMA_READ | VMA_GUARD,
59 VMA_WRITE | VMA_EXECUTE | VMA_READ | VMA_GUARD,
60 VMA_WRITE | VMA_EXECUTE | VMA_READ | VMA_GUARD
61};
62
63
64ULONG vmApiF1[] =
65{
66 0,
67 0,
68 VMA_DECOMMIT,
69 VMA_DECOMMIT,
70 VMA_TILE,
71 VMA_TILE,
72 VMA_DECOMMIT | VMA_TILE,
73 VMA_DECOMMIT | VMA_TILE,
74 VMA_PROTECTED,
75 VMA_PROTECTED,
76 VMA_PROTECTED | VMA_DECOMMIT,
77 VMA_PROTECTED | VMA_DECOMMIT,
78 VMA_PROTECTED | VMA_TILE,
79 VMA_PROTECTED | VMA_TILE,
80 VMA_PROTECTED | VMA_DECOMMIT | VMA_TILE,
81 VMA_PROTECTED | VMA_DECOMMIT | VMA_TILE
82};
83
84
85/**
86 * Extended edition of DosAllocMem. Allows you to suggest an address where you
87 * want the memory allocated.
88 * @returns OS2 returncode.
89 * @param ppv Pointer to a pointer. This points to a pointer which points to the
90 * suggested address of the memory block.
91 * @param cb Size of the memory block.
92 * @param flag Flags just as for DosAllocMem.
93 * @param ulCS CS where the memoryobject were requested.
94 * @param ulEIP EIP where the memoryobject were requested.
95 * @sketch
96 * @status stub
97 * @author knut st. osmundsen (knut.stange.osmundsen@mynd.no)
98 * @remark
99 */
100APIRET k32AllocMemEx(PPVOID ppv, ULONG cb, ULONG flag, ULONG ulCS, ULONG ulEIP)
101{
102 #if 0
103 APIRET rc;
104 ULONG flFlags2;
105 VMAC vmac = {0};
106 ULONG cbCommit;
107 HMTE hMTE;
108
109 if ((flag & ~(PAG_READ | PAG_WRITE | PAG_EXECUTE | PAG_GUARD | PAG_COMMIT
110 | OBJ_TILE | OBJ_SELMAPALL))
111 || (flag & (PAG_READ | PAG_WRITE | PAG_EXECUTE)) == 0UL
112 || cb == 0
113 || ulCS == 0
114 || ulEIP == 0
115 )
116 return ERROR_INVALID_PARAMETER;
117 if (cb > 0xC0000000UL)
118 return ERROR_NOT_ENOUGH_MEMORY;
119
120 vmac.ac_va = (ULONG)*ppv;
121 cb = (cb + 0xFFFUL) & ~0xFFFUL;
122 if (flag & PAG_COMMIT)
123 cbCommit = cb;
124 flag = vmApiF0[flag & (PAG_READ | PAG_WRITE | PAG_EXECUTE | PAG_GUARD)]
125 | vmApiF1[(flag & (PAG_COMMIT | PAG_DECOMMIT | OBJ_TILE | OBJ_PROTECTED)) >> 2]
126 | VMA_USER | VMA_RESIDENT | VMA_LOWMEM2 | VMA_TILE | 0x12000000;
127 flFlags2 = (flag & VMA_WRITE ? VMAF2_WRITE : 0) | 0x460;
128
129 hMTE = VMGetOwner(ulCS, ulEIP);
130 rc = VMAllocMem(cb,
131 cbCommit,
132 flag,
133 0,
134 0,
135 hMTE,
136 flFlags2,
137 0,
138 (PVMAC)SSToDS(&vmac));
139
140 return rc;
141 #else
142 NOREF(ppv);
143 NOREF(cb);
144 NOREF(flag);
145 NOREF(ulCS);
146 NOREF(ulEIP);
147 return ERROR_NOT_SUPPORTED;
148 #endif
149}
150
Note: See TracBrowser for help on using the repository browser.