m4n71k0r

Untitled

Aug 1st, 2012
141
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. /***
  2. *memcpy.c - contains memcpy routine
  3. *
  4. *       Copyright (c) Microsoft Corporation. All rights reserved.
  5. *
  6. *Purpose:
  7. *       memcpy() copies a source memory buffer to a destination buffer.
  8. *       Overlapping buffers are not treated specially, so propogation may occur.
  9. *
  10. *******************************************************************************/
  11.  
  12. #include <cruntime.h>
  13. #include <string.h>
  14.  
  15. #pragma function(memcpy)
  16.  
  17. /***
  18. *memcpy - Copy source buffer to destination buffer
  19. *
  20. *Purpose:
  21. *       memcpy() copies a source memory buffer to a destination memory buffer.
  22. *       This routine does NOT recognize overlapping buffers, and thus can lead
  23. *       to propogation.
  24. *
  25. *       For cases where propogation must be avoided, memmove() must be used.
  26. *
  27. *Entry:
  28. *       void *dst = pointer to destination buffer
  29. *       const void *src = pointer to source buffer
  30. *       size_t count = number of bytes to copy
  31. *
  32. *Exit:
  33. *       Returns a pointer to the destination buffer
  34. *
  35. *Exceptions:
  36. *******************************************************************************/
  37.  
  38. void * __cdecl memcpy (
  39.         void * dst,
  40.         const void * src,
  41.         size_t count
  42.         )
  43. {
  44.         void * ret = dst;
  45.  
  46. #if defined (_M_IA64)
  47.  
  48.         {
  49.  
  50.  
  51.         __declspec(dllimport)
  52.  
  53.  
  54.         void RtlCopyMemory( void *, const void *, size_t count );
  55.  
  56.         RtlCopyMemory( dst, src, count );
  57.  
  58.         }
  59.  
  60. #else  /* defined (_M_IA64) */
  61.         /*
  62.          * copy from lower addresses to higher addresses
  63.          */
  64.         while (count--) {
  65.                 *(char *)dst = *(char *)src;
  66.                 dst = (char *)dst + 1;
  67.                 src = (char *)src + 1;
  68.         }
  69. #endif  /* defined (_M_IA64) */
  70.  
  71.         return(ret);
  72. }
Advertisement
Add Comment
Please, Sign In to add comment