PostHeaderIcon Port Scanner With WinAPI

In most situation, I use MFC with the client application. but with little program maybe winapi is suit for it.

In this project, I use WinAPI instead of MFC, when finished, the size of it is only 12KB, very little.

This project uses Win Thread to scan, when each scan finished, the thread exits.

The picture of it is below

port scan

port scan

EXE:    PortScanner_exe

CODE:   PortScanner_src

There is no complex code for this application. see the following code:

// global variable
// the main window handle
HWND hDlg = NULL;

// data structure definition
struct MainThreadParam
{
	DWORD StartIp;
	DWORD EndIp;
	DWORD StartPort;
	DWORD EndPort;
	// notify the main thread the param copy event
	HANDLE hCopyEvent;
};

struct ThreadParam
{
	DWORD Ip;
	DWORD Port;
	// param copy event
	HANDLE hCopyOkEvent;
	// limit the number of threads
	HANDLE hThreadNum;
};

// functions definition
BOOL InitPortScan();
void InsertInfo( TCHAR* str );
// threads
DWORD WINAPI PortScanThread(LPVOID LpParam);
DWORD WINAPI MainThread(LPVOID LpParam);
// action
BOOL StartScanner(DWORD StartIp, DWORD EndIp, DWORD StartPort,
	DWORD EndPort);

For detail information, you can download the source code and complier it yourself.
This project is under VC2010 in unicode environment, take care about this.

15,767 views

Leave a Reply

Your email address will not be published. Required fields are marked *

*


*

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>


Copyright © 2010 - C++ Technology. All Rights Reserved.

Powered by Jerry | Free Space Provided by connove.com