What is the kernel object (3)

zhaozj2021-02-12  140

10:00 on July 7, 2004

carry on

1. Inheritance of the kernel object handle

When the parent process creates a kernel object, you must indicate to the system, it hopes that the handle of the object is an inherited handle. The parent process can use one or more kernel object handles, and the parent process can decide to generate a child process, give the child process to the access to the kernel object of the parent process.

Note: Although the internal object handle has inheritance, the kernel object itself does not have inheritance.

2. Create a handle that can inherit

The parent process simply specifies the binherithandle in the Security_Attributes structure, then passes the address of the structure to a specific CREATE function (created the function of the kernel object)

In the logo in the kernel object handle, it is used to indicate whether the handle has inheritance. If binherithandle is 1, then the flag is set to 1, otherwise 0;

Note: The inheritance of the object handle can only be used when generating a child process. If the parent process is ready to create a new kernel object with the inherited handle, then the sub-process that has been run will not inherit these new handles.

3. How to generate a sub-process

With CreateProcess (....) Where the parameters binheritHandles are set to TRUE, then the child process can inherit the inheritance handle of the parent process. At this point, the system creates a new and empty handle table for the child process because it sets binheritHandle to True, then it is necessary to traverse the handle table of the parent process, and for each item, system that it is found to contain valid inheritance handle. The project COPY is to the sentence handle table. The location of the handle of the project COPY to the child process will be identical to the position of the handle of the parent process. That is to say, in the parent process, the handle value identifies the kernel object is the same. In addition, the system also increases the use count of kernel objects.

Note: After the CreateProcess function returns, the parent process can immediately turn off the handle of the object without affecting the ability of the sub-process to operate the object.

4. Change the status of the handle

When the parent process creates a kernel object, then generate two child processes, the parent process only wants a child process to inherit the handle of the object. To change the inheritance flag of the kernel handle, you can call the setHandleinformation function.

Bool SetHandleinformation (Handle Hobject, DWORD DWMASK, DWORD DWFLAGS);

The HOBJECT parameter identifies a valid handle, dwMask tells the function to change which or selection of markers, can choose Handle_Flag_inherit Handle_Flag_Protect_FROM_CLOSE, dwflags indicates what value set to

to be continued........

转载请注明原文地址:https://www.9cbs.com/read-6560.html

New Post(0)