+---------+------------+-----------------------------+---+----------+-------+
| 开始按钮 |运行应用程序1 | 运行应用程序2... |[<]|托盘通知区域|托盘时钟|
+---------+------------+-----------------------------+---+----------+-------+
// ============================================
// HackerTools.h : YangTze presents. 07/07/2005
// ============================================
#pragma once
class CHackerTools
{
public:
CHackerTools(void);
~CHackerTools(void);
public:
// 任务栏
BOOL TaskbarOnOff( BOOL bFlag );
// 开始按钮
BOOL StartButtonOnOff( BOOL bFlag );
// 托盘
BOOL TrayOnOff( BOOL bFlag );
// 托盘时钟
BOOL TrayClockOnOff( BOOL bFlag );
// 任务栏中运行应用程序
BOOL AppButtonOnOff( BOOL bFlag );
// 托盘通知区域
BOOL NotifyAreaOnOff( BOOL bFlag );
// 托盘伸缩按钮
BOOL TrayExtendedButtonOnOff( BOOL bFlag );
// 程序管理器
BOOL ProgramManagerOnOff( BOOL bFlag );
};
// ==============================================
// HackerTools.cpp : YangTze presents. 07/07/2005
// ==============================================
#include "StdAfx.h"
#include ".\hackertools.h"
CHackerTools::CHackerTools(void)
{
}
CHackerTools::~CHackerTools(void)
{
}
// 任务栏
// ------------------------------------------
BOOL CHackerTools::TaskbarOnOff( BOOL bFlag )
{
HWND hWnd;
hWnd = ::FindWindow( _T("Shell_TrayWnd"),NULL );
if( hWnd == NULL ) return FALSE;
::ShowWindow( hWnd,bFlag ? SW_SHOW : SW_HIDE );
::UpdateWindow( hWnd );
return TRUE;
}
// 开始按钮
// ----------------------------------------------
BOOL CHackerTools::StartButtonOnOff( BOOL bFlag )
{
HWND hWnd;
hWnd = ::GetDlgItem( ::FindWindow( _T("Shell_TrayWnd"),NULL ),0x130 );
if( hWnd == NULL ) return FALSE;
::ShowWindow( hWnd,bFlag ? SW_SHOW : SW_HIDE );
::UpdateWindow( hWnd );
return TRUE;
}
// 托盘
// ---------------------------------------
BOOL CHackerTools::TrayOnOff( BOOL bFlag )
{
HWND hWnd;
hWnd = ::GetDlgItem( ::FindWindow( _T("Shell_TrayWnd"),NULL ),0x12F );
if( hWnd == NULL ) return FALSE;
::ShowWindow( hWnd,bFlag ? SW_SHOW : SW_HIDE );
::UpdateWindow( hWnd );
return TRUE;
}
// 托盘时钟
// --------------------------------------------
BOOL CHackerTools::TrayClockOnOff( BOOL bFlag )
{
HWND hWnd;
hWnd = ::GetDlgItem( ::FindWindow( _T("Shell_TrayWnd"),NULL ),0x12F );
if( hWnd == NULL ) return FALSE;
hWnd = ::GetDlgItem( hWnd,0x12F );
if( hWnd == NULL ) return FALSE;
::ShowWindow( hWnd,bFlag ? SW_SHOW : SW_HIDE );
::UpdateWindow( hWnd );
return TRUE;
}
// 任务栏中运行应用程序
// --------------------------------------------
BOOL CHackerTools::AppButtonOnOff( BOOL bFlag )
{
HWND hWnd;
hWnd = ::GetDlgItem( ::FindWindow( _T("Shell_TrayWnd"),NULL ),0xA005 );
{
HWND hWndSub;
hWndSub = ::FindWindowEx( hWnd,NULL,_T("MSTaskSwWClass"),_T("运行应用程序") );
if( hWndSub != NULL )
{
hWndSub = ::FindWindowEx( hWndSub,NULL,_T("ToolbarWindow32"),_T("运行应用程序") );
if( hWndSub != NULL )
{
hWnd = hWndSub;
}
}
}
if( hWnd == NULL ) return FALSE;
::ShowWindow( hWnd,bFlag ? SW_SHOW : SW_HIDE );
::UpdateWindow( hWnd );
return TRUE;
}
// 托盘通知区域
// ---------------------------------------------
BOOL CHackerTools::NotifyAreaOnOff( BOOL bFlag )
{
HWND hWnd;
hWnd = ::GetDlgItem( ::FindWindow( _T("Shell_TrayWnd"),NULL ),0x12F );
if( hWnd == NULL ) return FALSE;
hWnd = ::FindWindowEx( hWnd,NULL,_T("SysPager"),_T("") );
if( hWnd == NULL ) return FALSE;
::ShowWindow( hWnd,bFlag ? SW_SHOW : SW_HIDE );
::UpdateWindow( hWnd );
return TRUE;
}
// 托盘伸缩按钮
// -----------------------------------------------------
BOOL CHackerTools::TrayExtendedButtonOnOff( BOOL bFlag )
{
HWND hWnd;
hWnd = ::GetDlgItem( ::FindWindow( _T("Shell_TrayWnd"),NULL ),0x12F );
if( hWnd == NULL ) return FALSE;
hWnd = ::GetDlgItem( hWnd,0x5DE );
if( hWnd == NULL ) return FALSE;
::ShowWindow( hWnd,bFlag ? SW_SHOW : SW_HIDE );
::UpdateWindow( hWnd );
return TRUE;
}
// 程序管理器
// -------------------------------------------------
BOOL CHackerTools::ProgramManagerOnOff( BOOL bFlag )
{
HWND hWnd;
hWnd = ::FindWindow( NULL,_T("Program Manager") );
if( hWnd == NULL ) return FALSE;
::SetWindowPos( hWnd,NULL,0,0,0,0,
bFlag ? SWP_SHOWWINDOW : SWP_HIDEWINDOW | SWP_NOSIZE | SWP_NOMOVE | SWP_NOZORDER
);
return TRUE;
}
关于 被0除 异常的捕获!
默认情况下,系统屏蔽了浮点数/整数运算时的异常错误,并以0或者无穷大表示结果,并不会产生异常。
这些数值计算异常列表如下:
_EM_INVALID
_EM_DENORMAL
_EM_ZERODIVIDE
_EM_OVERFLOW
_EM_UNDERFLOW
_EM_INEXACT
为了捕获上述异常,必须使用 _controlfp(...)/_control87(...) 运行库函数设置相关的屏蔽位,代码示例如下:
// ZeroDivide.cpp : By YangTze!
//
#include "stdafx.h"
#include <WINDOWS.H>
#include <STDIO.H>
#include <FLOAT.H>
void TestFunc()
{
int i = 888;
int j = 0;
__try {
i = i/j;
}
__except( GetExceptionCode() == EXCEPTION_INT_DIVIDE_BY_ZERO ? EXCEPTION_EXECUTE_HANDLER : EXCEPTION_CONTINUE_SEARCH ) {
MessageBox( NULL,"EXCEPTION_INT_DIVIDE_BY_ZERO!","Error!",MB_OK );
}
}
int _tmain(int argc, _TCHAR* argv[])
{
unsigned int nOldMask;
unsigned int nNewMask;
nOldMask = _controlfp( 0,0 );
nNewMask = ( ( nOldMask & ~_EM_ZERODIVIDE ) | ( _EM_ZERODIVIDE & _MCW_EM ) );
_controlfp( nNewMask,_MCW_EM );
TestFunc();
_controlfp( _CW_DEFAULT, 0xfffff );
return 0;
}
程序隐藏 之 运行时更改名字
当一个程序正在运行时,Windows 系统是不允许把它删除的,但在 Windows 2000/XP 中,当一个程序正在运行时,可以将它本身在相同磁盘分区内重命名和移动位置!
试想想:如果我们的程序一运行,就把自己移动位置并且换个名字,此时,Windows 任务管理器还显示的是原来的名字,嘿嘿,程序不见了(只有你知道哦)...
这种做法有什么用?嘿嘿,干坏事呗!
#include "stdafx.h"
#include <WINDOWS.H>
int _tmain(int argc, _TCHAR* argv[])
{
TCHAR szCurName[1024];
TCHAR szNewName[1024];
GetModuleFileName( NULL,szCurName,MAX_PATH );
_tcscpy( szNewName,szCurName );
_tcsupr( szNewName );
TCHAR *pPostfix = _tcsstr( szNewName,_T(".EXE") );
_tcscpy( pPostfix,_T("Renamed.EXE") );
MoveFile( szCurName,szNewName );
return 0;
}
汇编的魅力
HelloWorld.ASM
; #########################################################################
.386
.model flat, stdcall
option casemap :none ; case sensitive
; #########################################################################
include c:\masm32\include\windows.inc
include c:\masm32\include\user32.inc
include c:\masm32\include\kernel32.inc
includelib c:\masm32\lib\user32.lib
includelib c:\masm32\lib\kernel32.lib
; #########################################################################
.data
szHelloWorld db "Hello,World!",0
szTitle db "Haha...",0
.code
start:
invoke MessageBox,NULL,ADDR szHelloWorld,ADDR szTitle,MB_OK
invoke ExitProcess,0
end start
附注:随着各种各样高级语言开发平台的百舸争流,心中某种缺憾却越来越强烈,有一种浮砂筑高台的感觉。
用ITaskbarList接口操纵Windows任务栏程序按钮的状态
Step 1: 变量定义
class CXDlg : public CDialog
{
......
public:
typedef ITaskbarList *LPITaskbarList;
LPITaskbarList pTaskbar;
......
};
Step 2: 初始化 任务栏COM 对象
BOOL CXDlg::OnInitDialog()
{
......
// Initializes the Component Object Model(COM)
CoInitialize(0);
// We call below function since we only need to create one object
CoCreateInstance(
CLSID_TaskbarList,
0,
CLSCTX_INPROC_SERVER,
IID_ITaskbarList,
(void**)&pTaskbar
);
// Below function will initialize the taskbar list object
pTaskbar->HrInit();
......
}
Step 3: 使用:删除/显示 任务栏程序按钮
void CXDlg::OnBnClickedButtonHide()
{
pTaskbar->DeleteTab(this->GetSafeHwnd());
}
void CXDlg::OnBnClickedButtonShow()
{
pTaskbar->AddTab(this->GetSafeHwnd());
}