Can't turn off leak detection when using madExceptPatch.exe

delphi package - automated exception handling
Post Reply
setzer0384
Posts: 7
Joined: Fri Apr 13, 2018 7:35 pm

Can't turn off leak detection when using madExceptPatch.exe

Post by setzer0384 »

Hi,
I am trying to use madExceptPatch.exe to activate madExcept in my executable.
In my Delphi project, the wizard is turned off (enable madExcept is not checked).
In the .mes file, i have ReportLeaks=0 (I assume this is the line that controls the leak check activation because when I uncheck "report ressource leaks" in the wizard this is the parameter that gets changed in the .mes file).

When I run the following, madExcept's exception handling becomes activated, however the leak checking also becomes activated and I do not understand why.

Code: Select all

madExceptPatch.exe PTest.exe ../../PTest.mes
I also tried the /enabled=1 option when using madExceptPatch.exe but I still end up with leak checking activated.

The madExcept and LeakChecking conditional are not present in my project.
In madExcept configuration, the 3 options are unchecked (adjust project uses clause, adjust compiler & linker options, adjust conditional defines).

In my dpr the first units used are

Code: Select all

  madExcept,
  madLinkDisAsm,
  madListHardware,
  madListProcesses,
  madListModules,
My .mes file starts with:

Code: Select all

[GeneralSettings]
MesVersion=4
HandleExceptions=0
LinkInCode=1
AppendMapFileToBinary=1
NoOwnMadExceptSettings=0
CheckFileCrc=0
CheckForFrozenMainThread=0
FreezeTimeout=60000
ReportLeaks=0
WindowsLogo=0
CrashOnBuffer=0
CrashOnUnderrun=0
My project is built directly in the IDE (Delphi 10.1 Berlin). I do not use MSbuild.

Can you help me with this issue please?

Thanks!
madshi
Site Admin
Posts: 10753
Joined: Sun Mar 21, 2004 5:25 pm

Re: Can't turn off leak detection when using madExceptPatch.

Post by madshi »

If you look at the resource section of the EXE file after madExceptPatch has run through (e.g. using the freeware "Resource Hacker"), there should be a resource "RCDATA\TMADEXCEPT". Is ReportLeaks set to True or False there?
setzer0384
Posts: 7
Joined: Fri Apr 13, 2018 7:35 pm

Re: Can't turn off leak detection when using madExceptPatch.

Post by setzer0384 »

Hi,
before running madExceptPatch, there is nothing about madExcept in RCData as expected.
After running madExceptPatch, I see Enabled = True and ReportLeaks = True. HandleExceptions=0 in my .mes file and madExcept's exception handling also becomes activated when I use madExceptPatch. This is strange.

Here is the content of RCData\TMADEXCEPT. I also included the whole .mes fle content.

Thanks

Code: Select all

