C++Talk.NET Forum Index C++Talk.NET
C++ language newsgroups
 
Archives   FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

VC++ project crashes in Windows 9x

 
Post new topic   Reply to topic    C++Talk.NET Forum Index -> C++ language (comp.lang.c++)
View previous topic :: View next topic  
Author Message
Mariano López
Guest





PostPosted: Sun Jan 30, 2005 8:27 am    Post subject: VC++ project crashes in Windows 9x Reply with quote



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.



Back to top
Mike Wahler
Guest





PostPosted: Sun Jan 30, 2005 8:53 am    Post subject: Re: VC++ project crashes in Windows 9x Reply with quote




"Mariano López" <vidriosjujuy-NOSPAM- (AT) infovia (DOT) com.ar> wrote

Quote:
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



Back to top
Mariano López
Guest





PostPosted: Sun Jan 30, 2005 9:27 am    Post subject: Re: VC++ project crashes in Windows 9x Reply with quote



Mike Wahler wrote:
Quote:
"Mariano López" <vidriosjujuy-NOSPAM- (AT) infovia (DOT) com.ar> wrote in message
news:363k3kF4soq86U1 (AT) individual (DOT) 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?


Back to top
Alf P. Steinbach
Guest





PostPosted: Sun Jan 30, 2005 9:36 am    Post subject: Re: VC++ project crashes in Windows 9x Reply with quote

* =?Windows-1252?Q?Mariano_L=F3pez?=:
Quote:

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?

Back to top
Mariano López
Guest





PostPosted: Sun Jan 30, 2005 9:42 am    Post subject: Re: VC++ project crashes in Windows 9x Reply with quote

Alf P. Steinbach wrote:
Quote:
* =?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?


Back to top
Mike Wahler
Guest





PostPosted: Sun Jan 30, 2005 7:22 pm    Post subject: Re: VC++ project crashes in Windows 9x Reply with quote


"Mariano López" <vidriosjujuy-NOSPAM- (AT) infovia (DOT) com.ar> wrote

Quote:
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?

Quote:
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).

Quote:
Anyways, I use Delphi

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

Quote:
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.

Quote:
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




Back to top
Mariano López
Guest





PostPosted: Sun Jan 30, 2005 8:26 pm    Post subject: Re: VC++ project crashes in Windows 9x Reply with quote

Mike Wahler wrote:
Quote:
"Mariano López" <vidriosjujuy-NOSPAM- (AT) infovia (DOT) com.ar> wrote in message
news:363oelF4rhu44U1 (AT) individual (DOT) 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.


Quote:
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++.

Quote:
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.

Quote:
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...


Quote:
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 [url]http://360software.dakotabcn.net/temp/WinampMagic.zip):[/url]


#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)structBuf,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: %snn", returnVal);
printf("Artist: %sn", GetMetaInfo("Artist", returnVal));
printf("Title: %sn", GetMetaInfo("Title", returnVal));
printf("Album: %sn", GetMetaInfo("Album", returnVal));
printf("Year: %sn", GetMetaInfo("Year", returnVal));
printf("Bitrate: %s kbpsn", GetMetaInfo("Bitrate", returnVal));

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

free(returnVal);

return 0;
}


Back to top
Mike Wahler
Guest





PostPosted: Mon Jan 31, 2005 7:08 am    Post subject: Re: VC++ project crashes in Windows 9x Reply with quote

"Mariano López" <vidriosjujuy-NOSPAM- (AT) infovia (DOT) com.ar> wrote

Quote:

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

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



Back to top
Display posts from previous:   
Post new topic   Reply to topic    C++Talk.NET Forum Index -> C++ language (comp.lang.c++) All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2006 phpBB Group
SEO toolkit © 2004-2006 webmedic.