CLEO Help Need help getting the raknet intercepted dialog info

CLEO related
Status
Not open for further replies.

ajom

Well-known member
Joined
Apr 14, 2020
Messages
389
Solutions
2
Reaction score
268
Location
Pluto
I am trying to intercept raknet bitstream that carries a dialog RPC. When my client accepted this RPC, it will project this dialog:
http://ugbase.eu/index.php?attachments/dialog-info-png.7312/

And my goal is to get the user id value "98670". That is why I made this code:
Code:
{$CLEO .cs}
{$INCLUDE SF}
0000: NOP

const
    CMDVAR1 = 31@
    CMDVAR2 = 30@
end

repeat
    wait 0
until 0AFA:  is_samp_available

0BE3: raknet setup_incoming_rpc_hook @in_rpc

0BDE: pause_thread 0

:in_rpc
    0BE5: raknet CMDVAR1 = get_hook_param PARAM_PACKETID
    if CMDVAR1 == RPC_SCRSHOWDIALOG
    then
        0BE5: raknet CMDVAR1 = get_hook_param PARAM_BITSTREAM
        0BE7: raknet 0@ = bit_stream_read CMDVAR1 type BS_TYPE_SHORT // Dialog ID
        0BE7: raknet 1@ = bit_stream_read CMDVAR1 type BS_TYPE_BYTE // Dialog Style
        if and
            0@ == 100
            1@ == 0
        then
            for 0@ = 1 to 3 // Title,Buton1,Button2
                0BE7: raknet CMDVAR2 = bit_stream_read CMDVAR1 type BS_TYPE_BYTE // Length
                CMDVAR2 *= 8 // convert bytes to bits
                0BEB: raknet bit_stream CMDVAR1 ignore_bits CMDVAR2
            end
            0BF0: raknet CMDVAR2 = bit_stream CMDVAR1 get_number_of_unread_bits // length of dialog info
            CMDVAR2 /= 8 // bits to bytes
            if CMDVAR2 > 0
            then
                CMDVAR2++
                alloc 2@ CMDVAR2
                CMDVAR2--
                0BE8: raknet bit_stream CMDVAR1 read_array 2@ size CMDVAR2  // copy the message with the specified length from the bitstream to buffer
                0C1E: array 2@ element CMDVAR2 el_size 1 = 0  // terminate the buffer with a null character
                0AF8: samp add_message_to_chat "info: %s" color 0xFF00FF00 2@
                free 2@
            end
        end
    end
0BE0: raknet hook_ret true


I can detect my target RPC dialog, but I can't get the contents of the dialog. As you can see on the image, the code generates a chat message "info:<dialog contents>" but it only shows this:
http://ugbase.eu/index.php?attachments/chatmessage-png.7313/

I am sure I did not make any mistake since I got the RPC data structure on this site:
Dialogs
  • ShowDialog - ID: 61
Parameters: UINT16 wDialogID, UINT8 bDialogStyle, UINT8 bTitleLength, char[] szTitle, UINT8 bButton1Len, char[] szButton1, UINT8 bButton2Len, char[] szButton2, CSTRING szInfo​


I will appreciate the help of the community.
 

Attachments

  • dialog info.png
    dialog info.png
    1,007.9 KB · Views: 65
  • chatmessage.png
    chatmessage.png
    9.4 KB · Views: 58
Last edited:

Parazitas

God
Joined
Jan 2, 2017
Messages
3,113
Solutions
5
Reaction score
878
Location
Lithuania
Getting dialog info with RPC
PHP:
{$CLEO .cs}
{$INCLUDE SF}

0000:

repeat
wait 0
until 0AFA:

0BE3: raknet setup_incoming_rpc_hook @in_rpc

while true
wait 0
end

/*
BS_TYPE_BYTE = 0 
BS_TYPE_BOOL = 1
BS_TYPE_SHORT = 2 
BS_TYPE_INT = 3
BS_TYPE_FLOAT = 4
BS_TYPE_ARRAY = 5
BS_TYPE_BITSTREAM = 6
*/

:in_rpc
0BE5: raknet 0@ = get_hook_param PARAM_PACKETID // Get RPC ID
if 0@ == RPC_SCRSHOWDIALOG
then
    // Get data
    0BE5: raknet 1@ = get_hook_param PARAM_BITSTREAM // Get BitStream
    0BE7: raknet 2@ = bit_stream_read 1@ type BS_TYPE_SHORT // WORD(DialogId)
    0BE7: raknet 3@ = bit_stream_read 1@ type BS_TYPE_BYTE // byte(DialogStyle)

    0BE7: raknet 4@ = bit_stream_read 1@ type BS_TYPE_BYTE // byte(TitleLength)
    0AB1: @allocate_memory 2 size 4@ reserve 1 ret_to 5@
    0BE8: raknet bit_stream 1@ read_array 5@ size 4@ // Title

    0BE7: raknet 4@ = bit_stream_read 1@ type BS_TYPE_BYTE // byte(Button1Length)
    0AB1: @allocate_memory 2 size 4@ reserve 1 ret_to 6@
    0BE8: raknet bit_stream 1@ read_array 6@ size 4@ // Button1
   
    0BE7: raknet 4@ = bit_stream_read 1@ type BS_TYPE_BYTE // byte(Button2Length)
    0AB1: @allocate_memory 2 size 4@ reserve 1 ret_to 7@
    0BE8: raknet bit_stream 1@ read_array 7@ size 4@ // Button2
   
    0AB1: @allocate_memory 2 size 4096 reserve 1 ret_to 8@ // Info
    0BF4: raknet bit_stream 1@ decode_string 8@ size 4096 // Dialog text is compressed (encoded), then you need to decode it
   
    // So: 5@ - dialog title, 6@, 7@ - first and second buttons, respectively, 8@ - dialog text
    0AF8: samp add_message_to_chat "Dialog #%d is open, type: %d. Title: '%s'. Buttons: '%s' / '%s'" color -1 2@ 3@ 5@ 6@ 7@
    0af8: "%s" -1 8@
   
    // Free the previously allocated memory (not used anymore, at this time)
    0AC9: free_allocated_memory 5@
    0AC9: free_allocated_memory 6@
    0AC9: free_allocated_memory 7@
    0AC9: free_allocated_memory 8@
