Исходник [JS] Get Samp Version

Статус
В этой теме нельзя размещать новые ответы.

Fr0z3n

Участник
Автор темы
50
30
This is function for getting samp versions(From 0.3.7 R1 - 0.3.7 R4 - 2). You can use it on new cleo extension Cleo Redux

The code contains 2 functions:
- get_samp_version_id
- get_samp_version_name


You can see more about this function here.

JavaScript:
/*
    get_samp_version_id function is reading the "IMAGE_FILE_HEADER" of samp.dll (TimeDateStamp to be specific)
    That TimeDateStamp is based on compilation time. See this for more info:
    https://docs.microsoft.com/en-us/windows/win32/debug/pe-format#file-headers
 
    "TimeDateStamp = The low 32 bits of the number of seconds since 00:00 January 1, 1970 (a C run-time time_t value), that indicates when the file was created. "
 
    In most versions that time stamp is located at offset 0x128 from samp.dll. In "0.3.7 R3 1" it is located at 0x120 offset though.
    --------------------------------------------------------------------
    Credits:
    *Monday - https://ugbase.eu/members/monday.17492/
    Parazitas - https://ugbase.eu/members/parazitas.39678/
    Fr0z3n - https://ugbase.eu/members/frozen.57428/
    --------------------------------------------------------------------
    Original post: https://ugbase.eu/threads/snippet-get-samp-version-js.22844/
*/

/// <reference path=".config/sa.d.ts" />
/// <reference no-default-lib="true" />

id = Int8Array;
verzija = Int8Array;

while(true) {

    wait(250); {

        get_samp_version_name();
        Text.PrintFormattedNow("You use SA-MP %s", 250, verzija);
    }
}

function get_samp_version_id()
{
    x = Int8Array;
    y = Int8Array;
    if ( x = DynamicLibrary.Load("samp.dll") ) {
        x += 0x128
        y = Memory.Read(x, 4, true);

        switch(y) {

            case 0x5542F47A:
            id = /*0.3.7 - R1*/1;

            case 0x59C30C94:
            id = /*0.3.7 - R2*/2;

            case 0x5A6A3130: {
            id = /*0.3.DL - R1*/3; }

            x -= 8; // samp.dll + 0x120
            y = Memory.Read(x, 4, true);

            case 0x5C0B4243:
            id = /*0.3.7 - R3 - 1*/4;

            case 0x5DD606CD:
            id = /*0.3.7 - R4 - 1*/5;

            case 0x6094ACAB:
            id = /*0.3.7 - R4 - 2*/6;

        }
    }
}

function get_samp_version_name()
{
    get_samp_version_id();
    switch (id) {
        case 0: verzija = "Unknown";
        case 1: verzija = "0.3.7 - R1"; 
        case 2: verzija = "0.3.7 - R2";
        case 3: verzija = "0.3.DL - R1";
        case 4: verzija = "0.3.7 - R3 - 1";
        case 5: verzija = "0.3.7 - R4 - 1";
        case 6: verzija = "0.3.7 - R4 - 2";
    
    }
}
 
Последнее редактирование:
Статус
В этой теме нельзя размещать новые ответы.