Coding

Welcome, Guest. Please login or register.
Did you miss your activation email?
August 19, 2017, 11:54:54 AM

Login with username, password and session length

Menu

Members
Stats
  • Total Posts: 12135
  • Total Topics: 1730
  • Online Today: 66
  • Online Ever: 195
  • (February 11, 2014, 12:46:08 PM)
Users Online
Users: 0
Guests: 36
Total: 57
Yahoo!
Sogou
Google
Baidu (18)

Recent Topics

Pages: [1]   Go Down

Author Topic: LoadLibrary & GetProcAddress call in IBasic Pro  (Read 2015 times)

0 Members and 1 Guest are viewing this topic.

TLaRoche

  • Newbie
  • *
  • Bananas: 0
  • Offline Offline
  • Gender: Male
  • Posts: 9
  • Born to code ... doomed to fail...
LoadLibrary & GetProcAddress call in IBasic Pro
« on: September 28, 2014, 03:45:35 AM »

Okay, if I can't declare a function in IBasic Pro using an ordinal value instead of the the function name (as is the case with some of the Windows API .... then how about using LoadLibrary and GetProcAddress. Is there a way in IBasic Pro to call an API function via the address retrieved from calling LoadLibrary and then calling GetProcAddress (ie. dynamically calling an API function)?

Hope I worded everything right.

As always, thank you in advance for any and all help,
T
Logged
Just finished backing up to the ol' tape backup drive ... again. Maybe this time restore will work...

Larry McCaughn

  • Head Monkey
  • Administrator
  • Sr. Member
  • *****
  • Bananas: 4
  • Offline Offline
  • Gender: Male
  • Posts: 254
Re: LoadLibrary & GetProcAddress call in IBasic Pro
« Reply #1 on: October 02, 2014, 06:13:51 PM »

