Im new to C Programming and the Windows API im getting "Run-Time Check Failure #2 - Stack around the variable 'pMyStringAdress' was corrupted." after compilation in Visual Studio
Thats my code:
#include <stdio.h>
#include <Windows.h>
#include <string.h>
char MyStrings[] = {
"ich bin ein text"
};
text";
int main() {
SIZE_T SizeMyStrings = sizeof(MyStrings);
PVOID pMyStringAdress = VirtualAlloc(
NULL,
SizeMyStrings,
MEM_COMMIT | MEM_RESERVE,
PAGE_READWRITE
);
if (pMyStringAdress == NULL) {
printf("VirtualAlloc fehlgeschlagen mit fehlercode %d", GetLastError());
}
else {
printf("Speicher erfolgreich allokiert sitzt bei: %p\n", &pMyStringAdress);
}
printf("Probiere in den Speicher zu schreiben.");
memcpy(&pMyStringAdress, MyStrings, SizeMyStrings);
return 0;
}