Jump to content

Reading char array pointer


Recommended Posts

Ive been trying to retrieve a pointer to a char array through dllcall, but i cant seem to get the return data, Any Suggestions?

What im trying to do is retrieve the title of the current song playing in winamp, without reading the window title.

dim $WM_USER=0x0400
dim $IPC_GETLISTLENGTH=124
dim $IPC_GETLISTPOS=125
dim $IPC_GETPLAYLISTTITLE=212

dim $hwnd
$hwnd=WinGetHandle("classname=Winamp v1.x")
dim $pointer

$pointer =DllCall("User32.dll","ptr","SendMessage","int",$hwnd,"int",$WM_USER,"int",$ListPos,"int",$IPC_GETLISTPOS)

i was able to make a working version in c++ but im stumped... when i searched the forums someone suggested using str or wstr as returntype, but that crashes autoit

Thanks in advance

Edited by death pax
Link to comment
Share on other sites

Shit, sorry left out something...

dim $WM_USER=0x0400
dim $IPC_GETLISTLENGTH=124
dim $IPC_GETLISTPOS=125
dim $IPC_GETPLAYLISTTITLE=212
$chararray = DLLStructCreate("char[256]")
dim $hwnd
opt("WinTitleMatchMode", 4)
$hwnd=WinGetHandle("classname=Winamp v1.x")
dim $pointer
dim $listPos
$listPos=DllCall("User32.dll","int","SendMessage","int",$hwnd,"int",$WM_USER,"int",0,"int",$IPC_GETLISTPOS)
$pointer=DLLStructGetPtr($chararray)
$pointer=DllCall("User32.dll","ptr","SendMessage","int",$hwnd,"int",$WM_USER,"int",$listpos[0],"int",$IPC_GETPLAYLISTTITLE)
MsgBox(4096,"",DllStructGetData($chararray,1))

totally my bad... still doesnt work though o.O

sorry for misleading you :o

Link to comment
Share on other sites

Perhaps it would be helpful for me to show you my C++ code to do the same thing :o

#include <cstdlib>
#include <cstdio>
#include <iostream>
#include <windows.h>

using namespace std;

int main(int argc, char *argv[])
{
    DWORD m_dwProcessID, Window;
    HWND m_hWindow = FindWindow ("Winamp v1.x", NULL);
    GetWindowThreadProcessId(m_hWindow, &m_dwProcessID);
    HANDLE m_hProcess = OpenProcess(PROCESS_VM_READ, FALSE, m_dwProcessID);
    char szTrack[765] = { '\0' };
    int iTrackPos = SendMessage(m_hWindow, 1024, 0, 125);
    DWORD m_dwBytes;
    char *pszName = (char *)SendMessage(m_hWindow, 1024, iTrackPos, 212);
ReadProcessMemory(m_hProcess, pszName, szTrack, 765, &m_dwBytes);

if (m_dwBytes < 765)
    szTrack[m_dwBytes] = '\0'; // no escape sequences
    cout << "Currently Playing: " <<szTrack <<"\n";  
    system("PAUSE");
    return EXIT_SUCCESS;
}
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...