Hmm, "DAMAGE: After normal block (#72) at <location>".
Think it's time to post the whole thing:
Code:
#include "stdafx.h"
_declspec(naked) void FastCopy16(char* src, char* dst, int c)
{
_asm
{
push ebp
mov ebp, esp
mov esi, [esp + 08h]
mov edi, [esp + 0Ch]
cld
mov ecx, [esp + 10h]
shr ecx, 1
rep movsw
lea eax, [edi]
mov byte ptr [eax], 00h
mov esp, ebp
pop ebp
ret
}
}
_declspec(naked) void ZeroString(char* s, int c)
{
_asm
{
push ebp
mov ebp, esp
mov edi, [esp + 08h]
mov ecx, [esp + 0Ch]
shr ecx, 1
xor eax, eax
rep stosw
mov esp, ebp
pop ebp
ret
}
}
_declspec(naked) int StringLen(char* stri)
{
int l;
_asm
{
push ebp
mov ebp, esp
mov [l], 0
mov ebx, 0
_proc:
mov eax, stri [ebx]
cmp eax, 0
je _out
inc ebx
inc l
jmp _proc
_out:
mov eax, [l]
mov esp, ebp
pop ebp
ret
}
}
int main(int argc, char **argv)
{
using namespace std;
char* src = "my name is LEEEEEEEEEE";
char* dst = new char[120];
int len = StringLen(src);
ZeroString(dst, 120);
FastCopy16(src, dst, len);
cout << "src: " << src << "\ndst: " << dst << endl;
delete[] dst;
return 0;
}
Hmm, hmm indeed.
EDIT: The funny thing is my output window shows the correct output:
Code:
src: my name is LEEEEEEEEEE
dst: my name is LEEEEEEEEEE
Press any key to continue