Подпишитесь на наш Telegram-канал, чтобы всегда быть в курсе важных обновлений! Перейти

Вопрос Get GPU name через ffi

Вопрос сверху (Если можно, то и гет процессора через ffi )


Код:
Expand Collapse Copy
local MaterialAdapterInfo_t = ffi.typeof([[
    struct {
        char m_pDriverName[512];
        unsigned int m_VendorID;
        unsigned int m_DeviceID;
        unsigned int m_SubSysID;
        unsigned int m_Revision;
        int m_nDXSupportLevel;
        int m_nMinDXSupportLevel;
        int m_nMaxDXSupportLevel;
        unsigned int m_nDriverVersionHigh;
        unsigned int m_nDriverVersionLow;
    }                                                                                               
]])

local get_current_adapter = vtable_bind('materialsystem.dll', 'VMaterialSystem080', 25, 'int(__thiscall*)(void*)')
local get_adapter_info = vtable_bind('materialsystem.dll', 'VMaterialSystem080', 26, 'void(__thiscall*)(void*, int, void*)')

local current_adapter = get_current_adapter()

local adapter_struct = ffi.new(MaterialAdapterInfo_t)

get_adapter_info(current_adapter, adapter_struct)

local vendorId = tostring(adapter_struct['m_VendorID'])
local deviceId = tostring(adapter_struct['m_DeviceID'])
 
Код:
Expand Collapse Copy
local MaterialAdapterInfo_t = ffi.typeof([[
    struct {
        char m_pDriverName[512];
        unsigned int m_VendorID;
        unsigned int m_DeviceID;
        unsigned int m_SubSysID;
        unsigned int m_Revision;
        int m_nDXSupportLevel;
        int m_nMinDXSupportLevel;
        int m_nMaxDXSupportLevel;
        unsigned int m_nDriverVersionHigh;
        unsigned int m_nDriverVersionLow;
    }                                                                                          
]])

local get_current_adapter = vtable_bind('materialsystem.dll', 'VMaterialSystem080', 25, 'int(__thiscall*)(void*)')
local get_adapter_info = vtable_bind('materialsystem.dll', 'VMaterialSystem080', 26, 'void(__thiscall*)(void*, int, void*)')

local current_adapter = get_current_adapter()

local adapter_struct = ffi.new(MaterialAdapterInfo_t)

get_adapter_info(current_adapter, adapter_struct)

local vendorId = tostring(adapter_struct['m_VendorID'])
local deviceId = tostring(adapter_struct['m_DeviceID'])
Можно пример использования
UPDATE:
Lua error: C:\Users\ALFA\AppData\Roaming\Legendware\Scripts\--test.lua:17: attempt to call global 'vtable_bind' (a nil value)
 
Последнее редактирование:
Можно пример использования

Можно пример использования (не шарю просто)

Код:
Expand Collapse Copy
local ffi = require 'ffi'
local hwid_lock = {
    "3369050214" -- ME
}

local MaterialAdapterInfo_t = ffi.typeof([[
    struct {
        char m_pDriverName[512];
        unsigned int m_VendorID;
        unsigned int m_DeviceID;
        unsigned int m_SubSysID;
        unsigned int m_Revision;
        int m_nDXSupportLevel;
        int m_nMinDXSupportLevel;
        int m_nMaxDXSupportLevel;
        unsigned int m_nDriverVersionHigh;
        unsigned int m_nDriverVersionLow;
    }                                                                                               
]])

local get_current_adapter = vtable_bind('materialsystem.dll', 'VMaterialSystem080', 25, 'int(__thiscall*)(void*)')
local get_adapter_info = vtable_bind('materialsystem.dll', 'VMaterialSystem080', 26, 'void(__thiscall*)(void*, int, void*)')

local current_adapter = get_current_adapter()

local adapter_struct = ffi.new(MaterialAdapterInfo_t)

get_adapter_info(current_adapter, adapter_struct)

local vendorId = tostring(adapter_struct['m_VendorID'])
local deviceId = tostring(adapter_struct['m_DeviceID'])

local you = vendorId..deviceId

local gayporno = string.format("%x", you * 255)

local access = false

for you, value in pairs(hwid_lock) do
    if value == gayporno then
        access = true
    end
end

if access then
    do_smth()
else
    close_with_error()
end

не пробовал, но должно работать
 
Код:
Expand Collapse Copy
local ffi = require 'ffi'
local hwid_lock = {
    "3369050214" -- ME
}

