From b6b6c9b15c34471fd3938bdb9715754f09f10e00 Mon Sep 17 00:00:00 2001 From: Vas Crabb Date: Thu, 13 Apr 2023 05:49:05 +1000 Subject: Allow loading PNG/JPEG/MS DIB bitmaps from Lua, and cleanup. Use VirtualAlloc rather than VirtualProtect on Windows to change page protection, as the latter can cause severe performance issues with some antivirus software. Added noexcept to lots of hash- and bitmap-related things, and added a little more error checking. Yes, I realise it will abort if an allocation fails while printing a log message, but if you get to that point, you're probably screwed already. --- src/osd/modules/lib/osdlib_win32.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src/osd/modules/lib/osdlib_win32.cpp') diff --git a/src/osd/modules/lib/osdlib_win32.cpp b/src/osd/modules/lib/osdlib_win32.cpp index 067fbd1224f..23e75bf9dc2 100644 --- a/src/osd/modules/lib/osdlib_win32.cpp +++ b/src/osd/modules/lib/osdlib_win32.cpp @@ -356,12 +356,12 @@ void virtual_memory_allocation::do_free(void *start, std::size_t size) bool virtual_memory_allocation::do_set_access(void *start, std::size_t size, unsigned access) { - DWORD p, o; + DWORD p; if (access & EXECUTE) p = (access & WRITE) ? PAGE_EXECUTE_READWRITE : (access & READ) ? PAGE_EXECUTE_READ : PAGE_EXECUTE; else p = (access & WRITE) ? PAGE_READWRITE : (access & READ) ? PAGE_READONLY : PAGE_NOACCESS; - return VirtualProtect(start, size, p, &o) != 0; + return VirtualAlloc(start, size, MEM_COMMIT, p) != nullptr; } -- cgit v1.2.3-70-g09d2