Work on master

This commit is contained in:
Bottersnike 2023-02-16 06:39:14 +00:00
parent c37ed01bb5
commit aef9cb26cb
Signed by: Bottersnike
SSH Key Fingerprint: SHA256:3g0ghwd4dNX1k1RX8qazbiT+3RIYn/daeBevHZVCiU0
10 changed files with 289 additions and 150 deletions

View File

@ -22,7 +22,11 @@ LSTATUS WINAPI FakeRegDeleteKeyValueA(HKEY hKey, LPCSTR lpSubKey, LPCSTR lpValue
LSTATUS WINAPI FakeRegEnumKeyExA(HKEY hKey, DWORD dwIndex, LPSTR lpName, LPDWORD lpcchName, LSTATUS WINAPI FakeRegEnumKeyExA(HKEY hKey, DWORD dwIndex, LPSTR lpName, LPDWORD lpcchName,
LPDWORD lpReserved, LPSTR lpClass, LPDWORD lpcchClass, LPDWORD lpReserved, LPSTR lpClass, LPDWORD lpcchClass,
PFILETIME lpftLastWriteTime) { PFILETIME lpftLastWriteTime) {
log_trace("registry", "RegEnumKeyExA %08x %s", hKey, lpName); log_trace("registry", "RegEnumKeyExA %08x[%d]", hKey, dwIndex);
if (dwIndex == 0) {
strcpy(lpName, "Direct3D HAL");
return ERROR_SUCCESS;
}
return ERROR_NO_MORE_ITEMS; return ERROR_NO_MORE_ITEMS;
} }
LSTATUS WINAPI FakeRegEnumValueA(HKEY hKey, DWORD dwIndex, LPSTR lpValueName, LSTATUS WINAPI FakeRegEnumValueA(HKEY hKey, DWORD dwIndex, LPSTR lpValueName,

View File

@ -173,7 +173,7 @@ VOID trace_hook(char* output) {
void setup_logging() { void setup_logging() {
// Force stdio even for GUI applications // Force stdio even for GUI applications
// AttachConsole(ATTACH_PARENT_PROCESS); AttachConsole(ATTACH_PARENT_PROCESS);
// Enable colour in CMD // Enable colour in CMD
HANDLE hConsole = GetStdHandle(STD_OUTPUT_HANDLE); HANDLE hConsole = GetStdHandle(STD_OUTPUT_HANDLE);

View File

@ -1,15 +1,53 @@
#include "appLauncher.h"
#include <io.h> #include <io.h>
#include <memory.h> #include <memory.h>
#include <shlwapi.h>
#include <string.h> #include <string.h>
#include "config.h" #include "mxm.h"
/*
"SOFTWARE\\Microsoft\\Direct3D\\Drivers"
"Direct3D HAL" /3
"SOFTWARE\\Microsoft\\Direct3D"
"Drivers" /2
"SOFTWARE\\Microsoft\\DirectDraw"
"Compatibility" /1
"SOFTWARE\\Microsoft\\DirectInput"
"Compatibility" /1
"SOFTWARE\\Microsoft\\DirectMusic"
"Defaults" /2
"GMFilePath" /1
*/
void appLauncherDefaultRegSet() { void appLauncherDefaultRegSet() {
// TODO: This // TODO: This
} }
#ifdef MXM_APM2
void nxAuthStart(LPPROCESS_INFORMATION procInfo) {
if (procInfo->hProcess != NULL) return;
STARTUPINFOW startupInfo = { 0 };
startupInfo.cb = 0x44;
startupInfo.dwFlags = 1;
startupInfo.wShowWindow = 0;
wchar_t commandLine[64] = { 0 };
wchar_t path[64] = { 0 };
MultiByteToWideChar(0, 0, Config.binary.nxAuth, -1, commandLine,
_countof(commandLine));
wcscpy_s(path, _countof(path), commandLine);
PathRemoveFileSpecW(path);
BOOL success =
CreateProcessW(NULL, commandLine, NULL, NULL, 0, 0, NULL, NULL, &startupInfo, procInfo);
if (!success) {
amiDebugLog("ERROR : start %S\n", commandLine);
}
}
#endif
char GAME_EXTENSIONS[3][4] = { char GAME_EXTENSIONS[3][4] = {
{ 'c', 'o', 'm', '\0' }, { 'c', 'o', 'm', '\0' },
{ 'e', 'x', 'e', '\0' }, { 'e', 'x', 'e', '\0' },
@ -19,7 +57,7 @@ char GAME_EXTENSIONS[3][4] = {
DWORD __stdcall appLauncherAppThread(appLauncherAppInfo_t *appInfo) { DWORD __stdcall appLauncherAppThread(appLauncherAppInfo_t *appInfo) {
if (appInfo == NULL || appInfo->m_appLauncher == NULL) { if (appInfo == NULL || appInfo->m_appLauncher == NULL) {
amiDebugLog("param error %p %p", appInfo, appInfo->m_appLauncher); amiDebugLog("param error %p %p", appInfo, appInfo->m_appLauncher);
return 0xffffffff; return (DWORD)-1;
} }
PROCESS_INFORMATION processInformation; PROCESS_INFORMATION processInformation;
@ -34,27 +72,27 @@ DWORD __stdcall appLauncherAppThread(appLauncherAppInfo_t *appInfo) {
struct _finddata_t next_file; struct _finddata_t next_file;
bool skipSpawn = false; bool skipSpawn = false;
bool appUser = false; appLauncherUser_t launchUser = appLauncherUserSystemUser;
switch (appInfo->m_mode) { switch (appInfo->m_mode) {
case 1: case appLauncherLaunchSegabootR:
sprintf_s(commandLine, sizeof commandLine, "%s%s", Config.dir.execute, sprintf_s(commandLine, sizeof commandLine, "%s%s", Config.dir.execute,
Config.binary.segaboot_r); Config.binary.segaboot_r);
break; break;
case 3: case appLauncherLaunchSegabootTR:
sprintf_s(commandLine, sizeof commandLine, "%s%s", Config.dir.execute, sprintf_s(commandLine, sizeof commandLine, "%s%s", Config.dir.execute,
Config.binary.segaboot_tr); Config.binary.segaboot_tr);
break; break;
case 5: case appLauncherLaunchSegabootD:
sprintf_s(commandLine, sizeof commandLine, "%s%s", Config.dir.execute, sprintf_s(commandLine, sizeof commandLine, "%s%s", Config.dir.execute,
Config.binary.segaboot_d); Config.binary.segaboot_d);
break; break;
case 6: case appLauncherLaunchSegaboot:
sprintf_s(commandLine, sizeof commandLine, "%s%s", Config.dir.execute, sprintf_s(commandLine, sizeof commandLine, "%s%s", Config.dir.execute,
Config.binary.segaboot); Config.binary.segaboot);
break; break;
case 2: case appLauncherLaunchGame:
if (appInfo->m_path[0] != '\0') { if (appInfo->m_path[0] != '\0') {
sprintf_s(commandLine, sizeof commandLine, "%s", appInfo->m_path); sprintf_s(commandLine, sizeof commandLine, "%s", appInfo->m_path);
hFile = _findfirst(commandLine, &next_file); hFile = _findfirst(commandLine, &next_file);
@ -80,7 +118,7 @@ DWORD __stdcall appLauncherAppThread(appLauncherAppInfo_t *appInfo) {
if (strcmp(findPath, next_file.name) == 0) { if (strcmp(findPath, next_file.name) == 0) {
sprintf_s(commandLine, 0x40, "%s%s", "x:\\", findPath); sprintf_s(commandLine, 0x40, "%s%s", "x:\\", findPath);
_findclose(hFile); _findclose(hFile);
appUser = true; launchUser = appLauncherUserAppUser;
goto game_found; goto game_found;
} }
} }
@ -93,7 +131,7 @@ DWORD __stdcall appLauncherAppThread(appLauncherAppInfo_t *appInfo) {
game_found: game_found:
break; break;
case 4: case appLauncherLaunchGameTest:
sprintf_s(findPath, 0x40, "%s%s.*", "x:\\", "gametest"); sprintf_s(findPath, 0x40, "%s%s.*", "x:\\", "gametest");
hFile = _findfirst(findPath, &next_file); hFile = _findfirst(findPath, &next_file);
if (hFile == -1) { if (hFile == -1) {
@ -110,7 +148,7 @@ DWORD __stdcall appLauncherAppThread(appLauncherAppInfo_t *appInfo) {
if (strcmp(findPath, next_file.name) == 0) { if (strcmp(findPath, next_file.name) == 0) {
sprintf_s(commandLine, 0x40, "%s%s", "x:\\", findPath); sprintf_s(commandLine, 0x40, "%s%s", "x:\\", findPath);
_findclose(hFile); _findclose(hFile);
appUser = true; launchUser = appLauncherUserAppUser;
goto gametest_found; goto gametest_found;
} }
} }
@ -120,11 +158,18 @@ DWORD __stdcall appLauncherAppThread(appLauncherAppInfo_t *appInfo) {
sprintf_s(commandLine, sizeof commandLine, "%s%s", Config.dir.execute, sprintf_s(commandLine, sizeof commandLine, "%s%s", Config.dir.execute,
Config.binary.segaboot_r); Config.binary.segaboot_r);
_findclose(hFile); _findclose(hFile);
appUser = true; launchUser = appLauncherUserAppUser;
gametest_found: gametest_found:
break; break;
#ifdef MXM_APM2
case appLauncherLaunchAPM2:
sprintf_s(commandLine, sizeof commandLine, "%s%s", "n:\\", "game.bat");
launchUser = appLauncherUserAppUser;
break;
#endif
default: default:
amiDebugLog("Error : Error Process"); amiDebugLog("Error : Error Process");
sprintf_s(commandLine, sizeof commandLine, "%s%s", Config.dir.execute, sprintf_s(commandLine, sizeof commandLine, "%s%s", Config.dir.execute,
@ -133,21 +178,27 @@ DWORD __stdcall appLauncherAppThread(appLauncherAppInfo_t *appInfo) {
ZeroMemory(&startupInfoA, sizeof startupInfoA); ZeroMemory(&startupInfoA, sizeof startupInfoA);
startupInfoA.cb = sizeof startupInfoA; startupInfoA.cb = sizeof startupInfoA;
startupInfoA.dwFlags = 1; startupInfoA.dwFlags = STARTF_USESHOWWINDOW;
startupInfoA.wShowWindow = 1; startupInfoA.wShowWindow = SW_NORMAL;
ZeroMemory(&startupInfoW, sizeof startupInfoW); ZeroMemory(&startupInfoW, sizeof startupInfoW);
startupInfoW.cb = sizeof startupInfoW; startupInfoW.cb = sizeof startupInfoW;
startupInfoW.dwFlags = 1; startupInfoW.dwFlags = STARTF_USESHOWWINDOW;
startupInfoW.wShowWindow = 1; startupInfoW.wShowWindow = SW_NORMAL;
if (!skipSpawn) { if (!skipSpawn) {
BOOL success; BOOL success;
if (appUser) {
if (launchUser == appLauncherUserSystemUser) {
amiDebugLog("Creating process: %s", commandLine);
success = CreateProcessA(NULL, commandLine, NULL, NULL, FALSE,
CREATE_NO_WINDOW | NORMAL_PRIORITY_CLASS, NULL, NULL,
&startupInfoA, &processInformation);
} else { // appLauncherUserAppUser
DWORD dwCreationFlags = 0; DWORD dwCreationFlags = 0;
if (strstr(commandLine, "bat") != NULL) { if (strstr(commandLine, "bat") != NULL) {
dwCreationFlags = CREATE_NO_WINDOW | NORMAL_PRIORITY_CLASS; dwCreationFlags = CREATE_NO_WINDOW | NORMAL_PRIORITY_CLASS;
startupInfoW.wShowWindow = 0; startupInfoW.wShowWindow = SW_HIDE;
} }
ZeroMemory(wCommandLine, sizeof wCommandLine); ZeroMemory(wCommandLine, sizeof wCommandLine);
@ -172,17 +223,14 @@ DWORD __stdcall appLauncherAppThread(appLauncherAppInfo_t *appInfo) {
success = CreateProcessWithLogonW(username, NULL, password, 0, NULL, wCommandLine, success = CreateProcessWithLogonW(username, NULL, password, 0, NULL, wCommandLine,
dwCreationFlags, NULL, workingDirectory, dwCreationFlags, NULL, workingDirectory,
&startupInfoW, &processInformation); &startupInfoW, &processInformation);
} else {
amiDebugLog("Creating process: %s", commandLine);
success = CreateProcessA(NULL, commandLine, NULL, NULL, FALSE,
CREATE_NO_WINDOW | NORMAL_PRIORITY_CLASS, NULL, NULL,
&startupInfoA, &processInformation);
} }
if (!success) { if (!success) {
CloseHandle(processInformation.hProcess); if (processInformation.hProcess != INVALID_HANDLE_VALUE)
CloseHandle(processInformation.hThread); CloseHandle(processInformation.hProcess);
amiDebugLog("ERROR : Close Process %s", commandLine); if (processInformation.hThread != INVALID_HANDLE_VALUE)
CloseHandle(processInformation.hThread);
amiDebugLog("ERROR : Close Process %ghis", commandLine);
} else { } else {
if (WaitForSingleObject(processInformation.hProcess, INFINITE) == WAIT_FAILED) { if (WaitForSingleObject(processInformation.hProcess, INFINITE) == WAIT_FAILED) {
amiDebugLog("WaitForSingleObject Error:%d", GetLastError()); amiDebugLog("WaitForSingleObject Error:%d", GetLastError());
@ -192,11 +240,19 @@ DWORD __stdcall appLauncherAppThread(appLauncherAppInfo_t *appInfo) {
} }
} }
#ifdef MXM_APM2
if (appInfo->m_mode == appLauncherLaunchSegabootR ||
appInfo->m_mode == appLauncherLaunchSegabootD ||
appInfo->m_mode == appLauncherLaunchSegaboot) {
nxAuthStart(&appInfo->m_nxAuthProcInfo);
}
#endif
pcpa_t *stream = &(appInfo->m_appLauncher->m_pcp); pcpa_t *stream = &(appInfo->m_appLauncher->m_pcp);
e_pcpa_t err; e_pcpa_t err;
if ((err = pcpaInitStream(stream)) != e_pcpa_ok) { if ((err = pcpaInitStream(stream)) != e_pcpa_ok) {
amiDebugLog("Error pcpaInitStream. Code %d", err); amiDebugLog("Error pcpaInitStream. Code %d", err);
return 0xffffffff; return (DWORD)-1;
} }
do { do {
err = pcpaOpenClient(stream, "127.0.0.1", 40100, 60000, TIMEOUT_NONE); err = pcpaOpenClient(stream, "127.0.0.1", 40100, 60000, TIMEOUT_NONE);
@ -206,13 +262,13 @@ DWORD __stdcall appLauncherAppThread(appLauncherAppInfo_t *appInfo) {
if (pcpaSetSendPacket(stream, "mxmaster.foreground.active", "0") == NULL) { if (pcpaSetSendPacket(stream, "mxmaster.foreground.active", "0") == NULL) {
pcpaClose(stream); pcpaClose(stream);
amiDebugLog("Error pcpaSetSendPacket return NULL"); amiDebugLog("Error pcpaSetSendPacket return NULL");
return 0xffffffff; return (DWORD)-1;
} }
if ((err = pcpaAccessClient(stream, TIMEOUT_NONE)) != e_pcpa_ok) { if ((err = pcpaAccessClient(stream, TIMEOUT_NONE)) != e_pcpa_ok) {
amiDebugLog("Error : Not Access Master Thread. Code %d", err); amiDebugLog("Error : Not Access Master Thread. Code %d", err);
pcpaClose(stream); pcpaClose(stream);
return 0xffffffff; return (DWORD)-1;
} }
pcpaClose(stream); pcpaClose(stream);
return 0; return 0;
@ -224,14 +280,16 @@ int appLauncherCreateThread(appLauncherAppInfo_t *appInfo, appLauncher_t *appLau
return 3; return 3;
} }
unsigned int mode = appInfo->m_mode; appLauncherLaunch_t mode = appInfo->m_mode;
appLauncher->m_appInfo.m_mode = mode; appLauncher->m_appInfo.m_mode = mode;
strcpy_s(appLauncher->m_appInfo.m_path, sizeof appLauncher->m_appInfo.m_path, appInfo->m_path); strcpy_s(appLauncher->m_appInfo.m_path, sizeof appLauncher->m_appInfo.m_path, appInfo->m_path);
if (mode == 1 || mode == 3 || mode == 5 || mode == 6) appLauncherDefaultRegSet(); if (mode == appLauncherLaunchSegabootR || mode == appLauncherLaunchSegabootTR ||
mode == appLauncherLaunchSegabootD || mode == appLauncherLaunchSegaboot)
appLauncherDefaultRegSet();
HANDLE hThread = CreateThread(NULL, 0, &appLauncherAppThread, &appLauncher->m_appInfo, 0, HANDLE hThread = CreateThread(NULL, 0, &appLauncherAppThread, &appLauncher->m_appInfo, 0,
&appLauncher->m_threadAddr); &appLauncher->m_threadAddr);
appLauncher->m_hThread = hThread; appLauncher->m_hThread = hThread;
if (hThread == 0) { if (hThread == 0) {

View File

@ -1,13 +1,36 @@
#include <Windows.h>
#include <process.h> #include <process.h>
#include <stdbool.h> #include <stdbool.h>
#include "lib/libpcp/libpcp.h" #include "lib/libpcp/libpcp.h"
typedef enum appLauncherUser_ {
appLauncherUserSystemUser = 0,
appLauncherUserAppUser,
} appLauncherUser_t;
// TODO: Rename the segaboots
typedef enum appLauncherLaunch_ {
appLauncherLaunchSegabootR = 1,
appLauncherLaunchGame,
appLauncherLaunchSegabootTR,
appLauncherLaunchGameTest,
appLauncherLaunchSegabootD,
appLauncherLaunchSegaboot,
#ifdef MXM_APM2
appLauncherLaunchAPM2 = 10,
#endif
} appLauncherLaunch_t;
struct appLauncher_; struct appLauncher_;
typedef struct { typedef struct {
struct appLauncher_* m_appLauncher; struct appLauncher_* m_appLauncher;
unsigned int m_mode; appLauncherLaunch_t m_mode;
char m_path[64]; char m_path[64];
#ifdef MXM_APM2
// mxmaster seems to be doing m_appLauncher[1] which is weird and so we're not gonna do that
PROCESS_INFORMATION m_nxAuthProcInfo;
#endif
} appLauncherAppInfo_t; } appLauncherAppInfo_t;
typedef struct appLauncher_ { typedef struct appLauncher_ {
@ -20,4 +43,7 @@ typedef struct appLauncher_ {
wchar_t m_password[64]; wchar_t m_password[64];
} appLauncher_t; } appLauncher_t;
#ifdef MXM_APM2
void nxAuthStart(LPPROCESS_INFORMATION procInfo);
#endif
int appLauncherCreateThread(appLauncherAppInfo_t* appInfo, appLauncher_t* appLauncher); int appLauncherCreateThread(appLauncherAppInfo_t* appInfo, appLauncher_t* appLauncher);

View File

@ -66,9 +66,12 @@ void mxmPcpNextFgprocess(pcpa_t* stream, MX_MASTER* mxMaster) {
} }
if (lCommand >= 0 && lCommand <= 5) { if (lCommand >= 0 && lCommand <= 5) {
#ifdef MXM_APM2
lCommand = apmsTranslateNext(lCommand);
#endif
mxMaster->m_next = lCommand; mxMaster->m_next = lCommand;
if (lCommand == 2) { if (lCommand == appLauncherLaunchGame) {
if (path == NULL) if (path == NULL)
mxMaster->m_nextPath[0] = '\0'; mxMaster->m_nextPath[0] = '\0';
else { else {
@ -89,7 +92,7 @@ void mxmPcpNextFgprocess(pcpa_t* stream, MX_MASTER* mxMaster) {
sprintf_s(next, sizeof next, "%d", mxMaster->m_next); sprintf_s(next, sizeof next, "%d", mxMaster->m_next);
pcpaSetSendPacket(stream, MXM_FG_NEXT, next); pcpaSetSendPacket(stream, MXM_FG_NEXT, next);
if (lCommand != 1) return; if (lCommand != appLauncherLaunchSegabootR) return;
if (errormsg != NULL) { if (errormsg != NULL) {
if (!mxMaster->m_develop) { if (!mxMaster->m_develop) {
@ -222,22 +225,29 @@ void mxmPcpGetStartCount(pcpa_t* stream, MX_MASTER* mxMaster) {
} }
long lWhich = strtol(command, NULL, 10); long lWhich = strtol(command, NULL, 10);
#ifdef MXM_APM2
lWhich = apmsTranslateNext(lWhich);
#endif
int count = 0; int count = 0;
bool valid = false; bool valid = false;
switch (lWhich) { switch (lWhich) {
case 1: case appLauncherLaunchSegabootR:
count = mxMaster->m_countSystemBoot; count = mxMaster->m_countSystemBoot;
valid = true; valid = true;
break; break;
case 2: case appLauncherLaunchGame:
#ifdef MXM_APM2
case appLauncherLaunchAPM2:
#endif
count = mxMaster->m_countGameBoot; count = mxMaster->m_countGameBoot;
valid = true; valid = true;
break; break;
case 3: case appLauncherLaunchSegabootTR:
count = mxMaster->m_countSystemTest; count = mxMaster->m_countSystemTest;
valid = true; valid = true;
break; break;
case 4: case appLauncherLaunchGameTest:
count = mxMaster->m_countGameTest; count = mxMaster->m_countGameTest;
valid = true; valid = true;
break; break;
@ -273,23 +283,29 @@ void mxmPcpSetStartCount(pcpa_t* stream, MX_MASTER* mxMaster) {
} }
long lWhich = strtol(command, NULL, 10); long lWhich = strtol(command, NULL, 10);
#ifdef MXM_APM2
lWhich = apmsTranslateNext(lWhich);
#endif
long lCount = strtol(sCount, NULL, 10); long lCount = strtol(sCount, NULL, 10);
bool valid = false; bool valid = false;
switch (lWhich) { switch (lWhich) {
case 1: case appLauncherLaunchSegabootR:
mxMaster->m_countSystemBoot = lCount; mxMaster->m_countSystemBoot = lCount;
valid = true; valid = true;
break; break;
case 2: case appLauncherLaunchGame:
#ifdef MXM_APM2
case appLauncherLaunchAPM2:
#endif
mxMaster->m_countGameBoot = lCount; mxMaster->m_countGameBoot = lCount;
valid = true; valid = true;
break; break;
case 3: case appLauncherLaunchSegabootTR:
mxMaster->m_countSystemTest = lCount; mxMaster->m_countSystemTest = lCount;
valid = true; valid = true;
break; break;
case 4: case appLauncherLaunchGameTest:
mxMaster->m_countGameTest = lCount; mxMaster->m_countGameTest = lCount;
valid = true; valid = true;
break; break;

View File

@ -11,19 +11,26 @@
SECTION(dir, "Base directories") SECTION(dir, "Base directories")
CFG_str(dir, execute, "c:\\System\\Execute\\", "The system bootstrap directory") CFG_str(dir, execute, "c:\\System\\Execute\\", "The system bootstrap directory")
CFG_str(dir, system, "s:\\", "The system binary directory") CFG_str(dir, system, "s:\\", "The system binary directory")
#ifdef MXM_APM2
CFG_str(dir, execute_firm, "c:\\Syetem\\Execute\\firm\\", "")
CFG_str(dir, firm, "s:\\firm\\", "")
#endif
CFG_str(dir, game, "x:\\", "The game working directory") CFG_str(dir, game, "x:\\", "The game working directory")
ENDSECTION(dir) ENDSECTION(dir)
SECTION(binary, "Binary names (command line arguments can be included)") SECTION(binary, "Binaries that will be executed during startup")
COMMENT("The following values are relative to [dir.system]") CFG_str(binary, mxkeychip, "s:\\mxkeychip.exe", "")
CFG_str(binary, mxkeychip, "mxkeychip.exe", "") CFG_str(binary, mxnetwork, "s:\\mxnetwork.exe -p 40104", "")
CFG_str(binary, mxnetwork, "mxnetwork.exe -p 40104", "") CFG_str(binary, mxstorage, "s:\\mxstorage.exe", "")
CFG_str(binary, mxstorage, "mxstorage.exe", "") CFG_str(binary, mxjvs, "s:\\mxjvs.exe", "")
CFG_str(binary, mxjvs, "mxjvs.exe", "") #ifdef MXM_APM2
CFG_str(binary, mxinstaller, "mxinstaller.exe -cmdport 40102 -binport 40103", "") CFG_str(binary, nxMount, "s:\\nxMount.exe", "")
CFG_str(binary, mxgcatcher, "mxgcatcher.exe", "") CFG_str(binary, nxAuth, "c:\\System\\Execute\\nxAuth.exe", "")
CFG_str(binary, mxgfetcher, "mxgfetcher.exe", "") #endif
CFG_str(binary, mxgdeliver, "mxgdeliver.exe", "") CFG_str(binary, mxinstaller, "s:\\mxinstaller.exe -cmdport 40102 -binport 40103", "")
CFG_str(binary, mxgcatcher, "s:\\mxgcatcher.exe", "")
CFG_str(binary, mxgfetcher, "s:\\mxgfetcher.exe", "")
CFG_str(binary, mxgdeliver, "s:\\mxgdeliver.exe", "")
COMMENT("--------------------------------------------------") COMMENT("--------------------------------------------------")
COMMENT("The following values are relative to [dir.execute]") COMMENT("The following values are relative to [dir.execute]")
CFG_str(binary, segaboot, "mxsegaboot.exe", "") CFG_str(binary, segaboot, "mxsegaboot.exe", "")

View File

@ -70,6 +70,13 @@ bool mxMasterInit(MX_MASTER* mxMaster) {
mxmCopySystemFile("d3dref9.dll"); mxmCopySystemFile("d3dref9.dll");
mxmCopySystemFile("mxsegaboot_2052.dll"); mxmCopySystemFile("mxsegaboot_2052.dll");
#ifdef MXM_APM2
mxmCopySystemFile("nxAuth.exe");
mxmCopySystemFile("SBYG_Table.dat");
mxmCopySystemFirmwareFile("315-6691A.bin");
mxmCopySystemFirmwareFile("TN32MSEC003S_V12.hex");
#endif
return mxMasterInitPcp(mxMaster); return mxMasterInitPcp(mxMaster);
} }
@ -180,19 +187,28 @@ bool mxMasterLoadKeychipInfo(MX_MASTER* mxMaster) {
} }
void mxMasterSysProcessesStart(MX_MASTER* mxMaster) { void mxMasterSysProcessesStart(MX_MASTER* mxMaster) {
char startup[4][128]; char startup[
#ifdef MXM_APM2
5
#else
4
#endif
][128];
strcpy_s(startup[0], sizeof startup[0], Config.binary.mxkeychip); strcpy_s(startup[0], sizeof startup[0], Config.binary.mxkeychip);
strcpy_s(startup[1], sizeof startup[1], Config.binary.mxnetwork); strcpy_s(startup[1], sizeof startup[1], Config.binary.mxnetwork);
strcpy_s(startup[2], sizeof startup[2], Config.binary.mxstorage); strcpy_s(startup[2], sizeof startup[2], Config.binary.mxstorage);
strcpy_s(startup[3], sizeof startup[3], Config.binary.mxjvs); strcpy_s(startup[3], sizeof startup[3], Config.binary.mxjvs);
#ifdef MXM_APM2
strcpy_s(startup[4], sizeof startup[4], Config.binary.nxMount);
#endif
STARTUPINFOA startupInfo; STARTUPINFOA startupInfo;
PROCESS_INFORMATION processInformation; PROCESS_INFORMATION processInformation;
DWORD dwCreationFlags; DWORD dwCreationFlags;
BOOL ret; BOOL ret;
for (int i = 0; i < 4; i++) { for (int i = 0; i < _countof(startup); i++) {
dwCreationFlags = CREATE_NO_WINDOW | NORMAL_PRIORITY_CLASS; dwCreationFlags = CREATE_NO_WINDOW | NORMAL_PRIORITY_CLASS;
ZeroMemory(&startupInfo, sizeof startupInfo); ZeroMemory(&startupInfo, sizeof startupInfo);
startupInfo.cb = sizeof startupInfo; startupInfo.cb = sizeof startupInfo;
@ -291,28 +307,30 @@ void mxMasterFirstFgProcessesStart(MX_MASTER* mxMaster) {
appLauncherAppInfo_t appInfo; appLauncherAppInfo_t appInfo;
appInfo.m_mode = mxMaster->m_current; appInfo.m_mode = mxMaster->m_current;
if (appInfo.m_mode == 1) { if (appInfo.m_mode == appLauncherLaunchSegabootR) {
appInfo.m_mode = 6; appInfo.m_mode = appLauncherLaunchSegaboot;
} else if (appInfo.m_mode != 2 && appInfo.m_mode != 3 && appInfo.m_mode != 4 && } else if (appInfo.m_mode != appLauncherLaunchGame &&
appInfo.m_mode != 5) { appInfo.m_mode != appLauncherLaunchSegabootTR &&
appInfo.m_mode != appLauncherLaunchGameTest &&
appInfo.m_mode != appLauncherLaunchSegabootD) {
amiDebugLog("Error : Not Process Mode"); amiDebugLog("Error : Not Process Mode");
mxMaster->m_current = 1; mxMaster->m_current = 1;
appInfo.m_mode = 6; appInfo.m_mode = appLauncherLaunchSegaboot;
} }
switch (appInfo.m_mode) { switch (appInfo.m_mode) {
case 1: case appLauncherLaunchSegabootR:
case 5: case appLauncherLaunchSegabootD:
case 6: case appLauncherLaunchSegaboot:
mxMaster->m_countSystemBoot = mxMaster->m_countSystemBoot + 1; mxMaster->m_countSystemBoot = mxMaster->m_countSystemBoot + 1;
break; break;
case 2: case appLauncherLaunchGame:
mxMaster->m_countGameBoot = mxMaster->m_countGameBoot + 1; mxMaster->m_countGameBoot = mxMaster->m_countGameBoot + 1;
break; break;
case 3: case appLauncherLaunchSegabootTR:
mxMaster->m_countSystemTest = mxMaster->m_countSystemTest + 1; mxMaster->m_countSystemTest = mxMaster->m_countSystemTest + 1;
break; break;
case 4: case appLauncherLaunchGameTest:
mxMaster->m_countGameTest = mxMaster->m_countGameTest + 1; mxMaster->m_countGameTest = mxMaster->m_countGameTest + 1;
break; break;
} }
@ -391,23 +409,23 @@ void mxMasterMainLoop(MX_MASTER* mxMaster) {
if (!mxMaster->m_develop || mxMaster->m_changeIsSpawn) { if (!mxMaster->m_develop || mxMaster->m_changeIsSpawn) {
appInfo[0].m_mode = mxMaster->m_current; appInfo[0].m_mode = mxMaster->m_current;
mxMaster->m_changeIsSpawn = 0; mxMaster->m_changeIsSpawn = 0;
if (appInfo[0].m_mode == 2) { if (appInfo[0].m_mode == appLauncherLaunchGame) {
sprintf_s(appInfo[0].m_path, sizeof appInfo[0].m_path, "%s", sprintf_s(appInfo[0].m_path, sizeof appInfo[0].m_path, "%s",
mxMaster->m_nextPath); mxMaster->m_nextPath);
} }
switch (appInfo[0].m_mode) { switch (appInfo[0].m_mode) {
case 1: case appLauncherLaunchSegabootR:
case 5: case appLauncherLaunchSegabootD:
case 6: case appLauncherLaunchSegaboot:
mxMaster->m_countSystemBoot++; mxMaster->m_countSystemBoot++;
break; break;
case 2: case appLauncherLaunchGame:
mxMaster->m_countGameBoot++; mxMaster->m_countGameBoot++;
break; break;
case 3: case appLauncherLaunchSegabootTR:
mxMaster->m_countSystemTest++; mxMaster->m_countSystemTest++;
break; break;
case 4: case appLauncherLaunchGameTest:
mxMaster->m_countGameTest++; mxMaster->m_countGameTest++;
} }
appLauncherCreateThread(appInfo, mxMaster->m_appLauncher); appLauncherCreateThread(appInfo, mxMaster->m_appLauncher);

View File

@ -4,6 +4,27 @@
#define TICK_MS 16 #define TICK_MS 16
#ifdef MXM_APM2
appLauncherLaunch_t apmsTranslateNext(appLauncherLaunch_t which) {
switch (which) {
case appLauncherLaunchSegabootR:
return appLauncherLaunchSegabootR;
case appLauncherLaunchGame:
return appLauncherLaunchGame;
case appLauncherLaunchSegabootTR:
return appLauncherLaunchSegabootTR;
case appLauncherLaunchGameTest:
return appLauncherLaunchGameTest;
// TODO: Inversigate this. `segaboot -d` translates to `n:\\game.bat` for APM?
case appLauncherLaunchSegabootD:
return appLauncherLaunchAPM2;
default:
return 0;
}
}
#endif
void mxmBeforeBinaryCallback(pcpa_t *stream, MX_MASTER *mxMaster) { void mxmBeforeBinaryCallback(pcpa_t *stream, MX_MASTER *mxMaster) {
pcpaSetSendBinaryBuffer(stream, mxMaster->m_binaryMessage, mxMaster->m_binaryMessageLen); pcpaSetSendBinaryBuffer(stream, mxMaster->m_binaryMessage, mxMaster->m_binaryMessageLen);
} }
@ -26,6 +47,20 @@ void mxmCopySystemFile(char *filename) {
if (!PathFileExistsA(dest)) CopyFileA(src, dest, 0); if (!PathFileExistsA(dest)) CopyFileA(src, dest, 0);
} }
void mxmCopySystemFirmwareFile(char *filename) {
char dest[256];
char src[256];
sprintf_s(src, sizeof src, "%s%s", Config.dir.firm, filename);
sprintf_s(dest, sizeof dest, "%s%s", Config.dir.execute_firm, filename);
if (!PathFileExistsA(src)) {
amiDebugLog("Error copy %s not exist", src);
return;
}
if (!PathFileExistsA(dest)) CopyFileA(src, dest, 0);
}
int mxmBackupEventlog(int destination) { int mxmBackupEventlog(int destination) {
if (!MxmEventLog.m_logDriveFound) return 0; if (!MxmEventLog.m_logDriveFound) return 0;
@ -42,7 +77,6 @@ int mxmBackupEventlog(int destination) {
DWORD numberOfRecords = 0; DWORD numberOfRecords = 0;
if (!GetNumberOfEventLogRecords(hEventLog, &numberOfRecords)) { if (!GetNumberOfEventLogRecords(hEventLog, &numberOfRecords)) {
printf("%d\n", hEventLog);
amiDebugLog("Error GetNumberOf-EventLogRecords(%d). Code %d", destination, GetLastError()); amiDebugLog("Error GetNumberOf-EventLogRecords(%d). Code %d", destination, GetLastError());
CloseEventLog(hEventLog); CloseEventLog(hEventLog);
return -3; return -3;

View File

@ -1,5 +1,7 @@
#include <stdio.h> #include <stdio.h>
#define MXM_APM2
#include "appLauncher.h" #include "appLauncher.h"
#include "callbacks/callbacks.h" #include "callbacks/callbacks.h"
#include "config.h" #include "config.h"
@ -7,20 +9,6 @@
#include "lib/libpcp/libpcp.h" #include "lib/libpcp/libpcp.h"
#include "mxmEventLog.h" #include "mxmEventLog.h"
typedef enum {
mxMasterStartType_0 = 0,
mxMasterStartType_1 = 1, // Stores system message
mxMasterStartType_2 = 2, // Stores "path" into m_nextPath
mxMasterStartType_3 = 3,
mxMasterStartType_4 = 4,
mxMasterStartType_5 = 5,
// Segaboot: 1, 5, 6
// Gameboot: 2
// Systemtest: 3
} mxMasterStartType_t;
typedef struct MX_MASTER_ { typedef struct MX_MASTER_ {
ushort m_controlPort; ushort m_controlPort;
ushort m_dataPort; ushort m_dataPort;
@ -64,3 +52,7 @@ void mxmBeforeBinaryCallback(pcpa_t* stream, MX_MASTER* mxMaster);
void mxmAfterBinaryCallback(pcpa_t* stream, MX_MASTER* mxMaster); void mxmAfterBinaryCallback(pcpa_t* stream, MX_MASTER* mxMaster);
void mxmCopySystemFile(char* filename); void mxmCopySystemFile(char* filename);
int mxmBackupEventlog(int destination); int mxmBackupEventlog(int destination);
#ifdef MXM_APM2
void mxmCopySystemFirmwareFile(char* filename);
appLauncherLaunch_t apmsTranslateNext(appLauncherLaunch_t which);
#endif

View File

@ -6,55 +6,50 @@ project('inih',
#### options #### #### options ####
arg_static = [] arg_static = []
distro_install = get_option('distro_install')
extra_args = [] extra_args = []
if distro_install if not get_option('multi-line_entries')
pkg = import('pkgconfig') arg_static += ['-DINI_ALLOW_MULTILINE=0']
else endif
if not get_option('multi-line_entries') if not get_option('utf-8_bom')
arg_static += ['-DINI_ALLOW_MULTILINE=0'] arg_static += ['-DINI_ALLOW_BOM=0']
endif endif
if not get_option('utf-8_bom') if not get_option('inline_comments')
arg_static += ['-DINI_ALLOW_BOM=0'] arg_static += ['-DINI_ALLOW_INLINE_COMMENTS=0']
endif endif
if not get_option('inline_comments') inline_comment_prefix = get_option('inline_comment_prefix')
arg_static += ['-DINI_ALLOW_INLINE_COMMENTS=0'] if inline_comment_prefix != ';'
endif arg_static += ['-DINI_INLINE_COMMENT_PREFIXES="' + inline_comment_prefix + '"']
inline_comment_prefix = get_option('inline_comment_prefix') endif
if inline_comment_prefix != ';' sol_comment_prefix = get_option('start-of-line_comment_prefix')
arg_static += ['-DINI_INLINE_COMMENT_PREFIXES="' + inline_comment_prefix + '"'] if sol_comment_prefix != ';#'
endif arg_static += ['-DINI_START_COMMENT_PREFIXES="' + start-of-line_comment_prefix + '"']
sol_comment_prefix = get_option('start-of-line_comment_prefix') endif
if sol_comment_prefix != ';#' if get_option('allow_no_value')
arg_static += ['-DINI_START_COMMENT_PREFIXES="' + start-of-line_comment_prefix + '"'] arg_static += ['-DINI_ALLOW_NO_VALUE=1']
endif endif
if get_option('allow_no_value') if get_option('stop_on_first_error')
arg_static += ['-DINI_ALLOW_NO_VALUE=1'] arg_static += ['-DINI_STOP_ON_FIRST_ERROR=1']
endif endif
if get_option('stop_on_first_error') if get_option('report_line_numbers')
arg_static += ['-DINI_STOP_ON_FIRST_ERROR=1'] arg_static += ['-DINI_HANDLER_LINENO=1']
endif endif
if get_option('report_line_numbers') if get_option('call_handler_on_new_section')
arg_static += ['-DINI_HANDLER_LINENO=1'] arg_static += ['-DINI_CALL_HANDLER_ON_NEW_SECTION=1']
endif endif
if get_option('call_handler_on_new_section') if get_option('use_heap')
arg_static += ['-DINI_CALL_HANDLER_ON_NEW_SECTION=1'] arg_static += ['-DINI_USE_STACK=0']
endif endif
if get_option('use_heap') max_line_length = get_option('max_line_length')
arg_static += ['-DINI_USE_STACK=0'] if max_line_length != 200
endif arg_static += ['-DINI_MAX_LINE=' + max_line_length.to_string()]
max_line_length = get_option('max_line_length') endif
if max_line_length != 200 initial_malloc_size = get_option('initial_malloc_size')
arg_static += ['-DINI_MAX_LINE=' + max_line_length.to_string()] if initial_malloc_size != 200
endif arg_static += ['-DINI_INITIAL_ALLOC=' + initial_malloc_size.to_string()]
initial_malloc_size = get_option('initial_malloc_size') endif
if initial_malloc_size != 200 if get_option('allow_realloc')
arg_static += ['-DINI_INITIAL_ALLOC=' + initial_malloc_size.to_string()] arg_static += ['-DINI_ALLOW_REALLOC=1']
endif
if get_option('allow_realloc')
arg_static += ['-DINI_ALLOW_REALLOC=1']
endif
endif endif
if host_machine.system() == 'windows' if host_machine.system() == 'windows'
@ -74,21 +69,10 @@ lib_inih = static_library('inih',
['ini.c'], ['ini.c'],
include_directories : inc_inih, include_directories : inc_inih,
c_args : [arg_static, extra_args], c_args : [arg_static, extra_args],
install : distro_install,
# soversion : '0', # soversion : '0',
gnu_symbol_visibility: 'hidden' gnu_symbol_visibility: 'hidden'
) )
if distro_install
install_headers('ini.h')
pkg.generate(lib_inih,
name : 'inih',
description : 'simple .INI file parser',
extra_cflags : extra_args,
)
endif
inih_dep = declare_dependency( inih_dep = declare_dependency(
link_with : lib_inih, link_with : lib_inih,
compile_args : arg_static + extra_args, compile_args : arg_static + extra_args,