Portal:AOL-Files/Articles/Main.cpp
Jump to navigation
Jump to search
AOL-Files | Articles | Downloads | FDO91 | |
(Originally by AOL-Files staff member Tau)
This file was originally contributed to me by Maxis. He claimed that his aunt worked for AOL or something. Tri e-mailed me regarding me previous thoughts on this and informed me that this is not an official chat room code, mainly because of the
SendChatRoom( hAOLWnd, "[-=+] ------------------------ [+=-]" ); Wait( SCROLL_WAIT ); SendChatRoom( hAOLWnd, "[ ] Highland Loaded [ ]" ); Wait( SCROLL_WAIT ); SendChatRoom( hAOLWnd, "[-=+] ------------------------ [+=-]" ); Wait( SCROLL_WAIT );
As he stated, it looks as this is the beginning of an AOL prog.
#include <stdio.h /> #include <windows.h /> #include <winuser.h /> #define MAX_CHATROOM 23 #define MAX_SCREENNAME 32 #define SCROLL_WAIT 550 typedef struct RoomList { long count; char name[MAX_CHATROOM][MAX_SCREENNAME]; }; static int IsChatRoom( HWND hWnd ) { int isChatRoom; HWND hw; isChatRoom=0; hw=FindWindowEx( hWnd, 0, "_AOL_Edit", 0 ); if( hw ) { hw=FindWindowEx( hWnd, 0, "_AOL_View", 0 ); } if( hw ) { hw=FindWindowEx( hWnd, 0, "_AOL_Listbox", 0 ); } if( hw ) { hw=FindWindowEx( hWnd, 0, "_AOL_Icon", 0 ); } if( hw ) { isChatRoom=1; } return isChatRoom; } typedef struct GetChatRoomParams { int isChatRoom; HWND hWnd; } GetChatRoomParams; static BOOL CALLBACK GetChatRoomProc( HWND hWnd, LPARAM lParam ) { GetChatRoomParams *param; param=(GetChatRoomParams *)lParam; param->isChatRoom=IsChatRoom( hWnd ); if( param->isChatRoom ) { param->hWnd=hWnd; } return !param->isChatRoom; } static HWND GetChatRoom( HWND hAOL ) { HWND hChatWnd; GetChatRoomParams param; param.isChatRoom=0; EnumChildWindows( hAOL, (WNDENUMPROC)GetChatRoomProc, (LPARAM)¶m ); if( param.isChatRoom ) { hChatWnd=param.hWnd; } else { hChatWnd=0; } return hChatWnd; } void SendChatRoom( HWND hAOLWnd, char *text ) { HWND hChatWnd; HWND hEditWnd; hChatWnd=GetChatRoom( hAOLWnd ); hEditWnd=FindWindowEx( hChatWnd, 0, "_AOL_Edit", 0 ); if( hEditWnd ) { // SetWindowText( hEditWnd, text ); SendMessage( hEditWnd, WM_SETTEXT, 0, (LPARAM)text ); SendMessage( hEditWnd, WM_CHAR, 13, 0 ); } } long GetChatRoomCount( HWND hAOLWnd ) { long count=0; HWND hChatWnd; HWND hListWnd; hChatWnd=GetChatRoom( hAOLWnd ); if( hChatWnd ) { hListWnd=FindWindowEx( hChatWnd, 0, "_AOL_Listbox", 0 ); if( hListWnd ) { count=SendMessage( hListWnd, LB_GETCOUNT, 0, 0 ); } } return count; } static void Wait( long mSecs ) { DWORD startTime, curTime; startTime=GetTickCount(); do { curTime=GetTickCount(); } while( (curTime-startTime)<msecs if( while( buf[1024] c n long *text haolwndchar hwnd scrollchattext( void )static />60 ) { c=60; } strncpy( buf, text, c ); buf[n]=0; SendChatRoom( hAOLWnd, buf ); text+=c; n-=c; if( n ) { Wait( SCROLL_WAIT ); } } } void RaiseWinErr( void ) { HRESULT code; char buf[1024]; char *str; code=GetLastError(); FormatMessage ( FORMAT_MESSAGE_FROM_SYSTEM, NULL, code, MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), // Default language buf, 1024, NULL ); } void GetNthChatRoomName( HWND hAOLWnd, long index, char *screenName ) { int result; HWND hChatWnd; HWND hListWnd; DWORD processID; HANDLE hProcess; char *itemData; char *personData; char sPerson[5]; DWORD bytes; DWORD lListItemHold, lListPersonHold; *screenName=0; hChatWnd=GetChatRoom( hAOLWnd ); if( hChatWnd ) { hListWnd=FindWindowEx( hChatWnd, 0, "_AOL_Listbox", 0 ); if( hListWnd ) { GetWindowThreadProcessId( hListWnd, &processID ); hProcess=OpenProcess( 0x10|0xf0000|PROCESS_VM_READ, 0, processID ); if( hProcess ) { lListItemHold=(DWORD)SendMessage( hListWnd, LB_GETITEMDATA, index-1, 0 ); lListItemHold=lListItemHold+24; result=ReadProcessMemory( hProcess, (void *)lListItemHold, &sPerson, 4, &bytes ); if( !result ) { RaiseWinErr(); } memcpy( &lListPersonHold, &sPerson, 4 ); lListPersonHold=lListPersonHold+6; ReadProcessMemory( hProcess, (void *)lListPersonHold, screenName, 16, &bytes ); CloseHandle( hProcess ); } } } } void GetChatRoomList( HWND hAOLWnd, RoomList *pRoomList ) { long i; long count; pRoomList->count=GetChatRoomCount( hAOLWnd ); for( i=pRoomList->count;i>=1;i-- ) { if( i>(pRoomList->count=GetChatRoomCount( hAOLWnd )) ) { i=pRoomList->count; } GetNthChatRoomName( hAOLWnd, i, pRoomList->name[i-1] ); } } void GetLastChatLine( HWND hAOLWnd, char *lastLine ) { HWND hChatWnd; HWND hViewWnd; long size; char *buf; char *c; hChatWnd=GetChatRoom( hAOLWnd ); if( hChatWnd ) { hViewWnd=FindWindowEx( hChatWnd, 0, "_AOL_View", 0 ); if( hViewWnd ) { size=SendMessage( hViewWnd, 14, 0, 0 ); buf=(char *)malloc( size+1 ); if( buf ) { SendMessage( hViewWnd, 13, size+1, (LPARAM)buf ); c=buf+size-1; while( *c!='\n' ) c--; c++; strcpy( lastLine, c ); c=lastLine; while( *c!='\n' ) c++; *c=0; } } } } #define kAOLChatMemberLeftMsg 1 typedef struct AOLChatMemberLeft { char *name; } AOLChatMemberLeft; #define kAOLChatMemberJoinMsg 2 typedef struct AOLChatMemberJoin { char *name; } AOLChatMemberJoin; static void DoChatMemberLeft( HWND hAOLWnd, AOLChatMemberLeft *param ) { char buf[255]; sprintf( buf, "ATTENTION: %s has LEFT", param->name ); SendChatRoom( hAOLWnd, buf ); Wait( SCROLL_WAIT ); } static void DoChatMemberJoin( HWND hAOLWnd, AOLChatMemberJoin *param ) { char buf[255]; sprintf( buf, "ATTENTION: %s has ENTERED", param->name ); SendChatRoom( hAOLWnd, buf ); Wait( SCROLL_WAIT ); } static void AOLPostEvent( HWND hAOLWnd, long event, void *param ) { switch( event ) { case kAOLChatMemberLeftMsg: { DoChatMemberLeft( hAOLWnd, (AOLChatMemberLeft *)param ); break; } case kAOLChatMemberJoinMsg: { DoChatMemberJoin( hAOLWnd, (AOLChatMemberJoin *)param ); break; } } } static RoomList gRoomList; static void AOLInit( HWND hAOLWnd ) { gRoomList.count=0; GetChatRoomList( hAOLWnd, &gRoomList ); } static int InRoomList( RoomList *roomList, char *name ) { int found; long i; found=0; for( i=1;i<=roomList->count;i++ ) { if( !strcmp( roomList->name[i-1], name ) ) { found=1; break; } } return found; } static void AOLProcessChatRoom( HWND hAOLWnd ) { RoomList roomList; long i, j; int found; AOLChatMemberLeft chatMemberLeftMsg; AOLChatMemberJoin chatMemberJoinMsg; GetChatRoomList( hAOLWnd, &roomList ); // process people that have left for( i=1;i<=gRoomList.count;i++ ) { if( !InRoomList( &roomList, gRoomList.name[i-1] ) ) { chatMemberLeftMsg.name=gRoomList.name[i-1]; AOLPostEvent( hAOLWnd, kAOLChatMemberLeftMsg, &chatMemberLeftMsg ); } } // process people that have entered for( i=1;i<=roomList.count;i++ ) { if( !InRoomList( &gRoomList, roomList.name[i-1] ) ) { chatMemberJoinMsg.name=roomList.name[i-1]; AOLPostEvent( hAOLWnd, kAOLChatMemberJoinMsg, &chatMemberJoinMsg ); } } gRoomList=roomList; // update the list } static void AOLProcessEvents( HWND hAOLWnd ) { AOLProcessChatRoom( hAOLWnd ); } int PASCAL WinMain( HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow ) { HWND hAOLWnd; HWND hChatWnd; long i, count; int done; hAOLWnd = FindWindow("AOL Frame25", 0 ); AOLInit( hAOLWnd ); done=0; do { AOLProcessEvents( hAOLWnd ); } while( !done ); return 0; } /* #if 0 hChatWnd = GetChatRoom( hAOLWnd ); SendChatRoom( hAOLWnd, "[-=+] ------------------------ [+=-]" ); Wait( SCROLL_WAIT ); SendChatRoom( hAOLWnd, "[ ] Highland Loaded [ ]" ); Wait( SCROLL_WAIT ); SendChatRoom( hAOLWnd, "[-=+] ------------------------ [+=-]" ); Wait( SCROLL_WAIT ); GetWindowText( hChatWnd, title, 255 ); count=GetChatRoomCount( hAOLWnd ); sprintf( buf, "%d people: ", count ); for( i=1;i<=count;i++ ) { GetNthChatRoomName( hAOLWnd, i, screenName ); strcat( buf, screenName ); if( i!=count ) { strcat( buf, ", " ); } } ScrollChatText( hAOLWnd, buf ); GetLastChatLine( hAOLWnd, buf ); #endif */