Page 1 of 1
Interfacing a _stdcall 32bit dll (Asio driver)
Posted: Fri Aug 16, 2013 10:08 am
by eriansa
I can natively interface a 64 bit asio driver without a problem
I can also interface a 32 bit asio driver through a C wrapper dll : this dll simply exports the Asio functions as STDMETHODIMP.
(STDMETHODIMP is a COM return type, which expands to HRESULT __export __stdcall. It's declared in winnt.h)
But I can't natively interface the 32 bit asio driver. (ESP and EAX at least become useless
after the first method call)
Anybody any idea how to safely push and pop the right registers???
Tia!
Btw : I've made my first VST plugin in PB (both 32 and 64 bit) and it works like a charm : see
http://www.raxntrax.com/modulys
Re: Interfacing a _stdcall 32bit dll (Asio driver)
Posted: Sat Aug 17, 2013 11:44 pm
by oreopa
Hey erisana,
A couple of questions... Any plans to release that VST template/skeleton? I am also interested if you would ever release the Rax'n'Trax source, or even consider cutting it down to make a very simple ASIO/VST host source available for PB?
Thanx in advance.
(My 64th post \o/ C= Forever!

)
PS: Sorry I cant help, didn't mean to hijack

Re: Interfacing a _stdcall 32bit dll (Asio driver)
Posted: Sun Aug 18, 2013 1:41 am
by idle
if your interfaces are working on x64 and linux x86/x64
and not on windows x86 it will be a thiscall, so you would have to patch the asm
Code: Select all
CompilerIf #PB_Compiler_OS = #PB_OS_Windows And SizeOf(Integer) = 4 ;tested x86
!Macro CALL proc {
!cmp [p_cppobjptr], 0
!je @f
!push edx
!mov edx, dword [p_cppobjptr]
!mov edx, [edx]
!cmp edx, eax
!pop edx
!jne @f
!pop eax
!mov eax, dword [p_cppobjptr]
!mov ecx, eax
!mov eax,[eax]
!@@:
!call proc
!}
Global *cppobjptr
Macro SetCppObj(pInterface)
*cppobjptr = pInterface
EndMacro
;call SetCppOjb with the *objectptr so it knows to patch it to a this call
CompilerElse
Macro SetCppObj(pInterface)
EndMacro
CompilerEndIf
;eg
*Device.IDevice=CreateDevice()
If *Device
SetCppObj(*Device) ;set c++ class interface to use the this call patch
*Device\foo() ;call functions
SetCppObj(0) ;set to zero to turn off the thiscall patching
endIf
Re: Interfacing a _stdcall 32bit dll (Asio driver)
Posted: Sun Aug 18, 2013 6:20 am
by eriansa
@idle
Thanks for your effort, but I am 100% sure it is a stdcall. Like I said it works without the C warpper on x64. The strange thing is, that on x86, a first call to a method works, but every second call (to the same or to another method) results in an invalid memory address. EAX is screwed...
Oh well, I'll just keep using the C wrapper dll...
@oreopa
I am planning to make a website "Making VST in PB" / "Making use of Asio in PB" / "Hosting VST's in PB".
Re: Interfacing a _stdcall 32bit dll (Asio driver)
Posted: Sun Aug 18, 2013 6:33 am
by idle
do you have a link to the libraries or their headers ?
Re: Interfacing a _stdcall 32bit dll (Asio driver)
Posted: Sun Aug 18, 2013 7:00 am
by eriansa
idle wrote:do you have a link to the libraries or their headers ?
I don't think I can post it publicly due to Steinberg's license agreement, but you can get the ASIO SDK from their website.
http://www.steinberg.net/en/company/developer.html
You can find a Delphi translation here :
http://www.axiworld.be/asio.html
You will notice that Delphi also required a C wrapper dll (openasio.dll) because of the stdcall convention.
I do exactly the same in PB x86 (use wrapper), in PB x64 there's no need for it.
But again, everything works!
I just want to find out why in x86 I need this wrapper...
I can only think that PB works exactly like Delphi in this matter. (x86 assuming cDecl).
If that's the case it would be great to have something like
Interface/EndInterface - InterfaceStd/EndInterfaceStd,
Re: Interfacing a _stdcall 32bit dll (Asio driver)
Posted: Mon Aug 19, 2013 2:01 am
by oreopa
eriansa wrote:@oreopa
I am planning to make a website "Making VST in PB" / "Making use of Asio in PB" / "Hosting VST's in PB".
eriansa: Thx for the reply, I'll be keeping a keen eye out for that - look forward to it. Cheers. Also good luck with the plugin, it looks interesting.
Re: Interfacing a _stdcall 32bit dll (Asio driver)
Posted: Tue Aug 20, 2013 6:45 am
by Thorium
eriansa wrote:
I just want to find out why in x86 I need this wrapper...
I can only think that PB works exactly like Delphi in this matter. (x86 assuming cDecl).
PB uses StdCall. You could try if it works if you call it with cDecl.
Take a look at PrototypeC.