Jump to content

Atom Table Functions (Local + Global Atoms)


Ascend4nt
 Share

Recommended Posts

Atom Table UDF

Local and Global Atom Table


Since I've had this collecting dust on my computer, I figured I'd release it to see if anyone can find some use for it.

About Atom Tables - MSDN

2ytr75y.jpg

Example Global Atom Table Listing

 

Basically, a bunch of strings can be stored locally (at program level) or globally (at O/S level) with unique numerical identifiers. This UDF lets you add, find, delete, and query these atoms.

 

Description from the top of the AtomFunctions UDF:

----------------------------------------------------------------

Functions for accesing Local and Global Atom Tables, which contain strings up to 255 characters long

The Atom tables are used for multiple types of Windows data including Window Classes (RegisterClass/Ex), Clipboard formats (RegisterClipboardFormat), Hotkeys (RegisterHotKey), and Dynamic Data Exchange (DDE) which is a form of interprocess communication. (Some of the above may use a Local rather than the Global Atom table)

Other uses can include storing program strings to lookup by a 16-bit value and interprocess communication

 "RegisterHotKey function" @ MSDN states this:

 "An application must specify an id value in the range 0x0000 through 0xBFFF.

  A shared DLL must specify a value in the range 0xC000 through 0xFFFF

  (the range returned by the GlobalAddAtom function).

  To avoid conflicts with hot-key identifiers defined by other shared DLLs,

  a DLL should use the GlobalAddAtom function to obtain the hot-key identifier."

 Kernel Note: The Atom Table is a separate entity from Kernel Objects like Events, Mutexes, Files, etc.  However, the Atom Table is (separately) accessible from within the Kernel, so its like a Kernish object?

Notes on Atom Tables:

  • Stringlimit is 255 characters NOT including a null-terminator. This is unfortunately not   enough for a MAX_PATH string, which is 259+null-term. However, stripping off root-drive prefix get you within 1 character of the length (259 - 3 ["C:"] = 256] which may be enough - but using IPC, one can store 4 - 6 (8-12 in x64) extra chars in wParam/lParam..   See <AtomExample_IPC.au3> for an implementation of this

     

  • There is both a Local and Global Atom Table. The Local one is local to this Process,   and the Global one is available/accessible to/from all Processes.

     

  • Atoms numbered 0 - 49151 (0xBFFF) are not actually part of the Atom Table.   Querying these values will return a string representation of the number as an unsigned integer

       Example: 1234 is translated to "#1234"

     

  • Adding atom strings that start with a "#" will return an unsigned integer if the numbers   following "#" are an integer less than 49152 (1 - 49151 [0xBFFF]).

        Examples: "#1" => 1, "#49151" => 49151

     

  • Atoms numbered from 49152 - 65535 (from 0xC000 - 0xFFFF) DO reference the Atom Table strings

     

  • Maximum Atom string length is 255 characters (not including a null-terminator)

 

Functions:

;  Local:
;    _AtomTableInit()        ; Initializes Local Atom Table. Optional [37 hash buckets allocated by default]
;    _AtomAddLocal()            ; Adds a string to the Local Atom table, returns # identifier [increments reference if already exists]
;    _AtomGetNameLocal()        ; Gets the Local Atom string associated with a numerical identifier
;    _AtomDeleteLocal()        ; Decrements the reference count of Local Atom, deletes when reaches 0
;    _AtomFindLocal()        ; Finds # identifier for a string in the Local Atom table
;    _AtomGetAllLocal()        ; Returns all found Local atoms in an array
; Global:
;    _AtomAddGlobal()        ; Adds a string to the Global Atom table, returns # identifier [increments reference if already exists]
;    _AtomGetNameGlobal()    ; Gets the Global Atom string associated with a numerical identifier
;    _AtomDeleteGlobal()        ; Decrements the reference count of Global Atom, deletes when reaches 0
;    _AtomFindGlobal()        ; Finds # identifier for a string in the Global Atom table
;    _AtomGetAllGlobal()        ; Returns all found Global atoms in an array
; 'Undocumented':
;    _AtomGetGlobalTableUD() ; Using 'undocumented' function calls, gets info on all Global Atoms
;    _AtomGetInfoUD()        ; Returns reference count, pinned status, as well as Atom Name

----------------------------------------------------------------