object madExcept: TMadExcept
  Enabled = True
  NoSettings = False
  CheckFileCrc = True
  CheckFreeze = False
  FreezeTimeout = 60000
  ReportLeaks = True
  WindowsLogo = False
  CrashOnBuffer = False
  CrashOnUnderrun = False
  AutoSave = True
  AutoSaveIfNotSent = True
  AutoSend = False
  AutoSendBox = False
  AutoClip = False
  PauseThreads = False
  PlWaitBox = True
  AutoContinue = False
  AutoRestart = 0
  AutoClose = 0
  SendBtnVis = True
  SaveBtnVis = False
  PrintBtnVis = False
  ShowBtnVis = True
  ContinueBtnVis = True
  RestartBtnVis = True
  CloseBtnVis = True
  FocusedBtn = 0
  SendAssis = 'SendAssistant'
  SaveAssis = 'SaveAssistant'
  PrintAssis = 'PrintAssistant'
  AutoShowBugRep = False
  UglyBtns = False
  SendInBackgr = True
  UploadViaHttp = False
  HttpServer = ''
  HttpSsl = False
  HttpPort = 80
  HttpAccount = ''
  HttpPassword = ''
  FogBugz = False
  BugZilla = False
  Mantis = False
  BugTrAccount = ''
  BugTrPassword = ''
  BugTrProject = ''
  BugTrArea = ''
  BugTrAssignTo = ''
  MailAsSmtpServer = False
  MailAsSmtpClient = False
  SmtpServer = ''
  SmtpSsl = False
  SmtpTls = False
  SmtpPort = 25
  SmtpPort = 0
  SmtpAccount = ''
  SmtpPassword = ''
  MailViaMapi = False
  MailViaMailto = False
  MailAddr = ''
  AttachBugRep = True
  AttachBugRepFile = True
  DelBugRepFile = True
  BugRepSendAs = 'bugreport.txt'
  BugRepZip = ''
  ScrShotDepth = 8
  ScrShotAppOnly = False
  ScrShotSendAs = 'screenshot.png'
  ScrShotZip = ''
  AddAttachs = ''
  BugRepFile = 'bugreport.txt'
  AppendBugReps = True
  BugRepFileSize = 100000
  NoDupExcepts = True
  NoDupFreezes = True
  DupExceptDef = 1
  DupFreezeDef = 2
  ListThreads = True
  CpuRegs = True
  StackDump = True
  ShowDisAsm = True
  HideUglyItems = False
  ShowRelAddrs = True
  ShowRelLines = True
  FormatDisAsm = False
  LimitDisAsm = 5
  Plugins = 'modules|processes|hardware'
  F1Classes = 'EDBEditError'
  F1NoBugRep = True
  F1NoScrShot = True
  F1NoHandlers = True
  F1NoSuspend = True
  F1ShowCfg = 3
  F1Assis = ''
  F2Classes = ''
  F2NoBugRep = False
  F2NoScrShot = False
  F2NoHandlers = False
  F2NoSuspend = False
  F2ShowCfg = 0
  F2Assis = ''
  GnNoBugRep = False
  GnNoScrShot = False
  GnNoHandlers = False
  GnNoSuspend = False
  GnShowCfg = 0
  GnAssis = ''
  Assistant1 = 'SendAssistant|Send Assistant|ContactForm|DetailsForm|ScrShotForm'
  Assistant2 = 'SaveAssistant|Save Assistant|ContactForm|DetailsForm'
  Assistant3 = 'PrintAssistant|Print Assistant|ContactForm|DetailsForm'
  TitleBar = '%appname%'
  ExceptMsg = 'An error occurred in the application.'
  FrozenMsg = 'The application seems to be frozen.'
  BitFaultMsg = 'The file "%modname%" seems to be corrupt!'
  SendBtnTxt = 'send bug report'
  SaveBtnTxt = 'save bug report'
  PrintBtnTxt = 'print bug report'
  ShowBtnTxt = 'show bug report'
  ContinueBtnTxt = 'continue application'
  RestartBtnTxt = 'restart application'
  CloseBtnTxt = 'close application'
  OkBtnTxt = '&OK'
  DetailsBtnTxt = '&Details'
  PlWaitTitle = 'Information'
  PlWaitText = 'Please wait a moment...'
  BugTrTitle = '%appname%, %exceptMsg%'
  BugTrDescr = 'error details: '#13#10'%errorDetails%'
  MailSubj = 'bug report'
  MailBody = 'please find the bug report attached'
  SendBoxTitle = 'Sending bug report...'
  PrepAttMsg = 'Preparing attachments...'
  MxLookMsg = 'Searching for mail server...'
  ConnMsg = 'Connecting to server...'
  SendMailMsg = 'Sending mail...'
  FieldMsg = 'Setting fields...'
  SendAttMsg = 'Sending attachments...'
  SendFinalMsg = 'Finalizing...'
  SendFailMsg = 'Sorry, sending the bug report didn'#39't work.'
end
Content of the .mes

Code: Select all

