The MASM Forum

General => The Campus => Topic started by: ragdog on December 03, 2017, 03:34:32 AM

Title: Bass.dll problem
Post by: ragdog on December 03, 2017, 03:34:32 AM
Hello

I playing with the Bass.dll from un4seen.com all works fine if i run my code in a (exe project)
If i run my code in a (Dll project) it does not works.

I have debug my code LoadLibrary and GetProcadress all works fine it have a poblem with BASS_Init procedur
And can not debug this Proc.

Has any same problem?



.data?
hBassDll dd ?
pBASS_Init dd ?
pBASS_StreamCreateFile dd ?
pBASS_ChannelPlay dd ?

invoke LoadLibrary, chr$("bass24100.dll")
.if (eax)
mov hBassDll,eax
invoke GetProcAddress,hBassDll,chr$("BASS_Init")
.if (eax)
mov pBASS_Init,eax
push 0
push hWnd
push 0
push 44100
push -1
call dword ptr [pBASS_Init] ;<<<<<<<<<<<<<
.if (eax)
invoke GetProcAddress,hBassDll,chr$("BASS_StreamCreateFile")
.if (eax)
mov pBASS_StreamCreateFile,eax
push 0
push dword ptr [qwSize+4]
push dword ptr [qwSize]
push dword ptr [qwSize+4]
push dword ptr [qwSize]
push chr$ ("music.mp3")
push FALSE
call dword ptr [pBASS_StreamCreateFile]
.if (eax)
mov ebx,eax
invoke GetProcAddress,hBassDll,chr$("BASS_ChannelPlay")
.if (eax)
mov pBASS_ChannelPlay,eax

push 0
push ebx
call dword ptr [pBASS_ChannelPlay]
.endif
.endif
.endif
.endif
.endif
.endif
Title: Re: Bass.dll problem
Post by: felipe on December 03, 2017, 05:56:04 AM
 :idea:

Maybe you need to put more information here for get help. I mean you can't debug the proc, but where is the source code of the proc?


If not available maybe you need to get information from that proc (assuming is a proc from the Bass.dll) with some tool.

Title: Re: Bass.dll problem
Post by: fearless on December 03, 2017, 06:05:54 AM
Is the resource (music file) stored in the compiled dll? if so then you probably need to use findresource, lockresource etc to use it when loading it from the dll itself, otherwise resources loaded will use the hInstance of the main program that uses the dll, and look for the resource in the main program and not in the dll resources. I think.
Title: Re: Bass.dll problem
Post by: ragdog on December 03, 2017, 06:38:56 AM
Hi thanks for trying to help

QuoteMaybe you need to put more information here for get help. I mean you can't debug the proc, but where is the source code of the proc?


If not available maybe you need to get information from that proc (assuming is a proc from the Bass.dll) with some tool.

This is my source code of the proc i cannot debug this bass dll correctly in hangs in bass_init by directsound and my debugger works any more.


@fear
i use not a resource file i load from a path.
The music file load ok but before i load the music must i initialize the bass with BASS_Init
If i have a  exe project works all fine but not by a dll project.
Title: Re: Bass.dll problem
Post by: aw27 on December 03, 2017, 07:34:24 AM
I don't see any procedure. I see sparse code.
If that sparse code is called in the entry point it is guaranteed to freeze.
Title: Re: Bass.dll problem
Post by: ragdog on December 03, 2017, 07:46:52 AM
The code works fine i have make test in a exe aplication
and it give not any procdur or should I now make a procdedur like xyz

xyz proc
Bass int code
and play mp3
xyz endp

I said allready in my exe project and test works fine but not in a dll project Bass_init is fail.
Title: Re: Bass.dll problem
Post by: nidud on December 03, 2017, 08:09:33 AM
deleted
Title: Re: Bass.dll problem
Post by: ragdog on December 03, 2017, 08:16:27 AM
Yes works fine in WinMain proc oder DlgMain Proc called by DialogBoxParam
But my dll call this in a DllEntry

The sdk help from Bass say

