https://git.reactos.org/?p=reactos.git;a=commitdiff;h=e98e9000c7e67e8293628c82e8342a6fab69697e

commit e98e9000c7e67e8293628c82e8342a6fab69697e
Author:     Timo Kreuzer <timo.kreu...@reactos.org>
AuthorDate: Sat Oct 12 00:05:27 2024 +0300
Commit:     Timo Kreuzer <timo.kreu...@reactos.org>
CommitDate: Thu Jan 16 14:18:53 2025 +0200

    [UCRT] Make SEH blocks ReactOS PSEH compatible
---
 sdk/lib/ucrt/conio/cgets.cpp               |  1 +
 sdk/lib/ucrt/conio/cgetws.cpp              |  1 +
 sdk/lib/ucrt/conio/cputs.cpp               |  1 +
 sdk/lib/ucrt/conio/cputws.cpp              |  1 +
 sdk/lib/ucrt/conio/getch.cpp               |  5 +++++
 sdk/lib/ucrt/conio/getwch.cpp              |  4 ++++
 sdk/lib/ucrt/conio/pipe.cpp                |  2 ++
 sdk/lib/ucrt/conio/popen.cpp               |  2 ++
 sdk/lib/ucrt/env/getenv.cpp                |  3 +++
 sdk/lib/ucrt/env/putenv.cpp                |  1 +
 sdk/lib/ucrt/heap/debug_heap.cpp           | 14 ++++++++++++++
 sdk/lib/ucrt/heap/heapwalk.cpp             |  1 +
 sdk/lib/ucrt/heap/new_handler.cpp          |  2 ++
 sdk/lib/ucrt/inc/internal_shared.h         |  1 +
 sdk/lib/ucrt/locale/locale_refcounting.cpp |  1 +
 sdk/lib/ucrt/locale/wsetlocale.cpp         |  2 ++
 sdk/lib/ucrt/lowio/dup.cpp                 |  1 +
 sdk/lib/ucrt/lowio/dup2.cpp                |  1 +
 sdk/lib/ucrt/lowio/filelength.cpp          |  1 +
 sdk/lib/ucrt/lowio/ioinit.cpp              |  1 +
 sdk/lib/ucrt/lowio/locking.cpp             |  1 +
 sdk/lib/ucrt/lowio/lseek.cpp               |  1 +
 sdk/lib/ucrt/lowio/open.cpp                |  2 ++
 sdk/lib/ucrt/lowio/osfinfo.cpp             |  3 +++
 sdk/lib/ucrt/lowio/read.cpp                |  1 +
 sdk/lib/ucrt/lowio/setmode.cpp             |  1 +
 sdk/lib/ucrt/lowio/write.cpp               |  1 +
 sdk/lib/ucrt/mbstring/mbctype.cpp          |  1 +
 sdk/lib/ucrt/misc/dbgrptt.cpp              |  4 ++++
 sdk/lib/ucrt/misc/perror.cpp               |  1 +
 sdk/lib/ucrt/misc/signal.cpp               |  3 +++
 sdk/lib/ucrt/misc/terminate.cpp            |  1 +
 sdk/lib/ucrt/startup/exit.cpp              |  1 +
 sdk/lib/ucrt/startup/thread.cpp            |  1 +
 sdk/lib/ucrt/stdio/clearerr.cpp            |  1 +
 sdk/lib/ucrt/stdio/closeall.cpp            |  1 +
 sdk/lib/ucrt/stdio/fclose.cpp              |  1 +
 sdk/lib/ucrt/stdio/fdopen.cpp              |  1 +
 sdk/lib/ucrt/stdio/fgetc.cpp               |  1 +
 sdk/lib/ucrt/stdio/fgets.cpp               |  1 +
 sdk/lib/ucrt/stdio/fgetwc.cpp              |  1 +
 sdk/lib/ucrt/stdio/fopen.cpp               |  1 +
 sdk/lib/ucrt/stdio/fputc.cpp               |  1 +
 sdk/lib/ucrt/stdio/fputwc.cpp              |  1 +
 sdk/lib/ucrt/stdio/fread.cpp               |  1 +
 sdk/lib/ucrt/stdio/freopen.cpp             |  1 +
 sdk/lib/ucrt/stdio/fseek.cpp               |  1 +
 sdk/lib/ucrt/stdio/ftell.cpp               |  1 +
 sdk/lib/ucrt/stdio/gets.cpp                |  1 +
 sdk/lib/ucrt/stdio/getw.cpp                |  1 +
 sdk/lib/ucrt/stdio/putw.cpp                |  1 +
 sdk/lib/ucrt/stdio/rewind.cpp              |  1 +
 sdk/lib/ucrt/stdio/rmtmp.cpp               |  2 ++
 sdk/lib/ucrt/stdio/stream.cpp              |  1 +
 sdk/lib/ucrt/stdio/tempnam.cpp             |  1 +
 sdk/lib/ucrt/stdio/tmpfile.cpp             |  3 +++
 sdk/lib/ucrt/stdio/ungetc.cpp              |  1 +
 sdk/lib/ucrt/stdio/ungetwc.cpp             |  1 +
 sdk/lib/ucrt/time/tzset.cpp                |  3 +++
 59 files changed, 98 insertions(+)

