summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSaikari <[email protected]>2026-02-06 11:11:15 +0300
committerSaikari <[email protected]>2026-02-06 11:11:15 +0300
commitd49ea464353c5e63c95c77cc97d1827dd3df53ad (patch)
treee7e62c2c19ec8678a08c2854c2c8e421ec44f857
parentda9078511fa52c95cf7e5aad21deb55b27e64488 (diff)
Resolve comments
-rw-r--r--core/src/xmake/process/openv.c27
-rw-r--r--tests/projects/windows/test_windows_links/xmake.lua2
-rw-r--r--xmake/core/base/os.lua3
-rw-r--r--xmake/core/sandbox/modules/os.lua109
4 files changed, 4 insertions, 137 deletions
diff --git a/core/src/xmake/process/openv.c b/core/src/xmake/process/openv.c
index b9020cb2c..223d2d774 100644
--- a/core/src/xmake/process/openv.c
+++ b/core/src/xmake/process/openv.c
@@ -34,9 +34,6 @@
defined(TB_CONFIG_OS_HAIKU) || defined(TB_COMPILER_IS_MINGW)
#include <signal.h>
#endif
-#ifdef TB_CONFIG_OS_WINDOWS
-#include <windows.h>
-#endif
/* //////////////////////////////////////////////////////////////////////////////////////
* implementation
@@ -103,12 +100,6 @@ tb_int_t xm_process_openv(lua_State *lua) {
// init attributes
tb_process_attr_t attr = { 0 };
-#ifdef TB_CONFIG_OS_WINDOWS
- // the error mode
- UINT old_error_mode = 0;
- tb_bool_t set_error_mode = tb_false;
-#endif
-
// get option arguments
tb_bool_t exclusive = tb_false;
tb_size_t envn = 0;
@@ -139,17 +130,6 @@ tb_int_t xm_process_openv(lua_State *lua) {
}
lua_pop(lua, 1);
-#ifdef TB_CONFIG_OS_WINDOWS
- // save winos error mode?
- lua_pushstring(lua, "winos_error_mode_gui");
- lua_gettable(lua, 3);
- if (lua_toboolean(lua, -1)) {
- old_error_mode = SetErrorMode(0);
- set_error_mode = tb_true;
- }
- lua_pop(lua, 1);
-#endif
-
// get curdir
lua_pushstring(lua, "curdir");
lua_gettable(lua, 3);
@@ -343,13 +323,6 @@ tb_int_t xm_process_openv(lua_State *lua) {
lua_pushnil(lua);
}
-#ifdef TB_CONFIG_OS_WINDOWS
- // restore error mode
- if (set_error_mode) {
- SetErrorMode(old_error_mode);
- }
-#endif
-
// exit argv
if (argv) {
tb_free(argv);
diff --git a/tests/projects/windows/test_windows_links/xmake.lua b/tests/projects/windows/test_windows_links/xmake.lua
index 2f01a3c88..e856892d3 100644
--- a/tests/projects/windows/test_windows_links/xmake.lua
+++ b/tests/projects/windows/test_windows_links/xmake.lua
@@ -1,6 +1,6 @@
add_rules("mode.debug", "mode.release")
-set_policy("run.gui_error_dialogs", false)
+set_policy("run.gui_error_dialogs", true)
target("foo")
set_kind("shared")
diff --git a/xmake/core/base/os.lua b/xmake/core/base/os.lua
index 0607bb209..ae730738e 100644
--- a/xmake/core/base/os.lua
+++ b/xmake/core/base/os.lua
@@ -994,8 +994,7 @@ function os.execv(program, argv, opt)
stderr = opt.stderr,
curdir = opt.curdir,
detach = opt.detach,
- exclusive = opt.exclusive,
- winos_error_mode_gui = opt.winos_error_mode_gui}
+ exclusive = opt.exclusive}
-- profile process performance
local runtime
diff --git a/xmake/core/sandbox/modules/os.lua b/xmake/core/sandbox/modules/os.lua
index 5718f8dec..25242f3f4 100644
--- a/xmake/core/sandbox/modules/os.lua
+++ b/xmake/core/sandbox/modules/os.lua
@@ -26,6 +26,7 @@ local utils = require("base/utils")
local xmake = require("base/xmake")
local option = require("base/option")
local semver = require("base/semver")
+local binutils = require("base/binutils")
local scheduler = require("base/scheduler")
local sandbox = require("sandbox/sandbox")
local vformat = require("sandbox/modules/vformat")
@@ -357,113 +358,7 @@ local function _get_missing_dlls(program)
return false
end
- local imports = {}
- local file = io.open(program, "rb")
- if file then
- local function read_uint16()
- local str = file:read(2)
- if not str then return 0 end
- local b1, b2 = string.byte(str, 1, 2)
- return b1 + b2 * 256
- end
- local function read_uint32()
- local str = file:read(4)
- if not str then return 0 end
- local b1, b2, b3, b4 = string.byte(str, 1, 4)
- return b1 + b2 * 256 + b3 * 65536 + b4 * 16777216
- end
-
- local mz = file:read(2)
- if mz == "MZ" then
- file:seek("set", 0x3C)
- local e_lfanew = read_uint32()
- file:seek("set", e_lfanew)
- if file:read(4) == "PE\0\0" then
- -- file header
- file:seek("cur", 2) -- Machine (2)
- local number_of_sections = read_uint16()
- file:seek("cur", 12) -- TimeDateStamp(4) + PointerToSymbolTable(4) + NumberOfSymbols(4)
- local size_of_optional_header = read_uint16()
- file:seek("cur", 2) -- Characteristics (2)
-
- -- optional header
- local magic = read_uint16()
- local is_pe64 = (magic == 0x20b)
-
- -- skip standard fields and some windows fields to reach DataDirectories
- -- Standard(24/22) + Windows(68/88)
- -- PE32: 24 + 68 = 92 bytes from magic to DataDirectories
- -- PE32+: 24 + 88 = 112 bytes from magic to DataDirectories
- -- Minus magic(2) that we just read
- local skip = (is_pe64 and (24 + 88 - 2) or (24 + 68 - 2))
- file:seek("cur", skip)
-
- -- Data Directories
- -- Export Table (8)
- file:seek("cur", 8)
-
- -- Import Table
- local import_rva = read_uint32()
- local import_size = read_uint32()
-
- if import_rva > 0 then
- -- Section Headers
- file:seek("set", e_lfanew + 4 + 20 + size_of_optional_header)
- local sections = {}
- for i = 1, number_of_sections do
- local s = {}
- file:seek("cur", 8) -- name
- s.vsize = read_uint32()
- s.vaddr = read_uint32()
- s.rawsize = read_uint32()
- s.rawaddr = read_uint32()
- file:seek("cur", 16)
- table.insert(sections, s)
- end
-
- local function rva_to_offset(rva)
- for _, s in ipairs(sections) do
- if rva >= s.vaddr and rva < s.vaddr + s.vsize then
- return s.rawaddr + (rva - s.vaddr)
- end
- end
- return nil
- end
-
- local import_offset = rva_to_offset(import_rva)
- if import_offset then
- file:seek("set", import_offset)
- while true do
- local original_ft = read_uint32() -- OriginalFirstThunk
- local time_date = read_uint32()
- local forwarder = read_uint32()
- local name_rva = read_uint32()
- local first_thunk = read_uint32()
-
- if original_ft == 0 and name_rva == 0 then break end
-
- if name_rva > 0 then
- local name_offset = rva_to_offset(name_rva)
- if name_offset then
- local save_pos = file:seek()
- file:seek("set", name_offset)
- local chars = {}
- while true do
- local b = string.byte(file:read(1))
- if b == 0 then break end
- table.insert(chars, string.char(b))
- end
- table.insert(imports, table.concat(chars))
- file:seek("set", save_pos)
- end
- end
- end
- end
- end
- end
- end
- file:close()
- end
+ local imports = binutils.deplibs(program) or {}
for _, dll in ipairs(imports) do
if not _find_dll(dll) then