Update Procedure CheckDevice()

AmigaOS specific forum
BackupUser
PureBasic Guru
PureBasic Guru
Posts: 16777133
Joined: Tue Apr 22, 2003 7:42 pm

Post by BackupUser »

Restored from previous forum. Originally posted by Roxxler.

Hi,

here again the procedure CheckDevice(). The old one can cause an enforcer hit
if the device we search for is not in the systems device list.

Reason for the enforcer hit 'long read from 00000028' is the line
'devinfo=PeekL(devinfo)*4' in the While-loop. If the end of the device list
is reached the PeekL(devinfo) returns 0 and 0*4 (because it is a BCPL pointer)
causes the enforcer hit.

Silly thing, my fault :-\ Anyway, now it works :)


Procedure.b CheckDevice(device$)
info.l=PeekL(PeekL(DosBase()+34)+24)*4
devinfo.l=PeekL(info+4)*4
texte.l=PeekL(devinfo+40)*4
type.l=PeekL(devinfo+4)
While devinfo0
IF type=0
text$=PeekS(texte+1)
IF text$=UCase(device$)
ProcedureReturn -1
EndIf
EndIf
If PeekL(devinfo) ; here we test now if the next devinfo is greater than 0
devinfo=PeekL(devinfo)*4 ; if so we can read our datas
texte=PeekL(devinfo+40)*4
type=PeekL(devinfo+4)
Else ; end of list is reached
devinfo=0 ; for exiting the loop
EndIf
Wend
ProcedureReturn 0
EndProcedure



Greetings ..
Roxxler