how to access oracle sga directly with c code

Zamong is free  oracle monitoring software with DMA method.

dma_picture

What is Direct oracle sga Memory Access ?

This example is from an AIX environment.
On linux, address value is differ from aix.

SQL>  select * from x$ksmmem  where rownum < 10 ;

ADDR                   INDX    INST_ID KSMMMVAL
---------------- ---------- ---------- ----------------
0700000000000000          0          1 00
0700000000000008          1          1 0700000514334020
0700000000000010          2          1 00
0700000000000018          3          1 00
0700000000000020          4          1 00
0700000000000028          5          1 00
0700000000000030          6          1 00
0700000000000038          7          1 00
0700000000000040          8          1 00

9 rows selected.

“0700000000000000” address is sga start address.

oracle@PaCG:/oracle> ipcs -mba
IPC status from /dev/mem as of Thu 
T        ID     KEY        MODE       OWNER    GROUP  CREATOR   CGROUP NATTCH     SEGSZ  CPID  LPID   ATIME    DTIME    CTIME 
Shared Memory:
m   1048576   00000000 --rw-r-----     grid      dba     grid      dba     32 318767104 4456886 58524018 21:41:51 21:41:51  5:38:14
m   5242882   00000000 --rw-r-----     grid      dba     grid      dba     32   3678208 4456886 58524018 21:41:51 21:41:51  5:38:14
m         3 0x8895c820 --rw-r-----     grid      dba     grid      dba     32      8192 4456886 58524018 21:41:51 21:41:51  5:38:14
m   1048581 0x3bea2a94 --rw-r-----   oracle      dba   oracle      dba   2404     16384 9371670 23593476 21:55:27 21:55:27  6:00:24
m   1048582   00000000 --rw-r-----   oracle      dba   oracle      dba   2404 21340618752 9371670 23593476 21:55:27 21:55:27  6:00:24
m   3145735   00000000 --rw-r-----   oracle      dba   oracle      dba   2404 134217728 9371670 23593476 21:55:27 21:55:27  6:00:24

shared memory id : 3145735

This is simple example of attaching oracle shared memory.