* win/systhrd.inc: added error checking in several places. Fail with code 226 if resources cannot be allocated, as Delphi does.
* win/syswin.inc, Dll_entry: Don't call DoneThread in PROCESS_DETACH callback, it is redundant because the main thread is finalized by FPC_DO_EXIT. SysReleaseThreadVars is still necessary. Also removed redundant assignments to return value.
git-svn-id: trunk@17992 -
- removed assembler from SysRelocateThreadVars: never actually worked, and this file is shared between different CPUs - not a proper place for assembler anyway.
- Obtain handle of kernel32.dll using GetModuleHandle, allows to get rid of UnloadLibrary call.
git-svn-id: trunk@17975 -
- Completely removed DLL_PROCESS_DETACH callback for executables. Reason: 1) it is executed after RTL has been shut down and called ExitProcess(), at which point it is really not a good idea to do the cleanup. 2) In executable (in contrast with DLL) it is just fine to leave remaining resources alone and let OS reclaim them.
* Using 'cvar' for _tls_used and _tls_index to get proper prefixing without $ifdef's.
git-svn-id: trunk@17943 -
- Do not call DLL hooks from exe callback handler.
- Do not call SysInitMultitheading from DLL_THREAD_ATTACH handler, it may only be called from the main thread. See comments in syswin.inc for details. Reverts rev. 17892.
+ To guarantee that SysInitMultithreading is called from the main thread, assume executables always multithreaded, just like DLLs are.
- Also removed all checks with MainThreadIdWin32, except checks for double DLL_PROCESS_DETACH in DLLs. They duplicate what Windows already does (the main thread invokes only PROCESS_ATTACH/PROCESS_DETACH and never THREAD_ATTACH/THREAD_DETACH callbacks).
* Attempts to avoid double initialization/finalization (once in callback, second time in normal control flow).
* Net result: webtbs/tw2423 and webtbs/tw15530 fixed, webtbs/tw3661 broken (because heaptrc does not support checking pointers in TLS area, and with 'always multithreaded' apps the Output varible moves into TLS).
git-svn-id: trunk@17938 -
Used to support TlsCallbacks.
Tls callback code added inside
ifdef FPC_USE_TLS_DIRECTORY.
NOTE: This code needs compiler changes also to work.
* win/systhread.inc:
Exec_Tls_callback: Callback for main executable.
Several new external variables:
FreePascal_TLS_callback, FreePascal_end_of_TLS_callback
need to be placed into .CRT$XL* section,
using name '.section .CRT$XLFPC __FPC_tls_callbacks'
extension to be provided by compiler change.
tls_callbacks : pointer; external name '___crt_xl_start__';
tls_data_start : pointer; external name '___tls_start__';
tls_data_end : pointer; external name '___tls_end__';
provided by linker script.
tls_index : DWord that will contain the automatic
TlsIndex generated by executable launch code (not used by
FPC code, but might be used by code from loaded objects).
_tls_used: TTlsdirectory record.
* win32/system.pp and win64/system.pp:
Code to force loading of _tls_used record.
git-svn-id: trunk@17893 -
This code is disabled by default, you need to complie the RTL
with option -dSUPPORT_WIN95.
2.4.2 release is already not usable on Windows 95 because
the kernel32 DLL function TryEnterCriticalSection is loaded
into system unit unconditionnally, while this function does
not exist in Winddows 95 kernel32.
This patch uses LoadLibrary/GetProcAddress coupple to check if
TryEnterCriticalSection exists and provides an alternate implementation
that will be used on Windows 95 systems only (Windows 98 kernel32
DLL does export TryEnterCriticalSection).
git-svn-id: trunk@16579 -
* Don't attempt to load shell32.dll, since every system with shell32.dll that exports SHGetFolderPath also has shfolder.dll present.
* Load shfolder.dll using a full path in order to prevent loading of malicious code by placing a same-named dll into program directory (Mantis #18185).
git-svn-id: trunk@16549 -
determine the length of a multi-byte character. The return values
are defined to be the same as those of POSIX' mblen: -1 =
invalid/incomplete sequence, 0 = #0, > 0 = length of sequence in
bytes.
+ default implementation for widestringmanager.codepointlengthproc
(assumes all code points have length 1) and Unix implementation
(based on mb(r)len); Windows implementation is still required
* replaced default implementation of
widestringmanager.CharLengthPCharProc with strlen() of the input
instead of an error (correct if all code points have length 1,
still needs Windows implementation)
+ implemented fpc_text_read_{wide,unicode}str() and
fpc_text_read_widechar() (mantis #18163); fpc_text_read_widechar()
uses the new widestringmanager.codepointlengthproc()
+ unicodestring support for readstr/writestr
* fixed declaration of fpc_Write_Text_UnicodeStr (unicodestring
instead of widestring parameter)
* extended test/twide*.pp tests to test the new/fixed functionality
git-svn-id: trunk@16533 -