DWORD MyAlloc(wFlags, wSize, wElem) | |||||
WORD wFlags; | /* segment flags, */ | ||||
WORD wSize; | /* size of element, */ | ||||
WORD wElem; | /* number of elements in segment | */ |
The MyAlloc function allocates memory for a segment in a self-loading appli-cation.
wFlags
Specifies the segment flags.
wSize
Specifies the element size, in bytes.
wElem
Specifies the number of elements in the segment.
The low-order word of the return value contains a segment handle if the function is successful; the high-order word contains a selector if the function is successful. (However, if the function allocates only a handle for the segment, the low-order word contains zero and the high-order word contains the handle.) Otherwise, the return value is zero for both high-order and low-order words.
The flags specified by the wFlags parameter are the values that precede the segment table appearing immediately after the information block in the Windows (new-style) header. The kernel translates wFlags into the proper values before calling the GlobalAlloc function.
The segment size, in bytes, is obtained by shifting the value specified in the wSize parameter left by the number of bits specified by the wElem parameter.
The MyAlloc function is one of three functions supplied by the Windows kernel. The kernel loads a pointer to this function at offset 0x0014 in the loader's code and data table. The kernel loads the pointer before calling the private startup procedure (the BootApp function).