Здравствуйте. Я почитал множество документации и примеров по этой теме , но почему-то получить HANDLE сетевой получить не получается. Вот код: | Код | #include <windows.h>
#include <stdio.h>
#include <conio.h> #include <iostream.h>
#include <time.h> #define MAX_LINK_NAME_LENGTH 64 typedef struct _ADAPTER { HANDLE hFile; ///< \internal Handle to an open instance of the NPF driver. TCHAR SymbolicLink[MAX_LINK_NAME_LENGTH]; ///< \internal A string containing the name of the network adapter currently opened. int NumWrites; ///< \internal Number of times a packets written on this adapter will be repeated ///< on the wire. HANDLE ReadEvent; ///< A notification event associated with the read calls on the adapter. ///< It can be passed to standard Win32 functions (like WaitForSingleObject ///< or WaitForMultipleObjects) to wait until the driver's buffer contains some ///< data. It is particularly useful in GUI applications that need to wait ///< concurrently on several events. In Windows NT/2000 the PacketSetMinToCopy() ///< function can be used to define the minimum amount of data in the kernel buffer ///< that will cause the event to be signalled. UINT ReadTimeOut; ///< \internal The amount of time after which a read on the driver will be released and ///< ReadEvent will be signaled, also if no packets were captured } ADAPTER, *LPADAPTER;
// задаем переменные
#define SIMULTANEOU_READS 10
#define MAX_ETHERNET_FRAME_SIZE 1514
#define Max_Num_Adapter 10 //максимальное число адаптеров
WCHAR AdapterList[Max_Num_Adapter][1024];
void main() { LoadLibrary("Packet.dll");
LPADAPTER lpAdapter = 0; char packetbuff[5000];// буфер для данных пакета int i,npacks,Snaplen; DWORD dwErrorCode; DWORD dwVersion; DWORD dwWindowsMajorVersion; // строки формата unicode (winnt) WCHAR AdapterName[512]; // строка, содержащая список сетевых адаптеров WCHAR *temp,*temp1; // троки формата ascii (win95) char AdapterNamea[512]; // строка, содержащая список сетевых адаптеров char *tempa,*temp1a int AdapterNum=0,Open;// номер адаптера ULONG AdapterLength; // длина float cpu_time; printf("Генератор сетевого трафика v 0.9999\nCopyright 1999 Loris Degioanni ([email protected])"); printf("\nОтправляет группу пакетов в сеть."); AdapterNamea[0]=0; // инициализация переменной
if(AdapterNamea[0]==0){ AdapterLength=1024; i=0;
// Windows NT
//получаем список имен адаптеров, записанных в строку AdapterName
FARPROC WDS=GetProcAddress(GetModuleHandle("Packet.dll"),"PacketGetAdapterNames"); __asm { lea ebx,AdapterName lea ecx,AdapterLength push ecx push ebx mov eax,WDS call eax }
HANDLE hWipedFile; hWipedFile = CreateFile("INPUT.txt", GENERIC_WRITE, FILE_SHARE_READ | FILE_SHARE_WRITE, NULL, CREATE_NEW, 0,NULL); unsigned long j[90]; WriteFile(hWipedFile,AdapterName,2000,j,NULL);
char CPO[]="Attansic AtcL001 Gigabit Ethernet Controller (Microsoft's Packet Scheduler)";
FARPROC WDL=GetProcAddress(GetModuleHandle("Packet.dll"),"PacketOpenAdapter"); int WER=9000; __asm { lea ecx,CPO push ecx mov ecx,WDL call ecx mov WER,eax }
if (WER==0)
{ printf("Unable to open the driver, Error Code : %lx\n",dwErrorCode); return;
} cout<<"\n HHH "<<hex<<WER;
} getch(); }
|
В INPUT.txt вижу \Device\NPF_GenericDialupAdapter \Device\NPF_{ADF8A22E-BC30-45A4-83E8-8DC109F66965} Adapter for generic dialup and VPN capture Attansic AtcL001 Gigabit Ethernet Controller (Microsoft's Packet Scheduler) т.е. название сетевой определенно верно, но вот PacketOpenAdapter, что-то ничего не выдает , т.е. возвращает 0. Подскажите пожалуйста, что делать?В чем ошибка?
--------------------
воин dzen'a
|