473,785 Members | 2,987 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Help! - Reading playlist files from winamp through Windows & Winamp APIs & .NET - Decoding memory contents

I've been trying for days to write a piece of VB.NET code that will
read from winamp's memory space the paths of the files from the current
winamp playlist.

The GETPLAYLISTFILE command of the winamp API will only return a
pointer to the position of the asked path. An article available on
http://msmvps.com/ch21st/archive/2004/02/26.aspx provides a VB6
implementation of this, using the ReadProcessMemo ry Windows API
command. Through digging and asking around, I managed to read the
memory contents that winamp points to, but I can't seem to be able to
decode them!

In the attached code below that contains all you need to recreate my
problem. The function always returns the following giberish:
"UVßwXjÝw

=============== =============== =============== =============== ==========

Private Sub Button1_Click(B yVal sender As System.Object, ByVal e As
System.EventArg s) Handles Button1.Click
MsgBox(Me.GetPl aylistFile(0))
End Sub

Private Const PROCESS_VM_READ As Long = &H10
Private Const IPC_GETPLAYLIST FILE = 211

Private Declare Auto Function FindWindow Lib "user32" (ByVal
lpClassName As String, ByVal lpWindowName As String) As IntPtr

Private Declare Auto Function SendMessage Lib "user32" (ByVal hwnd As
IntPtr, ByVal wMsg As Integer, ByVal wParam As Integer, ByVal lParam As
Integer) As IntPtr

Private Declare Function GetWindowThread ProcessId Lib "user32" (ByVal
hwnd As IntPtr, ByRef lpdwProcessId As IntPtr) As IntPtr

Private Declare Function OpenProcess Lib "kernel32" _
(ByVal dwDesiredAccess As Integer, _
ByVal bIneritHandle As Boolean, _
ByVal dwProcessId As IntPtr) As IntPtr

Private Declare Function ReadProcessMemo ry Lib "kernel32" (ByVal
hProcess As IntPtr, ByRef lpBase As IntPtr, ByVal lpBuffer() As Byte,
ByVal nSize As Integer, ByRef lpNumberOfBytes Written As Integer) As
Boolean

Private Declare Function CloseHandle Lib "kernel32" (ByVal hObject As
IntPtr) As Boolean

Private Function FindWinamp() As IntPtr
Return FindWindow("Win amp v1.x", vbNullString)
End Function

Public Function GetPlaylistFile (ByVal TrackNo As Integer) As String
Dim winampWindow As IntPtr = FindWinamp()
Dim fileName As String = String.Empty

If Not IsNullPtr(winam pWindow) Then

Dim lp As IntPtr = SendMessage(win ampWindow, &H400, TrackNo,
IPC_GETPLAYLIST FILE)

If Not IsNullPtr(lp) Then

Dim pid As IntPtr

Call GetWindowThread ProcessId(winam pWindow, pid)
If Not IsNullPtr(pid) Then

Dim hWinampProcess As IntPtr = OpenProcess(PRO CESS_VM_READ, False, pid)

If Not IsNullPtr(hWina mpProcess) Then

Dim buffer(1000) As Byte
Dim bytesWritten As Integer

If ReadProcessMemo ry(hWinampProce ss, lp, buffer, buffer.Length,
bytesWritten) Then

fileName = System.Text.Enc oding.Default.G etString(buffer )
End If

CloseHandle(hWi nampProcess)
End If

End If

End If

End If

Return fileName

End Function
Private Function IsNullPtr(ByVal ptr As IntPtr) As Boolean
Return ptr.Equals(IntP tr.Zero)
End Function

Nov 21 '05 #1
1 2340
The error lies in the fact that the lpBase argument of the ReadProcessMemo ry
declaration should be declared ByVal, not ByRef.

Hope this helps,
Stefan
<pa******@gmail .com> wrote in message
news:11******** **************@ g43g2000cwa.goo glegroups.com.. .
I've been trying for days to write a piece of VB.NET code that will
read from winamp's memory space the paths of the files from the current
winamp playlist.

The GETPLAYLISTFILE command of the winamp API will only return a
pointer to the position of the asked path. An article available on
http://msmvps.com/ch21st/archive/2004/02/26.aspx provides a VB6
implementation of this, using the ReadProcessMemo ry Windows API
command. Through digging and asking around, I managed to read the
memory contents that winamp points to, but I can't seem to be able to
decode them!

In the attached code below that contains all you need to recreate my
problem. The function always returns the following giberish:
"UVßwXjÝw

=============== =============== =============== =============== ==========

Private Sub Button1_Click(B yVal sender As System.Object, ByVal e As
System.EventArg s) Handles Button1.Click
MsgBox(Me.GetPl aylistFile(0))
End Sub

Private Const PROCESS_VM_READ As Long = &H10
Private Const IPC_GETPLAYLIST FILE = 211

Private Declare Auto Function FindWindow Lib "user32" (ByVal
lpClassName As String, ByVal lpWindowName As String) As IntPtr

Private Declare Auto Function SendMessage Lib "user32" (ByVal hwnd As
IntPtr, ByVal wMsg As Integer, ByVal wParam As Integer, ByVal lParam As
Integer) As IntPtr

Private Declare Function GetWindowThread ProcessId Lib "user32" (ByVal
hwnd As IntPtr, ByRef lpdwProcessId As IntPtr) As IntPtr

Private Declare Function OpenProcess Lib "kernel32" _
(ByVal dwDesiredAccess As Integer, _
ByVal bIneritHandle As Boolean, _
ByVal dwProcessId As IntPtr) As IntPtr

