System Error 0x5: CreateFileMapping()

社会主义新天地 提交于 2019-12-01 16:10:06

Looks like you don't have enough privileges.

From MSDN:

Creating a file mapping object in the global namespace from a session other than session zero requires the SeCreateGlobalPrivilege privilege. For more information, see Kernel Object Namespaces.

...

The creation of a file-mapping object in the global namespace, by using CreateFileMapping, from a session other than session zero is a privileged operation. Because of this, an application running in an arbitrary Remote Desktop Session Host (RD Session Host) server session must have SeCreateGlobalPrivilege enabled in order to create a file-mapping object in the global namespace successfully. The privilege check is limited to the creation of file-mapping objects, and does not apply to opening existing ones. For example, if a service or the system creates a file-mapping object, any process running in any session can access that file-mapping object provided that the user has the necessary access.

Administrators, Services and Network Services have SeCreateGlobalPrivilege by default. You must remember though, that Windows7/Vista does not run everything as admin. So use "Start as administrator" to make "Global\" work for your application. If you're debugging, start Visual Studio as admin also.

To create global file mappings you need the SeCreateGlobalPrivilege privilege - do you have that? Access-denied implies this is a permissions problem, for sure.

The reference to terminal services in the documentation about global namespace is a bit misleading as it implies you only need to worry about this if you have an unusual situation.

In fact both IIS and system services run in session zero, and the first / only user to log on runs in session 1 - so you have to use Global namespace to communicate between IIS or a service and a normal program.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!