Results 1 to 3 of 3
  1. #1
    [E]Key
    [E]Key is offline
    Guest
    Join Date
    2011 Feb
    Posts
    2
    Thanks
    1
    Thanked 0 Times in 0 Posts
    Rep Power
    0

    Question Convert small function C to Delphi

    Hey all, any1 can help convert small function writen on C to Delphi ?

    Code:
    #ifndef SSR_FILE_FORMAT_H_
    #define SSR_FILE_FORMAT_H_
    
    #define TRUE_SSR_IDENTIFIER (('S') + ('S' << 8) + ('R' << 16) + ('2' << 24))
    
    typedef struct t_ssrheader {
        DWORD   numOfFiles;
        DWORD   contentOffset;
        DWORD   contentSize;
        DWORD   extra;
    } SSR_HEADER;
    
    typedef struct t_ssrcontentheader {
        DWORD   extra1;
        DWORD   fileOffset;
        DWORD   extra2;
        char    filename[16];
    } SSR_CONTENT_HEADER;
    
    typedef struct t_ssrfileheader {
        DWORD           extra1;
        DWORD           extra2;
        DWORD           extra3;
        DWORD           extra4;
        DWORD           fileSize;
        DWORD           extra5;
        unsigned char   filenameLength;
        char            extra6[7];
    } SSR_FILE_HEADER;
    
    #endif
    Code:
    void Decrypt(void *buffer, unsigned int byteCount, unsigned int key1, unsigned int key2) {
        unsigned char   *pKey;
        unsigned int    byteCount64;
        __int64         *buffer64;
        unsigned char   *pByte;
        unsigned int    cBytes;
        unsigned int    keys[2] = { key2, key1 };
    
        buffer64 = (__int64 *)buffer;
        byteCount64 = byteCount / 8;
    
        for (; byteCount64; --byteCount64, ++buffer64) {
            unsigned int    ulong;
            unsigned int    *pLong = ((unsigned int *)buffer64);
    
            ulong = *pLong;
            *pLong = ~((~ulong) ^ key2);
            ++pLong;
            ulong = *pLong;
            *pLong = ~((~ulong) ^ key1);
        }
    
        pByte = ((unsigned char *)buffer64);
        cBytes = byteCount % 8;
        pKey = ((unsigned char *)keys);
    
        for (; cBytes; --cBytes, ++pByte, ++pKey) {
            unsigned char byte  = *pByte;
            unsigned char key   = *pKey;
    
            *pByte = (unsigned char)(~((~byte) ^ key));
        }
    }
    PS: Sorry if wrong section

  2. #2
    Dwar
    Dwar is offline
    Veteran Dwar's Avatar
    Join Date
    2010 Mar
    Posts
    2,221
    Thanks
    211
    Thanked 2,224 Times in 289 Posts
    Rep Power
    10
    Hi,
    I'm not sure, but here is a draft conversion
    const TRUE_SSR_IDENTIFIER =  (('S'( + ('S' shl 8) + ('R' shl 16) + ('2' shl 24));

    type
    t_ssrheader = record
    numOfFiles : DWORD;
    contentOffset : DWORD;
    contentSize : DWORD;
    extra : DWORD;
    end;
    SSR_HEADER = t_ssrheader;

    type
    t_ssrcontentheader = record
    extra1 : DWORD;
    fileOffset : DWORD;
    extra2 : DWORD;
    filename : array[0..15] of char;
    end;
    SSR_CONTENT_HEADER = t_ssrcontentheader;

    type
    t_ssrfileheader = record
    extra1 : DWORD;
    extra2 : DWORD;
    extra3 : DWORD;
    extra4 : DWORD;
    fileSize : DWORD;
    extra5 : DWORD;
    filenameLength: Byte;
    extra6 : array[0..6] of char;
    end;
    SSR_FILE_HEADER = t_ssrfileheader;


    procedure Decrypt(buffer, byteCount, key1, key2: integer);
    var
    keys : array [0..1] of cardinal;
    pKey : byte;
    byteCount64 : cardinal;
    buffer64 : int64;
    pByte : byte;
    key : byte;
    cbyte : byte;
    cBytes : integer;
    i : integer;
    ulong : cardinal
    buffer64 := (Int64 )buffer;
    begin
    keys[0] := key2;
    keys[1] := key1;
    byteCount64 := byteCount / 8;

    for i := 0 to byteCount64 do
    begin

    //Cardinal *pLong := ((Cardinal )buffer64);

    //ulong := *pLong;
    pLong := not((not ulong) xor key2);
    inc(pLong);
    //ulong := *pLong;
    pLong := not ((not ulong) xor key1);
    end;

    pByte := ((Byte )buffer64);
    cBytes := byteCount mod 8;
    pKey := ((Byte )keys);

    for i:=0 to do //(; cBytes; --cBytes, ++pByte, ++pKey)
    begin
    cbyte := *pByte;
    key := *pKey;
    *pByte := not((not cbyte) xor key);
    end;
    end;
    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. The Following User Says Thank You to Dwar For This Useful Post:


  4. #3
    [E]Key
    [E]Key is offline
    Guest
    Join Date
    2011 Feb
    Posts
    2
    Thanks
    1
    Thanked 0 Times in 0 Posts
    Rep Power
    0
    Awesome! Thanks Dwar

Visitors found this page by searching for:

C to delphi

delphi pbyte

c to delphi converter

delphi unsigned char *

unsigned char delphi

convert c to delphi online

delphi unsigned char

delphi dword

ctodelphi converter

dword converter

delphi to c converter online

c to delphi converter online

online delphi to c converter

c pbyte delphi

unsigned char* delphi

delphi to c online converter

C 2 Delphi Converter crackdelphi unsigned char [2]unsigned char* to delphidelphi dword shl 24c to delphi online translatordelphi cbytedelphi c structvoid function delphic delphi Pbyte

Posting Permissions

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