By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
446,131 Members | 1,977 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 446,131 IT Pros & Developers. It's quick & easy.

VC++ project crashes in Windows 9x

P: n/a
Hi, I found a program on the net and I'm having some problems with it.

Basically what this program does is communicate with Winamp, but it can
use the functions that are supposed to work only for Winamp plugins.

The problem is that it crashes in Windows 9x, can somebody please take a
look to it? It's very small :-)

I don't remember where I got it from, so I posted it here:
http://360software.dakotabcn.net/temp/WinampMagic.zip
Any help will be greatly appreciated.
Thanks a lot.

Jul 23 '05 #1
Share this Question
Share on Google+
7 Replies


P: n/a

"Mariano López" <vi******************@infovia.com.ar> wrote in message
news:36*************@individual.net...
Hi, I found a program on the net and I'm having some problems with it.

Basically what this program does is communicate with Winamp, but it can
use the functions that are supposed to work only for Winamp plugins.

The problem is that it crashes in Windows 9x, can somebody please take a
look to it? It's very small :-)

I don't remember where I got it from, so I posted it here:
http://360software.dakotabcn.net/temp/WinampMagic.zip
Any help will be greatly appreciated.


http://www.slack.net/~shiva/welcome.txt

-Mike
Jul 23 '05 #2

P: n/a
Mike Wahler wrote:
"Mariano López" <vi******************@infovia.com.ar> wrote in message
news:36*************@individual.net...
Hi, I found a program on the net and I'm having some problems with
it.

Basically what this program does is communicate with Winamp, but it
can use the functions that are supposed to work only for Winamp
plugins.

The problem is that it crashes in Windows 9x, can somebody please
take a look to it? It's very small :-)

I don't remember where I got it from, so I posted it here:
http://360software.dakotabcn.net/temp/WinampMagic.zip
Any help will be greatly appreciated.


http://www.slack.net/~shiva/welcome.txt

-Mike

What was wrong with my post?

Jul 23 '05 #3

P: n/a
* =?Windows-1252?Q?Mariano_L=F3pez?=:

What was wrong with my post?


Platform-specific.

See the link that Mike provided.

Read responses before responding to them.

--
A: Because it messes up the order in which people normally read text.
Q: Why is it such a bad thing?
A: Top-posting.
Q: What is the most annoying thing on usenet and in e-mail?
Jul 23 '05 #4

P: n/a
Alf P. Steinbach wrote:
* =?Windows-1252?Q?Mariano_L=F3pez?=:

What was wrong with my post?


Platform-specific.

See the link that Mike provided.

Read responses before responding to them.


I read the page... ¬_¬

Well, I thought there was no problem in posting it as I saw a few post about
VC below.

Anyways, I use Delphi and I don't know if that code can compile in other C++
versions, so, sorry, I didn't know. Could you at least see it?

Jul 23 '05 #5

P: n/a

"Mariano López" <vi******************@infovia.com.ar> wrote in message
news:36*************@individual.net...
Alf P. Steinbach wrote:
* =?Windows-1252?Q?Mariano_L=F3pez?=:

What was wrong with my post?
Platform-specific.

See the link that Mike provided.

Read responses before responding to them.


I read the page... ¬_¬


Did you read *all* of it? Did you understand what you read?
Well, I thought there was no problem in posting it as I saw a few post about VC below.
That's right, you're not the only one who has posted off-topic
material here. People who do will be advised about topicalily.
Also, sometimes even when a post is topical, some folks will
use e.g. "VC" or some other non-C++ term in their subject line.
That's no problem as long as the message content is topical
(i.e. only concerning the standard C++ language).
Anyways, I use Delphi
Correct me if I'm wrong but isn't Delphi a (Borland) dialect of
Pascal?
and I don't know if that code can compile in other C++
versions,
I don't think Delphi is C++, but in any event, it's not
topical here. We discuss only the language here, not
particular products.
so, sorry, I didn't know. Could you at least see it?


I didn't see it, because I didn't look.

1. I didn't need to look because your message clearly indicated
it's not about standard C++.

2. Most folks won't download binary files due to concern
about computer viruses.
-Mike

Jul 23 '05 #6

P: n/a
Mike Wahler wrote:
"Mariano López" <vi******************@infovia.com.ar> wrote in message
news:36*************@individual.net...
Alf P. Steinbach wrote:
* =?Windows-1252?Q?Mariano_L=F3pez?=:

What was wrong with my post?

Platform-specific.

See the link that Mike provided.

Read responses before responding to them.
I read the page... ¬_¬


Did you read *all* of it? Did you understand what you read?


I read most of it, sorry but it was 6 a.m. and I was going to bed.

Well, I thought there was no problem in posting it as I saw a few
post about VC below.


That's right, you're not the only one who has posted off-topic
material here. People who do will be advised about topicalily.
Also, sometimes even when a post is topical, some folks will
use e.g. "VC" or some other non-C++ term in their subject line.
That's no problem as long as the message content is topical
(i.e. only concerning the standard C++ language).


I shouldn't have put VC++ in the subject line, it's a console application
and I don't know if it will compile in other C++.
Anyways, I use Delphi


Correct me if I'm wrong but isn't Delphi a (Borland) dialect of
Pascal?


Yes, I don't know C++, I just know how to translate some stuff from C++ to
Delphi.
and I don't know if that code can compile in other C++
versions,


I don't think Delphi is C++, but in any event, it's not
topical here. We discuss only the language here, not
particular products.
so, sorry, I didn't know. Could you at least see it?


I didn't see it, because I didn't look.

1. I didn't need to look because your message clearly indicated
it's not about standard C++.


I'm still not sure about that...

2. Most folks won't download binary files due to concern
about computer viruses.


It's a zip file with text files, for god's sake! How can that have a virus?

Anyways, here's the code I was working with (requires winamp.h from the
Winamp SDK or http://360software.dakotabcn.net/temp/WinampMagic.zip):
#include <stdio.h>
#include <windows.h>
#include <malloc.h>
#include "winamp.h"

#define METASIZE 128

HWND hwndWinamp;

//returns NULL if alloc failed, returns remote address otherwise
void *AllocWinamp(unsigned long bufsize)
{
void *remoteBuf;
HANDLE hWinamp;
unsigned long dWinamp;

// find the process id
GetWindowThreadProcessId(hwndWinamp, &dWinamp);

// open the process object
hWinamp = OpenProcess(PROCESS_ALL_ACCESS,false,dWinamp);
if(hWinamp == NULL) return NULL;

// allocate chunk of memory in winamp's address space
remoteBuf = VirtualAllocEx(hWinamp, NULL, bufsize, MEM_COMMIT,
PAGE_READWRITE);

CloseHandle(hWinamp);
return remoteBuf;
}

// returns 0 on success (it's winamp's problem if it fails... right?)
int FreeWinamp(void *remoteBuf, unsigned long bufsize)
{
int isError;
HANDLE hWinamp;
unsigned long dWinamp;

// find the process id
GetWindowThreadProcessId(hwndWinamp, &dWinamp);

// open the process object
hWinamp = OpenProcess(PROCESS_ALL_ACCESS,false,dWinamp);
if(hWinamp == NULL) return 2;

// free the memory in winamp's space
isError = VirtualFreeEx(hWinamp, remoteBuf, bufsize, MEM_DECOMMIT);
if(!isError)
{
CloseHandle(hWinamp);
return isError;
}

// release it
isError = VirtualFreeEx(hWinamp, remoteBuf, 0, MEM_RELEASE);
if(!isError)
{
CloseHandle(hWinamp);
return isError;
}

CloseHandle(hWinamp);
return 0;
}

// returns how many bytes were copied to local buffer
unsigned long ReadWinampToLocal(void *remoteBuf, void *localBuf, unsigned
long bufsize)
{
int isError;
HANDLE hWinamp;
unsigned long dWinamp;

// find the process id
GetWindowThreadProcessId(hwndWinamp, &dWinamp);

// open the process object
hWinamp = OpenProcess(PROCESS_ALL_ACCESS,false,dWinamp);
if(hWinamp == NULL) return 0;

isError = ReadProcessMemory(hWinamp, remoteBuf, localBuf, bufsize, NULL);

CloseHandle(hWinamp);

if(!isError) return 0;
else return bufsize;
}

