Zwei Pointer mit einander verbinden
-
Hallo Leute, ich weiß nicht ob das Möglich ist, aber ich würde gerne zwei pointer mit einander verbinden.
Hier ist mein Code:
#include "windows.h" #include "Modules.h" #include "fastMD5.cpp" BOOL APIENTRY DllMain(HANDLE hModule, DWORD ul_reason_for_call, LPVOID lpReserved) { return TRUE; } // extern "C" __declspec(dllexport) void GetInfo(MODULEINFO *); // extern "C" __declspec(dllexport) int GetHash(HASHINFO *); // extern "C" __declspec(dllexport) int GetSalt(SALTINFO *); // extern "C" __declspec(dllexport) int GetPreparedHash(PREPAREDHASHINFO *); // extern "C" __declspec(dllexport) int GetPreparedSalt(PREPAREDSALTINFO *); extern "C" __declspec(dllexport) void GetInfo(MODULEINFO *info) { info->dwFlags = MODULE_HASH_BINARY | MODULE_HASH_SIMPLE; info->szAbout = "Type of hashes: MD5()\nMade by Nilix"; info->szHashType = "MD5()"; } extern "C" __declspec(dllexport) int GetHash(HASHINFO *info) { // Hash generation fast_MD5((unsigned char*)info->szPassword, info->nPasswordLen, info->pBuf); // Length of hash return 16; }
Und zwar würde ich das gerne beim Methodenaufruf machen
fast_MD5((unsigned char*)info->szPassword, info->nPasswordLen, info->pBuf);
Bei info->pBuf (es sollen 2 gleiche Strings aneinander geknüpft werden)
mit info.Equals(info->pBuf, info->pBuf) geht es nicht da es kein Klassen Sting variable ist.
Und mit dem . oder + Operator ist es ein völliger schmarn
Kann mir jemand bitte helfen?
-
1. Falsches Forum, dein Problem hat nichts mit Spiele- /Grafikprogrammierung zu tun.
2. Zeig mal die Definition von fast_MD5( ) her.
-
1.oh sorry hab mich wohl verklickt
2. Hier:
/* * Fast implementation of the MD5 message-digest algorithm as per RFC * (see http://tools.ietf.org/html/rfc1321) * * Author: Joao Inacio <jcinacio at gmail.com> * License: Use and share as you wish at your own risk, please keep this header ;) * * Optimizations: * - For lengths < 16, transformation steps are "unrolled" using macros/defines * - Constants used whenever possible, it's the compiler's job to sort them out * - Padding is done on 4-byte words, and memory copied as last resort. */ extern "C" { typedef unsigned int UINT4; /* MD5 defines as per RFC reference implementation */ #define AC1 0xd76aa478 #define AC2 0xe8c7b756 #define AC3 0x242070db #define AC4 0xc1bdceee #define AC5 0xf57c0faf #define AC6 0x4787c62a #define AC7 0xa8304613 #define AC8 0xfd469501 #define AC9 0x698098d8 #define AC10 0x8b44f7af #define AC11 0xffff5bb1 #define AC12 0x895cd7be #define AC13 0x6b901122 #define AC14 0xfd987193 #define AC15 0xa679438e #define AC16 0x49b40821 #define AC17 0xf61e2562 #define AC18 0xc040b340 #define AC19 0x265e5a51 #define AC20 0xe9b6c7aa #define AC21 0xd62f105d #define AC22 0x02441453 #define AC23 0xd8a1e681 #define AC24 0xe7d3fbc8 #define AC25 0x21e1cde6 #define AC26 0xc33707d6 #define AC27 0xf4d50d87 #define AC28 0x455a14ed #define AC29 0xa9e3e905 #define AC30 0xfcefa3f8 #define AC31 0x676f02d9 #define AC32 0x8d2a4c8a #define AC33 0xfffa3942 #define AC34 0x8771f681 #define AC35 0x6d9d6122 #define AC36 0xfde5380c #define AC37 0xa4beea44 #define AC38 0x4bdecfa9 #define AC39 0xf6bb4b60 #define AC40 0xbebfbc70 #define AC41 0x289b7ec6 #define AC42 0xeaa127fa #define AC43 0xd4ef3085 #define AC44 0x04881d05 #define AC45 0xd9d4d039 #define AC46 0xe6db99e5 #define AC47 0x1fa27cf8 #define AC48 0xc4ac5665 #define AC49 0xf4292244 #define AC50 0x432aff97 #define AC51 0xab9423a7 #define AC52 0xfc93a039 #define AC53 0x655b59c3 #define AC54 0x8f0ccc92 #define AC55 0xffeff47d #define AC56 0x85845dd1 #define AC57 0x6fa87e4f #define AC58 0xfe2ce6e0 #define AC59 0xa3014314 #define AC60 0x4e0811a1 #define AC61 0xf7537e82 #define AC62 0xbd3af235 #define AC63 0x2ad7d2bb #define AC64 0xeb86d391 #define S11 7 #define S12 12 #define S13 17 #define S14 22 #define S21 5 #define S22 9 #define S23 14 #define S24 20 #define S31 4 #define S32 11 #define S33 16 #define S34 23 #define S41 6 #define S42 10 #define S43 15 #define S44 21 #define Ca 0x67452301 #define Cb 0xefcdab89 #define Cc 0x98badcfe #define Cd 0x10325476 #define F(x, y, z) ((z) ^ ((x) & ((y) ^ (z)))) #define G(x, y, z) ((y) ^ ((z) & ((x) ^ (y)))) #define H(x, y, z) ((x) ^ (y) ^ (z)) #define I(x, y, z) ((y) ^ ((x) | ~(z))) #define ROTATE_LEFT(x, n) (((x) << (n)) | ((x) >> (32-(n)))) // md5 step #define MD5STEP(f, a, b, c, d, AC, x, s) { \ (a) += f ((b), (c), (d)); \ (a) += (AC) + (x); \ (a) = ROTATE_LEFT ((a), (s)); \ (a) += (b); \ } // full MD5 transformation #define MD5_steps(w0, w1, w2, w3, w4, w5, w6, w7, w8, w9, w10, w11, w12, w13, w14, w15) { \ \ MD5STEP(F, a, b, c, d, AC1, w0, S11);\ MD5STEP(F, d, a, b, c, AC2, w1, S12);\ MD5STEP(F, c, d, a, b, AC3, w2, S13);\ MD5STEP(F, b, c, d, a, AC4, w3, S14);\ MD5STEP(F, a, b, c, d, AC5, w4, S11);\ MD5STEP(F, d, a, b, c, AC6, w5, S12);\ MD5STEP(F, c, d, a, b, AC7, w6, S13);\ MD5STEP(F, b, c, d, a, AC8, w7, S14);\ MD5STEP(F, a, b, c, d, AC9, w8, S11);\ MD5STEP(F, d, a, b, c, AC10, w9, S12);\ MD5STEP(F, c, d, a, b, AC11, w10, S13);\ MD5STEP(F, b, c, d, a, AC12, w11, S14);\ MD5STEP(F, a, b, c, d, AC13, w12, S11);\ MD5STEP(F, d, a, b, c, AC14, w13, S12);\ MD5STEP(F, c, d, a, b, AC15, w14, S13);\ MD5STEP(F, b, c, d, a, AC16, w15, S14);\ \ MD5STEP(G, a, b, c, d, AC17, w1, S21);\ MD5STEP(G, d, a, b, c, AC18, w6, S22);\ MD5STEP(G, c, d, a, b, AC19, w11, S23);\ MD5STEP(G, b, c, d, a, AC20, w0, S24);\ MD5STEP(G, a, b, c, d, AC21, w5, S21);\ MD5STEP(G, d, a, b, c, AC22, w10, S22);\ MD5STEP(G, c, d, a, b, AC23, w15, S23);\ MD5STEP(G, b, c, d, a, AC24, w4, S24);\ MD5STEP(G, a, b, c, d, AC25, w9, S21);\ MD5STEP(G, d, a, b, c, AC26, w14, S22);\ MD5STEP(G, c, d, a, b, AC27, w3, S23);\ MD5STEP(G, b, c, d, a, AC28, w8, S24);\ MD5STEP(G, a, b, c, d, AC29, w13, S21);\ MD5STEP(G, d, a, b, c, AC30, w2, S22);\ MD5STEP(G, c, d, a, b, AC31, w7, S23);\ MD5STEP(G, b, c, d, a, AC32, w12, S24);\ \ MD5STEP(H, a, b, c, d, AC33, w5, S31);\ MD5STEP(H, d, a, b, c, AC34, w8, S32);\ MD5STEP(H, c, d, a, b, AC35, w11, S33);\ MD5STEP(H, b, c, d, a, AC36, w14, S34);\ MD5STEP(H, a, b, c, d, AC37, w1, S31);\ MD5STEP(H, d, a, b, c, AC38, w4, S32);\ MD5STEP(H, c, d, a, b, AC39, w7, S33);\ MD5STEP(H, b, c, d, a, AC40, w10, S34);\ MD5STEP(H, a, b, c, d, AC41, w13, S31);\ MD5STEP(H, d, a, b, c, AC42, w0, S32);\ MD5STEP(H, c, d, a, b, AC43, w3, S33);\ MD5STEP(H, b, c, d, a, AC44, w6, S34);\ MD5STEP(H, a, b, c, d, AC45, w9, S31);\ MD5STEP(H, d, a, b, c, AC46, w12, S32);\ MD5STEP(H, c, d, a, b, AC47, w15, S33);\ MD5STEP(H, b, c, d, a, AC48, w2, S34);\ \ MD5STEP(I, a, b, c, d, AC49, w0, S41);\ MD5STEP(I, d, a, b, c, AC50, w7, S42);\ MD5STEP(I, c, d, a, b, AC51, w14, S43);\ MD5STEP(I, b, c, d, a, AC52, w5, S44);\ MD5STEP(I, a, b, c, d, AC53, w12, S41);\ MD5STEP(I, d, a, b, c, AC54, w3, S42);\ MD5STEP(I, c, d, a, b, AC55, w10, S43);\ MD5STEP(I, b, c, d, a, AC56, w1, S44);\ MD5STEP(I, a, b, c, d, AC57, w8, S41);\ MD5STEP(I, d, a, b, c, AC58, w15, S42);\ MD5STEP(I, c, d, a, b, AC59, w6, S43);\ MD5STEP(I, b, c, d, a, AC60, w13, S44);\ MD5STEP(I, a, b, c, d, AC61, w4, S41);\ MD5STEP(I, d, a, b, c, AC62, w11, S42);\ MD5STEP(I, c, d, a, b, AC63, w2, S43);\ MD5STEP(I, b, c, d, a, AC64, w9, S44);\ } // len >= 56 #define MD5_transform_add(w0, w1, w2, w3, w4, w5, w6, w7, w8, w9, w10, w11, w12, w13, w14, w15) { \ \ a = wOut[0]; b = wOut[1]; c = wOut[2]; d = wOut[3];\ \ MD5_steps(w0, w1, w2, w3, w4, w5, w6, w7, w8, w9, w10, w11, w12, w13, w14, w15);\ \ wOut[0] += a; wOut[1] += b; wOut[2] += c; wOut[3] += d;\ } // len < 56 #define MD5_transform_single(w0, w1, w2, w3, w4, w5, w6, w7, w8, w9, w10, w11, w12, w13, w14, w15) { \ \ a = CC[0]; b=CC[1]; c=CC[2]; d=CC[3];\ \ MD5_steps(w0, w1, w2, w3, w4, w5, w6, w7, w8, w9, w10, w11, w12, w13, w14, w15);\ \ wOut[0] = a+Ca; wOut[1] = b+Cb; wOut[2] = c+Cc; wOut[3] = d+Cd;\ } // len < 16 #define MD5_transform_16(w0, w1, w2, w3, w14) \ MD5_transform_single(w0, w1, w2, w3, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, w14, 0); // pad word and append 0x80 at appropriate location #define MD5_pad_w0() (0x00000080) #define MD5_pad_w1(data) (((data) & 0x000000FF) | 0x00008000) #define MD5_pad_w2(data) (((data) & 0x0000FFFF) | 0x00800000) #define MD5_pad_w3(data) (((data) & 0x00FFFFFF) | 0x80000000) static inline void MD5_copy_pad_block(UINT4 *dData, UINT4 *wIn, int blocklen, int len) { register int cl; // copy full words for (cl = 0; cl < blocklen; cl++) dData[cl] = wIn[cl]; // copy with padding switch (len & 0x03) { case 0: dData[cl] = MD5_pad_w0(); break; case 1: dData[cl] = MD5_pad_w1(wIn[cl]); break; case 2: dData[cl] = MD5_pad_w2(wIn[cl]); break; case 3: dData[cl] = MD5_pad_w3(wIn[cl]); break; } // append 0's for (cl++; cl < 14; cl++) dData[cl] = 0; // append len dData[cl++] = (len << 3); dData[cl] = (len >> 29); } // fast initializer array static const UINT4 CC[4] = {Ca, Cb, Cc, Cd}; /* * fast_MD5() * */ void fast_MD5(unsigned char *pData, int len, unsigned char *pDigest) { #define wIn ((UINT4 *)pData) #define wOut ((UINT4 *)pDigest) register UINT4 a; register UINT4 b; register UINT4 c; register UINT4 d; switch (len) { case 0: MD5_transform_16(MD5_pad_w0(), 0, 0, 0, 8*0); return; case 1: MD5_transform_16(MD5_pad_w1(wIn[0]), 0, 0, 0, 8*1); return; case 2: MD5_transform_16(MD5_pad_w2(wIn[0]), 0, 0, 0, 8*2); return; case 3: MD5_transform_16(MD5_pad_w3(wIn[0]), 0, 0, 0, 8*3); return; case 4: MD5_transform_16(wIn[0], MD5_pad_w0(), 0, 0, 8*4); return; case 5: MD5_transform_16(wIn[0], MD5_pad_w1(wIn[1]), 0, 0, 8*5); return; case 6: MD5_transform_16(wIn[0], MD5_pad_w2(wIn[1]), 0, 0, 8*6); return; case 7: MD5_transform_16(wIn[0], MD5_pad_w3(wIn[1]), 0, 0, 8*7); return; case 8: MD5_transform_16(wIn[0], wIn[1], MD5_pad_w0(), 0, 8*8); return; case 9: MD5_transform_16(wIn[0], wIn[1], MD5_pad_w1(wIn[2]), 0, 8*9); return; case 10: MD5_transform_16(wIn[0], wIn[1], MD5_pad_w2(wIn[2]), 0, 8*10); return; case 11: MD5_transform_16(wIn[0], wIn[1], MD5_pad_w3(wIn[2]), 0, 8*11); return; case 12: MD5_transform_16(wIn[0], wIn[1], wIn[2], MD5_pad_w0(), 8*12); return; case 13: MD5_transform_16(wIn[0], wIn[1], wIn[2], MD5_pad_w1(wIn[3]), 8*13); return; case 14: MD5_transform_16(wIn[0], wIn[1], wIn[2], MD5_pad_w2(wIn[3]), 8*14) return; case 15: MD5_transform_16(wIn[0], wIn[1], wIn[2], MD5_pad_w3(wIn[3]), 8*15) return; } // data block used for padding UINT4 dData[16]; if (len < 56) { // 16 < length < 56 MD5_copy_pad_block(dData, wIn, (len >> 2), len); // redefine data input, point to padded data #undef wIn #define wIn dData MD5_transform_single ( wIn[ 0], wIn[ 1], wIn[ 2], wIn[ 3], wIn[ 4], wIn[ 5], wIn[ 6], wIn[ 7], wIn[ 8], wIn[ 9], wIn[10], wIn[11], wIn[12], wIn[13], wIn[14], wIn[15] ); #undef wIn return; } else { // len >= 56 #define wIn ((UINT4 *)pData) // original len int tlen = len; // init digest for long lens wOut[0] = Ca; wOut[1] = Cb; wOut[2] = Cc; wOut[3] = Cd; while (tlen >= 64) { // Process 64-byte chunks MD5_transform_add( wIn[ 0], wIn[ 1], wIn[ 2], wIn[ 3], wIn[ 4], wIn[ 5], wIn[ 6], wIn[ 7], wIn[ 8], wIn[ 9], wIn[10], wIn[11], wIn[12], wIn[13], wIn[14], wIn[15] ); tlen -= 64; pData += 64; } if (tlen >= 56) { // Process > 56-byte chunk int cl = (tlen >> 2); // perform padding on last 2 byte if (cl > 14) { dData[14] = wIn[14]; } else { dData[15] = 0; } // copy 1 word with padding byte switch (len & 0x03) { case 0: dData[cl] = MD5_pad_w0(); break; case 1: dData[cl] = MD5_pad_w1(wIn[cl]); break; case 2: dData[cl] = MD5_pad_w2(wIn[cl]); break; case 3: dData[cl] = MD5_pad_w3(wIn[cl]); break; } // transform MD5_transform_add( wIn[ 0], wIn[ 1], wIn[ 2], wIn[ 3], wIn[ 4], wIn[ 5], wIn[ 6], wIn[ 7], wIn[ 8], wIn[ 9], wIn[10], wIn[11], wIn[12], wIn[13], dData[14], dData[15] ); // final transform #define w14 (len << 3) #define w15 (len >> 29) MD5_transform_add( 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, w14, w15 ); #undef w14 #undef w15 return; } else { // (len mod 64) < 56 MD5_copy_pad_block(dData, wIn, (tlen >> 2), len); #undef wIn #define wIn dData // transform MD5_transform_add( wIn[ 0], wIn[ 1], wIn[ 2], wIn[ 3], wIn[ 4], wIn[ 5], wIn[ 6], wIn[ 7], wIn[ 8], wIn[ 9], wIn[10], wIn[11], wIn[12], wIn[13], wIn[14], wIn[15] ); #undef wIn #define wIn ((UINT4 *)pData) return; } } /* end of fast_MD5() */ } }
-
873 Zeilen sind fast schon rekordverdächtig. Sei versichert, dass sich niemand so langen Code anschaut. Selbst ohne unnötige Leerzeilen wäre der Code viel zu lange. Bemühe dich um ein kleines, repräsentatives Codestück, das erhöht die Chancen, dass dir geholfen wird, dramatisch.
Abgesehen davon könntest du dein Problem verständlich beschreiben. "Zwei Pointer verbinden" - was soll da gemeint sein? Willst du zwei Strings aneinander ketten? In welcher Sprache möchtest du deine Lösung, C oder C++?
-
Dieser Thread wurde von Moderator/in rapso aus dem Forum Spiele-/Grafikprogrammierung in das Forum Rund um die Programmierung verschoben.
Im Zweifelsfall bitte auch folgende Hinweise beachten:
C/C++ Forum :: FAQ - Sonstiges :: Wohin mit meiner Frage?Dieses Posting wurde automatisch erzeugt.
-
Ok, wenn du das jetzt noch reduzierst und du mal die MODULEINFO-Struktur(?) herzeigen kannst, sollten wir einen Schritt weiter sein.
-
lollno schrieb:
Bei info->pBuf (es sollen 2 gleiche Strings aneinander geknüpft werden)
im prinzip haste 2 möglichkeiten (bei 0-terminierten strings in C):
1. string 2 an string 1 anhängen, dazu muss string 2 genügend platz haben:char string1[256] = "hallo"; // platz == 256, aber nur 6 zeichen sind belegt strcat (string1, " doof"); // es werden 6 zeichen angehängt
2. einen neuen string erzeugen, in den beide kopiert werden
char buff[256]; strcpy (buff, "hallo"); // erster string strcat (buff, " doof"); // zweiten string anhängen // alternativ sprintf (buff, "%s%s", "hallo", " doof"); // macht selbiges wie strpy/strcat
^^wichtig: die result-strings dürfen keine lokalen variablen sein, wenn du's in einer funktion machst (also, statisch/global, dynamisch oder als pointer übergeben).
btw, den ganzen MD5-code brauchste nicht zu posten.
-
;fricky schrieb:
dazu muss string 2 genügend platz haben:
edit: zu schnell abgeschickt: string1 muss natürlich genug platz haben.