You can't store the new pointer in ReAllocate_Memory
since you don't have the address of it within that routine.
Either
- modify that routine to take a pointer to the variable (get and pass the address with
lea eax, SockArray; push eax
or similar) and then load the parameter and store to it with e.g.mov edx, [ebp + 0x10]
thenmov [edx], eax
.
or else, and this is way easier:
- don't attempt to store the new pointer in
ReAllocate_Memory
. Since it is returned ineax
you can simply store it in the calling scope, same as you do after themalloc
call.
Aside: loading edx
with a value and then calling a function (free
) is dangerous: sub-routines are not required to preserve the value of edx
. Better not to load that until after free
returns, even if it happens to currently work.