Private Declare Function ReadProcessMemo ry Lib "kernel32" (ByVal
hProcess As IntPtr, ByRef lpBase As IntPtr, ByVal lpBuffer() As Byte,
ByVal nSize As Integer, ByRef lpNumberOfBytes Written As Integer) As
Boolean

Private Declare Function CloseHandle Lib "kernel32" (ByVal hObject As
IntPtr) As Boolean

Private Function FindWinamp() As IntPtr
Return FindWindow("Win amp v1.x", vbNullString)
End Function

Public Function GetPlaylistFile (ByVal TrackNo As Integer) As String
Dim winampWindow As IntPtr = FindWinamp()
Dim fileName As String = String.Empty

If Not IsNullPtr(winam pWindow) Then

Dim lp As IntPtr = SendMessage(win ampWindow, &H400, TrackNo,
IPC_GETPLAYLIST FILE)

If Not IsNullPtr(lp) Then

Dim pid As IntPtr

Call GetWindowThread ProcessId(winam pWindow, pid)
If Not IsNullPtr(pid) Then

Dim hWinampProcess As IntPtr = OpenProcess(PRO CESS_VM_READ, False, pid)

If Not IsNullPtr(hWina mpProcess) Then

Dim buffer(1000) As Byte
Dim bytesWritten As Integer

If ReadProcessMemo ry(hWinampProce ss, lp, buffer, buffer.Length,
bytesWritten) Then

fileName = System.Text.Enc oding.Default.G etString(buffer )
End If

CloseHandle(hWi nampProcess)
End If

End If

End If

End If

Return fileName

End Function
Private Function IsNullPtr(ByVal ptr As IntPtr) As Boolean
Return ptr.Equals(IntP tr.Zero)
End Function
Nov 21 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

21
6557
by: Dave | last post by:
After following Microsofts admonition to reformat my system before doing a final compilation of my app I got many warnings/errors upon compiling an rtf file created in word. I used the Help Workshop program: hcw.exe that's included with Visual Basic. This exact same file compiled perfectly with no notes, warnings or errors prior to reformatting my system. Prior to the reformatting, I copied the help.rtf file onto a CD and checked the box to...
0
2216
by: python-help-bounces | last post by:
Your message for python-help@python.org, the Python programming language assistance line, has been received and is being delivered. This automated response is sent to those of you new to python-help, to point out a few resources that can help with answering your own questions, or improve the chances of getting a useful answer from the helpers. The most comprehensive overview of python.org help resources is at ...
4
3356
by: Sarir Khamsi | last post by:
Is there a way to get help the way you get it from the Python interpreter (eg, 'help(dir)' gives help on the 'dir' command) in the module cmd.Cmd? I know how to add commands and help text to cmd.Cmd but I would also like to get the man-page-like help for classes and functions. Does anyone know how to do that? Thanks. Sarir
3
3364
by: Colin J. Williams | last post by:
Python advertises some basic service: C:\Python24>python Python 2.4.1 (#65, Mar 30 2005, 09:13:57) on win32 Type "help", "copyright", "credits" or "license" for more information. >>> With numarray, help gives unhelpful responses:
27
2827
by: Bruce Dodds | last post by:
I recently started using Access 2003 for the first time. I wanted to pass on some comments about the Help system to Access MVPs who frequent this board. I'm doing this in the hope that some of what I say may be passed on to Microsoft. Microsoft has implemented a combination local and web based help system in Access 2003. The local Help installed on your hard drive is fast, but the content is abbreviated. For really useful help you have...
4
1475
by: jerry.ranch | last post by:
Say, on a data entry form a "HELP" cmbBUTTON that bounces the user off to word file that has help, or is there some other way to do it (like a label object with help on another form) Thanks Jerry
4
2256
by: Fred Flintstone | last post by:
This one baffles me. I'm using VS.Net 2005 and write desktop apps that need built in help. So logically, I figure maybe VS has a help system component built in so I search the help. Hey! Apparently, all I have to do is create a "Help Project"! There's my starting point. So the VS help says: "To create a Help project, click on the File menu, choose New and follow the wizard's instructions"
10
3366
by: JonathanOrlev | last post by:
Hello everybody, I wrote this comment in another message of mine, but decided to post it again as a standalone message. I think that Microsoft's Office 2003 help system is horrible, probably the worst I ever seen. I almost cannot find anything I need, including things I
1
6139
by: trunxnirvana007 | last post by:
'UPGRADE_WARNING: Array has a new behavior. Click for more: 'ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?keyword="9B7D5ADD-D8FE-4819-A36C-6DEDAF088CC7"' 'UPGRADE_WARNING: Couldn't resolve default property of object Label. Click for more: 'ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?keyword="6A50421D-15FE-4896-8A1B-2EC21E9037B2"' Label = New Object(){Box1, Box2, Box3, Box4, Box5, Box6, Box7, Box8, Box9, Box10, Box11,...
0
2891
by: hitencontractor | last post by:
I am working on .NET Version 2003 making an SDI application that calls MS Excel 2003. I added a menu item called "MyApp Help" in the end of the menu bar to show Help-> About. The application calls MS Excel, so the scenario is that I am supposed to see the Excel Menu bar, FILE EDIT VIEW INSERT ... HELP. I am able to see the menu bar, but in case of Help, I see the Help of Excel and help of my application, both as a submenu of help. ...
0
9645
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
10327
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10151
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
9950
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8973
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
5381
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5511
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4053
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
3
2879
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.