Based on the original question, there are two ways:
- Use the VirtualProtect function to make the memory region writable.
- Edit the PE file header on disk and make the sections writable.
Both methods have been successfully used many times by many people.
Based on your second post, the most promising answer would be:
- First, read a book about x86 assembler.
- Next, read a book about Win32 programming.
- Next, read a book about x64 assembler.
Your very short text and code fragments already violate at least 4 core principles of x86/Win32/x64 assembly. Your problem definitely is not some write permission, but the basic understanding of the CPU architecture.