forked from waskord/UnleashedRecomp_Android
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.cpp
More file actions
613 lines (511 loc) · 20 KB
/
Copy pathmain.cpp
File metadata and controls
613 lines (511 loc) · 20 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
#include <stdafx.h>
#ifdef _WIN32
#include <Windows.h>
#include <timeapi.h>
#endif
#ifdef __ANDROID__
#include <os/android/perf_android.h>
#include <os/android/asset_extractor.h>
#endif
#ifdef __x86_64__
#include <cpuid.h>
#endif
#include <cpu/guest_thread.h>
#include <gpu/video.h>
#include <kernel/function.h>
#include <kernel/memory.h>
#include <kernel/heap.h>
#include <kernel/xam.h>
#include <kernel/io/file_system.h>
#include <file.h>
#include <xex.h>
#include <apu/audio.h>
#include <hid/hid.h>
#include <user/config.h>
#include <user/paths.h>
#include <user/persistent_storage_manager.h>
#include <user/registry.h>
#include <kernel/xdbf.h>
#include <install/installer.h>
#include <install/update_checker.h>
#include <os/logger.h>
#include <os/process.h>
#include <os/registry.h>
#include <ui/game_window.h>
#include <ui/installer_wizard.h>
#include <mod/mod_loader.h>
#include <preload_executable.h>
const size_t XMAIOBegin = 0x7FEA0000;
const size_t XMAIOEnd = XMAIOBegin + 0x0000FFFF;
Memory g_memory;
Heap g_userHeap;
XDBFWrapper g_xdbfWrapper;
std::unordered_map<uint16_t, GuestTexture*> g_xdbfTextureCache;
void HostStartup()
void VideoInitializeCallbacks();
VideoInitializeCallbacks();
{
hid::Init();
}
// Name inspired from nt's entry point
void KiSystemStartup()
{
if (g_memory.base == nullptr)
{
SDL_ShowSimpleMessageBox(SDL_MESSAGEBOX_ERROR, GameWindow::GetTitle(), Localise("System_MemoryAllocationFailed").c_str(), GameWindow::s_pWindow);
std::exit(1);
}
g_userHeap.Init();
const auto gameContent = XamMakeContent(XCONTENTTYPE_RESERVED, "Game");
const auto updateContent = XamMakeContent(XCONTENTTYPE_RESERVED, "Update");
const std::string gamePath = (const char*)(GetGamePath() / "game").u8string().c_str();
const std::string updatePath = (const char*)(GetGamePath() / "update").u8string().c_str();
XamRegisterContent(gameContent, gamePath);
XamRegisterContent(updateContent, updatePath);
const auto saveFilePath = GetSaveFilePath(true);
bool saveFileExists = std::filesystem::exists(saveFilePath);
if (!saveFileExists)
{
// Copy base save data to modded save as fallback.
std::error_code ec;
std::filesystem::create_directories(saveFilePath.parent_path(), ec);
if (!ec)
{
std::filesystem::copy_file(GetSaveFilePath(false), saveFilePath, ec);
saveFileExists = !ec;
}
}
if (saveFileExists)
{
std::u8string savePathU8 = saveFilePath.parent_path().u8string();
XamRegisterContent(XamMakeContent(XCONTENTTYPE_SAVEDATA, "SYS-DATA"), (const char*)(savePathU8.c_str()));
}
// Mount game
XamContentCreateEx(0, "game", &gameContent, OPEN_EXISTING, nullptr, nullptr, 0, 0, nullptr);
XamContentCreateEx(0, "update", &updateContent, OPEN_EXISTING, nullptr, nullptr, 0, 0, nullptr);
// OS mounts game data to D:
XamContentCreateEx(0, "D", &gameContent, OPEN_EXISTING, nullptr, nullptr, 0, 0, nullptr);
std::error_code ec;
for (auto& file : std::filesystem::directory_iterator(GetGamePath() / "dlc", ec))
{
if (file.is_directory())
{
#ifdef _WIN32
std::u8string fileNameU8 = file.path().filename().u8string();
std::u8string filePathU8 = file.path().u8string();
XamRegisterContent(XamMakeContent(XCONTENTTYPE_DLC, (const char*)(fileNameU8.c_str())), (const char*)(filePathU8.c_str()));
#else
XamRegisterContent(XamMakeContent(XCONTENTTYPE_DLC, file.path().filename().c_str()), file.path().c_str());
#endif
}
}
XAudioInitializeSystem();
PreloadContext preloadContext;
preloadContext.PreloadExecutable();
}
static void EnsureMemoryRange(const void* start, size_t size)
{
if (size == 0)
return;
const auto* startPtr = static_cast<const uint8_t*>(start);
if (!g_memory.IsInMemoryRange(startPtr) || !g_memory.IsInMemoryRange(startPtr + size - 1))
{
SDL_ShowSimpleMessageBox(SDL_MESSAGEBOX_ERROR, GameWindow::GetTitle(), Localise("System_MemoryAllocationFailed").c_str(), GameWindow::s_pWindow);
std::exit(1);
}
}
static const Xex2Header* ValidateXexHeader(const std::vector<uint8_t>& loadResult)
{
if (loadResult.empty())
{
assert("Failed to load module" && false);
return nullptr;
}
if (loadResult.size() < sizeof(Xex2Header))
{
SDL_ShowSimpleMessageBox(SDL_MESSAGEBOX_ERROR, GameWindow::GetTitle(), "Invalid XEX file: File too small.", GameWindow::s_pWindow);
return nullptr;
}
auto* header = reinterpret_cast<const Xex2Header*>(loadResult.data());
if (header->magic != 0x58455832) // "XEX2"
{
SDL_ShowSimpleMessageBox(SDL_MESSAGEBOX_ERROR, GameWindow::GetTitle(), "Invalid XEX file: Incorrect magic.", GameWindow::s_pWindow);
return nullptr;
}
if (header->headerSize > loadResult.size())
{
SDL_ShowSimpleMessageBox(SDL_MESSAGEBOX_ERROR, GameWindow::GetTitle(), "Invalid XEX file: Header size too large.", GameWindow::s_pWindow);
return nullptr;
}
// Verify headers array bounds
uint64_t headersArraySize = (uint64_t)header->headerCount * sizeof(Xex2OptHeader);
if ((uint64_t)sizeof(Xex2Header) + headersArraySize > loadResult.size())
{
SDL_ShowSimpleMessageBox(SDL_MESSAGEBOX_ERROR, GameWindow::GetTitle(), "Invalid XEX file: Headers array out of bounds.", GameWindow::s_pWindow);
return nullptr;
}
if (header->securityOffset >= loadResult.size() ||
(uint64_t)header->securityOffset + sizeof(Xex2SecurityInfo) > loadResult.size())
{
SDL_ShowSimpleMessageBox(SDL_MESSAGEBOX_ERROR, GameWindow::GetTitle(), "Invalid XEX file: Security info out of bounds.", GameWindow::s_pWindow);
return nullptr;
}
return header;
}
static const Xex2OptFileFormatInfo* GetAndValidateFileFormatInfo(const std::vector<uint8_t>& loadResult)
{
const void* fileFormatInfoPtr = getOptHeaderPtr(loadResult.data(), XEX_HEADER_FILE_FORMAT_INFO);
if (!fileFormatInfoPtr)
{
SDL_ShowSimpleMessageBox(SDL_MESSAGEBOX_ERROR, GameWindow::GetTitle(), "Invalid XEX file: Missing File Format Info.", GameWindow::s_pWindow);
return nullptr;
}
// Verify fileFormatInfoPtr is within bounds
if ((const uint8_t*)fileFormatInfoPtr < loadResult.data() ||
(const uint8_t*)fileFormatInfoPtr + sizeof(Xex2OptFileFormatInfo) > loadResult.data() + loadResult.size())
{
SDL_ShowSimpleMessageBox(SDL_MESSAGEBOX_ERROR, GameWindow::GetTitle(), "Invalid XEX file: File Format Info pointer out of bounds.", GameWindow::s_pWindow);
return nullptr;
}
const auto* fileFormatInfo = reinterpret_cast<const Xex2OptFileFormatInfo*>(fileFormatInfoPtr);
// Verify infoSize fits in file
if ((const uint8_t*)fileFormatInfo + fileFormatInfo->infoSize > loadResult.data() + loadResult.size())
{
SDL_ShowSimpleMessageBox(SDL_MESSAGEBOX_ERROR, GameWindow::GetTitle(), "Invalid XEX file: File Format Info size out of bounds.", GameWindow::s_pWindow);
return nullptr;
}
return fileFormatInfo;
}
static bool GetAndValidateEntryPoint(const std::vector<uint8_t>& loadResult, uint32_t& outEntry)
{
const void* entryPtr = getOptHeaderPtr(loadResult.data(), XEX_HEADER_ENTRY_POINT);
if (!entryPtr)
{
SDL_ShowSimpleMessageBox(SDL_MESSAGEBOX_ERROR, GameWindow::GetTitle(), "Invalid XEX file: Missing Entry Point.", GameWindow::s_pWindow);
return false;
}
if ((const uint8_t*)entryPtr < loadResult.data() ||
(const uint8_t*)entryPtr + sizeof(uint32_t) > loadResult.data() + loadResult.size())
{
SDL_ShowSimpleMessageBox(SDL_MESSAGEBOX_ERROR, GameWindow::GetTitle(), "Invalid XEX file: Entry Point out of bounds.", GameWindow::s_pWindow);
return false;
}
memcpy(&outEntry, entryPtr, sizeof(outEntry));
ByteSwapInplace(outEntry);
return true;
}
static bool LoadCompressedImage(const std::vector<uint8_t>& loadResult, const Xex2Header* header, const Xex2SecurityInfo* security, const Xex2OptFileFormatInfo* fileFormatInfo)
{
auto srcData = loadResult.data() + header->headerSize;
auto destData = reinterpret_cast<uint8_t*>(g_memory.Translate(security->loadAddress));
auto loadAddress = security->loadAddress;
if ((uint64_t)loadAddress + security->imageSize > PPC_MEMORY_SIZE)
{
SDL_ShowSimpleMessageBox(SDL_MESSAGEBOX_ERROR, GameWindow::GetTitle(), Localise("System_MemoryAllocationFailed").c_str(), GameWindow::s_pWindow);
std::exit(1);
}
if (fileFormatInfo->compressionType == XEX_COMPRESSION_NONE)
{
memcpy(destData, srcData, security->imageSize);
}
else if (fileFormatInfo->compressionType == XEX_COMPRESSION_BASIC)
{
if (fileFormatInfo->infoSize < sizeof(Xex2FileBasicCompressionInfo))
{
SDL_ShowSimpleMessageBox(SDL_MESSAGEBOX_ERROR, GameWindow::GetTitle(), Localise("System_MemoryAllocationFailed").c_str(), GameWindow::s_pWindow);
std::exit(1);
}
auto* blocks = reinterpret_cast<const Xex2FileBasicCompressionBlock*>(fileFormatInfo + 1);
const size_t numBlocks = (fileFormatInfo->infoSize / sizeof(Xex2FileBasicCompressionInfo)) - 1;
auto* currentDest = destData;
for (size_t i = 0; i < numBlocks; i++)
{
EnsureMemoryRange(currentDest, blocks[i].dataSize);
if (srcData + blocks[i].dataSize > loadResult.data() + loadResult.size())
{
SDL_ShowSimpleMessageBox(SDL_MESSAGEBOX_ERROR, GameWindow::GetTitle(), "Invalid XEX file: Compressed block source data out of bounds.", GameWindow::s_pWindow);
return false;
}
memcpy(currentDest, srcData, blocks[i].dataSize);
srcData += blocks[i].dataSize;
currentDest += blocks[i].dataSize;
EnsureMemoryRange(currentDest, blocks[i].zeroSize);
memset(currentDest, 0, blocks[i].zeroSize);
currentDest += blocks[i].zeroSize;
}
}
else
{
assert(false && "Unknown compression type.");
}
return true;
}
uint32_t LdrLoadModule(const std::filesystem::path &path)
{
auto loadResult = LoadFile(path);
const Xex2Header* header = ValidateXexHeader(loadResult);
if (!header)
{
return 0;
}
auto* security = reinterpret_cast<const Xex2SecurityInfo*>(loadResult.data() + header->securityOffset);
const Xex2OptFileFormatInfo* fileFormatInfo = GetAndValidateFileFormatInfo(loadResult);
if (!fileFormatInfo)
{
return 0;
}
uint32_t entry;
if (!GetAndValidateEntryPoint(loadResult, entry))
{
return 0;
}
if (!LoadCompressedImage(loadResult, header, security, fileFormatInfo))
{
return 0;
}
auto res = reinterpret_cast<const Xex2ResourceInfo*>(getOptHeaderPtr(loadResult.data(), XEX_HEADER_RESOURCE_INFO));
g_xdbfWrapper = XDBFWrapper((uint8_t*)g_memory.Translate(res->offset.get()), res->sizeOfData);
return entry;
}
#ifdef __x86_64__
__attribute__((constructor(101), target("no-avx,no-avx2"), noinline))
void init()
{
uint32_t eax, ebx, ecx, edx;
// Execute CPUID for processor info and feature bits.
__get_cpuid(1, &eax, &ebx, &ecx, &edx);
// Check for AVX support.
if ((ecx & (1 << 28)) == 0)
{
printf("[*] CPU does not support the AVX instruction set.\n");
std::exit(1);
}
}
#endif
struct CommandLineOptions
{
bool ForceInstaller = false;
bool ForceDLCInstaller = false;
bool UseDefaultWorkingDirectory = false;
bool ForceInstallationCheck = false;
bool GraphicsApiRetry = false;
const char* SdlVideoDriver = nullptr;
};
CommandLineOptions ParseCommandLineArguments(int argc, char* argv[])
{
CommandLineOptions options;
for (int i = 1; i < argc; i++)
{
options.ForceInstaller = options.ForceInstaller || (strcmp(argv[i], "--install") == 0);
options.ForceDLCInstaller = options.ForceDLCInstaller || (strcmp(argv[i], "--install-dlc") == 0);
options.UseDefaultWorkingDirectory = options.UseDefaultWorkingDirectory || (strcmp(argv[i], "--use-cwd") == 0);
options.ForceInstallationCheck = options.ForceInstallationCheck || (strcmp(argv[i], "--install-check") == 0);
options.GraphicsApiRetry = options.GraphicsApiRetry || (strcmp(argv[i], "--graphics-api-retry") == 0);
if (strcmp(argv[i], "--sdl-video-driver") == 0)
{
if ((i + 1) < argc)
options.SdlVideoDriver = argv[++i];
else
LOGN_WARNING("No argument was specified for --sdl-video-driver. Option will be ignored.");
}
}
return options;
}
void InitializeSystem()
{
#ifdef _WIN32
timeBeginPeriod(1);
#endif
#ifdef __ANDROID__
perf::SetBigCoreAffinity();
SDL_setenv("SDL_AUDIO_DRIVER", "aaudio", 1);
SDL_setenv("SDL_VIDEODRIVER", "android", 1);
perf::InitChoreographer();
perf::EnableSustainedPerformanceMode(true);
#endif
os::process::CheckConsole();
if (!os::registry::Init())
LOGN_WARNING("OS does not support registry.");
os::logger::Init();
}
void SetWorkingDirectory(const CommandLineOptions& options)
{
if (!options.UseDefaultWorkingDirectory)
{
// Set the current working directory to the executable's path.
std::error_code ec;
std::filesystem::current_path(os::process::GetExecutableRoot(), ec);
}
}
void PerformInstallationIntegrityCheck(const CommandLineOptions& options)
{
if (options.ForceInstallationCheck)
{
// Create the console to show progress to the user, otherwise it will seem as if the game didn't boot at all.
os::process::ShowConsole();
Journal journal;
double lastProgressMiB = 0.0;
double lastTotalMib = 0.0;
Installer::checkInstallIntegrity(GAME_INSTALL_DIRECTORY, journal, [&]()
{
constexpr double MiBDivisor = 1024.0 * 1024.0;
constexpr double MiBProgressThreshold = 128.0;
double progressMiB = double(journal.progressCounter) / MiBDivisor;
double totalMiB = double(journal.progressTotal) / MiBDivisor;
if (journal.progressCounter > 0)
{
if ((progressMiB - lastProgressMiB) > MiBProgressThreshold)
{
LOGFN("Checking files: {:.2f} MiB / {:.2f} MiB", progressMiB, totalMiB);
lastProgressMiB = progressMiB;
}
}
else
{
if ((totalMiB - lastTotalMib) > MiBProgressThreshold)
{
LOGFN("Scanning files: {:.2f} MiB", totalMiB);
lastTotalMib = totalMiB;
}
}
return true;
});
char resultText[512];
uint32_t messageBoxStyle;
if (journal.lastResult == Journal::Result::Success)
{
snprintf(resultText, sizeof(resultText), "%s", Localise("IntegrityCheck_Success").c_str());
LOGN(resultText);
messageBoxStyle = SDL_MESSAGEBOX_INFORMATION;
}
else
{
snprintf(resultText, sizeof(resultText), "%s", fmt::format(fmt::runtime(Localise("IntegrityCheck_Failed")), journal.lastErrorMessage).c_str());
LOGN_ERROR(resultText);
messageBoxStyle = SDL_MESSAGEBOX_ERROR;
}
SDL_ShowSimpleMessageBox(messageBoxStyle, GameWindow::GetTitle(), resultText, GameWindow::s_pWindow);
std::exit(int(journal.lastResult));
}
}
void CheckForUpdates()
{
// Check the time since the last time an update was checked. Store the new time if the difference is more than six hours.
constexpr double TimeBetweenUpdateChecksInSeconds = 6 * 60 * 60;
time_t timeNow = std::time(nullptr);
double timeDifferenceSeconds = difftime(timeNow, Config::LastChecked);
if (timeDifferenceSeconds > TimeBetweenUpdateChecksInSeconds)
{
UpdateChecker::initialize();
UpdateChecker::start();
Config::LastChecked = timeNow;
Config::Save();
}
}
void InitializeVideoBackend(const CommandLineOptions& options)
{
if (!Video::CreateHostDevice(options.SdlVideoDriver, options.GraphicsApiRetry))
{
SDL_ShowSimpleMessageBox(SDL_MESSAGEBOX_ERROR, GameWindow::GetTitle(), Localise("Video_BackendError").c_str(), GameWindow::s_pWindow);
std::exit(1);
}
}
bool RunInstallerIfNeeded(const CommandLineOptions& options, std::filesystem::path& modulePath)
{
bool isGameInstalled = Installer::checkGameInstall(GetGamePath(), modulePath);
#ifdef __ANDROID__
// If game is not installed, try extracting embedded game data from APK assets.
if (!isGameInstalled && HasEmbeddedGameData())
{
LOGN("Game not installed but embedded data found, extracting...");
SDL_ShowSimpleMessageBox(SDL_MESSAGEBOX_INFORMATION, "Unleashed Recompiled",
"Extracting game data from APK...\nThis may take a few minutes on first launch.", nullptr);
if (ExtractEmbeddedGameData(GetGamePath()))
{
isGameInstalled = Installer::checkGameInstall(GetGamePath(), modulePath);
if (isGameInstalled)
{
LOGN("Embedded game data extracted successfully");
}
else
{
LOGN_ERROR("Extraction succeeded but game install check still fails");
}
}
else
{
LOGN_ERROR("Failed to extract embedded game data");
}
}
// If still not installed, check for a sideloaded game_data.tar.zst in the game directory.
// The user can copy this file from the workflow's game-data artifact.
if (!isGameInstalled && HasExternalGameData(GetGamePath()))
{
LOGN("Game not installed but external game data archive found, extracting...");
SDL_ShowSimpleMessageBox(SDL_MESSAGEBOX_INFORMATION, "Unleashed Recompiled",
"Extracting game data from archive...\nThis may take a few minutes on first launch.", nullptr);
if (ExtractExternalGameData(GetGamePath()))
{
isGameInstalled = Installer::checkGameInstall(GetGamePath(), modulePath);
if (isGameInstalled)
{
LOGN("External game data extracted successfully");
}
else
{
LOGN_ERROR("External extraction succeeded but game install check still fails");
}
}
else
{
LOGN_ERROR("Failed to extract external game data");
}
}
#endif
bool runInstallerWizard = options.ForceInstaller || options.ForceDLCInstaller || !isGameInstalled;
if (runInstallerWizard)
{
InitializeVideoBackend(options);
if (!InstallerWizard::Run(GetGamePath(), isGameInstalled && options.ForceDLCInstaller))
{
std::exit(0);
}
}
return runInstallerWizard;
}
int main(int argc, char *argv[])
{
InitializeSystem();
PreloadContext preloadContext;
preloadContext.PreloadExecutable();
CommandLineOptions options = ParseCommandLineArguments(argc, argv);
SetWorkingDirectory(options);
Config::Load();
PerformInstallationIntegrityCheck(options);
CheckForUpdates();
if (Config::ShowConsole)
os::process::ShowConsole();
HostStartup();
std::filesystem::path modulePath;
bool installerRan = RunInstallerIfNeeded(options, modulePath);
ModLoader::Init();
if (!PersistentStorageManager::LoadBinary())
LOGFN_ERROR("Failed to load persistent storage binary... (status code {})", (int)PersistentStorageManager::BinStatus);
KiSystemStartup();
uint32_t entry = LdrLoadModule(modulePath);
if (!installerRan)
{
InitializeVideoBackend(options);
}
Video::StartPipelinePrecompilation();
GuestThread::Start({ entry, 0, 0 });
return 0;
}
GUEST_FUNCTION_STUB(__imp__vsprintf);
GUEST_FUNCTION_STUB(__imp___vsnprintf);
GUEST_FUNCTION_STUB(__imp__sprintf);
GUEST_FUNCTION_STUB(__imp___snprintf);
GUEST_FUNCTION_STUB(__imp___snwprintf);
GUEST_FUNCTION_STUB(__imp__vswprintf);
GUEST_FUNCTION_STUB(__imp___vscwprintf);
GUEST_FUNCTION_STUB(__imp__swprintf);