Skip to content

Commit

Permalink
Update + Repair
Browse files Browse the repository at this point in the history
  • Loading branch information
Vicshann committed Mar 13, 2019
1 parent 64b2629 commit 698d634
Show file tree
Hide file tree
Showing 36 changed files with 5,490 additions and 675 deletions.
2 changes: 1 addition & 1 deletion AFD.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,7 @@ struct SAFD_INFO_CONN // 0x28(Two addr?) - This structure is in InputBuffer
ULONG Unknown3;
PVOID UnkPtr;
USHORT AddrCnt; // Last addr should be empty?
UCHAR AddrLst[0]; // PH,PH,A0,A1,A2,A3
UCHAR AddrLst[0]; // PH,PL,A0,A1,A2,A3
};

struct SAFD_WSABUF
Expand Down
14 changes: 7 additions & 7 deletions CompileTime.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -183,11 +183,11 @@ __forceinline C* Decrypt(void) // Run-time decryption // There will be a copy

// Compile-time string encryption macro
#ifndef ctDISENCSTR
#define ctOENCSA(Str, Name) CT::ctCplEncryptedString<char, sizeof(Str), ctEncKey, ctEncKeyEx, CT::ctCplIndexes<AlignAsPtr(sizeof(Str))>::Result> Name(Str) // Str size includes a terminating NULL
#define ctOENCSW(Str, Name) CT::ctCplEncryptedString<wchar_t, sizeof(Str)/sizeof(wchar_t), ctEncKey, ctEncKeyEx, CT::ctCplIndexes<AlignAsPtr(sizeof(Str))>::Result> Name(Str) // Str size includes a terminating NULL
#define ctOENCSA(Str, Name) CT::ctCplEncryptedString<char, sizeof(Str), ctEncKey, ctEncKeyEx, CT::ctCplIndexes<CT::ctAlignAsPtr(sizeof(Str))>::Result> Name(Str) // Str size includes a terminating NULL
#define ctOENCSW(Str, Name) CT::ctCplEncryptedString<wchar_t, sizeof(Str)/sizeof(wchar_t), ctEncKey, ctEncKeyEx, CT::ctCplIndexes<CT::ctAlignAsPtr(sizeof(Str))>::Result> Name(Str) // Str size includes a terminating NULL

#define ctCENCSA(Str) CT::ctCplEncryptedString<char, sizeof(Str), ctEncKey, ctEncKeyEx, CT::ctCplIndexes<AlignAsPtr(sizeof(Str))>::Result>(Str) // Str size includes a terminating NULL
#define ctCENCSW(Str) CT::ctCplEncryptedString<wchar_t, sizeof(Str)/sizeof(wchar_t), ctEncKey, ctEncKeyEx, CT::ctCplIndexes<AlignAsPtr(sizeof(Str))>::Result>(Str) // Str size includes a terminating NULL
#define ctCENCSA(Str) CT::ctCplEncryptedString<char, sizeof(Str), ctEncKey, ctEncKeyEx, CT::ctCplIndexes<CT::ctAlignAsPtr(sizeof(Str))>::Result>(Str) // Str size includes a terminating NULL
#define ctCENCSW(Str) CT::ctCplEncryptedString<wchar_t, sizeof(Str)/sizeof(wchar_t), ctEncKey, ctEncKeyEx, CT::ctCplIndexes<CT::ctAlignAsPtr(sizeof(Str))>::Result>(Str) // Str size includes a terminating NULL

#define ctENCSA(Str) (ctCENCSA(Str).Decrypt()) // Str size includes a terminating NULL
#define ctENCSW(Str) (ctCENCSW(Str).Decrypt()) // Str size includes a terminating NULL
Expand Down Expand Up @@ -237,8 +237,8 @@ template<typename A, typename B> constexpr __forceinline int ctTNDif(const int o

struct SCplFuncInfo // Holds info about a TypeName position in a function signature for current compiler
{
static const int TypeOffs = ctTNDif<char,long>(0); // Offset of a type in a string
static const int TailSize = ctTNLen<char>(TypeOffs+4) - (TypeOffs+4); // Left of a full string // 4 is len of 'char' string
static constexpr int TypeOffs = ctTNDif<char,long>(0); // Offset of a type in a string
static constexpr int TailSize = ctTNLen<char>(TypeOffs+4) - (TypeOffs+4); // Left of a full string // 4 is len of 'char' string
};

// Helps to get name of a type without RTTI and RTL
Expand Down Expand Up @@ -268,4 +268,4 @@ constexpr unsigned int ctCplHash(const unsigned char* Str) { return (*
*/
//==============================================================================
}
#pragma warning(pop)
#pragma warning(pop)
52 changes: 52 additions & 0 deletions Crypto/Crc32.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,58 @@ static const UINT32 crc_table[256] = {
return crc_table[Idx];
}
//------------------------------------------------------------------------------
/*
unsigned int __stdcall CalcAlignedCRC32(unsigned __int8 *aData, signed int aSize)
{
unsigned __int8 *vData; // edx
unsigned int ResCRC; // eax
signed int i; // edi
unsigned int v5; // esi
int v6; // ecx
unsigned int v7; // eax
unsigned int v8; // eax
signed int v9; // ecx
int v10; // edi
int v11; // esi
vData = aData;
ResCRC = 0xFFFFFFFF;
for ( i = aSize; (unsigned __int8)vData & 3; --i )
{
if ( i <= 0 )
break;
ResCRC = Crc32Tbl[*vData++ ^ (unsigned __int8)ResCRC] ^ (ResCRC >> 8);// Byte CRC 32 loop
}
if ( i >= 4 )
{
v5 = (unsigned int)i >> 2;
i -= 4 * ((unsigned int)i >> 2);
do
{
v6 = *(_DWORD *)vData;
vData += 4;
v7 = ((v6 ^ ResCRC) >> 8) ^ Crc32Tbl[(unsigned __int8)(v6 ^ ResCRC)];
v8 = (((v7 >> 8) ^ Crc32Tbl[(unsigned __int8)v7]) >> 8) ^ Crc32Tbl[(unsigned __int8)(BYTE1(v7) ^ LOBYTE(Crc32Tbl[(unsigned __int8)v7]))];
ResCRC = Crc32Tbl[(unsigned __int8)v8] ^ (v8 >> 8);
--v5;
}
while ( v5 );
}
v9 = i;
v10 = i - 1;
if ( v9 )
{
v11 = v10 + 1;
do
{
ResCRC = Crc32Tbl[*vData++ ^ (unsigned __int8)ResCRC] ^ (ResCRC >> 8);
--v11;
}
while ( v11 );
}
return ResCRC;
}
*/
static UINT32 ByteCRC32(UINT32 crc, UINT8 val)
{
return Table((UINT8)crc ^ val) ^ (crc >> 8);
Expand Down
2 changes: 1 addition & 1 deletion Crypto/MD5.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -214,7 +214,7 @@ void Update(UINT8* inBuf, UINT inLen)
while (inLen--)
{
this->lpszBuffer[mdi++] = *inBuf++;
if (mdi == 0x40)
if (mdi == 0x40) // TODO: Optimize
{
UINT32 in[16];
for(int i = 0, ii = 0; i < 16; i++, ii += 4)in[i] = (((UINT32)this->lpszBuffer[ii+3]) << 24) | (((UINT32)this->lpszBuffer[ii+2]) << 16) | (((UINT32)this->lpszBuffer[ii+1]) << 8) | ((UINT32)this->lpszBuffer[ii]);
Expand Down
Loading

0 comments on commit 698d634

Please sign in to comment.