Hello,
I hesitated to put this post in the "beginners" section.
I am trying to set up a Win32 DLL to intercept all the various exceptions and errors that can occur, including in threads.
Currently I'm failing completely, and I think my inexperience with FPC is most likely the cause. Something that seems pretty basic to me like setting up an ErrorProc procedure, which is supposed to convert a call to RunError into an exception, doesn't work at all: the set up function is obviously not called and the program execution abruptly terminates. This seems to me to be a sign that I'm missing something as big as a house.
The minimal code is here. To me the call to TestExceptionRunError from the host application should produce an exception intercepted by the try except block, not terminate immediately. Am I making a mistake?
Library FPCDLL;
uses SysUtils;
procedure TestExceptionRunError; stdcall; export;
begin
try
RunError(123);
except
end;
end;
Procedure RunErrorToExcept (ErrNo : Longint; Address : CodePointer; Frame : Pointer);
begin
raise Exception.Create('Run error '+IntToStr(ErrNo));
end;
exports
TestExceptionRunError;
begin
ErrorProc:=@RunErrorToExcept;
end.
I call FPC compiler using the following FPC.cfg file for options.
-Twin32
-ve
-S2
-Sc
-Se
-Sg
-Sm
-Sd
-FeErrPrg.Log
-Ci-
-FuC:\FPC\3.2.2\units\i386-win32\fcl-base
-gl
-Rintel
-MDelphi
Could someone possibly give me an example of this kind of thing? I've seen that exception handling in a DLL is a boring topic, but I must not be the first one to break my teeth on this ?
Thanks in advance.