Skip to content

winos ​

The windows system operation module is a built-in module, no need to use import to import, you can directly call its interface in the script scope.

winos.version ​

  • Get windows system version

Function Prototype ​

API

lua
winos.version()

Parameter Description ​

No parameters required for this function.

Usage ​

The version returned is the semver semantic version object

lua
if winos.version():ge("win7") then
    - ...
end

if winos.version():ge("6.1") then
    - ...
end

In addition, it can also support the direct judgment of the windows version name. The mapping rules are as follows:

nt4 = "4.0"
win2k = "5.0"
winxp = "5.1"
ws03 = "5.2"
win6 = "6.0"
vista = "6.0"
ws08 = "6.0"
longhorn = "6.0"
win7 = "6.1"
win8 = "6.2"
winblue = "6.3"
win81 = "6.3"
win10 = "10.0"

winos.processes ​

  • Get current system process list

Function Prototype ​

API

lua
winos.processes()

Parameter Description ​

No parameters required for this function.

Return Value ​

Returns an array, each element is a process info table:

FieldDescription
nameProcess executable name
pidProcess id
parent_pidParent process id

Returns nil on non-Windows platforms.

Usage ​

lua
local processes = winos.processes()
if processes then
    for _, p in ipairs(processes) do
        print(p.pid, p.parent_pid, p.name)
    end
end

winos.set_error_mode ​

  • Set Windows process error mode

Function Prototype ​

API

lua
winos.set_error_mode(mode: <integer>)

Parameter Description ​

ParameterDescription
modeProcess error mode value (Windows API SetErrorMode)

Return Value ​

Returns the previous error mode value.

Usage ​

Disable system error dialogs (e.g. critical errors, GP fault, open-file error dialogs):

lua
local SEM_FAILCRITICALERRORS     = 0x0001
local SEM_NOGPFAULTERRORBOX      = 0x0002
local SEM_NOOPENFILEERRORBOX     = 0x8000

local oldmode = winos.set_error_mode(SEM_FAILCRITICALERRORS | SEM_NOGPFAULTERRORBOX | SEM_NOOPENFILEERRORBOX)

winos.registry_keys ​

  • Get the list of registry builds

Function Prototype ​

API

lua
winos.registry_keys(pattern: <string>)

Parameter Description ​

ParameterDescription
patternPattern string for matching registry keys

Usage ​

Support through pattern matching, traverse to obtain the registry key path list, * is single-level path matching, ** is recursive path matching.

lua
local keypaths = winos.registry_keys("HKEY_LOCAL_MACHINE\\SOFTWARE\\*\\Windows NT\\*\\CurrentVersion\\AeDebug")
for _, keypath in ipairs(keypaths) do
    print(winos.registry_query(keypath .. ";Debugger"))
end

winos.registry_values ​

  • Get a list of registry value names

Function Prototype ​

API

lua
winos.registry_values(pattern: <string>)

Parameter Description ​

ParameterDescription
patternPattern string for matching registry values

Usage ​

Support to obtain the value name list of the specified key path through pattern matching, and the string after the ; is the specified key name pattern matching string.

lua
local valuepaths = winos.registry_values("HKEY_LOCAL_MACHINE\\SOFTWARE\\xx\\AeDebug;Debug*")
for _, valuepath in ipairs(valuepaths) do
    print(winos.registry_query(valuepath))
end

winos.registry_query ​

  • Get the registry value

Function Prototype ​

API

lua
winos.registry_query(keypath: <string>)

Parameter Description ​

ParameterDescription
keypathRegistry key path

Usage ​

Get the value under the specified registry path, if the value name is not specified, then get the default value of the key path

lua
local value, errors = winos.registry_query("HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion\\AeDebug")
local value, errors = winos.registry_query("HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion\\AeDebug;Debugger")

winos.file_signature v3.0.8 ​

  • Get the digital signature information of a file

Function Prototype ​

API

lua
winos.file_signature(filepath: <string>)

Parameter Description ​

ParameterDescription
filepathWindows executable file path

Return Value ​

TypeDescription
table/nilReturns a table with signature information, nil if the file has no signature

The returned table contains the following fields:

  • is_signed: Whether the file is digitally signed
  • is_trusted: Whether the signature is trusted by the OS
  • signer_name: Name of the signer

Usage ​

lua
local info = winos.file_signature("C:\\Windows\\System32\\notepad.exe")
if info then
    print(info.is_signed)    -- true
    print(info.is_trusted)   -- true
    print(info.signer_name)  -- "Microsoft Windows"
end

Note

This interface is only available on Windows.