NtSuspendProcess is an undocumented function isn't it? Undocumented functions are not supported in the API, and may suddenly vanish or be changed in some way by later updates/service packs or versions of windows, so I'm a little shy about using such if I want my stuff to keep working in later versions of Windows or after updates/service packs in case something does happen to NtSuspendProcess.
This is something I used in Windows 7 64 bit (don't know about Win 7 32 bit version) for my purposes to pause (suspend) the thread of another process via its PID that did not belong to my own process which is the same thing as pausing/suspending the process, you could also do your own process as well, never tried it in Windows 8 so don't know about there but it worked in Windows 7 64 bit, the not so pretty version is this:
Code: Select all
Structure thread32
size.l
use.l
idth.l
parentid.l
base.l
delta.l
flags.l
EndStructure
OpenLibrary(0,"kernel32.dll")
Procedure pause(pid)
thread.thread32
snap = CallFunction(0, "CreateToolhelp32Snapshot",4,0)
If snap
thread\size=SizeOf(thread32)
CallFunction(0,"Thread32First",snap,@thread)
If thread\parentid=pid
h=CallFunction(0,"OpenThread",2,0,thread\idth)
SuspendThread_(h)
CloseHandle_(h)
EndIf
While CallFunction(0,"Thread32Next",snap,@thread)
If thread\parentid=pid
h=CallFunction(0,"OpenThread",2,0,thread\idth)
SuspendThread_(h)
CloseHandle_(h)
EndIf
Wend
EndIf
EndProcedure
Procedure resume(pid)
thread.thread32
snap = CallFunction (0, "CreateToolhelp32Snapshot",4,0)
If snap
thread\size=SizeOf(thread32)
CallFunction(0,"Thread32First",snap,@thread)
If thread\parentid=pid
h=CallFunction(0,"OpenThread",2,0,thread\idth)
ResumeThread_(h)
CloseHandle_(h)
EndIf
While CallFunction(0,"Thread32Next",snap,@thread)
If thread\parentid=pid
h=CallFunction(0,"OpenThread",2,0,thread\idth)
ResumeThread_(h)
CloseHandle_(h)
EndIf
Wend
EndIf
EndProcedure
Can't find the pretty version right now but I'm sure you could restructure the code some to pretty it up a little.
The world and human nature was screwed up before I was born. It's not my fault and I'm just stuck with trying to deal with the mess left behind, so don't blame me.