diff --git a/sdk/lib/ucrt/conio/cgets.cpp b/sdk/lib/ucrt/conio/cgets.cpp
index fe3fffea718..7ec4ae6dcfe 100644
--- a/sdk/lib/ucrt/conio/cgets.cpp
+++ b/sdk/lib/ucrt/conio/cgets.cpp
@@ -91,6 +91,7 @@ extern "C" errno_t __cdecl _cgets_s(char* const 
source_string, size_t const size
     {
         __acrt_unlock(__acrt_conio_lock);
     }
+    __endtry
 
     *string++ = '\0';
 
diff --git a/sdk/lib/ucrt/conio/cgetws.cpp b/sdk/lib/ucrt/conio/cgetws.cpp
index 0149e82b2b4..3b40b722a3c 100644
--- a/sdk/lib/ucrt/conio/cgetws.cpp
+++ b/sdk/lib/ucrt/conio/cgetws.cpp
@@ -121,6 +121,7 @@ extern "C" errno_t __cdecl _cgetws_s(wchar_t* const 
string_buffer, size_t const
     {
         __acrt_unlock(__acrt_conio_lock);
     }
+    __endtry
 
     return retval;
 }
diff --git a/sdk/lib/ucrt/conio/cputs.cpp b/sdk/lib/ucrt/conio/cputs.cpp
index 58e312d37c6..96e2232b544 100644
--- a/sdk/lib/ucrt/conio/cputs.cpp
+++ b/sdk/lib/ucrt/conio/cputs.cpp
@@ -34,5 +34,6 @@ extern "C" int __cdecl _cputs(char const* const string)
     {
         __acrt_unlock(__acrt_conio_lock);
     }
+    __endtry
     return result;
 }
diff --git a/sdk/lib/ucrt/conio/cputws.cpp b/sdk/lib/ucrt/conio/cputws.cpp
index 2a16e4fac0a..fcede25a0cb 100644
--- a/sdk/lib/ucrt/conio/cputws.cpp
+++ b/sdk/lib/ucrt/conio/cputws.cpp
@@ -58,6 +58,7 @@ extern "C" int __cdecl _cputws(wchar_t const* string)
     {
         __acrt_unlock(__acrt_conio_lock);
     }
+    __endtry
 
     return result;
 }
diff --git a/sdk/lib/ucrt/conio/getch.cpp b/sdk/lib/ucrt/conio/getch.cpp
index 0a8699b8053..9850aaf0cbc 100644
--- a/sdk/lib/ucrt/conio/getch.cpp
+++ b/sdk/lib/ucrt/conio/getch.cpp
@@ -254,6 +254,7 @@ extern "C" int __cdecl _getch()
     {
         __acrt_unlock(__acrt_conio_lock);
     }
+    __endtry
     return result;
 }
 
@@ -269,6 +270,7 @@ extern "C" int __cdecl _getche()
     {
         __acrt_unlock(__acrt_conio_lock);
     }
+    __endtry
     return result;
 }
 
@@ -353,6 +355,7 @@ extern "C" int __cdecl _getch_nolock()
         // Restore the previous console mode:
         __dcrt_set_input_console_mode(old_console_mode);
     }
+    __endtry
     return result;
 }
 
@@ -394,6 +397,7 @@ extern "C" int __cdecl _kbhit()
     {
         __acrt_unlock(__acrt_conio_lock);
     }
+    __endtry
     return result;
 }
 
@@ -472,6 +476,7 @@ extern "C" int __cdecl _ungetch(int const c)
     {
         __acrt_unlock(__acrt_conio_lock);
     }
+    __endtry
     return result;
 }
 
diff --git a/sdk/lib/ucrt/conio/getwch.cpp b/sdk/lib/ucrt/conio/getwch.cpp
index cfc0a8ab7ac..f8fe8dd1a36 100644
--- a/sdk/lib/ucrt/conio/getwch.cpp
+++ b/sdk/lib/ucrt/conio/getwch.cpp
@@ -51,6 +51,7 @@ extern "C" wint_t __cdecl _getwch()
     {
         __acrt_unlock(__acrt_conio_lock);
     }
+    __endtry
     return result;
 }
 
@@ -67,6 +68,7 @@ extern "C" wint_t __cdecl _getwche()
     {
         __acrt_unlock(__acrt_conio_lock);
     }
+    __endtry
     return result;
 }
 
@@ -140,6 +142,7 @@ extern "C" wint_t __cdecl _getwch_nolock()
         // Restore the previous console mode:
         __dcrt_set_input_console_mode(old_console_mode);
     }
+    __endtry
     return result;
 }
 
@@ -185,6 +188,7 @@ extern "C" wint_t __cdecl _ungetwch(wint_t const c)
     {
         __acrt_unlock(__acrt_conio_lock);
     }
+    __endtry
     return result;
 }
 
diff --git a/sdk/lib/ucrt/conio/pipe.cpp b/sdk/lib/ucrt/conio/pipe.cpp
index 17bb5b0ee83..33b5ffd4b69 100644
--- a/sdk/lib/ucrt/conio/pipe.cpp
+++ b/sdk/lib/ucrt/conio/pipe.cpp
@@ -61,6 +61,7 @@ extern "C" int __cdecl _pipe(int* const phandles, unsigned 
const psize, int cons
     {
         __acrt_lowio_unlock_fh(crt_read_handle);
     }
+    __endtry
 
     // Create the CRT write handle for the pipe:
     int const crt_write_handle = _alloc_osfhnd();
@@ -84,6 +85,7 @@ extern "C" int __cdecl _pipe(int* const phandles, unsigned 
const psize, int cons
     {
         __acrt_lowio_unlock_fh(crt_write_handle);
     }
+    __endtry
 
     // Figure out which textmode the file gets:
     int fmode = 0;
diff --git a/sdk/lib/ucrt/conio/popen.cpp b/sdk/lib/ucrt/conio/popen.cpp
index 77d73495530..f1a524cfae4 100644
--- a/sdk/lib/ucrt/conio/popen.cpp
+++ b/sdk/lib/ucrt/conio/popen.cpp
@@ -400,6 +400,7 @@ static FILE* __cdecl common_popen(
     {
         __acrt_unlock(__acrt_popen_lock);
     }
+    __endtry
 
     return return_value;
 }
@@ -483,6 +484,7 @@ extern "C" int __cdecl _pclose(FILE* const stream)
     {
         __acrt_unlock(__acrt_popen_lock);
     }
+    __endtry
 
     return return_value;
 }
diff --git a/sdk/lib/ucrt/env/getenv.cpp b/sdk/lib/ucrt/env/getenv.cpp
index 5e9c24894ef..05faf989d6a 100644
--- a/sdk/lib/ucrt/env/getenv.cpp
+++ b/sdk/lib/ucrt/env/getenv.cpp
@@ -76,6 +76,7 @@ static Character* __cdecl common_getenv(Character const* 
const name) throw()
     {
         __acrt_unlock(__acrt_environment_lock);
     }
+    __endtry
     
     return result;
 }
