#1 2010-08-07 15:23:05

ab
Administrator
From: France
Registered: 2010-06-21
Posts: 14,659
Website

Every Delphi DB program contains hidden code for EMB licence checking

After looking further at the SysUtils unit, I found out some small piece of asm code I didn't notice at first.

There is some hidden and not documented code in every program using the DB features, in order to verify that you have the right to use some drivers or DB features.

The licence checking performed by Borland (it was a trick existing in Delphi 4, or perhaps before) is somewhat childish.

So here are the three function procedures in SysUtils.pas, not documented:

function GDAL: LongWord;
procedure RCS;
procedure RPR;

Here is a first explanation: http://assarbad.net/stuff/!export/dvclal/jeremyres.html

The purpose of these functions is to check the presence of the DVCLAL resource in the exe (or one of the current module).

This resource is just an array of 4 longword, i.e. 4 cardinal values.

The function GDAL, for example, returns either 0, -16, -5136, or -1 depending of the version of your current Delphi licence (i.e. Professional, Entreprise, Architecture, GPL, whatever). The returned value of GDAL is checked in the following units:  SqlExpr.pas BDEReg.pas DBReg.pas DBTables.pas BDEReg.pas DBReg.pas MidReg.pas

And the protection takes place easily, for example here is an extract of the BDEReg.pas code:

procedure Register;
begin
  { Database Components are excluded from the STD SKU }
  if GDAL <> LongWord(-16) then
  begin
    // Restrict these components to only be used with VCL components.
    GroupDescendentsWith(TBDEDataSet, Controls.TControl);
....
    { Components that are excluded from the STD & PRO SKUs }
    if GDAL = 0 then
      RegisterComponents(srBDE, [TNestedTable]);

The RPR procedure is a bit more agressive: it raises an exception in case you don't have the right to use some components registered in DBXClient.pas DbxFirebird.pas DbxInterbase.pas DbxMySql.pas DbxSybaseASA.pas DSServer.pas DB.pas dbcgrids.pas HTTPApp.pas HTTPProd.pas Sockets.pas SOAPConn.pas units.

And within the RCS procedure, the exception is raised for other components registered in DBXClient.pas DbxDb2.pas DbxInformix.pas DbxMSSQL.pas DbxOracle.pas DbxSybaseASE.pas DBClient.pas MConnect.pas TConnect.pas HTTPApp.pas HTTPProd.pas MXDB.PAS MXGRAPH.PAS MXGRID.PAS MXPIVSRC.PAS units.

I let you guess which component is what, just from the official EMB feature matrix.

Why all this?

Since the raw compiler is the same, that is the language feature and RTL is the same for all Delphi versions (from Professional up to Architect), you could be tempted buying the Professional version, then copy the dcu/bpl from an Architect, and use it... but in fact, you won't have the "magic" resource in your exe, so the trick won't play.

Writing a patcher for your exe is very easy. You don't even have to patch the memory, just some standard Win32 API like BeginUpdateResource / UpdateResource / EndUpdateResource like stated in msdn will do the work.
I won't commit Delphi code here, because I want to stay friend with EMB. But guess what, it's not a great protection system!

I don't blame Borland/EMB. But lol big_smile ! Such a weak "protection", giving all the source code at once. Thanks EMB for making me smile after my "object type" funeral.

Offline

#2 2010-08-07 17:09:39

Mohammed Nasman
Member
From: Palestine
Registered: 2010-07-05
Posts: 5
Website

Re: Every Delphi DB program contains hidden code for EMB licence checking

ab wrote:

There is some hidden and not documented code in every program using the DB features

They are documented in Delphi 2009 help, I didn't check with older version.

Few days ago I was browsing "SysUtils" help, and while looking for some parameters for "Format function" I noticed the GDAL, I pressed on it and got this from help system:

"GDAL retreives the access licences resource. It checks if it is valid, if not an Access Licence Violation exception with the message 'Application is not licenced to use this feature' is raised.

The returned value is the decrypted first Access Licence (AL1). "

but I didn't know it too weak like you described ;-)

BTW, they seems don't use Spell checker when writing the documentations smile

Offline

#3 2010-08-07 17:24:59

ab
Administrator
From: France
Registered: 2010-06-21
Posts: 14,659
Website

Re: Every Delphi DB program contains hidden code for EMB licence checking

Mohammed Nasman wrote:

They are documented in Delphi 2009 help, I didn't check with older version.

I checked with Delphi 7 only, didn't check with Delphi 2009/2010.
In fact:
GDAL get Delphi Access Licence;
RCS checks for Delphi Client/Server Licence;
RPR checks for Delphi Professional Licence.

I made a mistake myself, about spelling.
The "License" term is the verb, whereas "Licence" is the noun.
The spelling rules are the same for 'practice', 'licence' and 'advice': the noun has a 'c', while the verb has an 's'.

Perhaps it's all about American English, I don't know.

But the way this code works is still funny.

Offline

#4 2011-10-27 06:39:41

ab
Administrator
From: France
Registered: 2010-06-21
Posts: 14,659
Website

Re: Every Delphi DB program contains hidden code for EMB licence checking

This code is still included in System.SysUtils.pas XE2 unit.
smile

Offline

#5 2012-04-03 18:34:16

Arioch
Member
Registered: 2011-11-17
Posts: 28

Re: Every Delphi DB program contains hidden code for EMB licence checking

ab wrote:

GDAL get Delphi Access Licence;
RCS checks for Delphi Client/Server Licence;
RPR checks for Delphi Professional Licence.

I'd re-phrase.

GDAL stands for GetDelphiAccessLicence;
RCS stands for RequireClientServer;
RPR stands for RequireProfessionalLicence.

Last two are named quite along VCL habits :-)


About protection force and patcher - why bother? go torrents and download the most full-featured Delphi version for free.
You can have legal Delphi and your app, or you can get contrafact ones. But semi-illegal Delphi is ... like semi-pregnant girl.

That is not the fencing, but rather a warning label "Do not tresspass"
It's simplicity makes it rock-stable, not suddenly turning mad like more Artificialy Idiotic protections, like those used by PC Games.

Offline

Board footer

Powered by FluxBB