Deprecated: The behavior of unparenthesized expressions containing both '.' and '+'/'-' will change in PHP 8: '+'/'-' will take a higher precedence in /home/iano/public_html/tpforums-vb5/forum/includes/class_core.php on line 5842

PHP Warning: Use of undefined constant MYSQL_NUM - assumed 'MYSQL_NUM' (this will throw an Error in a future version of PHP) in ..../includes/init.php on line 165

PHP Warning: Use of undefined constant MYSQL_ASSOC - assumed 'MYSQL_ASSOC' (this will throw an Error in a future version of PHP) in ..../includes/init.php on line 165

PHP Warning: Use of undefined constant MYSQL_BOTH - assumed 'MYSQL_BOTH' (this will throw an Error in a future version of PHP) in ..../includes/init.php on line 165

PHP Warning: "continue" targeting switch is equivalent to "break". Did you mean to use "continue 2"? in ..../includes/functions_navigation.php on line 588

PHP Warning: "continue" targeting switch is equivalent to "break". Did you mean to use "continue 2"? in ..../includes/functions_navigation.php on line 612

PHP Warning: Use of undefined constant misc - assumed 'misc' (this will throw an Error in a future version of PHP) in ..../global.php(29) : eval()'d code(6) : eval()'d code on line 1

PHP Warning: Use of undefined constant index - assumed 'index' (this will throw an Error in a future version of PHP) in ..../global.php(29) : eval()'d code(6) : eval()'d code on line 1

PHP Warning: Use of undefined constant misc - assumed 'misc' (this will throw an Error in a future version of PHP) in ..../includes/class_bootstrap.php(1422) : eval()'d code(4) : eval()'d code on line 1

PHP Warning: Use of undefined constant index - assumed 'index' (this will throw an Error in a future version of PHP) in ..../includes/class_bootstrap.php(1422) : eval()'d code(4) : eval()'d code on line 1

PHP Warning: Use of undefined constant onlinestatusphrase - assumed 'onlinestatusphrase' (this will throw an Error in a future version of PHP) in ..../includes/class_core.php(4684) : eval()'d code on line 6

PHP Warning: Use of undefined constant onlinestatusphrase - assumed 'onlinestatusphrase' (this will throw an Error in a future version of PHP) in ..../includes/class_core.php(4684) : eval()'d code on line 6

PHP Warning: Use of undefined constant onlinestatusphrase - assumed 'onlinestatusphrase' (this will throw an Error in a future version of PHP) in ..../includes/class_core.php(4684) : eval()'d code on line 6

PHP Warning: Use of undefined constant onlinestatusphrase - assumed 'onlinestatusphrase' (this will throw an Error in a future version of PHP) in ..../includes/class_core.php(4684) : eval()'d code on line 6

PHP Warning: Use of undefined constant onlinestatusphrase - assumed 'onlinestatusphrase' (this will throw an Error in a future version of PHP) in ..../includes/class_core.php(4684) : eval()'d code on line 6

PHP Warning: Use of undefined constant onlinestatusphrase - assumed 'onlinestatusphrase' (this will throw an Error in a future version of PHP) in ..../includes/class_core.php(4684) : eval()'d code on line 6

PHP Warning: Use of undefined constant onlinestatusphrase - assumed 'onlinestatusphrase' (this will throw an Error in a future version of PHP) in ..../includes/class_core.php(4684) : eval()'d code on line 6
Reading battlelist, return value fails
Results 1 to 7 of 7

