SSDT and ssdt

Source: Internet
Author: User
Tags ssdt

SSDT and ssdt

SSDT (system service dispatch table) system service dispatch table

SSPT (system service parameter table) system service parameter table

 

# PragmaPack (1) // SSDT table structure

Typedef structServiceDescriptorEntry {
Unsigned int* ServiceTableBase;
Unsigned int* ServiceCounterTableBase; // Used only in checked build
Unsigned intNumberOfServices;
Unsigned char* ParamTableBase;
} ServiceDescriptorTableEntry_t, * PServiceDescriptorTableEntry_t;

# PragmaPack ()

 

Function call Process Analysis:

(1) The user calls ReadFile in kenel32.dll, and kenel32.dll contains all packaging functions. kenel32.dll uses these packaging functions to check the parameter validity, convert everything to unicode, and then lock NTDLL. the NtReadFile function in dll.

(2) NTDLL. dll is a service packaging function. When the NtReadFile is called, these service packaging functions send the required Servcie ID to the EAX register, and send the pointer of the parameter stack frame to the EDX register, then the INT 2e interrupt is triggered. This command will switch the processor to the kernel mode. The processing program corresponding to INT 2e is established by windows NT executive (probably the kernel), which copies parameters from the user mode stack to the kernel mode stack. The base address of the stack frame is the value of the EDX register. This interrupt program is called KiSystemService ()

(3) when accessing the internal kernel, ntoskrnl.exe starts to work, And it performs the final call of the system service.User InterfaceProvided in the form of wrapper functions. These functions are all in a DLL called NTDLL. dll. NTOSKNL. EXE is initialized first. during initialization, an SSDT function table is created for different services provided by NTOSKRNL. Each item in the table specifies the address of the function required by the Service ID, each function code is in the kernel. Similarly, SSPT is also created.

 

The diagram is as follows:



The structure of the two tables is as follows:



 

Ssdt hook explanation:The ssdt hook is implemented by modifying the function address of the SSDT table. The following are the macros for the three related operations.

// Obtain the position of the function in SSDT. The following is a fixed calculation method.
# Define SYSTEMSERVICE (_ function) KeServiceDescriptorTable. ServiceTableBase [* (PULONG) (PUCHAR) _ function + 1)]


// Retrieve the index of the function, fixed mode
# Define SYSCALL_INDEX (_ Function) * (PULONG) (PUCHAR) _ Function + 1)


// Modify the function address
# Define HOOK_SYSCALL (_ Function, _ Hook, _ Orig) _ Orig = (PVOID) InterlockedExchange (PLONG) & m_Mapped [SYSCALL_INDEX (_ Function)], (LONG) _ Hook)

 

Other operations are written as drivers. The principle is to modify the SSDT table and replace the original functions with your own functions for process protection or other purposes.

 

Refer to: untitled ented Windows NT, line of defense magazine 2010.9, and line of defense driver tutorial.

If you want to learn more, you can refer to the above articles. You can find them on the Internet.

Related Article

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.