forum.vdsworld.com Forum Index forum.vdsworld.com
Visit VDSWORLD.com
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 


HELP CALLING DLL

 
Post new topic   Reply to topic    forum.vdsworld.com Forum Index -> General Help
View previous topic :: View next topic  
Author Message
cnodnarb
Professional Member
Professional Member


Joined: 11 Sep 2002
Posts: 762
Location: Rockeledge, GA

PostPosted: Tue Mar 18, 2014 2:17 am    Post subject: HELP CALLING DLL Reply with quote

I've built a standard DLL by hacking my VB6 linker.

I have no clue how to call it from VDS.

Here's my DLL code LoL

Code:

   
Option Explicit

Public Const DLL_PROCESS_DETACH = 0
Public Const DLL_PROCESS_ATTACH = 1
Public Const DLL_THREAD_ATTACH = 2
Public Const DLL_THREAD_DETACH = 3

Public Function DllMain(hInst As Long, fdwReason As Long, lpvReserved As Long) As Boolean
   Select Case fdwReason
      Case DLL_PROCESS_DETACH
         ' No per-process cleanup needed
      Case DLL_PROCESS_ATTACH
         DllMain = True
      Case DLL_THREAD_ATTACH
         ' No per-thread initialization needed
      Case DLL_THREAD_DETACH
         ' No per-thread cleanup needed
   End Select
End Function

Public Function Increment(var As Integer) As Integer
   If Not IsNumeric(var) Then Err.Raise 5
   
   Increment = var + 1
End Function

Public Function Decrement(var As Integer) As Integer
   If Not IsNumeric(var) Then Err.Raise 5
   
   Decrement = var - 1
End Function

Public Function Square(var As Long) As Long
   If Not IsNumeric(var) Then Err.Raise 5
   
   Square = var ^ 2
End Function

Back to top
View user's profile Send private message AIM Address
cnodnarb
Professional Member
Professional Member


Joined: 11 Sep 2002
Posts: 762
Location: Rockeledge, GA

PostPosted: Tue Mar 18, 2014 2:22 am    Post subject: Reply with quote

I don't think it's gonna work with VDS.

"Error: Library function not found at line 4"

Code:

loadlib mathlib.dll
%s = ""

%i = @lib(mathlib.dll,Increment,INT:,5,@addr("%s"))

info %s

freelib mathlib.dll
Back to top
View user's profile Send private message AIM Address
cnodnarb
Professional Member
Professional Member


Joined: 11 Sep 2002
Posts: 762
Location: Rockeledge, GA

PostPosted: Tue Mar 18, 2014 2:44 am    Post subject: Reply with quote

Alright, I had an error with a .def file for my DLL, it's fixed.

I can call this baby from VB6...
Now time to play with VDS....
Back to top
View user's profile Send private message AIM Address
cnodnarb
Professional Member
Professional Member


Joined: 11 Sep 2002
Posts: 762
Location: Rockeledge, GA

PostPosted: Tue Mar 18, 2014 2:46 am    Post subject: Reply with quote

Need help!

Code:

loadlib Project1.dll
%s = ""

%i = @lib(Project1.dll,Increment,INT:,5+5)

info %i

freelib Project1.dll


WORKS!! I get a variable returned to i!!!

Is this a memory address or somehow the sum of 5+5?

%i = 285223734

?


Last edited by cnodnarb on Tue Mar 18, 2014 3:03 am; edited 3 times in total
Back to top
View user's profile Send private message AIM Address
cnodnarb
Professional Member
Professional Member


Joined: 11 Sep 2002
Posts: 762
Location: Rockeledge, GA

PostPosted: Tue Mar 18, 2014 2:56 am    Post subject: Reply with quote

OK!!

IT IS TOTALLY WORKING!!

Can someone tell me why it starts counting from 285212672 ?

It works though!

Yay!

%i = @lib(Project1.dll,Increment,INT:,1+1) = 285223730

Does this make sense to any of our math wizards/those familiar with DLL's?

Does 285212672 have any significance?
Back to top
View user's profile Send private message AIM Address
cnodnarb
Professional Member
Professional Member


Joined: 11 Sep 2002
Posts: 762
Location: Rockeledge, GA

PostPosted: Tue Mar 18, 2014 3:03 am    Post subject: Reply with quote

DANGER WILL ROBINSON - I have found the significance

http://msdn.microsoft.com/en-us/library/aa733541(v=vs.60).aspx

NO DANGER!

Just means my DLL is public.

So why is it counting memory addresses?
Back to top
View user's profile Send private message AIM Address
cnodnarb
Professional Member
Professional Member


Joined: 11 Sep 2002
Posts: 762
Location: Rockeledge, GA

PostPosted: Tue Mar 18, 2014 3:12 am    Post subject: Reply with quote

Square works perfectly.

loadlib Project1.dll
%s = 9

%i = @lib(Project1.dll,Square,INT:,@binary(INT,2))

clipboard set,%i

freelib Project1.dll

It is on like Donkey Kong.
Back to top
View user's profile Send private message AIM Address
Garrett
Moderator Team


Joined: 04 Oct 2001
Posts: 2149
Location: A House

PostPosted: Tue Mar 18, 2014 4:10 am    Post subject: Reply with quote

Wish I could answer your questions but it looks all geek to me.
_________________
'What you do not want done to yourself, do not do to others.' - Confucius (550 b.c. to 479 b.c.)
Back to top
View user's profile Send private message
cnodnarb
Professional Member
Professional Member


Joined: 11 Sep 2002
Posts: 762
Location: Rockeledge, GA

PostPosted: Tue Mar 18, 2014 12:00 pm    Post subject: Reply with quote

I think it's because I've failed to properly pass a variable from VDS to my increment function, so it starts counting from the memory address.

When I pass null by mistake it returns memory address. When I was guessing it was hex counting or something, 5+5, I have no ideal what it translated.

Now square roots passed properly... and apparently it was waiting for a 'solid' parameter.

The good news is, I can make VB6 DLL's for VDS now!

[edit]
I am passing the parameter perfectly. It's just a quirk of communicating with the DLL. The function works as programmed, I just have to subtract 285212672 from the returned value.

%i = @lib(Project1.dll,Increment,INT:,@binary(largeint,24))

= 285212697

285212697 - 285212672 = 25

25 = 24 incremented by 1.
Back to top
View user's profile Send private message AIM Address
cnodnarb
Professional Member
Professional Member


Joined: 11 Sep 2002
Posts: 762
Location: Rockeledge, GA

PostPosted: Tue Mar 18, 2014 1:12 pm    Post subject: Reply with quote

Alright, learned how to change the base address, which is highly recommended. Good thing this quirk happened! So my first thought of 'DANGER!' was also accurate. Helps to read/review this stuff when you're actually awake.

"The default value is &H11000000 (285,212,672). If you neglect to change this value, your component will conflict with every other in-process component compiled using the default. Staying well away from this address is recommended."
Back to top
View user's profile Send private message AIM Address
Display posts from previous:   
Post new topic   Reply to topic    forum.vdsworld.com Forum Index -> General Help All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You can attach files in this forum
You can download files in this forum

Twitter@vdsworld       RSS

Powered by phpBB © 2001, 2005 phpBB Group