Quantcast

Jump to content

» «
Photo

Call bass.dll function from cleo

13 replies to this topic
MKKJ
  • MKKJ

    Honest Steaks

  • Members
  • Joined: 04 Jun 2015
  • Indonesia

#1

Posted 13 August 2017 - 11:10 AM Edited by MKKJ, 15 August 2017 - 08:26 AM.

I'm trying to use functions from bass.dll that returns a value.
However the proc always return -1 and with error code 5, which means the handle is invalid.
 
So does handle i got from CLEO is different from handle used in bass.dll?
Or is there's anything else i miss?

Spoiler



EDIT: It's solved. But i have more question to ask.

Now i'm not actually a knowledgeable coder, so i have lot of things i don't understand when it comes to actual coding outside of scm.

One of functions, BASS_Bytes2Seconds requires a qword and returns a double.

Spoiler


I'm also trying to use BASS_FXSetParameters.
Spoiler

Veryzon
  • Veryzon

    Player Hater

  • Members
  • Joined: 15 Jun 2017
  • Brazil

#2

Posted 13 August 2017 - 11:34 AM Edited by Veryzon, 13 August 2017 - 11:39 AM.

Yes. The CLEO sound system is a interface to BASS. The handle returned by opcodes 0x0AAC and 0x0AC1 can not be directly used by BASS API because it's a address pointing to a CAudioStream or C3dAudioStream object (concept of CLEO).


MKKJ
  • MKKJ

    Honest Steaks

  • Members
  • Joined: 04 Jun 2015
  • Indonesia

#3

Posted 13 August 2017 - 11:38 AM Edited by MKKJ, 13 August 2017 - 11:39 AM.

Is there a way to retrieve the bass.dll handle?

I've been trying to figure out what is stored in CLEO handle, but only got some address at +0x0 and audio state (play/stop) at +0x8


Veryzon
  • Veryzon

    Player Hater

  • Members
  • Joined: 15 Jun 2017
  • Brazil

#4

Posted 13 August 2017 - 11:51 AM Edited by Veryzon, 13 August 2017 - 12:06 PM.

The CAudioStream class is composed of...

+0x00 hBassStream ; This is a HSTREAM type. It's provided by BASS API.

+0x04 uState

+0x08 bOk

 

I am not sure if a BASS function works fine when a CAudioStream->hBassStream is pushed to itself as parameter. Perhaps, you can load a stream by call BASS_StreamCreateFile function.


MKKJ
  • MKKJ

    Honest Steaks

  • Members
  • Joined: 04 Jun 2015
  • Indonesia

#5

Posted 13 August 2017 - 03:13 PM Edited by MKKJ, 13 August 2017 - 05:23 PM.

Apparently pushing CAudioStream->hBassStream as parameter doesn't work, or any other values around.

Also AudioStream play/pause state is in +0x8 (unless that is what you meant), i don't know what value is in +0x4 but it seems important as it's always pushed before cleo call bass functions.

 

Considering my lack of knowledge around audiostream and bass.dll, I'll take my time to either figure to the handle from cleo's stream or streaming audio from BASS_StreamCreateFile (although its kinda redundant to do it in cleo).

 

 

EDIT:

CAudioStream + 0x4 does contain actual handle. Another thing i missed is that i supposed to reverse order of params to pass at 0AA7.

I can use command process (Play, Pause) with 0AA5, but not returned functions (0AA7). It always returns error code 37 (Requested data is not available)


Veryzon
  • Veryzon

    Player Hater

  • Members
  • Joined: 15 Jun 2017
  • Brazil

#6

Posted 13 August 2017 - 05:26 PM Edited by Veryzon, 15 August 2017 - 02:00 AM.

Perhaps have another value at 0x00 offset, so 0x04 potentially would be a HSTREAM. I have seen the CAudioStream class from CLEO 4(1/2) SDK, it had only hBassStream, uState e bOk; the remaining items are functions. I will try to find the CLEO SDK. It's hard to find anything in my HDD.

 

I had tried to use symbols of BASS, but the game crashed several times. Then i have preferred to use Miles Sound System.


MKKJ
  • MKKJ

    Honest Steaks

  • Members
  • Joined: 04 Jun 2015
  • Indonesia

#7

Posted 13 August 2017 - 05:46 PM Edited by MKKJ, 13 August 2017 - 05:48 PM.

Thanks, but i've gotten around it just now.

The only problem might be some function just crashes the game for some reason. Like BASS_Bytes2Seconds. Maybe because one of required param is a qword.

if
0AA2: [email protected] = load_library "bass.dll" // IF and SET
then
    if and
    0AA4: [email protected] = get_proc_address "BASS_ChannelGetLength" library [email protected] // IF and SET
    0AA4: [email protected] = get_proc_address "BASS_ChannelPlay" library [email protected] // IF and SET
    0AA4: [email protected] = get_proc_address "BASS_ChannelPause" library [email protected] // IF and SET
    0AA4: [email protected] = get_proc_address "BASS_ChannelGetPosition" library [email protected] // IF and SET
    0AA4: [email protected] = get_proc_address "BASS_ChannelBytes2Seconds" library [email protected] // IF and SET
    0AA4: [email protected] = get_proc_address "BASS_ErrorGetCode" library [email protected] // IF and SET
    then
        0A8E: [email protected] = [email protected] + 0x4 // int
        0A8D: [email protected] = read_memory [email protected] size 4 virtual_protect 0
        //0AA7: call_function [email protected] num_params 2 pop 0 0 [email protected] [email protected]
        //0AA5: call [email protected] num_params 2 pop 0 1 [email protected]
        //0AA5: call [email protected] num_params 1 pop 0 [email protected]
        0AA7: call_function [email protected] num_params 2 pop 0 0 [email protected] [email protected]
        0AA7: call_function [email protected] num_params 2 pop 0 [email protected] [email protected] [email protected]      //  crash
        0ACE: show_formatted_text_box "Proc Loaded~n~%d~n~%d~n~%d" [email protected] [email protected] [email protected]
        0AA7: call_function [email protected] num_params 0 pop 0 [email protected]
        0AD1: show_formatted_text_highpriority "Proc BASS_ErrorCode...~n~%d~n~0x%X~n~0x%X" time 6000 [email protected] [email protected] [email protected]
    end
end

Veryzon
  • Veryzon

    Player Hater

  • Members
  • Joined: 15 Jun 2017
  • Brazil

#8

Posted 13 August 2017 - 06:45 PM Edited by Veryzon, 13 August 2017 - 11:40 PM.

I had forgotten of this. It also has been one of reasons to do me try another solution. The file position is treated as QWORD and the fractional time as double.

double BASSDEF(BASS_ChannelBytes2Seconds)(DWORD handle, QWORD pos);

MKKJ
  • MKKJ

    Honest Steaks

  • Members
  • Joined: 04 Jun 2015
  • Indonesia

#9

Posted 14 August 2017 - 10:29 AM Edited by MKKJ, 14 August 2017 - 10:29 AM.

So yeah, apparently CAudioStream struct that was posted earlier is correct, except it's should moved forward by 4 bytes

+0x0 ??? ; Idk what this is.

+0x4 hBassStream ; the actual handle as stated.

+0x8 uState ; the audio state (1 = playing | 2 = stop/pause)

+0x8 bOk ; idk what this is too.

 

I'm trying to manipulate Audiostream's time position with BASS functions.

I managed to get/set the byte position but can't convert it to time position unless by workaround. (BASS_Bytes2Seconds can't return double value. I just don't know how to solve it)

 

Still, i got what i wanted so i marked this as answered.


MKKJ
  • MKKJ

    Honest Steaks

  • Members
  • Joined: 04 Jun 2015
  • Indonesia

#10

Posted 15 August 2017 - 08:24 AM

I decided to continue this post for my new question, since it's still relevant.

 

 

Now i'm not actually a knowledgeable coder, so i have lot of things i don't understand when it comes to actual coding outside of scm.

One of functions, BASS_Bytes2Seconds requires a qword and returns a double.

