- 94 名前:デフォルトの名無しさん mailto:sage [2007/01/11(木) 22:55:38 ]
- >7にはこのコードをあげる。よい子は使っちゃダメだぞ。
typedef void (*throwFuncType)(); void dothrow_func(){ throw 300;} DWORD CALLBACK threadproc( void * ){ printf("BeginThread\n"); int i=0; try{ while(1) { i++; } }catch( int ){ printf("\n%d: catched exception.\n",i); } return 0; } int main(){ throwFuncType dothrow_ptr = dothrow_func; DWORD id; HANDLE hThread = CreateThread(NULL,0,threadproc,NULL,0,&id); char t[255]; fgets(t,200,stdin); CONTEXT context; context.ContextFlags = CONTEXT_CONTROL; SuspendThread( hThread); GetThreadContext(hThread, &context); context.Eip = (DWORD)dothrow_ptr; SetThreadContext(hThread, &context); ResumeThread( hThread); WaitForSingleObject(hThread,INFINITE); }
|

|