Detect madexcept inside an Delphi Application

delphi, madexcept

Solution

If you use `madexcept` with a Delphi application, there should be a resource entry: `MAD->EXCEPT` in that executable.

To test an external application:

var
  h: HMODULE;

  h := LoadLibraryEx('c:\foo\bar.exe', 0, LOAD_LIBRARY_AS_DATAFILE);
  if h <> 0 then
  begin
    if FindResource(h, 'EXCEPT', 'MAD') <> 0 then 
      ShowMessage('madexcept Found!');
    FreeLibrary(h);
  end;

To test inside your own application:

if FindResource(HInstance, 'EXCEPT', 'MAD') <> 0 then 
  ShowMessage('madexcept Found!');

Note that whis however will NOT tell you what options `madexcept` uses. for example there could be an exception filter set to filter access violation exceptions, or a setting that will NOT check frozen threads etc...

Problem

can I detect wheather madexcept is used inside an delphi application by analyzing the exe file only ? Is there a simple way by adding a few lines of code to my application and inform the final exe file user if madshi madexcept has been used or not

Original source