Pointers

58 views
Skip to first unread message

Hugo Dante Diaz

unread,
Nov 10, 2025, 12:57:07 PMNov 10
to xblite
Hi all

I've been reading the documentation and I don't think I've found the pointer construct and its dereference.

Yes I found the operator "address-of" (&)  used to load the value of a pointer,  but not its counterpart.

It would be very useful for managing dynamic linked lists. For example:

TYPE Node_t
   USHORT .dato
   XLONG .siguiente
END TYPE

Node_t nodo
XLONG lista

lista = &nodo
lista -> dato = 10 ?????  'not compile
lista -> siguiente = 0 ???? 'not compile

Is there an indirect way to program this?

Thanks!

Guy Lonne

unread,
Nov 12, 2025, 10:46:34 PMNov 12
to xbl...@googlegroups.com
Hi Hugo!

To read the value thru a pointer, use: *AT( ); for example: The ULONGAT(
) Intrinsic reads/writes a ULONG value into a specified memory address.

Welcome to the list, and happy xbliting!

Bye! Guy

Guy LONNE

unread,
Nov 12, 2025, 10:46:40 PMNov 12
to xblite

Guy LONNE

unread,
Nov 14, 2025, 4:16:58 AMNov 14
to xbl...@googlegroups.com
Hi Hugo!
If I understand your message correctly, you use the wrong operator ->.
I suggest you use instead the dot in XBLite.
Hope this helps, and give me a feedback to let me know if I'm on mark.
Cheers, Guy

--
You received this message because you are subscribed to the Google Groups "xblite" group.
To unsubscribe from this group and stop receiving emails from it, send an email to xblite+un...@googlegroups.com.
To view this discussion visit https://groups.google.com/d/msgid/xblite/90de3bf7-30e8-4f53-b00e-7ab769cc16d1n%40googlegroups.com.

Hugo Dante Diaz

unread,
Nov 14, 2025, 7:36:34 AMNov 14
to xblite
Hi Guy,

Yes, I used the arrow operator (as it exists in the C programming language) knowing it was wrong. Just to illustrate the point of the question.

According to your suggestion to use the *AT() functions, while they work, the resulting code is quite confusing.

I've been playing around a bit and I think I've found a way, albeit a slightly dirty one, but the result is more understandable.

I used a single line of inline assembly, overwriting an auxiliary variable of type node with the pointer to dynamic memory.

Care must be taken to ensure that the auxiliary variable of type node is declared first in the declaration of local variables of the function where the inline assembly will be applied.

Another requirement is that it works with 32 bits and the xblite version is 2.4.3

A working example of a complete program is as follows:

PROGRAM "nodo_dyn"
EXPLICIT
CONSOLE

IMPORT "xst"


TYPE Node_t
  USHORT .dato
  XLONG  .siguiente
END TYPE

DECLARE FUNCTION Entry()
DECLARE FUNCTION GetFirstNode()

FUNCTION Entry()
  Node_t aux
  XLONG ptr

  ptr = GetFirstNode()
ASM mov d[ebp - 44], eax

  PRINT HEXX$(aux.dato)
  PRINT HEXX$(aux.siguiente)

  Xfree(ptr)

  RETURN 0
END FUNCTION

FUNCTION GetFirstNode()
  Node_t aux
  XLONG ret

  ret = Xcalloc(SIZE(Node_t))
ASM mov d[ebp - 44], eax

  aux.dato = 0xDEAD
  aux.siguiente = 0

  RETURN ret
END FUNCTION

Thanks! Regards..

Guy LONNE

unread,
Nov 14, 2025, 8:46:50 AMNov 14
to xbl...@googlegroups.com
Hi Hugo.
Your problem is:
1.To allocate a STRUCTure in RAM,
2.To initialize the allocated STRUCT at run-time.

Indeed, it's a recurring snippet in XBLite, as it is almost the norm in win32 api GUI programming.

