Tips on writing 64-bit ⎕NA calls in Dyalog /W 64-bit
Forum rules
The FAQ is a read-only forum which is in general updated only by employees of Dyalog Ltd. It replaces the FAQ page which existed under http://www.dyalog.com. Rather than rejecting other posts to this forum, such posts will be put in a moderation queue, and moved to a more appropriate forum.
The FAQ is a read-only forum which is in general updated only by employees of Dyalog Ltd. It replaces the FAQ page which existed under http://www.dyalog.com. Rather than rejecting other posts to this forum, such posts will be put in a moderation queue, and moved to a more appropriate forum.
1 post
• Page 1 of 1
Tips on writing 64-bit ⎕NA calls in Dyalog /W 64-bit
All pointers, HANDLE, SIZE_T, and LPARAM/WPARAM types are 64-bit. We'd recommend using P for these types.
The P type specifier is U4 on a 32-bit Dyalog and U8 on a 64-bit Dyalog. This P type was introduced with Dyalog 13.0 in 2011.
DWORD and UINT are always 32-bit on both 32-bit and 64-bit Windows.
Example:
MEMCPY in dyalog64.dll has 3 arguments. The first 2 are pointers and the third is an unsigned integer. Modifying the examples from our Language reference:
If you need to specify structures in your ⎕NA specification, you need to remember that P and U8 need to start on a 64-bit boundary. So, if you have a P following an I4, you actually need two I4s. One is the I4 you want and the other is padding.
An example of this is the ChooseColor function in the supplied quadna workspace:
Another example:
The P type specifier is U4 on a 32-bit Dyalog and U8 on a 64-bit Dyalog. This P type was introduced with Dyalog 13.0 in 2011.
DWORD and UINT are always 32-bit on both 32-bit and 64-bit Windows.
Example:
⎕NA 'U4 USER32|SendMessage* U8 U4 U8 U8'
MEMCPY in dyalog64.dll has 3 arguments. The first 2 are pointers and the third is an unsigned integer. Modifying the examples from our Language reference:
'doubles' ⎕NA 'dyalog64|MEMCPY >F8[] U8 U4'
'prec' ⎕NA 'dyalog64|MEMCPY U8 <{I4 F4 T[20]} U4'
'get' ⎕NA 'dyalog64|MEMCPY >0T[] U8 U4'
'put' ⎕NA 'dyalog64|MEMCPY U8 <0T[] U4'
If you need to specify structures in your ⎕NA specification, you need to remember that P and U8 need to start on a 64-bit boundary. So, if you have a P following an I4, you actually need two I4s. One is the I4 you want and the other is padding.
An example of this is the ChooseColor function in the supplied quadna workspace:
PAD←0
'ChooseColorFn'⎕NA'U4 comdlg32.dll|ChooseColor* ={I4 U4 P P {U1[4]} U4 P U4 U4 P P P}'
r←ChooseColorFn⊂(72 PAD 0 0(0 0 0 0)PAD addr 0 PAD 0 0 0)
Another example:
startprog program;TRUE;NORMAL_PRIORITY_CLASS;PAD;dir;rc;processinfo;startupinfo
TRUE←1
NORMAL_PRIORITY_CLASS←32
PAD←0
dir←'c:\tmp\'
startupinfo←104 PAD 0 0 0 0 0 640 480 80 25 30 1 0 0 PAD 0 0 0 0
'CreateProcess'⎕NA'I4 kernel32.dll|CreateProcess* I4 <0T P P I4 I4 P <0T <{I4 U4 P P P I4 I4 I4 I4 I4 I4 I4 I4 I2 I2 U4 P P P P} >{P P I4 I4}'
(rc processinfo)←CreateProcess 0 program 0 0 TRUE NORMAL_PRIORITY_CLASS 0 dir startupinfo 0
- Vince|Dyalog
- Posts: 432
- Joined: Wed Oct 01, 2008 9:39 am
1 post
• Page 1 of 1
Return to Frequently Asked Questions (FAQ)
Who is online
Users browsing this forum: No registered users and 1 guest
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group