Portal:AOL-Files/Articles/Main.cpp: Difference between revisions

From NINA Wiki
Jump to navigation Jump to search
(Created page with "{{AOL-Files}} (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-mai...")
 
No edit summary
Line 14: Line 14:


As he stated, it looks as this is the beginning of an AOL prog.
As he stated, it looks as this is the beginning of an AOL prog.
<pre>
#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, &quot;_AOL_Edit&quot;, 0 );
if( hw )
{
hw=FindWindowEx( hWnd, 0, &quot;_AOL_View&quot;, 0 );
}
if( hw )
{
hw=FindWindowEx( hWnd, 0, &quot;_AOL_Listbox&quot;, 0 );
}
if( hw )
{
hw=FindWindowEx( hWnd, 0, &quot;_AOL_Icon&quot;, 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-&gt;isChatRoom=IsChatRoom( hWnd );
if( param-&gt;isChatRoom )
{
param-&gt;hWnd=hWnd;
}
return !param-&gt;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, &quot;_AOL_Edit&quot;, 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, &quot;_AOL_Listbox&quot;, 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, &quot;_AOL_Listbox&quot;, 0 );
if( hListWnd )
{
GetWindowThreadProcessId( hListWnd, &amp;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, &amp;sPerson, 4, &amp;bytes );
if( !result )
{
RaiseWinErr();
}
memcpy( &amp;lListPersonHold, &amp;sPerson, 4 );
lListPersonHold=lListPersonHold+6;
ReadProcessMemory( hProcess, (void *)lListPersonHold, screenName, 16, &amp;bytes );
CloseHandle( hProcess );
}
}
}
}
void GetChatRoomList( HWND hAOLWnd, RoomList *pRoomList )
{
long i;
long count;
pRoomList-&gt;count=GetChatRoomCount( hAOLWnd );
for( i=pRoomList-&gt;count;i&gt;=1;i-- )
{
if( i&gt;(pRoomList-&gt;count=GetChatRoomCount( hAOLWnd )) )
{
i=pRoomList-&gt;count;
}
GetNthChatRoomName( hAOLWnd, i, pRoomList-&gt;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, &quot;_AOL_View&quot;, 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, &quot;ATTENTION: %s has LEFT&quot;, param-&gt;name );
SendChatRoom( hAOLWnd, buf );
Wait( SCROLL_WAIT );
}
static void DoChatMemberJoin( HWND hAOLWnd, AOLChatMemberJoin *param )
{
char buf[255];
sprintf( buf, &quot;ATTENTION: %s has ENTERED&quot;, param-&gt;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, &amp;gRoomList );
}
static int InRoomList( RoomList *roomList, char *name )
{
int found;
long i;
found=0;
for( i=1;i&lt;=roomList-&gt;count;i++ )
{
if( !strcmp( roomList-&gt;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, &amp;roomList );
// process people that have left
for( i=1;i&lt;=gRoomList.count;i++ )
{
if( !InRoomList( &amp;roomList, gRoomList.name[i-1] ) )
{
chatMemberLeftMsg.name=gRoomList.name[i-1];
AOLPostEvent( hAOLWnd, kAOLChatMemberLeftMsg, &amp;chatMemberLeftMsg );
}
}
// process people that have entered
for( i=1;i&lt;=roomList.count;i++ )
{
if( !InRoomList( &amp;gRoomList, roomList.name[i-1] ) )
{
chatMemberJoinMsg.name=roomList.name[i-1];
AOLPostEvent( hAOLWnd, kAOLChatMemberJoinMsg, &amp;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(&quot;AOL Frame25&quot;, 0 );
AOLInit( hAOLWnd );
done=0;
do
{
AOLProcessEvents( hAOLWnd );
}
while( !done );
return 0;
}
/*
#if 0
hChatWnd = GetChatRoom( hAOLWnd );
SendChatRoom( hAOLWnd, &quot;[-=+] ------------------------ [+=-]&quot; );
Wait( SCROLL_WAIT );
SendChatRoom( hAOLWnd, &quot;[    ] Highland Loaded [    ]&quot; );
Wait( SCROLL_WAIT );
SendChatRoom( hAOLWnd, &quot;[-=+] ------------------------ [+=-]&quot; );
Wait( SCROLL_WAIT );
GetWindowText( hChatWnd, title, 255 );
count=GetChatRoomCount( hAOLWnd );
sprintf( buf, &quot;%d people: &quot;, count );
for( i=1;i&lt;=count;i++ )
{
GetNthChatRoomName( hAOLWnd, i, screenName );
strcat( buf, screenName );
if( i!=count )
{
strcat( buf, &quot;, &quot; );
}
}
ScrollChatText( hAOLWnd, buf );
GetLastChatLine( hAOLWnd, buf );
#endif
*/
</pre>


[[Category:AOL]]
[[Category:AOL]]
[[Category:AOL-Files]]
[[Category:AOL-Files]]
[[Category:FDO-Files]]
[[Category:FDO-Files]]

Revision as of 09:02, 2 October 2020

 
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
*/