//////////////////////////////////////////////////////////////////////
// Decrypt Message From FrontCode Peer Cache Server
//
// Parameters
// pSrc : (IN) Message From Peer Cache Server. Buffer must be 132 bytes.
// pDst : (OUT) Primary Node Addresses. Buffer must be 120 bytes.
//
// Remarks
// Node Address Structure
//
// typedef struct TAG_NODEINFO {
// DWORD dwNodeIP; // Primary Node IP Addresses
// WORD wUDPPort; // Primary Node UDP Port
// WORD wTCPPort; // Primary Node TCP Port
// BYTE bFreePri; // Free Primary Connections
// BYTE bFreeSec; // Free Secondary Connections
// WORD wDummy; // Padding
// } NODEINFO, *PNODEINFO;
//
// Example
// NODEINFO NodeInfo[10];
// DecryptFrontCode(pBuff, (BYTE *)NodeInfo);
//
//////////////////////////////////////////////////////////////////////
MXSOCKAPI void DecryptFrontCode(const BYTE *pSrc, BYTE *pDst);
//////////////////////////////////////////////////////////////////////
// Create Crypt Key Block for send
//
// Parameters
// wID : (IN) Crypt Key ID.
// pBlock : (OUT) Key Block . Buffer must be 16 bytes.
//
// Remarks
// WPNP Key IDs
// 0x0050 : Primary Client
// 0x0051 : Primary Server
// 0x0052 : Secondary Client
// 0x0053 : Secondary Server
// 0x0057 : Chat Client
// 0x0058 : Chat Server
//
// Example
// BYTE KeyBlock[16];
// CreateCryptKeyID(0x0057, KeyBlock);
//
//////////////////////////////////////////////////////////////////////
MXSOCKAPI void CreateCryptKeyID(const WORD wID, BYTE *pBlock);
//////////////////////////////////////////////////////////////////////
// Get Key ID from Key Block
//
// Parameters
// pBlock : (IN) Key Block. Buffer must be 16 bytes.
//
// Return Value
// WPNP Key ID
//
//////////////////////////////////////////////////////////////////////
MXSOCKAPI const WORD GetCryptKeyID(const BYTE *pBlock);
//////////////////////////////////////////////////////////////////////
// Get Crypt Key from Key Block
//
// Parameters
// pBlock : (IN) Key Block. Buffer must be 16 bytes.
// pUpKey : (OUT) Pointer to Crypt Key for send
// pDwKey : (OUT) Pointer to Crypt Key for recv
//
// Return Value
// WPNP Key ID
//
//////////////////////////////////////////////////////////////////////
MXSOCKAPI const WORD GetCryptKey(const BYTE *pBlock, DWORD *pUpKey, DWORD *pDwKey);
//////////////////////////////////////////////////////////////////////
// Encrypt or Decrypt WPNP TCP Message
//
// Parameters
// pBuf : (IN) Message.
// iLen : (IN) Message Size.
// dwKey : (IN) Crypt Key
// Remarks
// WPNP TCP Message Format
//
// typedef struct TAG_MXTCPMESSAGE {
// WORD wType; // Message Type
// WORD wLen; // Data Length
// BYTE Data[0]; // Data
// } MXTCPMESSAGE, *PMXTCPMESSAGE;
//
// Return Value
// New Crypt Key
//
//////////////////////////////////////////////////////////////////////
MXSOCKAPI const DWORD DecryptMXTCP(BYTE *pBuf, const int iLen, const DWORD dwKey);
MXSOCKAPI const DWORD EncryptMXTCP(BYTE *pBuf, const int iLen, const DWORD dwKey);
//////////////////////////////////////////////////////////////////////
// Decrypt WPNP UDP Message
//
// Parameters
// pBuf : (IN) Message.
// iLen : (IN) Message Size.
//
//////////////////////////////////////////////////////////////////////
MXSOCKAPI void DecryptMXUDP(BYTE *pBuf, const int iLen);
//////////////////////////////////////////////////////////////////////
// Get File Hash from file
//
// Parameters
// lpszFileName : (IN) File Path.
// pHash : (OUT) File Hash.
// pFileLen : (OUT) File Length.
//
// Example
// DWORD dwHash;
// DWORD dwLen;
// GetFileHash("c:\\Example.avi", &dwHash, &dwLen);
//
// Return Value
// If no error occurs, GetFileHash returns TRUE
//
//////////////////////////////////////////////////////////////////////
MXSOCKAPI const BOOL GetFileHash(LPCTSTR lpszFileName, DWORD *pHash, DWORD *pFileLen);
Help me with importing c++ dll functions.
Hi, Im trying to import these functions from vb.net but i dont know what WORD and so on would be in vb.net and how I would call them.

