News:

Help! We're trapped in the computer, and the computer is trapped in 2008! Someone call the time police!

Main Menu

Gaim Plugin Request

Started by Towelie, September 18, 2005, 03:42:48 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

Quik

Quote[20:21:13] xar: i was just thinking about the time iago came over here and we made this huge bomb and light up the sky for 6 min
[20:21:15] xar: that was funny

Towelie

Could you guys not go off topic........... I just want to know is
A) is it doable with reasonable amount of work?
B) If anyone is willing to do it?

iago

Quote from: Toweliex86] link=topic=2948.msg28284#msg28284 date=1127101176]
Could you guys not go off topic........... I just want to know is
A) is it doable with reasonable amount of work?
Yes.  A lot of work, but not unreasonable. 

Quote
B) If anyone is willing to do it?
Probably not.  People around here don't seem to care about Windows. 

If anybody is interested, however, I might be able to get some information on how to compile Gaim plugins for Windows.  I don't want to bug the guy, but I will if somebody here wants me to find out. 

Newby

Quote from: iago on September 18, 2005, 11:41:20 PM
Probably not.  People around here don't seem to care about Windows. 

And yet the majority of "people" use Windows! :P
- Newby
http://www.x86labs.org

Quote[17:32:45] * xar sets mode: -oooooooooo algorithm ban chris cipher newby stdio TehUser tnarongi|away vursed warz
[17:32:54] * xar sets mode: +o newby
[17:32:58] <xar> new rule
[17:33:02] <xar> me and newby rule all

Quote from: Rule on June 30, 2008, 01:13:20 PM
Quote from: CrAz3D on June 30, 2008, 10:38:22 AM
I'd bet that you're currently bloated like a water ballon on a hot summer's day.

That analogy doesn't even make sense.  Why would a water balloon be especially bloated on a hot summer's day? For your sake, I hope there wasn't too much logic testing on your LSAT. 

Joe

I'm going to laugh when I end up being the one who writes this. -sigh-
Quote from: Camel on June 09, 2009, 04:12:23 PMI'd personally do as Joe suggests

Quote from: AntiVirus on October 19, 2010, 02:36:52 PM
You might be right about that, Joe.


Towelie


Quik

Quote from: iago on September 18, 2005, 11:41:20 PM
Quote from: Toweliex86] link=topic=2948.msg28284#msg28284 date=1127101176]
Could you guys not go off topic........... I just want to know is
A) is it doable with reasonable amount of work?
Yes. A lot of work, but not unreasonable.

Quote
B) If anyone is willing to do it?
Probably not. People around here don't seem to care about Windows.

If anybody is interested, however, I might be able to get some information on how to compile Gaim plugins for Windows. I don't want to bug the guy, but I will if somebody here wants me to find out.

I might be interested in writing this, please contact me with any information you can get.
Quote[20:21:13] xar: i was just thinking about the time iago came over here and we made this huge bomb and light up the sky for 6 min
[20:21:15] xar: that was funny

Newby

Quote from: Joe[e2] on September 18, 2005, 11:58:07 PM
I'm going to laugh when I end up being the one who writes this. -sigh-

You won't finish it. :)
- Newby
http://www.x86labs.org

Quote[17:32:45] * xar sets mode: -oooooooooo algorithm ban chris cipher newby stdio TehUser tnarongi|away vursed warz
[17:32:54] * xar sets mode: +o newby
[17:32:58] <xar> new rule
[17:33:02] <xar> me and newby rule all

Quote from: Rule on June 30, 2008, 01:13:20 PM
Quote from: CrAz3D on June 30, 2008, 10:38:22 AM
I'd bet that you're currently bloated like a water ballon on a hot summer's day.

That analogy doesn't even make sense.  Why would a water balloon be especially bloated on a hot summer's day? For your sake, I hope there wasn't too much logic testing on your LSAT. 

Joe

Sure I will. It'll be a leached combo of yPlugin and iago's encoding thing. =)
Quote from: Camel on June 09, 2009, 04:12:23 PMI'd personally do as Joe suggests

Quote from: AntiVirus on October 19, 2010, 02:36:52 PM
You might be right about that, Joe.


iago

I'm guessing that what you need is to install cygwin, go into the "plugins" directory, make your plugin called <pluginname>.c, then compile it by doing "make <pluginname>.dll

rabbit

Or you could use MinGW and do "gcc -c -DBUILD_DLL winamp_plugin.c; gcc -shared -o winamp_plugin.dll -Wl,--out-implib,libwinamp_plugin.a winamp_plugin.o"

Joe

char *GetWinampSongTitle(HWND Winamp, DWORD Index) // Winamp 2.04+, pointer is in local address space {
   static char SongTitle[1024];

   DWORD WinampProcessID;
   HANDLE WinampProcess;
   char *SongTitleRemote;
   char *Ret = NULL; // Return value

   GetWindowThreadProcessId(Winamp, &WinampProcessID); // get pid

   if(WinampProcess = OpenProcess(PROCESS_VM_READ, FALSE, WinampProcessID)) { // open process
      if(SongTitleRemote = GetWinampSongTitleRemote(Winamp, Index)) { // get pointer
         if(ReadProcessMemory(WinampProcess, SongTitleRemote, SongTitle, sizeof(SongTitle), NULL)) { // read it
            Ret = SongTitle; // success
         }
      }
      CloseHandle(WinampProcess);
   }

   return Ret;
}


From yPlugin2.
Quote from: Camel on June 09, 2009, 04:12:23 PMI'd personally do as Joe suggests

Quote from: AntiVirus on October 19, 2010, 02:36:52 PM
You might be right about that, Joe.


Newby

Quote from: Joe[e2] on September 19, 2005, 06:31:14 PM
From yPlugin2.

Now all you have to do is stick that in a plugin, make all the appropriate hooks / calls, compile it, and release it, and you'll be done!
- Newby
http://www.x86labs.org

Quote[17:32:45] * xar sets mode: -oooooooooo algorithm ban chris cipher newby stdio TehUser tnarongi|away vursed warz
[17:32:54] * xar sets mode: +o newby
[17:32:58] <xar> new rule
[17:33:02] <xar> me and newby rule all

Quote from: Rule on June 30, 2008, 01:13:20 PM
Quote from: CrAz3D on June 30, 2008, 10:38:22 AM
I'd bet that you're currently bloated like a water ballon on a hot summer's day.

That analogy doesn't even make sense.  Why would a water balloon be especially bloated on a hot summer's day? For your sake, I hope there wasn't too much logic testing on your LSAT. 

iago

Quote from: rabbit on September 19, 2005, 05:29:28 PM
Or you could use MinGW and do "gcc -c -DBUILD_DLL winamp_plugin.c; gcc -shared -o winamp_plugin.dll -Wl,--out-implib,libwinamp_plugin.a winamp_plugin.o"
Don't forget, you have to add Gaim's libraries and include files.  That's why make is handy. 


rabbit

This is my entire (incomplete) C++ Winamp code.  There are a few minor things I have left to do, but, whatever:

#include <windows.h>
#include <stdio.h>
#include <iostream.h>

HWND__ *hwnd_winamp;

const long IPC_ISPLAYING = 104;
const long IPC_GETOUTPUTTIME    = 105;
const long IPC_SETPLAYLISTPOS   = 121;
const long IPC_SETVOLUME        = 122;
const long IPC_GETLISTLENGTH = 124;
const long IPC_GETLISTPOS = 125;
const long IPC_GETINFO          = 126;
const long IPC_GETPLAYLISTTITLE = 212;
const long WM_WA_IPC = 0x400;
const long WA_DIALOGJUMPTOFILE  = 0x9D02;
const long WA_SENDCUSTOMDATA    = 0x111;
const long WINAMP_BUTTON1       = 40044;
const long WINAMP_BUTTON2       = 40045;
const long WINAMP_BUTTON3       = 40046;
const long WINAMP_BUTTON4       = 40047;
const long WINAMP_BUTTON5       = 40048;
const long xPROCESS_VM_READ = 0x10;

