Commit graph

6 commits

Author SHA1 Message Date
sina
29398bd9cf update CHANGELOG and minor CPUID SDK fucntion fix 2026-10-04 21:46:13 +02:00
sina
0c13e26835 Restore Linux change 2026-10-04 21:46:13 +02:00
Claude
b451e6c810 Locate files next to the executable on Linux
`SetupPathForFileName` is the "find a file beside my binary" helper: it is how
the driver path, the hwdbg test/script files, the exported
`hyperdbg_u_setup_path_for_filename` and (now) the PCI ID database are all
resolved. On Linux it was a stub that printed an error and returned FALSE, so
every one of those lookups failed. Implementing it also removes the blocker that
kept two neighbouring helpers stubbed, so all three are done here.

install-linux.cpp — SetupPathForFileName:

A call-for-call port of the Windows body. `readlink("/proc/self/exe")` is the
`GetModuleFileName(GetModuleHandle(NULL), ...)` counterpart, `strrchr(..., '/')`
replaces `strrchr(..., '\\')` to strip the program name, and `access(path, F_OK)`
replaces the `CreateFile(..., OPEN_EXISTING)` probe behind `CheckFileExists`.

Two things it does that the Windows version does not:

- BufferLength is honoured on every write. `readlink` truncates silently, so a
  result that fills the buffer is rejected instead of being handed back as a
  valid-looking path to the wrong file, and the directory + '/' + name + NUL
  total is checked before appending. install.cpp gets the second half of this
  from StringCbCat, but its GetModuleFileName truncation is unchecked.

- Windows-style separators in FileName are normalized to '/'. The names come
  from shared headers and are spelled the Windows way —
  HWDBG_TEST_READ_INSTANCE_INFO_PATH ("..\\..\\..\\..\\hwdbg\\...") and
  PCI_ID_DATABASE_PATH ("constants\\pci.ids"). Normalizing here keeps those
  constants shared and keeps the #ifdef out of every call site. Only the
  appended part is rewritten, so a backslash inside a real Linux directory name
  survives.

common.cpp — ListDirectory:

opendir/readdir with fnmatch for the wildcard, mirroring how FindFirstFileA
applies the pattern to the file name. No fnmatch flag is passed, so a leading
'.' is unremarkable and "." / ".." match a bare "*", as they do in the Win32
walk; a missing directory throws the same std::runtime_error as the
INVALID_HANDLE_VALUE branch. One deliberate difference: the result is sorted,
since readdir returns entries in file-system order and the caller (eval.cpp's
script-engine test harness) is easier to compare across runs when the order is
stable.

pci-id.cpp — GetVendorById:

The Linux branch now builds the database path with SetupPathForFileName and
calls the same GetVendorByIdStr as Windows. It had been left Windows-only
because wrapping just the two Win32 calls would have left strrchr looking for a
'\\' and silently resolving against the cwd; the normalization above removes
that objection. !pcitree and !pcicam resolve vendor and device names on Linux
whenever constants/pci.ids is deployed next to the binary.

Verified by extracting SetupPathForFileName and the Linux ListDirectory branch
into a standalone harness built with -fsanitize=address,undefined: 20 probes
covering the separator normalization, both CheckFileExists outcomes, the
exact-fit and one-byte-short buffer boundaries, a buffer too small for the
executable path itself, the NULL/zero-length arguments, and the four
ListDirectory cases (filtering, sorting, empty match, missing directory). All
pass with no sanitizer diagnostics. The three modified files were also compiled
with the project's own Linux CMake build. The Windows build is untouched: every
change is inside a non-Windows branch or in a file that is not in the Windows
project.

The ledger in hyperdbg/linux/PORTING_STATUS.md is updated accordingly;
GetConfigFilePath stays open, as it is the same walk behind a PWCHAR
out-parameter and remains blocked on the wide-char work.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01W3C1DuhHtqK64eEkHjKCHM
2026-10-04 21:46:13 +02:00
Max Raulea
3faff1e1e2 kernel module compilation guide
Some checks failed
vs2026-ci / win-amd64-build (release, x64) (push) Has been cancelled
vs2026-ci / win-amd64-build (debug, x64) (push) Has been cancelled
vs2026-ci / Deploy release (push) Has been cancelled
2026-08-26 18:02:47 +02:00
Max Raulea
1abac35edc new email and some changes 2026-07-22 11:05:07 +02:00
Max Raulea
d6f70eecd9 Added driver install for linux stub, and new platform functions and 1:1 mappings 2026-07-18 16:38:09 +02:00