📄 exceptanti.cpp
字号:
/********************************************************************
Copyright (c) Beijing Feitian Technologies
http://www.FTSafe.com
File : ExceptAnti.cpp
Created: 2003/11/05
Author: yihai
Purpose: ?
Revision: ?
*********************************************************************/
// ExceptAnti.cpp : Defines the entry point for the console application.
//
#include "stdafx.h"
#include <Windows.h>
void Branch2_Func1();
void Branch2_Func2();
void Branch2_Func3();
void Branch1_Func1();
void Branch1_Func2();
void Branch1_Func3();
void FuncEntry();
#pragma optimize( "", off )
void Throw_Div0()
{
printf("(Throw_Div0)\n");
int i=0;
i /=i;
}
#pragma optimize( "", on )
void Throw_ErrIns()
{
printf("(Throw_ErrIns)\n");
__asm _emit 0x8d
__asm _emit 0xc0
}
void Throw_Addr0()
{
printf("(Throw_Addr0)\n");
char* p = (char*)NULL;
*p = (char)GetTickCount();
}
void Throw_Addr0_asm()
{
printf("(Throw_Addr0_asm)\n");
__asm xor eax,eax
__asm mov eax,[eax]
}
void Branch1_Func1()
{
printf("Branch1_Func1\n");
__try
{
Branch1_Func2();
}
__except(EXCEPTION_EXECUTE_HANDLER)
{
printf("catch exception Branch1_Func1\n");
Throw_Div0();
}
}
void Branch1_Func2()
{
printf("\tBranch1_Func2\n");
__try
{
Branch1_Func3();
}
__except(EXCEPTION_EXECUTE_HANDLER)
{
printf("\tcatch exception Branch1_Func2\n");
Throw_Addr0();
}
}
void Branch1_Func3()
{
printf("\t\tBranch1_Func3\n");
__try
{
Throw_ErrIns();
}
__except(EXCEPTION_EXECUTE_HANDLER)
{
printf("\t\tcatch exception Branch1_Func3\n");
Throw_Addr0_asm();
}
}
void Branch2_Func1()
{
printf("Branch2_Func1\n");
__try
{
Branch2_Func2();
}
__except(EXCEPTION_EXECUTE_HANDLER)
{
printf("catch exception Branch2_Func1\n");
Throw_Div0();
}
}
void Branch2_Func2()
{
printf("\tBranch2_Func2\n");
__try
{
Branch2_Func3();
}
__except(EXCEPTION_EXECUTE_HANDLER)
{
printf("\tcatch exception Branch2_Func2\n");
Throw_Addr0();
}
}
void Branch2_Func3()
{
printf("\t\tBranch2_Func3\n");
__try
{
Throw_ErrIns();
}
__except(EXCEPTION_EXECUTE_HANDLER)
{
printf("\t\tcatch exception Branch2_Func3\n");
printf("\t\tcall FuncEntry now\n");
FuncEntry();
}
}
void FuncEntry()
{
MessageBox(NULL,"Function is Normal",NULL,MB_OK);
}
int main(int argc, char* argv[])
{
__try
{
Branch1_Func1();
}
__except(EXCEPTION_EXECUTE_HANDLER)
{
Branch2_Func1();
}
return 0;
}
int APIENTRY WinMain(
IN HINSTANCE hInstance,
IN HINSTANCE hPrevInstance,
IN LPSTR lpCmdLine,
IN int nShowCmd
)
{
return main(0,0);
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -