Couple different ways. Here I'm declaring a global var in a dll and accessing it in two different ways: (1) passing its address in an Init() procedure, after which the var will be accessible via PeekI() and (2) creating a function to return the var, which can be called any time you want the var's value.
; DLL code:
Global this.i = 123
; Calling code
Init.Init = GetFunction(0, "Init")
Getthis.Getthis = GetFunction(0, "GetThis")
*ptr_i = Init()
I have the global declaration inside the AttachProcess function, but it doesn't need to be there. It can just be declared normally at the top of the code.