end
0BE0: raknet hook_ret true

:allocate_memory
// 0AB1: @allocate_memory 2 size 0@ reserve 1@ ret_to 2@
005A: 0@ += 1@
0AC8: 2@ = allocate_memory_size 0@
0C11: memset destination 2@ value 0 size 0@
0AB2: ret 1 2@
 

ajom

Well-known member
Joined
Apr 14, 2020
Messages
389
Solutions
2
Reaction score
268
Location
Pluto
Getting dialog info with RPC
PHP:
{$CLEO .cs}
{$INCLUDE SF}

0000:

repeat
wait 0
until 0AFA:

0BE3: raknet setup_incoming_rpc_hook @in_rpc

while true
wait 0
end

/*
BS_TYPE_BYTE = 0
BS_TYPE_BOOL = 1
BS_TYPE_SHORT = 2
BS_TYPE_INT = 3
BS_TYPE_FLOAT = 4
BS_TYPE_ARRAY = 5
BS_TYPE_BITSTREAM = 6
*/

:in_rpc
0BE5: raknet 0@ = get_hook_param PARAM_PACKETID // Get RPC ID
if 0@ == RPC_SCRSHOWDIALOG
then
    // Get data
    0BE5: raknet 1@ = get_hook_param PARAM_BITSTREAM // Get BitStream
    0BE7: raknet 2@ = bit_stream_read 1@ type BS_TYPE_SHORT // WORD(DialogId)
    0BE7: raknet 3@ = bit_stream_read 1@ type BS_TYPE_BYTE // byte(DialogStyle)

    0BE7: raknet 4@ = bit_stream_read 1@ type BS_TYPE_BYTE // byte(TitleLength)
    0AB1: @allocate_memory 2 size 4@ reserve 1 ret_to 5@
    0BE8: raknet bit_stream 1@ read_array 5@ size 4@ // Title

    0BE7: raknet 4@ = bit_stream_read 1@ type BS_TYPE_BYTE // byte(Button1Length)
    0AB1: @allocate_memory 2 size 4@ reserve 1 ret_to 6@
    0BE8: raknet bit_stream 1@ read_array 6@ size 4@ // Button1
  
    0BE7: raknet 4@ = bit_stream_read 1@ type BS_TYPE_BYTE // byte(Button2Length)
    0AB1: @allocate_memory 2 size 4@ reserve 1 ret_to 7@
    0BE8: raknet bit_stream 1@ read_array 7@ size 4@ // Button2
  
    0AB1: @allocate_memory 2 size 4096 reserve 1 ret_to 8@ // Info
    0BF4: raknet bit_stream 1@ decode_string 8@ size 4096 // Dialog text is compressed (encoded), then you need to decode it
  
    // So: 5@ - dialog title, 6@, 7@ - first and second buttons, respectively, 8@ - dialog text
    0AF8: samp add_message_to_chat "Dialog #%d is open, type: %d. Title: '%s'. Buttons: '%s' / '%s'" color -1 2@ 3@ 5@ 6@ 7@
    0af8: "%s" -1 8@
  
    // Free the previously allocated memory (not used anymore, at this time)
    0AC9: free_allocated_memory 5@
    0AC9: free_allocated_memory 6@
    0AC9: free_allocated_memory 7@
    0AC9: free_allocated_memory 8@
end
0BE0: raknet hook_ret true

:allocate_memory
// 0AB1: @allocate_memory 2 size 0@ reserve 1@ ret_to 2@
005A: 0@ += 1@
0AC8: 2@ = allocate_memory_size 0@
0C11: memset destination 2@ value 0 size 0@
0AB2: ret 1 2@
Thank you.
 

ajom

Well-known member
Joined
Apr 14, 2020
Messages
389
Solutions
2
Reaction score
268
Location
Pluto
Btw, why you use rpc instead simple memories?

RPC Interception is more real-time than reading the dialog in memory using the infinite loop.

Also, Since raknet hook interrupts the main thread, this give me advantage to:
  1. get all incoming/outcoming dialog and process them one by one(since it is a hook, all incoming/outcoming RPC will be queued and proceed only Everytime the hook finishes it's job).
  2. At the infinite loop. When the change in dialog because of multiple popups is so fast, there may be a chance that I will fail reading the dialog that is overwritten by a new dialog in memory.

I mostly do all the job relating to raknet using The Raknet Hook because I have a crappy laptop with slow processing power and slow fps, reading memory sometimes fails to get my target dialog at the right time.
 
Status
Not open for further replies.
Top