2004-10-21 04:48:46 +00:00
|
|
|
#define UNICODE
|
2005-11-20 18:54:55 +00:00
|
|
|
#define WIN32_NO_STATUS
|
2004-10-21 04:48:46 +00:00
|
|
|
#include <windows.h>
|
|
|
|
#include <stdio.h>
|
2005-11-14 23:44:15 +00:00
|
|
|
#define NTOS_MODE_USER
|
|
|
|
#include <ndk/ntndk.h>
|
2004-10-21 04:48:46 +00:00
|
|
|
|
|
|
|
#define NDEBUG
|
|
|
|
#include <debug.h>
|
|
|
|
|
|
|
|
static volatile DWORD z;
|
|
|
|
static volatile DWORD x=0;
|
|
|
|
|
2008-11-29 21:37:54 +00:00
|
|
|
static NTSTATUS WINAPI
|
2004-10-21 04:48:46 +00:00
|
|
|
thread_1(PVOID Param)
|
|
|
|
{
|
|
|
|
DWORD y=0;
|
|
|
|
|
|
|
|
for(;;)
|
|
|
|
{
|
|
|
|
z++;
|
|
|
|
if(x>50)
|
|
|
|
{
|
|
|
|
printf("I should have been suspended for years :-)\n");
|
|
|
|
Sleep(100);
|
|
|
|
x=0;y++;
|
|
|
|
if(y==3) ExitProcess(0);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
int
|
|
|
|
main(int argc, char *argv[])
|
|
|
|
{
|
|
|
|
HANDLE thread;
|
|
|
|
DWORD thread_id;
|
|
|
|
CONTEXT context;
|
|
|
|
|
|
|
|
context.ContextFlags=CONTEXT_CONTROL;
|
|
|
|
|
|
|
|
z=0;
|
|
|
|
thread=CreateThread(NULL,
|
|
|
|
0x1000,
|
|
|
|
(LPTHREAD_START_ROUTINE)thread_1,
|
|
|
|
NULL,
|
|
|
|
0,
|
|
|
|
&thread_id);
|
|
|
|
|
|
|
|
if(!thread)
|
|
|
|
{
|
|
|
|
printf("Error: could not create thread ...\n");
|
|
|
|
ExitProcess(0);
|
|
|
|
}
|
|
|
|
|
|
|
|
Sleep(1000);
|
|
|
|
|
|
|
|
SuspendThread(thread);
|
|
|
|
|
|
|
|
for(;;)
|
|
|
|
{
|
|
|
|
printf("%lx ", z);
|
|
|
|
Sleep(100);x++;
|
|
|
|
if(x>100 && GetThreadContext(thread, &context))
|
|
|
|
{
|
2010-06-25 01:37:58 +00:00
|
|
|
#if defined(_M_IX86)
|
2004-10-21 04:48:46 +00:00
|
|
|
printf("EIP: %lx\n", context.Eip);
|
2010-06-25 01:37:58 +00:00
|
|
|
#elif defined(_M_AMD64)
|
|
|
|
printf("RIP: %p\n", context.Rip);
|
|
|
|
#endif
|
2004-10-21 04:48:46 +00:00
|
|
|
printf("Calling resumethread ... \n");
|
|
|
|
ResumeThread(thread);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
ExitProcess(0);
|
|
|
|
return(0);
|
|
|
|
}
|