Results 1 to 4 of 4
  1. #1
    kofmaster
    kofmaster is offline
    New member
    Join Date
    2011 Jun
    Posts
    4
    Thanks Thanks Given 
    0
    Thanks Thanks Received 
    0
    Thanked in
    0 Posts
    Rep Power
    0

    can someone convert that? c to delphi ?

    Code:
        unsigned short table[] = {
            0x0068, 0x0005, 0x0007, 0x8000, 0x0002, 0x0005, 0x0005, 0x0007,
            0x000e, 0x0005, 0x000b, 0x0007, 0x8000, 0x0003, 0x8000, 0x003d,
            0x00d7, 0x8000, 0x8000, 0x000a, 0x0006, 0x0009, 0x8000, 0x8000,
            0x8000, 0x8000, 0x8000, 0x0025, 0x8000, 0x0005, 0x0004, 0x0008,
            0x0013, 0x0008, 0x0003, 0x001a, 0x0007, 0x0014, 0x0005, 0x0002,
            0x0005, 0x0001, 0x0005, 0x0002, 0x0002, 0x0011, 0x000f, 0x000a,
            0x0005, 0x8000, 0x0002, 0x0002, 0x000a, 0x028d, 0x8000, 0x0008,
            0x0007, 0x0009, 0x8000, 0x8000, 0x8000, 0x0002, 0x0025, 0x8000,
            0x00c9, 0x8000, 0x8000, 0x0229, 0x02c9, 0x0005, 0x8000, 0x000b,
            0x0049, 0x005d, 0x0005, 0x0009, 0x8000, 0x8000, 0x0006, 0x0002,
            0x8000, 0x8000, 0x8000, 0x0002, 0x000c, 0x0001, 0x000b, 0x006e,
            0x006a, 0x8000, 0x8000, 0x0004, 0x0002, 0x0049, 0x8000, 0x0031,
            0x0005, 0x0009, 0x000f, 0x000d, 0x0001, 0x0004, 0x8000, 0x0015,
            0x8000, 0x8000, 0x0003, 0x0009, 0x0013, 0x0003, 0x000e, 0x8000,
            0x001c, 0x8000, 0x0005, 0x0002, 0x8000, 0x0023, 0x0010, 0x0011,
            0x8000, 0x0009, 0x8000, 0x0002, 0x8000, 0x000d, 0x0002, 0x8000,
            0x003e, 0x8000, 0x0002, 0x0027, 0x0045, 0x0002, 0x8000, 0x8000,
            0x0042, 0x8000, 0x8000, 0x8000, 0x000b, 0x8000, 0x8000, 0x8000,
            0x0013, 0x0041, 0x8000, 0x0063, 0x8000, 0x0009, 0x8000, 0x0002,
            0x8000, 0x001a, 0x8000, 0x0102, 0x0135, 0x0033, 0x8000, 0x8000,
            0x0003, 0x0009, 0x0009, 0x0009, 0x0095, 0x8000, 0x8000, 0x0004,
            0x8000, 0x8000, 0x0005, 0x8000, 0x8000, 0x8000, 0x8000, 0x000d,
            0x8000, 0x8000, 0x8000, 0x8000, 0x8000, 0x0040, 0x0009, 0x8000,
            0x8000, 0x0003, 0x0006, 0x0009, 0x0003, 0x8000, 0x8000, 0x8000,
            0x0024, 0x8000, 0x8000, 0x8000, 0x0006, 0x00cb, 0x0001, 0x0031,
            0x0002, 0x0006, 0x0006, 0x0007, 0x8000, 0x0001, 0x8000, 0x004e,
            0x8000, 0x0002, 0x0019, 0x8000, 0x8000, 0x8000, 0x8000, 0x8000,
            0x8000, 0x010c, 0x8000, 0x8000, 0x0009, 0x8000
        };
    
        struct {
            unsigned int    e1;
            unsigned int    e2;
            unsigned int    e3;
            unsigned int    e4;
        } enco;
    
    
    
        void enccalc(unsigned int ip) {
            unsigned int    pi = ~ip;
    
            enco.e1 = ((pi ^ 0x1357) << 16) | ((ip ^ 0xaaaa) & 0x0000);
            enco.e2 = ((ip ^ 0x4321) >> 16) | ((pi ^ 0xabcd) & 0xffff);
            enco.e3 = (((ip ^ pi) & 0x0f0f) ^ ip) ^ 0xa76e;
            enco.e4 = (((ip ^ pi) & 0x0f0f) ^ pi) ^ 0xf4bc;
        }
    
    
    
        unsigned short pcklength(unsigned char *data) {
            if(*data < 222) {
                return(table[*data]);
            }
            return(0);
        }
    
    
    
        void cryptin(unsigned char *data, int len) {
            unsigned int    t1,
                            t2;
    
            for(; len--; data++) {
                *data   ^= enco.e1;
                t1       = enco.e1;
                t2       = enco.e2;
                enco.e1 = ((t1 >> 1) | (t2 << 31)) ^ 0x7e7f;
                t2       = ((t2 >> 1) | (t1 << 31)) ^ 0xa7ec;
                enco.e2 = ((t2 >> 1) | (t1 << 31)) ^ 0xa7ed;
            }
        }
    
    
    
        int logbuild(unsigned char *buff, unsigned char *come, unsigned char *doit) {
            int     len;
    
            buff[0] = 0x80;
            strncpy(buff + 1,      come, 30);
            strncpy(buff + 1 + 30, doit, 31);
            len = pcklength(buff);
            cryptin(buff, len);
            return(len);
        }

  2. #2
    Dwar
    Dwar is offline
    Veteran Dwar's Avatar
    Join Date
    2010 Mar
    Posts
    2,222
    Thanks Thanks Given 
    211
    Thanks Thanks Received 
    2,230
    Thanked in
    292 Posts
    Rep Power
    10
    unit Unit1;

    interface

    uses
    Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
    Dialogs;

    type
    TForm1 = class(TForm)
    private
    { Private declarations }
    public
    { Public declarations }
    end;

    Type
    ByteArray = array of byte;

    type
    enco = packed record
    e1: Cardinal;
    e2: Cardinal;
    e3: Cardinal;
    e4: Cardinal;
    end;

    var
    Form1: TForm1;
    Tenco: enco;

    const
    table : array [0..221] of word = (
    $0068, $0005, $0007, $8000, $0002, $0005, $0005, $0007,
    $000e, $0005, $000b, $0007, $8000, $0003, $8000, $003d,
    $00d7, $8000, $8000, $000a, $0006, $0009, $8000, $8000,
    $8000, $8000, $8000, $0025, $8000, $0005, $0004, $0008,
    $0013, $0008, $0003, $001a, $0007, $0014, $0005, $0002,
    $0005, $0001, $0005, $0002, $0002, $0011, $000f, $000a,
    $0005, $8000, $0002, $0002, $000a, $028d, $8000, $0008,
    $0007, $0009, $8000, $8000, $8000, $0002, $0025, $8000,
    $00c9, $8000, $8000, $0229, $02c9, $0005, $8000, $000b,
    $0049, $005d, $0005, $0009, $8000, $8000, $0006, $0002,
    $8000, $8000, $8000, $0002, $000c, $0001, $000b, $006e,
    $006a, $8000, $8000, $0004, $0002, $0049, $8000, $0031,
    $0005, $0009, $000f, $000d, $0001, $0004, $8000, $0015,
    $8000, $8000, $0003, $0009, $0013, $0003, $000e, $8000,
    $001c, $8000, $0005, $0002, $8000, $0023, $0010, $0011,
    $8000, $0009, $8000, $0002, $8000, $000d, $0002, $8000,
    $003e, $8000, $0002, $0027, $0045, $0002, $8000, $8000,
    $0042, $8000, $8000, $8000, $000b, $8000, $8000, $8000,
    $0013, $0041, $8000, $0063, $8000, $0009, $8000, $0002,
    $8000, $001a, $8000, $0102, $0135, $0033, $8000, $8000,
    $0003, $0009, $0009, $0009, $0095, $8000, $8000, $0004,
    $8000, $8000, $0005, $8000, $8000, $8000, $8000, $000d,
    $8000, $8000, $8000, $8000, $8000, $0040, $0009, $8000,
    $8000, $0003, $0006, $0009, $0003, $8000, $8000, $8000,
    $0024, $8000, $8000, $8000, $0006, $00cb, $0001, $0031,
    $0002, $0006, $0006, $0007, $8000, $0001, $8000, $004e,
    $8000, $0002, $0019, $8000, $8000, $8000, $8000, $8000,
    $8000, $010c, $8000, $8000, $0009, $8000
    );

    implementation
    //uses C2PTypes
    {$R *.dfm}

    procedure enccalc(ip: cardinal);
    var pi : cardinal;
    begin
    pi := ip xor -1; //bitwise NOT
    Tenco.e1 := ((pi xor $1357) shl 16) or ((ip xor $aaaa) and $0000);
    Tenco.e2 := ((ip xor $4321) shr 16) or ((pi xor $abcd) and $ffff);
    Tenco.e3 := (((ip xor pi) and $0f0f) xor ip) xor $a76e;
    Tenco.e4 := (((ip xor pi) and $0f0f) xor pi) xor $f4bc;
    end;

    function pcklength(data: byte): word;
    begin
    if(data < 222) then
    begin
    result := table[data];
    end;
    result := 0;

    end;

    procedure cryptin(data: ByteArray; len: integer);
    var
    t1, t2 : cardinal;
    i : integer;
    begin
    for I := 0 to len do
    begin
    data[i] := data[i] xor Tenco.e1;
    t1 := Tenco.e1;
    t2 := Tenco.e2;
    Tenco.e1 := ((t1 shr 1) or (t2 shl 31)) xor $7e7f;
    t2 := ((t2 shr 1) or (t1 shl 31)) xor $a7ec;
    Tenco.e2 := ((t2 shr 1) or (t1 shl 31)) xor $a7ed;
    end;
    end;

    function logbuild(var buff: ByteArray; var come: ByteArray; var doit: ByteArray): Integer;
    var
    len : integer;
    begin
    buff[0] := $80;
    //check this part
    move(come[0], buff[1], 30) ;
    move(doit[0], buff[31], 31);
    len := pcklength(buff[0]);
    cryptin(buff, len);
    result:=(len);
    end;

    end.

    Try this.
    Please, post your questions on forum, not by PM or mail

    I spend my time, so please pay a little bit of your time to keep world in equilibrium

  3. #3
    kofmaster
    kofmaster is offline
    New member
    Join Date
    2011 Jun
    Posts
    4
    Thanks Thanks Given 
    0
    Thanks Thanks Received 
    0
    Thanked in
    0 Posts
    Rep Power
    0
    oh thx man. i will just try

    ---------- Post added at 12:34 PM ---------- Previous post was at 11:47 AM ----------

    Quote Originally Posted by Dwar View Post
    unit Unit1;

    function logbuild(var buff: ByteArray; var come: ByteArray; var doit: ByteArray): Integer;
    var
    len : integer;
    begin
    buff[0] := $80;
    //check this part
    move(come[0], buff[1], 30) ;
    move(doit[0], buff[31], 31);
    len := pcklength(buff[0]);
    cryptin(buff, len);
    result:=(len);
    end;

    end.

    Try this.

    i was think this function, come and doit is a string or pchar.

    i cant use this function if they are not string..

  4. #4
    Dwar
    Dwar is offline
    Veteran Dwar's Avatar
    Join Date
    2010 Mar
    Posts
    2,222
    Thanks Thanks Given 
    211
    Thanks Thanks Received 
    2,230
    Thanked in
    292 Posts
    Rep Power
    10
    Quote Originally Posted by kofmaster View Post
    i was think this function, come and doit is a string or pchar.
    i cant use this function if they are not string..
    So, just convert your strings to byte array , or modify functions for strings (it's simplest task)
    Please, post your questions on forum, not by PM or mail

    I spend my time, so please pay a little bit of your time to keep world in equilibrium

Similar Threads

  1. [Delphi] Dll Injection functions
    By Dwar in forum Delphi
    Replies: 3
    Last Post: 2016-06-17, 11:18 PM
  2. [Delphi] Simple Dll Injection
    By Dwar in forum Delphi
    Replies: 1
    Last Post: 2012-03-29, 04:14 PM
  3. Convert small function C to Delphi
    By [E]Key in forum Delphi
    Replies: 2
    Last Post: 2011-03-26, 01:46 PM
  4. [Delphi] Delphi Training Video
    By Dwar in forum Programming Tutorials
    Replies: 0
    Last Post: 2010-11-29, 04:10 PM
  5. [Delphi] Creating DLLs
    By Dwar in forum Delphi
    Replies: 0
    Last Post: 2010-11-04, 09:58 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •