[UCRT] Make SEH blocks ReactOS PSEH compatible

This commit is contained in:
Timo Kreuzer 2024-10-12 00:05:27 +03:00
parent 7bb9f6bf28
commit e98e9000c7
59 changed files with 98 additions and 0 deletions

View file

@ -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';

View file

@ -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;
}

View file

@ -34,5 +34,6 @@ extern "C" int __cdecl _cputs(char const* const string)
{
__acrt_unlock(__acrt_conio_lock);
}
__endtry
return result;
}

View file

@ -58,6 +58,7 @@ extern "C" int __cdecl _cputws(wchar_t const* string)
{
__acrt_unlock(__acrt_conio_lock);
}
__endtry
return result;
}

View file

@ -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;
}

View file

@ -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;
}

View file

@ -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;

View file

@ -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;
}

View file

@ -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;
}

View file

@ -212,6 +212,7 @@ static int __cdecl common_putenv(
{
__acrt_unlock(__acrt_environment_lock);
}
__endtry
return status;
}

View file

@ -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");
}

View file

@ -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

View file

@ -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;
}

View file

@ -158,6 +158,7 @@ struct __crt_seh_guarded_call
{
cleanup();
}
__endtry
}
};

View file

@ -280,6 +280,7 @@ extern "C" __crt_locale_data* __cdecl __acrt_update_thread_locale_data()
{
__acrt_unlock(__acrt_locale_lock);
}
__endtry
}
else
{

View file

@ -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);

View file

@ -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;
}

View file

@ -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;
}

View file

@ -48,6 +48,7 @@ static Integer __cdecl common_filelength(int const fh) throw()
{
__acrt_lowio_unlock_fh(fh);
}
__endtry
return end;
}

View file

@ -242,6 +242,7 @@ extern "C" bool __cdecl __acrt_initialize_lowio()
{
__acrt_unlock(__acrt_lowio_index_lock);
}
__endtry
return result;
}

View file

@ -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;
}

View file

@ -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;
}

View file

@ -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)
{

View file

@ -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;
}

View file

@ -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;
}

View file

@ -46,6 +46,7 @@ extern "C" int __cdecl _setmode(int const fh, int const mode)
{
__acrt_lowio_unlock_fh(fh);
}
__endtry
return result;
}

View file

@ -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;
}

View file

@ -343,6 +343,7 @@ static __crt_multibyte_data* __cdecl update_thread_multibyte_data_internal(
{
__acrt_unlock(__acrt_multibyte_cp_lock);
}
__endtry
}
else
{

View file

@ -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;
}

View file

@ -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)

View file

@ -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;

View file

@ -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

View file

@ -228,6 +228,7 @@ static void __cdecl common_exit(
{
terminate();
}
__endtry
#ifndef CRTDLL
// When the CRT is statically linked, we are responsible for executing

View file

@ -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.

View file

@ -25,6 +25,7 @@ extern "C" errno_t __cdecl clearerr_s(FILE* const public_stream)
{
_unlock_file(stream.public_stream());
}
__endtry
return 0;
}

View file

@ -39,6 +39,7 @@ extern "C" int __cdecl _fcloseall()
{
__acrt_unlock(__acrt_stdio_index_lock);
}
__endtry
return count;
}

View file

@ -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;
}

View file

@ -53,6 +53,7 @@ static FILE* __cdecl common_fdopen(
{
stream.unlock();
}
__endtry
return stream.public_stream();
}

View file

@ -55,6 +55,7 @@ extern "C" int __cdecl fgetc(FILE* const public_stream)
{
_unlock_file(stream.public_stream());
}
__endtry
return return_value;
}

View file

@ -75,6 +75,7 @@ static Character* __cdecl common_fgets(
{
_unlock_file(stream.public_stream());
}
__endtry
return return_value;
}

View file

@ -110,6 +110,7 @@ extern "C" wint_t __cdecl fgetwc(FILE* const stream)
{
_unlock_file(stream);
}
__endtry
return return_value;
}

View file

@ -60,6 +60,7 @@ static FILE* __cdecl common_fsopen(
stream.unlock();
}
__endtry
return return_value;
}

View file

@ -60,6 +60,7 @@ static int __cdecl _fputc_internal(int const c, FILE* const stream, __crt_cached
{
_unlock_file(stream);
}
__endtry
return return_value;
}

View file

@ -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;
}

View file

@ -59,6 +59,7 @@ extern "C" size_t __cdecl fread_s(
{
_unlock_file(stream);
}
__endtry
return return_value;
}

View file

@ -79,6 +79,7 @@ static errno_t __cdecl common_freopen(
{
_unlock_file(stream.public_stream());
}
__endtry
return return_value;
}

View file

@ -194,6 +194,7 @@ static int __cdecl common_fseek(
{
_unlock_file(stream.public_stream());
}
__endtry
return return_value;
}

View file

@ -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;
}

View file

@ -111,6 +111,7 @@ static Character* __cdecl common_gets(
{
_unlock_file(stdin);
}
__endtry
return return_value;
}

View file

@ -43,6 +43,7 @@ extern "C" int __cdecl _getw(FILE* const stream)
{
_unlock_file(stream);
}
__endtry
return return_value;
}

View file

@ -38,6 +38,7 @@ extern "C" int __cdecl _putw(int const value, FILE* const stream)
{
_unlock_file(stream);
}
__endtry
return return_value;
}

View file

@ -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)

View file

@ -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;
}

View file

@ -89,6 +89,7 @@ __crt_stdio_stream __cdecl __acrt_stdio_allocate_stream() throw()
{
__acrt_unlock(__acrt_stdio_index_lock);
}
__endtry
return stream;
}

View file

@ -172,6 +172,7 @@ static bool __cdecl compute_name(
{
__acrt_unlock(__acrt_tempnam_lock);
}
__endtry
return return_value;
}

View file

@ -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;
}

View file

@ -28,6 +28,7 @@ extern "C" int __cdecl ungetc(int const c, FILE* const stream)
{
_unlock_file(stream);
}
__endtry
return return_value;
}

View file

@ -28,6 +28,7 @@ extern "C" wint_t __cdecl ungetwc(wint_t const c, FILE* const stream)
{
_unlock_file(stream);
}
__endtry
return return_value;
}

View file

@ -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;
}