[GeneralSettings]
MesVersion=4
HandleExceptions=0
LinkInCode=1
AppendMapFileToBinary=1
NoOwnMadExceptSettings=0
CheckFileCrc=0
CheckForFrozenMainThread=0
FreezeTimeout=60000
ReportLeaks=0
WindowsLogo=0
CrashOnBuffer=0
CrashOnUnderrun=0
AutomaticallySaveBugReport=1
AutoSaveBugReportIfNotSent=1
AutomaticallyMailBugReport=0
AutoMailProgressBox=0
CopyBugReportToClipboard=0
SuspendAllRunningThreads=0
ShowPleaseWaitBox=1
PleaseWaitIcon=plwait1
AutomaticallyContinueApplication=0
AutomaticallyRestartApplication=0
AutomaticallyCloseApplication=0
SendInBackground=1
SendHelper=196608
Send32Icon=send321
UploadViaHttp=0
HttpServer=
HttpSsl=0
HttpPort=0
HttpAccount=
HttpPassword=
UploadToFogBugz=0
UploadToBugZilla=0
UploadToMantis=0
BugTrackerAccount=
BugTrackerPassword=
BugTrackerProject=
BugTrackerArea=
BugTrackerAssignTo=
MailAsSmtpServer=0
MailAsSmtpClient=0
SmtpServer=
SmtpSsl=0
SmtpTls=0
SmtpPort=0
SmtpAccount=
SmtpPassword=
MailViaMapi=0
MailViaMailto=0
MailAddress=
BugReportFile=bugreport.txt
AttachBugReport=1
AttachBugReportFile=1
DeleteBugReportFile=1
BugReportSendAs=bugreport.txt
BugReportZip=
ScreenShotDepth=8
ScreenShotAppOnly=0
ScreenShotSendAs=screenshot.png
ScreenShotZip=
AdditionalAttachments=
AppendBugReports=1
BugReportFileSize=100000
DontSaveDuplicateExceptions=1
DontSaveDuplicateFreezings=1
DuplicateExceptionDefinition=1
DuplicateFreezeDefinition=2
ShowExceptionBox=1
OkBtnText=&OK
DetailsBtnText=&Details
PleaseWaitTitle=Information
PleaseWaitText=Please wait a moment...
BugTrackerTitle=%25appname%25, %25exceptMsg%25
BugTrackerDescr=error details: %0d%0a%25errorDetails%25
MailSubject=bug report
MailBody=please find the bug report attached
SendBoxTitle=Sending bug report...
PrepareAttachMsg=Preparing attachments...
MxLookupMsg=Searching for mail server...
ConnectMsg=Connecting to server...
SendMailMsg=Sending mail...
FieldsMsg=Setting fields...
SendAttachMsg=Sending attachments...
SendFinalizeMsg=Finalizing...
MailFailureMsg=Sorry, sending the bug report didn't work.
VersionVariable=
[ExceptionBox]
ShowButtonMailBugReport=1
ShowButtonSaveBugReport=0
ShowButtonPrintBugReport=0
ShowButtonShowBugReport=1
ShowButtonContinueApplication=1
ShowButtonRestartApplication=1
ShowButtonCloseApplication=1
IconButtonSendBugReport=send1
IconButtonSaveBugReport=save1
IconButtonPrintBugReport=print1
IconButtonShowBugReport=show1
IconButtonContinueApplication=continue1
IconButtonCantContinueApplication=cantContinue1
IconButtonRestartApplication=restart1
IconButtonCloseApplication=close1
FocusedButton=0
SendAssistant=SendAssistant
SaveAssistant=SaveAssistant
PrintAssistant=PrintAssistant
AutomaticallyShowBugReport=0
NoOwnerDrawButtons=0
BigExceptionIcon=big1
TitleBar=%25appname%25
ExceptionMessage=An error occurred in the application.
FrozenMessage=The application seems to be frozen.
BitFaultMsg=The file "%25modname%25" seems to be corrupt!
MailBugReportText=send bug report
SaveBugReportText=save bug report
PrintBugReportText=print bug report
ShowBugReportText=show bug report
ContinueApplicationText=continue application
RestartApplicationText=restart application
CloseApplicationText=close application
[BugReport]
ListThreads=1
ListModules=1
ListHardware=1
ShowCpuRegisters=1
ShowStackDump=1
Disassembly=1
HideUglyItems=0
ShowRelativeAddrs=1
ShowRelativeLines=1
FormatDisassembly=0
LimitDisassembly=5
EnabledPlugins=modules|processes|hardware
[Filters]
Filter1ExceptionClasses=EDBEditError
Filter1DontCreateBugReport=1
Filter1DontCreateScreenshot=1
Filter1DontSuspendThreads=1
Filter1DontCallHandlers=1
Filter1ShowBox=3
Filter1Assis=
Filter2ExceptionClasses=
Filter2DontCreateBugReport=0
Filter2DontCreateScreenshot=0
Filter2DontSuspendThreads=0
Filter2DontCallHandlers=0
Filter2ShowBox=0
Filter2Assis=
GeneralDontCreateBugReport=0
GeneralDontCreateScreenshot=0
GeneralDontSuspendThreads=0
GeneralDontCallHandlers=0
GeneralShowBox=0
GeneralAssis=
[Assistants]
Assistant1=SendAssistant|Send Assistant|ContactForm|DetailsForm|ScrShotForm
Assistant2=SaveAssistant|Save Assistant|ContactForm|DetailsForm
Assistant3=PrintAssistant|Print Assistant|ContactForm|DetailsForm
Forms1=TPF0%0eTMEContactForm%0bContactForm%07Message%0c%13%00%00%00Contact Information%08MinWidth%04%00%00%00%00%08OnAction%0c%1b%00%00%00madExcept.HandleContactForm%05Timer%04%00%00%00%00%00%09INVButton%0bContinueBtn%07Caption%0c%08%00%00%00Continue%07Enabled%09%0bNoOwnerDraw%08%07Visible%09%00%00%09INVButton%07SkipBtn%07Caption%0c%04%00%00%00Skip%07Enabled%08%0bNoOwnerDraw%08%07Visible%09%00%00%09INVButton%09CancelBtn%07Caption%0c%06%00%00%00Cancel%07Enabled%09%0bNoOwnerDraw%08%07Visible%09%00%00%08INVLabel%06Label1%07Caption%0c%0a%00%00%00your name:%07Enabled%09%07Spacing%04%00%00%00%00%00%00%07INVEdit%08NameEdit%07Colored%09%07Enabled%09%05Lines%04%01%00%00%00%08Optional%09%0aOutputName%0c%0c%00%00%00contact name%0aOutputType%07%09nvoHeader%07Spacing%04%00%00%00%00%04Text%0c%00%00%00%00%05Valid%09%00%00%08INVLabel%06Label2%07Caption%0c%0b%00%00%00your email:%07Enabled%09%07Spacing%04%00%00%00%00%00%00%07INVEdit%09EmailEdit%07Colored%09%07Enabled%09%05Lines%04%01%00%00%00%08Optional%08%0aOutputName%0c%0d%00%00%00contact email%0aOutputType%07%09nvoHeader%07Spacing%04%00%00%00%00%04Text%0c%00%00%00%00%05Valid%09%00%00%0bINVCheckBox%08MemCheck%07Caption%0c%0b%00%00%00remember me%07Checked%08%07Enabled%09%0aOutputName%0c%00%00%00%00%07Spacing%04%00%00%00%00%00%00%00
Forms2=TPF0%0eTMEDetailsForm%0bDetailsForm%07Message%0c%0d%00%00%00Error Details%08MinWidth%04%00%00%00%00%08OnAction%0c%00%00%00%00%05Timer%04%00%00%00%00%00%09INVButton%0bContinueBtn%07Caption%0c%08%00%00%00Continue%07Enabled%09%0bNoOwnerDraw%08%07Visible%09%00%00%09INVButton%07SkipBtn%07Caption%0c%04%00%00%00Skip%07Enabled%09%0bNoOwnerDraw%08%07Visible%09%00%00%09INVButton%09CancelBtn%07Caption%0c%06%00%00%00Cancel%07Enabled%09%0bNoOwnerDraw%08%07Visible%09%00%00%08INVLabel%06Label1%07Caption%0c,%00%00%00what were you doing when the error occurred?%07Enabled%09%07Spacing%04%00%00%00%00%00%00%07INVEdit%0bDetailsMemo%07Colored%09%07Enabled%09%05Lines%04%09%00%00%00%08Optional%08%0aOutputName%0c%0d%00%00%00error details%0aOutputType%07%0dnvoOwnSection%07Spacing%04%00%00%00%00%04Text%0c%00%00%00%00%05Valid%09%00%00%00
Forms3=TPF0%0eTMEScrShotForm%0bScrShotForm%0dActiveControl%07%0bContinueBtn%07Message%0c%18%00%00%00Screenshot Configuration%08MinWidth%04%00%00%00%00%08OnAction%0c%1e%00%00%00madExcept.HandleScreenshotForm%05Timer%04%fa%00%00%00%00%09INVButton%0bContinueBtn%07Caption%0c%08%00%00%00Continue%07Enabled%09%0bNoOwnerDraw%08%07Visible%09%00%00%09INVButton%07SkipBtn%07Caption%0c%04%00%00%00Skip%07Enabled%08%0bNoOwnerDraw%08%07Visible%09%00%00%09INVButton%09CancelBtn%07Caption%0c%06%00%00%00Cancel%07Enabled%09%0bNoOwnerDraw%08%07Visible%09%00%00%0bINVCheckBox%0bAttachCheck%07Caption%0c%25%00%00%00attach a screenshot to the bug report%07Checked%09%07Enabled%09%0aOutputName%0c%00%00%00%00%07Spacing%04%00%00%00%00%00%00%08INVImage%0aScrShotImg%06Border%09%09Clickable%09%07Enabled%09%04File%0c%00%00%00%00%06Height%04%00%00%00%00%07Spacing%04%00%00%00%00%05Width%04%00%00%00%00%00%00%08INVLabel%06Label1%07Caption%0c%15%00%00%00(click to edit image)%07Enabled%09%07Spacing%04%00%00%00%00%00%00%00
madshi
Site Admin
Posts: 10753
Joined: Sun Mar 21, 2004 5:25 pm

