Module globmem.pkg
1// ************************************************************************ //
2// ** ** //
3// ** File : GLOBMEM.PKG ** //
4// ** ** //
5// ** Author : Ulbe Stellema ** //
6// ** : Data Access Nederland ** //
7// ** : 26 march 1997 ** //
8// ** ** //
9// ** Purpose : This package contains the functions for creating and ** //
10// ** : maintaining global memory objects. ** //
11// ** ** //
12// ************************************************************************ //
13
14// GlobalAlloc Flags constants:
15#REPLACE GMEM_FIXED |CI$0000
16#REPLACE GMEM_MOVEABLE |CI$0002
17#REPLACE GMEM_NOCOMPACT |CI$0010
18#REPLACE GMEM_NODISCARD |CI$0020
19#REPLACE GMEM_ZEROINIT |CI$0040
20#REPLACE GMEM_MODIFY |CI$0080
21#REPLACE GMEM_DISCARDABLE |CI$0100
22#REPLACE GMEM_NOT_BANKED |CI$1000
23#REPLACE GMEM_SHARE |CI$2000
24#REPLACE GMEM_DDESHARE |CI$2000
25#REPLACE GMEM_NOTIFY |CI$4000
26#REPLACE GMEM_LOWER GMEM_NOT_BANKED
27
28// The GlobalAlloc function allocates the specified number of bytes from the
29// heap. The 'Flags' parameter specifies how to allocate memory. If zero is
30// specified, the default is GMEM_FIXED. Except for the incompatible
31// combinations that are specifically noted, any combination of the following
32// flags can be used. To indicate whether the function allocates fixed or
33// movable memory, specify one of the first four flags.
34External_Function32 GlobalAlloc "GlobalAlloc" KERNEL32.DLL ;
35 Integer Flags dWord Bytes Returns Handle
36
37// The GlobalDiscard function discards the specified global memory block. The
38// lock count of the memory object must be zero.
39External_Function32 GlobalDiscard "GlobalDiscard" KERNEL32.DLL ;
40 Handle MemObject Returns Handle
41
42// The GlobalFlags function returns information about the specified global
43// memory object.
44External_Function32 GlobalFlags "GlobalFlags" KERNEL32.DLL ;
45 Handle MemObject Returns Integer
46
47// The GlobalFree function frees the specified global memory object and
48// invalidates its handle.
49External_Function32 GlobalFree "GlobalFree" KERNEL32.DLL ;
50 Handle MemObject Returns Handle
51
52// The GlobalHandle function retrieves the handle associated with the
53// specified pointer to a global memory block.
54External_Function32 GlobalHandle "GlobalHandle" KERNEL32.DLL ;
55 Pointer MemObject Returns Handle
56
57// The GlobalLock function locks a global memory object and returns a pointer
58// to the first byte of the object's memory block. The memory block associated
59// with a locked memory object cannot be moved or discarded. For memory
60// objects allocated with the GMEM_MOVEABLE flag, the function increments the
61// lock count associated with the memory object.
62External_Function32 GlobalLock "GlobalLock" KERNEL32.DLL ;
63 Handle MemObject Returns Pointer
64
65// The GlobalReAlloc function changes the size or attributes of a specified
66// global memory object. The size can increase or decrease.
67External_Function32 GlobalReAlloc "GlobalReAlloc" KERNEL32.DLL ;
68 Handle MemObject dWord Bytes Integer Flags Returns Handle
69
70// The GlobalSize function retrieves the current size, in bytes, of the
71// specified global memory object.
72External_Function32 GlobalSize "GlobalSize" KERNEL32.DLL ;
73 Handle MemObject Returns dWord
74
75// The GlobalUnlock function decrements the lock count associated with a
76// memory object that was allocated with the GMEM_MOVEABLE flag. This function
77// has no effect on memory objects allocated with the GMEM_FIXED flag.
78External_Function32 GlobalUnlock "GlobalUnlock" KERNEL32.DLL ;
79 Handle MemObject Returns Integer
80
81// The WOWGetVDMPointer function converts a 16:16 address to the equivalent
82// linear address.
83External_Function32 WOWGetVDMPointer "WOWGetVDMPointer" WOW32.DLL ;
84 dWord vp dWord dwBytes Integer fProtectedMode Returns Integer
85
86// The WOWGetVDMPointerFix function converts a 16:16 address to the equivalent
87// linear address.
88// Windows 95: This function calls the GlobalFix function before returning the
89// linear address so that the 16-bit memory block will not be moved around in
90// the 16-bit global heap.
91// Windows NT: This function behaves like the WOWGetVDMPointer function. The
92// memory is not fixed.
93External_Function32 WOWGetVDMPointerFix "WOWGetVDMPointerFix" WOW32.DLL ;
94 dWord vp dWord d2wBytes Integer fProtectedMode Returns Integer
95
96// Windows 95: The WOWGetVDMPointerUnfix function uses the GlobalUnfix
97// function to unfix a pointer retrieved by the WOWGetVDMPointerFix function.
98// Windows NT: This function has no effect
99External_Function32 WOWGetVDMPointerUnfix "WOWGetVDMPointerUnfix" WOW32.DLL ;
100 Pointer vp Returns Integer
101
102// The WOWGlobalAlloc16 function allocates the specified number of bytes from
103// the 16-bit global heap.
104External_Function32 WOWGlobalAlloc16 "WOWGlobalAlloc16" WOW32.DLL ;
105 Integer wFlags dWord cb Returns Integer
106
107// The WOWGlobalAllocLock16 function combines the functionality of the
108// WOWGlobalAlloc16 and WOWGlobalLock16 functions.
109External_Function32 WOWGlobalAllocLock16 "WOWGlobalAllocLock16" WOW32.DLL ;
110 Integer wFlags dWord cb Integer phMem Returns dWord
111
112// The WOWGlobalFree16 function frees the specified global memory object.
113External_Function32 WOWGlobalFree16 "WOWGlobalFree16" WOW32.DLL ;
114 Integer hMem Returns Integer
115
116// The WOWGlobalLock16 function locks a global memory object and returns a
117// pointer to the first byte of the object's memory block.
118External_Function32 WOWGlobalLock16 "WOWGlobalLock16" WOW32.DLL ;
119 Integer hMem Returns dWord
120
121// The WOWGlobalLockSize16 function combines the functionality of the
122// WOWGlobalLock16 and 16-bit GlobalSize functions.
123External_Function32 WOWGlobalLockSize16 "WOWGlobalLockSize16" WOW32.DLL ;
124 Integer hMem dWord pcb Returns dWord
125
126// The WOWGlobalUnlock16 function unlocks a global memory object.
127External_Function32 WOWGlobalUnlock16 "WOWGlobalUnlock16" WOW32.DLL ;
128 Integer hMem Returns Integer
129
130// The WOWGlobalUnlockFree16 function combines the functionality of the
131// WOWGlobalUnlock16 and WOWGlobalFree16 functions.
132External_Function WOWGlobalUnlockFree16 "WOWGlobalUnlockFree16" WOW32.DLL ;
133 dWord vpMem Returns Integer
134
135// The WOWHandle16 function is used to map a 32-bit handle to a 16-bit handle.
136// Because the relationship between a Win16 handle and a Win32 handle may
137// change in the future, use this function to convert handles instead of any
138// knowledge of the relationship between them.
139External_Function32 WOWHandle16 "WOWHandle16" WOW32.DLL ;
140 Handle hHandle Integer iType Returns Integer
141
142// The WOWHandle32 function is used to map a 16-bit handle to a 32-bit handle.
143// Because the relationship between a Win16 handle and a Win32 handle may
144// change in the future, use this function to convert handles instead of any
145// knowledge of the relationship between them.
146External_Function32 WOWHandle32 "WOWHandle32" WOW32.DLL ;
147 Integer hHandle Integer iType Returns Handle
148