Windows core programming Reading Notes

Source: Internet
Author: User

1.

It must be remembered that the existence time of the kernel object can be longer than the process for creating the object.

2.

Kernel objects can be protected by security descriptors. The security descriptor is used to describe who created the object, who can access or use the object, and who has no permission to access the object. Security descriptors are usually used when writing server applications. If you write client applications, you can ignore this feature of kernel objects.

3.

Handle createthread (

Psecurity_attributes PSA,

DWORD dwstacksize,

Pthread_start_routine pfnstartaddr,

Pvoid pvparam,

DWORD dwcreationflags,

Pdword pdwfhreadid );

 

Handee createfile (

Pctstr pszfilename,

DWORD dwdesiredaccebs,

DWORD dw1_mode,

Psecurity_attributes PSA,

DWORD dwcreationdistribution,

DWORD dwflagsandattnbutes,

Handee htemplatefile );

 

Handle createfilemapping (

Handle hfile,

Psecurity_attributes PSA,

DWORD flprotect,

DWORD dwmdximumsizchigh,

DWORD dwmaximumsizelow,

Pctstr pszname );

 

Handle createsemaphore (

Psecurity_attributes PSA,

Long linitialcount,

Long lmaximumcount,

Pctstr pszname );

Handle createwaitabletimer (

Pslcurity_attributes PSA,

Bool bmanualreset,

Pctstr pszname );

 

Handle createjobobject (

Psecurity_attributes PSA,

Pctstr pszname );

 

Another way to share objects by name is that a process does not call the C r e a t e * function, but calls one of the o p e * functions shown below:

Handle openmutex (

DWORD dwdesiredaccess,

Bool binherithandle,

Pctstr pszname );

 

Handle openevent (

DWORD dwdesiredaccess,

Bool binherithandle,

Pctstr pszname );

 

Handle opensemaphore (

DWORD dwdesiredaccess,

Bool binherithandle,

Pctstr pszname ),

 

Handle openwaitabletimer (

DWORD dwdesiredaccess,

Bool binherithandle,

Pctstr pszname );

 

Handle openfilemapping (

DWORD dwdesiredaccess,

Bool binherithandle,

Pctstr pszname );

 

Handle openjob0bject (

DWORD dwdesiredaccess,

Bool binherithandle,

Pctstr pszname );

 

4.

If a function is called to create a kernel object but the call fails, the returned handle value is usually 0 (n u L ). This occurs because the system memory is very short or security problems are encountered. However, when a few functions fail to run, the returned handle value is-1 (I n va l I D _ H a n d l e _ va L U E ). For example, if C r e a t e f I l e fails to open the specified file, then it returns I n va l I D _ H a n d l e _ va L U E, instead of returning n u L. Be cautious when viewing the function return values of the created kernel object. Note that only when the C r e a t e f I l e function is called, this value can be compared with I n va l I D _ H a n d l e _ va L U E.

5.

No matter how the kernel object is created, specify to the system that the operation on the object will be terminated by calling c l o s e h a n d l E:

 

Bool closehandle (handle hobj );

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.