Old 7th December 2000, 22:48   #1
herbie123
Junior Member
 
Join Date: Jun 2000
Posts: 15
Here's a technique to use the WM_WA_IPC messages that return pointers to strings from an external app.
More details in an article by Jeffrey Richter may be found here: http://msdn.microsoft.com/library/pe.../win320997.htm

It involves these steps:
- Get the winamp process id from the hwnd
- Create a buffer in winamp's process space
- Use ReadProcessMemory and WriteProcessMemory to read/write to this buffer
- Use this buffer in SendMessage

Example:

HWND hwndWinamp = FindWindow("Winamp v1.x", NULL);
if (!hwndWinamp) return;
DWORD dwProcessId;
GetWindowThreadProcessId(hwndWinamp, &dwProcessId);

// Check if our process can read/write in winamp's process space
HANDLE hProcess = OpenProcess(PROCESS_VM_OPERATION | PROCESS_VM_READ | PROCESS_VM_WRITE, FALSE, dwProcessId);
if (!hProcess) return;

// Create the buffer in winamp's process space
LPTSTR pWinampBuf = (LPTSTR) VirtualAllocEx(hProcess, NULL, BUFSIZE, MEM_RESERVE | MEM_COMMIT, PAGE_READWRITE);

// Example: Get all playlist entries
TCHAR szBuf[BUFSIZE];
int nPLCount = SendMessage(hwndWinamp, WM_WA_IPC, 0, IPC_GETLISTLENGTH);
for (int i=0; i<nPLCount; i++)
{
LPVOID pBase = (LPVOID)::SendMessage(hwndWinamp, WM_USER, i, IPC_GETPLAYLISTFILE);
ReadProcessMemory(hProcess, pBase, szBuf, sizeof(szBuf), NULL);
// szBuf now contains the filename for entry i
}

// Example: Set a skin
_tcscpy(szBuf, _T("Our_Friend_Joe_Final.zip"));
WriteProcessMemory(hProcess, pWinampBuf, szBuf, _tcslen(szBuf),NULL);
::SendMessage(hwndWinamp, WM_WA_IPC, (WPARAM)pWinampBuf, IPC_SETSKIN);

// Clean up
VirtualFreeEx(hProcess, pWinampBuf, 0, MEM_RELEASE);
herbie123 is offline   Reply With Quote
Old 7th December 2000, 22:59   #2
blomme
Junior Member
 
Join Date: Dec 2000
Posts: 3
Send a message via ICQ to blomme
We already knew that

------------------
Thomas S. P.
__programmer at Blox Technologies__
blomme is offline   Reply With Quote
Old 7th December 2000, 23:17   #3
herbie123
Junior Member
 
Join Date: Jun 2000
Posts: 15
We already knew that


I wish I had seen this before , could've saved me a lot of time. May be worth mentioning in NSDN.
herbie123 is offline   Reply With Quote
Reply
Go Back   Winamp & Shoutcast Forums > Winamp > Winamp Technical Support

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump