Results 1 to 30 of 30

Thread: Technocrat > Winamp > pointer in 'ret'

  1. #1

    Thread Starter
    transcendental analytic kedaman's Avatar
    Join Date
    Mar 2000
    Location
    0x002F2EA8
    Posts
    7,221
    I'm having problems again, I need the filename for a playlist entry, nullsoft says:

    211 Retrieves (and returns a pointer in 'ret') a string that contains the filename of a playlist entry (indexed by 'data'). Returns NULL if error, or if 'data' is out of range.

    I use:
    Code:
        GetFilename = SendMessage(WinamphWnd, WM_USER, index, 211)
    And it returns a number(a "pointer"), not a string. How do I get the filename from here?

  2. #2
    Frenzied Member Technocrat's Avatar
    Join Date
    Jan 2000
    Location
    I live in the 1s and 0s of everyones data streams
    Posts
    1,024
    Hmm I have not got that far yet. I tried it and it seems to pass back a memory pointer alright but I dont know how to get what is in that memory location. I will look in to it unless someone else knows how to do it.

  3. #3
    Frenzied Member
    Join Date
    Mar 2000
    Posts
    1,089
    try This

    declare a new API function

    Code:
    Private Declare Function StringFromPointer Lib "Kernel32" Alias "RtlMoveMemory" (ByVal Dest as string, ByVal StringPointer as long, Byval StringLength as Long)
    it's a variant on copymemory, declare a fixed length string (I think 15 characters long should be enough) when you call the string from pointer function put your string in dest, the returned pointer in string pointer and the length you fixed the string at in stringlength

    I haven't tried this so It might not work, I suspect you'll have to use VB's strConv function and convert it to unicode and you might get a few random characters at the end.

    Hope this helps

  4. #4

    Thread Starter
    transcendental analytic kedaman's Avatar
    Join Date
    Mar 2000
    Location
    0x002F2EA8
    Posts
    7,221
    Thanks, I will give it a try...

  5. #5

    Thread Starter
    transcendental analytic kedaman's Avatar
    Join Date
    Mar 2000
    Location
    0x002F2EA8
    Posts
    7,221
    Ok, Sam Finch! Using the StringFromPointer i encountered this error:
    Error 49 Bad dll calling convention. That means that the declaration is wrong, or? I have all my arguments in their specific type and the declaration was copied from your post. So what's wrong?

    Code:
    Function GetFilename() As String
        Dim temp As String * 15, Length As Long, pointer As Long
        Length = Len(temp): temp = Space(15)
        pointer = SendMessage(WinamphWnd, WM_USER, 1, 211)
        StringFromPointer temp, pointer, Length
        GetFilename = temp
    End Function

  6. #6
    Frenzied Member
    Join Date
    Mar 2000
    Posts
    1,089
    Sorry my modem's knackered so I'm on a different machine with no VB so I can't test any code until my modem's fixed(Wednesday hopefully) try putting strPtr(temp) or varPtr(temp) instead of just temp when you call the function or leaving out the byval keyword before Dest as string when you declare the function. I did just make the function up on the spot and I did say it might not work first time.

  7. #7

    Thread Starter
    transcendental analytic kedaman's Avatar
    Join Date
    Mar 2000
    Location
    0x002F2EA8
    Posts
    7,221
    It didn't work! I tested with all combinations of removing the byval and setting the temp to strPtr(temp), varptr, It didn't work. WHY?! help me!

  8. #8
    Frenzied Member
    Join Date
    Mar 2000
    Posts
    1,089
    I'll have a proper go tonight, See if I can have an answer tomorow

  9. #9

    Thread Starter
    transcendental analytic kedaman's Avatar
    Join Date
    Mar 2000
    Location
    0x002F2EA8
    Posts
    7,221
    Anyone? Ideas?

  10. #10
    Frenzied Member Technocrat's Avatar
    Join Date
    Jan 2000
    Location
    I live in the 1s and 0s of everyones data streams
    Posts
    1,024
    Well I dont get that error when I do it. But I dont get anything back but random chars and chr(0)s so I dont think that works like it should.

    I have noticed though that when I change the index var, or the 1 in your example, to any number I always get the same pointer number back (4527196 in my program). I am unsure now as to what it is really returning. What about yours?

  11. #11

    Thread Starter
    transcendental analytic kedaman's Avatar
    Join Date
    Mar 2000
    Location
    0x002F2EA8
    Posts
    7,221
    4527196 4527196 4527196 4527196 4527196 4527196
    I'm sure that's correct, Winamp puts the string in the same place. But I just can't get the string from it. How did you get any resluts anyway? For me, it's just causing me this painful error.

  12. #12
    Frenzied Member Technocrat's Avatar
    Join Date
    Jan 2000
    Location
    I live in the 1s and 0s of everyones data streams
    Posts
    1,024
    What ver of Windows and VB are you running?
    Let me see your Declare Function StringFromPointer statement

    Here is mine:

    Public Declare Sub StringFromPointer Lib "Kernel32" alias "RtlMoveMemory" (ByVal Destination As String, ByVal Source As Long, ByVal Length As Long)

    Dim strTemp as String * 255
    Dim ret as Long

    Case "F" 'Test Remove Later
    ret = SendMessage(WinamphWnd, WM_USER, 3, 211)
    StringFromPointer strTemp, ret, 255
    strTemp = Trim$(strTemp)
    strTemp = StrConv(strTemp, vbUnicode)

    Like I said all I get is trash.

  13. #13

    Thread Starter
    transcendental analytic kedaman's Avatar
    Join Date
    Mar 2000
    Location
    0x002F2EA8
    Posts
    7,221
    OK, I shall try your version, I have VB5 and Win98 and my declaration look pretty much like yours:
    Code:
    Private Declare Function StringFromPointer Lib "kernel32" Alias "RtlMoveMemory" (Dest As String, ByVal StringPointer As Long, ByVal StringLength As Long)

  14. #14
    Frenzied Member Technocrat's Avatar
    Join Date
    Jan 2000
    Location
    I live in the 1s and 0s of everyones data streams
    Posts
    1,024
    You might try ByVal your first string in your declare.
    It might also have to do with VB5 I have VB6

    Private Declare Function StringFromPointer Lib "kernel32" Alias "RtlMoveMemory" (BYVAL Dest As String, ByVal StringPointer As Long, ByVal StringLength As Long)

  15. #15

    Thread Starter
    transcendental analytic kedaman's Avatar
    Join Date
    Mar 2000
    Location
    0x002F2EA8
    Posts
    7,221
    I've tried that already... But I removed it as Sam told me to,

  16. #16
    Frenzied Member Technocrat's Avatar
    Join Date
    Jan 2000
    Location
    I live in the 1s and 0s of everyones data streams
    Posts
    1,024
    I found your declare is a function and mine is a sub. When I change yours to a sub it works.


    Private Declare --Function-- StringFromPointer Lib "kernel32" Alias "RtlMoveMemory" (Dest As String, ByVal StringPointer As Long, ByVal StringLength As Long)

  17. #17

    Thread Starter
    transcendental analytic kedaman's Avatar
    Join Date
    Mar 2000
    Location
    0x002F2EA8
    Posts
    7,221
    Wow! I tried to change it to Sub and VB crashed! What now?!?!?!?

  18. #18

    Thread Starter
    transcendental analytic kedaman's Avatar
    Join Date
    Mar 2000
    Location
    0x002F2EA8
    Posts
    7,221
    I changed the string length to 15 and got Out of memory. And then I changed length to 1 and it succeed. Four times actually! Then I got this:

    Run-time error "-2147417848 (80010108)":

    Method "GetFilename" of object "_KedaWinamp" failed



  19. #19
    Frenzied Member Technocrat's Avatar
    Join Date
    Jan 2000
    Location
    I live in the 1s and 0s of everyones data streams
    Posts
    1,024
    Try a longer string like I did in mine. I made mine 255.

  20. #20
    Frenzied Member Technocrat's Avatar
    Join Date
    Jan 2000
    Location
    I live in the 1s and 0s of everyones data streams
    Posts
    1,024
    When I made mine 15 my program exploded also. Thats strange.

  21. #21

    Thread Starter
    transcendental analytic kedaman's Avatar
    Join Date
    Mar 2000
    Location
    0x002F2EA8
    Posts
    7,221
    That's odd! I mean I got it work, I've put the Byval back and it works great. A not so great thing is that it returns the **** you was talking about:

    ° ¶ˆƒE ÿ$SE ‹Mü…É„÷¯ ‹E ‹ …À„ô¯ PQÿP@ ƒøë4‹E f‹ f+Eüf= ë$‹E ‹ +Eüƒøë‹E ƒ8À÷؃}üÉ÷Ù+ÁƒøÀ÷Ø‹å] ‹E f‹ f+Eüf= ëæ‹Uü‹E ‹ …Àu.¸à
    F ƒ}ü „ˆ¯ …À„Н …Ò„Œ¯ PRèÌÖüÿƒÄƒø묋ÈÁéfùÿÿuËév¯ ‹E fÇEþ ‹ …À„j¯ MþQP‹ ÿPfƒ}þétÿÿÿnE “E

    Can you post your ****, so that we maybe can get something common out of it or something?

  22. #22
    Frenzied Member Technocrat's Avatar
    Join Date
    Jan 2000
    Location
    I live in the 1s and 0s of everyones data streams
    Posts
    1,024
    Sure I love posting ****

    " E
    Zpÿÿÿÿ0 EZtÿÿÿÿ@ E
    ZxÿÿÿÿÀEXÿÿ@Ð E Xÿÿ%Aˆ E:ÁDÿÿÿÿ¨ E2ÁDþÿÿÿÿÿÎ@à E$áˆûÿ"

    You got me what any of this means.

  23. #23

    Thread Starter
    transcendental analytic kedaman's Avatar
    Join Date
    Mar 2000
    Location
    0x002F2EA8
    Posts
    7,221
    Argh! I can't find anything common in this! You have too many of those boxes and I can't find out what ascii codes there are included.
    Use
    writing software in C++ is like driving rivets into steel beam with a toothpick.
    writing haskell makes your life easier:
    reverse (p (6*9)) where p x|x==0=""|True=chr (48+z): p y where (y,z)=divMod x 13
    To throw away OOP for low level languages is myopia, to keep OOP is hyperopia. To throw away OOP for a high level language is insight.

  24. #24

    Thread Starter
    transcendental analytic kedaman's Avatar
    Join Date
    Mar 2000
    Location
    0x002F2EA8
    Posts
    7,221
    Ok! Let's do it again! This time in hex!
    Code:
        For n = 1 To Len(Text)
            s = s & Hex(Asc(mid(Text,n,1))) & ","
        Next n
        debug.print s
    And it looks like this:

    6,B0,5,0,F,B6,88,83,15,45,0,FF,24,8D,53,15,45,0,8B,4D,FC,85,C9,F,84,F7,AF,5,0,8B,45,C,8B,0,85,C0,F,8 4,F4,AF,5,0,50,51,FF,15,50,13,40,0,83,F8,1,EB,34,8B,45,C,66,8B,0,66,2B,45,FC,66,3D,1,0,EB,24,8B,45,C ,8B,0,2B,45,FC,83,F8,1,EB,17,8B,45,C,83,38,1,1B,C0,F7,D8,83,7D,FC,1,1B,C9,F7,D9,2B,C1,83,F8,1,1B,C0, F7,D8,8B,E5,5D,C2,8,0,8B,45,C,66,8B,0,66,2B,45,FC,66,3D,1,0,EB,E6,8B,55,FC,8B,45,C,8B,0,85,C0,75,2E, B8,E0,D,46,0,

    [Edited by kedaman on 04-06-2000 at 01:01 PM]
    Use
    writing software in C++ is like driving rivets into steel beam with a toothpick.
    writing haskell makes your life easier:
    reverse (p (6*9)) where p x|x==0=""|True=chr (48+z): p y where (y,z)=divMod x 13
    To throw away OOP for low level languages is myopia, to keep OOP is hyperopia. To throw away OOP for a high level language is insight.

  25. #25
    Frenzied Member
    Join Date
    Mar 2000
    Posts
    1,089
    My modem's fixed now, sorry I've been offline for a couple of days and this thread got quite interesting

    sorry about the Function/Sub thing, just about every other API is a function so it threw me and I didn't have VB working at the time

    I had a play and remembered that I have no Idea what WinAmp is so I havn't tested it from there, If I make a byte array with the correct ascII codes in it and declare my function like this

    Code:
    Private Declare Sub StringFromPointer Lib "kernel32" Alias "RtlMoveMemory (ByVal Dest as String, ByVal Pointer as Long, ByVal Length as Long)
    then just put the pointer to the byte array into Pointer and the string into Dest, it works without the StrConv function. This could be why you're getting jibberish. It's a problem with windows moving to unicode wheras VB's already in unicode so strings havve to be converted and it's anyones guess what format the strings come in (or look at the C++ declaration, I'm guessing it's an LPWSTR or an LPSTR.

  26. #26
    Frenzied Member Technocrat's Avatar
    Join Date
    Jan 2000
    Location
    I live in the 1s and 0s of everyones data streams
    Posts
    1,024
    Here you go

    0,0,0,0,20,B,45,0,A,5A,0,12,70,1,0,FF,FF,0,0,0,0,0,0,0,0,0,0,0,FF,FF,0,0,0,0,0,0,30,B,45,0,8,5A,0,12 ,74,1,0,FF,FF,0,0,0,0,0,0,0,0,0,0,0,FF,FF,0,0,0,0,0,0,40,B,45,0,A,5A,0,12,78,1,0,FF,FF,0,0,0,0,0,0,0 ,0,0,0,0,FF,FF,0,0,0,0,0,0,C0,3,45,0,2,58,0,0,0,0,"

    We should try a common song and see if we get the same codes back. Let me know what MP3 you want to use for a test, I have too many to count so chances are I have it, or can find it.

    Sam:
    Winamp is an MP3 player (http://www.winamp.com). What we are try to do is get the name of a song in a certian position in the playlist.

    Code:
    Public Const WM_USER = &H400
    WinamphWnd = FindWindow("Winamp v1.x", 0) 'Get winamps hWnd
    
    ret = SendMessage(WinamphWnd, WM_USER, index, 211) 'Index is the playlist pos and 211 is the code to get that info
    StringFromPointer strTemp, ret, 255
    ret has been returning the number 4527196

    And as you can see, StringFromPointer gives crap back. Any help would be great.

  27. #27

    Thread Starter
    transcendental analytic kedaman's Avatar
    Join Date
    Mar 2000
    Location
    0x002F2EA8
    Posts
    7,221
    Sam, glad youre back but, I'm really confused about what you just suggested:
    Code:
        Dim BtA(0) As Byte 'Byte Array
        BtA(0) = CByte(pointer)
        StringFromPointer temp, BtA(0), Length
    I know, this is not what you meant, but I wrote it exactly as you told me to. Do I have to split up the pointer into numbers to insert in each byte or divide it with 256, 65536... and mod them with 256 or what did you mean with "put the pointer to the byte array into Pointer". And how do I set the byte array into the pointer wich is a Long then?

    Logged

    Technocrat: I'll try what Sam is trying to tell me, so our interesting method will wait...
    Use
    writing software in C++ is like driving rivets into steel beam with a toothpick.
    writing haskell makes your life easier:
    reverse (p (6*9)) where p x|x==0=""|True=chr (48+z): p y where (y,z)=divMod x 13
    To throw away OOP for low level languages is myopia, to keep OOP is hyperopia. To throw away OOP for a high level language is insight.

  28. #28
    old fart Frans C's Avatar
    Join Date
    Oct 1999
    Location
    the Netherlands
    Posts
    2,926
    I think I know what the problem is.
    Winamp returns a pointer to a string.
    The pointer is just a reference to a memory location.
    Each program runs in its own memory space, so in order to retrieve the string from that memory location, your program has to run in the same thread as winamp.
    I think this can only be accomplished if your program runs as a plug in from winamp.

  29. #29
    Frenzied Member
    Join Date
    Mar 2000
    Posts
    1,089
    I was just about to say that, honest. I think there's a way of getting at the string out but it may involve writing a C++ DLLfor use with the global hook, I'm not entirely sure.

    Does anyone know if you'll be able to wrte proper DLLs in VB7 by the way?

  30. #30

    Thread Starter
    transcendental analytic kedaman's Avatar
    Join Date
    Mar 2000
    Location
    0x002F2EA8
    Posts
    7,221
    OK, I'm not going to do any plugins, so I'm going to sit right here, an wait until anyone finds another way.
    Use
    writing software in C++ is like driving rivets into steel beam with a toothpick.
    writing haskell makes your life easier:
    reverse (p (6*9)) where p x|x==0=""|True=chr (48+z): p y where (y,z)=divMod x 13
    To throw away OOP for low level languages is myopia, to keep OOP is hyperopia. To throw away OOP for a high level language is insight.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width