⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 asmseh.cpp

📁 此为本书的配套光盘.本书不但由浅入深地讲解了软件保护技术
💻 CPP
字号:
/********************************************************************

	Copyright (c) Beijing Feitian Technologies
	http://www.FTSafe.com

	File :		asmseh.cpp	

	Created:	2003/11/05

	Author:		yihai
	
	Purpose:	?

	Revision:	?

*********************************************************************/
// asmseh.cpp : Defines the entry point for the application.
//

#include "stdafx.h"
#include <windows.h>

void Throw_Addr0();
void func1();
void func2();
void func3();

typedef struct _EXCEPTION_REGISTRATION_RECORD
{
    struct _EXCEPTION_REGISTRATION_RECORD * pNext;
    FARPROC                                 pfnHandler;
} EXCEPTION_REGISTRATION_RECORD, *PEXCEPTION_REGISTRATION_RECORD;

void Throw_Addr0()
{
	__asm
	{
		xor eax,eax
		mov eax,[eax]
	}	
}

void my_except1_handler()
{
	MessageBox(0,"catch exception1","exception",MB_OK);
	func2();
}

void my_except2_handler()
{
	MessageBox(0,"catch exception2","exception",MB_OK);
	__asm mov eax,fs:[0]
	__asm mov eax,[eax]
	__asm mov fs:[0],eax

	func3();
}

void op_fs()
{
	__asm push fs:[0]
	__asm mov  fs:[0],esp
	Throw_Addr0();
}

void func3()
{
	op_fs();
	MessageBox(0,"catch exception3","exception",MB_OK);
	ExitProcess(0);
}

void func2()
{
	PEXCEPTION_REGISTRATION_RECORD pNextRec=0;
	EXCEPTION_REGISTRATION_RECORD  eRec;

	__asm mov eax,fs:[0]
	__asm mov pNextRec,eax
	
	__asm lea eax,eRec
	__asm mov fs:[0],eax
	
	eRec.pNext = pNextRec;
	eRec.pfnHandler = (FARPROC)my_except2_handler;
	
	Throw_Addr0();
}

void func1()
{
	__asm
	{
		push offset my_except1_handler
		push fs:[0]
		mov  fs:[0],esp
	}
	Throw_Addr0();	
	ExitProcess(0);
}

int main(int argc,char* argv[])
{ 	
	__try
	{
		func1();
	}
	__except(EXCEPTION_EXECUTE_HANDLER)
	{
		printf("std handler");
	}	

	return 0;
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -