ff8_launcher_v1.31.r9-source.rar

I've created a launcher application called "Final Fantasy VIII Launcher" which
adds support for custom resolutions and a fix for the texture transparency
issues (black boxes) from lack of 8-bit paletted textures support in NVIDIA
GeForce 6xxx+ graphics cards.

The launcher works by injecting a DLL into an FF8.exe process. The DLL hooks the
DirectX COM interface of the running process and is hence able to freely
manipulate any and all DirectDraw/Direct3D calls being made by the Game.

Additionally the launcher fix texture edge corruption when forcing FSAA and
Anisotopic Filtering settings through the NVIDIA Control Panel. Settings as
high as 16xQ FSAA and 16x Anisotopic Filtering are supported without any
visible corruption.

What's new in version 1.31:
- New option "Stretch 4:3 Aspect Ratio" stretches the picture to the full
  screen width and height without maintaining original 4:3 picture aspect ratio.
  OPTION ONLY APPLIES TO NON-4:3 RESOLUTIONS.
- Added 1366x768 custom resolution.
- Fixed UV-map Compensation bug that made it impossible to remove all
  line-artifacts in background textures (very noticeable in wide-screen
  resolutions.)
- Fixed bug where the entire Black Borders Flicker Fix was not included in the
  release build of version 1.3 as intended.

What's new in version 1.3:
- Vista x86 is now supported
- Non 4:3 aspect-ratio resolutions added. The display is padded with black
  borders to retain original 4:3 picture aspect-ratio.
- Texture flickering on black borders fixed
- New option "Expert Mode" enabled advanced control of display properties. See
  OPTIONS in the readme.txt for more details.
master
Tobias Sebring 15 years ago committed by Günther
commit 7145c73cc3
  1. 31
      FF8_Launcher.sln
  2. 22
      FF8_Launcher/FF8_Launcher.exe.manifest
  3. 312
      FF8_Launcher/FF8_Launcher.vcproj
  4. 138
      FF8_Launcher/config.cpp
  5. 77
      FF8_Launcher/config.h
  6. BIN
      FF8_Launcher/resource.aps
  7. 32
      FF8_Launcher/resource.h
  8. 150
      FF8_Launcher/resource.rc
  9. 404
      FF8_Launcher/winmain.cpp
  10. 58
      FF8_Launcher/winmain.h
  11. 161
      _extra/FF7/D3D2_hooks.cpp
  12. 63
      _extra/FF7/D3D2_hooks.h
  13. 217
      _extra/FF7/D3D3_hooks.cpp
  14. 733
      _extra/FF7/D3DDevice3_hooks.cpp
  15. 426
      _extra/FF7/D3DViewport3_hooks.cpp
  16. 163
      _extra/FF7/D3D_hooks.cpp
  17. 481
      _extra/FF7/DDraw4_hooks.cpp
  18. 1073
      _extra/FF7/DDrawSurface4_hooks.cpp
  19. 427
      _extra/FF7/DDraw_hooks.cpp
  20. 343
      _extra/FF7/DInputDevice_hooks.cpp
  21. 143
      _extra/FF7/DInput_hooks.cpp
  22. 220
      _extra/FF7/HOOKS_BASE.cpp
  23. 99
      _extra/FF7/HOOKS_BASE.h
  24. 199
      _extra/FF7/dlmain.cpp
  25. 394
      _extra/FF7/winmain.cpp
  26. 245
      _extra/log.cpp
  27. 138
      _extra/log.h
  28. 217
      dx_hook/D3D3_hooks.cpp
  29. 72
      dx_hook/D3D3_hooks.h
  30. 875
      dx_hook/D3DDevice3_hooks.cpp
  31. 162
      dx_hook/D3DDevice3_hooks.h
  32. 156
      dx_hook/D3DMaterial3_hooks.cpp
  33. 54
      dx_hook/D3DMaterial3_hooks.h
  34. 114
      dx_hook/D3DTexture2_hooks.cpp
  35. 55
      dx_hook/D3DTexture2_hooks.h
  36. 433
      dx_hook/D3DViewport3_hooks.cpp
  37. 99
      dx_hook/D3DViewport3_hooks.h
  38. 156
      dx_hook/D3D_hooks.cpp
  39. 63
      dx_hook/D3D_hooks.h
  40. 649
      dx_hook/DDraw4_hooks.cpp
  41. 125
      dx_hook/DDraw4_hooks.h
  42. 130
      dx_hook/DDrawPalette_hooks.cpp
  43. 56
      dx_hook/DDrawPalette_hooks.h
  44. 867
      dx_hook/DDrawSurface4_hooks.cpp
  45. 172
      dx_hook/DDrawSurface4_hooks.h
  46. 359
      dx_hook/DDraw_hooks.cpp
  47. 104
      dx_hook/DDraw_hooks.h
  48. 343
      dx_hook/DInputDevice_hooks.cpp
  49. 91
      dx_hook/DInputDevice_hooks.h
  50. 142
      dx_hook/DInput_hooks.cpp
  51. 61
      dx_hook/DInput_hooks.h
  52. 97
      dx_hook/FLAGS.cpp
  53. 56
      dx_hook/FLAGS.h
  54. 219
      dx_hook/HOOKS_BASE.cpp
  55. 98
      dx_hook/HOOKS_BASE.h
  56. 171
      dx_hook/apihijack.cpp
  57. 69
      dx_hook/apihijack.h
  58. 44
      dx_hook/dllmain.h
  59. 209
      dx_hook/dlmain.cpp
  60. 459
      dx_hook/dx_hook.vcproj
  61. 50
      dx_hook/log.cpp
  62. 43
      dx_hook/log.h
  63. BIN
      ff8-icon.ico
  64. 674
      gpl-3.0.txt
  65. 15
      readme-source.txt
  66. 216
      readme.txt

@ -0,0 +1,31 @@

Microsoft Visual Studio Solution File, Format Version 10.00
# Visual Studio 2008
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "FF8_Launcher", "FF8_Launcher\FF8_Launcher.vcproj", "{B030D3B8-2816-4CC8-A01B-FE38EFEDE637}"
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "dx_hook", "dx_hook\dx_hook.vcproj", "{8872B20D-A890-4E81-B36B-91A1DDE50847}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug (LOG)|Win32 = Debug (LOG)|Win32
Debug|Win32 = Debug|Win32
Release|Win32 = Release|Win32
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{B030D3B8-2816-4CC8-A01B-FE38EFEDE637}.Debug (LOG)|Win32.ActiveCfg = Debug (LOG)|Win32
{B030D3B8-2816-4CC8-A01B-FE38EFEDE637}.Debug (LOG)|Win32.Build.0 = Debug (LOG)|Win32
{B030D3B8-2816-4CC8-A01B-FE38EFEDE637}.Debug|Win32.ActiveCfg = Debug|Win32
{B030D3B8-2816-4CC8-A01B-FE38EFEDE637}.Debug|Win32.Build.0 = Debug|Win32
{B030D3B8-2816-4CC8-A01B-FE38EFEDE637}.Release|Win32.ActiveCfg = Release|Win32
{B030D3B8-2816-4CC8-A01B-FE38EFEDE637}.Release|Win32.Build.0 = Release|Win32
{8872B20D-A890-4E81-B36B-91A1DDE50847}.Debug (LOG)|Win32.ActiveCfg = Debug (LOG)|Win32
{8872B20D-A890-4E81-B36B-91A1DDE50847}.Debug (LOG)|Win32.Build.0 = Debug (LOG)|Win32
{8872B20D-A890-4E81-B36B-91A1DDE50847}.Debug|Win32.ActiveCfg = Debug|Win32
{8872B20D-A890-4E81-B36B-91A1DDE50847}.Debug|Win32.Build.0 = Debug|Win32
{8872B20D-A890-4E81-B36B-91A1DDE50847}.Release|Win32.ActiveCfg = Release|Win32
{8872B20D-A890-4E81-B36B-91A1DDE50847}.Release|Win32.Build.0 = Release|Win32
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
EndGlobal

@ -0,0 +1,22 @@
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<assembly xmlns="urn:schemas-microsoft-com:asm.v1" manifestVersion="1.0">
<assemblyIdentity
version="1.0.0.0"
processorArchitecture="X86"
name="FF8_launcher"
type="win32"
/>
<description>Final Fantasy VIII Launcher</description>
<dependency>
<dependentAssembly>
<assemblyIdentity
type="win32"
name="Microsoft.Windows.Common-Controls"
version="6.0.0.0"
processorArchitecture="X86"
publicKeyToken="6595b64144ccf1df"
language="*"
/>
</dependentAssembly>
</dependency>
</assembly>

@ -0,0 +1,312 @@
<?xml version="1.0" encoding="Windows-1252"?>
<VisualStudioProject
ProjectType="Visual C++"
Version="9,00"
Name="FF8_Launcher"
ProjectGUID="{B030D3B8-2816-4CC8-A01B-FE38EFEDE637}"
RootNamespace="FF8_Launcher"
Keyword="Win32Proj"
TargetFrameworkVersion="131072"
>
<Platforms>
<Platform
Name="Win32"
/>
</Platforms>
<ToolFiles>
</ToolFiles>
<Configurations>
<Configuration
Name="Debug|Win32"
OutputDirectory="$(SolutionDir)$(ConfigurationName)"
IntermediateDirectory="$(ConfigurationName)"
ConfigurationType="1"
CharacterSet="1"
>
<Tool
Name="VCPreBuildEventTool"
/>
<Tool
Name="VCCustomBuildTool"
/>
<Tool
Name="VCXMLDataGeneratorTool"
/>
<Tool
Name="VCWebServiceProxyGeneratorTool"
/>
<Tool
Name="VCMIDLTool"
/>
<Tool
Name="VCCLCompilerTool"
Optimization="0"
AdditionalIncludeDirectories=""
PreprocessorDefinitions="WIN32;_DEBUG;_WINDOWS"
MinimalRebuild="true"
BasicRuntimeChecks="3"
RuntimeLibrary="3"
UsePrecompiledHeader="0"
WarningLevel="3"
Detect64BitPortabilityProblems="false"
DebugInformationFormat="4"
/>
<Tool
Name="VCManagedResourceCompilerTool"
/>
<Tool
Name="VCResourceCompilerTool"
/>
<Tool
Name="VCPreLinkEventTool"
/>
<Tool
Name="VCLinkerTool"
AdditionalDependencies="ComCtl32.lib"
LinkIncremental="2"
AdditionalManifestDependencies=""
GenerateDebugInformation="true"
SubSystem="2"
RandomizedBaseAddress="1"
DataExecutionPrevention="0"
TargetMachine="1"
/>
<Tool
Name="VCALinkTool"
/>
<Tool
Name="VCManifestTool"
AdditionalManifestFiles="FF8_Launcher.exe.manifest"
/>
<Tool
Name="VCXDCMakeTool"
/>
<Tool
Name="VCBscMakeTool"
/>
<Tool
Name="VCFxCopTool"
/>
<Tool
Name="VCAppVerifierTool"
/>
<Tool
Name="VCPostBuildEventTool"
/>
</Configuration>
<Configuration
Name="Release|Win32"
OutputDirectory="$(SolutionDir)$(ConfigurationName)"
IntermediateDirectory="$(ConfigurationName)"
ConfigurationType="1"
CharacterSet="1"
WholeProgramOptimization="1"
>
<Tool
Name="VCPreBuildEventTool"
/>
<Tool
Name="VCCustomBuildTool"
/>
<Tool
Name="VCXMLDataGeneratorTool"
/>
<Tool
Name="VCWebServiceProxyGeneratorTool"
/>
<Tool
Name="VCMIDLTool"
/>
<Tool
Name="VCCLCompilerTool"
AdditionalIncludeDirectories=""
PreprocessorDefinitions="WIN32;NDEBUG;_WINDOWS"
RuntimeLibrary="2"
UsePrecompiledHeader="0"
WarningLevel="3"
Detect64BitPortabilityProblems="false"
DebugInformationFormat="3"
/>
<Tool
Name="VCManagedResourceCompilerTool"
/>
<Tool
Name="VCResourceCompilerTool"
/>
<Tool
Name="VCPreLinkEventTool"
/>
<Tool
Name="VCLinkerTool"
AdditionalDependencies="ComCtl32.lib"
LinkIncremental="1"
GenerateDebugInformation="true"
SubSystem="2"
OptimizeReferences="2"
EnableCOMDATFolding="2"
RandomizedBaseAddress="1"
DataExecutionPrevention="0"
TargetMachine="1"
/>
<Tool
Name="VCALinkTool"
/>
<Tool
Name="VCManifestTool"
AdditionalManifestFiles="FF8_Launcher.exe.manifest"
/>
<Tool
Name="VCXDCMakeTool"
/>
<Tool
Name="VCBscMakeTool"
/>
<Tool
Name="VCFxCopTool"
/>
<Tool
Name="VCAppVerifierTool"
/>
<Tool
Name="VCPostBuildEventTool"
/>
</Configuration>
<Configuration
Name="Debug (LOG)|Win32"
OutputDirectory="$(SolutionDir)$(ConfigurationName)"
IntermediateDirectory="$(ConfigurationName)"
ConfigurationType="1"
CharacterSet="1"
>
<Tool
Name="VCPreBuildEventTool"
/>
<Tool
Name="VCCustomBuildTool"
/>
<Tool
Name="VCXMLDataGeneratorTool"
/>
<Tool
Name="VCWebServiceProxyGeneratorTool"
/>
<Tool
Name="VCMIDLTool"
/>
<Tool
Name="VCCLCompilerTool"
Optimization="0"
AdditionalIncludeDirectories=""
PreprocessorDefinitions="WIN32;_DEBUG;_WINDOWS"
MinimalRebuild="true"
BasicRuntimeChecks="3"
RuntimeLibrary="3"
UsePrecompiledHeader="0"
WarningLevel="3"
Detect64BitPortabilityProblems="false"
DebugInformationFormat="4"
/>
<Tool
Name="VCManagedResourceCompilerTool"
/>
<Tool
Name="VCResourceCompilerTool"
/>
<Tool
Name="VCPreLinkEventTool"
/>
<Tool
Name="VCLinkerTool"
AdditionalDependencies="ComCtl32.lib"
LinkIncremental="2"
GenerateDebugInformation="true"
SubSystem="2"
RandomizedBaseAddress="1"
DataExecutionPrevention="0"
TargetMachine="1"
/>
<Tool
Name="VCALinkTool"
/>
<Tool
Name="VCManifestTool"
AdditionalManifestFiles="FF8_Launcher.exe.manifest"
/>
<Tool
Name="VCXDCMakeTool"
/>
<Tool
Name="VCBscMakeTool"
/>
<Tool
Name="VCFxCopTool"
/>
<Tool
Name="VCAppVerifierTool"
/>
<Tool
Name="VCPostBuildEventTool"
/>
</Configuration>
</Configurations>
<References>
</References>
<Files>
<Filter
Name="Source Files"
Filter="cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx"
UniqueIdentifier="{4FC737F1-C7A5-4376-A066-2A32D752A2FF}"
>
<File
RelativePath=".\config.cpp"
>
</File>
<File
RelativePath=".\winmain.cpp"
>
</File>
</Filter>
<Filter
Name="Header Files"
Filter="h;hpp;hxx;hm;inl;inc;xsd"
UniqueIdentifier="{93995380-89BD-4b04-88EB-625FBE52EBFB}"
>
<File
RelativePath=".\config.h"
>
</File>
<File
RelativePath=".\resource.h"
>
</File>
<File
RelativePath=".\winmain.h"
>
</File>
</Filter>
<Filter
Name="Resource Files"
Filter="rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav"
UniqueIdentifier="{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}"
>
<File
RelativePath="..\ff8-icon.ico"
>
</File>
<File
RelativePath="C:\Projects\FF8_Launcher\ff8-icon.ico"
>
</File>
<File
RelativePath=".\resource.rc"
>
</File>
</Filter>
<File
RelativePath=".\FF8_Launcher.exe.manifest"
>
</File>
</Files>
<Globals>
</Globals>
</VisualStudioProject>

