Problems with a DLL in ooRexx 4.0.0 under Windows XP

Problems with a DLL in ooRexx 4.0.0 under Windows XP

Post by Jeremy Nic » Wed, 04 Nov 2009 03:50:52


oRexx 4.0.0, Windows XP Pro SP3

I'm trying to get a rexx exec to use a function from a DLL. It's not
working how I expected it to, but I don't know where the problem lies.


The DLL is something called aamd532.dll, and it implements an MD5 digest on
a file. I found the following example of its use in VB (which I've never
used either):

Public Declare Sub MDFile Lib "aamd532.dll" (ByVal f As String,
ByVal r As String)

- which I presume means the function in the DLL expects to be given the
address of two strings, one containing a filename and the other enough space
for a (16-byte, represented as 32 hex digits?) md5 digest.

I've seen that used in turn as:

Public Function MD5File(f As String) As String
Dim r As String * 32
r = Space(32)
MDFile f, r
MD5File = r
End Function


So, in my rexx exec I did this:

md5dllnm = "MDFile" /* function name as defined inside DLL */
md5dllrx = "rxMD5" /* name I'll use for it in this rexx exec */
md5dllpt = "C:\Program Files\~A-folder\AutoPatcher\bin\aamd532.dll"

findadll = rxfuncadd(md5dllrx,md5dllpt,md5dllnm)
say "funcadd rc="findadll "(0=ok, 1=err)"


That shows a rc of 0 each time I run it, so I suppose it worked. I then
tried querying 4 function names, three of which I expected the exec not to
be able to find. In particular I was trying to show that the function name
that rexx would now recognise was the 'rx' one rather than the 'nm' value:

q.1 = "rxwibble"
q.2 = md5dllrx /* hopefully this one will work */
q.3 = md5dllnm
q.4 = "rxwobble"
q.0 = 4

do qq = 1 to q.0
qqthname = q.qq
queryfnm = rxfuncquery(qqthname)
say " rxfuncquery for name:" right(qqthname,12) "was:" queryfnm
end

which produces:

rxfuncquery for name: rxwibble was: 1
rxfuncquery for name: rxMD5 was: 0
rxfuncquery for name: MDFile was: 1
rxfuncquery for name: rxwobble was: 1

which I think means I have managed ok to define "rxMD5" as a function as far
as rexx is concerned.


Learning one step at a time, I thought I'd next try to drop the four
functions (or at least one function and three irrelevant names), in which I
expected to get one success and three failures, but that didn't happen, so I
followed this by 4 more queries to see if the drops had done anything:

do qq = 1 to q.0
qqthname = q.qq
dropfunc = rxfuncdrop(qqthname)
say " rxfuncdrop for name:" right(qqthname,12) "was:" dropfunc
end
say

do qq = 1 to q.0
qqthname = q.qq
queryfnm = rxfuncquery(qqthname)
say " rxfuncquery for name:" right(qqthname,12) "was:" queryfnm
end
say

which produces:

rxfuncdrop for name: rxwibble was: 1
rxfuncdrop for name: rxMD5 was: 1
rxfuncdrop for name: MDFile was: 1
rxfuncdrop for name: rxwobble was: 1

rxfuncquery for name: rxwibble was: 1
rxfuncquery for name: rxMD5 was: 0
rxfuncquery for name: MDFile was: 1
rxfuncquery for name: rxwobble was: 1

Does this mean that none of the rxfuncdrop calls worked?


After that I thought I'd have a go at calling the loaded function anyway.
So I tried an exec with the rxfuncadd (as above), then the four queries,
then:

testfile = "C:\TESTFILE.PY" /* this file does exist */
digest = copies(" ",40)
say "digest sz=" length(di
 
 
 

Problems with a DLL in ooRexx 4.0.0 under Windows XP

Post by Swift » Wed, 04 Nov 2009 20:08:02


The problem is, what format would those strings be when passed from VB
to the DLL? My guess would be a null-terminated sequence of 1-byte
characters, but that's all it is, a wild guess.

It's then easy enough to tack an '00'x on the ends or your arguments,
but does REXX pass strings to DLL's as nothing but the supplied string?
I'd be surprised if nothing is passed to define the length of the string.

I had a similar problem trying to call an obscure Lotus Notes OLE
function. It expected one of its parameters to be encoded in some
obscure format. I managed to get my string into the required format, but
never to the point where Notes would accept it.

--
Steve Swift
http://www.yqcomputer.com/
http://www.yqcomputer.com/

 
 
 

Problems with a DLL in ooRexx 4.0.0 under Windows XP

Post by Mark Hessl » Wed, 04 Nov 2009 20:52:51


[snip]

You can't simply call rxfuncadd() on any DLL. rxfuncadd() expects to load
a DLL consisting of Rexx external function packages. The DLL in question
is very likely NOT a Rexx external function package.
To load this DLL you would need to use something like the General Call
Interface (GCI) that is provided with Regina.
Otherwise you would need to write a Rexx function package that provides
an interface into the specified DLL.

Cheers, Mark
 
 
 

Problems with a DLL in ooRexx 4.0.0 under Windows XP

Post by Jeremy Nic » Thu, 05 Nov 2009 01:07:25


Ah. AH. Rats!

I used to use Rexx on MVS quite often for writing test harnesses for
assembler programs; whereas in the past the harnesses also needed to be in
assembler, being able to build parm lists in rexx and invoke things via eg
address attachmvs/attachpgm etc was extremely useful. Of course in those
situations we knew exactly what the called routine expected to see, whereas
in this case I have no idea what the DLL needs to be given.




Is that something that's integrated with Regina, or is it a standalone thing
that can also be used with ooRexx?



No chance of that... Maybe I should just stick to using a CLI MD5 utility
and call that, with redirected output or something.



DO you have any thoughts on the rxfuncadd 'working', at least in that
rxfuncquery returned 0 in one case, but rxfuncdrop not working? Even if
the add only worked in the sense that a function name & the address of its
definition got added to a lookup table, surely the drop should have been
able to discard that info?

--
Jeremy C B Nicoll - my opinions are my own.

Email sent to my from-address will be deleted. Instead, please reply
to XXXX@XXXXX.COM replacing "nnn" by "284".
 
 
 

Problems with a DLL in ooRexx 4.0.0 under Windows XP

Post by Jeremy Nic » Thu, 05 Nov 2009 01:15:52


Actually I did try the null yesterday (thinking that that, which AFAIK is a
C-ism, might be needed), except for some reason I only put it on the end of
the string that was going to be written to...

I just tried again on both strings. It doesn't work.

Thanks for the idea.

--
Jeremy C B Nicoll - my opinions are my own.

Email sent to my from-address will be deleted. Instead, please reply
to XXXX@XXXXX.COM replacing "nnn" by "284".
 
 
 

Problems with a DLL in ooRexx 4.0.0 under Windows XP

Post by Rick McGui » Thu, 05 Nov 2009 03:17:14


This sounds like it might be a bug in drop...I suggest opening a bug
report.

Rick
 
 
 

Problems with a DLL in ooRexx 4.0.0 under Windows XP

Post by bwcherr » Thu, 05 Nov 2009 05:36:39


> > Public Declare Sub MDFile Lib "aamd532.dll" (ByVal f As String, >>>> ByVal r As Strin>) >>> > > - which I presume means the function in the DLL expects to be given t>e> > > address of two strings, one containing a filename and the other enou>h> > > space for a (16-byte, represented as 32 hex digits?) md5 diges>. >>
> [snip] gt;> gt;> > >
>
>
> > All hints grat>fu>ly accepted!
>
> You can't simply call rxfuncadd() on any DLL. rxfuncadd()>expects to load
> a DLL consisting of Rexx external function packages. The>DLL in question
> is very likely NOT a Rexx external f>nction package.
> To load this DLL you would need to use something like >he General Call
> Interface (GCI) that is provi>ed with Regina.
> Otherwise you would need to write a Rexx function packa>e that provides
> an interface into th> s>ecified DLL.
>
> Cheers, Mark

If you decide to go with GCI, you might want to look at this
presentation on "The Generic Call Interface (GCI)":
http://www.yqcomputer.com/

I can confirm it works on ooRexx 3.2.
Brandon Cherry
 
 
 

Problems with a DLL in ooRexx 4.0.0 under Windows XP

Post by Shmuel Met » Thu, 05 Nov 2009 06:01:27

In < XXXX@XXXXX.COM >, on 11/03/2009
at 04:07 PM, Jeremy Nicoll - news posts
< XXXX@XXXXX.COM > said:


The same considerations apply in TSO/E REXX; if you call an external
function the interface is a REXX interface. Since you were already aware
of the various ADDRESS environments, you should have realized that.

--
Shmuel (Seymour J.) Metz, SysProg and JOAT < http://www.yqcomputer.com/ ~shmuel>

Unsolicited bulk E-mail subject to legal action. I reserve the
right to publicly post or ridicule any abusive E-mail. Reply to
domain Patriot dot net user shmuel+news to contact me. Do not
reply to XXXX@XXXXX.COM
 
 
 

Problems with a DLL in ooRexx 4.0.0 under Windows XP

Post by spamgat » Sat, 07 Nov 2009 04:45:31


> I'm trying to get a rexx exec to use a function from a DLL.

Then obtain a rather simple example, like the old VXTECH01.ZIP, and use
some language one actually masters? Your problems really have nothing
to do with Rexx if you're not able to port (not *.C) or use (*.C) those
rather basic examples. Try e.g. comp.lang.c instead and don't downgrade
to the latest forever-broken-ooRexx.



---
 
 
 

Problems with a DLL in ooRexx 4.0.0 under Windows XP

Post by Jeremy Nic » Tue, 10 Nov 2009 10:40:32


I've done so.

--
Jeremy C B Nicoll - my opinions are my own.

Email sent to my from-address will be deleted. Instead, please reply
to XXXX@XXXXX.COM replacing "nnn" by "284".