// returns how many bytes were written to winamp's space
unsigned long WriteLocalToWinamp(void *localBuf, void *remoteBuf, unsigned
long bufsize)
{
int isError;
HANDLE hWinamp;
unsigned long dWinamp;

// find the process id
GetWindowThreadProcessId(hwndWinamp, &dWinamp);

// open the process object
hWinamp = OpenProcess(PROCESS_ALL_ACCESS,false,dWinamp);
if(hWinamp == NULL) return 0;

isError = WriteProcessMemory(hWinamp, remoteBuf, localBuf, bufsize, NULL);

CloseHandle(hWinamp);

if(!isError) return 0;
else return bufsize;
}

int GetPlayingTrack()
{
return SendMessage(hwndWinamp,WM_WA_IPC,0,IPC_GETLISTPOS) ;
}

char *GetMetaInfo(char *whichInfo, char *returnVal)
{
char *remoteBuf, *whichBuf, *structBuf;
static extendedFileInfoStruct xstruct;

// allocate the memory in winamp's space
remoteBuf = (char *)AllocWinamp(METASIZE);
whichBuf = (char *)AllocWinamp(sizeof(whichInfo));
structBuf = (char *)AllocWinamp(sizeof(xstruct));

// fill in ext struct
xstruct.filename = (char *)SendMessage(hwndWinamp, WM_WA_IPC,
GetPlayingTrack(), IPC_GETPLAYLISTFILE);
xstruct.metadata = whichBuf;
xstruct.ret = remoteBuf;
xstruct.retlen = METASIZE;

// write the local buffers to winamp's space
WriteLocalToWinamp(whichInfo, whichBuf, strlen(whichInfo));
WriteLocalToWinamp(&xstruct, structBuf, sizeof(xstruct));

// send the "get ext info call"
if(!SendMessage(hwndWinamp,WM_WA_IPC,(int)structBu f,IPC_GET_EXTENDED_FILE_INFO_HOOKABLE))
{
printf("Extended file information not available.\n");
return "no_ex";
}

// copy the remote buffer to local space
ReadWinampToLocal(remoteBuf, returnVal, METASIZE);

// free up the memory we allocated in winamp's space
FreeWinamp(remoteBuf, METASIZE);
FreeWinamp(whichBuf, sizeof(whichBuf));
FreeWinamp(structBuf, sizeof(xstruct));
return returnVal;
}

int main(int argc, char* argv[])
{
char *returnVal;
int length;

returnVal = (char *)malloc(MAX_PATH*sizeof(char));

hwndWinamp = FindWindowA("Winamp v1.x",NULL);

if(hwndWinamp == NULL)
{
printf("Winamp not running.\n");
return 0;
}

ReadWinampToLocal((char *)SendMessage(hwndWinamp, WM_WA_IPC,
GetPlayingTrack(), IPC_GETPLAYLISTFILE), returnVal, MAX_PATH);

printf("\nCurrently Playing song: %s\n\n", returnVal);
printf("Artist: %s\n", GetMetaInfo("Artist", returnVal));
printf("Title: %s\n", GetMetaInfo("Title", returnVal));
printf("Album: %s\n", GetMetaInfo("Album", returnVal));
printf("Year: %s\n", GetMetaInfo("Year", returnVal));
printf("Bitrate: %s kbps\n", GetMetaInfo("Bitrate", returnVal));

// in milliseconds
length = atoi(GetMetaInfo("Length", returnVal));
printf("Length: %d:%02d\n", length/(1000*60), (length/1000)%60);

free(returnVal);

return 0;
}

Jul 23 '05 #7

P: n/a
"Mariano López" <vi******************@infovia.com.ar> wrote in message
news:36*************@individual.net...

Anyways, here's the code I was working with (requires winamp.h from the
Winamp SDK or http://360software.dakotabcn.net/temp/WinampMagic.zip):


I've run out of ways to explain why your query is not
topical for comp.lang.c++, so I'll give up now, but
in parting, I'll remind you that the link I posted has
information about where you *can* get help with your
questions.

-Mike
Jul 23 '05 #8

This discussion thread is closed

Replies have been disabled for this discussion.