Click to See Complete Forum and Search --> : more torture with .dll win libraries and perl
YaRness
12-07-2000, 09:34 AM
i'm reading up on the perl module Win32::API. this seems to be what i was looking for earlier, something to access .dll functions. it mentions that i should look for an XS extension or something already written because it would be a better tool for this. what the hell is an XS extension thingy?
also, using this function requires that you properly pack and unpack the parameters (or the space for return values i think) before/after executing the .dll function. i may need some serious help with this, but i'm trying to figure it out from the example.
------------------
"Assembly of Japanese bicycle require great peace of mind."
Registered Linux User #188285 http://counter.li.org/
------------------
[This message has been edited by YaRness (edited 07 December 2000).]
Stuka
12-07-2000, 10:39 AM
Can you post the example? I'm in the joyous position of dealing with Win32 a lot right now, so I might be able to help explain parts you're having trouble with.
YaRness
12-07-2000, 10:54 AM
silly me, yes of course.
this is the first fucntion i'll try to implement. i think i can handle all the object creating stuff, i'm just not sure what to do about retrieving the return value
basically the function is
Prototype: DWORD GetASPI32SupportInfo(VOID)
The GetASPI32SupportInfo function returns the number of host adapters installed and ensures that the ASPI manager is initialized properly. This function must be called once at initialization time, before SendASPI32Command is accessed. The number of host adapters returned represents the logical bus count, not the true physical adapter count. For host adapters with a single bus, the host adapter count and logical bus count are identical.
This function has no parameters.
The DWORD return value specifies the result of the ASPI request. The DWORD is encoded as follows:
Table 4-1. Return Values from GetASPI32SupportInfo Function
Length Bit Meaning
----------------------
WORD 31-16 Reserved = zero
BYTE 15-8 Status
(Values for status:
SS_COMP ASPI request completed without error
SS_FAILED_INIT ASPI manager unable to initialize; ASPI services not available )
BYTE 7-0
If Status = SS_COMP
Number of host adapters
i, ugh, barely know where to begin
"BYTE 15-8 Status"
this i don't understand at all. are the SS_COMP and the other ones some kind of identifiers for constants, because i don't see how you could store much information in 8 bits.
hopefully, i (for now) just need to figure out how to unpack that DWORD. if i've been reading the docs on the Win32:API module correctly, i can just get the return value from this GetASPI.. function (a DWORD) in an integer:
$myint=<call to GetASPIfunction>
either that or i will have to pack $myint with some zeroed out 32 bit template so it collects the return value properly. i'm having a hard time understanding the pack function as well.
anyway, i'm sure that's clear as mud. here's some links to the actual function and .dll:
GetASPI... function: http://www.microsoft.com/devonly/TECH/hardware/ddk/DDKdocs/win98ddk/storage_5nzo.htm
beginning of documentation for wnaspi32.dll: http://www.microsoft.com/devonly/TECH/hardware/ddk/DDKdocs/win98ddk/storage_5ny0.htm
------------------
"Assembly of Japanese bicycle require great peace of mind."
Registered Linux User #188285 http://counter.li.org/
------------------
miller
12-07-2000, 02:30 PM
You need to strip out the bytes from the double word to get the individual values.
$x = <Call to GetASPI32SupportInfo>;
$status = (($x & 0x0000ff00) >> 8);
#this masks out all the bits except the second byte (bits 8-15) and shifts them right by 8 bits, giving you the status.
$num_adapters = ($x & 0x000000ff);
#This masks out all the bits except the first byte (bits 0-7), giving you the number of adapters.
You'll have to figure out what the constant values are, like SS_COMP, and SS_FAILED_INIT.
YaRness
12-07-2000, 02:47 PM
holy crap, flashbacks from college. duh, i shoulda thought of masking out the values. i got caught up reading about that pack stuff. masking will work, i was thinking maybe there was a prettier way to do it http://www.linuxnewbie.org/ubb/redface.gif
anyway, i'm having some module issues first, gonna do that in a seperate thread i think. i managed to create an object successfully (i think), but i need to get the Win32::API module installed on the lab workstation to do further work.
------------------
"Assembly of Japanese bicycle require great peace of mind."
Registered Linux User #188285 http://counter.li.org/
------------------
Stuka
12-07-2000, 07:35 PM
Sounds like you have the solution in hand! http://www.linuxnewbie.org/ubb/smile.gif Yup, masking out bits would probably be the easiest solution, like miller said. And yeah, the SS_COMP, etc. are symbolic constants - once you know what they are, you're golden.
YaRness
12-07-2000, 07:36 PM
you guys just rock. screw all the weirdoes in off topic and whatnot, this is the place to be.
time to post another question i think http://www.linuxnewbie.org/ubb/biggrin.gif
------------------
"Assembly of Japanese bicycle require great peace of mind."
Registered Linux User #188285 http://counter.li.org/
------------------