Retro video games delivered to your door every month!
Click above to get retro games delivered to your door ever month!
X-Hacker.org- Force 4.0 Reference - addr() return the address of an object http://www.X-Hacker.org [<<Previous Entry] [^^Up^^] [Next Entry>>] [Menu] [About The Guide]
 addr()              Return the address of an object
------------------------------------------------------------------------------
 Declaration
   memory.hdr

 Syntax
   func _POINTER addr extern
   param untyped xObject

 Arguments
   xObject is a memory object.

 Return
   The memory address of the passed object.

 Description
   This function returns the address of an item in memory. Items may be
   functions, procedures, or variables. The return value of this function
   is a value of 32 bits which can be interpreted as a pointer to the
   specified item. The address of a memory object can also be produced using
   the & operator.

 Example
   #define EXAMPLE_MEMORY
   #include example.hdr

   vardef public
      uint nData
   enddef
   
   vardef sfar
      uint nFar
   enddef
   
   dbfdef sTest static
   enddef
   
   proc Dummy
   endproc
   
   func logical DSVar
   param value _POINTER pObject
   // Determine if an object is in the data segment
   vardef
      uint nSeg, nOff
   enddef
   splitptr( nSeg, nOff, pObject )
   getregs()
   return( nSeg == __regs.ds )
   endfunc
   
   proc Test_addr
   vardef
      char cString
   enddef
   ? DSVar( addr( nData ) )   // public variable, prints .t.
   ? DSVar( &nData )          // the & operator can be used instead of addr()
   ? DSVar( addr( nFar ) )    // static far variable, prints .f.
   ? DSVar( addr( sTest ) )   // static alias structure, prints .t.
   ? DSVar( addr( cString ) ) // local variable, prints .f.
   ? DSVar( addr( Dummy ) )   // function, prints .f.
   endproc

   proc main
   Test_addr()
   endproc

See Also: & indcall() offsetvalue() ptr() segmentvalue()

Online resources provided by: http://www.X-Hacker.org --- NG 2 HTML conversion by Dave Pearson