Add Wow64 Check and log some environment information to KrnlDebug.log (And Wine version, if detected
This commit is contained in:
parent
6abb41304a
commit
53dcd92d4d
|
@ -1,112 +1,126 @@
|
|||
// This is an open source non-commercial project. Dear PVS-Studio, please check it.
|
||||
// PVS-Studio Static Code Analyzer for C, C++ and C#: http://www.viva64.com
|
||||
// ******************************************************************
|
||||
// *
|
||||
// * .,-::::: .,:: .::::::::. .,:: .:
|
||||
// * ,;;;'````' `;;;, .,;; ;;;'';;' `;;;, .,;;
|
||||
// * [[[ '[[,,[[' [[[__[[\. '[[,,[['
|
||||
// * $$$ Y$$$P $$""""Y$$ Y$$$P
|
||||
// * `88bo,__,o, oP"``"Yo, _88o,,od8P oP"``"Yo,
|
||||
// * "YUMMMMMP",m" "Mm,""YUMMMP" ,m" "Mm,
|
||||
// *
|
||||
// * Cxbx->Win32->Cxbx->WinMain.cpp
|
||||
// *
|
||||
// * This file is part of the Cxbx project.
|
||||
// *
|
||||
// * Cxbx and Cxbe are free software; you can redistribute them
|
||||
// * and/or modify them under the terms of the GNU General Public
|
||||
// * License as published by the Free Software Foundation; either
|
||||
// * version 2 of the license, or (at your option) any later version.
|
||||
// *
|
||||
// * This program is distributed in the hope that it will be useful,
|
||||
// * but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// * GNU General Public License for more details.
|
||||
// *
|
||||
// * You should have recieved a copy of the GNU General Public License
|
||||
// * along with this program; see the file COPYING.
|
||||
// * If not, write to the Free Software Foundation, Inc.,
|
||||
// * 59 Temple Place - Suite 330, Bostom, MA 02111-1307, USA.
|
||||
// *
|
||||
// * (c) 2002-2006 Aaron Robinson <caustik@caustik.com>
|
||||
// *
|
||||
// * All rights reserved
|
||||
// *
|
||||
// ******************************************************************
|
||||
|
||||
#include "WndMain.h"
|
||||
|
||||
#include "CxbxKrnl/CxbxKrnl.h"
|
||||
#include "CxbxKrnl/Emu.h"
|
||||
#include "CxbxKrnl/EmuShared.h"
|
||||
#include <commctrl.h>
|
||||
|
||||
// Enable Visual Styles
|
||||
#pragma comment(linker,"\"/manifestdependency:type='win32' \
|
||||
name = 'Microsoft.Windows.Common-Controls' version = '6.0.0.0' \
|
||||
processorArchitecture = '*' publicKeyToken = '6595b64144ccf1df' language = '*'\"")
|
||||
|
||||
/*! program entry point */
|
||||
int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow)
|
||||
{
|
||||
/*! verify Cxbx.exe is loaded to base address 0x00010000 */
|
||||
if ((UINT_PTR)GetModuleHandle(nullptr) != CXBX_BASE_ADDR)
|
||||
{
|
||||
/*! CXBX_BASE_ADDR is defined as 0x00010000, which is the base address of
|
||||
the Cxbx.exe host executable.
|
||||
Set in Cxbx Project options, Linker, Advanced, Base Address */
|
||||
MessageBox(NULL, "Cxbx.exe is not loaded to base address 0x00010000 (which is a requirement for Xbox emulation)", "Cxbx-Reloaded", MB_OK);
|
||||
return 1;
|
||||
}
|
||||
|
||||
/* Initialize Cxbx File Paths */
|
||||
CxbxInitFilePaths();
|
||||
|
||||
/*! initialize shared memory */
|
||||
EmuShared::Init();
|
||||
|
||||
if (__argc >= 2 && strcmp(__argv[1], "/load") == 0 && strlen(__argv[2]) > 0) {
|
||||
CxbxKrnlMain(__argc, __argv);
|
||||
return 0;
|
||||
}
|
||||
|
||||
INITCOMMONCONTROLSEX icc;
|
||||
icc.dwSize = sizeof(icc);
|
||||
icc.dwICC = ICC_WIN95_CLASSES;
|
||||
InitCommonControlsEx(&icc);
|
||||
|
||||
WndMain *MainWindow = new WndMain(hInstance);
|
||||
|
||||
/*! wait for window to be created, or failure */
|
||||
while(!MainWindow->isCreated() && MainWindow->ProcessMessages())
|
||||
{
|
||||
Sleep(20);
|
||||
}
|
||||
|
||||
/*! optionally open xbe and start emulation, if command line parameter was specified */
|
||||
if(__argc > 1 && false == MainWindow->HasError())
|
||||
{
|
||||
MainWindow->OpenXbe(__argv[1]);
|
||||
|
||||
MainWindow->StartEmulation(MainWindow->GetHwnd());
|
||||
}
|
||||
|
||||
/*! wait for window to be closed, or failure */
|
||||
while(!MainWindow->HasError() && MainWindow->ProcessMessages())
|
||||
{
|
||||
Sleep(10);
|
||||
}
|
||||
|
||||
/*! if an error occurred, notify user */
|
||||
if(MainWindow->HasError())
|
||||
{
|
||||
MessageBox(NULL, MainWindow->GetError().c_str(), "Cxbx-Reloaded", MB_ICONSTOP | MB_OK);
|
||||
}
|
||||
|
||||
delete MainWindow;
|
||||
|
||||
/*! cleanup shared memory */
|
||||
EmuShared::Cleanup();
|
||||
|
||||
return 0;
|
||||
}
|
||||
// This is an open source non-commercial project. Dear PVS-Studio, please check it.
|
||||
// PVS-Studio Static Code Analyzer for C, C++ and C#: http://www.viva64.com
|
||||
// ******************************************************************
|
||||
// *
|
||||
// * .,-::::: .,:: .::::::::. .,:: .:
|
||||
// * ,;;;'````' `;;;, .,;; ;;;'';;' `;;;, .,;;
|
||||
// * [[[ '[[,,[[' [[[__[[\. '[[,,[['
|
||||
// * $$$ Y$$$P $$""""Y$$ Y$$$P
|
||||
// * `88bo,__,o, oP"``"Yo, _88o,,od8P oP"``"Yo,
|
||||
// * "YUMMMMMP",m" "Mm,""YUMMMP" ,m" "Mm,
|
||||
// *
|
||||
// * Cxbx->Win32->Cxbx->WinMain.cpp
|
||||
// *
|
||||
// * This file is part of the Cxbx project.
|
||||
// *
|
||||
// * Cxbx and Cxbe are free software; you can redistribute them
|
||||
// * and/or modify them under the terms of the GNU General Public
|
||||
// * License as published by the Free Software Foundation; either
|
||||
// * version 2 of the license, or (at your option) any later version.
|
||||
// *
|
||||
// * This program is distributed in the hope that it will be useful,
|
||||
// * but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// * GNU General Public License for more details.
|
||||
// *
|
||||
// * You should have recieved a copy of the GNU General Public License
|
||||
// * along with this program; see the file COPYING.
|
||||
// * If not, write to the Free Software Foundation, Inc.,
|
||||
// * 59 Temple Place - Suite 330, Bostom, MA 02111-1307, USA.
|
||||
// *
|
||||
// * (c) 2002-2006 Aaron Robinson <caustik@caustik.com>
|
||||
// *
|
||||
// * All rights reserved
|
||||
// *
|
||||
// ******************************************************************
|
||||
|
||||
#include "WndMain.h"
|
||||
|
||||
#include "CxbxKrnl/CxbxKrnl.h"
|
||||
#include "CxbxKrnl/Emu.h"
|
||||
#include "CxbxKrnl/EmuShared.h"
|
||||
#include <commctrl.h>
|
||||
|
||||
// Enable Visual Styles
|
||||
#pragma comment(linker,"\"/manifestdependency:type='win32' \
|
||||
name = 'Microsoft.Windows.Common-Controls' version = '6.0.0.0' \
|
||||
processorArchitecture = '*' publicKeyToken = '6595b64144ccf1df' language = '*'\"")
|
||||
|
||||
/*! program entry point */
|
||||
int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow)
|
||||
{
|
||||
// First detect if we are running on WoW64, if not, prevent Cxbx-Reloaded from starting
|
||||
// Cxbx-Relaoded needs access to high memory, only exposed to WoW64.
|
||||
typedef BOOL(WINAPI *LPFN_ISWOW64PROCESS) (HANDLE, PBOOL);
|
||||
BOOL bIsWow64 = FALSE;
|
||||
LPFN_ISWOW64PROCESS fnIsWow64Process = (LPFN_ISWOW64PROCESS)GetProcAddress(GetModuleHandle(TEXT("kernel32")), "IsWow64Process");
|
||||
if (fnIsWow64Process != nullptr) {
|
||||
fnIsWow64Process(GetCurrentProcess(), &bIsWow64);
|
||||
}
|
||||
|
||||
if (bIsWow64 == FALSE) {
|
||||
MessageBox(NULL, "Cxbx-Reloaded can only run under WoW64\nThis means either a 64-bit version of Windows or Wine with a 64-bit prefix", "Cxbx-Reloaded", MB_OK);
|
||||
return 1;
|
||||
}
|
||||
|
||||
/*! verify Cxbx.exe is loaded to base address 0x00010000 */
|
||||
if ((UINT_PTR)GetModuleHandle(nullptr) != CXBX_BASE_ADDR)
|
||||
{
|
||||
/*! CXBX_BASE_ADDR is defined as 0x00010000, which is the base address of
|
||||
the Cxbx.exe host executable.
|
||||
Set in Cxbx Project options, Linker, Advanced, Base Address */
|
||||
MessageBox(NULL, "Cxbx.exe is not loaded to base address 0x00010000 (which is a requirement for Xbox emulation)", "Cxbx-Reloaded", MB_OK);
|
||||
return 1;
|
||||
}
|
||||
|
||||
/* Initialize Cxbx File Paths */
|
||||
CxbxInitFilePaths();
|
||||
|
||||
/*! initialize shared memory */
|
||||
EmuShared::Init();
|
||||
|
||||
if (__argc >= 2 && strcmp(__argv[1], "/load") == 0 && strlen(__argv[2]) > 0) {
|
||||
CxbxKrnlMain(__argc, __argv);
|
||||
return 0;
|
||||
}
|
||||
|
||||
INITCOMMONCONTROLSEX icc;
|
||||
icc.dwSize = sizeof(icc);
|
||||
icc.dwICC = ICC_WIN95_CLASSES;
|
||||
InitCommonControlsEx(&icc);
|
||||
|
||||
WndMain *MainWindow = new WndMain(hInstance);
|
||||
|
||||
/*! wait for window to be created, or failure */
|
||||
while(!MainWindow->isCreated() && MainWindow->ProcessMessages())
|
||||
{
|
||||
Sleep(20);
|
||||
}
|
||||
|
||||
/*! optionally open xbe and start emulation, if command line parameter was specified */
|
||||
if(__argc > 1 && false == MainWindow->HasError())
|
||||
{
|
||||
MainWindow->OpenXbe(__argv[1]);
|
||||
|
||||
MainWindow->StartEmulation(MainWindow->GetHwnd());
|
||||
}
|
||||
|
||||
/*! wait for window to be closed, or failure */
|
||||
while(!MainWindow->HasError() && MainWindow->ProcessMessages())
|
||||
{
|
||||
Sleep(10);
|
||||
}
|
||||
|
||||
/*! if an error occurred, notify user */
|
||||
if(MainWindow->HasError())
|
||||
{
|
||||
MessageBox(NULL, MainWindow->GetError().c_str(), "Cxbx-Reloaded", MB_ICONSTOP | MB_OK);
|
||||
}
|
||||
|
||||
delete MainWindow;
|
||||
|
||||
/*! cleanup shared memory */
|
||||
EmuShared::Cleanup();
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
|
|
@ -303,10 +303,6 @@ void *CxbxRestoreContiguousMemory(char *szFilePath_memory_bin)
|
|||
}
|
||||
}
|
||||
|
||||
// Make sure memory.bin is at least 128 MB in size
|
||||
SetFilePointer(hFile, CHIHIRO_MEMORY_SIZE, nullptr, FILE_BEGIN);
|
||||
SetEndOfFile(hFile);
|
||||
|
||||
HANDLE hFileMapping = CreateFileMapping(
|
||||
hFile,
|
||||
/* lpFileMappingAttributes */nullptr,
|
||||
|
@ -357,22 +353,6 @@ void *CxbxRestoreContiguousMemory(char *szFilePath_memory_bin)
|
|||
else
|
||||
printf("[0x%.4X] INIT: Loaded contiguous memory.bin\n", GetCurrentThreadId());
|
||||
|
||||
// Map memory.bin contents into tiled memory too :
|
||||
void *tiled_memory = (void *)MapViewOfFileEx(
|
||||
hFileMapping,
|
||||
FILE_MAP_READ | FILE_MAP_WRITE | FILE_MAP_EXECUTE,
|
||||
/* dwFileOffsetHigh */0,
|
||||
/* dwFileOffsetLow */0,
|
||||
TILED_MEMORY_CHIHIRO_SIZE,
|
||||
(void *)TILED_MEMORY_BASE);
|
||||
if (tiled_memory != (void *)TILED_MEMORY_BASE)
|
||||
{
|
||||
if (tiled_memory)
|
||||
UnmapViewOfFile(tiled_memory);
|
||||
|
||||
CxbxKrnlCleanup("CxbxRestoreContiguousMemory: Couldn't map contiguous memory.bin into tiled memory at 0xF0000000!");
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
printf("[0x%.4X] INIT: Mapped contiguous memory to Xbox tiled memory at 0x%.8X to 0x%.8X\n",
|
||||
GetCurrentThreadId(), TILED_MEMORY_BASE, TILED_MEMORY_BASE + TILED_MEMORY_CHIHIRO_SIZE - 1);
|
||||
|
@ -400,6 +380,50 @@ void CxbxPopupMessage(const char *message, ...)
|
|||
|
||||
void PrintCurrentConfigurationLog()
|
||||
{
|
||||
// Print environment information
|
||||
{
|
||||
// Get Windows Version
|
||||
DWORD dwVersion = 0;
|
||||
DWORD dwMajorVersion = 0;
|
||||
DWORD dwMinorVersion = 0;
|
||||
DWORD dwBuild = 0;
|
||||
|
||||
// TODO: GetVersion is deprecated but we use it anyway (for now)
|
||||
// The correct solution is to use GetProductInfo but that function
|
||||
// requires more logic to parse the response, and I didn't feel
|
||||
// like building it just yet :P
|
||||
dwVersion = GetVersion();
|
||||
|
||||
dwMajorVersion = (DWORD)(LOBYTE(LOWORD(dwVersion)));
|
||||
dwMinorVersion = (DWORD)(HIBYTE(LOWORD(dwVersion)));
|
||||
|
||||
// Get the build number.
|
||||
if (dwVersion < 0x80000000) {
|
||||
dwBuild = (DWORD)(HIWORD(dwVersion));
|
||||
}
|
||||
|
||||
// Detect Wine
|
||||
bool isWine = false;
|
||||
typedef const char* (CDECL *LPFN_WINEGETVERSION)(void);
|
||||
LPFN_WINEGETVERSION wine_get_version;
|
||||
HMODULE hNtDll = GetModuleHandle("ntdll.dll");
|
||||
|
||||
if (hNtDll != nullptr) {
|
||||
wine_get_version = (LPFN_WINEGETVERSION)GetProcAddress(hNtDll, "wine_get_version");
|
||||
if (wine_get_version) {
|
||||
isWine = true;
|
||||
}
|
||||
}
|
||||
|
||||
printf("------------------------ENVIRONMENT DETAILS-------------------------\n");
|
||||
if (isWine) {
|
||||
printf("Wine %s\n", wine_get_version());
|
||||
printf("Presenting as Windows %d.%d (%d)\n", dwMajorVersion, dwMinorVersion, dwBuild);
|
||||
} else {
|
||||
printf("Windows %d.%d (%d)\n", dwMajorVersion, dwMinorVersion, dwBuild);
|
||||
}
|
||||
}
|
||||
|
||||
// Print current LLE configuration
|
||||
{
|
||||
printf("---------------------------- LLE CONFIG ----------------------------\n");
|
||||
|
|
Loading…
Reference in New Issue