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 A week ago Edited by MKKJ, 6 days ago.

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 A week ago Edited by Veryzon, A week ago.

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 A week ago Edited by MKKJ, A week ago.

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 A week ago Edited by Veryzon, A week ago.

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 A week ago Edited by MKKJ, A week ago.

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 A week ago Edited by Veryzon, A week ago.

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 A week ago Edited by MKKJ, A week ago.

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: 10@ = load_library "bass.dll" // IF and SET
then
    if and
    0AA4: 11@ = get_proc_address "BASS_ChannelGetLength" library 10@ // IF and SET
    0AA4: 12@ = get_proc_address "BASS_ChannelPlay" library 10@ // IF and SET
    0AA4: 13@ = get_proc_address "BASS_ChannelPause" library 10@ // IF and SET
    0AA4: 14@ = get_proc_address "BASS_ChannelGetPosition" library 10@ // IF and SET
    0AA4: 15@ = get_proc_address "BASS_ChannelBytes2Seconds" library 10@ // IF and SET
    0AA4: 19@ = get_proc_address "BASS_ErrorGetCode" library 10@ // IF and SET
    then
        0A8E: 28@ = 0@ + 0x4 // int
        0A8D: 27@ = read_memory 28@ size 4 virtual_protect 0
        //0AA7: call_function 11@ num_params 2 pop 0 0 27@ 20@
        //0AA5: call 12@ num_params 2 pop 0 1 27@
        //0AA5: call 13@ num_params 1 pop 0 27@
        0AA7: call_function 14@ num_params 2 pop 0 0 27@ 20@
        0AA7: call_function 15@ num_params 2 pop 0 20@ 27@ 22@      //  crash
        0ACE: show_formatted_text_box "Proc Loaded~n~%d~n~%d~n~%d" 20@ 21@ 22@
        0AA7: call_function 19@ num_params 0 pop 0 28@
        0AD1: show_formatted_text_highpriority "Proc BASS_ErrorCode...~n~%d~n~0x%X~n~0x%X" time 6000 28@ 27@ 0@
    end
end

Veryzon
  • Veryzon

    Player Hater

  • Members
  • Joined: 15 Jun 2017
  • Brazil

#8

Posted A week ago Edited by Veryzon, A week ago.

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 A week ago Edited by MKKJ, A week ago.

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 6 days ago

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

    Crackhead

  • Members
  • Joined: 01 Jan 2014
  • Russia

#11

Posted 6 days ago Edited by madleg, 6 days ago.

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: 1@ = float, ... 4@ = float, 5@ = bool and pass var 1@ 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 6 days ago Edited by MKKJ, 6 days ago.

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: 12@ = get_proc_address "BASS_ChannelGetPosition" library 10@ // IF and SET
0AA4: 13@ = get_proc_address "BASS_ChannelBytes2Seconds" library 10@ // IF and SET        
0AC6: 24@ = label @Test offset
0AA7: call_function 12@ num_params 2 pop 0 0 hBASS 25@        
0AA7: call_function 24@ num_params 4 pop 4 qword 25@ 26@ handle hBASS bass_func 13@ result 23@

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

    Crackhead

  • Members
  • Joined: 01 Jan 2014
  • Russia

#13

Posted 5 days ago Edited by madleg, 5 days ago.

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


MKKJ
  • MKKJ

    Honest Steaks

  • Members
  • Joined: 04 Jun 2015
  • Indonesia

#14

Posted 5 days ago Edited by MKKJ, 5 days ago.

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 24@ num_params 4 pop 4 qword 25@ 26@ handle hBASS bass_func 13@ result 23@




1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users