Checked in Petr Matousek's suspend test application.

svn path=/trunk/; revision=5184
This commit is contained in:
David Welch 2003-07-20 12:17:19 +00:00
parent ae921ed9bb
commit eccf821ef2
3 changed files with 98 additions and 0 deletions

View file

@ -0,0 +1,6 @@
*.o
*.d
*.exe
*.coff
*.sym
*.map

View file

@ -0,0 +1,19 @@
# $Id: Makefile,v 1.1 2003/07/20 12:17:19 dwelch Exp $
PATH_TO_TOP = ../../..
TARGET_NORC = yes
TARGET_TYPE = program
TARGET_APPTYPE = console
TARGET_NAME = suspend
TARGET_OBJECTS = $(TARGET_NAME).o
include $(PATH_TO_TOP)/rules.mak
include $(TOOLS_PATH)/helper.mk
# EOF

View file

@ -0,0 +1,73 @@
#define UNICODE
#define NTOS_MODE_USER
#include <ntos.h>
#include <windows.h>
#define DBG
#define NDEBUG
#include <debug.h>
static volatile DWORD z;
static volatile DWORD x=0;
static NTSTATUS STDCALL
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,
thread_1,
NULL,
0,
&thread_id);
if(!thread)
{
printf("Error: could not create thread ...\n");
ExitProcess(0);
}
Sleep(1000);
SuspendThread(thread);
for(;;)
{
printf("%x ", z);
Sleep(100);x++;
if(x>100 && GetThreadContext(thread, &context))
{
printf("EIP: %x\n", context.Eip);
printf("Calling resumethread ... \n");
ResumeThread(thread);
}
}
ExitProcess(0);
return(0);
}