enum playState
{
paused,
playing,
stopped
};

void DoEvents();
long findwinamp();
playState getPlayState();
long GetPlayListLength();
long GetPlayListPosition();
void GetCurrentSongPosition(char *&outbuf);
void GetSongLength(char *&outbuf);
bool JumpToFile(char *sFile);
long SetPlaylistPosition(int pos);
long SetVolume(int vol);
long GetBitrate();
long PrevTrack();
long PlayTrack();
long PauseTrack();
long StopTrack();
long NextTrack();
long GetWinampSongTitleRemote(int index);
char *GetWinampSongTitle(int index);

int main(int argc, char **argv)
{
// it's meant to be a command line driven program!
/*if(argc == 1 || (argc == 2 && argv[1] == "/?"))
{
printf("Invalid arguments.  Use is \n\tclamp <switch> [extra]\n\n");
printf("\tSWITCHES\tDESCRIPTION\n");
printf("\t  /?\t\tList this help\n");
return 1;
}*/

char *buffer = new char[1024];

// get winamp's handle
if(findwinamp() == 0)
{
printf("Error: winamp not found\n");
return 2;
}

// get the title of song 2414 in the playlist ^^
// best used with GetPlayListPosition()
cout << GetWinampSongTitle(2414) << endl;

// get the current playstate
playState check = getPlayState();

if(check == paused)
sprintf(buffer, "%s", "Winamp: Paused");
if(check == playing)
sprintf(buffer, "%s", "Winamp: Playing");
if(check == stopped)
sprintf(buffer, "%s", "Winamp: Stopped");

long pos = GetPlayListPosition();
long len = GetPlayListLength();

// start building the output
sprintf(buffer, "%s; [%i / %i] (", buffer, pos, len);
GetCurrentSongPosition(buffer);
sprintf(buffer, "%s)", buffer);

printf("%s\n", buffer);
return 0;
}

void DoEvents()
{
// stolen from the public DMBot source code
MSG Msg;
while(PeekMessage(&Msg,NULL,0,0,PM_REMOVE))
{
if(Msg.message == WM_QUIT) break;
TranslateMessage(&Msg);
DispatchMessage(&Msg);
}
}

long findwinamp()
{
hwnd_winamp = FindWindow("Winamp v1.x", NULL);
if(hwnd_winamp != 0)
return 1;
else
return 0;
}

playState getPlayState()
{
long res = SendMessage(hwnd_winamp, WM_WA_IPC, 0, IPC_ISPLAYING);
if(res == 0)
return stopped;
else if(res == 1)
return playing;
else
return paused;
}

long GetPlayListLength()
{
long ret = SendMessage(hwnd_winamp, WM_WA_IPC, 0, IPC_GETLISTLENGTH);
return ret;
}

long GetPlayListPosition()
{
long ret = SendMessage(hwnd_winamp, WM_WA_IPC, 0, IPC_GETLISTPOS) + 1;
return ret;
}

void GetCurrentSongPosition(char *&outbuf)
{
long sec = 0;
long min = 0;
long total = 0;
   
total = SendMessage(hwnd_winamp, WM_WA_IPC, 0, IPC_GETOUTPUTTIME);
min = total / 1000 / 60;
sec = total / 1000 % 60;
if(min < 10) sprintf(outbuf, "%s%i", outbuf, 0);
sprintf(outbuf, "%s%i:", outbuf, min);

if(sec < 10) sprintf(outbuf, "%s%i", outbuf, 0);
sprintf(outbuf, "%s%i", outbuf, sec);

return;
}

void GetSongLength(char *&outbuf)
{
long sec = 0;
long min = 0;
long total = 0;
   
total = SendMessage(hwnd_winamp, WM_WA_IPC, 1, IPC_GETOUTPUTTIME);
min = total / 1000 / 60;
sec = total / 1000 % 60;
if(min < 10) sprintf(outbuf, "%s%i", outbuf, 0);
sprintf(outbuf, "%s%i:", outbuf, min);

if(sec < 10) sprintf(outbuf, "%s%i", outbuf, 0);
sprintf(outbuf, "%s%i", outbuf, sec);

return;
}

