mirror of
https://github.com/momo5502/emulator.git
synced 2026-01-19 03:33:56 +00:00
Add temp environment variables to fix GetTempPath(2)W (#362)
`GetTempPathW` in the following code will fail to retrieve a path from
`TMP`, `TEMP`, then `USERPROFILE` environment variables (and
`SystemTemp` in `GetTempPath2W`):
```
if ( GetTempPathW(0x104u, &PathName) - 1 > 0x102 || !GetTempFileNameW(&PathName, L"xx", 0, p_LibFileName) )
return 3;
```
`GetTempFileNameW` will then call `CreateFileW` **many** times, before
giving up (see [ReactOS
implementation](https://doxygen.reactos.org/da/d76/filename_8c.html#a0963043522ee3e70101d2a764f2153e0)):

Adding the environment variables to the process context appears to
resolve this:

This commit is contained in:
@@ -119,6 +119,10 @@ namespace
|
||||
env_map[u"USERNAME"] = u"momo";
|
||||
env_map[u"SystemDrive"] = u"C:";
|
||||
env_map[u"SystemRoot"] = u"C:\\WINDOWS";
|
||||
env_map[u"SystemTemp"] = u"C:\\Windows\\SystemTemp";
|
||||
env_map[u"TMP"] = u"C:\\Users\\momo\\AppData\\Temp";
|
||||
env_map[u"TEMP"] = u"C:\\Users\\momo\\AppData\\Temp";
|
||||
env_map[u"USERPROFILE"] = u"C:\\Users\\momo";
|
||||
|
||||
for (const auto& key : keys_to_expand)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user