Patch WinMX ::: Developer Center ::: WinMX Encryption  ::: C++ Encryption Information
Patch WinMX ::: Developer Center ::: Encryption ::: C++ Encryption Information

WinMX Encryption For C++:

Download the MXSock.dll + Header file here

Decrypting/Encrypting Functions (C++):


Below shows how to use the encryption functions and what they are for.

 

DecryptFrontCode(const BYTE *pSrc, BYTE *pDst):
When connecting to a cache server to get 10 primary nodes, they are encrypted and this is what you need to use to decrypt them.

Parameters:

pSrc: (IN) - Message from peer cache server. Buffer must be 132 Bytes.
pDst: (Out) - Primary Node Addresses. - 120 Bytes

Node Structure:

DWORD [4] IPAddress
WORD   [2] UDPPort
WORD   [2] TCPPort
BYTE     [1] Free Primaries
BYTE     [1] Free Secondaries
WORD   [2] Blank for splitting

 

void CreateCryptKeyID(const WORD wID, BYTE *pBlock):
When connecting to any WinMX Server/Client they all use encryption and you must use Encryption keys to communicate with each other to tell what you are.

Crypt Key ID Options:

0x0050 - Primary Client
0x0051 - Primary Server
0x0052 - Secondary Client
0x0053 - Secondary Server
0x0054 - Cache Server
0x0057 - Chat Client
0x0058 - Chat Server

Parameters:

wDI: (IN) - The Crypt Key ID
pBlock: (Out) - Key Block. Buffer must be 16 bytes.

 

const WORD GetCryptKeyID(const BYTE *pBlock):
This checks a key block for the Key ID.


Parameters:

pBlock: (IN) - The Key Block. 16 bytes.

Return Value:

WNPN Key ID

 

const WORD GetCryptKey(const BYTE *pBlock, DWORD *pUpKey, DWORD *pDwKey):
When establishing the encryption between a client and server for the WinMX network, they need to extract the encryption keys from the key blocks. There is a key for data sent and there is a key for the data received. They both mutate when run through the encryption/decryption algorithm.


Parameters:

pBlock: (IN) - The Key Block. 16 Bytes.
pUpKey (Out) - The Upload Key
pDwKey (Out) - The Download Key

Return Value:

WNPN Key ID

 

const DWORD EncryptMXTCP(BYTE *pBuf, const int iLen, const DWORD dwKey):
When communicating with other WinMX clients or servers on a TCP connection the data is encrypted. This function encrypts the data, and the return value is the new encryption key.


Parameters:

pBuf: (IN) - The Data to be encrypted
iLen (IN) - The Length of the data
dwKey (IN) - The Crypt Key (Upload)

Return Value:

New Crypt Key (Upload)

 

const DWORD DecryptMXTCP(BYTE *pBuf, const int iLen, const DWORD dwKey):
When communicating with other WinMX clients or servers on a TCP connection the data is encrypted. This function encrypts the data, and the return value is the new encryption key.


Parameters:

pBuf: (IN) - The Data to be decrypted
iLen (IN) - The Length of the data
dwKey (IN) - The Crypt Key (Download)

Return Value:

New Crypt Key (Download)

 

void EncryptMXUDP(BYTE *pBuf, const int iLen):
When communicating with other WinMX clients or servers on a UDP connection, there is no mutating encryption key, but it's still encrypted. UDP is used for the Primary Protocol.


Parameters:

pBuf: (IN) - The Data to be encrypted
iLen (IN) - The Length of the data

 

void DecryptMXUDP(BYTE *pBuf, const int iLen):
When communicating with other WinMX clients or servers on a UDP connection, there is no mutating encryption key, but it's still encrypted. UDP is used for the Primary Protocol.


Parameters:

pBuf: (IN) - The Data to be decrypted
iLen (IN) - The Length of the data

 

const BOOL GetFileHash(LPCTSTR lpszFileName, DWORD *pHash, DWORD *pFileLen):
When searching, downloading, and sharing files on WinMX, they all have their own HASH ID. This sets apart the file from all the other files on the network and is used to identify them while searching, downloading, and uploading.


Parameters:

lpszFileName: (IN) - The file path of the file you want to be hashed.
pHash (OUT) - The File Hash.
pFileLen (OUT) - The length of the file.

Return Value:

If there was no error, it will return TRUE.

 

Note: If you find any errors or have any more questions please post in the forum under the encryption section. Thanks.


 
© Copyright 2008-2009 PatchWinMX.com, All Rights Reserved.