From: Yuxuan Shui <yshui@codeweavers.com> --- dlls/ntdll/Makefile.in | 2 ++ dlls/ntdll/initterm.c | 44 ++++++++++++++++++++++++++++++++++++++++ dlls/ntdll/initterm_e.c | 45 +++++++++++++++++++++++++++++++++++++++++ 3 files changed, 91 insertions(+) create mode 100644 dlls/ntdll/initterm.c create mode 100644 dlls/ntdll/initterm_e.c diff --git a/dlls/ntdll/Makefile.in b/dlls/ntdll/Makefile.in index 3c0dfa7a895..6649b638dcd 100644 --- a/dlls/ntdll/Makefile.in +++ b/dlls/ntdll/Makefile.in @@ -21,6 +21,8 @@ SOURCES = \ exception.c \ handletable.c \ heap.c \ + initterm.c \ + initterm_e.c \ large_int.c \ loader.c \ locale.c \ diff --git a/dlls/ntdll/initterm.c b/dlls/ntdll/initterm.c new file mode 100644 index 00000000000..93ba25b91d6 --- /dev/null +++ b/dlls/ntdll/initterm.c @@ -0,0 +1,44 @@ +/* + * _initterm fallback implementation + * + * Copyright 2025 Yuxuan Shui for CodeWeavers + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA + */ + +#include <process.h> +#include "minwindef.h" + +#include "wine/asm.h" + +#if 0 +#pragma makedep implib +#endif + +/* This is a fallback version of msvcrt's _initterm. Since _initterm is used in winecrt0, + * if the final object is linked with a version of msvcrt without the _initterm function, this + * version will be used. */ +void CDECL _initterm( _PVFV *start,_PVFV *end ) +{ + _PVFV *current = start; + + while (current < end) + { + if (*current) (**current)(); + current++; + } +} + +__ASM_GLOBAL_IMPORT(_initterm) diff --git a/dlls/ntdll/initterm_e.c b/dlls/ntdll/initterm_e.c new file mode 100644 index 00000000000..99d899c81cf --- /dev/null +++ b/dlls/ntdll/initterm_e.c @@ -0,0 +1,45 @@ +/* + * _initterm_e fallback implementation + * + * Copyright 2025 Yuxuan Shui for CodeWeavers + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA + */ + +#include <process.h> +#include "minwindef.h" + +#include "wine/asm.h" + +#if 0 +#pragma makedep implib +#endif + +/* This is a fallback version of msvcrt's _initterm_e. Since _initterm_e is used in winecrt0, + * if the final object is linked with a version of msvcrt without the _initterm_e function, this + * version will be used. */ +int CDECL _initterm_e( _PIFV *table, _PIFV *end ) +{ + int res = 0; + + while (!res && table < end) + { + if (*table) res = (**table)(); + table++; + } + return res; +} + +__ASM_GLOBAL_IMPORT(_initterm_e) -- GitLab https://gitlab.winehq.org/wine/wine/-/merge_requests/9265