@@ -160,6 +161,7 @@ static errno_t __cdecl common_getenv_s(
     {
         __acrt_unlock(__acrt_environment_lock);
     }
+    __endtry
     
     return status;
 }
@@ -275,6 +277,7 @@ static errno_t __cdecl common_dupenv_s(
     {
         __acrt_unlock(__acrt_environment_lock);
     }
+    __endtry
     
     return status;
 }
diff --git a/sdk/lib/ucrt/env/putenv.cpp b/sdk/lib/ucrt/env/putenv.cpp
index 0c8a03df005..09e504eed39 100644
--- a/sdk/lib/ucrt/env/putenv.cpp
+++ b/sdk/lib/ucrt/env/putenv.cpp
@@ -212,6 +212,7 @@ static int __cdecl common_putenv(
     {
         __acrt_unlock(__acrt_environment_lock);
     }
+    __endtry
 
     return status;
 }
diff --git a/sdk/lib/ucrt/heap/debug_heap.cpp b/sdk/lib/ucrt/heap/debug_heap.cpp
index 0a8841e0c5e..0c3f9d0153a 100644
--- a/sdk/lib/ucrt/heap/debug_heap.cpp
+++ b/sdk/lib/ucrt/heap/debug_heap.cpp
@@ -241,6 +241,7 @@ static bool __cdecl is_bad_read_pointer(void const* const 
p, size_t const size)
     {
         return true;
     }
+    __endtry
 
     return false;
 }
@@ -285,6 +286,7 @@ static void __cdecl validate_heap_if_required_nolock() 
throw()
     {
         heap_validation_pending = false;
     }
+    __endtry
 
     __acrt_check_counter = 0;
 }
@@ -431,6 +433,7 @@ static void* __cdecl heap_alloc_dbg_internal(
     {
         __acrt_unlock(__acrt_heap_lock);
     }
+    __endtry
 
     return block;
 }
@@ -763,6 +766,7 @@ extern "C" __declspec(noinline) void* __cdecl _realloc_dbg(
     {
         __acrt_unlock(__acrt_heap_lock);
     }
+    __endtry
 
     return new_block;
 }
@@ -835,6 +839,7 @@ extern "C" __declspec(noinline) void* __cdecl _expand_dbg(
     {
         __acrt_unlock(__acrt_heap_lock);
     }
+    __endtry
 
     return new_block;
 }
@@ -1035,6 +1040,7 @@ extern "C" __declspec(noinline) void __cdecl 
_free_dbg(void* const block, int co
     {
         __acrt_unlock(__acrt_heap_lock);
     }
+    __endtry
 }
 
 
@@ -1070,6 +1076,7 @@ extern "C" __declspec(noinline) size_t __cdecl 
_msize_dbg(void* const block, int
     {
         __acrt_unlock(__acrt_heap_lock);
     }
+    __endtry
 
     return size;
 }
@@ -1115,6 +1122,7 @@ extern "C" void __cdecl _CrtSetDbgBlockType(
     {
         __acrt_unlock(__acrt_heap_lock);
     }
+    __endtry
 }
 
 
@@ -1301,6 +1309,7 @@ extern "C" int __cdecl _CrtCheckMemory()
     {
         __acrt_unlock(__acrt_heap_lock);
     }
+    __endtry
 
     return all_okay ? TRUE : FALSE;
 }
@@ -1344,6 +1353,7 @@ extern "C" int __cdecl _CrtSetDbgFlag(int const new_bits)
     {
         __acrt_unlock(__acrt_heap_lock);
     }
+    __endtry
 
     return old_bits;
 }
@@ -1374,6 +1384,7 @@ extern "C" void __cdecl _CrtDoForAllClientObjects(
     {
         __acrt_unlock(__acrt_heap_lock);
     }
+    __endtry
 }
 
 
@@ -1469,6 +1480,7 @@ extern "C" int __cdecl _CrtIsMemoryBlock(
     {
         __acrt_unlock(__acrt_heap_lock);
     }
+    __endtry
 
     return result;
 }
@@ -1547,6 +1559,7 @@ extern "C" void __cdecl _CrtMemCheckpoint(_CrtMemState* 
const state)
     {
         __acrt_unlock(__acrt_heap_lock);
     }
+    __endtry
 }
 
 
@@ -1701,6 +1714,7 @@ extern "C" void __cdecl 
_CrtMemDumpAllObjectsSince(_CrtMemState const* const sta
     {
         __acrt_unlock(__acrt_heap_lock);
     }
+    __endtry
 
     _RPT0(_CRT_WARN, "Object dump complete.\n");
 }
diff --git a/sdk/lib/ucrt/heap/heapwalk.cpp b/sdk/lib/ucrt/heap/heapwalk.cpp
index dfaf91181ed..27b6745beb7 100644
--- a/sdk/lib/ucrt/heap/heapwalk.cpp
+++ b/sdk/lib/ucrt/heap/heapwalk.cpp
@@ -28,6 +28,7 @@ static int __cdecl try_walk(PROCESS_HEAP_ENTRY* const 
win32_entry) throw()
     {
         return _HEAPBADNODE;
     }
+    __endtry
 }
 
 // Walks the heap, returning information on one entry at a time.  If there are
