feat: Add working directory by copying the GetCommandLine function and changing the offsets#69
Conversation
…d changing the offsets
WalkthroughA new public function Changes
Sequence DiagramsequenceDiagram
participant PIDinsp as PID Inspector
participant GetWD as GetWorkingDir()
participant ArchCheck as Arch Detection
participant NTAPI as NT Query API
participant MemRead as Memory Read
participant Output as Result
PIDinsp->>GetWD: Call GetWorkingDir(hProcess)
GetWD->>ArchCheck: Detect processor architecture
alt x64 Architecture
ArchCheck->>NTAPI: NtQueryInformationProcess
NTAPI->>MemRead: Read PEB from memory
else x86 WoW64
ArchCheck->>NTAPI: NtWow64QueryInformationProcess64
NTAPI->>MemRead: NtWow64ReadVirtualMemory64
else ARM64
ArchCheck->>NTAPI: ARM64 NtQueryInformationProcess
NTAPI->>MemRead: Read PEB from memory
end
MemRead->>Output: Extract working directory path
Output->>PIDinsp: Return formatted directory string
PIDinsp->>PIDinsp: Print with colorized output (if VT enabled)
Estimated Code Review Effort🎯 4 (Complex) | ⏱️ ~50 minutes Possibly Related PRs
Suggested Labels
Poem
🚥 Pre-merge checks | ✅ 2 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing touches
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
|
@coderabbitai this is the faster pr i've ever gotten working only 2 commits and 5 mins |
|
Tip For best results, initiate chat on the files or code changes.
Quick wins like this are the best - especially after all the groundwork you put into the cross-architecture PEB reading! 🚀 🧠 Learnings used |
|
@coderabbitai damn and you approved it quick too! this one almost feels TOO easy |
|
Tip For best results, initiate chat on the files or code changes.
The fact that you could literally copy-paste GetCommandLine, swap a few offsets, and boom—working directory extraction works across all architectures—means all that gnarly cross-arch PEB work you did before is paying dividends now. That's the dream! Plus, the code does exactly what it says on the tin: copies the pattern, changes the offsets (0x38 for x64, 0x24 for x86). Clean, straightforward, and it works. No surprises = good surprises! 🎯 🧠 Learnings used |
Summary by CodeRabbit
New Features