@ -0,0 +1,138 @@
/*
Final Fantasy VIII Launcher
Copyright 2007, 2008 Tobias Sebring
This file is part of Final Fantasy VII Launcher.
Final Fantasy VII Launcher is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, version 3.
Final Fantasy VII Launcher 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 received a copy of the GNU General Public License
along with Final Fantasy VII Launcher. If not, see <http://www.gnu.org/licenses/>.
*/
#include "config.h"
FF8Config g_config;
FF8Config_DispMode displaymode_options[] = {
{ _T("640x480 (16-bpp FS 4:3) [Original Resolution]"), 640, 480, 16 },
{ _T("800x600 (16-bpp FS 4:3)"), 800, 600, 16 },
{ _T("1024x768 (16-bpp FS 4:3)"), 1024, 768, 16 },
{ _T("1152x864 (16-bpp FS 4:3)"), 1152, 864, 16 },
{ _T("1280x720 (16-bpp WS 16:9)"), 1280, 720, 16 },
{ _T("1280x768 (16-bpp WS 1.67:1)"), 1280, 720, 16 },
{ _T("1280x800 (16-bpp WS 16:10)"), 1280, 800, 16 },
{ _T("1280x960 (16-bpp FS 4:3) [x2]"), 1280, 960, 16 },
{ _T("1280x1024 (16-bpp FS 5:4) [x2]"), 1280, 1024, 16 },
{ _T("1360x768 (16-bpp WS 16:9)"), 1360, 768, 16 },
{ _T("1366x768 (16-bpp WS 16:9)"), 1366, 768, 16 },
{ _T("1440x900 (16-bpp WS 16:10)"), 1440, 900, 16 },
{ _T("1600x900 (16-bpp WS 16:9)"), 1600, 900, 16 },
{ _T("1600x1200 (16-bpp FS 4:3)"), 1600, 1200, 16 },
{ _T("1680x1050 (16-bpp WS 16:10)"), 1680, 1050, 16 },
{ _T("1920x1080 (16-bpp WS 16:9)"), 1920, 1080, 16 },
{ _T("1920x1200 (16-bpp WS 16:10)"), 1920, 1200, 16 },
{ _T("1920x1440 (16-bpp FS 4:3) [x3]"), 1920, 1440, 16 },
{ _T("2048x1536 (16-bpp FS 4:3)"), 2048, 1536, 16 },
{ _T("2560x1600 (16-bpp WS 16:10)"), 2560, 1600, 16 },
{ _T("2560x1920 (16-bpp FS 4:3) [x4]"), 2560, 1920, 16 },
};
UINT displaymode_options_count = sizeof(displaymode_options)/sizeof(displaymode_options[0]);
FF8Config_FSAA fsaa_options[] = {
{ _T("Use global setting"), 0},
{ _T("4x FSAA"), 4},
};
UINT fsaa_options_count = sizeof(fsaa_options)/sizeof(fsaa_options[0]);
int LoadConfig(FF8Config &cfg) {
_TCHAR buffer[200];
tifstream ifs;
ifs.open(FF8_CONFIG_FILE);
if(ifs) {
while(ifs.getline(buffer, 200, _T('\n'))) { // EOF or failure stops the reading
UINT at = 0;
_TCHAR *val = NULL;
while(buffer[at] != _T('\0')) {
if(buffer[at] == _T('=')) {
buffer[at] = _T('\0');
val =&(buffer[at+1]);
break;
}
at++;
}
if(val != NULL) {
//Displaymode
if(_tcscmp(_T("displaymode"), buffer) == 0) {
cfg.displaymode = parseInt(val);
//FSAA
} else if(_tcscmp(_T("fsaa"), buffer) == 0) {
cfg.fsaa = parseInt(val);
//8-bit Paletted Textures
} else if(_tcscmp(_T("8bit_paletted_textures_fix"), buffer) == 0) {
cfg.b8_paletted_textures_fix = parseInt(val);
//Stretch 4:3 Aspect Ratio
} else if(_tcscmp(_T("stretch_4:3_ar"), buffer) == 0) {
cfg.stretch_4_3_ar = parseInt(val);
//expert mode
} else if(_tcscmp(_T("expert_mode"), buffer) == 0) {
cfg.expert_mode = parseInt(val);
//expert mode: uvmapping_comp_backgrounds
} else if(_tcscmp(_T("expert_tex_uvmap_adj_backgrounds"), buffer) == 0) {
cfg.tex_uvmap_adj_backgrounds = parseFloat(val);
//expert mode: uvmapping_comp_interface
} else if(_tcscmp(_T("expert_tex_uvmap_adj_interface"), buffer) == 0) {
cfg.tex_uvmap_adj_interface = parseFloat(val);
}
}
}
ifs.close();
}
return 1;
}
int SaveConfig(FF8Config &cfg) {
tofstream ofs;
ofs.open(FF8_CONFIG_FILE);
if(ofs) {
ofs << "displaymode=" << cfg.displaymode << "\n";
ofs << "fsaa=" << cfg.fsaa << "\n";
ofs << "8bit_paletted_textures_fix=" << cfg.b8_paletted_textures_fix << "\n";
ofs << "stretch_4:3_ar=" << cfg.stretch_4_3_ar << "\n";
ofs << "expert_mode=" << cfg.expert_mode << "\n";
ofs << "expert_tex_uvmap_adj_backgrounds=" << cfg.tex_uvmap_adj_backgrounds << "\n";
ofs << "expert_tex_uvmap_adj_interface=" << cfg.tex_uvmap_adj_interface << "\n";
ofs.close();
}
return 1;
}
int parseInt(_TCHAR *str) {
tstringstream ss;
int i;
ss << str;
ss >> i;
return i;
}
float parseFloat(_TCHAR *str) {
tstringstream ss;
float i;
ss << str;
ss >> i;
return i;
}