diff --git a/sdk/lib/ucrt/heap/new_handler.cpp 
b/sdk/lib/ucrt/heap/new_handler.cpp
index a0866eeb914..801da85897a 100644
--- a/sdk/lib/ucrt/heap/new_handler.cpp
+++ b/sdk/lib/ucrt/heap/new_handler.cpp
@@ -35,6 +35,7 @@ _PNH __cdecl _set_new_handler(_PNH new_handler)
     {
         __acrt_unlock(__acrt_heap_lock);
     }
+    __endtry
 
     return result;
 }
@@ -65,6 +66,7 @@ _PNH __cdecl _query_new_handler()
     {
         __acrt_unlock(__acrt_heap_lock);
     }
+    __endtry
 
     return result;
 }
diff --git a/sdk/lib/ucrt/inc/internal_shared.h 
b/sdk/lib/ucrt/inc/internal_shared.h
index a5f50f0f681..d4234e7cdf7 100644
--- a/sdk/lib/ucrt/inc/internal_shared.h
+++ b/sdk/lib/ucrt/inc/internal_shared.h
@@ -158,6 +158,7 @@ struct __crt_seh_guarded_call
         {
             cleanup();
         }
+        __endtry
     }
 };
 
diff --git a/sdk/lib/ucrt/locale/locale_refcounting.cpp 
b/sdk/lib/ucrt/locale/locale_refcounting.cpp
index c949b2036c7..b9731136f47 100644
--- a/sdk/lib/ucrt/locale/locale_refcounting.cpp
+++ b/sdk/lib/ucrt/locale/locale_refcounting.cpp
@@ -280,6 +280,7 @@ extern "C" __crt_locale_data* __cdecl 
__acrt_update_thread_locale_data()
         {
             __acrt_unlock(__acrt_locale_lock);
         }
+        __endtry
     }
     else
     {
diff --git a/sdk/lib/ucrt/locale/wsetlocale.cpp 
b/sdk/lib/ucrt/locale/wsetlocale.cpp
index da3b6d834f6..f7b309dab71 100644
--- a/sdk/lib/ucrt/locale/wsetlocale.cpp
+++ b/sdk/lib/ucrt/locale/wsetlocale.cpp
@@ -168,6 +168,7 @@ void __cdecl _free_locale(
         {
             __acrt_unlock(__acrt_multibyte_cp_lock);
         }
+        __endtry
 
         if (plocinfo->locinfo != nullptr)
         {
@@ -191,6 +192,7 @@ void __cdecl _free_locale(
             {
                 __acrt_unlock(__acrt_locale_lock);
             }
+            __endtry
         }
 
         _free_crt(plocinfo);
diff --git a/sdk/lib/ucrt/lowio/dup.cpp b/sdk/lib/ucrt/lowio/dup.cpp
index dc170b62f49..0bea1ae87ad 100644
--- a/sdk/lib/ucrt/lowio/dup.cpp
+++ b/sdk/lib/ucrt/lowio/dup.cpp
@@ -72,6 +72,7 @@ static int __cdecl _dup_nolock_internal(int const fh, 
__crt_cached_ptd_host& ptd
 
         __acrt_lowio_unlock_fh(new_fh);
     }
+    __endtry
     return return_value;
 }
 
diff --git a/sdk/lib/ucrt/lowio/dup2.cpp b/sdk/lib/ucrt/lowio/dup2.cpp
index 1b38c7c6b7b..453bd9b5614 100644
--- a/sdk/lib/ucrt/lowio/dup2.cpp
+++ b/sdk/lib/ucrt/lowio/dup2.cpp
@@ -105,6 +105,7 @@ static int __cdecl _dup2_internal(int const source_fh, int 
const target_fh, __cr
         __acrt_lowio_unlock_fh(source_fh);
         __acrt_lowio_unlock_fh(target_fh);
     }
+    __endtry
     return result;
 }
 
diff --git a/sdk/lib/ucrt/lowio/filelength.cpp 
b/sdk/lib/ucrt/lowio/filelength.cpp
index 595b8906ca8..f9b6577ac16 100644
--- a/sdk/lib/ucrt/lowio/filelength.cpp
+++ b/sdk/lib/ucrt/lowio/filelength.cpp
@@ -48,6 +48,7 @@ static Integer __cdecl common_filelength(int const fh) throw()
     {
         __acrt_lowio_unlock_fh(fh);
     }
+    __endtry
     return end;
 }
 
diff --git a/sdk/lib/ucrt/lowio/ioinit.cpp b/sdk/lib/ucrt/lowio/ioinit.cpp
index 5a3e858607c..452f4011339 100644
--- a/sdk/lib/ucrt/lowio/ioinit.cpp
+++ b/sdk/lib/ucrt/lowio/ioinit.cpp
@@ -242,6 +242,7 @@ extern "C" bool __cdecl __acrt_initialize_lowio()
     {
         __acrt_unlock(__acrt_lowio_index_lock);
     }
+    __endtry
 
     return result;
 }
diff --git a/sdk/lib/ucrt/lowio/locking.cpp b/sdk/lib/ucrt/lowio/locking.cpp
index 6f62a514da9..8f7dda92b51 100644
--- a/sdk/lib/ucrt/lowio/locking.cpp
+++ b/sdk/lib/ucrt/lowio/locking.cpp
@@ -116,5 +116,6 @@ extern "C" int __cdecl _locking(int const fh, int const 
locking_mode, long const
     {
         __acrt_lowio_unlock_fh(fh);
     }
+    __endtry
     return result;
 }
diff --git a/sdk/lib/ucrt/lowio/lseek.cpp b/sdk/lib/ucrt/lowio/lseek.cpp
index 35f41aec86b..e0bbd9f0967 100644
--- a/sdk/lib/ucrt/lowio/lseek.cpp
+++ b/sdk/lib/ucrt/lowio/lseek.cpp
@@ -123,6 +123,7 @@ static Integer __cdecl common_lseek(int const fh, Integer 
const offset, int cons
     {
         __acrt_lowio_unlock_fh(fh);
     }
+    __endtry
     return result;
 }
 