There are a few 'undocumented' functions used for getting information on the Atom Table included (I can't help myself).

In addition to the core UDF, there's 2 example files:

  • AtomTableExample.au3 - This demonstrates various use - adding, deleting, and querying information in the Local and Global atom tables. (Extended info comes from 'undocumented' functions)

     

  • AtomExample_IPC.au3 - This demonstrates how the Atom Table could be used in InterProcess Communication. A rather rough sketch, but shows how you could squeeze MAX_PATH pathnames into IPC messages combined with Atom tables.

It's all a bit light on the documentation, but I just wanted to prevent this thing from collecting more dust ;)  Might prove useful to someone!

History::

Update 2014-08-17:

- Added some documentation to all functions

- made the ugly 'AtomTableExample' script into something half-decent.

- IPC script modified to change how messages are reported

- Added array-length return in @extended in 'GetAll' functions

AtomTablesUDF.zip ~prev Downloads: 29

 

Edited by Ascend4nt
Link to comment
Share on other sites

Something new everyday! Thanks for sharing.

This wonderful site allows debugging and testing regular expressions (many flavors available). An absolute must have in your bookmarks.
Another excellent RegExp tutorial. Don't forget downloading your copy of up-to-date pcretest.exe and pcregrep.exe here
RegExp tutorial: enough to get started
PCRE v8.33 regexp documentation latest available release and currently implemented in AutoIt beta.

SQLitespeed is another feature-rich premier SQLite manager (includes import/export). Well worth a try.
SQLite Expert (freeware Personal Edition or payware Pro version) is a very useful SQLite database manager.
An excellent eBook covering almost every aspect of SQLite3: a must-read for anyone doing serious work.
SQL tutorial (covers "generic" SQL, but most of it applies to SQLite as well)
A work-in-progress SQLite3 tutorial. Don't miss other LxyzTHW pages!
SQLite official website with full documentation (may be newer than the SQLite library that comes standard with AutoIt)

Link to comment
Share on other sites

So I just looked at the script today and thought it was too much of a mess.  I cleaned it up a little so now the examples make a little more sense :)  See 1st post for updated version

Update 2014-08-17:

- Added some documentation to all functions

- made the ugly 'AtomTableExample' script into something half-decent.

- IPC script modified to change how messages are reported

- Added array-length return in @extended in 'GetAll' functions

Link to comment
Share on other sites

  • 1 month later...

Very cool

UDF List:

 
_AdapterConnections()_AlwaysRun()_AppMon()_AppMonEx()_ArrayFilter/_ArrayReduce_BinaryBin()_CheckMsgBox()_CmdLineRaw()_ContextMenu()_ConvertLHWebColor()/_ConvertSHWebColor()_DesktopDimensions()_DisplayPassword()_DotNet_Load()/_DotNet_Unload()_Fibonacci()_FileCompare()_FileCompareContents()_FileNameByHandle()_FilePrefix/SRE()_FindInFile()_GetBackgroundColor()/_SetBackgroundColor()_GetConrolID()_GetCtrlClass()_GetDirectoryFormat()_GetDriveMediaType()_GetFilename()/_GetFilenameExt()_GetHardwareID()_GetIP()_GetIP_Country()_GetOSLanguage()_GetSavedSource()_GetStringSize()_GetSystemPaths()_GetURLImage()_GIFImage()_GoogleWeather()_GUICtrlCreateGroup()_GUICtrlListBox_CreateArray()_GUICtrlListView_CreateArray()_GUICtrlListView_SaveCSV()_GUICtrlListView_SaveHTML()_GUICtrlListView_SaveTxt()_GUICtrlListView_SaveXML()_GUICtrlMenu_Recent()_GUICtrlMenu_SetItemImage()_GUICtrlTreeView_CreateArray()_GUIDisable()_GUIImageList_SetIconFromHandle()_GUIRegisterMsg()_GUISetIcon()_Icon_Clear()/_Icon_Set()_IdleTime()_InetGet()_InetGetGUI()_InetGetProgress()_IPDetails()_IsFileOlder()_IsGUID()_IsHex()_IsPalindrome()_IsRegKey()_IsStringRegExp()_IsSystemDrive()_IsUPX()_IsValidType()_IsWebColor()_Language()_Log()_MicrosoftInternetConnectivity()_MSDNDataType()_PathFull/GetRelative/Split()_PathSplitEx()_PrintFromArray()_ProgressSetMarquee()_ReDim()_RockPaperScissors()/_RockPaperScissorsLizardSpock()_ScrollingCredits_SelfDelete()_SelfRename()_SelfUpdate()_SendTo()_ShellAll()_ShellFile()_ShellFolder()_SingletonHWID()_SingletonPID()_Startup()_StringCompact()_StringIsValid()_StringRegExpMetaCharacters()_StringReplaceWholeWord()_StringStripChars()_Temperature()_TrialPeriod()_UKToUSDate()/_USToUKDate()_WinAPI_Create_CTL_CODE()_WinAPI_CreateGUID()_WMIDateStringToDate()/_DateToWMIDateString()Au3 script parsingAutoIt SearchAutoIt3 PortableAutoIt3WrapperToPragmaAutoItWinGetTitle()/AutoItWinSetTitle()CodingDirToHTML5FileInstallrFileReadLastChars()GeoIP databaseGUI - Only Close ButtonGUI ExamplesGUICtrlDeleteImage()GUICtrlGetBkColor()GUICtrlGetStyle()GUIEventsGUIGetBkColor()Int_Parse() & Int_TryParse()IsISBN()LockFile()Mapping CtrlIDsOOP in AutoItParseHeadersToSciTE()PasswordValidPasteBinPosts Per DayPreExpandProtect GlobalsQueue()Resource UpdateResourcesExSciTE JumpSettings INISHELLHOOKShunting-YardSignature CreatorStack()Stopwatch()StringAddLF()/StringStripLF()StringEOLToCRLF()VSCROLLWM_COPYDATAMore Examples...

Updated: 22/04/2018

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...