I asked this on the powerBASIC forum but without luck.

I wanted to try to get rid of my declares and call the few calls i have using Call Dword...
This works fine but i still need to include GetModuleHandle() and GetProcAddress().

Is there any way to obtain these addresses in PB/WIN without declaring them?
Some sort of ASM eq. ??

Posted on 2005-01-03 10:44:44 by Edwin Knoppert
What you really need is LoadLibrary and GetProcAddress, from there everything is at your finger tips. After all in most cases the module handle for your main executable is 0400000h anyway. You can take a look at Iczelion's page, I think there is an example of a Win32 program without imports by y0da.
Posted on 2005-01-03 20:27:22 by donkey
Will search for it.
I need the "kernel" instance to be used with GetProcAddress().
Then i can obtain "LoadLibraryA" and so..

Would be neat if i could get rid of the first two (declares)

I thought you 'left the building'?

Posted on 2005-01-04 03:14:28 by Edwin Knoppert
I found this ASM file, but frankly way to complex to me to convert.


If someone is able to manage the Kernel instance and GetProcAddress() this way in PowerBASIC let me know.

(I'll ask on the PB forum as well)
Posted on 2005-01-04 03:24:10 by Edwin Knoppert
Why don't you just say that you want to imports? Anyway you need at least one entry in the import table for your exe to work on win2k.

To get kernel32.dll address...

assume fs:nothing
mov eax,fs:[30h]
mov edx,0B8h
mov ecx,[eax+30h]
test eax,eax
jns KI_1
mov ebx,[eax+34h]
or ecx,ecx
jnz KI_2
mov eax,[eax+0Ch]
sub edx,0B0h
mov eax,[eax+1Ch]
mov ebx,[eax]
mov eax,[ebx+edx] ;;ebp = kernel base
mov ebp,eax

Code by lingo12 (if I remember the nick correctly)

Search for the export table and then extract the address.
Posted on 2005-01-04 06:05:55 by roticv
I appreciate your efforst but i still have difficulty with:

1) assume fs:nothing ( i assume a flag which must be set to 0 first?)

2) ;ebp = kernel base
If so, how do i get that in an ordianry long.dword ion PB?

Posted on 2005-01-04 06:50:33 by Edwin Knoppert
Btw, The powerbasic exe or dll will already have kernel loaded the moment i need the instance handle.
So i assume the kernel example will not be OS depending at all.
Posted on 2005-01-04 06:52:23 by Edwin Knoppert
If you don't want to be kernel/OS version dependant, use GetModuleHandle and GetProcAddress...
Posted on 2005-01-04 11:00:24 by f0dder