Thread: Error in memcpy

  1. #1
    Registered User
    Join Date
    Dec 2008
    Posts
    1

    Error in memcpy

    Im working on a DLL that is supposed to replace certain parts of the memory with NOP.

    Here is the line of code...
    Code:
    memcpy((DWORD*)0x00481BEC,(BYTE*)0x90,1);
    Here are the errors...
    error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
    error C2365: 'memcpy' : redefinition; previous definition was 'function'
    c:\program files\microsoft visual studio 9.0\vc\include\string.h(53) : see declaration of 'memcpy'
    error C2078: too many initializers
    Thankyou for helping me.

  2. #2
    Kernel hacker
    Join Date
    Jul 2007
    Location
    Farncombe, Surrey, England
    Posts
    15,677
    Are you including cstring?

    Also, you probably should cast the first address to void * rather than DWORD *, and the second parameter should be the address of something containing 0x90 (or you could of course just use a BYTE * pointer and assign it with 0x90 in the first place if all you are setting is one byte, or use memset)

    --
    Mats
    Compilers can produce warnings - make the compiler programmers happy: Use them!
    Please don't PM me for help - and no, I don't do help over instant messengers.

  3. #3
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    39,660
    Are windows code segments writable?

    And where did you pluck that address from?
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Disagreement about memcpy
    By ch4 in forum C Programming
    Replies: 9
    Last Post: 05-28-2009, 10:12 AM
  2. Replies: 14
    Last Post: 06-28-2006, 01:58 AM
  3. Memcpy(); Errors...
    By Shamino in forum C++ Programming
    Replies: 4
    Last Post: 03-24-2006, 11:35 AM
  4. memcpy with 128 bit registers
    By grady in forum Linux Programming
    Replies: 2
    Last Post: 01-19-2004, 06:25 AM
  5. memcpy
    By doubleanti in forum C++ Programming
    Replies: 10
    Last Post: 02-28-2002, 04:44 PM