Thread: Reading battlelist, return value fails

  1. #1

    Reading battlelist, return value fails

    Hi, I'm trying to read the battlelist, the compiler I'm using is Visual Studio 2008

    [code=cpp]
    case IDT_BATTLELIST:
    {
    KillTimer(hWnd, IDT_BATTLELIST);
    GetWindowThreadProcessId(FindWindow("TibiaClient", "Tibia"), &pID);
    p_Tibia = OpenProcess(PROCESS_VM_READ | PROCESS_VM_OPERATION, 0, pID);
    for(ID = 0; ID < 250; ID++) {
    aux = dir;
    er = ReadProcessMemory(p_Tibia, (void*)aux, &B[ID].id, 4, 0);
    wsprintf(szIDfound, "B[ID]: %d\nPlayerID: %d\nAUX READ: %d\nLoop ID: %d\nOffset: %xn\nGetLastError() : %d\nReturn value: %d", B[ID].id, ReadTibiaMemory(va_playerID), ReadTibiaMemoryLong(aux), ID, aux, GetLastError(), er);
    MessageBox(NULL, szIDfound, "ID Found", MB_OK);
    Sleep(500);
    if(B[ID].id == 0) {
    break;
    } else {
    aux = dir + 136;
    ReadProcessMemory(p_Tibia, (void*)aux, &B[ID].life, 4, 0);
    aux = dir + 44;
    ReadProcessMemory(p_Tibia, (void*)aux, &B[ID].z, 4, 0);
    aux = dir + 40;
    ReadProcessMemory(p_Tibia, (void*)aux, &B[ID].y, 4, 0);
    aux = dir + 36;
    ReadProcessMemory(p_Tibia, (void*)aux, &B[ID].x, 4, 0);
    aux = dir + 144;
    ReadProcessMemory(p_Tibia, (void*)aux, &B[ID].visible, 1, 0);
    aux = dir + 4;
    ReadTibiaMemoryChar(aux, ID);
    dir += 168;
    }
    Sleep(500);
    }

    CloseHandle(p_Tibia);
    SetTimer(hWnd, IDT_BATTLELIST, 250, (TIMERPROC)NULL);
    }[/code]

    The battlelist structure Im using:
    [code=cpp]
    typedef struct {
    char name[128];
    int z, y, x, id, life;
    BOOL visible;
    } BATTLELIST;
    BATTLELIST * B;

    B = (BATTLELIST *)malloc(sizeof(BATTLELIST) * 250);
    [/code]

    ReadTibiaMemoryChar
    [code=cpp]
    void ReadTibiaMemoryChar(int vaTibia, short pos) {
    DWORD dwRead;
    char dwData[64];

    GetWindowThreadProcessId(FindWindow("TibiaClient", "Tibia"), &pID);
    p_Tibia = OpenProcess(PROCESS_VM_READ | PROCESS_VM_OPERATION, 0, pID);
    ReadProcessMemory(p_Tibia, (void *)vaTibia, &dwData, sizeof(dwData), &dwRead);

    CloseHandle(p_Tibia);
    strcpy(B[pos].name, dwData);
    }
    [/code]

    This code returns rubbish on CreatureID and the rest, if I use Dev C++ to compile it will turn out fine. Any ideas?

    GetLastError() returns 299 :
    ERROR_PARTIAL_COPY - 299 (0x12B)
    Only part of a ReadProcessMemory or WriteProcessMemory request was completed.

  2. #2
    Senior Member
    Join Date
    Mar 2007
    Posts
    1,323

    RE: Reading battlelist, return value fails

    I assume you're using C/C++ as a language am I right?

    Try to track down your error to somewhere. Might be that your problem isn't your battlelist reader but the whole memory reading part. That's what GetLastError() is suggesting. Is everything else where you use memory reading working?

  3. #3

    RE: Reading battlelist, return value fails

    All functions for reading and writing memory is working fine,
    Updated the code;

    [code=cpp]
    case IDT_BATTLELIST:
    {
    KillTimer(hWnd, IDT_BATTLELIST);
    GetWindowThreadProcessId(FindWindow("TibiaClient", "Tibia"), &pID);
    p_Tibia = OpenProcess(PROCESS_VM_READ | PROCESS_VM_OPERATION, 0, pID);

    for(ID = 0; ID < 250; ID++) {
    B[ID].id = ReadTibiaMemory(va_BattlelistStart+step);
    wsprintf(szIDfound, "B[ID]: %d\nPlayerID: %d\nAUX READ: %d\nLoop ID: %d\nOffset: %x\nGetLastError() : %d\nReturn value: %d\nBytes read: %d", B[ID].id, ReadTibiaMemory(va_playerID), ReadTibiaMemoryLong(va_BattlelistStart), ID, va_BattlelistStart, GetLastError(), er, dwResult);
    MessageBox(NULL, szIDfound, "ID Found", MB_OK);
    Sleep(500);
    if(B[ID].id == 0) {
    step += 164;
    break;
    } else {
    ReadProcessMemory(p_Tibia, (int *)va_BattlelistStart+136+step, &B[ID].life, 4, 0);
    ReadProcessMemory(p_Tibia, (int *)va_BattlelistStart+44+step, &B[ID].z, 4, 0);
    ReadProcessMemory(p_Tibia, (int *)va_BattlelistStart+40+step, &B[ID].y, 4, 0);
    ReadProcessMemory(p_Tibia, (int *)va_BattlelistStart+36+step, &B[ID].x, 4, 0);
    ReadProcessMemory(p_Tibia, (int *)va_BattlelistStart+144+step, &B[ID].visible, 1, 0);
    ReadTibiaMemoryChar(va_BattlelistStart+4+step, ID);
    }
    Sleep(500);
    }
    CloseHandle(p_Tibia);
    SetTimer(hWnd, IDT_BATTLELIST, 250, (TIMERPROC)NULL);
    }
    [/code]

    ReadTibiaMemory()
    [code=cpp]
    DWORD ReadTibiaMemory(int vaTibia) {
    DWORD dwRead, dwData;

    GetWindowThreadProcessId(FindWindow("TibiaClient", "Tibia"), &pID);
    p_Tibia = OpenProcess(PROCESS_VM_READ | PROCESS_VM_OPERATION, 0, pID);
    ReadProcessMemory(p_Tibia, (void *)vaTibia, &dwData, sizeof(dwData), &dwRead);

    CloseHandle(p_Tibia);
    return dwData;
    }
    [/code]

    ReadTibiaMemory works fine for other functions, but here nothing's stored in the battlelist structure. B[index].id is always set to 0 after a read.
    Number of bytes read is returned as 0, but this works fine when compiling with Dev C++
    Also, the debug messagebox returns that it successfully read the playerID directly from memory, but I need to compare it to the IDs from the battlelist so I need to get this working. So the memory reading in itself should be alright.

    EDIT. It B[index].id does return -2, 0, 1 so maybe the offsets are wrong, I mean where in the battlelist structure is the ID stored?

  4. #4
    Super Moderator
    Join Date
    May 2007
    Posts
    1,191

    RE: Reading battlelist, return value fails

    it depends where your battlelist start is, most people use ID or name as start

    name is ID+4

  5. #5

    RE: Reading battlelist, return value fails

    I know that, but the ID = Battle_list_start yes?

  6. #6
    Super Moderator
    Join Date
    May 2007
    Posts
    1,191

    RE: Reading battlelist, return value fails

    that's the most convenient way, yes

  7. #7

    RE: Reading battlelist, return value fails

    Updated the code, now this makes me able to read all the data, but only once or the structure is filled with the same data

    [code=cpp]
    case IDT_BATTLELIST:
    {
    GetWindowThreadProcessId(FindWindow("TibiaClient", "Tibia"), &pID);
    p_Tibia = OpenProcess(PROCESS_VM_READ | PROCESS_VM_OPERATION, 0, pID);
    dir = va_BattlelistStart;
    step = 0;
    for(ID = 0; ID < 250; ID++) {
    ReadProcessMemory(p_Tibia, (unsigned int *)dir+step, &readBuffer, 4, 0);
    B[ID].id = readBuffer;
    //MessageBox(hWnd, szIDfound, "ID Found", MB_OK);
    Sleep(500);
    if(readBuffer == 0) {
    break;
    } else {
    ReadProcessMemory(p_Tibia, (unsigned int *)dir+136+step, &readBuffer, 4, 0);
    B[ID].life = readBuffer;
    ReadProcessMemory(p_Tibia, (unsigned int *)dir+44+step, &readBuffer, 4, 0);
    B[ID].z = readBuffer;
    ReadProcessMemory(p_Tibia, (unsigned int *)dir+40+step, &readBuffer, 4, 0);
    B[ID].y = readBuffer;
    ReadProcessMemory(p_Tibia, (unsigned int *)dir+36+step, &readBuffer, 4, 0);
    B[ID].x = readBuffer;
    ReadProcessMemory(p_Tibia, (unsigned int *)dir+144+step, &readBuffer, 1, 0);
    B[ID].visible = readBuffer;
    ReadTibiaMemoryChar(dir+4+step, ID);
    }
    step += 168;
    wsprintf(szIDfound, "ID: %d\nName: %s\nZ: %d\nX: %d\nY: %d\nVisible: %d", B[ID].id, B[ID].name, B[ID].z, B[ID].x, B[ID].y, B[ID].visible);
    MessageBox(NULL, szIDfound, "report", B_OK);
    }
    CloseHandle(p_Tibia);
    }
    return 0;
    [/code]

Posting Permissions

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