[FarGroup/FarManager] master: LuaFAR: refactoring (174bcef5e)

0 views
Skip to first unread message

farg...@farmanager.com

unread,
Sep 28, 2025, 8:15:50 AM (3 days ago) Sep 28
to farco...@googlegroups.com
Repository : https://github.com/FarGroup/FarManager
On branch : master
Link : https://github.com/FarGroup/FarManager/commit/174bcef5ea3e92109e01a37813c661f3b37cbe47

>---------------------------------------------------------------

commit 174bcef5ea3e92109e01a37813c661f3b37cbe47
Author: Shmuel Zeigerman <solo...@gmail.com>
Date: Sun Sep 28 15:10:12 2025 +0300

LuaFAR: refactoring


>---------------------------------------------------------------

174bcef5ea3e92109e01a37813c661f3b37cbe47
plugins/luamacro/_globalinfo.lua | 2 +-
plugins/luamacro/changelog | 4 ++++
plugins/luamacro/luafar/lf_version.h | 2 +-
plugins/luamacro/luafar/lf_win.c | 36 +++++++++++++++++-------------------
4 files changed, 23 insertions(+), 21 deletions(-)

diff --git a/plugins/luamacro/_globalinfo.lua b/plugins/luamacro/_globalinfo.lua
index b207c92c4..1147fccd0 100644
--- a/plugins/luamacro/_globalinfo.lua
+++ b/plugins/luamacro/_globalinfo.lua
@@ -1,6 +1,6 @@
function export.GetGlobalInfo()
return {
- Version = { 3, 0, 0, 894 },
+ Version = { 3, 0, 0, 895 },
MinFarVersion = { 3, 0, 0, 6546 },
Guid = win.Uuid("4EBBEFC8-2084-4B7F-94C0-692CE136894D"),
Title = "LuaMacro",
diff --git a/plugins/luamacro/changelog b/plugins/luamacro/changelog
index 4d251b39a..9bf6c2127 100644
--- a/plugins/luamacro/changelog
+++ b/plugins/luamacro/changelog
@@ -1,3 +1,7 @@
+shmuel 2025-09-28 15:08:34+03:00 - build 895
+
+1. LuaFAR: refactoring.
+
shmuel 2025-09-28 10:56:35+03:00 - build 894

1. LuaFAR: refactoring.
diff --git a/plugins/luamacro/luafar/lf_version.h b/plugins/luamacro/luafar/lf_version.h
index 29a3e0979..d91663263 100644
--- a/plugins/luamacro/luafar/lf_version.h
+++ b/plugins/luamacro/luafar/lf_version.h
@@ -1,3 +1,3 @@
#include <farversion.hpp>

-#define PLUGIN_BUILD 894
+#define PLUGIN_BUILD 895
diff --git a/plugins/luamacro/luafar/lf_win.c b/plugins/luamacro/luafar/lf_win.c
index 438c60521..61d242fef 100644
--- a/plugins/luamacro/luafar/lf_win.c
+++ b/plugins/luamacro/luafar/lf_win.c
@@ -17,6 +17,14 @@ WARNING_POP()
#include "lf_bit64.h"
#include "lf_service.h"

+typedef NTSTATUS(NTAPI* tpNtQueryInformationFile)(HANDLE FileHandle, PIO_STATUS_BLOCK IoStatusBlock, PVOID FileInformation, ULONG Length, FILE_INFORMATION_CLASS FileInformationClass);
+typedef NTSTATUS(NTAPI* tpNtSetInformationFile)(HANDLE FileHandle, PIO_STATUS_BLOCK IoStatusBlock, PVOID FileInformation, ULONG Length, FILE_INFORMATION_CLASS FileInformationClass);
+typedef LSTATUS(* tpRegDeleteKeyExW)(HKEY hKey, LPCWSTR lpSubKey, REGSAM samDesired, DWORD Reserved);
+
+static tpNtQueryInformationFile pNtQueryInformationFile;
+static tpNtSetInformationFile pNtSetInformationFile;
+static tpRegDeleteKeyExW pRegDeleteKeyExW;
+
static BOOL dir_exist(const wchar_t* path)
{
DWORD attr = GetFileAttributesW(path);
@@ -213,22 +221,11 @@ static int win_GetRegKey(lua_State *L)
// Result: TRUE if success, FALSE if failure, [boolean]
static int win_DeleteRegKey(lua_State *L)
{
- long res;
HKEY hRoot = CheckHKey(L, 1);
const wchar_t* Key = check_utf8_string(L, 2, NULL);
REGSAM samDesired = (REGSAM) OptFlags(L, 3, 0);

- FARPROC ProcAddr;
- HMODULE module = GetModuleHandleW(L"Advapi32.dll");
- if (module && (ProcAddr = GetProcAddress(module, "RegDeleteKeyExW")) != NULL)
- {
- typedef LONG (WINAPI *pRegDeleteKeyEx)(HKEY, LPCTSTR, REGSAM, DWORD);
- res = ((pRegDeleteKeyEx)(intptr_t)ProcAddr)(hRoot, Key, samDesired, 0);
- }
- else
- {
- res = RegDeleteKeyW(hRoot, Key);
- }
+ long res = pRegDeleteKeyExW ? pRegDeleteKeyExW(hRoot, Key, samDesired, 0) : RegDeleteKeyW(hRoot, Key);
return lua_pushboolean(L, res==ERROR_SUCCESS), 1;
}

@@ -865,18 +862,19 @@ static void PutFileTimeToTableEx(lua_State *L, const LARGE_INTEGER *FT, const ch
lua_setfield(L, -2, key);
}

-typedef NTSTATUS(NTAPI* QueryInformationFile)(HANDLE FileHandle, PIO_STATUS_BLOCK IoStatusBlock, PVOID FileInformation, ULONG Length, FILE_INFORMATION_CLASS FileInformationClass);
-typedef NTSTATUS(NTAPI* SetInformationFile)(HANDLE FileHandle, PIO_STATUS_BLOCK IoStatusBlock, PVOID FileInformation, ULONG Length, FILE_INFORMATION_CLASS FileInformationClass);
-static QueryInformationFile pNtQueryInformationFile;
-static SetInformationFile pNtSetInformationFile;
-
static void SetFunctionPointers()
{
HMODULE hNtDll = GetModuleHandleW(L"ntdll.dll");
if (hNtDll)
{
- pNtQueryInformationFile = (QueryInformationFile)(INT_PTR)GetProcAddress(hNtDll, "NtQueryInformationFile");
- pNtSetInformationFile = (SetInformationFile)(INT_PTR)GetProcAddress(hNtDll, "NtSetInformationFile");
+ pNtQueryInformationFile = (tpNtQueryInformationFile)(INT_PTR)GetProcAddress(hNtDll, "NtQueryInformationFile");
+ pNtSetInformationFile = (tpNtSetInformationFile)(INT_PTR)GetProcAddress(hNtDll, "NtSetInformationFile");
+ }
+
+ HMODULE hAdvApi = GetModuleHandleW(L"Advapi32.dll");
+ if (hAdvApi)
+ {
+ pRegDeleteKeyExW = (tpRegDeleteKeyExW)(INT_PTR)GetProcAddress(hAdvApi, "RegDeleteKeyExW");
}
}



Reply all
Reply to author
Forward
0 new messages