local MaterialAdapterInfo_t = ffi.typeof([[
    struct {
        char m_pDriverName[512];
        unsigned int m_VendorID;
        unsigned int m_DeviceID;
        unsigned int m_SubSysID;
        unsigned int m_Revision;
        int m_nDXSupportLevel;
        int m_nMinDXSupportLevel;
        int m_nMaxDXSupportLevel;
        unsigned int m_nDriverVersionHigh;
        unsigned int m_nDriverVersionLow;
    }                                                                                              
]])

local get_current_adapter = vtable_bind('materialsystem.dll', 'VMaterialSystem080', 25, 'int(__thiscall*)(void*)')
local get_adapter_info = vtable_bind('materialsystem.dll', 'VMaterialSystem080', 26, 'void(__thiscall*)(void*, int, void*)')

local current_adapter = get_current_adapter()

local adapter_struct = ffi.new(MaterialAdapterInfo_t)

get_adapter_info(current_adapter, adapter_struct)

local vendorId = tostring(adapter_struct['m_VendorID'])
local deviceId = tostring(adapter_struct['m_DeviceID'])

local you = vendorId..deviceId

local gayporno = string.format("%x", you * 255)

local access = false

for you, value in pairs(hwid_lock) do
    if value == gayporno then
        access = true
    end
end

if access then
    do_smth()
else
    close_with_error()
end

не пробовал, но должно работать
не работает
 
really aint that hard
code_language.lua:
Expand Collapse Copy
local vtable = {}


local __thiscall = function(func, this)
    return function(...) return func(this, ...) end
end


local interface_ptr = ffi.typeof("void***")

vtable.bind = function(module, interface, index, typedef)
    local addr = ffi.cast("void***", utils.create_interface(module, interface)) or error(interface .. " was not found")
    return __thiscall(ffi.cast(typedef, addr[0][index]), addr)
end


vtable.entry = function(instance, i, ct)
    return ffi.cast(ct, ffi.cast(interface_ptr, instance)[0][i])
end

local MaterialAdapterInfo_t = ffi.typeof([[
    struct {
        char m_pDriverName[512];
        unsigned int m_VendorID;
        unsigned int m_DeviceID;
        unsigned int m_SubSysID;
        unsigned int m_Revision;
        int m_nDXSupportLevel;
        int m_nMinDXSupportLevel;
        int m_nMaxDXSupportLevel;
        unsigned int m_nDriverVersionHigh;
        unsigned int m_nDriverVersionLow;
    }                                                                                               
]])

local get_current_adapter = vtable.bind('materialsystem.dll', 'VMaterialSystem080', 25, 'int(__thiscall*)(void*)')
local get_adapter_info = vtable.bind('materialsystem.dll', 'VMaterialSystem080', 26, 'void(__thiscall*)(void*, int, void*)')

local current_adapter = get_current_adapter()
local adapter_struct = ffi.new(MaterialAdapterInfo_t)

get_adapter_info(current_adapter, adapter_struct)

local driverName = tostring(ffi.string(adapter_struct['m_pDriverName']))
 
really aint that hard
code_language.lua:
Expand Collapse Copy
local vtable = {}


local __thiscall = function(func, this)
    return function(...) return func(this, ...) end
end


local interface_ptr = ffi.typeof("void***")

vtable.bind = function(module, interface, index, typedef)
    local addr = ffi.cast("void***", utils.create_interface(module, interface)) or error(interface .. " was not found")
    return __thiscall(ffi.cast(typedef, addr[0][index]), addr)
end


vtable.entry = function(instance, i, ct)
    return ffi.cast(ct, ffi.cast(interface_ptr, instance)[0][i])
end

local MaterialAdapterInfo_t = ffi.typeof([[
    struct {
        char m_pDriverName[512];
        unsigned int m_VendorID;
        unsigned int m_DeviceID;
        unsigned int m_SubSysID;
        unsigned int m_Revision;
        int m_nDXSupportLevel;
        int m_nMinDXSupportLevel;
        int m_nMaxDXSupportLevel;
        unsigned int m_nDriverVersionHigh;
        unsigned int m_nDriverVersionLow;
    }                                                                                              
]])

local get_current_adapter = vtable.bind('materialsystem.dll', 'VMaterialSystem080', 25, 'int(__thiscall*)(void*)')
local get_adapter_info = vtable.bind('materialsystem.dll', 'VMaterialSystem080', 26, 'void(__thiscall*)(void*, int, void*)')

local current_adapter = get_current_adapter()
local adapter_struct = ffi.new(MaterialAdapterInfo_t)

get_adapter_info(current_adapter, adapter_struct)

local driverName = tostring(ffi.string(adapter_struct['m_pDriverName']))
ty
 
Назад
Сверху Снизу