Byte array in DLL

Posted by Aliaksandr Tarasevich on 17-Apr-2012 10:18

Hi guys,

Trying to use WTSQuerySessionInformation function from Wtsapi32.dll. Everything works fine and I can get string values back, but when I try to use 13 entry from WTS_INFO_CLASS I get back the following structure:

typedef struct _WTS_CLIENT_ADDRESS {
  DWORD AddressFamily;
  BYTE  Address[20];
} WTS_CLIENT_ADDRESS, *PWTS_CLIENT_ADDRESS;

And I successfully got AddressFamily using GET-LONG function, but had no luck with BYTE Address[20] yet. How we can get data from it in Progress?

In C++ example people get this data in the following way:

ClientAddressPtr.Address[2] + "." + ClientAddressPtr.Address[3] + "." + ClientAddressPtr.Address[4] + "." + ClientAddressPtr.Address[5];

Thanks,

Aliaks

All Replies

Posted by gus on 24-Apr-2012 09:54

Try GET-BYTES  (ClientAddressPtr, 4, 20)

The start position is 4 because the first 4 bytes of the structure are the LONG occupied by AddressFamily.

Posted by Matt Baker on 24-Apr-2012 10:07

The ABL is 1 based indexing for arrays.  So the first position would be 5, not 4.


Posted by gus on 24-Apr-2012 10:42

Gah. Proof that I should not be believed.

Posted by jmls on 24-Apr-2012 10:52

soooooo, when you say "don't do that!" ...

Posted by gus on 24-Apr-2012 11:36

Hmmm. Then again, my preceding statement should not be believed.

Posted by Aliaksandr Tarasevich on 24-Apr-2012 15:33

Thanks for help,

But how I can get meaningful information from this array?

P.S. In the attachment you can find procedure, if you run it in RDP session it will give you this structure back.

Thanks,

Aliaks

Posted by Matt Baker on 24-Apr-2012 16:09

The equivalent would be this, assuming you have the offsets correct.


define variable address as character no-undo.

address = String(get-byte(mClientAddressPtr, 3)) + "." + String(get-byte(mClientAddressPtr, 4)) + "." + string(get-byte(mClientAddressPtr, 5)) + "." + String(get-byte(mClientAddressPtr, 6)).

This thread is closed