gman24
Oct 26 2003, 04:56 AM
Thnx, I'll try those.
Heh, I found the code. I used packet x functions (basically, I just modified the packet and a few things). I think this is the one with the modified packets.
#include "stdafx.h"
// Raw packet
BYTE Packet[] =
{
0x00, 0xc0, 0x9f, 0x17, 0xd4, 0xc5, 0x00 , 0x06, 0x25, 0xc1, 0xf9, 0xc7, 0x08, 0x00, 0x45, 0x00,
0x00, 0xec, 0x80, 0x43, 0x00, 0x00, 0x32, 0x06, 0x0d, 0x78, 0xcf, 0x2e, 0x6c, 0x11, 0xc0, 0xa8,
0xfe, 0x68, 0x07, 0x47, 0x0d, 0xec, 0xd5, 0x2d, 0xee, 0x88, 0xc8,0xff,0xac,0x52,0x50,0x18,
0x43,0xdc,0xcd,0xa0,0x00,0x00,0x4d,0x53,0x47,0x20,0x69,0x62,0x6d,0x70,0x65,0x74,
0x65,0x40,0x68,0x6f,0x74,0x6d,0x61,0x69,0x6c,0x2e,0x63,0x6f,0x6d,0x20,0x50,0x65,
0x74,0x65,0x27,0x73,0x25,0x32,0x30,0x57,0x6f,0x72,0x6b,0x25,0x32,0x30,0x50,0x43,
0x20,0x31,0x34,0x38,0x0d,0x0a,0x4d,0x49,0x4d,0x45,0x2d,0x56,0x65,0x72,0x73,0x69,
0x6f, 0x6e, 0x3a, 0x20, 0x31, 0x2e, 0x30, 0x0d, 0x0a, 0x43, 0x6f, 0x6e, 0x74, 0x65, 0x6e, 0x74, 0x2d, 0x54, 0x79, 0x70, 0x65, 0x3a, 0x20, 0x74, 0x65, 0x78, 0x74, 0x2f, 0x70, 0x6c, 0x61, 0x69, 0x6e, 0x3b, 0x20, 0x63, 0x68, 0x61, 0x72, 0x73, 0x65, 0x74, 0x3d, 0x55, 0x54, 0x46, 0x2d, 0x38, 0x0d, 0x0a, 0x58, 0x2d, 0x4d, 0x53, 0x2d, 0x49, 0x4d, 0x2d, 0x46, 0x6f, 0x72, 0x6d, 0x61, 0x74, 0x3a, 0x20, 0x46, 0x4e, 0x3d, 0x4d, 0x53, 0x25, 0x32, 0x30, 0x53, 0x25, 0x32, 0x30, 0x53, 0x68, 0x65, 0x6c, 0x6c, 0x25, 0x32, 0x30, 0x44, 0x6c, 0x67, 0x3b, 0x20, 0x45, 0x46, 0x3d, 0x3b, 0x20, 0x43, 0x3f, 0x3d, 0x30, 0x3b, 0x20, 0x43, 0x53, 0x3d, 0x30, 0x3b, 0x20, 0x50, 0x46, 0x3d, 0x30, 0x0d, 0x0a, 0x0d, 0x0a, 0x50, 0x65, 0x74, 0x65, 0x20, 0x69, 0x73, 0x20, 0x61, 0x20, 0x62, 0x69, 0x67, 0x20, 0x73, 0x74, 0x75, 0x64, 0x20, 0x6d, 0x75, 0x66, 0x66, 0x69, 0x6e
};
#define PacketSize sizeof(Packet)
int main(int argc, char* argv[])
{
// Initialize COM
#ifdef MT_APARTMENT
_S(CoInitializeEx(NULL,COINIT_MULTITHREADED));
#else
_S(CoInitialize(NULL));
#endif
// Create PacketX
IPktXPacketXPtr pPktX;
_S(pPktX.CreateInstance(__uuidof(PacketX)));
// Display network adapters
LONG lCount= IPktXAdapterCollectionPtr(pPktX->GetAdapters())->GetCount();
for (int i=0; i < lCount; i++)
{
// If adapter is good print adapter properties
IPktXAdapterPtr pAdapter = IPktXAdapterCollectionPtr(pPktX->GetAdapters())->GetItem(i+1);
if (pAdapter->GetIsGood())
{
_bstr_t bstrtDesciption = pAdapter->GetDescription();
printf("(%d) %s\n",i+1,(char*)bstrtDesciption);
}
}
// Select network adapter
pPktX->PutAdapter(NULL);
while (pPktX->GetAdapter() == NULL)
{
char buffer[256];
printf("Choose adapter#");
try { pPktX->PutAdapter(IPktXAdapterCollectionPtr(
pPktX->GetAdapters())->GetItem(atoi(gets(buffer)))); }
catch ( _com_error& ) {}
}
// Create safe array containing raw packet and fill it
LPSAFEARRAY psa = SafeArrayCreateVector(VT_VARIANT,0,PacketSize);
LPVARIANT rgElems;
SafeArrayAccessData(psa,(LPVOID*)&rgElems);
for (i=0; i < PacketSize; i++)
{
VariantInit(&rgElems[i]);
V_VT(&rgElems[i])=VT_UI1;
V_UI1(&rgElems[i])=Packet[i];
}
// Create variant for safearray
VARIANT Buffer;
VariantInit(&Buffer);
Buffer.vt = VT_VARIANT|VT_ARRAY;
Buffer.parray = psa;
// Send raw packet, repeat 100 times
IPktXAdapterPtr(pPktX->GetAdapter())->SendPacket(Buffer,100);
// Cleanup
SafeArrayUnaccessData(psa);
SafeArrayDestroy(psa);
pPktX = NULL;
// Uninitialize COM
CoUninitialize();
return 0;
}