QuoteBOOL BASS_Init(
    int device,
    DWORD freq,
    DWORD flags,
    HWND win,
    GUID *clsid

win The application's main window... 0 = the desktop window (use this for console applications). 
);

i have change in Bass_Init remove hWnd to NULL for desktop
push 0
push    0;hWnd  <<
push 0
push 44100
push -1
call dword ptr [pBASS_Init] ;<<<<<<<<<<<<<


but is same fail

ps: nidud
is this a hjwasm code?
Title: Re: Bass.dll problem
Post by: nidud on December 03, 2017, 08:44:29 AM
deleted
Title: Re: Bass.dll problem
Post by: aw27 on December 03, 2017, 11:55:04 AM
Quote from: ragdog on December 03, 2017, 07:46:52 AM
The code works fine i have make test in a exe aplication
and it give not any procdur or should I now make a procdedur like xyz

xyz proc
Bass int code
and play mp3
xyz endp

I said allready in my exe project and test works fine but not in a dll project Bass_init is fail.

You did not get the point of my comment.
I said that if you call that in the entry point it will freeze. So, you are calling that in the entry point of the DLL and believe it is absolutely normal and should work.  :badgrin:
It will never work.
Title: Re: Bass.dll problem
Post by: ragdog on December 03, 2017, 06:47:30 PM
QuoteYou did not get the point of my comment.
I said that if you call that in the entry point it will freeze. So, you are calling that in the entry point of the DLL and believe it is absolutely normal and should work.  :badgrin:
It will never work.

Why?

The dll is loaded when the Main.exe window is created (WM_INITDIALOG)

Or give a better soulution?
Title: Re: Bass.dll problem
Post by: aw27 on December 03, 2017, 07:03:17 PM
Quote from: ragdog on December 03, 2017, 06:47:30 PM
Or give a better soulution?

You were expected to know it  :dazzled:
Quoting Microsoft:
"The entry-point function should perform only simple initialization or termination tasks. It must not call the LoadLibrary or LoadLibraryEx function (or a function that calls these functions), because this may create dependency loops in the DLL load order. This can result in a DLL being used before the system has executed its initialization code."




Title: Re: Bass.dll problem
Post by: ragdog on December 03, 2017, 07:40:43 PM
I forgot

But i use now a Procedur for this code and call it with GetProcAdress

example:

invoke LoadLibrary, chr$("Player.dll")
invoke GetProcAddress,eax,chr$("Player_Init")
call  eax

Player_Init proc

invoke LoadLibrary, chr$("bass24100.dll")
.if (eax)
mov hBassDll,eax
invoke GetProcAddress,hBassDll,chr$("BASS_Init")
.if (eax)
mov pBASS_Init,eax
push 0
pushNULL
push 0
push 44100
push -1
call dword ptr [pBASS_Init] ;<<<<<<<<<<<<<
                    .endif
           .endif
Player_Init endp


is the same problem with Bass_init
Title: Re: Bass.dll problem
Post by: aw27 on December 03, 2017, 07:55:24 PM
OK, what I have seen so far is that you forget the basics so bugs can happen anywhere. Since we are too lazy to do it, may be someone would bother to reconstructed a demo from your sparse snippets, and check it.
Title: Re: Bass.dll problem
Post by: nidud on December 03, 2017, 10:12:17 PM
deleted
Title: Re: Bass.dll problem
Post by: ragdog on December 04, 2017, 01:52:04 AM
I found the problem

aw27 say it works not in dllmain entry point is correct
and the programm how use the plugin interface call the export procedur to late.

thank you ,

Title: Re: Bass.dll problem
Post by: LordAdef on December 12, 2017, 04:00:46 PM
hey,

let me take the opportunity and ask:
how do you guys like the Bass library? not many of those with asm bindings around..
Title: Re: Bass.dll problem
Post by: ragdog on December 13, 2017, 05:25:04 AM
I like it good sound and many function :t
Title: Re: Bass.dll problem
Post by: LordAdef on December 13, 2017, 11:26:23 AM
thanks Ragdog!
I'll check it out.
Marinus was onto something very promising, I hope he gets it forwards.