SHMAT
Attach the shared memory segment identified by ecx to the address space of the calling process. The sys_brk value of the calling process is not altered by the attach. The segment will automatically be detached at process exit. The same segment may be attached as a read and as a read-write one, and more than once, in the process's address space. A successful SHMAT call updates the members of the shmid_ds structure (see SHMCTL) associated with the shared memory segment as follows: shm_atime is set to the current time. shm_lpid is set to the process-ID of the calling process. shm_nattch is incremented by one Arguments
ecx | Shared memory segment ID.
edx | Mode flags:
`SHM_RDONLY` | `If this flag is specified, then the segment is attached for reading and the process must have read permission for the segment. Otherwise the segment is attached for read and write and the process must have read and write permission for the segment. There is no notion of a write-only shared memory segment.`
`SHM_RND` | `See above.`
`SHM_REMAP` | `If this flag is specified, then the mapping of the segment will replace any existing mapping in the range starting at the address pointed by esi and continuing for the size of the segment. (Normally an -EINVAL error would result if a mapping already exists in this address range.) In this case, address pointed by esi must not be NULL.`
`SHM_EXEC` | `If this flag is specified, then the segment is attached with execution access (PROT_EXEC).`
esi | Pointer to a 4 byte long value specifying the attaching address. If the pointed by value is NULL, the system chooses a suitable (unused) address at which to attach the segment. On return it will be overwritten by the attaching address. If it isn't NULL and SHM_RND is specified in edx, the attach occurs at the address rounded down to the nearest multiple of SHMLBA. Otherwise the specified address must be a page-aligned address at which the attach occurs.
Return values If the function succeeds the return value 0. If the function fails the return value is one of the following errno values:
`-EACCES` | `The calling process does not have the required permissions for the requested attach type, and does not have the CAP_IPC_OWNER capability.`
`-EINVAL` | `Invalid ecx value, unaligned (i.e., not page-aligned and SHM_RND was not specified) or invalid esi value, or failing attach at sys_brk, or SHM_REMAP was specified and value pointed by esi was NULL.`
`-EFAULT` | ``
`-ENOMEM` | `Could not allocate memory for the descriptor or for the page tables.`
Remarks Using SHMAT with specified address equal to NULL is the preferred, portable way of attaching a shared memory segment. Be aware that the shared memory segment attached in this way may be attached at different addresses in different processes. Therefore, any pointers maintained within the shared memory must be made relative (typically to the starting address of the segment), rather than absolute. It is possible to attach a shared memory segment even if it is already marked to be deleted. The following system parameter affects SHMAT: SHMLBA - Segment low boundary address multiple. Must be page aligned. For the current implementation the SHMLBA value is PAGE_SIZE. The implementation places no intrinsic limit on the per-process maximum number of shared memory segments (SHMSEG). See samples/ipc/shmem.asm for an example.