MCPcopy Create free account
hub / github.com/qilingframework/qiling / _GetTempPath

Function _GetTempPath

qiling/os/windows/dlls/kernel32/fileapi.py:369–390  ·  view source on GitHub ↗
(ql: Qiling, address: int, params, *, wide: bool)

Source from the content-addressed store, hash-verified

367 return _CreateFile(ql, address, params)
368
369def _GetTempPath(ql: Qiling, address: int, params, *, wide: bool):
370 vtmpdir = ntpath.join(ql.os.windir, 'Temp')
371 htmpdir = ql.os.path.virtual_to_host_path(vtmpdir)
372
373 if ql.os.path.is_safe_host_path(htmpdir):
374 if not os.path.exists(htmpdir):
375 os.makedirs(htmpdir, 0o755)
376
377 nBufferLength = params['nBufferLength']
378 lpBuffer = params['lpBuffer']
379
380 enc = 'utf-16le' if wide else 'utf-8'
381
382 # temp dir path has to end with a path separator
383 tmpdir = f'{vtmpdir}{ntpath.sep}'.encode(enc)
384 cstr = tmpdir + '\x00'.encode(enc)
385
386 if nBufferLength >= len(cstr):
387 ql.mem.write(lpBuffer, cstr)
388
389 # returned length does not include the null-terminator
390 return len(tmpdir)
391
392# DWORD GetTempPathW(
393# DWORD nBufferLength,

Callers 2

hook_GetTempPathWFunction · 0.85
hook_GetTempPathAFunction · 0.85

Calls 4

virtual_to_host_pathMethod · 0.80
is_safe_host_pathMethod · 0.80
existsMethod · 0.45
writeMethod · 0.45

Tested by

no test coverage detected