Code/Resource
Windows Develop
Linux-Unix program
Internet-Socket-Network
Web Server
Browser Client
Ftp Server
Ftp Client
Browser Plugins
Proxy Server
Email Server
Email Client
WEB Mail
Firewall-Security
Telnet Server
Telnet Client
ICQ-IM-Chat
Search Engine
Sniffer Package capture
Remote Control
xml-soap-webservice
P2P
WEB(ASP,PHP,...)
TCP/IP Stack
SNMP
Grid Computing
SilverLight
DNS
Cluster Service
Network Security
Communication-Mobile
Game Program
Editor
Multimedia program
Graph program
Compiler program
Compress-Decompress algrithms
Crypt_Decrypt algrithms
Mathimatics-Numerical algorithms
MultiLanguage
Disk/Storage
Java Develop
assembly language
Applications
Other systems
Database system
Embeded-SCM Develop
FlashMX/Flex
source in ebook
Delphi VCL
OS Develop
MiddleWare
MPI
MacOS develop
LabView
ELanguage
Software/Tools
E-Books
Artical/Document
Util.cpp
Package: HookAPI [view]
Upload User: nbcables
Upload Date: 2007-01-11
Package Size: 1243k
Code Size: 2k
Category:
Hook api
Development Platform:
Visual C++
- #include "stdafx.h"
- #include <stdio.h>
- #include <io.h>
- #include "resource.h"
- #include "util.h"
- void GetFileName(char *fname)
- {
- char temp[200];
- GetModuleFileName(NULL, temp, sizeof(temp));
- int i =strlen(temp);
- while(i >0 && temp[i-1] !='\' && temp[i-1] !=':') i--;
- strcpy(fname, &temp[i]);
- }
- // 如果是win9x,不能使用fopen函数
- void WriteLog(char *fmt,...)
- {
- va_list args;
- char modname[200];
- char temp[5000];
- HANDLE hFile;
- GetModuleFileName(NULL, modname, sizeof(modname));
- if((hFile =CreateFile("c:\hookapi.log", GENERIC_WRITE, 0, NULL, OPEN_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL)) <0)
- {
- return;
- }
- _llseek((HFILE)hFile, 0, SEEK_END);
- wsprintf(temp, "mydll.dll:%s:", modname);
- DWORD dw;
- WriteFile(hFile, temp, strlen(temp), &dw, NULL);
- va_start(args,fmt);
- vsprintf(temp, fmt, args);
- va_end(args);
- WriteFile(hFile, temp, strlen(temp), &dw, NULL);
- wsprintf(temp, "rn");
- WriteFile(hFile, temp, strlen(temp), &dw, NULL);
- _lclose((HFILE)hFile);
- }
- int ipcmp(char *szip1, char *szip2)
- {
- ULONG ip1 =GetIntIP(szip1);
- ULONG ip2 =GetIntIP(szip2);
- if(ip1 > ip2) return 1;
- else if(ip1 <ip2) return -1;
- else return 0;
- }
- ULONG GetIntIP(char *szip)
- {
- char *p, *p1;
- char ip[16];
- int i;
- ULONG ii[4];
- i =0;
- strcpy(ip, szip);
- p =ip;
- while(*p && i<4)
- {
- p1 =p;
- while(*p && *p !='.') p++;
- *p =0;
- ii[i] =my_atoi(p1);
- p ++;
- i++;
- }
- return ii[0]*256*256*256+ii[1]*256*256+ii[2]*256+ii[3];
- }
- ULONG my_atoi(char *p)
- {
- ULONG i;
- i =0;
- while(*p)
- {
- i =(i+*p-'0')*10;
- p++;
- }
- i =i/10;
- return i;
- }