Results 1 to 2 of 2

Thread: Simple problem

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Jul 2002
    Posts
    68

    Simple problem

    Well I wanted to put 2 c++ functions in a dll so I could use them in my vb project but when I comple I get these 2 errors:

    D:\coding\madchat dll\Cdkeyhash.cpp(15) : error C2065: 'HashData' : undeclared identifier
    D:\coding\madchat dll\Cdkeyhash.cpp(26) : error C2373: 'HashData' : redefinition; different type modifiers

    heres the code:
    Code:
    #include <windows.h>
    #include <stdlib.h>
    #include <stdio.h>
    
    #define ROL(nr, shift)	((nr << shift) | (nr >> (32 - shift)))
    
    bool HashCDKey(DWORD*key, DWORD*seed, DWORD*prodid, DWORD*val1, DWORD*val2)
    {
    	DWORD dwHashBuff[5];
    	dwHashBuff[0] = *key;
    	dwHashBuff[1] = *seed;
    	dwHashBuff[2] = *prodid;
    	dwHashBuff[3] = *val1;
    	dwHashBuff[4] = *val2;
    	HashData(dwHashBuff, 20, dwHashBuff); 
    
    	*key = dwHashBuff[0];
    	*seed = dwHashBuff[1];
    	*prodid = dwHashBuff[2];
    	*val1 = dwHashBuff[3];
    	*val2 = dwHashBuff[4];
    	return TRUE;
    }
    
    void HashData(void* lpSource, int nLength, void* lpResult)
    {
       BYTE bBuffer[1024];
       int i;
       DWORD a, b, c, d, e, g, * lpdwBuffer;
    
       ZeroMemory(bBuffer, 1024);
       CopyMemory(bBuffer, lpSource, nLength);
       lpdwBuffer = (LPDWORD) bBuffer;
    
       for (i=0; i<64; i++)
          lpdwBuffer[i+16] = ROL(1, (lpdwBuffer[i] ^ lpdwBuffer[i+8] ^
                                 lpdwBuffer[i+2] ^ lpdwBuffer[i+13]) % 32);
       a = 0x67452301lu;
       b = 0xefcdab89lu;
       c = 0x98badcfelu;
       d = 0x10325476lu;
       e = 0xc3d2e1f0lu;
       for (i = 0; i < (20 * 1); i++)
       {
          g = lpdwBuffer[i] + ROL(a,5) + e + ((b & c) | (~b & d)) + 0x5a827999lu;
          e = d;
          d = c;
          c = ROL(b,30);
          b = a;
          a = g;
       }
       for (; i < (20 * 2); i++)
       {
          g = (d ^ c ^ b) + e + ROL(g,5) + lpdwBuffer[i] + 0x6ed9eba1lu;
          e = d;
          d = c;
          c = ROL(b,30);
          b = a;
          a = g;
       }
       for (; i < (20 * 3); i++)
       {
          g = lpdwBuffer[i] + ROL(g,5) + e + ((c & b) | (d & c) | (d & b)) -
              0x70e44324lu;
          e = d;
          d = c;
          c = ROL(b,30);
          b = a;
          a = g;
       }
       for (; i < (20 * 4); i++)
       {
          g = (d ^ c ^ b) + e + ROL(g,5) + lpdwBuffer[i] - 0x359d3e2alu;
          e = d;
          d = c;
          c = ROL(b,30);
          b = a;
          a = g;
       }
    
       lpdwBuffer = (LPDWORD) lpResult;
       lpdwBuffer[0] = 0x67452301lu + g;
       lpdwBuffer[1] = 0xefcdab89lu + b;
       lpdwBuffer[2] = 0x98badcfelu + c;
       lpdwBuffer[3] = 0x10325476lu + d;
       lpdwBuffer[4] = 0xc3d2e1f0lu + e;
       return;
    }
    -Maddox

  2. #2
    Addicted Member HairyDave's Avatar
    Join Date
    Aug 2002
    Location
    Er...I can't remember.
    Posts
    196
    I think you need a function prototype.

    At the top of the file (or in a corresponding header file) you need the line:

    Code:
    void HashData(void* lpSource, int nLength, void* lpResult);
    This has to appear before any other reference to the function. Both errors are caused by it. I tend to do this for every function used - its easier to see whats defined in the file.

    HD

Posting Permissions

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



Click Here to Expand Forum to Full Width