Help me with importing c++ dll functions.
J.T. Shyman
I'm a C++ expert NOT! But I know a couple of things.
I just checked on the net and there were mentions of a VB compatible version of this DLL but you may be ahead of the game if you have sources.
I can recommend a couple of things. The difficult is in how the DLL entry points are defined.
Post a couple of entry points and if I can't help you someone else can.
Cgraus would be really helpful with this.
Renee
Craig Richardson
DllExport void CreateCryptKeyID(const WORD wID, BYTE *pBlock)
{
int i;
for(i=0 ; i < 16 ; i++)pBlock
pBlock[4] = pBlock[15] ^ pBlock[13] ^ pBlock[5] ^ pBlock[2];
pBlock[9] = (pBlock[14] ^ pBlock
pBlock[11] = (pBlock[12] ^ pBlock[10] ^ pBlock[7] ^ pBlock
for(i=0 ; i < 105 ; i++)
{
BYTE K = (i) pBlock[(i - 1) & 0x0F] : 0x57;
if(i % 5)pBlock[i & 0x0F] += K;
else pBlock[i & 0x0F] ^= K;
}
}
And so on
Sandman13
There is an alternative if we're good which is a wrapper dll.... that has inputs compatible with Basic and outputs compatible with C++ and vice-versa.
Dustin Campbell
WIll vs2005 translate his sources from V6 C++ to VS2005 C++
If that was the case... this should be easy since he has the sources......
Veg
The answer is maybe...
Is the dll registered Can it be registed with regsvr32 Where did it come from and who was the company What does the DLL do
If you knew how to interface it do you have the data it requires such as the Hash's and do you know the format of what the DLL needs
Does it have one extremely simple function interface-wise that we can try a few things with it
qingxisong
#define DllExport extern "C" __declspec(dllexport)
This doesn't look good. There is an interface VB likes that I forget but this doesn't look like it....
Cgraus is on his way......
MartinClayton
Here is the source - http://www.winmxunlimited.net/mxsock-c++6-code.zip
laslo67
Hugh Haggerty
Pietje_Gates
Well, in that case, Renee said there's a VB version. The other option is to use pinvoke, which will require matching between C++ and VB types, but otherwise will be a VB task.
Sowelie
You have a few options. If the DLL uses COM, make sure it's registered, and import it. It sounds like this is not the case. Pinvoke is the next option, www.pinvoke.net contains example signatures for lots of WinAPI functions, but I'm sure there are better *reference* sites for how to use it. Pinvoke can run any function from a dll, so long as it's exposed, and if it's not, then nothing can call it :-)
Depending on how much code is involved, you may prefer to write a C++/CLI DLL. Basically this means a dll which has a managed class, the managed class would wrap an instance of the unmanaged class you want to expose, call it's methods and return the result. Beware - VC6 was a very poor compiler, unless it was written by skilled developers, there is a good chance that your code won't compile in VC2005, which is where you need to be to make a C++/CLI DLL.
ISLAM AHMED
Ravindran GG
I have the source to it for c++6 if that will help.
m1n2i3s4ti5ka
These are the data definitions from Windef.h
The defined entity is on the right, thus a DWORD is an unsigned long
But you have to remember something.... A long here was 32 bits thus a DWORD is 32 bits (two 16 bit words)
In VB 2005 a long is 64 bits and in integer is 32 bits. In the .h file an integer is 16 bits both of which coincide with VB6.
typedef unsigned long DWORD;
typedef int BOOL;
typedef unsigned char BYTE;
typedef unsigned short WORD;
typedef float FLOAT;
typedef FLOAT *PFLOAT;
typedef BOOL near *PBOOL;
typedef BOOL far *LPBOOL;
typedef BYTE near *PBYTE;
typedef BYTE far *LPBYTE;
typedef int near *PINT;
typedef int far *LPINT;
typedef WORD near *PWORD;
typedef WORD far *LPWORD;
typedef long far *LPLONG;
typedef DWORD near *PDWORD;
typedef DWORD far *LPDWORD;
typedef void far *LPVOID;
typedef CONST void far *LPCVOID;
typedef int INT;
typedef unsigned int UINT;
typedef unsigned int *PUINT;
typedef unsigned long ULONG;
typedef ULONG *PULONG;
typedef unsigned short USHORT;
typedef USHORT *PUSHORT;
typedef unsigned char UCHAR;
typedef UCHAR *PUCHAR;
typedef char *PSZ;
As far as the other structures that are basic to C++ windef.h will definitely help.
windef.h maybe found at:
http://doc.ddart.net/msdn/header/include/windef.h.html
I hope this helps.