I'm creating a boost::interprocess::message_queue from a medium integrity process like so:
permissions p;
p.set_unrestricted();
message_queue queue(create_only, queueName, 1, sizeof(message_args), p);
And opening the queue from a low integrity process:
message_queue queue(open_only, queueName);
This fails in Windows with Access denied.
This is because the directory used to store the message_queue is in %ProgramData%
(%ProgramData%\boost_interprocess\
), for which low integrity processes do not have write permissions.
Is there any way to change the directory in which boost stores interprocess message queues? Is there any other way to make this work between a medium- or high-integrity process and a low-integrity process?
I'm using boost 1.55, on Windows 7, built with VC++ version v120 in Visual Studio 2013.
I did not try this myself but that seems to be possible according to boost documentation.
In Windows platforms, if "Common AppData" key is present in the registry, "boost_interprocess" folder is created in that directory (in XP usually "C:\Documents and Settings\All Users\Application Data" and in Vista "C:\ProgramData"). For Windows platforms without that registry key and Unix systems, shared memory is created in the system temporary files directory ("/tmp" or similar).
See link for more details.
I did search Windows registry for "Common AppData" key and found it under:
HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\Shell Folders
HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\User Shell Folders
HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Microsoft\Windows\CurrentVersion\Explorer\Shell Folders
HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Microsoft\Windows\CurrentVersion\Explorer\User Shell Folders
Common AppData
key points to %ProgramData%
so you can try to change it to something else or remove the key entirely and see if a default location has write permission for everybody.
EDIT: I found better alternative. Define new path using BOOST_INTERPROCESS_SHARED_DIR_PATH
before interprocess #includes
. (Added in boost 1.56)