Re: Can't turn off leak detection when using madExceptPatch.

Post by madshi »

Are you 100% sure that the correct MES file is passed on to madExceptPatch?
setzer0384
Posts: 7
Joined: Fri Apr 13, 2018 7:35 pm

Re: Can't turn off leak detection when using madExceptPatch.

Post by setzer0384 »

I am 100% certain but I think I just found out the issue.
I renamed the .mes file to qwerty.mes to be sure it did not use any other file.

If I copy the qwerty.mes file in the same folder as my executable to patch, it works as intended and the leak check does not become activated.

However if my .mes file is in another folder it does not work.
For example my executable is in this folder:

Code: Select all

C:\MyProject\TestMadExcept\Win32\Debug\
and my qwerty.mes in in this folder (2 folders behind)

Code: Select all

C:\MyProject\TestMadExcept\
So this command works as intended (.mes file in same folder as executable):

Code: Select all

madExceptPatch.exe PTest.exe qwerty.mes
but this one doesn't work (.mes file in a different folder), it patches the exetutable but leakcheck becomes activated:

Code: Select all

madExceptPatch.exe PTest.exe ../../qwerty.mes
Could this be an issue in the patcher itself?

Thanks
setzer0384
Posts: 7
Joined: Fri Apr 13, 2018 7:35 pm

Re: Can't turn off leak detection when using madExceptPatch.

Post by setzer0384 »

I just found this old post where someone mentionned a similar issue if this can be of any help:
viewtopic.php?f=4&t=28262

And, we just noticed that if we use backslash instead of slash it works... So i guess we have our solution!

This doesn't work:

Code: Select all

madExceptPatch.exe PTest.exe ../../qwerty.mes
This works:

Code: Select all

madExceptPatch.exe PTest.exe ..\..\qwerty.mes
Thanks for your time
Last edited by setzer0384 on Mon Apr 16, 2018 2:38 pm, edited 1 time in total.
madshi
Site Admin
Posts: 10753
Joined: Sun Mar 21, 2004 5:25 pm

Re: Can't turn off leak detection when using madExceptPatch.

Post by madshi »

Oh wait, I just notice now that you're using "/". That's is not how Windows works. Windows uses "\". Could that explain the problem?
setzer0384
Posts: 7
Joined: Fri Apr 13, 2018 7:35 pm

Re: Can't turn off leak detection when using madExceptPatch.

Post by setzer0384 »

Yes, using backslash does solves the issue, I made an edit to my last post mentioning this but you answer too fast!

Thanks
Post Reply