Welcome!

By registering with us, you'll be able to discuss, share and private message with other members of our community.

SignUp Now!

How to? Accessing alias shared memory

Dec
32
0
Don't laugh, but I still use 4NT (v5.00, Build 128, Unicode) under Windows 10. It still work fine for my needs.
I'd like to access the alias-list that 4NT keeps in a shared-memory region. From ProcessExplorer, I see sections like:
\Sessions\1\BaseNamedObjects\Sharemem4NTUAliasGisle

How can I access such section from another instance of 4NT (or cmd, or whatever)?
And what is the format these, pure text?
 
Don't laugh, but I still use 4NT (v5.00, Build 128, Unicode) under Windows 10. It still work fine for my needs.
I'd like to access the alias-list that 4NT keeps in a shared-memory region. From ProcessExplorer, I see sections like:
\Sessions\1\BaseNamedObjects\Sharemem4NTUAliasGisle

How can I access such section from another instance of 4NT (or cmd, or whatever)?
And what is the format these, pure text?
To elaborate on what Joe said ...
Two 4NTs running simultaneously shouls both be able to access them as long as the "Global" options are set in both instances. The purpose of SHRALIAS is to keep the memory-mapped files open even when no 4NTs are running; so any 4NT will use the lists that were previously in use. Any other access is something you'll have to program yourself (more on that below).
In recent versions of the product (now called TCC) the memory-mapped files are Unicode. That's OK with 4NTv8 which is as far back as I can go. Since your files have "U" in their names, I suppose yours are Unicode. Accessing the lists programmatically involves the following
Code:
(1) MapFileHandle = OpenFileMapping (with names like the one you mentioned, Sharemem4NTUAlias<username>).  In newer versions that's just SharememUAlias<user_name>.
(2) MapFilePointer = (WCHAR*) MapViewOfFile(MapFileHandle, ...
At this point, MapFilePointer points to the first character if the memory-mapped file.
When you're done,
Code:
UnmapViewOfFile(MapFilePointer)
CloseHandle(MapFileHandle)
 
Here's code that will display the first 1000 bytes of your Alias MMF;
Code:
#COMPILE EXE
#DIM ALL
#INCLUDE "win32api.inc"

FUNCTION PBMAIN () AS LONG
  LOCAL hMap AS LONG, MapName AS ASCIIZ * 64, lRet AS LONG, lString AS STRING
 
  MapName = "SharememUAliasjlc" '<-- Change this to your MapName
 
  lRet = OpenFileMapping _
         (%FILE_MAP_ALL_ACCESS,_ ' access mode
         BYVAL %NULL, _ ' inherit flag
         MapName) ' pointer to name of file-mapping object

  IF lRet THEN
    hMap = MapViewOfFile _
           (lRet,_ ' file-mapping object to map into address space
           %FILE_MAP_ALL_ACCESS,_ ' access mode
           0,_ ' high-order 32 bits of file offset
           0,_ ' low-order 32 bits of file offset
           0) ' number of bytes to map

    PRINT ACODE$(PEEK$(hMap,1000))
  ELSE
    STDOUT "Cannot open file mapping" + CHR$(13) + "Filemap must exist!"
  END IF
  UnmapViewOfFile BYVAL lRet
  CloseHandle hMap
END FUNCTION

Joe
 
Back
Top