|
|||||||
![]() |
|
|
Thread Tools | Search this Thread | Display Modes |
|
|
#1 |
|
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); |
|
|
|
|
|
#2 |
|
Junior Member
|
We already knew that
![]() ------------------ Thomas S. P. __programmer at Blox Technologies__ |
|
|
|
|
|
#3 |
|
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.
|
|
|
|
![]() |
|
|||||||
| Thread Tools | Search this Thread |
| Display Modes | |
|
|