PDA

View Full Version : New version : VTDbManager for Asphyre



jansoft
13-10-2004, 02:34 PM
VTDbManager v2.0 (now for Asphyre) released.
It is free advanced manager for VTDb files with ability of compilation VTDb files from XML-definition "make files", usable to change your graphics and quick recompile to your VTDb.

Visit http://jansoft.aquasoft.cz,
please send bugs and comments.
Thanks Jansoft

Huehnerschaender
13-10-2004, 03:19 PM
High Jansoft,

the manager looks great and is a little more comfortable than the one included in Asphyre. Good work.

I have a question concerning LZcompression.
Is it possible to add a password somehow so that it is not possible to view my vtdb just by opening it in vtdb-manager?

jansoft
13-10-2004, 03:54 PM
aaa - little mistake : password is not yet supported because of not-existing Encode/decode plugin for encryption.
Maybe Lifepower will create some ?
Or am I wrong and this can be done by another way ?

Huehnerschaender
13-10-2004, 04:40 PM
That's exactly the question...
I was wondering if I can encrypt my data, so that it is a little more protected from being manipulated, because I want to store highscores and such stuff in VTDB, too...

jansoft
13-10-2004, 04:46 PM
yes, you can.
Write-down your own TEncodePlugin for encode/decode.
Than use it in your application (probably compiled into your code).

For VTDbManager you must have dll, which will export some functions (see sources of Asphyre, it is clear) and say to VTDBMan, that you want to use it (from cmd line or xml).

Little problem is, that VTdbManager now doesn't support sending parameters to plugins, so your password must be always same.

In future version i'll add this.

Huehnerschaender
13-10-2004, 04:51 PM
Ok, thanks for info...

I will take a look at it when I really need it, got other things that have to work first.
Maybe someone has finished an encryption-dll till then :)

LP
13-10-2004, 05:36 PM
I forgot to include the VTDb Plugin SDK with the current release. There is an example of VTDb plugin and some documentation. I'll try to include it next time (in few days)....
And thanks for VTDbManager!

jansoft
19-10-2004, 09:40 AM
New Release 2.1 with better plugins support now released .

I use simple plugin definition for support passwords


library PwdPlugin;

uses
AsphyreDef,
encodeplugins,
Classes;

{$R *.res}
var password:string;

function proc_encode(Source, Dest: Pointer; SourceSize, DestSize: Longword):Integer;
begin
Result:=SourceSize;
if Result>DestSize then Result:=DestSize;
Move(source^,Dest^,Result);
end;

function proc_decode(Source, Dest: Pointer; SourceSize, DestSize: Longword):Integer;
begin
Result:=SourceSize;
if Result>DestSize then Result:=DestSize;
Move(source^,Dest^,Result);
end;

function proc_params(Source, Dest: Pointer; SourceSize, DestSize: Longword):Integer;
begin
password:=PChar(Source);
Result:=errNone;
end;

function proc_reset(Source, Dest: Pointer; SourceSize, DestSize: Longword):Integer;
begin
password:='';
Result:=errNone;
end;

function PluginEnum(EnumFunc: TEnumFunc; MiscParam: Longword): Integer; stdcall;export;
begin
Result:=errUnknownError;
if not EnumFunc(attribName, 0,'Password test plugin',MiscParam) then Exit;
if not EnumFunc(attribID, 0,'PwdPlugin',MiscParam) then Exit;
if not EnumFunc(attribVersion,$100,'',MiscParam) then Exit;
if not EnumFunc(attribMinVersion,0,'',MiscParam) then Exit;
if not EnumFunc(attribFlags,flagEncode,'Crypt data block',MiscParam) then Exit;
if not EnumFunc(attribFlags,flagDecode,'Uncrypt data block',MiscParam) then Exit;
if not EnumFunc(attribFlags,flagParams,'Set password',MiscParam) then Exit;
if not EnumFunc(attribFlags,flagReset+99,'MySecureProc',M iscParam) then Exit;
Result:=0;
end;

function PluginExec(Source, Dest: Pointer; SourceSize, DestSize, Flags: Longword): Integer; stdcall;export;
begin
case Flags of
flagEncode : Result:=proc_encode(Source,Dest,SourceSize,DestSiz e);
flagDecode : Result:=proc_decode(Source,Dest,SourceSize,DestSiz e);
flagParams : Result:=proc_params(Source,Dest,SourceSize,DestSiz e);
flagReset : Result:=proc_reset(Source,Dest,SourceSize,DestSize );
else
Result := errFlags;
end;
end;

exports
PluginEnum,
PluginExec;
end.


Is it right way ?

LP
19-10-2004, 01:12 PM
I've tried to upload, my connection is garbled, so here's a simple plugin example:


library SEncode;

