What are the list of all possible values for DVCLAL?
Asked Answered
M

2

6

I was reading SysUtils when I came across with this function:

function ALR: Pointer;
var
  LibModule: PLibModule;
begin
  if MainInstance <> 0 then
    Result := Pointer(LoadResource(MainInstance, FindResource(MainInstance, 'DVCLAL',
      RT_RCDATA)))
  else
  begin

After that, I searched what is DVCLAL and I've found this question.

What are all the possible signatures that Delphi compiler emits to the DVCLAL resource?

Mordecai answered 10/9, 2013 at 13:18 Comment(1)
It is not very clear what is your real question.Sacchariferous
P
5

There is no official documentation on this, so here is something from my notes of 15+ years ago:

The DVCLAL is there to check which SKU of Delphi you are using and it varies per SKU.

There are only checks for the Professional (RPR) and Client/Server (RCS) SKUs:

procedure RCS;

procedure RPR;

If they fail, they call this method:

procedure ALV;
begin
  raise Exception.CreateRes(@SNL);
end;

where

resourcestring
  SNL = 'Application is not licensed to use this feature';

Depending on the feature matrix and Delphi version, various components call RPR and RCS in their Create constructors to guarantee a minimum SKU.

Phthisic answered 10/9, 2013 at 18:23 Comment(2)
There is not even a non official documentation?Mordecai
@MatheusFreitas now there is (;Phthisic
S
11

I am just adding another answer to this question, for all the people who search for actual DVCLAL (= Delphi Visual Component Library Access License) values, as well as some other information for all people who are curious about how stuff works.

  1. As Jeroen Wiert Pluimers said, if you want to check for "Professional or higher" or "Enterprise only" inside your Delphi application/library/package/component, you can use RPR (= "Require Professional") or RCS (= "Require Client/Server"; Client/Server was the name for the Enterprise edition in early Delphi versions) respectively. If the requirement is not met, ALV (= "Access License Violation") will be called which will raise an Exception with the message defined in SysConst.SNL (= "(String) Not Licensed"). In English:

Application is not licensed to use this feature

  1. In case you want to check for one specific edition, you can use the output of the function GDAL (Get Delphi Access License), which is one of the following (AL1s array):
AL1s[0] = $FFFFFFF0; // Standard/Personal edition DVCLAL value
AL1s[1] = $FFFFEBF0; // Professional edition DVCLAL value
AL1s[2] = $00000000; // Enterprise/ClientServer edition DVCLAL value
AL1s[3] = $FFFFFFFF; // DVCLAL resource not existing

If the DVCLAL resource has an invalid value, GDAL will call ALV which will raise an Exception with the message SysConst.SNL.

  1. In case you want to check the DVCLAL value of a foreign EXE/DLL file (e.g. if you want to write a Resource Editor, decompiler, etc), then you'll have to query the DVCLAL resource directly.

There are only three official values:

Standard:      23 78 5D 23 B6 A5 F3 19 43 F3 40 02 26 D1 11 C7
Professional:  A2 8C DF 98 7B 3C 3A 79 26 71 3F 09 0F 2A 25 17
Enterprise:    26 3D 4F 38 C2 82 37 B8 F3 24 42 03 17 9B 3A 83
  1. Just for fun: If you solve the formula 0 = (ROR(a,15) xor a) xor (ROR(b,10) xor b) xor (ROR(c,5) xor c) xor (AL1 xor AL2) you can define any DVCLAL value (tuple a, b, c, d) you want! (AL1 and AL2 are the values in the AL1s and AL2s arrays that describe the desired Delphi edition; ROR is rotating right without carry)

For example, here are alternative DVCLALs that work too:

Standard:      00 00 00 00 00 00 00 00 9B 70 0C 66 6B 8F F3 99
Professional:  00 00 00 00 00 00 00 00 9A DB 73 0F 6A 30 8C F0
Enterprise:    00 00 00 00 00 00 00 00 D8 B2 48 11 D8 B2 48 11

To validate a DVCLAL, you calculate

AL1 := DVCLAL[0] xor DVCLAL[1] xor DVCLAL[2] xor DVCLAL[3];
AL2 := ROR(DVCLAL[0],15) xor ROR(DVCLAL[1],10) xor ROR(DVCLAL[2],5) xor DVCLAL[3];

and look up AL1 and AL2 in the array AL1s and AL2s,

This way you can disguise the edition you have used (at least a little bit).

  1. In the meantime, official documentation, at least for the functions GDAL, RPR, and RCS, has been published.

  2. Of course, everything works for C++ Builder, too.

Scrabble answered 11/7, 2017 at 0:54 Comment(9)
"ROR is rotate right through carry" - probably WITHOUT carry? carry flag is such a low-level feature that... Well, guuess it is obvious using RCR x86 opcode is nigh impossible for a formula written in a high-level language (or imitation)Pemmican
The original Borland implementation uses the ROR x86 opcode. I could replicate the behavior with the following Pure Pascal implementation: function ROR(Value: DWord; N: Integer): DWord; begin result := (value shr N) or (value shl (32-N)); end;Scrabble
Yes, and x86 ROR is explicitly NOT "rotate through carry flag" because that is what "RCR" is. So, this line in your answer is wrong: "ROR is rotate right through carry" see c9x.me/x86/html/file_module_x86_id_273.html and see stackoverflow.com/questions/4976636Pemmican
@Arioch'The Which name should I write instead? I want to avoid the word "ROR" because many people don't know what it is.Scrabble
bet "ROR" is correct, but your DESCRIPTION of it is wrong. Read my first comment: "ROR is rotate right through carry" - probably WITHOUT carry? You seem to mention the correct opcode, but give it a very wrong desciprion! "carry flag" is one extra bit outside the register/variable that gets used during RCL/RCR rotations. Not 32 bits but 33 bits. That is why it is called "through carry [flag]" - there is one extra outside storage added to the "circular queue" of bits. And that is what AFAIU is NOT happening here. "through carry" is wrong words, has to be deleted or replaced with their negationPemmican
@Arioch'The I don't quite understand it, and I couldn't find a webpage that describes the operation in one sentence. :-) But I have now changed the sentence from "ROR is rotate right through carry" to "ROR is rotate right without carry". I was confused because you wrote "probably without carry", so I thought you wasn't sure about it.Scrabble
I am never sure, because, 1, as a human I can and do make mistakes, and, 2, i did not research or verify DCLVAL formula, so while I did think using CF was meaningless and nigh impossible in the context, I could not know for sure. As for the book, well, any assembler tutorial would describe the difference, as well as between SHR and SAR commands. Of course if you never wet your feet, then even find those tutorials is some challenge. OTOH I believe any seasoned Delphi programmer has to be medium-level asm progger too. Compiler bugs, RTL bugs and in-memory patching it, fast code project, etcPemmican
Also as for understanding, I think you know what "circular queue" is, FIFO buffer of fixed length and without copying? DOS/BIOS keyboard handler used it, for example. Think that amd64 CPU has quite a choice of register sizes: 8bits, 16, 32, 64. And programmer might wish to rotate any of those. So, the CPU has to provide rotator unit as a circular bit queue of any customizable length. Now, if you have such a unit,then you are not confined of one singular register nor even to registers of equal size, you can snap together, in theory, any number of any size bit storages. RCL/RCR do just that :)Pemmican
They "add one bit kinda sorta register - Carry Flag bit of FLAGS register - to the argument register" , and do the bits rotation over that whole aggregated body. PS. actually, c-queue can be used as both FIFO and LIFO, it is bidirectional, but size is fixed, and programming/storage is a bit more complex.Pemmican
P
5

There is no official documentation on this, so here is something from my notes of 15+ years ago:

The DVCLAL is there to check which SKU of Delphi you are using and it varies per SKU.

There are only checks for the Professional (RPR) and Client/Server (RCS) SKUs:

procedure RCS;

procedure RPR;

If they fail, they call this method:

procedure ALV;
begin
  raise Exception.CreateRes(@SNL);
end;

where

resourcestring
  SNL = 'Application is not licensed to use this feature';

Depending on the feature matrix and Delphi version, various components call RPR and RCS in their Create constructors to guarantee a minimum SKU.

Phthisic answered 10/9, 2013 at 18:23 Comment(2)
There is not even a non official documentation?Mordecai
@MatheusFreitas now there is (;Phthisic

© 2022 - 2024 — McMap. All rights reserved.