WriteProcessMemory

This is a discussion on WriteProcessMemory within the Windows Programming forums, part of the Platform Specific Boards category; I have 2 questions about the WriteProcessMemory function. If i want to write 6 adjacent bytes all to the value ...

  1. #1
    Registered User cppdude's Avatar
    Join Date
    Jan 2002
    Posts
    62

    WriteProcessMemory

    I have 2 questions about the WriteProcessMemory function.

    If i want to write 6 adjacent bytes all to the value of 0x90, do i just do this:

    WriteProcessMemory(HProcess, (LPVOID)ADDRESS, &Patch, 6, NULL)

    Where Patch = 0x90.

    My second question: is the base address param in WriteProcessMemory relative to the beginning address of the program or is it relative to the entire computers memory?

    Thanks for any help.

  2. #2
    It's full of stars adrianxw's Avatar
    Join Date
    Aug 2001
    Posts
    4,831
    I have never used the function, but looking at the help, would guess that it would copy 6 bytes starting at the address of Patch, hence to copy 6 0x90, &Patch should point to an, at least, 6 element buffer.

    Your second question, it must be the address within the process. You do not have access to the absolute addresses, and since the module could be loaded at almost any physical address, the call must have the current within process address as a start point.

    Sounds like a nasty thing to be doing.
    Wave upon wave of demented avengers march cheerfully out of obscurity unto the dream.

  3. #3
    Registered User cppdude's Avatar
    Join Date
    Jan 2002
    Posts
    62
    cheers adrian

    but what type of cast should i use to just put 0x90 into the function instead of putting in a variable pointer? im talking about the buffer param.

  4. #4
    It's full of stars adrianxw's Avatar
    Join Date
    Aug 2001
    Posts
    4,831
    I would probably declare a 6 element array of char, fill each element with 0x90, and use the base address of the array. No cast.

    Remember, I'm guessing, but that is where I would start after reading the help page.
    Wave upon wave of demented avengers march cheerfully out of obscurity unto the dream.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. WriteProcessMemory failing with GetLastError 87
    By Anddos in forum Windows Programming
    Replies: 5
    Last Post: 04-19-2009, 02:34 PM
  2. WriteProcessMemory
    By Crypteasy in forum Windows Programming
    Replies: 1
    Last Post: 07-26-2008, 10:33 PM
  3. createremotethread and writeprocessmemory problems
    By Hawkin in forum Windows Programming
    Replies: 3
    Last Post: 01-19-2008, 08:33 AM
  4. createremotethread and writeprocessmemory problems
    By cloudy in forum C++ Programming
    Replies: 1
    Last Post: 07-03-2005, 05:06 PM
  5. WriteProcessMemory help please
    By Rune Hunter in forum Windows Programming
    Replies: 6
    Last Post: 02-21-2005, 11:34 PM

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