From 42bb82666356f04cdc3597f28131354dc1ceff53 Mon Sep 17 00:00:00 2001 From: cracyc Date: Sat, 11 May 2024 15:45:53 -0500 Subject: [PATCH] make pointer in callproc32w16 null if invalid and special case nul in openfile16 --- krnl386/file.c | 15 ++++++++++----- krnl386/thunk.c | 5 ++++- 2 files changed, 14 insertions(+), 6 deletions(-) diff --git a/krnl386/file.c b/krnl386/file.c index 2e330eee433..6b2935d1b63 100644 --- a/krnl386/file.c +++ b/krnl386/file.c @@ -804,11 +804,16 @@ HFILE16 WINAPI OpenFile16( LPCSTR name, OFSTRUCT *ofs, UINT16 mode ) } goto error; } - pathw = strdupAtoW(path); - found = SearchPathW( pathw, filename, NULL, sizeof(ofs->szPathName), - pathname, NULL ); - HeapFree( GetProcessHeap(), 0, path ); - HeapFree( GetProcessHeap(), 0, pathw ); + if (!wcsicmp(pathname, L"\\\\.\\nul")) + found = TRUE; + else + { + pathw = strdupAtoW(path); + found = SearchPathW( pathw, filename, NULL, sizeof(ofs->szPathName), + pathname, NULL ); + HeapFree( GetProcessHeap(), 0, path ); + HeapFree( GetProcessHeap(), 0, pathw ); + } if (!found) { RtlInitUnicodeString(&uni, pathname); diff --git a/krnl386/thunk.c b/krnl386/thunk.c index cf1e880661a..ce083fd0ae5 100644 --- a/krnl386/thunk.c +++ b/krnl386/thunk.c @@ -2531,7 +2531,10 @@ DWORD WINAPIV CallProc32W16( DWORD nrofargs, DWORD argconvmask, FARPROC proc32, { SEGPTR ptr = VA_ARG16( valist, SEGPTR ); /* pascal convention, have to reverse the arguments order */ - args[nrofargs - i - 1] = (DWORD)MapSL(ptr); + DWORD arg = (DWORD)MapSL(ptr); + if (!HIWORD(arg)) + arg = 0; + args[nrofargs - i - 1] = arg; TRACE("%08x(%p),",ptr,MapSL(ptr)); } else