diff --git a/sdk/lib/ucrt/lowio/open.cpp b/sdk/lib/ucrt/lowio/open.cpp
index 941f331b91e..62e92d108c5 100644
--- a/sdk/lib/ucrt/lowio/open.cpp
+++ b/sdk/lib/ucrt/lowio/open.cpp
@@ -110,6 +110,7 @@ static int __cdecl common_open(
             __acrt_lowio_unlock_fh(fh);
         }
     }
+    __endtry
 
     if (error_code != 0)
     {
@@ -182,6 +183,7 @@ static errno_t __cdecl common_sopen_dispatch(
             __acrt_lowio_unlock_fh(*pfh);
         }
     }
+    __endtry
 
     if (error_code != 0)
     {
diff --git a/sdk/lib/ucrt/lowio/osfinfo.cpp b/sdk/lib/ucrt/lowio/osfinfo.cpp
index 89a866b9de3..e7687732f71 100644
--- a/sdk/lib/ucrt/lowio/osfinfo.cpp
+++ b/sdk/lib/ucrt/lowio/osfinfo.cpp
@@ -93,6 +93,7 @@ extern "C" errno_t __cdecl __acrt_lowio_ensure_fh_exists(int 
const fh)
     {
         __acrt_unlock(__acrt_lowio_index_lock);
     }
+    __endtry
 
     return status;
 }
@@ -183,6 +184,7 @@ extern "C" int __cdecl _alloc_osfhnd()
     {
         __acrt_unlock(__acrt_lowio_index_lock);
     }
+    __endtry
     return result;
 }
 
@@ -328,6 +330,7 @@ extern "C" int __cdecl _open_osfhandle(intptr_t const 
osfhandle, int const sourc
 
         __acrt_lowio_unlock_fh(fh);
     }
+    __endtry
     return fh;
 }
 
diff --git a/sdk/lib/ucrt/lowio/read.cpp b/sdk/lib/ucrt/lowio/read.cpp
index ee5a3cf2256..d9814556876 100644
--- a/sdk/lib/ucrt/lowio/read.cpp
+++ b/sdk/lib/ucrt/lowio/read.cpp
@@ -399,6 +399,7 @@ extern "C" int __cdecl _read(int const fh, void* const 
buffer, unsigned const bu
     {
         __acrt_lowio_unlock_fh(fh);
     }
+    __endtry
     return result;
 }
 
diff --git a/sdk/lib/ucrt/lowio/setmode.cpp b/sdk/lib/ucrt/lowio/setmode.cpp
index 414a4e5a705..5c465f4bc16 100644
--- a/sdk/lib/ucrt/lowio/setmode.cpp
+++ b/sdk/lib/ucrt/lowio/setmode.cpp
@@ -46,6 +46,7 @@ extern "C" int __cdecl _setmode(int const fh, int const mode)
     {
         __acrt_lowio_unlock_fh(fh);
     }
+    __endtry
     return result;
 }
 
diff --git a/sdk/lib/ucrt/lowio/write.cpp b/sdk/lib/ucrt/lowio/write.cpp
index 302d6de5f97..c251a53d4a5 100644
--- a/sdk/lib/ucrt/lowio/write.cpp
+++ b/sdk/lib/ucrt/lowio/write.cpp
@@ -68,6 +68,7 @@ extern "C" int __cdecl _write_internal(int const fh, void 
const* const buffer, u
     {
         __acrt_lowio_unlock_fh(fh);
     }
+    __endtry
     return result;
 }
 
diff --git a/sdk/lib/ucrt/mbstring/mbctype.cpp 
b/sdk/lib/ucrt/mbstring/mbctype.cpp
index 4d2f7f1e35f..c02db844d60 100644
--- a/sdk/lib/ucrt/mbstring/mbctype.cpp
+++ b/sdk/lib/ucrt/mbstring/mbctype.cpp
@@ -343,6 +343,7 @@ static __crt_multibyte_data* __cdecl 
update_thread_multibyte_data_internal(
             {
                 __acrt_unlock(__acrt_multibyte_cp_lock);
             }
+            __endtry
         }
         else
         {
diff --git a/sdk/lib/ucrt/misc/dbgrptt.cpp b/sdk/lib/ucrt/misc/dbgrptt.cpp
index f46f9488efa..ee3a23ef76a 100644
--- a/sdk/lib/ucrt/misc/dbgrptt.cpp
+++ b/sdk/lib/ucrt/misc/dbgrptt.cpp
@@ -380,6 +380,7 @@ int __cdecl _VCrtDbgReportA(
             {
                 __acrt_unlock(__acrt_debug_lock);
             }
+            __endtry
         }
 
         if (handled)
@@ -427,6 +428,7 @@ int __cdecl _VCrtDbgReportA(
             _InterlockedDecrement(&_crtAssertBusy);
         }
     }
+    __endtry
 
     return retval;
 }
@@ -602,6 +604,7 @@ int __cdecl _VCrtDbgReportW
             {
                 __acrt_unlock(__acrt_debug_lock);
             }
+            __endtry
         }
 
         if (handled)
@@ -680,6 +683,7 @@ int __cdecl _VCrtDbgReportW
             _InterlockedDecrement(&_crtAssertBusy);
         }
     }
+    __endtry
 
     return retval;
 }
diff --git a/sdk/lib/ucrt/misc/perror.cpp b/sdk/lib/ucrt/misc/perror.cpp
index 319649bbba9..2fa4c2e0465 100644
--- a/sdk/lib/ucrt/misc/perror.cpp
+++ b/sdk/lib/ucrt/misc/perror.cpp
@@ -62,6 +62,7 @@ static void __cdecl _perror_internal(char const* const 
user_prefix, __crt_cached
     {
         __acrt_lowio_unlock_fh( fh );
     }
+    __endtry
 }
 
 extern "C" void __cdecl perror(char const* const user_prefix)
