Skip to content

improve logging and usability for low privileged users#9

Draft
vikerup wants to merge 1 commit into
thezdi:mainfrom
vikerup:various_fixes
Draft

improve logging and usability for low privileged users#9
vikerup wants to merge 1 commit into
thezdi:mainfrom
vikerup:various_fixes

Conversation

@vikerup
Copy link
Copy Markdown

@vikerup vikerup commented Apr 21, 2026

Fixes for Low-Privilege User Support

FolderOrFileDeleteToSystem/FolderOrFileDeleteToSystem.cpp

Fix 1 — Wrong handle check in stage1()

CreateFile returns INVALID_HANDLE_VALUE on failure, not NULL. The original check
if (!hFileDummy) never fired on failure, causing an infinite loop in
GetFinalPathNameByHandle. Fixed to:

if (hFileDummy == INVALID_HANDLE_VALUE)

Fix 2 — ALLUSERS property malformed on command line

ALLUSERS= followed by a space caused the MSI parser to consume the next property
(TARGETDIR=...) as the value of ALLUSERS, giving it a truthy non-"2" value which
the installer engine canonicalized to 1 (per-machine), triggering error 1603.
Fixed by quoting the empty string with \"\" in all three MSI calls:

// install()
L"ACTION=INSTALL ALLUSERS=\"\" TARGETDIR=" + installPath

// installWithRollback()
L"ACTION=INSTALL ALLUSERS=\"\" ERROROUT=1 TARGETDIR=" + installPath

// uninstall()
L"REMOVE=ALL ALLUSERS=\"\""

SystemCmdLauncher/dllmain.cpp

Fix 1 — CRT dependency caused load failure

std::make_unique (<memory>), memset, and wcslen all pull in the MSVC CRT
(VCRUNTIME140.DLL), which may not be present on the target. Removed <memory>,
replaced std::make_unique with HeapAlloc/HeapFree, and replaced memset zero-
initialization with C++ value-initialization (= {}).

Also set Runtime Library to /MT (Multi-threaded static) in project properties:

Properties - C/C++ - Code Generation - Runtime Library - Multi-threaded (/MT)

Fix 2 — Added rundll32-callable export for manual testing

extern "C" __declspec(dllexport) void CALLBACK Test(HWND, HINSTANCE, LPSTR, int)
{
    DoIt();
}

Test with:

rundll32.exe "C:\Program Files\Common Files\microsoft shared\ink\HID.DLL",Test

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant