Thread: WriteProcessMemory() problem on Windows 7 64-bit - C programming

  1. #1
    Registered User
    Join Date
    Jan 2013
    Posts
    55

    WriteProcessMemory() problem on Windows 7 64-bit - C programming

    Code:
                BYTE bNewData[]={0x90,0x90,0x90,0x90,0x90,0x90,0x90};
                DWORD dwNewDataSize = sizeof(bNewData);
    
    
                if (WriteProcessMemory(hProcess, 0x0094f720, &bNewData, dwNewDataSize, NULL) == 0 ) 
                { 
                    puts("Failure!"); printf( "Reason for failure : %s\n", strerror( GetLastError() ) ); 
                } else { 
                    puts("Success!"); 
                }
    When I execute that code on my computer, I get the error, " Reason for failure : No such device or address ". I do not get how to fix this error when I know the address I gave it is valid. Is the error because I don't typecast the address to LPVOID, or is it just my computer? Also, how can I fix it?

  2. #2
    Registered User
    Join Date
    Jan 2013
    Posts
    55
    Never mind, I fixed it, I accidentally closed the process handle before changing the memory inside.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. WriteProcessMemory() problem on Windows 7 64-bit
    By BatchProgrammer in forum C Programming
    Replies: 1
    Last Post: 06-08-2013, 11:06 PM
  2. WriteProcessMemory failing with GetLastError 87
    By Anddos in forum Windows Programming
    Replies: 5
    Last Post: 04-19-2009, 02:34 PM
  3. WriteProcessMemory
    By Crypteasy in forum Windows Programming
    Replies: 1
    Last Post: 07-26-2008, 10:33 PM
  4. WriteProcessMemory help please
    By Rune Hunter in forum Windows Programming
    Replies: 6
    Last Post: 02-22-2005, 12:34 AM
  5. WriteProcessMemory
    By cppdude in forum Windows Programming
    Replies: 3
    Last Post: 04-12-2002, 08:31 AM