//---------------------------------------------------------------------------
uses
SysUtils, Classes, AsphyreDef, EncodePlugins;

{$R *.res}

//---------------------------------------------------------------------------
const
PluginVersion = $100; // current version of the plugin
PluginMinVersion = $100; // lowest compatible version of previous plugins
// PluginMinVersion determines which previous versions of the plugin can
// be decoded by current version of plugin. If it has the same value
// as PluginVersion, then this plugin can only decode its own encodings.

//---------------------------------------------------------------------------
var
AttrVersion : ShortString = 'Version 1.0'#0;
AttrMinVersion: ShortString = 'Compatible with version 1.0 and higher'#0;
AttrName : ShortString = 'Simple encode algorythm'#0;
AttrID : ShortString = 'MyEncode8'#0;
AttrFlags : array[flagEncode..flagDecode] of ShortString = ('Encode Data'#0,
'Decode Data'#0);

//---------------------------------------------------------------------------
procedure DoEncode(Source, Dest: Pointer; SourceSize, DestSize: Cardinal);
var
i: Integer;
InB, OutB: PByte;
begin
InB:= Source;
OutB:= Dest;
for i:= 0 to SourceSize - 1 do
begin
OutB^:= InB^;
Inc(OutB^);
Inc(InB);
Inc(OutB);
end;
end;

//---------------------------------------------------------------------------
procedure DoDecode(Source, Dest: Pointer; SourceSize, DestSize: Cardinal);
var
i: Integer;
InB, OutB: PByte;
begin
InB:= Source;
OutB:= Dest;
for i:= 0 to SourceSize - 1 do
begin
OutB^:= InB^;
Dec(OutB^);
Inc(InB);
Inc(OutB);
end;
end;

//---------------------------------------------------------------------------
function PluginExec(Source, Dest: Pointer; SourceSize,
DestSize, Flags: Longword): Integer; stdcall;
begin
Result:= errFlags;

case Flags of
// compress the data
flagEncode:
begin
DoEncode(Source, Dest, SourceSize, DestSize);
Result:= SourceSize;
end;

// decompress the data
flagDecode:
begin
DoDecode(Source, Dest, SourceSize, DestSize);
Result:= SourceSize;
end;

// plugin parameters
flagParams:
begin
// change Result to >= 0, if successful
Result:= errFlags;
end;

// reset plugin
flagReset:
begin
// change Result to >= 0, if successful
Result:= errFlags;
end;
end; // case Flags of
end;

//---------------------------------------------------------------------------
function PluginEnum(EnumFunc: TEnumFunc; MiscParam: Longword): Integer; stdcall;
var
KeepGoing: Boolean;
cFlag: Longword;
begin
// number of successful calls
Result:= 0;

// plugin name
KeepGoing:= EnumFunc(AttribName, 0, @AttrName[1], MiscParam);
if (not KeepGoing) then Exit else Inc(Result);

// plugin id
KeepGoing:= EnumFunc(AttribID, 0, @AttrID[1], MiscParam);
if (not KeepGoing) then Exit else Inc(Result);

// plugin version
KeepGoing:= EnumFunc(AttribVersion, PluginVersion, @AttrVersion[1], MiscParam);
if (not KeepGoing) then Exit else Inc(Result);

// plugin minimal version
KeepGoing:= EnumFunc(attribMinVersion, PluginMinVersion, @AttrMinVersion[1], MiscParam);
if (not KeepGoing) then Exit else Inc(Result);

// encode flags
for cFlag:= flagEncode to flagParams do
begin
KeepGoing:= EnumFunc(attribFlags, cFlag, @AttrFlags[cFlag][1], MiscParam);
if (not KeepGoing) then Exit else Inc(Result);
end;
end;

//---------------------------------------------------------------------------
exports
PluginExec,
PluginEnum;

//---------------------------------------------------------------------------
// Plugin Initialization
//---------------------------------------------------------------------------
begin
end.

jansoft
19-10-2004, 02:13 PM
Yes, but can you provide example with usage of parameter ?

I need some "fixed" or "recommended" way of using parameters to implement it in VTDbManager (I know, that it cannot be 100% general, but if developer uses recomended way, he can use VTDbManager for setting param)
Now, VTDBMan shows all flags in plugin and if one of them is fsParam (or something like this), it displays editbox and user can set parameter of plugin usage. Parameter is then passed as PChar(editbox.text).

LP
21-10-2004, 12:05 AM
Sorry, but I did not understand you well...
Setting plugin parameters can be made in the same way you "encode" data, just passing "flagParams" and a pointer to plugin information. Currently, VTDbTool supplied with Asphyre does not support setting parameters but I'll try to make an example for this in the next release... things got slow now because I'm graduating and have thousand things to do which left me almost no time for development. Hopefully, this will be over soon....