Implement a memory DLL runner

This commit is contained in:
yuanyuanxiang
2025-04-21 02:39:00 +08:00
parent e9b0be2761
commit ca8ff799ef
6 changed files with 1572 additions and 20 deletions

View File

@@ -72,6 +72,13 @@ typedef struct PR {
}
}PR;
enum {
COMPRESS_UNKNOWN = -2, // δ֪ѹ<D6AA><D1B9><EFBFBD>
COMPRESS_ZLIB = -1, // <20><>ǰ<EFBFBD>ʹ<E6B1BE>õ<EFBFBD>ѹ<EFBFBD><D1B9><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
COMPRESS_ZSTD = 0, // <20><>ǰʹ<C7B0>õ<EFBFBD>ѹ<EFBFBD><D1B9><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
COMPRESS_NONE = 1, // û<><C3BB>ѹ<EFBFBD><D1B9>
};
struct CONTEXT_OBJECT;
// Header parser: parse the data to make sure it's from a supported client.
@@ -84,7 +91,7 @@ protected:
virtual ~HeaderParser() {
Reset();
}
PR Parse(CBuffer& buf) {
PR Parse(CBuffer& buf, int &compressMethod) {
const int MinimumCount = 8;
if (buf.GetBufferLength() < MinimumCount) {
return PR{ PARSER_NEEDMORE };
@@ -95,7 +102,7 @@ protected:
return memcmp(m_szPacketFlag, szPacketFlag, m_nCompareLen) == 0 ? PR{ m_nFlagLen } : PR{ PARSER_FAILED };
}
// More version may be added in the future.
const char version0[] = "Shine", version1[] = "<<FUCK>>";
const char version0[] = "Shine", version1[] = "<<FUCK>>", version2[] = "Hello?";
if (memcmp(version0, szPacketFlag, sizeof(version0) - 1) == 0) {
memcpy(m_szPacketFlag, version0, sizeof(version0) - 1);
m_nCompareLen = strlen(m_szPacketFlag);
@@ -112,6 +119,15 @@ protected:
m_bParsed = TRUE;
m_Encoder = new XOREncoder();
}
else if (memcmp(version2, szPacketFlag, sizeof(version2) - 1) == 0) {
memcpy(m_szPacketFlag, version2, sizeof(version2) - 1);
m_nCompareLen = strlen(m_szPacketFlag);
m_nFlagLen = 8;
m_nHeaderLen = m_nFlagLen + 8;
m_bParsed = TRUE;
compressMethod = COMPRESS_NONE;
m_Encoder = new Encoder();
}
else {
return PR{ PARSER_FAILED };
}
@@ -154,12 +170,6 @@ enum IOType
IOIdle
};
enum {
COMPRESS_UNKNOWN = -2, // δ֪ѹ<D6AA><D1B9><EFBFBD>
COMPRESS_ZLIB = -1, // <20><>ǰ<EFBFBD>ʹ<E6B1BE>õ<EFBFBD>ѹ<EFBFBD><D1B9><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
COMPRESS_ZSTD = 0, // <20><>ǰʹ<C7B0>õ<EFBFBD>ѹ<EFBFBD><D1B9><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
};
typedef struct CONTEXT_OBJECT
{
CString sClientInfo[10];
@@ -224,7 +234,7 @@ typedef struct CONTEXT_OBJECT
}
// Parse the data to make sure it's from a supported client. The length of `Header Flag` will be returned.
PR Parse(CBuffer& buf) {
return Parser.Parse(buf);
return Parser.Parse(buf, CompressMethod);
}
// Encode data before compress.
void Encode(PBYTE data, int len) const {