Let me start by saying that I’m a total beginner when it comes to C++. Recently I’ve created a .dll for a project I’m working on that suppose to XOR each character in a string and then out puts the hex value of the answer... Here's my code...
Code:
#include "stdafx.h"
#include <stdio.h> // for namespace
#include <valarray> // for Xor
#include <string>
BOOL APIENTRY DllMain( HANDLE hModule,
DWORD ul_reason_for_call,
LPVOID lpReserved
)
{
return TRUE;
}
char outvalue[2] = "";
char out [2] = "";
__declspec(dllexport) LPCTSTR ecc(LPCTSTR invalue)
{
unsigned int v=0;
unsigned int vlen=0;
// Setup Values of Variables
vlen = strlen(invalue);
outvalue[0] = invalue[0];
// Loop
for(v;v<vlen-1;v++)
{
outvalue [0] ^= invalue[v+1];
}
sprintf(out, "%X",2, outvalue[0]);
return out;
}
Now, it's not the prettiest but it works. The only trouble I’m having is that the program I’m using has specific requirements for it to work correctly (right now after the DLL run the program tries to clear the memory but sometimes clears it incorrectly and I’m getting thing crashing because of it).
The requirements are...
• accepts a constant char* null terminated string as the sole parameter
• returns type char* that points to a dynamically allocated null terminated string that can be freed by the step
At this point I really could use all the help I can get. Anyone have any ideas how I can patch my current DLL to meet those two steps?
Thanks a bunch this forum rocks!