Tuesday 19 December 2017

ZenCart Emails Fail to Send

I did an update of my Windows Server 2012 R2 with new versions of PHP (v.7.1.11) and ZenCart v1.56-Alpha.

A day ago I happened to login to the store admin area and noted there were 3 orders waiting to be dispatched but I was not notified.... oh dear.

Logging into the server via RDP and looking at the logs directory, showed me that I had a few

"SSL operation failed with code 1. OpenSSL Error"

and

"Email Error: SMTP connect() failed. https://github.com/PHPMailer/PHPMailer/wiki/Troubleshooting
in C:\Domains\ecufix.com\wwwroot\shop\includes\functions\functions_email.php on line 375"

Errors meaning that the emails were not being sent - double oh dear. To check, I logged into the ZenCart Admin console and altered the PayPal module settings and then a red banner appeared at the top of the browser telling me that there was an email sending error.

So something had changed either in PHP or ZenCart since the last time I used it. I know the ZenCart developers would never have let their code out of the door with a simple email bug. Therefore the error had to be related to PHP.

After a few hours of searching, I found the reason why emails were failing: essentially PHP now requires the CaCerts (Certificate Authority Certificates) defining in the OpenSSL section as well.

[curl]
; A default value for the CURLOPT_CAINFO option. This is required to be an
; absolute path.
curl.cainfo = "C:\Program Files (x86)\PHP\v7.1\Extras\SSL\cacert.pem"
[openssl]
; The location of a Certificate Authority (CA) file on the local filesystem
; to use when verifying the identity of SSL/TLS peers. Most users should
; not specify a value for this directive as PHP will attempt to use the
; OS-managed cert stores in its absence. If specified, this value may still
; be overridden on a per-stream basis via the "cafile" SSL stream context
; option.
openssl.cafile= "C:\Program Files (x86)\PHP\v7.1\Extras\SSL\cacert.pem"

This allows the emails to be sent again.

Remember, you can download the latest CA cert file from curl, install it somewhere accessible (for example c:/program files (x86)/php/v7.1/extras/ssl/cacert.pem) and point at it from the openssl.cafile and curl.cainfo directives in your php.ini file 

More info is available here: PHPMailer/wiki/Troubleshooting

Sunday 12 November 2017

ECUFix has been updated to v6.2.6.12

Recompiled with Microsoft's latest version of Visual Studio 2017.

Tested on Windows 10 down to Windows XP.

The ME7.5 detection algorithm has been updated.

This version has added VAG binaries 363497, 366494, 362510 and ME72002 wasn't correcting all checksums on first pass since the last update. If you would like to give it a try, the new version can be downloaded direct from ECUFix's product page or from the download directory HERE.

Friday 15 September 2017

ECUFix has been updated to v6.2.6.10


Recompiled with Microsoft's latest version of Visual Studio 2017.

Tested on Windows 10 down to Windows XP.

This version has added VAG binary 369321 since the last update. If you would like to give it a try, the new version can be downloaded direct from ECUFix's product page or from the download directory HERE.

Monday 3 July 2017

Can't Send SMS Error 38 - Vodafone UK

I had a OnePlus 2 mobile phone here in the UK.

I really liked it but my Vodafone SIM wouldn't let me send SMS texts out. Since it's a dual SIM phone, I tried an EE SIM in the other slot and this worked fine.

Sending texts didn't really bother me much and, at the time in June 2017, the OnePlus 5 was due to be released so I wasn't much bothered.

OnePlus 5 in my hands and everything swapped over I randomly tried to send an SMS a few days later.... it failed with the error message "Could not send text Error 38"..... hmm, not good. I telephoned Vodafone and spent about 45 minutes on the phone with the technical chap. We tried all-sorts including disabling and re-enabling SMS from the Vodafone system app but all to no-avail. Then I found an article about a similar problem on the OnePlus 3T forums and thought I'd give it a go....

There's a (not so) secret menu available for Android phones that's accessed by typing *#*#4636#*#* from your phone's dialer. As soon as you enter the last "*", a menu pops up labelled "Testing".

Secret Menu 1
Tap on the Phone Information selection and you'll get this menu:
Secret Menu 2

In my phone, the SMSC: field was blank. The message centre for Vodafone UK is +447785016005 which needs to be added here. To add it, you must put the number in double quotes and then tap on the UPDATE button, e.g. "+447785016005" - tap UPDATE.

Tapping REFRESH should append the ",145" at the end.

Sending a test SMS to myself succeeded!
P.S. don't go changing anything else or you'll probably do more damage unless you know what you're doing. Ironically, if you know what you're doing, you wouldn't be here anyway 😃
Hope this helps someone, Andy

