diff --git a/3rd/bee.lua b/3rd/bee.lua index 9def7171..4c8546f8 160000 --- a/3rd/bee.lua +++ b/3rd/bee.lua @@ -1 +1 @@ -Subproject commit 9def71716a3223927178b49d194bcd157fa80542 +Subproject commit 4c8546f85ffe9603fe10217e9c8e9d122924ef6c diff --git a/compile/common/runtime.lua b/compile/common/runtime.lua index 7717412a..a227fc73 100644 --- a/compile/common/runtime.lua +++ b/compile/common/runtime.lua @@ -58,7 +58,7 @@ lm:source_set 'luadbg' { windows = { defines = { "_CRT_SECURE_NO_WARNINGS", - "_WIN32_WINNT=0x0601", + "_WIN32_WINNT=0x0602", }, } } @@ -92,7 +92,7 @@ lm:source_set 'luadbg-compatible' { windows = { defines = { "_CRT_SECURE_NO_WARNINGS", - "_WIN32_WINNT=0x0601", + "_WIN32_WINNT=0x0602", }, } } @@ -344,7 +344,7 @@ for _, luaver in ipairs { deps = luaver..'/'..luaver, defines = { "_CRT_SECURE_NO_WARNINGS", - "_WIN32_WINNT=0x0601", + "_WIN32_WINNT=0x0602", ("LUA_DLL_VERSION="..luaver) }, links = { diff --git a/compile/windows/runtime.lua b/compile/windows/runtime.lua index 9cf86157..ad41b7e1 100644 --- a/compile/windows/runtime.lua +++ b/compile/windows/runtime.lua @@ -4,7 +4,7 @@ require "compile.common.config" local platform = lm.runtime_platform -lm.defines = "_WIN32_WINNT=0x0601" +lm.defines = "_WIN32_WINNT=0x0602" lm.builddir = ("build/%s/%s"):format(platform, lm.mode) require "compile.common.runtime" diff --git a/src/process_inject/windows/inject.cpp b/src/process_inject/windows/inject.cpp index 58464b2e..727f7fb5 100644 --- a/src/process_inject/windows/inject.cpp +++ b/src/process_inject/windows/inject.cpp @@ -1,6 +1,7 @@ #include #include #include +#include #include #include @@ -9,22 +10,27 @@ #include "injectdll.h" -inline std::string_view checkstrview(lua_State* L, int idx) { +static bee::zstring_view checkstrview(lua_State* L, int idx) { size_t len = 0; const char* buf = luaL_checklstring(L, idx, &len); return { buf, len }; } +static std::wstring checkstring(lua_State* L, int idx) { + auto str = checkstrview(L, idx); + return bee::win::u2w(str); +} + static int injectdll(lua_State* L) { if (lua_type(L, 1) == LUA_TNUMBER) { DWORD pid = (DWORD)luaL_checkinteger(L, 1); - bool ok = injectdll(pid, bee::lua::checkstring(L, 2), bee::lua::checkstring(L, 3), checkstrview(L, 4)); + bool ok = injectdll(pid, checkstring(L, 2), checkstring(L, 3), checkstrview(L, 4)); lua_pushboolean(L, ok); return 1; } else { auto& self = *(bee::subprocess::process*)luaL_checkudata(L, 1, "bee::subprocess"); - bool ok = injectdll(self.native_handle(), self.thread_handle(), bee::lua::checkstring(L, 2), bee::lua::checkstring(L, 3), checkstrview(L, 4)); + bool ok = injectdll(self.native_handle(), self.thread_handle(), checkstring(L, 2), checkstring(L, 3), checkstrview(L, 4)); lua_pushboolean(L, ok); return 1; } diff --git a/src/process_inject/windows/injectdll.cpp b/src/process_inject/windows/injectdll.cpp index ca42d248..fedd6c79 100644 --- a/src/process_inject/windows/injectdll.cpp +++ b/src/process_inject/windows/injectdll.cpp @@ -49,7 +49,7 @@ static bool wow64_write_memory(uint64_t nwvm, HANDLE hProcess, uint64_t lpBaseAd return true; } -static bool injectdll_x64(HANDLE process_handle, HANDLE thread_handle, const std::wstring& dll, const std::string_view& entry) { +static bool injectdll_x64(HANDLE process_handle, HANDLE thread_handle, const std::wstring& dll, const bee::zstring_view& entry) { static unsigned char sc[] = { 0x9C, // pushfq 0x0F, 0xA8, // push gs @@ -195,7 +195,7 @@ static bool injectdll_x64(HANDLE process_handle, HANDLE thread_handle, const std return true; } -static bool injectdll_x86(HANDLE process_handle, HANDLE thread_handle, const std::wstring& dll, const std::string_view& entry) { +static bool injectdll_x86(HANDLE process_handle, HANDLE thread_handle, const std::wstring& dll, const bee::zstring_view& entry) { static unsigned char sc[] = { 0x68, 0x00, 0x00, 0x00, 0x00, // push eip 0x9C, // pushfd @@ -266,7 +266,7 @@ static bool injectdll_x86(HANDLE process_handle, HANDLE thread_handle, const std return true; } -bool injectdll(HANDLE process_handle, HANDLE thread_handle, const std::wstring& x86dll, const std::wstring& x64dll, const std::string_view& entry) { +bool injectdll(HANDLE process_handle, HANDLE thread_handle, const std::wstring& x86dll, const std::wstring& x64dll, const bee::zstring_view& entry) { if (is_process64(process_handle)) { return !x64dll.empty() && injectdll_x64(process_handle, thread_handle, x64dll, entry); } @@ -342,7 +342,7 @@ static bool openprocess(DWORD pid, DWORD process_access, DWORD thread_access, PR return true; } -bool injectdll(DWORD pid, const std::wstring& x86dll, const std::wstring& x64dll, const std::string_view& entry) { +bool injectdll(DWORD pid, const std::wstring& x86dll, const std::wstring& x64dll, const bee::zstring_view& entry) { PROCESS_INFORMATION pi = { 0 }; if (!openprocess(pid, PROCESS_ALL_ACCESS, THREAD_GET_CONTEXT | THREAD_SET_CONTEXT | THREAD_SUSPEND_RESUME, pi)) { return false; diff --git a/src/process_inject/windows/injectdll.h b/src/process_inject/windows/injectdll.h index 2b914480..d578f98e 100644 --- a/src/process_inject/windows/injectdll.h +++ b/src/process_inject/windows/injectdll.h @@ -7,7 +7,7 @@ #include #include -#include +#include -bool injectdll(HANDLE process_handle, HANDLE thread_handle, const std::wstring& x86dll, const std::wstring& x64dll, const std::string_view& entry = 0); -bool injectdll(DWORD pid, const std::wstring& x86dll, const std::wstring& x64dll, const std::string_view& entry = 0); +bool injectdll(HANDLE process_handle, HANDLE thread_handle, const std::wstring& x86dll, const std::wstring& x64dll, const bee::zstring_view& entry = 0); +bool injectdll(DWORD pid, const std::wstring& x86dll, const std::wstring& x64dll, const bee::zstring_view& entry = 0);