From 67c1fcedea98536bff4073be32d417e97992c00b Mon Sep 17 00:00:00 2001 From: Tau Date: Sun, 9 Jun 2019 15:38:43 -0400 Subject: [PATCH] amex/nvram.c: Relax file sharing mode QoL hack for Chunithm support. --- amex/nvram.c | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/amex/nvram.c b/amex/nvram.c index bbade62..b869b3e 100644 --- a/amex/nvram.c +++ b/amex/nvram.c @@ -21,10 +21,25 @@ HRESULT nvram_open_file(HANDLE *out, const wchar_t *path, size_t size) *out = NULL; + /* This is somewhat sloppy: allow multiple processes to open the backing + store simultaneously. Multiple processes don't actually need to open + the backing store simultaneously, but it allows use to reuse the same + chunihook.dll for both chuniApp.exe and aimeReaderHost.exe, since a + backing store fd gets opened during process init and subsequentely + re-used for all device open operations on that NVRAM. + + We could defer the file open until it is actually needed instead, but + this requires some messy locking; naive solutions would be racy or would + effectively block all but one thread at a time in the process from + performing any I/O. + + Hopefully some day Chunithm will move to the new amdaemon-based system + architecture. */ + file = CreateFileW( path, GENERIC_READ | GENERIC_WRITE, - FILE_SHARE_READ, + FILE_SHARE_READ | FILE_SHARE_WRITE, NULL, OPEN_ALWAYS, FILE_ATTRIBUTE_NORMAL,