# Has my EXE been modified?

**URL:** <https://clarionhub.com/t/has-my-exe-been-modified/5844>\
**Category:** questions\
**Tags:** c11\
**Created:** [January 18, 2023, 7:51am UTC](https://clarionhub.com/t/has-my-exe-been-modified/5844 "2023-01-18T07:51:26Z")\
**Posts on this page:** 20\
**Page:** 1

<div class="post-metadata">

**Author:** ![DonnEdwards](https://clarionhub.com/user_avatar/clarionhub.com/donnedwards/32/1047_2.png) [@DonnEdwards](https://clarionhub.com/u/DonnEdwards)\
**Post date:** [January 18, 2023, 7:51am UTC](https://clarionhub.com/t/has-my-exe-been-modified/5844/1 "2023-01-18T07:51:26Z")

</div>

Does anyone have a simple method of determining whether the running EXE has been modified? With or without code signing, Windows doesn’t help.

For example, I did a search and replace on Clarion.exe and changed “SoftVelocity” to “HardVelocity” and nothing complained when I ran the EXE. If you inspect the code signing certificate, it says it’s invalid, but the program runs anyway. So why bother with code signing if it can’t detect modified code? No wonder viruses can modify executables with impunity!

---

<div class="post-metadata">

**Author:** ![Bruce](https://clarionhub.com/letter_avatar_proxy/v4/letter/b/ccd318/32.png) [@Bruce](https://clarionhub.com/u/Bruce)\
**Post date:** [January 18, 2023, 8:25am UTC](https://clarionhub.com/t/has-my-exe-been-modified/5844/2 "2023-01-18T08:25:19Z")

</div>

So firstly, yes, exe’s can be changed without windows complaining. Your program needs to explicitly check the certificate on startup if you want to prevent that. I don’t have the code to do that to hand, but Wolfgang did a webinar on this, and posted code to the newsgroup.

---

<div class="post-metadata">

**Author:** ![DonnEdwards](https://clarionhub.com/user_avatar/clarionhub.com/donnedwards/32/1047_2.png) [@DonnEdwards](https://clarionhub.com/u/DonnEdwards)\
**Post date:** [January 18, 2023, 8:46am UTC](https://clarionhub.com/t/has-my-exe-been-modified/5844/3 "2023-01-18T08:46:46Z")

</div>

> [@Bruce](#):
>
> Wolfgang did a webinar on this

ClarionLive #503, #512 and #515. Thanks.

Edit:

Then there’s this: [Masquerading as a Windows System Binary Using Digital Signatures](https://labs.withsecure.com/publications/masquerading-as-a-windows-system-binary-using-digital-signatures)

I’m curious to know whether a self-signed certificate triggers an alarm in the Ultimate Code Sign Checker. Has anyone tried it?

---

<div class="post-metadata">

**Author:** ![anon23294430](https://clarionhub.com/user_avatar/clarionhub.com/anon23294430/32/3829_2.png) [@anon23294430](https://clarionhub.com/u/anon23294430)\
**Post date:** [January 18, 2023, 4:32pm UTC](https://clarionhub.com/t/has-my-exe-been-modified/5844/4 "2023-01-18T16:32:34Z")

</div>

(post deleted by author)

---

<div class="post-metadata">

**Author:** ![PaulAttryde](https://clarionhub.com/user_avatar/clarionhub.com/paulattryde/32/3519_2.png) [@PaulAttryde](https://clarionhub.com/u/PaulAttryde)\
**Post date:** [January 20, 2023, 3:08pm UTC](https://clarionhub.com/t/has-my-exe-been-modified/5844/5 "2023-01-20T15:08:43Z")

</div>

20+ years ago, before code signing certificates were a thing, we had a similar requirement from the Venezuelan government to ensure our code for dealing with fiscal printers hadn’t been tampered with.  
IIRC we came up with a post-compile process that used extra fields in the MZ DOS header of the executable to store the current date & time. Then when the application ran it checked the timestamp we added against the date/time the OS had for the file and if they were different it refused to run

---

<div class="post-metadata">

**Author:** ![anon23294430](https://clarionhub.com/user_avatar/clarionhub.com/anon23294430/32/3829_2.png) [@anon23294430](https://clarionhub.com/u/anon23294430)\
**Post date:** [January 20, 2023, 6:15pm UTC](https://clarionhub.com/t/has-my-exe-been-modified/5844/6 "2023-01-20T18:15:26Z")

</div>

(post deleted by author)

---

<div class="post-metadata">

**Author:** ![DonnEdwards](https://clarionhub.com/user_avatar/clarionhub.com/donnedwards/32/1047_2.png) [@DonnEdwards](https://clarionhub.com/u/DonnEdwards)\
**Post date:** [January 21, 2023, 9:24am UTC](https://clarionhub.com/t/has-my-exe-been-modified/5844/7 "2023-01-21T09:24:18Z")

</div>

Is there a third party app that can be used to warn if I launch a signed app that has been modified?

Or a whitelisting program for Windows? I don’t have secpol.msc

---

<div class="post-metadata">

**Author:** ![anon23294430](https://clarionhub.com/user_avatar/clarionhub.com/anon23294430/32/3829_2.png) [@anon23294430](https://clarionhub.com/u/anon23294430)\
**Post date:** [January 21, 2023, 4:06pm UTC](https://clarionhub.com/t/has-my-exe-been-modified/5844/8 "2023-01-21T16:06:52Z")

</div>

(post deleted by author)

---

<div class="post-metadata">

**Author:** ![CarlBarnes](https://clarionhub.com/user_avatar/clarionhub.com/carlbarnes/32/1859_2.png) [@CarlBarnes](https://clarionhub.com/u/CarlBarnes)\
**Post date:** [January 21, 2023, 4:41pm UTC](https://clarionhub.com/t/has-my-exe-been-modified/5844/9 "2023-01-21T16:41:54Z")

</div>

> [@DonnEdwards](#):
>
> Is there a third party app that can be used to warn if I launch a signed app that has been modified?

There may be a reasonable way to implement this as a class and template. There should be a Checksum written into the [PE Header](https://learn.microsoft.com/en-us/windows/win32/debug/pe-format#optional-header-windows-specific-fields-image-only) by the Linker every build.

> Checksum: The image file checksum. The algorithm for computing the checksum is incorporated into IMAGHELP.DLL. The following are checked for validation at load time: all Drivers, any DLL loaded at boot time, and any DLL that is loaded into a critical Windows process.

The Checksum is Not required to be correct nor checked for ordinary binaries, as noted above, only Drivers and critical.

Maybe @anon77170705 can confirm if the Clarion Linker follows the Microsoft standard. The below link gives the code for the Checksum algorithm (not sure it is correct). And it discusses it’s use for spotting malware.

> **[Threat Hunting with the PE Checksum](https://practicalsecurityanalytics.com/pe-checksum/)**
>
> What is the PE Checksum? When the portable executable format was developed, network connections were much less reliable than they are today. It was not uncommon for the integrity of a connection to…

Note: I don’t think this method is not going to work for digitally signed binaries because the signature is part of the file added after the Linker calculated. Also malware could update the Linker Checksum in the header.

---

<div class="post-metadata">

**Author:** ![DonnEdwards](https://clarionhub.com/user_avatar/clarionhub.com/donnedwards/32/1047_2.png) [@DonnEdwards](https://clarionhub.com/u/DonnEdwards)\
**Post date:** [January 21, 2023, 5:51pm UTC](https://clarionhub.com/t/has-my-exe-been-modified/5844/10 "2023-01-21T17:51:37Z")

</div>

Clarification: I’m looking for a program that can inspect **ANY** EXE or DLL that has been signed and tell me if it has been tampered with. I have the template that can tell if **my** (signed) application is broken when it runs.

The closest I can find is Airlock Digital but it isn’t open source

---

<div class="post-metadata">

**Author:** ![jslarve](https://clarionhub.com/letter_avatar_proxy/v4/letter/j/e480ec/32.png) [@jslarve](https://clarionhub.com/u/jslarve)\
**Post date:** [January 21, 2023, 6:01pm UTC](https://clarionhub.com/t/has-my-exe-been-modified/5844/11 "2023-01-21T18:01:06Z")

</div>

You can use SignTool, but I think MS is weird about distributing it. That’s why SetupBuilder has a menu choice to install it from the MS site.

> **[Use SignTool to Verify a File Signature - Win32 apps](https://learn.microsoft.com/en-us/windows/win32/seccrypto/using-signtool-to-verify-a-file-signature)**
>
> Explains how to use SignTool to verify a file signature.

---

<div class="post-metadata">

**Author:** ![jslarve](https://clarionhub.com/letter_avatar_proxy/v4/letter/j/e480ec/32.png) [@jslarve](https://clarionhub.com/u/jslarve)\
**Post date:** [January 21, 2023, 6:24pm UTC](https://clarionhub.com/t/has-my-exe-been-modified/5844/12 "2023-01-21T18:24:19Z")

</div>

> **[SignTool.exe (Sign Tool) - .NET Framework](https://learn.microsoft.com/en-us/dotnet/framework/tools/signtool-exe#verify-command-options)**
>
> Learn about SignTool.exe, the Sign Tool. This command-line tool digitally signs files, verifies signatures in files, and applies timestamps to files.

---

<div class="post-metadata">

**Author:** ![anon23294430](https://clarionhub.com/user_avatar/clarionhub.com/anon23294430/32/3829_2.png) [@anon23294430](https://clarionhub.com/u/anon23294430)\
**Post date:** [January 21, 2023, 8:28pm UTC](https://clarionhub.com/t/has-my-exe-been-modified/5844/13 "2023-01-21T20:28:38Z")

</div>

(post deleted by author)

---

<div class="post-metadata">

**Author:** ![anon23294430](https://clarionhub.com/user_avatar/clarionhub.com/anon23294430/32/3829_2.png) [@anon23294430](https://clarionhub.com/u/anon23294430)\
**Post date:** [January 21, 2023, 8:37pm UTC](https://clarionhub.com/t/has-my-exe-been-modified/5844/14 "2023-01-21T20:37:01Z")

</div>

(post deleted by author)

---

<div class="post-metadata">

**Author:** ![Julian](https://clarionhub.com/letter_avatar_proxy/v4/letter/j/74df32/32.png) [@Julian](https://clarionhub.com/u/Julian)\
**Post date:** [January 23, 2023, 9:19am UTC](https://clarionhub.com/t/has-my-exe-been-modified/5844/15 "2023-01-23T09:19:16Z")

</div>

As Bruce said, there is code in the Newsgroup for this.

Graham Dawson posted this sample (thanks Graham) which does exactly as you request, ie: can check any file.

[Clarion-Demo-Verify-Code-Signing.zip](https://clarionhub.com/uploads/short-url/A3FvsNdT5RHjDkGl1LAZJHJwHy6.zip) (16.4 KB)

---

<div class="post-metadata">

**Author:** ![PaulAttryde](https://clarionhub.com/user_avatar/clarionhub.com/paulattryde/32/3519_2.png) [@PaulAttryde](https://clarionhub.com/u/PaulAttryde)\
**Post date:** [January 23, 2023, 2:26pm UTC](https://clarionhub.com/t/has-my-exe-been-modified/5844/16 "2023-01-23T14:26:41Z")

</div>

@CarlBarnes “There should be a Checksum written into the [PE Header] by the Linker every build.”

A long time ago the CW linker used it’s own checksum. When I complained about it (probably to Ole or Richard Chapman, but I forget who) they didn’t care. Don’t know if that’s changed by now.

---

<div class="post-metadata">

**Author:** ![jslarve](https://clarionhub.com/letter_avatar_proxy/v4/letter/j/e480ec/32.png) [@jslarve](https://clarionhub.com/u/jslarve)\
**Post date:** [January 23, 2023, 3:02pm UTC](https://clarionhub.com/t/has-my-exe-been-modified/5844/17 "2023-01-23T15:02:51Z")

</div>

I knew I saw that somewhere. Thanks Julian and @Graham_Dawson

---

<div class="post-metadata">

**Author:** ![PaulAttryde](https://clarionhub.com/user_avatar/clarionhub.com/paulattryde/32/3519_2.png) [@PaulAttryde](https://clarionhub.com/u/PaulAttryde)\
**Post date:** [January 23, 2023, 5:22pm UTC](https://clarionhub.com/t/has-my-exe-been-modified/5844/18 "2023-01-23T17:22:34Z")

</div>

FWIW, in case anyone is interested the IQCQO.DLL that the example app ships with appears to be a C DLL that’s “just” a wrapper around the WinVerifyTrust() API call using the WINTRUST\_ACTION\_GENERIC\_VERIFY\_V2 GUID

---

<div class="post-metadata">

**Author:** ![CarlBarnes](https://clarionhub.com/user_avatar/clarionhub.com/carlbarnes/32/1859_2.png) [@CarlBarnes](https://clarionhub.com/u/CarlBarnes)\
**Post date:** [January 23, 2023, 5:31pm UTC](https://clarionhub.com/t/has-my-exe-been-modified/5844/19 "2023-01-23T17:31:35Z")

</div>

I wrote this before @PaulAttryde posted about IQCQO.

> [@Julian](#):
>
> Graham Dawson posted this sample (thanks Graham) which does exactly as you request, ie: can check any file.  
> Clarion-Demo-Verify-Code-Signing.zip

That relies on 2 functions `ReturnSigningInfo` and `VerifySignature` in `IQCQO.DLL`.

The IQCQO DLL properties shows No Details and No Digital Signature. Did @Graham_Dawson say the source of that DLL? Seems like a bad idea to check security using an unknown unsigned DLL.

Code excerpt:

```auto
 MAP
     module('IQCQO')
         ReturnSigningInfo(const *cstring inFilename,*cstring outputStr,*long bufferSize),long,C,raw,name('ReturnSigningInfo')
         VerifySignature(const *cstring inFilename,*cstring outputStr,*long bufferSize),long,C,raw,name('VerifySignature')
     end
 END

... CODE ...       
   bufferSizeNeeded = size(CStrBuffer)
   result = VerifySignature(filename,CStrBuffer,bufferSizeNeeded)
   IF result
      Message('Error ' & CStrBuffer,filename)
   ELSE
      Message(CStrBuffer,filename)
   END    
   IF CStrBuffer <> 'The file is not signed<13,10>'                
      bufferSizeNeeded = size(CStrBuffer)
      result = ReturnSigningInfo(filename,CStrBuffer,bufferSizeNeeded)
      IF result
          message('Error ' & CStrBuffer,filename)
      ELSE
          message(CStrBuffer,filename)
      END    
   END

```

---

<div class="post-metadata">

**Author:** ![jslarve](https://clarionhub.com/letter_avatar_proxy/v4/letter/j/e480ec/32.png) [@jslarve](https://clarionhub.com/u/jslarve)\
**Post date:** [January 23, 2023, 5:54pm UTC](https://clarionhub.com/t/has-my-exe-been-modified/5844/20 "2023-01-23T17:54:26Z")

</div>

Source is here

> **[Icetips Alta LLC download file](https://www.icetips.com/downloadfile.php?FileID=267)**
>
> Icetips Alta LLC download file.

[Next page](https://clarionhub.com/t/has-my-exe-been-modified/5844.md?page=2)
