UserData and Expiration Date

Issues related to VMProtect
Post Reply
MrLot
Posts: 19
Joined: Sun Feb 17, 2019 8:21 am

UserData and Expiration Date

Post by MrLot »

I have si.pUserData set to what I want but it doesn't show up in license once it has been generated.

I can't seem to get the user data to be added. What am I missing?

How would I get a string to be added to user data?


Also how would I have a DateTimePicker1.Date to be set as expiration date in keygen?

How would I set statement:
si.dwExpDate := Cardinal(DateTimePicker1.Date);

^^ this doesn't work... looking for solution.


I am using Delphi to program.
Admin
Site Admin
Posts: 2566
Joined: Mon Aug 21, 2006 8:19 pm
Location: Russia, E-burg
Contact:

Re: UserData and Expiration Date

Post by Admin »

How would I get a string to be added to user data?
It seems your forgot to specify "HAS_USER_DATA" in si.flags:

Code: Select all

si.flags := ... or HAS_USER_DATA;
How would I set statement:
si.dwExpDate := Cardinal(DateTimePicker1.Date);
You have to use the following code for it:

Code: Select all

#define MAKEDATE(y, m, d) (DWORD)((y << 16) + (m <<8) + d)
Where "y" = "year", "m" = "month", "d" = "day" and "<<" = "shl". Also don't forget to specify "HAS_EXP_DATE" in si.flags.
MrLot
Posts: 19
Joined: Sun Feb 17, 2019 8:21 am

Re: UserData and Expiration Date

Post by MrLot »

How do I get a datetimepicker to get correct value? MAKEDATE is not a function or string anywhere. Even if I made it, that only allows for static input not dynamic from a datetimepicker in delphi.

I have a DateTimePicker that I want to pull the date from and set as expiration date.
Admin
Site Admin
Posts: 2566
Joined: Mon Aug 21, 2006 8:19 pm
Location: Russia, E-burg
Contact:

Re: UserData and Expiration Date

Post by Admin »

Code: Select all

var
  y, m, d : Word;
begin
  DecodeDate(DateTimePicker1.Date, y, m, d);
  si.dwExpDate := (y shl 16) + (m shl 8) + d;
MrLot
Posts: 19
Joined: Sun Feb 17, 2019 8:21 am

Re: UserData and Expiration Date

Post by MrLot »

Thank you, this is working now. However, is the UserData supposed to be in a specific format or char type? I've specified it, but it's not being added to the license. I have the flag specified, so that's not the problem.
Admin
Site Admin
Posts: 2566
Joined: Mon Aug 21, 2006 8:19 pm
Location: Russia, E-burg
Contact:

Re: UserData and Expiration Date

Post by Admin »

"UserData" is just a byte array. You can store any data in this field.
MrLot
Posts: 19
Joined: Sun Feb 17, 2019 8:21 am

Re: UserData and Expiration Date

Post by MrLot »

No matter what I do, it's not in the right format and is giving me errors.

Incompatible types: 'PByte' and 'System.TArray<SystemBytes>'
or

Incompatible types: 'PByte' and 'System.String'


I am using:
si.PUserData := TEncoding.UTF8.GetBytes(mystring);
Admin
Site Admin
Posts: 2566
Joined: Mon Aug 21, 2006 8:19 pm
Location: Russia, E-burg
Contact:

Re: UserData and Expiration Date

Post by Admin »

Code: Select all

var user_data: array [0..20] of Byte;
...
user_data[0] := 1;
user_data[2] := 2;
..
user_data[19] := 20;
si.pUserData := @user_data[0];
si.nUserDataLength:= SizeOf(user_data);
MrLot
Posts: 19
Joined: Sun Feb 17, 2019 8:21 am

Re: UserData and Expiration Date

Post by MrLot »

Thank you, this works great.

However, what if you have a string in which you want to place into user data?
Admin
Site Admin
Posts: 2566
Joined: Mon Aug 21, 2006 8:19 pm
Location: Russia, E-burg
Contact:

Re: UserData and Expiration Date

Post by Admin »

I recommend to store such string in UTF8/Base64 and decode it in a protected program.
Post Reply