diff --git a/sdk/lib/ucrt/misc/signal.cpp b/sdk/lib/ucrt/misc/signal.cpp
index 457e2b6504f..9be5453c6bc 100644
--- a/sdk/lib/ucrt/misc/signal.cpp
+++ b/sdk/lib/ucrt/misc/signal.cpp
@@ -195,6 +195,7 @@ static BOOL WINAPI ctrlevent_capture(DWORD const ctrl_type) 
throw()
     {
         __acrt_unlock(__acrt_signal_lock);
     }
+    __endtry
 
     // The default signal action leaves the event unhandled, so return false to
     // indicate such:
@@ -333,6 +334,7 @@ extern "C" __crt_signal_handler_t __cdecl signal(int 
signum, __crt_signal_handle
         {
             __acrt_unlock(__acrt_signal_lock);
         }
+        __endtry
 
         if (set_console_ctrl_error)
             return signal_failed(signum);
@@ -525,6 +527,7 @@ extern "C" int __cdecl raise(int const signum)
         if (action_is_global)
             __acrt_unlock(__acrt_signal_lock);
     }
+    __endtry
 
     if (return0)
         return 0;
diff --git a/sdk/lib/ucrt/misc/terminate.cpp b/sdk/lib/ucrt/misc/terminate.cpp
index b62854c7d64..10cd6504064 100644
--- a/sdk/lib/ucrt/misc/terminate.cpp
+++ b/sdk/lib/ucrt/misc/terminate.cpp
@@ -51,6 +51,7 @@ extern "C" void __cdecl terminate() throw()
         {
             ; // Deliberately do nothing
         }
+        __endtry
     }
 
     // If the terminate handler returned, faulted, or otherwise failed to end
diff --git a/sdk/lib/ucrt/startup/exit.cpp b/sdk/lib/ucrt/startup/exit.cpp
index cc680c175ff..0b3ee5ba814 100644
--- a/sdk/lib/ucrt/startup/exit.cpp
+++ b/sdk/lib/ucrt/startup/exit.cpp
@@ -228,6 +228,7 @@ static void __cdecl common_exit(
         {
             terminate();
         }
+        __endtry
 
         #ifndef CRTDLL
         // When the CRT is statically linked, we are responsible for executing
diff --git a/sdk/lib/ucrt/startup/thread.cpp b/sdk/lib/ucrt/startup/thread.cpp
index 00ce20d8b21..63884e65199 100644
--- a/sdk/lib/ucrt/startup/thread.cpp
+++ b/sdk/lib/ucrt/startup/thread.cpp
@@ -107,6 +107,7 @@ static unsigned long WINAPI thread_start(void* const 
parameter) throw()
         // Execution should never reach here:
         _exit(GetExceptionCode());
     }
+    __endtry
 
     // This return statement will never be reached.  All execution paths result
     // in the thread or process exiting.
diff --git a/sdk/lib/ucrt/stdio/clearerr.cpp b/sdk/lib/ucrt/stdio/clearerr.cpp
index d3a0afcdd77..8ce8a4f05d1 100644
--- a/sdk/lib/ucrt/stdio/clearerr.cpp
+++ b/sdk/lib/ucrt/stdio/clearerr.cpp
@@ -25,6 +25,7 @@ extern "C" errno_t __cdecl clearerr_s(FILE* const 
public_stream)
     {
         _unlock_file(stream.public_stream());
     }
+    __endtry
 
     return 0;
 }
diff --git a/sdk/lib/ucrt/stdio/closeall.cpp b/sdk/lib/ucrt/stdio/closeall.cpp
index cb537957fe2..c857169230d 100644
--- a/sdk/lib/ucrt/stdio/closeall.cpp
+++ b/sdk/lib/ucrt/stdio/closeall.cpp
@@ -39,6 +39,7 @@ extern "C" int __cdecl _fcloseall()
     {
         __acrt_unlock(__acrt_stdio_index_lock);
     }
+    __endtry
 
     return count;
 }
diff --git a/sdk/lib/ucrt/stdio/fclose.cpp b/sdk/lib/ucrt/stdio/fclose.cpp
index b4c120cb686..a538f4e187e 100644
--- a/sdk/lib/ucrt/stdio/fclose.cpp
+++ b/sdk/lib/ucrt/stdio/fclose.cpp
@@ -75,6 +75,7 @@ static int __cdecl _fclose_internal(FILE* const 
public_stream, __crt_cached_ptd_
     {
         _unlock_file(stream.public_stream());
     }
+    __endtry
 
     return return_value;
 }
diff --git a/sdk/lib/ucrt/stdio/fdopen.cpp b/sdk/lib/ucrt/stdio/fdopen.cpp
index 9edbf11d316..ab5062b78b3 100644
--- a/sdk/lib/ucrt/stdio/fdopen.cpp
+++ b/sdk/lib/ucrt/stdio/fdopen.cpp
@@ -53,6 +53,7 @@ static FILE* __cdecl common_fdopen(
     {
         stream.unlock();
     }
+    __endtry
 
     return stream.public_stream();
 }
diff --git a/sdk/lib/ucrt/stdio/fgetc.cpp b/sdk/lib/ucrt/stdio/fgetc.cpp
index ba589ec13cc..d18888ac482 100644
--- a/sdk/lib/ucrt/stdio/fgetc.cpp
+++ b/sdk/lib/ucrt/stdio/fgetc.cpp
@@ -55,6 +55,7 @@ extern "C" int __cdecl fgetc(FILE* const public_stream)
     {
         _unlock_file(stream.public_stream());
     }
+    __endtry
 
     return return_value;
 }
