The Game Creators
The Game Creators Home Online Shop Click to Login
  Hot: Christmas CompetitionNovember NewsletterModel Pack 36DB Pro Pack 2009DGS BonanzaCharacter PackFPS Creator Bonanza;
The Game Creators
DLL Talk / rockey hasp dll comunication error

Go to the first page of this board Return to the Forum Menu Post Message
7 Messages - Page   of 1   
Bookmark and Share Search the Forum

Author Message
lms

User


Joined: Tue Nov 3rd 2009
Location: Cyberspace
Posted: 3rd Nov 2009 18:11           | link | toggle

hi guys

Rockey4ND.dll that i use is made for vb

vb example
+ Code Snippet
module :
Declare Function Rockey Lib "Rockey4ND.dll" (ByVal fcode As Integer, ByRef handle As Integer, ByRef lp1 As Long, ByRef lp2 As Long, ByRef p1 As Integer, ByRef p2 As Integer, ByRef p3 As Integer, ByRef p4 As Integer, ByVal buffer As Any) As Integer

Global Const RY_FIND = 1
Global Const RY_FIND_NEXT = 2
Global Const RY_OPEN = 3
mainprog : 
Private Sub TestBtn_Click()

Dim handle(0 To 15) As Integer
Dim p1, p2, p3, p4, i, j, retcode As Integer
Dim lp1, lp2, v As Long
Dim buffer As String
Dim rc(0 To 3) As Integer
Dim curline As Integer

curline = 0

p1 = &HC44C
p2 = &HC8F8
p3 = 0
p4 = 0

retcode = Rockey(RY_FIND, handle(0), lp1, lp2, p1, p2, p3, p4, buffer)
If (retcode <> 0) Then
    List1.List(curline) = "Error Code:" & retcode
    Exit Sub
End If



i tried to make it work in dbpro
+ Code Snippet

load dll "Rockey4ND.dll",12

global handle
local p1 , p2, p3, p4, i, j, retcode
local lp1, lp2, v As double integer
local buffer as byte 
local rc
local curline
rem fcode 1=call ry_find
global fcode = 1 
p1=11111
p2=11111
p3=0
p4=0


retcode = call dll (12,"Rockey",fcode)

if retcode <> 0 
	print retcode
	wait key
	end
else 
wait key
endif

the code like this works and i get that retcode = 4 when hasp is on pc and 3 when hasp is off pc thats cool
but the problem is that
when i put the call dll (12,"Rockey",fcode,handle< a fourth parameter the program crases i get the window with send report)
the thing is that the correct full syntaax to work is something like this
call dll (12,"Rockey",fcode,handle,lp1,lp2,p1,p2,p3,p4,buffer)