Spoiler


I'm also trying to use BASS_FXSetParameters.
Spoiler


madleg
  • madleg

    Square Civilian

  • Members
  • Joined: 01 Jan 2014
  • Russia

#11

Posted 15 August 2017 - 01:26 PM Edited by madleg, 15 August 2017 - 01:29 PM.

well, idk if function calling opcodes support returning floating point values, but you can write some sort of wrapper which will return double like int (float in eax). Not sure about using doubles in cleo, so theres also to float conversion.

int __declspec(dllexport, noinline)wrapper(double(__cdecl *func)(unsigned int, unsigned __int64), unsigned int a0, unsigned __int64 a1)
{
	float a = func(a0, a1);
	return reinterpret_cast<int&>(a);
}

compiled result
55                    // push ebp
8B EC                 // mov ebp,esp
83 E4 F8              // and esp,-08
83 EC 08              // sub esp,08
FF 75 14              // push [ebp+14]
FF 75 10              // push [ebp+10]
FF 75 0C              // push [ebp+0C]
FF 55 08              // call dword ptr [ebp+08]
D9 5C 24 10           // fstp dword ptr [esp+10]
8B 44 24 10           // mov eax,[esp+10]
83 C4 0C              // add esp,0C
8B E5                 // mov esp,ebp
5D                    // pop ebp
C3                    // ret 

insert these bytes in your script under some label and call it something like this

0AA7: call_function <get label address> num_params 4 pop 4 int int (qword), int, <get bass function address>, result to @

 
typedef struct {
    float fWetDryMix;
    float fFeedback;
    float fLeftDelay;
    float fRightDelay;
    BOOL lPanDelay;
} BASS_DX8_ECHO;
 
if theres no export function in this library to construct this structure, then just set it by yourself. This is just an array of 4 floats and 1 bool, so... Idk about how function, which recieves this structure, is handling it (maybe stores pointer, maybe just copies params), so you can try something like: [email protected] = float, ... [email protected] = float, [email protected] = bool and pass var [email protected] addres in function, or just allocate memory and fill it in same way.
  • MKKJ likes this

MKKJ
  • MKKJ

    Honest Steaks

  • Members
  • Joined: 04 Jun 2015
  • Indonesia

#12

Posted 15 August 2017 - 03:51 PM Edited by MKKJ, 15 August 2017 - 04:00 PM.

Thanks for your help. The pointer to array of params perfectly solves it.

 

But the function you posted just crashes the game. Maybe i just did it wrong.

0AA4: [email protected] = get_proc_address "BASS_ChannelGetPosition" library [email protected] // IF and SET
0AA4: [email protected] = get_proc_address "BASS_ChannelBytes2Seconds" library [email protected] // IF and SET        
0AC6: [email protected] = label @Test offset
0AA7: call_function [email protected] num_params 2 pop 0 0 hBASS [email protected]        
0AA7: call_function [email protected] num_params 4 pop 4 qword [email protected] [email protected] handle hBASS bass_func [email protected] result [email protected]

On a less relevant note, what did exactly Bass boost and Bike's EQ do to the radio output?

I just assume Bike crappy radio just raises pitch while i Bass boost outputs sound in stereo (which was normally in mono).


madleg
  • madleg

    Square Civilian

  • Members
  • Joined: 01 Jan 2014
  • Russia

#13

Posted 16 August 2017 - 09:34 AM Edited by madleg, 16 August 2017 - 09:34 AM.

it was actually only for bass_channelbytes2seconds. is it working with it?


MKKJ
  • MKKJ

    Honest Steaks

  • Members
  • Joined: 04 Jun 2015
  • Indonesia

#14

Posted 16 August 2017 - 09:41 AM Edited by MKKJ, 16 August 2017 - 09:43 AM.

Yes it crashes with BASS_ChannelBytes2Seconds.

 

Did i insert the value correctly?

Where does result variable belong, input param or output param?

0AA7: call_function [email protected] num_params 4 pop 4 qword [email protected] [email protected] handle hBASS bass_func [email protected] result [email protected]




1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users