Skip to content

Commit db02a66

Browse files
committed
Fix GetProcessImageFilePathByFileObject
1 parent ba5fc34 commit db02a66

File tree

1 file changed

+18
-2
lines changed

1 file changed

+18
-2
lines changed

src/processhlp.hpp

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@
4040
#include "symcache.hpp"
4141
#include "dummypdb.hpp"
4242
#include "processimplicithlp.hpp"
43+
#include "objhelper.hpp"
4344

4445
namespace wa {
4546

@@ -188,11 +189,26 @@ class WDbgArkRemoteTypedProcess : public WDbgArkImplicitProcess, public ExtRemot
188189
m_sym_cache->GetCookieCache(segm),
189190
nullptr).Field("ControlArea").Field("FilePointer");
190191

191-
if ( !fp.GetPtr() ) {
192+
uint64_t fp_offset = 0;
193+
194+
if ( fp.HasField("Object") ) {
195+
fp_offset = ExFastRefGetObject(fp.Field("Object").GetPtr());
196+
} else {
197+
fp_offset = fp.GetPtr();
198+
}
199+
200+
if ( !offset ) {
192201
return false;
193202
}
194203

195-
auto file_name = fp.Field("FileName");
204+
const std::string file_obj("nt!_FILE_OBJECT");
205+
ExtRemoteTyped file_object(file_obj.c_str(),
206+
fp_offset,
207+
false,
208+
m_sym_cache->GetCookieCache(file_obj),
209+
nullptr);
210+
211+
auto file_name = file_object.Field("FileName");
196212
const auto [result, path] = UnicodeStringStructToString(file_name);
197213

198214
if ( SUCCEEDED(result) ) {

0 commit comments

Comments
 (0)