Im trying to write a dll in assembly language that I can pass a pointer to an array from my c++ program to, to be modified.. I thought I had it figured out, but it crashes if the elements are more than 2, so I know Im doing it wrong
Here is what I have for my program so far...
in the c++ part I have
and on in the library part I have
When I run this progam it works fine, as long as c doesnt have more than c[2] elements.. I'd like it to be BYTE c[128], and to be able to modify those elements..
I dont know alot about using arrays in assembly, I've never tried passing them between languages especialy..
Im using masm32 just in case that makes a difference, if anyone knows what Im doing wrong could please give me some hints or point me in a direction where I could find more info about this, I'd really appreciate it
Here is what I have for my program so far...
in the c++ part I have
Code:
extern "C" void _cdecl Num(BYTE []);
int main()
{
BYTE c[2];
c[0] = 0;
c[1] = 0;
c[2] = 0;
Num(c);
printf("%d, %d, %d\n", c[0], c[1], c[2]);
system("PAUSE");
return 0;
}
and on in the library part I have
Code:
Num proc public
push ebp
push eax
push ebx
mov ebp, esp
mov eax, 10
mov [ebx], eax
mov eax, 12
mov [ebx+1], eax
mov eax, 22
mov [ebx+2], eax
pop ebx
pop eax
pop ebp
ret
Num endp
When I run this progam it works fine, as long as c doesnt have more than c[2] elements.. I'd like it to be BYTE c[128], and to be able to modify those elements..
I dont know alot about using arrays in assembly, I've never tried passing them between languages especialy..
Im using masm32 just in case that makes a difference, if anyone knows what Im doing wrong could please give me some hints or point me in a direction where I could find more info about this, I'd really appreciate it