diff --git a/sdk/lib/ucrt/stdio/fgets.cpp b/sdk/lib/ucrt/stdio/fgets.cpp
index 332c9df3ad7..0f7d17a7738 100644
--- a/sdk/lib/ucrt/stdio/fgets.cpp
+++ b/sdk/lib/ucrt/stdio/fgets.cpp
@@ -75,6 +75,7 @@ static Character* __cdecl common_fgets(
     {
         _unlock_file(stream.public_stream());
     }
+    __endtry
 
     return return_value;
 }
diff --git a/sdk/lib/ucrt/stdio/fgetwc.cpp b/sdk/lib/ucrt/stdio/fgetwc.cpp
index bdf0efa5236..715410553f4 100644
--- a/sdk/lib/ucrt/stdio/fgetwc.cpp
+++ b/sdk/lib/ucrt/stdio/fgetwc.cpp
@@ -110,6 +110,7 @@ extern "C" wint_t __cdecl fgetwc(FILE* const stream)
     {
         _unlock_file(stream);
     }
+    __endtry
 
     return return_value;
 }
diff --git a/sdk/lib/ucrt/stdio/fopen.cpp b/sdk/lib/ucrt/stdio/fopen.cpp
index 2ca0eba7ba3..aace2ba7eae 100644
--- a/sdk/lib/ucrt/stdio/fopen.cpp
+++ b/sdk/lib/ucrt/stdio/fopen.cpp
@@ -60,6 +60,7 @@ static FILE* __cdecl common_fsopen(
 
         stream.unlock();
     }
+    __endtry
 
     return return_value;
 }
diff --git a/sdk/lib/ucrt/stdio/fputc.cpp b/sdk/lib/ucrt/stdio/fputc.cpp
index f4e3453f9be..e191289990c 100644
--- a/sdk/lib/ucrt/stdio/fputc.cpp
+++ b/sdk/lib/ucrt/stdio/fputc.cpp
@@ -60,6 +60,7 @@ static int __cdecl _fputc_internal(int const c, FILE* const 
stream, __crt_cached
     {
         _unlock_file(stream);
     }
+    __endtry
 
     return return_value;
 }
diff --git a/sdk/lib/ucrt/stdio/fputwc.cpp b/sdk/lib/ucrt/stdio/fputwc.cpp
index d5cfc5acef7..be357b2db67 100644
--- a/sdk/lib/ucrt/stdio/fputwc.cpp
+++ b/sdk/lib/ucrt/stdio/fputwc.cpp
@@ -110,6 +110,7 @@ static wint_t __cdecl _fputwc_internal(wchar_t const c, 
FILE* const stream, __cr
     {
         _unlock_file(stream);
     }
+    __endtry
 
     return return_value;
 }
diff --git a/sdk/lib/ucrt/stdio/fread.cpp b/sdk/lib/ucrt/stdio/fread.cpp
index 04326dbdbca..5e607ad567d 100644
--- a/sdk/lib/ucrt/stdio/fread.cpp
+++ b/sdk/lib/ucrt/stdio/fread.cpp
@@ -59,6 +59,7 @@ extern "C" size_t __cdecl fread_s(
     {
         _unlock_file(stream);
     }
+    __endtry
 
     return return_value;
 }
diff --git a/sdk/lib/ucrt/stdio/freopen.cpp b/sdk/lib/ucrt/stdio/freopen.cpp
index fe6bf2cc4c7..c8a3b26e366 100644
--- a/sdk/lib/ucrt/stdio/freopen.cpp
+++ b/sdk/lib/ucrt/stdio/freopen.cpp
@@ -79,6 +79,7 @@ static errno_t __cdecl common_freopen(
     {
         _unlock_file(stream.public_stream());
     }
+    __endtry
 
     return return_value;
 }
diff --git a/sdk/lib/ucrt/stdio/fseek.cpp b/sdk/lib/ucrt/stdio/fseek.cpp
index b635bc31cfb..4a6ea859e6c 100644
--- a/sdk/lib/ucrt/stdio/fseek.cpp
+++ b/sdk/lib/ucrt/stdio/fseek.cpp
@@ -194,6 +194,7 @@ static int __cdecl common_fseek(
     {
         _unlock_file(stream.public_stream());
     }
+    __endtry
 
     return return_value;
 }
diff --git a/sdk/lib/ucrt/stdio/ftell.cpp b/sdk/lib/ucrt/stdio/ftell.cpp
index b1b4321300b..e93c19c0884 100644
--- a/sdk/lib/ucrt/stdio/ftell.cpp
+++ b/sdk/lib/ucrt/stdio/ftell.cpp
@@ -362,6 +362,7 @@ static Integer __cdecl common_ftell(__crt_stdio_stream 
const stream, __crt_cache
     {
         _unlock_file(stream.public_stream());
     }
+    __endtry
 
     return return_value;
 }
diff --git a/sdk/lib/ucrt/stdio/gets.cpp b/sdk/lib/ucrt/stdio/gets.cpp
index b42ba038803..9a2436092e0 100644
--- a/sdk/lib/ucrt/stdio/gets.cpp
+++ b/sdk/lib/ucrt/stdio/gets.cpp
@@ -111,6 +111,7 @@ static Character* __cdecl common_gets(
     {
         _unlock_file(stdin);
     }
+    __endtry
 
     return return_value;
 }
diff --git a/sdk/lib/ucrt/stdio/getw.cpp b/sdk/lib/ucrt/stdio/getw.cpp
index 9c2a4fcc4d4..9f79e2a705f 100644
--- a/sdk/lib/ucrt/stdio/getw.cpp
+++ b/sdk/lib/ucrt/stdio/getw.cpp
@@ -43,6 +43,7 @@ extern "C" int __cdecl _getw(FILE* const stream)
     {
         _unlock_file(stream);
     }
+    __endtry
 
     return return_value;
 }
