News:

MASM32 SDK Description, downloads and other helpful links
MASM32.com New Forum Link
masmforum WebSite

c++ structure conversion to masm

Started by ChillyWilly, April 15, 2010, 03:54:45 AM

Previous topic - Next topic

ChillyWilly

first anyone know how to put this in masm syntax:
unsigned char sKey[16]={ 0xa3,0x1e,0xf3,0x69,
                                          0x07,0x62,0xd9,0x1f,
                                          0x4f,0xd2,0x7d,0x48 };

if anyone has experience using a data blob structs in masm using CryptUnprotectData
please let me know

kinda like this http://msdn.microsoft.com/en-us/library/aa380882(VS.85).aspx

DATA_BLOB   DataIn, DataEntropy, DataOut;
if (CryptUnprotectData(&DataIn,             // input data
                          NULL,             // output description
                  &DataEntropy,             // optional entropy
                          NULL,             // reserved
                          NULL,             // optional prompt structure
                             1,             // flags
                      &DataOut);
{
     printf("The decrypted data is: %s\n", DataOut.pbData);
}
else
{
    printf("Decryption error!");
}


im thiking the masm code would kinda look like this

struct DATA_BLOB
cbData dd ?
pbData dd ?
ends
DataOut DATA_BLOB
DataIn DATA_BLOB

mov [DataIn.cbData],edx
mov [DataIn.pbData] ,esi
invoke CryptUnprotectData,tBlobIn, 0, DataEntropy, 0, 0, 1, DataOut
Invoke wsprintf,addr buffer,CTXT("The decrypted data is: %s"),[DataOut.cbData]

joemc

Quote from: ChillyWilly on April 15, 2010, 03:54:45 AM
first anyone know how to put this in masm syntax:
unsigned char sKey[16]={ 0xa3,0x1e,0xf3,0x69,
                                          0x07,0x62,0xd9,0x1f,
                                          0x4f,0xd2,0x7d,0x48 };

Is it legal to define a 16 byte array with 12 bytes? i think my compiler would give a warning or error. not sure if you need to pad in the front or back. but something similar to

.data
sKey db 0A3h,01Eh,0F3h,069h,007h,062h,0D9h,01Fh,04Fh,0D2h,07Dh,048h

joemc


jj2007

Quote from: ChillyWilly on April 15, 2010, 03:54:45 AM
first anyone know how to put this in masm syntax:
unsigned char sKey[16]={ 0xa3,0x1e,0xf3,0x69,
                                          0x07,0x62,0xd9,0x1f,
                                          0x4f,0xd2,0x7d,0x48 };

if anyone has experience using a data blob structs in masm using CryptUnprotectData
please let me know


sKey db 0a3h, 1eh, ..., 0,0,0,0

Your DATA_BLOB looks fine, what's the problem?