I can offer you 3 solutions:
1.To copy physically the piece of RAM that stores the data into your allocated STRUCT using XstCopyMemory, or the win32 api (Xbliters do that 99% of the time).
2.To copy using inline ASM (I do that in my tool viXen for the speed,  AND for the fun of hacking).
3.I recall Callum Lowcay using a doubled esperluette (&&lparam) in his WinX library, which I never understood how it worked. My understanding is that Callum switched  the addresses so that his allocated STRUCT would keep its description but would point to the RAM address that actually contains the data.

Now, you found a 4th method, which concerns me as you need to spell out this address, begging for "anonymity", if you see what I mean...

Bye! Guy

Hugo Dante Diaz

unread,
Nov 16, 2025, 8:15:28 PM (13 days ago) Nov 16
to xblite
Hello Guy

I've improved the concept, this time without using inline assembly. I used the intrinsic XLONGAT(). 

I verified that user-defined types located on the stack (because they are declared local to a function) are stored in two parts: a pointer to the contiguous memory region and the region itself.
Therefore, we should change the value of the pointer so that it points to the actual data (in the example, the heap) instead of the stack region where it was declared.
As we know, the XLONG type refers to a natural processor address, so XLONGAT() means "the address of the address" and that's what we should change.
So the composite variable is the pointer (the address) of the data, and in the example it is written like this: &aux. But since the intrinsic operator works with the address of the address, it finally becomes: &&aux. Hence the double address operator.

The proof of concept is:

PROGRAM "nodo_dyn"
EXPLICIT
CONSOLE

IMPORT "xst"

TYPE Node_t
  USHORT .dato
  XLONG  .siguiente
END TYPE

DECLARE FUNCTION Entry()
DECLARE FUNCTION GetFirstNode()

FUNCTION Entry()
  XLONG ptr
  Node_t aux

  ptr = GetFirstNode()
  XLONGAT(&&aux) = ptr  


  PRINT HEXX$(aux.dato)
  PRINT HEXX$(aux.siguiente)

  Xfree(ptr)

  RETURN 0
END FUNCTION

FUNCTION GetFirstNode()
  XLONG ret
  Node_t aux

  ret = 10

  ret = Xcalloc(SIZE(Node_t))
  XLONGAT(&&aux) = ret

  aux.dato = 0xDEAD
  aux.siguiente = -1

  RETURN ret
END FUNCTION

The auxiliary composite type can be declared in any position in the list of local variables.

By the way, where can I get the updated source code for viXen and WinX?

Thanks!
Best regards

Guy LONNE

unread,
Nov 19, 2025, 5:55:36 AM (10 days ago) Nov 19
to xblite
Hi Hugo!
Callum Lowcay keeps a website where you can download his original WinX library: https://callumscode.com/projects.
The double address operator is in the main window loop in WinX.X that you can download there as WinX.zip.
For viXen, you can download the source vxbl.x at SourceForge; just look for VisualXBLiteEnvironment, and go for the menubar option "Files", select "vixen version 1", select VIXEN v1.99, and select "vixen_v1_99u.zip". The initialization by copy is in FUNCTION GetNotifyMsg:
'
' normal---
'' XstCopyMemory (sourceAddr, destAddr, bytes) 'Xsx library function
' RtlMoveMemory (&nmhdr, lParam, SIZE (NMHDR)) ' fill nmhdr using lParam
' normal===
' speedy+++
IFZ lParam THEN RETURN

sourceAddr = lParam
destAddr   = &nmhdr
bytes      = SIZE (NMHDR)

ASM mov esi,[GetNotifyMsg.sourceAddr]
ASM mov edi,[GetNotifyMsg.destAddr]
ASM mov ecx,[GetNotifyMsg.bytes]
ASM cld
ASM rep movsb
' speedy===
'
Bye! Guy
Reply all
Reply to author
Forward
0 new messages