UserData and Expiration Date

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

UserData and Expiration Date

Postby MrLot » Wed Oct 23, 2019 6:53 am

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: 1724
Joined: Mon Aug 21, 2006 8:19 pm
Location: Russia, E-burg
Contact:

Re: UserData and Expiration Date

Postby Admin » Wed Oct 23, 2019 8:01 am

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: 17
Joined: Sun Feb 17, 2019 8:21 am

Re: UserData and Expiration Date

Postby MrLot » Wed Oct 23, 2019 9:10 am

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: 1724
Joined: Mon Aug 21, 2006 8:19 pm
Location: Russia, E-burg
Contact:

Re: UserData and Expiration Date

Postby Admin » Wed Oct 23, 2019 11:43 am

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: 17
Joined: Sun Feb 17, 2019 8:21 am

Re: UserData and Expiration Date

Postby MrLot » Sun Dec 01, 2019 11:51 pm

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: 1724
Joined: Mon Aug 21, 2006 8:19 pm
Location: Russia, E-burg
Contact:

Re: UserData and Expiration Date

Postby Admin » Mon Dec 02, 2019 8:38 am

"UserData" is just a byte array. You can store any data in this field.

MrLot
Posts: 17
Joined: Sun Feb 17, 2019 8:21 am

Re: UserData and Expiration Date

Postby MrLot » Mon Dec 02, 2019 4:42 pm

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: 1724
Joined: Mon Aug 21, 2006 8:19 pm
Location: Russia, E-burg
Contact:

Re: UserData and Expiration Date

Postby Admin » Tue Dec 03, 2019 12:21 pm

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);