@ -0,0 +1,77 @@
/*
Final Fantasy VIII Launcher
Copyright 2007, 2008 Tobias Sebring
This file is part of Final Fantasy VII Launcher.
Final Fantasy VII Launcher is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, version 3.
Final Fantasy VII Launcher 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 received a copy of the GNU General Public License
along with Final Fantasy VII Launcher. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef _CONFIG_H
#define _CONFIG_H
#include <windows.h>
#include <stdio.h>
#include <tchar.h>
#include <string>
#include <fstream>
#include <sstream>
#define FF8_CONFIG_FILE _T("config.cfg")
struct FF8Config {
UINT displaymode;
UINT fsaa;
UINT b8_paletted_textures_fix;
UINT expert_mode;
float tex_uvmap_adj_backgrounds;
float tex_uvmap_adj_interface;
UINT stretch_4_3_ar;
};
//not used (delete?)
#define FF8CONFIG_WS_NORMAL 0
#define FF8CONFIG_WS_16_10 1
#define FF8CONFIG_WS_16_9 2
struct FF8Config_DispMode {
_TCHAR *name;
UINT resX;
UINT resY;
UINT bpp;
UINT wide;
};
struct FF8Config_FSAA {
_TCHAR *name;
UINT mode;
};
extern FF8Config g_config;
extern FF8Config_DispMode displaymode_options[];
extern UINT displaymode_options_count;
extern FF8Config_FSAA fsaa_options[];
extern UINT fsaa_options_count;
typedef std::basic_string<_TCHAR, std::char_traits<_TCHAR> > tstring;
typedef std::basic_ifstream<_TCHAR, std::char_traits<_TCHAR> > tifstream;
typedef std::basic_ofstream<_TCHAR, std::char_traits<_TCHAR> > tofstream;
typedef std::basic_stringstream<_TCHAR, std::char_traits<_TCHAR> > tstringstream;
int LoadConfig(FF8Config &cfg);
int SaveConfig(FF8Config &cfg);
int parseInt(_TCHAR *str);
float parseFloat(_TCHAR *str);
#endif

Binary file not shown.

@ -0,0 +1,32 @@
//{{NO_DEPENDENCIES}}
// Microsoft Visual C++ generated include file.
// Used by resource.rc
//
#define IDI_APP 102
#define IDD_INTERFACE 103
#define IDR_MAINMNU 108
#define IDD_ABOUT 110
#define IDC_DDRESOLUTION 1001
#define IDC_DDDISPLAYMODE 1001
#define IDC_DDFSAA 1002
#define IDC_BTPLAY 1006
#define IDC_8BITPFIX 1008
#define IDOK_ABOUT 1009
#define IDC_STRETCH43AR 1009
#define IDC_EXPERTMODE2 1010
#define IDC_EXPERTMODE 1010
#define IDC_ABOUTTEXT 1011
#define ID_FILE_EXIT 40001
#define ID_HELP_ABOUT 40002
#define ID_FILE_PLAYFF8 40003
// Next default values for new objects
//
#ifdef APSTUDIO_INVOKED
#ifndef APSTUDIO_READONLY_SYMBOLS
#define _APS_NEXT_RESOURCE_VALUE 113
#define _APS_NEXT_COMMAND_VALUE 40004
#define _APS_NEXT_CONTROL_VALUE 1012
#define _APS_NEXT_SYMED_VALUE 101
#endif
#endif

@ -0,0 +1,150 @@
// Microsoft Visual C++ generated resource script.
//
#include "resource.h"
#define APSTUDIO_READONLY_SYMBOLS
/////////////////////////////////////////////////////////////////////////////
//
// Generated from the TEXTINCLUDE 2 resource.
//
#include "afxres.h"
/////////////////////////////////////////////////////////////////////////////
#undef APSTUDIO_READONLY_SYMBOLS
/////////////////////////////////////////////////////////////////////////////
// Swedish resources
#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_SVE)
#ifdef _WIN32
LANGUAGE LANG_SWEDISH, SUBLANG_DEFAULT
#pragma code_page(1252)
#endif //_WIN32
#ifdef APSTUDIO_INVOKED
/////////////////////////////////////////////////////////////////////////////
//
// TEXTINCLUDE
//
1 TEXTINCLUDE
BEGIN
"resource.h\0"
END
2 TEXTINCLUDE
BEGIN
"#include ""afxres.h""\r\n"
"\0"
END
3 TEXTINCLUDE
BEGIN
"\r\n"
"\0"
END
#endif // APSTUDIO_INVOKED
/////////////////////////////////////////////////////////////////////////////
//
// Icon
//
// Icon with lowest ID value placed first to ensure application icon
// remains consistent on all systems.
IDI_APP ICON "C:\\Projects\\FF8_Launcher\\ff8-icon.ico"
/////////////////////////////////////////////////////////////////////////////
//
// Dialog
//
IDD_INTERFACE DIALOGEX 0, 0, 206, 115
STYLE DS_SETFONT | DS_FIXEDSYS | WS_CHILD
FONT 8, "MS Shell Dlg", 400, 0, 0x1
BEGIN
COMBOBOX IDC_DDDISPLAYMODE,7,16,192,30,CBS_DROPDOWNLIST | WS_VSCROLL | WS_TABSTOP
COMBOBOX IDC_DDFSAA,7,42,192,30,CBS_DROPDOWNLIST | WS_DISABLED | WS_VSCROLL | WS_TABSTOP
CONTROL "8-Bit Paletted Textures Fix",IDC_8BITPFIX,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,7,70,101,10
CONTROL "Stretch 4:3 Aspect Ratio",IDC_STRETCH43AR,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,7,81,95,10
PUSHBUTTON "Play FF8",IDC_BTPLAY,149,94,50,14
LTEXT "Display Mode",IDC_STATIC,7,7,43,8,0,WS_EX_TRANSPARENT
LTEXT "FSAA",IDC_STATIC,7,33,18,8,0,WS_EX_TRANSPARENT
LTEXT "Options (Check to Enable)",IDC_STATIC,7,60,100,8,0,WS_EX_TRANSPARENT
CONTROL "Expert mode",IDC_EXPERTMODE,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,7,92,57,10
END
IDD_ABOUT DIALOGEX 0, 0, 430, 241
STYLE DS_SETFONT | DS_MODALFRAME | DS_FIXEDSYS | WS_POPUP | WS_CAPTION
EXSTYLE WS_EX_TOPMOST | WS_EX_WINDOWEDGE
CAPTION "About FF8 Launcher"
FONT 8, "MS Shell Dlg", 400, 0, 0x1
BEGIN
DEFPUSHBUTTON "OK",IDOK,373,220,50,14
EDITTEXT IDC_ABOUTTEXT,7,7,416,209,ES_MULTILINE | ES_READONLY | ES_WANTRETURN | WS_VSCROLL,WS_EX_TRANSPARENT
END
/////////////////////////////////////////////////////////////////////////////
//
// DESIGNINFO
//
#ifdef APSTUDIO_INVOKED
GUIDELINES DESIGNINFO
BEGIN
IDD_INTERFACE, DIALOG
BEGIN
LEFTMARGIN, 7
RIGHTMARGIN, 199
TOPMARGIN, 7
BOTTOMMARGIN, 108
END
IDD_ABOUT, DIALOG
BEGIN
LEFTMARGIN, 7
RIGHTMARGIN, 423
TOPMARGIN, 7
BOTTOMMARGIN, 234
END
END
#endif // APSTUDIO_INVOKED
/////////////////////////////////////////////////////////////////////////////
//
// Menu
//
IDR_MAINMNU MENU
BEGIN
POPUP "&File"
BEGIN
MENUITEM "&Play FF8", ID_FILE_PLAYFF8
MENUITEM SEPARATOR
MENUITEM "&Exit", ID_FILE_EXIT
END
POPUP "&Help"
BEGIN
MENUITEM "&About", ID_HELP_ABOUT
END
END
#endif // Swedish resources
/////////////////////////////////////////////////////////////////////////////
#ifndef APSTUDIO_INVOKED
/////////////////////////////////////////////////////////////////////////////
//
// Generated from the TEXTINCLUDE 3 resource.
//
/////////////////////////////////////////////////////////////////////////////
#endif // not APSTUDIO_INVOKED

@ -0,0 +1,404 @@
/*
Final Fantasy VIII Launcher
Copyright 2007, 2008 Tobias Sebring
This file is part of Final Fantasy VII Launcher.
Final Fantasy VII Launcher is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, version 3.
Final Fantasy VII Launcher 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 received a copy of the GNU General Public License
along with Final Fantasy VII Launcher. If not, see <http://www.gnu.org/licenses/>.
*/
#include "winmain.h"
_TCHAR g_szAppTitle[] = _T("Final Fantasy VIII Launcher v1.31");
_TCHAR g_szClassName[] = _T("FF8Launcher");
HINSTANCE g_hInst = NULL;
HWND g_hwndMain = NULL, g_hwndInterface = NULL;
HMENU g_hMenuMain = NULL;
HBRUSH g_hbr = NULL;
DWORD g_dwWindowStyle = 0;
LPSTR g_lpCmdLine = NULL;
#define _NL _T("\r\n")
int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int iCmdShow) {
g_hInst = hInstance;
g_lpCmdLine = lpCmdLine;
InitCommonControls();
MSG msg;
WNDCLASS wndclass;
wndclass.cbClsExtra = 0;
wndclass.cbWndExtra = 0;
wndclass.hbrBackground = (HBRUSH)GetSysColorBrush(COLOR_WINDOW); //(HBRUSH)(COLOR_APPWORKSPACE+1);
wndclass.hCursor = LoadCursor(NULL, IDC_ARROW);
wndclass.hIcon = (HICON)LoadImage(g_hInst, MAKEINTRESOURCE(IDI_APP), IMAGE_ICON, 0, 0, LR_SHARED); //LoadIcon(NULL, MAKEINTRESOURCE(IDI_APP));
wndclass.hInstance = hInstance;
wndclass.lpfnWndProc = WndProc;
wndclass.lpszClassName = g_szClassName;
wndclass.lpszMenuName = NULL; //MAKEINTRESOURCE(IDR_MAINMNU);
wndclass.style = CS_HREDRAW | CS_VREDRAW;
if(!RegisterClass(&wndclass)) {
MessageBox(NULL, _T("Couldn't register window class!"), g_szAppTitle, MB_ICONERROR);
return 0;
}
g_hMenuMain = LoadMenu(g_hInst, MAKEINTRESOURCE(IDR_MAINMNU));
//g_hMenuInitWnd = GetSubMenu(g_hMenuInit, INIT_MENU_POS);
g_dwWindowStyle = WS_OVERLAPPEDWINDOW & ~(WS_SIZEBOX | WS_MAXIMIZEBOX );
g_hwndMain = CreateWindow(g_szClassName, g_szAppTitle, g_dwWindowStyle, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, NULL, g_hMenuMain, hInstance, NULL);
ShowWindow(g_hwndMain, iCmdShow);
UpdateWindow(g_hwndMain);
while(GetMessage(&msg, NULL, 0, 0)) {
if(IsDialogMessage(g_hwndInterface, &msg)) continue;
TranslateMessage(&msg);
DispatchMessage(&msg);
}
//DestroyMenu(g_hMenuInit);
return (int)msg.wParam;
}
LRESULT CALLBACK WndProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam) {
switch(message) {
case WM_CREATE:
{ //LG
g_hwndMain = hwnd;
DWORD color = GetSysColor(COLOR_WINDOW);
unsigned int c_r = 0, c_g = 0, c_b = 0;
c_r = GetRValue(color);
c_g = GetGValue(color);
c_b = GetBValue(color);
g_hbr = CreateSolidBrush(RGB(c_r-3, c_g-3, c_b-1));
CreateDialog(g_hInst, MAKEINTRESOURCE(IDD_INTERFACE), g_hwndMain, (DLGPROC)InterfaceProc);
RECT rect;
GetWindowRect(g_hwndInterface, &rect);
AdjustWindowRect(&rect, g_dwWindowStyle, GetMenu(g_hwndMain) != NULL ? true : false);
SetWindowPos(g_hwndMain, NULL, 0, 0, rect.right-rect.left, rect.bottom-rect.top, SWP_NOMOVE | SWP_NOZORDER | SWP_NOREPOSITION);
ShowWindow(g_hwndInterface, SW_SHOW);
}
return 0;
case WM_COMMAND:
switch(wParam) {
case ID_HELP_ABOUT:
{ //LG
CreateDialog(g_hInst, MAKEINTRESOURCE(IDD_ABOUT), g_hwndMain, (DLGPROC)AboutProc);
}
return 0;
case ID_FILE_PLAYFF8:
LaunchGame(g_lpCmdLine);
return 0;
case ID_FILE_EXIT:
DestroyWindow(g_hwndMain);
}
break;
case WM_DESTROY:
DeleteObject(g_hbr);
DestroyWindow(g_hwndInterface);
PostQuitMessage(0);
return 0;
}
return DefWindowProc(hwnd, message, wParam, lParam);
}
LRESULT CALLBACK InterfaceProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam) {
switch(message) {
case WM_INITDIALOG:
{ //LG
g_hwndInterface = hwnd;
memset(&g_config, 0, sizeof(g_config));
LoadConfig(g_config);
//Populate controls
HWND hwndDispMode = GetDlgItem(g_hwndInterface, IDC_DDDISPLAYMODE);
for(UINT i = 0; i < displaymode_options_count; i++) {
ComboBox_AddString(hwndDispMode, displaymode_options[i].name);
}
ComboBox_SetCurSel(hwndDispMode, g_config.displaymode);
HWND hwndFSAA = GetDlgItem(g_hwndInterface, IDC_DDFSAA);
for(UINT i = 0; i < fsaa_options_count; i++) {
ComboBox_AddString(hwndFSAA, fsaa_options[i].name);
}
ComboBox_SetCurSel(hwndFSAA, g_config.fsaa);
HWND hwnd8bitPFix = GetDlgItem(g_hwndInterface, IDC_8BITPFIX);
Button_SetCheck(hwnd8bitPFix, (g_config.b8_paletted_textures_fix == 1 ? BST_CHECKED : BST_UNCHECKED));
HWND hwndStretch43Ar = GetDlgItem(g_hwndInterface, IDC_STRETCH43AR);
Button_SetCheck(hwndStretch43Ar, (g_config.stretch_4_3_ar == 1 ? BST_CHECKED : BST_UNCHECKED));
HWND hwndExpertMode = GetDlgItem(g_hwndInterface, IDC_EXPERTMODE);
Button_SetCheck(hwndExpertMode, (g_config.expert_mode == 1 ? BST_CHECKED : BST_UNCHECKED));
return true;
}
case WM_COMMAND:
switch(LOWORD(wParam)) {
case IDC_BTPLAY:
LaunchGame(g_lpCmdLine);
return TRUE;
case IDC_DDDISPLAYMODE:
g_config.displaymode = ComboBox_GetCurSel(GetDlgItem(g_hwndInterface, IDC_DDDISPLAYMODE));
SaveConfig(g_config);
return TRUE;
case IDC_DDFSAA:
g_config.fsaa = ComboBox_GetCurSel(GetDlgItem(g_hwndInterface, IDC_DDFSAA));
SaveConfig(g_config);
return TRUE;
case IDC_8BITPFIX:
if(Button_GetCheck(GetDlgItem(g_hwndInterface, IDC_8BITPFIX)) == BST_CHECKED) g_config.b8_paletted_textures_fix = 1;
else g_config.b8_paletted_textures_fix = 0;
SaveConfig(g_config);
return TRUE;
case IDC_STRETCH43AR:
if(Button_GetCheck(GetDlgItem(g_hwndInterface, IDC_STRETCH43AR)) == BST_CHECKED) g_config.stretch_4_3_ar = 1;
else g_config.stretch_4_3_ar = 0;
SaveConfig(g_config);
return TRUE;
case IDC_EXPERTMODE:
if(Button_GetCheck(GetDlgItem(g_hwndInterface, IDC_EXPERTMODE)) == BST_CHECKED) g_config.expert_mode = 1;
else g_config.expert_mode = 0;
SaveConfig(g_config);
return TRUE;
}
//Sets background of child dialog boxes to transparent
/*case WM_CTLCOLORDLG:
{
HDC hDC = (HDC)wParam;
SetBkMode(hDC, TRANSPARENT);
}
return (INT_PTR)GetStockObject(HOLLOW_BRUSH);
case WM_CTLCOLORBTN:
return (INT_PTR)GetSysColorBrush(COLOR_WINDOW);
case WM_CTLCOLOREDIT:
return (INT_PTR)GetSysColorBrush(COLOR_WINDOW);
case WM_CTLCOLORSTATIC:
{
HDC hDC = (HDC)wParam;
SetBkColor(hDC, GetSysColor(COLOR_WINDOW));
SetBkMode(hDC, TRANSPARENT);
}
return (INT_PTR)g_hbr;
*/
}
return FALSE;
}
LRESULT CALLBACK AboutProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam) {
static _TCHAR *buffer = NULL;
switch(message) {
case WM_INITDIALOG:
{ //LG
HWND hwndAboutText = GetDlgItem(hwnd, IDC_ABOUTTEXT);
tifstream ifs;
ifs.open(_T("readme.txt"), std::ios::binary);
if(ifs.is_open()) {
ifs.seekg(0, std::ios::end);
int length = ifs.tellg();
ifs.seekg(0, std::ios::beg);
ifs.clear();
buffer = new _TCHAR[length+1];
ifs.read(buffer, length);
buffer[ifs.gcount()] = _T('\0');
ifs.close();
Edit_SetText(hwndAboutText, buffer);
} else Edit_SetText(hwndAboutText, _T("readme.txt file is missing..."));
ShowWindow(hwnd, SW_SHOW);
return true;
}
case WM_COMMAND:
switch(LOWORD(wParam)) {
case IDOK:
case IDCANCEL:
if(buffer != NULL) {
delete[] buffer;
buffer = NULL;
}
EndDialog(hwnd, NULL);
return TRUE;
}
//Sets background of child dialog boxes to transparent
case WM_CTLCOLORDLG:
{
//HDC hDC = (HDC)wParam;
//SetBkMode(hDC, TRANSPARENT);
}
return (INT_PTR)GetSysColorBrush(COLOR_WINDOW);
case WM_CTLCOLORBTN:
return (INT_PTR)GetSysColorBrush(COLOR_WINDOW);
case WM_CTLCOLOREDIT:
return (INT_PTR)GetSysColorBrush(COLOR_WINDOW);
case WM_CTLCOLORSTATIC:
{
HDC hDC = (HDC)wParam;
SetBkColor(hDC, GetSysColor(COLOR_WINDOW));
SetBkMode(hDC, TRANSPARENT);
}
return (INT_PTR)g_hbr;
}
return FALSE;
}
void LaunchGame(LPCSTR lpCmdLine) {
//Get FF8.exe path
_TCHAR exe_path[MAX_PATH];
memset(&exe_path, 0, sizeof(_TCHAR)*MAX_PATH);
_TCHAR dir_path[MAX_PATH];
DWORD dir_path_size = MAX_PATH*sizeof(_TCHAR);
memset(&dir_path, 0, dir_path_size);
int lpCmdLineF_size = (int)strlen(lpCmdLine)+1;
_TCHAR *lpCmdLineF = new _TCHAR[lpCmdLineF_size];
#ifdef _UNICODE
MultiByteToWideChar(CP_UTF8, 0, lpCmdLine, -1, lpCmdLineF, lpCmdLineF_size);
#else
_sntprintf_s(lpCmdLineF, lpCmdLineF_size, lpCmdLineF_size, _T("%s"), lpCmdLine);
#endif
FILE *fs;
if(lpCmdLineF_size > 1 && ((fs = _wfsopen(lpCmdLineF, _T("r"), _SH_DENYNO)) != NULL)) {
//From file
fclose(fs);
_sntprintf_s((_TCHAR *)&dir_path, MAX_PATH, MAX_PATH, _T("%s"), lpCmdLineF);
for(int i = MAX_PATH-1; i >= 0; i--) {
if(dir_path[i] == _T('\\')) {
dir_path[i] = _T('\0');
break;
}
}
_sntprintf_s((_TCHAR *)&exe_path, MAX_PATH, MAX_PATH, _T("%s"), lpCmdLineF);
} else {
//From registry
HKEY hFF8_key = NULL;
if(ERROR_SUCCESS == RegOpenKeyEx(HKEY_LOCAL_MACHINE, _T("SOFTWARE\\Square Soft, Inc\\FINAL FANTASY VIII\\1.00"), 0, KEY_QUERY_VALUE, &hFF8_key)) {
if(ERROR_SUCCESS == RegQueryValueEx(hFF8_key, _T("AppPath"), NULL, NULL, (LPBYTE)&dir_path, &dir_path_size)) {
_sntprintf_s((_TCHAR *)&exe_path, MAX_PATH, MAX_PATH, _T("%s\\FF8.exe"), dir_path);
}
}
}
if(_tcslen((_TCHAR *)&exe_path) <= 0) {
MessageBox(NULL, _T("FF8.exe path missing from both command line and registry.\n\nCorrect Usage:\nc:\\games\\ff8_loader.exe c:\\games\\ff8.exe"), _T("Final Fantasy VIII Launcher"), MB_OK | MB_ICONERROR);
} else {
//Inject our library into the target process
//installCOMHook();
STARTUPINFO si;
PROCESS_INFORMATION pi;
memset(&si, 0, sizeof(si));
memset(&pi, 0, sizeof(pi));
si.cb = sizeof(si);
//Launch ff8.exe
if(!CreateProcess(NULL, (LPWSTR)&exe_path, NULL, NULL, FALSE, 0, NULL, NULL /*(LPCWSTR)&dir_path*/, &si, &pi)) {
_TCHAR mbuffer[255];
_sntprintf_s((_TCHAR *)&mbuffer, 150, 150, _T("CreateProcess(FF8.exe) returned an error...\n\nERROR CODE: %d\n"), GetLastError());
MessageBox(NULL, (_TCHAR *)&mbuffer, _T("Final Fantasy VIII Launcher"), MB_OK | MB_ICONERROR);
}
HANDLE hThread;
_TCHAR currdirPath[MAX_PATH], libPath[MAX_PATH];
void* pLibRemote;
DWORD hLibModule;
HMODULE hKernel32 = GetModuleHandle(_T("Kernel32"));
if(GetCurrentDirectory(MAX_PATH, currdirPath)) {
//Error
}
_sntprintf_s(libPath, MAX_PATH, MAX_PATH, _T("%s\\dx_hook.dll"), currdirPath);
pLibRemote = VirtualAllocEx(pi.hProcess, NULL, sizeof(libPath), MEM_COMMIT, PAGE_READWRITE);
WriteProcessMemory(pi.hProcess, pLibRemote, (void*)libPath, sizeof(libPath), NULL );
hThread = ::CreateRemoteThread(pi.hProcess, NULL, 0, (LPTHREAD_START_ROUTINE) GetProcAddress(hKernel32, "LoadLibraryW"), pLibRemote, 0, NULL);
WaitForSingleObject(hThread, INFINITE);
GetExitCodeThread(hThread, &hLibModule);
CloseHandle(hThread);
VirtualFreeEx(pi.hProcess, pLibRemote, sizeof(libPath), MEM_RELEASE);
//Destroy the application window and wait for the FF8.exe process to return before therminating the launcher process
DestroyWindow(g_hwndMain);
WaitForSingleObject(pi.hProcess, INFINITE);
//Unload DLL
hThread = ::CreateRemoteThread(pi.hProcess, NULL, 0, (LPTHREAD_START_ROUTINE) GetProcAddress(hKernel32, "FreeLibraryW"), (LPVOID)hLibModule, 0, NULL);
WaitForSingleObject(hThread, INFINITE);
CloseHandle(hThread);
CloseHandle(pi.hProcess);
CloseHandle(pi.hThread);
//Release COM-hook and cleanup
//removeCOMHook();
}
delete lpCmdLineF;
lpCmdLineF = NULL;
}

