Process protection--crossthreadflags Flag bit

Source: Internet
Author: User

Principle:

1. Set the thread crossthreadflags flag bit for all threads of the process to terminated or system.

Effect: Task Manager, Wsyscheck,icesword cannot end the process.

However, PCH unter can end a protected process. However, Pchunter cannot end a protected thread in a normal way, and must use the force end thread to end the thread.


Code:

VOID Setthreadflagtoterminatedbythreadid (ulong dwthreadid) {ulong Ulflagoffset; NTSTATUS status = status_unsuccessful; Pulong PFlag; Pethread Ethead; HANDLE Threadhandle;__try{threadhandle = (HANDLE) Dwthreadid;ulflagoffset = Getcrossthreadflagoffset ();//dprintf ("[ Protectprocess]getcrossthreadflagoffset:0x%08x\r\n ", ulflagoffset); status = Pslookupthreadbythreadid (threadHandle , &ethead); if (! Nt_success (status) {dprintf ("Pslookupthreadbythreadid errorid:0x%08x, tid:0x%08x\r\n", status, dwThreadID); return status;} dprintf ("ethread:0x%08x\n", ethead);p flag = (ulong*) ((Puchar) Ethead + ulflagoffset);//dprintf ("Ulflag address:0x%0 8X value:0x%08x\n ", PFlag, *pflag); *pflag |= ps_cross_thread_flags_terminated;dprintf (" New Ulflag address:0x%08x value : 0x%08x\n ", PFlag, *pflag);} __except (exception_execute_handler) {dprintf ("EXCEPTION on set thread Cross flags!"); return status;}}

RING3 Program and RING0 program:

http://download.csdn.net/detail/xiaocaiju/8192897


Process protection--crossthreadflags Flag bit

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.