bool JumpToFile(char *sFile)
{
HWND__ *jumpTo = 0;
HWND__ *edit = 0;
HWND__ *listBox = 0;

if(hwnd_winamp == 0x0)
return false;

PostMessage(hwnd_winamp, WA_SENDCUSTOMDATA, WA_DIALOGJUMPTOFILE, 0x0);

do
{
DoEvents();
jumpTo = FindWindow("#32770", "Jump to file");
edit = FindWindowEx(jumpTo, 0x0, "Edit", NULL);
listBox = FindWindowEx(jumpTo, 0x0, "ListBox", NULL);
} while(jumpTo == 0x0 || edit == 0x0 || listBox == 0x0);

SendMessage(edit, 0x0c, 0x0, (LPARAM)sFile);
DoEvents();
if(SendMessage(listBox, 0x18b, 0x0, 0x0) == 0x0)
PostMessage(jumpTo, 0x10, 0x0, 0x0);
else
SendMessage(listBox, 0x203, 0x0, (long)0x0);

return true;
}

long SetPlaylistPosition(int pos)
{
return SendMessage(hwnd_winamp, WM_WA_IPC, pos - 1, IPC_SETPLAYLISTPOS);
}

long SetVolume(int vol)
{
return SendMessage(hwnd_winamp, WM_WA_IPC, vol, IPC_SETVOLUME);
}

long GetBitrate()
{
return SendMessage(hwnd_winamp, WM_WA_IPC, 1, IPC_GETINFO);
}

char *GetChannels()
{
char *ret = new char[15];
long check = SendMessage(hwnd_winamp, WM_WA_IPC, 2, IPC_GETINFO);
switch(check)
{
case 0:
ret = "No Speakers";
break;
case 1:
ret = "Mono";
break;
case 2:
ret = "Stereo";
break;
default:
ret = "Surround-Sound";
break;
}

return ret;
}

long PrevTrack()
{
return SendMessage(hwnd_winamp, WM_COMMAND, WINAMP_BUTTON1, 0);
}

long PlayTrack()
{
return SendMessage(hwnd_winamp, WM_COMMAND, WINAMP_BUTTON2, 0);
}

long PauseTrack()
{
return SendMessage(hwnd_winamp, WM_COMMAND, WINAMP_BUTTON3, 0);
}

long StopTrack()
{
return SendMessage(hwnd_winamp, WM_COMMAND, WINAMP_BUTTON4, 0);
}

long NextTrack()
{
return SendMessage(hwnd_winamp, WM_COMMAND, WINAMP_BUTTON5, 0);
}

long GetWinampSongTitleRemote(int index)
{
return SendMessage(hwnd_winamp, WM_WA_IPC, index, IPC_GETPLAYLISTTITLE);
}

char *GetWinampSongTitle(int index)
{
char *title = new char[1024];
DWORD ProcessID = 0;
HANDLE ProcessHandle = 0;
long TitleRemote = 0;

ProcessID = GetWindowThreadProcessId((HWND)hwnd_winamp, (LPDWORD)ProcessID);
cout << "ProcessID: " << ProcessID << endl;
ProcessHandle = OpenProcess((DWORD)0x10, false, ProcessID);
cout << "ProcessHandle: " << ProcessHandle << endl;
if(ProcessHandle != 0)
{
TitleRemote = GetWinampSongTitleRemote(index);
cout << "TitleRemote: " << TitleRemote << endl;
if(TitleRemote != 0)
{
if(ReadProcessMemory((HANDLE)ProcessHandle, (LPCVOID)TitleRemote, (LPVOID)title, (DWORD)sizeof(title), (LPDWORD)0) != 0)
{
CloseHandle(ProcessHandle);
return title;
}
}
CloseHandle(ProcessHandle);
}
return "Error: Song Not Found";
}