Hi everybody, I'm working at school with inline assembler (in C++). I don't understand, where I could have a mistake.
My code:
This is problem, because this code breaks my application down. If I go through code in debugger, it throws me an unhandled exception after calling malloc, exactly it throws following:
Where is an error? Thank you.
My code:
Code:
#include <stdlib.h>
void blah()
{
_asm {
mov ecx, 4 // I'd like to allocate place for four pointers
inc ecx // in the end I'd like to NULL
shl ecx, 2 // because of pointers, I have to multiply by four
push ecx // parameter on stack
call malloc // call malloc
add esp, 4 // push parameter back
// now I should have place for 20bytes in eax
}
}
void main()
{
blah();
}
Code:
„Unhandled exception at 0x004182c0 in app.exe: 0xC0000005: Access violation writing location 0x7ffe2486.“