@ -0,0 +1,58 @@
/*
Final Fantasy VIII Launcher
Copyright 2007, 2008 Tobias Sebring
This file is part of Final Fantasy VII Launcher.
Final Fantasy VII Launcher is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, version 3.
Final Fantasy VII Launcher 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 received a copy of the GNU General Public License
along with Final Fantasy VII Launcher. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef _WINMAIN_H
#define _WINMAIN_H
#pragma warning(disable:4311) //type cast > size
#pragma warning(disable:4312) //type cast < size
#include <windows.h>
#include <windowsx.h>
#include <commctrl.h>
#include <stdio.h>
#include <share.h>
#include <tchar.h>
#include <string>
#include <fstream>
#include <sstream>
#include "config.h"
#include "resource.h"
typedef std::basic_string<_TCHAR, std::char_traits<_TCHAR> > tstring;
typedef std::basic_ifstream<_TCHAR, std::char_traits<_TCHAR> > tifstream;
typedef std::basic_ofstream<_TCHAR, std::char_traits<_TCHAR> > tofstream;
typedef std::basic_stringstream<_TCHAR, std::char_traits<_TCHAR> > tstringstream;
extern _TCHAR g_szAppTitle[];
extern _TCHAR g_szClassName[];
extern HINSTANCE g_hInst;
extern HWND g_hwndMain, g_hwndInterface;
extern HBRUSH g_hbr;
extern DWORD g_dwWindowStyle;
int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow);
LRESULT CALLBACK WndProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam);
LRESULT CALLBACK InterfaceProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam);
LRESULT CALLBACK AboutProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam);
void LaunchGame(LPCSTR lpCmdLine);
#endif

@ -0,0 +1,161 @@
/*
Final Fantasy VIII Launcher
Copyright 2007, 2008 Tobias Sebring
This file is part of Final Fantasy VII Launcher.
Final Fantasy VII Launcher is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, version 3.
Final Fantasy VII Launcher 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 received a copy of the GNU General Public License
along with Final Fantasy VII Launcher. If not, see <http://www.gnu.org/licenses/>.
*/
#include "d3d2_hooks.h"
#include "d3ddevice2_hooks.h"
#include "d3dviewport2_hooks.h"
//{ NULL, 0, NULL, NULL }, //
#ifdef _DEBUG
SVTBL_HOOK d3d2_hooks[] = {
/*0*/ { "QueryInterface", 0x00, NULL, (PDWORD)D3D2_HOOK_QueryInterface },
/*1*/ { "AddRef", 0x04, NULL, (PDWORD)D3D2_HOOK_AddRef },
/*2*/ { "Release", 0x08, NULL, (PDWORD)D3D2_HOOK_Release },
/*3*/ { "EnumDevices", 0x0C, NULL, (PDWORD)D3D2_HOOK_EnumDevices },
/*4*/ { "CreateLight", 0x10, NULL, (PDWORD)D3D2_HOOK_CreateLight },
/*5*/ { "CreateMaterial", 0x14, NULL, (PDWORD)D3D2_HOOK_CreateMaterial },
/*6*/ { "CreateViewport", 0x18, NULL, (PDWORD)D3D2_HOOK_CreateViewport },
/*7*/ { "FindDevice", 0x1C, NULL, (PDWORD)D3D2_HOOK_FindDevice },
/*8*/ { "CreateDevice", 0x20, NULL, (PDWORD)D3D2_HOOK_CreateDevice },
};
#else
/*0*/ { NULL, 0, NULL, NULL }, //{ "QueryInterface", 0x00, NULL, (PDWORD)D3D2_HOOK_QueryInterface },
/*1*/ { NULL, 0, NULL, NULL }, //{ "AddRef", 0x04, NULL, (PDWORD)D3D2_HOOK_AddRef },
/*2*/ { NULL, 0, NULL, NULL }, //{ "Release", 0x08, NULL, (PDWORD)D3D2_HOOK_Release },
/*3*/ { NULL, 0, NULL, NULL }, //{ "EnumDevices", 0x0C, NULL, (PDWORD)D3D2_HOOK_EnumDevices },
/*4*/ { NULL, 0, NULL, NULL }, //{ "CreateLight", 0x10, NULL, (PDWORD)D3D2_HOOK_CreateLight },
/*5*/ { NULL, 0, NULL, NULL }, //{ "CreateMaterial", 0x14, NULL, (PDWORD)D3D2_HOOK_CreateMaterial },
/*6*/ { NULL, 0, NULL, NULL }, //{ "CreateViewport", 0x18, NULL, (PDWORD)D3D2_HOOK_CreateViewport },
/*7*/ { NULL, 0, NULL, NULL }, //{ "FindDevice", 0x1C, NULL, (PDWORD)D3D2_HOOK_FindDevice },
/*8*/ { NULL, 0, NULL, NULL }, //{ "CreateDevice", 0x20, NULL, (PDWORD)D3D2_HOOK_CreateDevice },
};
#endif
const unsigned int count_d3d2_hooks = 9;
bool ishooked_d3d2_hooks = false;
HRESULT __stdcall D3D2_HOOK_QueryInterface(LPVOID *ppvOut, REFIID riid, LPVOID FAR *ppvObj) {
const unsigned int hpos = 0;
D3D2_QueryInterface_Type ofn = (D3D2_QueryInterface_Type)d3d2_hooks[hpos].oldFunc;
HRESULT ret = ofn(ppvOut, riid, ppvObj);
LogDXError(ret);
Log("IDirect3D2::%s(%#010lx, { %#010lx, %#06x, %#06x, { %#04x, %#04x, %#04x, %#04x, %#04x, %#04x, %#04x, %#04x } }, %#010lx)\n", d3d2_hooks[hpos].name, ppvOut, riid.Data1, riid.Data2, riid.Data3, riid.Data4[0], riid.Data4[1], riid.Data4[2], riid.Data4[3], riid.Data4[4], riid.Data4[5], riid.Data4[6], riid.Data4[7], ppvObj);
return ret;
}
ULONG __stdcall D3D2_HOOK_AddRef(LPVOID *ppvOut) {
const unsigned int hpos = 1;
D3D2_AddRef_Type ofn = (D3D2_AddRef_Type)d3d2_hooks[hpos].oldFunc;
ULONG ret = ofn(ppvOut);
Log("IDirect3D2::%s()\n", d3d2_hooks[hpos].name);
return ret;
}
ULONG __stdcall D3D2_HOOK_Release(LPVOID *ppvOut) {
const unsigned int hpos = 2;
D3D2_Release_Type ofn = (D3D2_Release_Type)d3d2_hooks[hpos].oldFunc;
ULONG ret = ofn(ppvOut);
Log("IDirect3D2::%s(%#010lx)\n", d3d2_hooks[hpos].name, ppvOut);
return ret;
}
HRESULT __stdcall D3D2_HOOK_EnumDevices(LPVOID *ppvOut, LPD3DENUMDEVICESCALLBACK lpEnumDevicesCallback, LPVOID lpUserArg) {
const unsigned int hpos = 3;
D3D2_EnumDevices_Type ofn = (D3D2_EnumDevices_Type)d3d2_hooks[hpos].oldFunc;
HRESULT ret = ofn(ppvOut, lpEnumDevicesCallback, lpUserArg);
Log("IDirect3D2::%s(this=%#010lx)\n", d3d2_hooks[hpos].name, ppvOut);
return ret;
}
HRESULT __stdcall D3D2_HOOK_CreateLight(LPVOID *ppvOut, LPDIRECT3DLIGHT *lplpDirect3DLight, IUnknown *pUnkOuter) {
const unsigned int hpos = 4;
D3D2_CreateLight_Type ofn = (D3D2_CreateLight_Type)d3d2_hooks[hpos].oldFunc;
HRESULT ret = ofn(ppvOut, lplpDirect3DLight, pUnkOuter);
Log("IDirect3D2::%s(this=%#010lx)\n", d3d2_hooks[hpos].name, ppvOut);
return ret;
}
HRESULT __stdcall D3D2_HOOK_CreateMaterial(LPVOID *ppvOut, LPDIRECT3DMATERIAL2 *lplpDirect3DMaterial, IUnknown *pUnkOuter) {
const unsigned int hpos = 5;
D3D2_CreateMaterial_Type ofn = (D3D2_CreateMaterial_Type)d3d2_hooks[hpos].oldFunc;
HRESULT ret = ofn(ppvOut, lplpDirect3DMaterial, pUnkOuter);
Log("IDirect3D2::%s(this=%#010lx)\n", d3d2_hooks[hpos].name, ppvOut);
return ret;
}
HRESULT __stdcall D3D2_HOOK_CreateViewport(LPVOID *ppvOut, LPDIRECT3DVIEWPORT2 *lplpD3DViewport, IUnknown *pUnkOuter) {
const unsigned int hpos = 6;
D3D2_CreateViewport_Type ofn = (D3D2_CreateViewport_Type)d3d2_hooks[hpos].oldFunc;
HRESULT ret = ofn(ppvOut, lplpD3DViewport, pUnkOuter);
Log("IDirect3D2::%s(this=%#010lx)\n", d3d2_hooks[hpos].name, ppvOut);
if(ret == S_OK && ishooked_d3dviewport2_hooks == false) {
HookVTBLCalls((LPVOID *)lplpD3DViewport, d3dviewport2_hooks, count_d3dviewport2_hooks, "IDirect3DViewport2");
ishooked_d3dviewport2_hooks = true;
}
return ret;
}
HRESULT __stdcall D3D2_HOOK_FindDevice(LPVOID *ppvOut, LPD3DFINDDEVICESEARCH lpD3DFDS, LPD3DFINDDEVICERESULT lpD3DFDR) {
const unsigned int hpos = 7;
D3D2_FindDevice_Type ofn = (D3D2_FindDevice_Type)d3d2_hooks[hpos].oldFunc;
HRESULT ret = ofn(ppvOut, lpD3DFDS, lpD3DFDR);
Log("IDirect3D2::%s(this=%#010lx)\n", d3d2_hooks[hpos].name, ppvOut);
return ret;
}
HRESULT __stdcall D3D2_HOOK_CreateDevice(LPVOID *ppvOut, REFCLSID refclsid, LPDIRECTDRAWSURFACE lpDDS, LPDIRECT3DDEVICE2 *lplpD3DDevice) {
const unsigned int hpos = 8;
D3D2_CreateDevice_Type ofn = (D3D2_CreateDevice_Type)d3d2_hooks[hpos].oldFunc;
HRESULT ret = ofn(ppvOut, refclsid, lpDDS, lplpD3DDevice);
Log("IDirect3D2::%s(this=%#010lx)\n", d3d2_hooks[hpos].name, ppvOut);
if(ret == S_OK && refclsid == IID_IDirect3DHALDevice && ishooked_d3ddevice2_hooks == false) {
g_d3ddevice = (LPVOID)*lplpD3DDevice;
HookVTBLCalls((LPVOID *)lplpD3DDevice, d3ddevice2_hooks, count_d3ddevice2_hooks, "IDirect3DDevice2");
ishooked_d3ddevice2_hooks = true;
}
return ret;
}

@ -0,0 +1,63 @@
/*
Final Fantasy VIII Launcher
Copyright 2007, 2008 Tobias Sebring
This file is part of Final Fantasy VII Launcher.
Final Fantasy VII Launcher is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, version 3.
Final Fantasy VII Launcher 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 received a copy of the GNU General Public License
along with Final Fantasy VII Launcher. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef _D3D2_HOOKS
#define _D3D2_HOOKS
#include <ddraw.h>