Results 1 to 5 of 5

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Dwar
    Dwar is offline
    Veteran Dwar's Avatar
    Join Date
    2010 Mar
    Posts
    2,222
    Thanks Thanks Given 
    211
    Thanks Thanks Received 
    2,230
    Thanked in
    292 Posts
    Rep Power
    10

    [C++] Basic memory-scanning in DLL

    Basic memory-scanning in DLL


    Header with functions for searching thru the current applications memory for a certain value.
    The add_log function is just a function which prints to a log-file using a stream.
     /*
    Memory-scanner/searcher

    Syntax
    dwScanMemory(
    DWORD dwScanStart,
    DWORD dwScanEnd,
    int fValueToScanFor,
    int iValueType
    );

    Parameters
    dwScanStart
    offset to start scanning from, eg. 0x00400000
    dwScanEnd
    offset to end scanning on, eg. 0x00500000
    fValueToScanFor
    the value to scan for
    iValueType
    Data-type of the value
    0: char (1 byte)
    1: short (2 bytes)
    2: int (4 bytes)
    3: float (4 bytes & decimals)
    4: double (8 bytes & decimals)

    Return
    If it finds value it returns the offset, if not found returns 0.

    <novcain@gmail.com>
    */
    DWORD dwScanMemory( DWORD dwScanStart, DWORD dwScanEnd, float fValueToScanFor, int iValueType )
    {
    DWORD dwScanOffset = dwScanStart; //holds current offset
    char* cScanValue; //temporary variable.. holds value of current offset
    bool bScan = true; //if true, end scanning
    if( iValueType == 1 ){ short vScanFor = fValueToScanFor; }
    else if( iValueType == 2 ){ int vScanFor = fValueToScanFor; }
    else if( iValueType == 3 ){ float vScanFor = fValueToScanFor; }
    else if( iValueType == 4 ){ double vScanFor = fValueToScanFor; }
    else{ char vScanFor = fValueToScanFor; }
    add_log("Starting to scan memory for %i",vScanFor);
    while(bScan == true){ //while we're scanning, no result found
    dwScanOffset += 0x00000001; //move to next offset
    cScanValue = (char*)dwScanOffset; //set cScanValue to the current value
    if(*cScanValue == vScanFor){ //if the current value is same as the one we're scanning for
    add_log("Value found (%i) * %d",vScanFor,dwScanOffset); } //add it to the log
    if(dwScanOffset == dwScanEnd){ //if we reached the end of the scan-range
    add_log("Reached end of scan-range"); bScan = false; } //end scanning
    }
    return dwScanOffset; //return the offset that was found
    }

    Author: Mr. Novocain
    Please, post your questions on forum, not by PM or mail

    I spend my time, so please pay a little bit of your time to keep world in equilibrium

  2. #2
    TEDSON
    TEDSON is offline
    New member
    Join Date
    2010 Nov
    Posts
    6
    Thanks Thanks Given 
    0
    Thanks Thanks Received 
    1
    Thanked in
    1 Post
    Rep Power
    0
    Seems my last post was lost.

    Wanted to ask how to determine dwScanStart and dwScanEnd values.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •