include "stdafx.h"
#include <Windows.h>
#include <process.h>
#include <stdio.h>
#pragma comment (lib,"Kernel32.lib")
#pragma comment(lib,"user32")
typedef unsigned (__stdcall *threadfunc)(VOID *);
typedef struct _IO_STATUS_BLOCK
{
ULONG Status;
ULONG Information;
}
IO_STATUS_BLOCK, *PIO_STATUS_BLOCK;
void WINAPI APC_ROUTINES (ULONG_PTR dwParam);
HANDLE hEvent;
unsigned __stdcall ThreadStaticEntryPoint(void *param)
{
printf("Process_id=%d\n",GetCurrentProcessId());
printf("Thread_id=%d\n",GetCurrentThreadId());
//_asm{int 3};
QueueUserAPC((PAPCFUNC)APC_ROUTINES,GetCurrentThread(),NULL);
SleepEx(1000,TRUE);//让切片,在APC执行或者TIMEOUT返回
return 0;
}
void WINAPI APC_ROUTINES (ULONG_PTR dwParam)
{
//_asm{int 3};
MessageBoxA(NULL,"ASSSS","ASDFAS",MB_OK);
return;
}
int main(int argc,char* argv[])
{
int a=1000;
HANDLE handle=(HANDLE)_beginthreadex(NULL,0,ThreadStaticEntryPoint,(PVOID)&a,0,0);
WaitForSingleObject(handle,INFINITE);
CloseHandle(handle);
return 0;
}
QUEUSERAPC
最新推荐文章于 2017-08-16 23:31:00 发布