Quote:
Originally posted by LaptoniC
Finallly below one worked
_SLS_SECRET * __cdecl GetSecrets(char const *,int & ;
typedef struct _SLS_SECRET
{
unsigned char Secret[32]; //null-terminate string
} SLS_SECRET;
char * pId="1234-5678-9012-3456-7890";
SLS_SECRET *mysecret;
strcpy(pId,"5328-8301-2929-7640-5794" ;
mysecret=GetSecrets(pId,sSize);
However I cant show mysecret with messagebox etc. |
You might want to learn programming C++ a bit better before diving into such as this.
I downloaded the sdk though and studied the static library as you said the function would be in.
The prototype of the function should be SLS_SECRET * GetSecrets(const char *, int *);
I don't think you want to use cdecl spec because that would conflict with C++ name mangling. Also the file you have your code in must be named *.cpp and not *.c to make sure you activate the C++ compiler.
From the prototype we see that parameter 1 is not modified by the function and should be zero terminated. For the second parameter you used reference instead of pointer but from the code I found:
.text:00000168 mov ecx, [ebp+arg_4]
.text:0000016B mov dword ptr [ecx], 4
So by using a pointer you make sure you get the correct code generated by the compiler.
So to call it you should do:
SLS_SECRET *pMysecret;
int nSize;
pMysecret = GetSecrets("5328-8301-2929-7640-5794", &nSize);
Now you state that you can't display the SLS_SECRET variable to a messagebox. Why doesn't that not surprise me?
What you really want is not to feed the messagebox with the SLS_SECRET structure but the char string inside it.
Try with something like:
MessageBox(NULL, pMysecret->Secret, "Secret data...!?", MB_OK);
// CyberHeg