diff options
author | Kirill Volinsky <mataes2007@gmail.com> | 2013-09-25 19:25:38 +0000 |
---|---|---|
committer | Kirill Volinsky <mataes2007@gmail.com> | 2013-09-25 19:25:38 +0000 |
commit | 2cf824fd2efaec5fa0125fdde5fd513dd906d844 (patch) | |
tree | aadae8304f8cf90c06c73ca49180c62faeef539b /plugins/Ping/src/icmp.cpp | |
parent | a01f62f394fc01e3c6ed89924be804d2438787e5 (diff) |
plugins cleanup
git-svn-id: http://svn.miranda-ng.org/main/trunk@6233 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
Diffstat (limited to 'plugins/Ping/src/icmp.cpp')
-rw-r--r-- | plugins/Ping/src/icmp.cpp | 45 |
1 files changed, 5 insertions, 40 deletions
diff --git a/plugins/Ping/src/icmp.cpp b/plugins/Ping/src/icmp.cpp index eeab3cf567..3cd34384bc 100644 --- a/plugins/Ping/src/icmp.cpp +++ b/plugins/Ping/src/icmp.cpp @@ -9,57 +9,23 @@ ICMP::ICMP(): timeout(2000),
functions_loaded(false)
{
- hDLL = LoadLibrary(_T("IPHLPAPI.DLL"));
- if(hDLL) {
- pIcmpCreateFile = (pfnHV)GetProcAddress(hDLL, "IcmpCreateFile");
- pIcmpCloseHandle = (pfnBH)GetProcAddress(hDLL, "IcmpCloseHandle");
- pIcmpSendEcho2 = (pfnDHDPWPipPDD)GetProcAddress(hDLL, "IcmpSendEcho2");
- }
- if (hDLL == 0 || pIcmpCreateFile == 0 || pIcmpCloseHandle == 0 || pIcmpSendEcho2 == 0) {
- hDLL = LoadLibrary(_T("ICMP.DLL"));
- if(hDLL) {
- pIcmpCreateFile = (pfnHV)GetProcAddress(hDLL, "IcmpCreateFile");
- pIcmpCloseHandle = (pfnBH)GetProcAddress(hDLL, "IcmpCloseHandle");
- pIcmpSendEcho2 = (pfnDHDPWPipPDD)GetProcAddress(hDLL, "IcmpSendEcho2");
- }
- if (hDLL == 0 || pIcmpCreateFile == 0 || pIcmpCloseHandle == 0 || pIcmpSendEcho2 == 0)
- return;
- else
- db_set_s(0, PLUG, "PingLib", "ICMP.DLL"); // for debugging
- } else
- db_set_s(0, PLUG, "PingLib", "IPHLPAPI.DLL"); // for debugging
-
WSAData wsaData;
if (WSAStartup(MAKEWORD(1, 1), &wsaData) != 0) {
WSACleanup();
- FreeLibrary((HMODULE)hDLL);
return;
}
- /*
- hIP = pIcmpCreateFile();
- if (hIP == INVALID_HANDLE_VALUE) {
- pIcmpCloseHandle(hIP);
- return;
- }
- */
-
buff = new char[BUFFER_SIZE];
functions_loaded = true;
}
-void ICMP::stop() {
- //if(hIP) {
- // pIcmpCloseHandle(hIP);
- // hIP = 0;
- //}
+void ICMP::stop()
+{
}
ICMP::~ICMP() {
if(hIP) stop();
WSACleanup();
- if(hDLL)
- FreeLibrary(hDLL);
delete[] buff;
}
@@ -90,12 +56,11 @@ bool ICMP::ping(char *host, ICMP_ECHO_REPLY &reply) reply.Status = 0;
- hIP = pIcmpCreateFile();
+ hIP = IcmpCreateFile();
if (hIP == INVALID_HANDLE_VALUE)
return false;
- //pIcmpSendEcho2(hIP, 0, 0, 0, address, data, sizeof(data), &ipoi, buff, sizeof(ICMP_ECHO_REPLY) + sizeof(data), timeout);
- DWORD rep_cnt = pIcmpSendEcho2(hIP, 0, 0, 0, address, data, sizeof(data), 0, buff, BUFFER_SIZE, timeout);
+ DWORD rep_cnt = IcmpSendEcho2(hIP, 0, 0, 0, address, data, sizeof(data), 0, buff, BUFFER_SIZE, timeout);
if (rep_cnt == 0)
{
DWORD code = GetLastError();
@@ -110,7 +75,7 @@ bool ICMP::ping(char *host, ICMP_ECHO_REPLY &reply) }
memcpy(&reply, buff, sizeof(ICMP_ECHO_REPLY));
- pIcmpCloseHandle(hIP);
+ IcmpCloseHandle(hIP);
return (reply.Status == 0);
}
|