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

Function hook_SHGetSpecialFolderPathW

qiling/os/windows/dlls/shell32.py:148–174  ·  view source on GitHub ↗
(ql: Qiling, address: int, params)

Source from the content-addressed store, hash-verified

146 'fCreate' : BOOL
147})
148def hook_SHGetSpecialFolderPathW(ql: Qiling, address: int, params):
149 directory_id = params["csidl"]
150 dst = params["pszPath"]
151
152 if directory_id == CSIDL_COMMON_APPDATA:
153 path = ntpath.join(ql.os.userprofile, "AppData\\")
154 # We always create the directory
155 appdata_dir = path.split("C:\\")[1].replace("\\", "/")
156 ql.log.debug("dir path: %s" % path)
157
158 path_emulated = os.path.join(ql.rootfs, appdata_dir)
159 ql.log.debug("emulated path: %s" % path_emulated)
160
161 ql.mem.write(dst, (path + "\x00").encode("utf-16le"))
162
163 # FIXME: Somehow winodws path is wrong
164 if not os.path.exists(path_emulated):
165 try:
166 os.makedirs(path_emulated, 0o755)
167 except OSError:
168 ql.log.debug("os.makedirs failed")
169 else:
170 ql.log.debug("os.makedirs completed")
171 else:
172 raise QlErrorNotImplemented("API not implemented")
173
174 return 1

Callers

nothing calls this directly

Calls 3

writeMethod · 0.45
existsMethod · 0.45

Tested by

no test coverage detected