Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

wnaspi32.dll and VFP

Status
Not open for further replies.

pepe000p

Programmer
Jul 22, 2003
4
AR
Thanks to AirCon i could go ahead with the wnaspi32.dll but now I got in problems again.
When I try to read a CD TOC I keep getting an 0xE0 error and I can't find anything wrong.
Thank you,
Pepe


*** TOC Reading
* preparing the buffer
BuffTOC = REPLICATE(c0, 804)
DECLARE LONG GlobalAlloc IN "kernel32" LONG wFlags, LONG dwBytes
lnRet = GlobalAlloc(0, 804)
DECLARE LONG RtlMoveMemory IN "kernel32" LONG ptrIntoHere, STRING @cFromHere, LONG cb
RtlMoveMemory(lnRet,@BuffTOC,LEN(BuffTOC))
BuffPtr = Num2DWord(lnRet)
BuffLen = Num2DWord(0x324)

* preparing the structure
SRB_ExecSCSICmd = REPLICATE(c0, 80)
SRB_ExecSCSICmd = STUFF(SRB_ExecSCSICmd, 1, 1, CHR(2)) && Comando Exec SCSI Command
SRB_ExecSCSICmd = STUFF(SRB_ExecSCSICmd, 3, 1, CHR(lnHAId)) && HAId - got with Get Device Type
SRB_ExecSCSICmd = STUFF(SRB_ExecSCSICmd, 4, 1, CHR(0x8)) && Flags Dir_In
SRB_ExecSCSICmd = STUFF(SRB_ExecSCSICmd, 9, 1, CHR(lnTargetSCSIId)) && Target - got with Get Device Type
SRB_ExecSCSICmd = STUFF(SRB_ExecSCSICmd, 10, 1, CHR(lnLUN)) && LUN - got with Get Device Type
SRB_ExecSCSICmd = STUFF(SRB_ExecSCSICmd, 13, 4, BuffLen) && Buffer Length 0x324
SRB_ExecSCSICmd = STUFF(SRB_ExecSCSICmd, 17, 4, BuffPtr) && Buffer Pointer
SRB_ExecSCSICmd = STUFF(SRB_ExecSCSICmd, 21, 1, CHR(0x0E)) && Sense Length
SRB_ExecSCSICmd = STUFF(SRB_ExecSCSICmd, 22, 1, CHR(0x0A)) && CDBLen
SRB_ExecSCSICmd = STUFF(SRB_ExecSCSICmd, 49, 16, CHR(0x43)+CHR(2)+CHR(0)+CHR(0)+CHR(0);
+CHR(0)+CHR(0)+CHR(0x3)+CHR(0x24)+CHR(0)) && CDB - Read TOC, MSF, and Buffer 0x324

* sending the command
DO WHILE SendASPI32Command(@SRB_ExecSCSICmd) = SS_PENDING
DOEVENTS
ENDDO

* getting the buffer back
lnPtr = DWord2Num(SUBSTR(SRB_ExecSCSICmd, 17, 4))
DECLARE LONG GlobalSize IN "Kernel32" LONG HGLOBAL_hMem
lnLen = GlobalSize(lnPtr)
BuffTOC = SPACE(lnLen)
DECLARE LONG RtlMoveMemory IN "kernel32" STRING @ cIntoHere, LONG ptrFromHere, LONG cb
RtlMoveMemory(@BuffTOC,lnPtr,lnLen)


FUNCTION DWord2Num(tcDWord)
RETURN ASC(SUBSTR(tcDWord, 1,1)) + ASC(SUBSTR(tcDWord, 2,1)) * 256 + ;
ASC(SUBSTR(tcDWord, 3,1)) * 65536 + ASC(SUBSTR(tcDWord, 4,1)) * 16777216
ENDFUNC

FUNCTION Num2DWord(lnNum)
a1=INT(MOD(MOD(MOD(lnNum,16777216),65536),256))
a2=INT(MOD(MOD(lnNum,16777216),65536)/256)
a3=INT(MOD(lnNum,16777216)/65536)
a4=INT(lnNum/16777216)
* ? lnret, a1, a2, a3, a4
RETURN CHR(a1) + CHR(a2) + CHR(a3) + CHR(a4)
ENDFUNC
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top