Skip to content

Instantly share code, notes, and snippets.

@Aetopia
Created September 18, 2025 09:37
Show Gist options
  • Select an option

  • Save Aetopia/e7179820749ca77703a263d481a5e36b to your computer and use it in GitHub Desktop.

Select an option

Save Aetopia/e7179820749ca77703a263d481a5e36b to your computer and use it in GitHub Desktop.
Alternative bootstrapper for Minecraft Preview's PC Bootstrapper.
#define INITGUID
#define COBJMACROS
#define _MINAPPMODEL_H_
#define WIDL_C_INLINE_WRAPPERS
#include <windows.h>
#include <shobjidl.h>
#include <appmodel.h>
#include <shlwapi.h>
CONST WCHAR EventName[] = L"142E10C8-AEC2-47C4-81C3-DF51CA87B02F";
CONST WCHAR PackageFamilyName[] = L"Microsoft.MinecraftWindowsBeta_8wekyb3d8bbwe";
CONST WCHAR ApplicationUserModelId[] = L"Microsoft.MinecraftWindowsBeta_8wekyb3d8bbwe!Game";
VOID Launcher(HANDLE event, PWSTR path)
{
CoInitialize(NULL);
IPackageDebugSettings *settings = NULL;
IApplicationActivationManager *manager = NULL;
LPIID iid = (LPIID)&IID_IPackageDebugSettings;
LPCLSID clsid = (LPCLSID)&CLSID_PackageDebugSettings;
CoCreateInstance(clsid, NULL, CLSCTX_INPROC_SERVER, iid, (PVOID *)&settings);
iid = (LPIID)&IID_IApplicationActivationManager;
clsid = (LPCLSID)&CLSID_ApplicationActivationManager;
CoCreateInstance(clsid, NULL, CLSCTX_INPROC_SERVER, iid, (PVOID *)&manager);
WCHAR name[PACKAGE_FULL_NAME_MAX_LENGTH + 1] = {};
GetPackagesByPackageFamily(PackageFamilyName, &(UINT32){1}, &(PWSTR){}, &(UINT32){ARRAYSIZE(name)}, name);
IPackageDebugSettings_DisableDebugging(settings, name);
IPackageDebugSettings_EnableDebugging(settings, name, path, NULL);
IApplicationActivationManager_ActivateApplication(manager, ApplicationUserModelId, NULL, AO_NOERRORUI, &(DWORD){});
WaitForSingleObject(event, INFINITE);
IPackageDebugSettings_DisableDebugging(settings, name);
IPackageDebugSettings_Release(settings);
IApplicationActivationManager_Release(manager);
CoUninitialize();
}
VOID Injector(HANDLE event, PWSTR path)
{
SetEvent(event);
INT count = 0;
PWSTR *arguments = CommandLineToArgvW(GetCommandLineW(), &count);
for (INT index = 0; index < count - 1; index++)
{
if (CompareStringOrdinal(L"-tid", -1, arguments[index], -1, FALSE) != CSTR_EQUAL)
continue;
DWORD threadId = StrToIntW(arguments[++index]);
HANDLE thread = OpenThread(THREAD_ALL_ACCESS, FALSE, threadId);
DWORD processId = GetProcessIdOfThread(thread);
HANDLE process = OpenProcess(PROCESS_ALL_ACCESS, FALSE, processId);
ResumeThread(thread);
CloseHandle(process);
CloseHandle(thread);
}
LocalFree(arguments);
}
int main()
{
WCHAR path[MAX_PATH] = {};
GetModuleFileNameW(NULL, path, MAX_PATH);
if (!GetLastError())
{
HANDLE event = CreateEventW(NULL, TRUE, FALSE, EventName);
(GetLastError() ? Injector : Launcher)(event, path);
CloseHandle(event);
}
return EXIT_SUCCESS;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment