death pax Posted March 4, 2006 Posted March 4, 2006 (edited) 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 March 4, 2006 by death pax
death pax Posted March 6, 2006 Author Posted March 6, 2006 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
death pax Posted March 6, 2006 Author Posted March 6, 2006 whenever i try to return a str with that func it crashes autoit
death pax Posted March 6, 2006 Author Posted March 6, 2006 Perhaps it would be helpful for me to show you my C++ code to do the same thing #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; }
death pax Posted March 6, 2006 Author Posted March 6, 2006 still not working... ah well, in that case, do you think you could tell me to get functions in a dll to export properly... whenever i try making a dll the functions are unusable externally
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now