the byref commands in vb maby is the key but i dont understand what or how the hell means exactly or how to make it work almost everything i put after dll(12,"Rockey",fcode,crashes the prog

i put the dll so if u run the code u should get a 3 means not a hasp on pc
if u change value of fcode to 5 u get a 15 > is cant read hasp smthing

also passwords has Uint16bit integer &HC44C < how can i convert it to simple integer i cant say p1 = &HC44C ffs
thank u in advance

all os break
Back to top
Download: rockey4nd.dll Size: 57344 bytesReport this message as abusive
Rudolpho

User


Joined: Wed Dec 28th 2005
Location: Sweden
Posted: 4th Nov 2009 05:05           | link | toggle

I'm fairly certain you should substitute long with dword, not double integer

Back to top
Under construction
Report this message as abusive
IanM

Moderator


Joined: Wed Sep 11th 2002
Location: In my moon base
Posted: 4th Nov 2009 07:42           | link | toggle

'byref' variables are actually variable addresses. You need to pass memory addresses where the DLL can write the results to. Use either MAKE MEMORY or MAKE MEMBBLOCK/GET MEMBLOCK ADDRESS for this.

Back to top
Matrix1 Software
Report this message as abusive
Google Ad
Back to top
 
lms

User


Joined: Tue Nov 3rd 2009
Location: Cyberspace
Posted: 4th Nov 2009 14:06           | link | toggle

can u give me a simple example with the make memory command
i cant make it work but it stopped crash
example.
i can take adress of a variable that i create a = make memory(4)
i cant take the variable handle adress which is in the hasp memory i always take 0
how to tell take adress handle in the hasp?


also make memblock/get memblock address command seems that i dont have it is it from the matrix.dll?

thanks in advanced

all os break
Back to top
Report this message as abusive
IanM

Moderator


Joined: Wed Sep 11th 2002
Location: In my moon base
Posted: 4th Nov 2009 16:51           | link | toggle

TBH, that interface is too complex and I'm too out-of-practice in that level of VB6 for me to try and put into an example.

&HC44C in VB6 is the same as 0xc44c in DBPro.

Make memory does not make a variable. It allocates a small chunk of memory and gives you its address so that you can pass it around into DLLs for example:
+ Code Snippet
a = make memory(4)
*a = 123456789
value = *a
print value


Strings are already memory addresses, as long as they contain something, so if you need to pass a string address, simply pass the string instead but make sure it's large enough to accept any changes that the DLL call makes to it.

Back to top
Matrix1 Software
Report this message as abusive
lms

User


Joined: Tue Nov 3rd 2009
Location: Cyberspace
Posted: 7th Nov 2009 06:09           | link | toggle

great thanks for the tips IT WORKED PERFECT

here is the code for rockey hasps first steps sample in dbpro
2 points of interest
a. use make memblock to get and "connect" a string adress > byref in other language
b. &HC44C in VB6 is the same as 0xc44c in DBPro
+ Code Snippet

load dll "Rockey4ND.dll",12

global handle
global p1 , p2, p3, p4, retcode
global lp1, lp2 As dword
global buffer as byte 
global fcode = 1
rem fcode 1=ry_find 2=ry_open 3=ryclose ....
rem handle < string > adresse "> hex16bitnumber

handle = make memory(4)
p1 = make memory(4)
p2 = make memory(4)
*p1=0xc44c
*p2=0xc8f8
p3 = make memory(4)
p4 = make memory(4)
lp1 = make memory(4)
lp2 = make memory(4)
buffer = make memory(4)
retcode = call dll (12,"Rockey",fcode,handle,lp1,lp2,p1,p2,p3,p4,buffer)

if retcode <> 0 
	
	end
else 
print "retcode : ",retcode,"passed the find and read the 2 basic password "
wait key
rem edo open afou find
retcode = call dll (12,"Rockey",3,handle,lp1,lp2,p1,p2,p3,p4,buffer)
if retcode <> 0 
	end
else
print "hasp open - already opened the hasp and read the p1 and p2"
wait key
retcode = call dll (12,"Rockey",4,handle,lp1,lp2,p1,p2,p3,p4,buffer)
if retcode <> 0 
	end
else
print "hasp close" 
wait key
endif
endif
endif


all os break
Back to top
Report this message as abusive
IanM

Moderator


Joined: Wed Sep 11th 2002
Location: In my moon base
Posted: 7th Nov 2009 06:27           | link | toggle

I noticed that you didn't initialise the memory for p3, p4, lp1 and lp2 - There's a good chance that initially any memory you allocate will be filled with zeros, but as your program runs and you free and allocate more memory that you will get memory that is not filled with zeros.

You also need to make sure that you use DELETE MEMORY on any memory addresses you are finished with so that you don't leak memory.

Back to top
Matrix1 Software
Report this message as abusive

Go to the first page of this board Return to the Forum Menu Post Message
7 Messages - Page   of 1   
Search the Forum

You must be logged-in to post messages to this forum. You can register an account for free. Or click here to login.
Forum Search

Enter a word or phrase to search our Forum for:

Thread Subject Search
Search Phrase:
Search Scope: Entire forum
Just this board
 
Google Forum Search
Search Phrase:
 
Apollo v2.02


Game Creator Store
Privacy Policy AUP Top of Page