(ql: Qiling, address: int, params, *, wide: bool)
| 367 | return _CreateFile(ql, address, params) |
| 368 | |
| 369 | def _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, |
no test coverage detected