... ordinal value instead of the the function name (as is the case with some of the Windows API ....
can you give me an example of a windows api that uses an ordinal number instead of a function number...I've never come across one?
Logged
Admin - Here and @ Ionic Wind Software Forums
Author of Custom Button Designer, Custom Chart Designer, Snippet Manager, and IWB+ (A Visual Designer for IWBasic 2.x)

TLaRoche

  • Newbie
  • *
  • Bananas: 0
  • Offline Offline
  • Gender: Male
  • Posts: 9
  • Born to code ... doomed to fail...
Re: LoadLibrary & GetProcAddress call in IBasic Pro
« Reply #2 on: October 12, 2014, 05:44:33 PM »

Thank you for your response,  and sorry for my late response in return; I've been stuck with work for a while now. Okay, so here is an API call that uses an ordinal value in order to function on a Win 9x/Me system:

(VB Syntax)
Declare Sub Exitwindowsdialog Lib "Shell32.dll" Alias "#60" (ByVal hwndOwner As Long)

And my question again: Is there a way to either declare this function in IBasic Pro or by a call to the function dynamically by using LoadLibrary and GetProcAddress that I have missed?

And again, thanks for any help with this issue.
Logged
Just finished backing up to the ol' tape backup drive ... again. Maybe this time restore will work...

Larry McCaughn

  • Head Monkey
  • Administrator
  • Sr. Member
  • *****
  • Bananas: 4
  • Offline Offline
  • Gender: Male
  • Posts: 254
Re: LoadLibrary & GetProcAddress call in IBasic Pro
« Reply #3 on: October 12, 2014, 07:01:29 PM »

I'm running win 7 and couldn't make it work.

Looking up that command and found this:
Platforms
◾Windows 95: Supported.
◾Windows 98: Supported.
◾Windows NT: Requires Windows NT 3.1 or later.
◾Windows 2000: Supported.
◾Windows CE: Unknown.
The ExitWindowsDialog function is officially undocumented.


and it appears to have been last update in 2000.
Logged
Admin - Here and @ Ionic Wind Software Forums
Author of Custom Button Designer, Custom Chart Designer, Snippet Manager, and IWB+ (A Visual Designer for IWBasic 2.x)

TLaRoche

  • Newbie
  • *
  • Bananas: 0
  • Offline Offline
  • Gender: Male
  • Posts: 9
  • Born to code ... doomed to fail...
Re: LoadLibrary & GetProcAddress call in IBasic Pro
« Reply #4 on: October 13, 2014, 03:46:13 AM »

Hi Larry,
Okay, but like I said the VB declaration I listed is correct for Win 9x/Me. This getting slightly off my point.

The main thing is ... can I use LoadLibrary and GetProcAddress to dynamically call a function, or to declare a function somehow by its ordinal.

Thank you for your responses.
Logged
Just finished backing up to the ol' tape backup drive ... again. Maybe this time restore will work...

Larry McCaughn

  • Head Monkey
  • Administrator
  • Sr. Member
  • *****
  • Bananas: 4
  • Offline Offline
  • Gender: Male
  • Posts: 254
Re: LoadLibrary & GetProcAddress call in IBasic Pro
« Reply #5 on: October 13, 2014, 08:07:34 AM »

And my point is that unless you are using one of those old versions of windows the command with the #60 or whatever isn't on your computer to call no matter what.

So, I have no idea of how to call a function that isn't there  and I don't have and old machine to see if it will work with it there.

Sorry
Logged
Admin - Here and @ Ionic Wind Software Forums
Author of Custom Button Designer, Custom Chart Designer, Snippet Manager, and IWB+ (A Visual Designer for IWBasic 2.x)

TLaRoche

  • Newbie
  • *
  • Bananas: 0
  • Offline Offline
  • Gender: Male
  • Posts: 9
  • Born to code ... doomed to fail...
Re: LoadLibrary & GetProcAddress call in IBasic Pro
« Reply #6 on: October 13, 2014, 05:06:30 PM »

Larry,
I thank you again for your help on this. Okay,  so the project requiring the use of ordinals is a no go. So, back to the topic at hand. LOL

Can I use LoadLibrary and GetProcAddress to dynamically call a function? For the following function I can  call LoadLibrary and GetProcAddress and get the expected values, I just don't know what IBasic Pro command / instruction to call the function with the address obtained from GetProcAddress:
Code: [Select]
BOOL DvdLauncher (
     HWND HWnd,
     CHAR DriveLetter
);
This API call requires LoadLibrary, and GetProcAddress to access the function's address, and that is where I am with this project.

Larry, I thank you again for helping me clear up the issue about ordinals and to finally put it to rest.

And thanks in advance for your or anyone else's help with this issue.
Logged
Just finished backing up to the ol' tape backup drive ... again. Maybe this time restore will work...

Larry McCaughn

  • Head Monkey
  • Administrator
  • Sr. Member
  • *****
  • Bananas: 4
  • Offline Offline
  • Gender: Male
  • Posts: 254
Re: LoadLibrary & GetProcAddress call in IBasic Pro
« Reply #7 on: October 13, 2014, 06:53:01 PM »

maybe this will help
Code: [Select]
DECLARE IMPORT,LoadLibraryA(lpLibFileName:STRING),INT
DECLARE IMPORT,FreeLibrary(hLibModule:INT),INT
DECLARE IMPORT,GetProcAddress(hModule:INT, lpProcName:STRING),INT
DECLARE IMPORT,CallWindowProcA(lpPrevWndFunc:INT, hwnd:INT, msg:INT, wParam:INT, lParam:INT),INT

DEF Library:INT
DEF ProcAddress,ProcAddress2:INT

Library=LoadLibraryA(getstartpath+"msvcrt.dll")
ProcAddress=GetProcAddress(Library, "_ftol")
ProcAddress2=GetProcAddress(Library, "_ftol2")

If ProcAddress=NULL
messagebox 0,"_ftol entry not found, do not attempt to call this function.","Warning"
else
messagebox 0,"_ftol entry found at address"+str$(ProcAddress)+"."+CHR$(13)+CHR$(13)_
+"It is safe to call this function."+CHR$(13)_
+"Use the following to call this function:"+CHR$(13)+CHR$(13)_
+"CallWindowProc(ProcAddress, winhandle, message, wParam, lParam)"_
,"Info"
endif

If ProcAddress2=NULL
messagebox 0,"_ftol2 entry not found, do not attempt to call this function.","Warning"
else
messagebox 0,"_ftol2 entry found at address"+str$(ProcAddress2)+"."+CHR$(13)+CHR$(13)_
+"It is safe to call this function."+CHR$(13)_
+"Use the following to call this function:"+CHR$(13)+CHR$(13)_
+"CallWindowProc(ProcAddress, winhandle, message, wParam, lParam)"_
,"Info"
endif

FreeLibrary(Library)

End
Logged
Admin - Here and @ Ionic Wind Software Forums
Author of Custom Button Designer, Custom Chart Designer, Snippet Manager, and IWB+ (A Visual Designer for IWBasic 2.x)
Pages: [1]   Go Up
 

To link to us use this code/button on your site

http://www.codingmonkeys.com/images/cm_link.gif