Results 1 to 15 of 15
  1. #1
    qsc's Avatar
    Join Date
    Feb 2009
    Posts
    35
    Reputation
    10
    Thanks
    0

    Question writeprocessmemory function

    can sum1 tell me how to use the write process memory function?

    ive got this
    Code:
    WriteProcessMemory(ProcessHandle,address, &newdata, newdatasize, NULL);
    "ProcessHandle" and "address" are two variables which i have declared and all, all i need to know is wat i need to put in for "newdata" and "newdatasize"?

    is new data the new value for the address?
    i think newdatasize is a signature?

    can sum1 help plz?

  2. #2
    A⁴'s Avatar
    Join Date
    Dec 2008
    Gender
    male
    Location
    I want my minion back /fosho.
    Posts
    4,001
    Reputation
    67
    Thanks
    437
    My Mood
    Flirty
    Pictures would help...

  3. #3
    Toymaker's Avatar
    Join Date
    Feb 2008
    Gender
    male
    Location
    Hannah, Montana
    Posts
    659
    Reputation
    14
    Thanks
    193
    My Mood
    Amused
    I could be wrong but, I thought there were countless examples of WPM on this forum as is. I posted an example as well. I see you want a give away so truth be told it's as easy as:

    Code:
    #include <windows.h>
    void write(LPVOID addy, DWORD mydata);
    void enableDebugPrivileges();
    void urMemoryInjection();
        void write(LPVOID addy, DWORD mydata) {
        DWORD PID, TID;
        TID = ::GetWindowThreadProcessId (hHack, &PID);
        HANDLE hopen=OpenProcess( PROCESS_ALL_ACCESS|PROCESS_TERMINATE|PROCESS_VM_OPERATION|PROCESS_VM_READ|
        PROCESS_VM_WRITE,FALSE,PID);
        WriteProcessMemory(hopen,addy,&mydata,1,0);
        CloseHandle(hopen);  
    }
         
        void enableDebugPrivileges() {
        HANDLE hcurrent=GetCurrentProcess();
        HANDLE hToken;
        BOOL bret=OpenProcessToken(hcurrent,40,&hToken);
        LUID luid;
        bret=LookupPrivilegeValue(NULL,"SeDebugPrivilege",&luid);
        TOKEN_PRIVILEGES NewState,PreviousState;
        DWORD ReturnLength;
        NewState.PrivilegeCount =1;
        NewState.Privileges[0].Luid =luid;
        NewState.Privileges[0].Attributes=2;
        AdjustTokenPrivileges(hToken,FALSE,&NewState,28,&PreviousState,&ReturnLength);
    }
         
         void urMemoryInjection() {
              write((LPVOID)0xOFFSET1, 0xBYTE1);
              }

  4. #4
    qsc's Avatar
    Join Date
    Feb 2009
    Posts
    35
    Reputation
    10
    Thanks
    0
    so all i need is:

    WriteProcessMemory(processHandle, Address, Value, Bytes, Nothing)

    ^^^^^^^^^^^^^^^i got the above from a VB tut but what does bytes mean??
    i usually see this in source codes as sumthin like:

    Code:
    newdatasize = ( {0x0} {0x74}..........................}
    or sumthin like that?


    Code:
    WriteProcessMemory(ProcessHandle,0x00000000,&mydata,1,0);
    but wat does the words in red stand for?

    Code:
    int mydata = 4000
    WriteProcessMemory(ProcessHandle,0x000000,&mydata,1,0);
    so i just declare mydata as whatever i want to change the address value to?
    and what does the 1 and 0 stand for?

    sorry, its just ive got everything else like findprocessid and all working, its just this function that getting tricky

    (btw 0x00000000 is not the actual address, just a representation of it)
    Last edited by qsc; 05-10-2009 at 06:41 AM.

  5. #5
    qsc's Avatar
    Join Date
    Feb 2009
    Posts
    35
    Reputation
    10
    Thanks
    0
    Quote Originally Posted by qsc View Post
    so all i need is:

    WriteProcessMemory(processHandle, Address, Value, Bytes, Nothing)

    ^^^^^^^^^^^^^^^i got the above from a VB tut but what does bytes mean??
    i usually see this in source codes as sumthin like:

    Code:
    newdatasize = ( {0x0} {0x74}..........................}
    or sumthin like that?


    Code:
    WriteProcessMemory(ProcessHandle,0x00000000,&mydata,1,0);
    but wat does the words in red stand for?

    Code:
    int mydata = 4000
    WriteProcessMemory(ProcessHandle,0x000000,&mydata,1,0);
    so i just declare mydata as whatever i want to change the address value to?
    and what does the 1 and 0 stand for?

    sorry, its just ive got everything else like findprocessid and all working, its just this function that getting tricky

    (btw 0x00000000 is not the actual address, just a representation of it)
    BUMP????????

  6. #6
    A⁴'s Avatar
    Join Date
    Dec 2008
    Gender
    male
    Location
    I want my minion back /fosho.
    Posts
    4,001
    Reputation
    67
    Thanks
    437
    My Mood
    Flirty
    I really can't get what hes saying...If I could,I would help tho...

  7. #7
    qsc's Avatar
    Join Date
    Feb 2009
    Posts
    35
    Reputation
    10
    Thanks
    0
    Quote Originally Posted by OMGitsasabotage! View Post
    I really can't get what hes saying...If I could,I would help tho...
    ive got the FindWindow,GetWindowThreadProcessId and OpenProcess functions working fine.

    but when itry to use the writeprocessmemory function, i cant work out what to put in the brackets.

    ive got this basic code:
    Code:
    WriteProcessMemory(ProcessHandle,address, &newdata, newdatasize, NULL);
    ive already declared "address" as a variable using
    Code:
    LPVOID address = (void*) 0x000000;
    and ive got the "ProcessHandle" value from the other funtions.

    MY PROBLEM IS THAT I DONT KNOW HOW TO DECLARE "newdata" and "newdatasize"

  8. #8
    Toymaker's Avatar
    Join Date
    Feb 2008
    Gender
    male
    Location
    Hannah, Montana
    Posts
    659
    Reputation
    14
    Thanks
    193
    My Mood
    Amused
    Oh, I didn't check this thread recently. Any way you got it confused. Value is the 'bytes to write' and Byte is the 'length,' so WriteProcessMemory(processHandle, Offset, Byte, Length, Nothing) is technically what it should read. But you don't change those at all, dude, you modify the

    Code:
         void urMemoryInjection() {
              write((LPVOID)0xOFFSET1, 0xBYTE1);
              }
    only. The example I gave you is ready to rock. Notice offset1, byte1.

  9. #9
    qsc's Avatar
    Join Date
    Feb 2009
    Posts
    35
    Reputation
    10
    Thanks
    0
    Quote Originally Posted by Toymaker View Post
    Oh, I didn't check this thread recently. Any way you got it confused. Value is the 'bytes to write' and Byte is the 'length,' so WriteProcessMemory(processHandle, Offset, Byte, Length, Nothing) is technically what it should read. But you don't change those at all, dude, you modify the

    Code:
         void urMemoryInjection() {
              write((LPVOID)0xOFFSET1, 0xBYTE1);
              }
    only. The example I gave you is ready to rock. Notice offset1, byte1.
    Sorry if i sound like a n00b, but wat ure saying is that i do this in my main.cpp (not alone but in with the rest of my code):

    Code:
    WriteProcessMemory(ProcessHandle,address, &newdata, newdatasize, NULL);
    and leave it as it is, and then put the urMemoryInjection function under all my code.

    but im just wonderin wen does the urMemoryInjection function get called?
    do i have to change the writeprocessmemory to this:

    Code:
    urMemoryFunction(ProcessHandle,address, &newdata, newdatasize, NULL);
    ????????

    also in urMemoryFunction, if byte is the value to change the memory adress to, then why is it written like 0x0, can it not be written as just a standard integer?

  10. #10
    radnomguywfq3's Avatar
    Join Date
    Jan 2007
    Gender
    male
    Location
    J:\E\T\A\M\A\Y.exe
    Posts
    8,858
    Reputation
    381
    Thanks
    1,823
    My Mood
    Sad
    If you don't understand the definition of WriteProcessMemory on MSDN Library, you should be programming this in C++.

    WriteProcessMemory Function (Windows)

    It's a pretty basic API

  11. #11
    qsc's Avatar
    Join Date
    Feb 2009
    Posts
    35
    Reputation
    10
    Thanks
    0
    Quote Originally Posted by Jetamay View Post
    If you don't understand the definition of WriteProcessMemory on MSDN Library, you should be programming this in C++.

    WriteProcessMemory Function (Windows)

    It's a pretty basic API
    Code:
    LPVOID addy = (void*) 0x000000;
    
    BOOL WINAPI WriteProcessMemory(
      __in   HANDLE ProcessHandle,
      __in   LPVOID addy,
      __in   LPCVOID lpBuffer,
      __in   SIZE_T sizeof(lpbuffer),
      __out  SIZE_T *NULL
    );
    I Have now realised that the data to write has to be in a pointer, how do i put data in a pointer ??

  12. #12
    Toymaker's Avatar
    Join Date
    Feb 2008
    Gender
    male
    Location
    Hannah, Montana
    Posts
    659
    Reputation
    14
    Thanks
    193
    My Mood
    Amused
    Don't try to mix our codes.

  13. #13
    qsc's Avatar
    Join Date
    Feb 2009
    Posts
    35
    Reputation
    10
    Thanks
    0
    Quote Originally Posted by Toymaker View Post
    Don't try to mix our codes.
    i used ur code :
    Code:
    #include <windows.h>
    void write(LPVOID addy, DWORD mydata);
    void enableDebugPrivileges();
    void urMemoryInjection();
        void write(LPVOID addy, DWORD mydata) {
        DWORD PID, TID;
        TID = ::GetWindowThreadProcessId (hHack, &PID);
        HANDLE hopen=OpenProcess( PROCESS_ALL_ACCESS|PROCESS_TERMINATE|PROCESS_VM_OPERATION|PROCESS_VM_READ|
        PROCESS_VM_WRITE,FALSE,PID);
        WriteProcessMemory(hopen,addy,&mydata,1,0);
        CloseHandle(hopen);  
    }
         
        void enableDebugPrivileges() {
        HANDLE hcurrent=GetCurrentProcess();
        HANDLE hToken;
        BOOL bret=OpenProcessToken(hcurrent,40,&hToken);
        LUID luid;
        bret=LookupPrivilegeValue(NULL,"SeDebugPrivilege",&luid);
        TOKEN_PRIVILEGES NewState,PreviousState;
        DWORD ReturnLength;
        NewState.PrivilegeCount =1;
        NewState.Privileges[0].Luid =luid;
        NewState.Privileges[0].Attributes=2;
        AdjustTokenPrivileges(hToken,FALSE,&NewState,28,&PreviousState,&ReturnLength);
    }
         
         void urMemoryInjection() {
              write((LPVOID)0xOFFSET1, 0xBYTE1);
              }
    but got an error that hHack wasnt declared: so i changed the parts of code in red:
    Code:
    #include <windows.h>
    void write(LPVOID addy, DWORD mydata);
    void enableDebugPrivileges();
    int main();
        void write(LPVOID addy, DWORD mydata) {
        DWORD PID, TID;
        HWND hHack;
        TID = ::GetWindowThreadProcessId (hHack, &PID);
        HANDLE hopen=OpenProcess( PROCESS_ALL_ACCESS|PROCESS_TERMINATE|PROCESS_VM_OPERATION|PROCESS_VM_READ|
        PROCESS_VM_WRITE,FALSE,PID);
        WriteProcessMemory(hopen,addy,&mydata,1,0);
        CloseHandle(hopen);  
    }
         
        void enableDebugPrivileges() {
        HANDLE hcurrent=GetCurrentProcess();
        HANDLE hToken;
        BOOL bret=OpenProcessToken(hcurrent,40,&hToken);
        LUID luid;
        bret=LookupPrivilegeValue(NULL,"SeDebugPrivilege",&luid);
        TOKEN_PRIVILEGES NewState,PreviousState;
        DWORD ReturnLength;
        NewState.PrivilegeCount =1;
        NewState.Privileges[0].Luid =luid;
        NewState.Privileges[0].Attributes=2;
        AdjustTokenPrivileges(hToken,FALSE,&NewState,28,&PreviousState,&ReturnLength);
    }
         
         int main() {
              write((LPVOID)0x040005 , 0x90);
              }
    I Changed the OFFSET1 to 0x040005 and BYTE1 to 0x90
    and i got an error that hHack wasnt declared so i added HWND Hhack;

    everything compiled fine until the linker part where it gave me an error
    so i changed urMemoryInjection() to int main() which seemed to solve the problem.

    SO THIS CODE SHOULD WRITE "90" TO THE ADDRESS 0x040005 ????

    ALSO, ONE QUESTION. HOW DOES IT KNOW WHICH PROCESS TO CHANGE THE MEMORY OF? In My other cpp i had :

    Code:
    HWND gamewindow;
    gamewindow = FindWindow(NULL, "CrossFire");
    thx for the help so far!
    Last edited by qsc; 05-12-2009 at 08:04 AM.

  14. #14
    Toymaker's Avatar
    Join Date
    Feb 2008
    Gender
    male
    Location
    Hannah, Montana
    Posts
    659
    Reputation
    14
    Thanks
    193
    My Mood
    Amused
    Yeah you fucked it up, i'll paste a working model, ready to use, when I get home. =\ You have main() twice instead of memoryinjection() and hwnd has to include 'findwindow("name")' but i'll post it soon if you don't figure it out or someone beats me to it.

  15. #15
    qsc's Avatar
    Join Date
    Feb 2009
    Posts
    35
    Reputation
    10
    Thanks
    0
    Quote Originally Posted by Toymaker View Post
    Yeah you fucked it up, i'll paste a working model, ready to use, when I get home. = You have main() twice instead of memoryinjection() and hwnd has to include 'findwindow("name")' but i'll post it soon if you don't figure it out or someone beats me to it.
    thx alot! your really helpful ty
    alot easier to learn when people arent all secretive

Similar Threads

  1. How do u define function in VB6
    By ilovepie21 in forum WarRock - International Hacks
    Replies: 5
    Last Post: 03-02-2008, 12:20 PM
  2. How can i kill a function in vb
    By HeXel in forum Visual Basic Programming
    Replies: 5
    Last Post: 02-15-2008, 04:56 PM
  3. hack function idea
    By l0ngcat in forum WarRock - International Hacks
    Replies: 6
    Last Post: 10-02-2007, 06:01 AM
  4. Replies: 8
    Last Post: 07-09-2007, 03:15 PM
  5. Disable some of punkbuster's functions.
    By System79 in forum Game Hacking Tutorials
    Replies: 3
    Last Post: 09-06-2006, 11:32 PM

Tags for this Thread