I'm having trouble getting a string out of eax. I made a call with SendMessage that returns a string value in eax, but I can't seem to get the actual string out of it, I just get a bunch of weird characters. Any help would be much appreciated.
Posted on 2001-07-28 17:24:40 by mc`
String in EAX?
I don't mean to be nasty , but remember that EAX's size is 4 bytes thus chances are that EAX holds, after the call to SendMessage, a pointer a string.
If what you got is a pointer which points to garbage, then at least tell us which message you sent to which window.
Bye :)

Posted on 2001-07-28 17:38:32 by latigo
Sorry, I'll try to be a little more clear.

I am writing a program to interface with winamp. To retrieve the file name of the currently playing song, I do..

invoke SendMessage,wahWnd,WM_USER,15,211

this should return a pointer to a string in eax, I am however having trouble getting the actual string. Instead of the file name I should be getting, I get things like 8zE and i??wF

Hope that clarifies things a bit.
Posted on 2001-07-28 17:44:16 by mc`
Coincidentally enough i've been playing with winamp sometime ago too.
Is the code too big?
I'm in a rush right now, but if you post it i'll be able to take a look at it later.

Posted on 2001-07-28 17:49:11 by latigo
It's actually to be a dll to be used with a script for mIRC, but the code should still be fairly easy to follow..

GetWAFile proc mWnd:DWORD,aWnd:DWORD,data:DWORD,parms:DWORD,show:DWORD,nopause:DWORD
local wahWnd:DWORD
local tTrack:DWORD
local tFile:DWORD
invoke FindWindow,addr waClass,0
mov wahWnd,eax
invoke SendMessage,wahWnd,WM_USER,0,PL_POS
mov tTrack,eax
invoke SendMessage,wahWnd,WM_USER,tTrack,GET_FILE_NAME
;---need string from eax's pointer to go into tFile here---
invoke lstrcpy,data,addr tFile
mov eax,3
GetWAFile endp
Posted on 2001-07-28 17:52:59 by mc`
I'm turning my pc off right now..and i'll look at it after..but one thing before i sign off..
Shouldn't it be:

invoke lstrcpy,OFFSET data,addr tFile

instead of:

invoke lstrcpy,data,addr tFile



Posted on 2001-07-28 17:59:16 by latigo
or even better:

invoke lstrcpy,OFFSET data,EAX


Posted on 2001-07-28 18:00:41 by latigo
Correct me if I'm wrong, but:
Are you using the right section selector? Is the string stored in WinAmps data section, or your own?
Posted on 2001-07-28 18:02:18 by eet_1024
theoretically, it should be in mine
Posted on 2001-07-28 18:06:13 by mc`
Theoretically, pigs can fly. ;) But I have no experience with getting strings from other apps.
Posted on 2001-07-28 18:46:02 by eet_1024
If I have got what the original problem is, there is a string ADDRESS being returned in EAX from a DLL function call.

Solution is to read it up to the terminator if its a zero terminated string and copy it into a buffer.

In pseudo code, something like this,

LOCAL buffer[64]:BYTE ; somwhere to write return string address to.

String address returned in EAX.
push eax ; save it on stack
invoke strlen,eax
mov ecx, eax ; put length in ECX
pop esi ; restore address into esi
lea edi, buffer
rep movsb

result should be a copy of the string in the buffer provided.


Posted on 2001-07-28 20:02:03 by hutch--
hmm.. still not working, maybe it is trying to get it from winamp's data instead of my own.. anyone have any ideas?
Posted on 2001-07-28 20:34:54 by mc`

you may need some more data about what is being returned from the SendMessage call before you can get a usable value.


Posted on 2001-07-28 23:56:40 by hutch--
Basically, all I'm trying to do is get the file name of the song that's playing in winamp (note: file name, not title). If anyone has a good idea as to how I can do this, please let me know, I've tried everything short of writing the playlist to the disk and reading through it line by line in search of the song that's playing. Maybe I missed something though, any help would be greatly appreciated.
Posted on 2001-07-29 02:46:18 by mc`