Retro video games delivered to your door every month!
Click above to get retro games delivered to your door ever month!
X-Hacker.org- LanMan Library Reference Guide - <b>ll_mem2str()</b> http://www.X-Hacker.org [<<Previous Entry] [^^Up^^] [Next Entry>>] [Menu] [About The Guide]
 LL_MEM2STR()
 Copy a string from memory to a char variable
------------------------------------------------------------------------------

 Syntax

      LL_Mem2Str( <nSegment>, <nOffset>, <nLength> ) -> cString

 Arguments

     <nSegment> is the segment of the desired memory address

     <nOffset> is the offset of the desired memory address

     <nLength> is the number of bytes to copy

 Returns

     <cString>, which is a copy of the data that was stored at the
     specified memory location. If the function fails, an empty string
     is returned.

 Description

     LL_Mem2Str() can be used to copy a binary string from a specified
     memory location to a character variable. It is included in the LFN
     Library primarily because the SFN versions of the file find functions
     in the library use it to copy the DTA for retrieving file data.

     LL_Mem2Str() was designed for grabbing a few hundred bytes from the
     DTA or the PSP and for similar purposes. Although in principle any
     data can be copied from memory using LL_Mem2Str(), there are a few
     rules that must be taken into account:

     First of all, we are still in the 16-bit world, so only 64 KB chunks of
     memory can be allocated. In reality the maximum size is even smaller
     than that. If you try to allocate memory with more than 64504 bytes in
     the <nLength> argument, an unrecoverable error 5304 (conventional
     memory exhausted) will occur (the same goes for -1031 bytes up to -1
     because that is really the same thing).

     Don't allocate a memory buffer with a negative segment, offset or
     length since that would be pretty silly anyway :-) (but it might happen
     if they are carelessly calculated on the fly).

     Offset plus length must not exceed 64 KB (or even come too close to it
     - see above) or you will end up somewhere in memory where you had not
     intended to go. And then the result will be undefined.

     If you break any of these rules you will get what you deserve :-)

     LL_Mem2Str() requires the CPMI library.

 Examples

     local nSegment := 61440     // F000h
     local nOffset := 65525      // FFF5h
     local nLength := 8
     local cBiosDate
     cBiosDate := LL_Mem2Str(nSegment,nOffset,nLength)
     if !empty(cBiosDate)
        ? 'The BIOS date stamp is ' + cBiosDate
     else
        ? 'Could not retrieve the BIOS date stamp'
     endif

 Source: MEM2STR.ASM

 Author: Klas Engwall <klas.engwall@engwall.com>

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