Skip to content

Commit 51b7169

Browse files
committed
shadercompile: Backport error checking from CS:GO
1 parent 633d9ca commit 51b7169

File tree

1 file changed

+12
-1
lines changed

1 file changed

+12
-1
lines changed

utils/shadercompile/subprocess.cpp

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,11 @@ void *SubProcessKernelObjects_Memory::Lock() {
9696
case WAIT_OBJECT_0: {
9797
m_pLockData = MapViewOfFile(m_pObjs->m_hMemorySection,
9898
FILE_MAP_ALL_ACCESS, 0, 0, 0);
99+
if (!m_pLockData) {
100+
// dimhotepus: CS:GO backport.
101+
Warning("MapViewOfFile failed with error 0x%x\n",
102+
HRESULT_FROM_WIN32(GetLastError()));
103+
}
99104

100105
if (m_pLockData && *(const DWORD *)m_pLockData != m_pObjs->m_dwCookie) {
101106
// Yes, this is our turn, set our cookie in that memory segment
@@ -143,7 +148,13 @@ BOOL SubProcessKernelObjects_Memory::Unlock() {
143148
// Assert that the memory hasn't been spoiled
144149
Assert(m_pObjs->m_dwCookie == *(const DWORD *)m_pLockData);
145150

146-
UnmapViewOfFile(m_pLockData);
151+
DWORD rc = UnmapViewOfFile(m_pLockData);
152+
if (rc == 0) {
153+
// dimhotepus: CS:GO backport.
154+
Warning("UnmapViewOfFile failed with error 0x%x\n",
155+
HRESULT_FROM_WIN32(GetLastError()));
156+
}
157+
147158
m_pMemory = NULL;
148159
m_pLockData = NULL;
149160

0 commit comments

Comments
 (0)