(ql: Qiling, address: int, params)
| 146 | 'fCreate' : BOOL |
| 147 | }) |
| 148 | def 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 |
nothing calls this directly
no test coverage detected