diff --git a/sdk/lib/ucrt/stdio/putw.cpp b/sdk/lib/ucrt/stdio/putw.cpp
index 3f264c8d838..301e8e52615 100644
--- a/sdk/lib/ucrt/stdio/putw.cpp
+++ b/sdk/lib/ucrt/stdio/putw.cpp
@@ -38,6 +38,7 @@ extern "C" int __cdecl _putw(int const value, FILE* const 
stream)
     {
         _unlock_file(stream);
     }
+    __endtry
 
     return return_value;
 }
diff --git a/sdk/lib/ucrt/stdio/rewind.cpp b/sdk/lib/ucrt/stdio/rewind.cpp
index 11fcb4ba81c..3cb1d26f419 100644
--- a/sdk/lib/ucrt/stdio/rewind.cpp
+++ b/sdk/lib/ucrt/stdio/rewind.cpp
@@ -51,6 +51,7 @@ static void __cdecl _rewind_internal(FILE* const 
public_stream, __crt_cached_ptd
     {
         _unlock_file(stream.public_stream());
     }
+    __endtry
 }
 
 extern "C" void __cdecl rewind(FILE* const public_stream)
diff --git a/sdk/lib/ucrt/stdio/rmtmp.cpp b/sdk/lib/ucrt/stdio/rmtmp.cpp
index 8a3a2229bbd..0aed77d32ab 100644
--- a/sdk/lib/ucrt/stdio/rmtmp.cpp
+++ b/sdk/lib/ucrt/stdio/rmtmp.cpp
@@ -58,12 +58,14 @@ extern "C" int __cdecl _rmtmp()
             {
                 _unlock_file(stream.public_stream());
             }
+            __endtry
         }
     }
     __finally
     {
         __acrt_unlock(__acrt_stdio_index_lock);
     }
+    __endtry
 
     return count;
 }
diff --git a/sdk/lib/ucrt/stdio/stream.cpp b/sdk/lib/ucrt/stdio/stream.cpp
index 69ea56a0f8e..713556fc0e8 100644
--- a/sdk/lib/ucrt/stdio/stream.cpp
+++ b/sdk/lib/ucrt/stdio/stream.cpp
@@ -89,6 +89,7 @@ __crt_stdio_stream __cdecl __acrt_stdio_allocate_stream() 
throw()
     {
         __acrt_unlock(__acrt_stdio_index_lock);
     }
+    __endtry
 
     return stream;
 }
diff --git a/sdk/lib/ucrt/stdio/tempnam.cpp b/sdk/lib/ucrt/stdio/tempnam.cpp
index dd213f16b26..f9041d46abb 100644
--- a/sdk/lib/ucrt/stdio/tempnam.cpp
+++ b/sdk/lib/ucrt/stdio/tempnam.cpp
@@ -172,6 +172,7 @@ static bool __cdecl compute_name(
     {
         __acrt_unlock(__acrt_tempnam_lock);
     }
+    __endtry
 
     return return_value;
 }
diff --git a/sdk/lib/ucrt/stdio/tmpfile.cpp b/sdk/lib/ucrt/stdio/tmpfile.cpp
index a58a8e48bfe..d0786c8007a 100644
--- a/sdk/lib/ucrt/stdio/tmpfile.cpp
+++ b/sdk/lib/ucrt/stdio/tmpfile.cpp
@@ -309,6 +309,7 @@ static errno_t common_tmpnam(
     {
         __acrt_unlock(__acrt_tempnam_lock);
     }
+    __endtry
 
     return return_value;
 }
@@ -408,6 +409,7 @@ static errno_t __cdecl common_tmpfile_nolock(_Out_ FILE** 
const stream, int cons
 
         local_stream.unlock();
     }
+    __endtry
 
     return result;
 }
@@ -435,6 +437,7 @@ static errno_t __cdecl common_tmpfile(_Out_ FILE** const 
stream, int const sh_fl
     {
         __acrt_unlock(__acrt_tempnam_lock);
     }
+    __endtry
 
     return return_value;
 }
diff --git a/sdk/lib/ucrt/stdio/ungetc.cpp b/sdk/lib/ucrt/stdio/ungetc.cpp
index 211216ec119..eabd8908941 100644
--- a/sdk/lib/ucrt/stdio/ungetc.cpp
+++ b/sdk/lib/ucrt/stdio/ungetc.cpp
@@ -28,6 +28,7 @@ extern "C" int __cdecl ungetc(int const c, FILE* const stream)
     {
         _unlock_file(stream);
     }
+    __endtry
 
     return return_value;
 }
diff --git a/sdk/lib/ucrt/stdio/ungetwc.cpp b/sdk/lib/ucrt/stdio/ungetwc.cpp
index 831ac543d2c..ceef236d5a7 100644
--- a/sdk/lib/ucrt/stdio/ungetwc.cpp
+++ b/sdk/lib/ucrt/stdio/ungetwc.cpp
@@ -28,6 +28,7 @@ extern "C" wint_t __cdecl ungetwc(wint_t const c, FILE* const 
stream)
     {
         _unlock_file(stream);
     }
+    __endtry
 
     return return_value;
 }
diff --git a/sdk/lib/ucrt/time/tzset.cpp b/sdk/lib/ucrt/time/tzset.cpp
index bd3e68931dc..2e7ae9254b3 100644
--- a/sdk/lib/ucrt/time/tzset.cpp
+++ b/sdk/lib/ucrt/time/tzset.cpp
@@ -381,6 +381,7 @@ extern "C" void __cdecl _tzset()
     {
         __acrt_unlock(__acrt_time_lock);
     }
+    __endtry
 }
 
 
@@ -413,6 +414,7 @@ extern "C" void __cdecl __tzset()
     {
         __acrt_unlock(__acrt_time_lock);
     }
+    __endtry
 }
 
 
@@ -707,6 +709,7 @@ extern "C" int __cdecl _isindst(tm* const tb)
     {
         __acrt_unlock(__acrt_time_lock);
     }
+    __endtry
 
     return retval;
 }

Reply via email to