Error in memcpy

This is a discussion on Error in memcpy within the C++ Programming forums, part of the General Programming Boards category; Im working on a DLL that is supposed to replace certain parts of the memory with NOP. Here is the ...

  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 wrongness Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    32,761
    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.
    I support http://www.ukip.org/ as the first necessary step to a free Europe.

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, 11:12 AM
  2. Replies: 14
    Last Post: 06-28-2006, 02: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

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21