Sunday 11 June 2017

ECUFix has been updated to v6.2.6.8


Recompiled with Microsoft's latest version of Visual Studio 2017.

Tested on Windows 10 down to Windows XP.

This version has added various extra binaries since the last update. If you would like to give it a try, the new version can be downloaded direct from ECUFix's product page or from the download directory HERE.

Sunday 23 April 2017

ECUFix has been updated to v6.2.6.7

Probably should have gone up a slightly higher version number this time because of the work I had to put into this.


I've added two extra binaries for US/Canada VW Rabbits (Golfs), both Normally Aspirated (NA) which took some doing! 360930 and 372644

If you would like to give it a try, the new version can be downloaded direct from ECUFix's product page or from the download directory HERE.

However, over the past month or so, I updated my development environment to Visual Studio 2017 and all seemed well except I noticed some unusual behaviour only after the project was compiled into Release mode.

The bug? Well to make things try and autocomplete as much as possible, I have a small routine to try and search for a string of bytes in a binary. A snippet follows (Thanks to http://hilite.me/)

unsigned __int32 chksumBase::FindStringWithDontCareInBinary(unsigned char *szString, unsigned __int32 nSLength, unsigned __int32 nStartAddress) 
{
 unsigned __int32 nAddr = 0xffffffff, nIndexA, nIndexB;
 CString  csBuf;

 //Guard against overflows
 if(nSLength > m_nBSize)
 {
  nSLength = m_nBSize;
  csBuf.Format(_T("Warning! Function FindStringInBinary given nSLength of 0x%lx but the binary is only 0x%lx long"), (unsigned __int32)nSLength, (unsigned __int32)m_nBSize);
  DisplayErrorText(csBuf);
  return 0xffffffff;//Error
 }

 //Guard against overflows
 if((nStartAddress + nSLength) > m_nBSize)
 {
  csBuf.Format(_T("Warning! Function FindStringInBinary given a StartAddress of 0x%lx but length of 0x%lx when the binary is only 0x%lx long"), (unsigned __int32)nStartAddress, (unsigned __int32)nSLength, (unsigned __int32)m_nBSize);
  DisplayErrorText(csBuf);
  return 0xffffffff;//Error
 }

 for(nIndexA=nStartAddress; nIndexA < m_nBSize; nIndexA++)
 {
  if(*(m_pBinary+nIndexA) == *szString)
  {// We're matched for the 1st char, now check the rest
   for(nIndexB=0; nIndexB < nSLength; nIndexB++)
   {
    if(*(szString+nIndexB) != 0xff) //check for don't care flag
    {
     if(*(m_pBinary+nIndexA+nIndexB) != *(szString+nIndexB))
     {
      break;// No longer matched
     }
     
     if ((nIndexB + 1) == nSLength)
     {
      return nIndexA; // String completely matched
     }
    }
   }
  }
 }

 return nAddr;
}

That code has worked for the past few years but since the change to VS2017, it's stopped 😐 Therefore I've wrote the following instead and am just testing it for inclusion with the next version:

/*
* The memmem() function finds the start of the first occurrence of the
* substring 'needle' of length 'nSLength' in the memory area 'm_pBinary' of
* length 'binaryLength'.
*
* The return value is a pointer to the beginning of the sub-string, or
* NULL if the substring is not found.
* 
* From: http://stackoverflow.com/questions/2188914/c-searching-for-a-string-in-a-file
*/
unsigned __int32* chksumBase::memmem(unsigned char *needle, unsigned __int32 nSLength)
{
 int needle_first;
 unsigned char *p = m_pBinary;
 unsigned __int32 binaryLength = sizeof(m_pBinary);
 unsigned __int32 plen = nSLength;

 if (!nSLength)
  return nullptr;

 needle_first = *(unsigned char *)needle;

 while (plen >= nSLength && (p = (unsigned char *)memchr(p, needle_first, plen - nSLength + 1)))
 {
  if (!memcmp(p, needle, nSLength))
   return (unsigned __int32 *)p;

  p++;
  plen = binaryLength - (p - m_pBinary);
 }

 return nullptr;
}

Friday 24 March 2017

ECUFix Has Been Updated to v6.2.6.6

ECUFix v6.2.6.6
Recompiled with Microsoft's latest version of Visual Studio 2017.

Tested on Windows 10 down to Windows XP.

This version has added various extra binaries since the last update. If you would like to give it a try, the new version can be downloaded direct from ECUFix's product page or from the download directory HERE.