memcpy – cast to pointer from integer of different size-Collection of common programming errors

Neither JMP[1] nor JMPSize are pointers. This means that memcpy will interpret the actual values of the variables as pointers, which will then point to somewhere way off and lead to undefined behavior.

You need to use the address-of operator & to make them pointers:

memcpy(&JMP[1], &JMPSize, 4);

Generally, if a functions takes a void * argument, or returns void *, then don’t cast the types. Not casting the types will give you warnings, and warnings are in many cases indicators of undefined behavior.