10-16-2011، 07:34 PM
با سورس زیر که با سی پلاس پلاس نوشته شده ایت میتونید فایروال رو از کار بندازید.
کد:
/*
Windows Firewall
->Vista check
->Enable/Disable
by: stoopid
2009/5/25
*/
#include <windows.h>
#include <stdio.h>
int WindowsFirewall( bool bEnable );
bool IsVista( void );
int main()
{
WindowsFirewall( false );
Sleep( 5000 );
WindowsFirewall( true );
getchar( );
return( 0 );
}
int WindowsFirewall( bool bEnable )
{
SERVICE_STATUS sStatus;
BOOL bControl;
LPCTSTR cService;
if( IsVista( ) == true ) {
cService = "MpsSvc"; //vista
} else {
cService = "SharedAccess"; //xp
}
SC_HANDLE hManager = OpenSCManager( NULL, NULL, 0xF003F );
if( hManager == NULL ) {
return( 1 );
}
SC_HANDLE hService = OpenService( hManager, cService, 0xF01FF );
if( hService == NULL ) {
return( 2 );
}
if( bEnable == true ) {
bControl = StartService( hService, 0, NULL ); //start
} else {
bControl = ControlService( hService, 0x00000001, &sStatus ); //stop
}
if( bControl == 0 ) {
return( 3 );
}
CloseServiceHandle( hManager );
CloseServiceHandle( hService );
return( 0 );
}
bool IsVista()
{
OSVERSIONINFO osvi;
osvi.dwOSVersionInfoSize = sizeof(OSVERSIONINFO);
if( GetVersionExA( &osvi ) != 0 ) {
if( osvi.dwMajorVersion > 5 ) {
return( true ); //vista or newer
} else {
return( false ); //xp or older
}
}
}