mirror of
https://github.com/narzoul/DDrawCompat
synced 2024-12-30 08:55:36 +01:00
Moved common macros to compiler options
This commit is contained in:
parent
785663700d
commit
e69b5e312c
@ -1,7 +1,5 @@
|
||||
#pragma once
|
||||
|
||||
#define CINTERFACE
|
||||
|
||||
#include <type_traits>
|
||||
|
||||
#include <d3d.h>
|
||||
|
@ -2,7 +2,6 @@
|
||||
|
||||
#include <vector>
|
||||
|
||||
#include <atlstr.h>
|
||||
#include <Windows.h>
|
||||
|
||||
#include "Common/Log.h"
|
||||
@ -53,8 +52,7 @@ std::ostream& operator<<(std::ostream& os, const WCHAR* wstr)
|
||||
return os << static_cast<const void*>(wstr);
|
||||
}
|
||||
|
||||
CStringA str(wstr);
|
||||
return os << '"' << static_cast<const char*>(str) << '"';
|
||||
return os << std::string(wstr, wstr + wcslen(wstr)).c_str();
|
||||
}
|
||||
|
||||
std::ostream& operator<<(std::ostream& os, const DEVMODEA& dm)
|
||||
@ -143,13 +141,13 @@ std::ostream& operator<<(std::ostream& os, const DDSURFACEDESC2& sd)
|
||||
{
|
||||
return Compat::LogStruct(os)
|
||||
<< Compat::hex(sd.dwFlags)
|
||||
<< sd.dwHeight
|
||||
<< sd.dwWidth
|
||||
<< sd.lPitch
|
||||
<< sd.dwBackBufferCount
|
||||
<< sd.dwHeight
|
||||
<< sd.dwWidth
|
||||
<< sd.lPitch
|
||||
<< sd.dwBackBufferCount
|
||||
<< sd.dwMipMapCount
|
||||
<< sd.dwAlphaBitDepth
|
||||
<< sd.dwReserved
|
||||
<< sd.dwAlphaBitDepth
|
||||
<< sd.dwReserved
|
||||
<< sd.lpSurface
|
||||
<< sd.ddpfPixelFormat
|
||||
<< sd.ddsCaps
|
||||
@ -160,16 +158,16 @@ std::ostream& operator<<(std::ostream& os, const CWPSTRUCT& cwrp)
|
||||
{
|
||||
return Compat::LogStruct(os)
|
||||
<< Compat::hex(cwrp.message)
|
||||
<< cwrp.hwnd
|
||||
<< cwrp.hwnd
|
||||
<< Compat::hex(cwrp.wParam)
|
||||
<< Compat::hex(cwrp.lParam);
|
||||
}
|
||||
|
||||
std::ostream& operator<<(std::ostream& os, const CWPRETSTRUCT& cwrp)
|
||||
{
|
||||
return Compat::LogStruct(os)
|
||||
return Compat::LogStruct(os)
|
||||
<< Compat::hex(cwrp.message)
|
||||
<< cwrp.hwnd
|
||||
<< cwrp.hwnd
|
||||
<< Compat::hex(cwrp.wParam)
|
||||
<< Compat::hex(cwrp.lParam)
|
||||
<< Compat::hex(cwrp.lResult);
|
||||
|
@ -1,7 +1,5 @@
|
||||
#pragma once
|
||||
|
||||
#define CINTERFACE
|
||||
|
||||
#include <ddraw.h>
|
||||
#include <fstream>
|
||||
#include <ostream>
|
||||
@ -186,7 +184,7 @@ namespace Compat
|
||||
class LogNull
|
||||
{
|
||||
public:
|
||||
template <typename T> LogNull& operator<<(const T&) { return *this; }
|
||||
template <typename T> LogNull& operator<<(const T&) { return *this; }
|
||||
};
|
||||
|
||||
typedef LogNull LogDebug;
|
||||
|
@ -1,7 +1,5 @@
|
||||
#pragma once
|
||||
|
||||
#define CINTERFACE
|
||||
|
||||
#include <ddraw.h>
|
||||
#include <typeinfo>
|
||||
|
||||
|
@ -1,7 +1,5 @@
|
||||
#pragma once
|
||||
|
||||
#define CINTERFACE
|
||||
|
||||
#include <d3d.h>
|
||||
#include <d3dumddi.h>
|
||||
|
||||
|
@ -1,7 +1,5 @@
|
||||
#pragma once
|
||||
|
||||
#define CINTERFACE
|
||||
|
||||
#include <d3d.h>
|
||||
#include <d3dumddi.h>
|
||||
#include <d3dnthal.h>
|
||||
|
@ -1,7 +1,5 @@
|
||||
#pragma once
|
||||
|
||||
#define CINTERFACE
|
||||
|
||||
#include <map>
|
||||
#include <set>
|
||||
|
||||
|
@ -1,7 +1,5 @@
|
||||
#pragma once
|
||||
|
||||
#define CINTERFACE
|
||||
|
||||
#include <d3d.h>
|
||||
#include <d3dumddi.h>
|
||||
|
||||
|
@ -1,7 +1,5 @@
|
||||
#pragma once
|
||||
|
||||
#define CINTERFACE
|
||||
|
||||
#include <d3d.h>
|
||||
#include <d3dumddi.h>
|
||||
|
||||
|
@ -1,5 +1,3 @@
|
||||
#define CINTERFACE
|
||||
|
||||
#include <set>
|
||||
|
||||
#include <Windows.h>
|
||||
|
@ -1,5 +1,3 @@
|
||||
#define CINTERFACE
|
||||
|
||||
#include <map>
|
||||
|
||||
#include <d3d.h>
|
||||
|
@ -1,8 +1,5 @@
|
||||
#pragma once
|
||||
|
||||
#define CINTERFACE
|
||||
#define WIN32_LEAN_AND_MEAN
|
||||
|
||||
#include <d3d.h>
|
||||
#include <d3dumddi.h>
|
||||
#include <../km/d3dkmthk.h>
|
||||
|
@ -1,7 +1,5 @@
|
||||
#pragma once
|
||||
|
||||
#define CINTERFACE
|
||||
|
||||
#include <ostream>
|
||||
|
||||
#include <d3d.h>
|
||||
|
@ -1,7 +1,5 @@
|
||||
#pragma once
|
||||
|
||||
#define CINTERFACE
|
||||
|
||||
#include <ostream>
|
||||
|
||||
#include <d3d.h>
|
||||
|
@ -1,7 +1,5 @@
|
||||
#pragma once
|
||||
|
||||
#define CINTERFACE
|
||||
|
||||
#include <ostream>
|
||||
|
||||
#include <d3d.h>
|
||||
|
@ -1,7 +1,5 @@
|
||||
#pragma once
|
||||
|
||||
#define CINTERFACE
|
||||
|
||||
#include <ostream>
|
||||
|
||||
#include <d3d.h>
|
||||
|
@ -1,7 +1,5 @@
|
||||
#pragma once
|
||||
|
||||
#define CINTERFACE
|
||||
|
||||
#include <d3d.h>
|
||||
#include <d3dumddi.h>
|
||||
|
||||
|
@ -1,7 +1,5 @@
|
||||
#pragma once
|
||||
|
||||
#define CINTERFACE
|
||||
|
||||
#include <d3d.h>
|
||||
#include <d3dumddi.h>
|
||||
|
||||
|
@ -1,7 +1,5 @@
|
||||
#pragma once
|
||||
|
||||
#define CINTERFACE
|
||||
|
||||
#include <d3d.h>
|
||||
#include <d3dumddi.h>
|
||||
|
||||
|
@ -1,7 +1,5 @@
|
||||
#pragma once
|
||||
|
||||
#define CINTERFACE
|
||||
|
||||
#include <d3d.h>
|
||||
#include <d3dumddi.h>
|
||||
|
||||
|
@ -1,7 +1,5 @@
|
||||
#pragma once
|
||||
|
||||
#define CINTERFACE
|
||||
|
||||
#include <d3d.h>
|
||||
#include <d3dumddi.h>
|
||||
|
||||
|
@ -1,7 +1,5 @@
|
||||
#pragma once
|
||||
|
||||
#define CINTERFACE
|
||||
|
||||
#include <d3d.h>
|
||||
#include <d3dumddi.h>
|
||||
|
||||
|
@ -1,5 +1,3 @@
|
||||
#define CINTERFACE
|
||||
|
||||
#include <ddraw.h>
|
||||
|
||||
#include "Common/Hook.h"
|
||||
|
@ -1,7 +1,5 @@
|
||||
#pragma once
|
||||
|
||||
#define CINTERFACE
|
||||
|
||||
#include <ddraw.h>
|
||||
|
||||
#include "Common/CompatPtr.h"
|
||||
|
@ -1,5 +1,3 @@
|
||||
#define CINTERFACE
|
||||
|
||||
#include <d3d.h>
|
||||
|
||||
#include "Common/CompatPtr.h"
|
||||
|
@ -1,7 +1,5 @@
|
||||
#pragma once
|
||||
|
||||
#define CINTERFACE
|
||||
|
||||
#include <ddraw.h>
|
||||
|
||||
#include "Common/CompatWeakPtr.h"
|
||||
|
@ -1,7 +1,5 @@
|
||||
#pragma once
|
||||
|
||||
#define CINTERFACE
|
||||
|
||||
#include <ddraw.h>
|
||||
|
||||
#include "Common/CompatRef.h"
|
||||
|
@ -1,6 +1,3 @@
|
||||
#define CINTERFACE
|
||||
#define _NO_DDRAWINT_NO_COM
|
||||
|
||||
#include <ddraw.h>
|
||||
|
||||
#include "Common/CompatPtr.h"
|
||||
@ -170,7 +167,7 @@ namespace DDraw
|
||||
{
|
||||
return CompatPtr<IDirectDrawSurface7>::from(surface.get());
|
||||
}
|
||||
|
||||
|
||||
if (FAILED(surface->GetAttachedSurface(surface, &caps, &surface.getRef())))
|
||||
{
|
||||
return nullptr;
|
||||
|
@ -1,7 +1,5 @@
|
||||
#pragma once
|
||||
|
||||
#define CINTERFACE
|
||||
|
||||
#include <ddraw.h>
|
||||
|
||||
#include "Common/CompatRef.h"
|
||||
|
@ -1,7 +1,5 @@
|
||||
#pragma once
|
||||
|
||||
#define CINTERFACE
|
||||
|
||||
#include <memory>
|
||||
|
||||
#include <ddraw.h>
|
||||
|
@ -1,7 +1,5 @@
|
||||
#pragma once
|
||||
|
||||
#define CINTERFACE
|
||||
|
||||
#include <functional>
|
||||
|
||||
#include <ddraw.h>
|
||||
|
@ -1,7 +1,5 @@
|
||||
#pragma once
|
||||
|
||||
#define CINTERFACE
|
||||
|
||||
#include <ddraw.h>
|
||||
|
||||
namespace DDraw
|
||||
|
@ -90,7 +90,7 @@
|
||||
<PrecompiledHeader>
|
||||
</PrecompiledHeader>
|
||||
<WarningLevel>Level4</WarningLevel>
|
||||
<PreprocessorDefinitions>PSAPI_VERSION=1;WIN32;_DEBUG;_WINDOWS;_USRDLL;DDRAWCOMPAT_EXPORTS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<PreprocessorDefinitions>CINTERFACE;_NO_DDRAWINT_NO_COM;PSAPI_VERSION=1;WIN32;_DEBUG;_WINDOWS;_USRDLL;DDRAWCOMPAT_EXPORTS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<RuntimeLibrary>MultiThreadedDebug</RuntimeLibrary>
|
||||
<MultiProcessorCompilation>true</MultiProcessorCompilation>
|
||||
<MinimalRebuild>false</MinimalRebuild>
|
||||
@ -121,7 +121,7 @@
|
||||
<PrecompiledHeader>
|
||||
</PrecompiledHeader>
|
||||
<WarningLevel>Level4</WarningLevel>
|
||||
<PreprocessorDefinitions>PSAPI_VERSION=1;WIN32;NDEBUG;_WINDOWS;_USRDLL;DDRAWCOMPAT_EXPORTS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<PreprocessorDefinitions>CINTERFACE;_NO_DDRAWINT_NO_COM;PSAPI_VERSION=1;WIN32;NDEBUG;_WINDOWS;_USRDLL;DDRAWCOMPAT_EXPORTS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<RuntimeLibrary>MultiThreaded</RuntimeLibrary>
|
||||
<MultiProcessorCompilation>true</MultiProcessorCompilation>
|
||||
<ObjectFileName>$(IntDir)%(RelativeDir)</ObjectFileName>
|
||||
|
@ -1,5 +1,3 @@
|
||||
#define CINTERFACE
|
||||
|
||||
#include <functional>
|
||||
|
||||
#include <d3d.h>
|
||||
|
@ -1,7 +1,5 @@
|
||||
#pragma once
|
||||
|
||||
#define CINTERFACE
|
||||
|
||||
#include <d3d.h>
|
||||
|
||||
namespace Direct3d
|
||||
|
@ -1,7 +1,5 @@
|
||||
#pragma once
|
||||
|
||||
#define CINTERFACE
|
||||
|
||||
#include <d3d.h>
|
||||
|
||||
#include "Common/VtableVisitor.h"
|
||||
|
@ -1,7 +1,5 @@
|
||||
#pragma once
|
||||
|
||||
#define CINTERFACE
|
||||
|
||||
#include <d3d.h>
|
||||
|
||||
#include "Common/VtableVisitor.h"
|
||||
|
@ -1,7 +1,5 @@
|
||||
#pragma once
|
||||
|
||||
#define CINTERFACE
|
||||
|
||||
#include <d3d.h>
|
||||
|
||||
#include "Common/VtableVisitor.h"
|
||||
|
@ -1,7 +1,5 @@
|
||||
#pragma once
|
||||
|
||||
#define CINTERFACE
|
||||
|
||||
#include <d3d.h>
|
||||
|
||||
#include "Common/VtableVisitor.h"
|
||||
|
@ -1,7 +1,5 @@
|
||||
#pragma once
|
||||
|
||||
#define CINTERFACE
|
||||
|
||||
#include <d3d.h>
|
||||
|
||||
#include "Common/VtableVisitor.h"
|
||||
|
@ -2,45 +2,49 @@
|
||||
#include <cstring>
|
||||
#include <map>
|
||||
#include <set>
|
||||
|
||||
#include <atlstr.h>
|
||||
#include <sstream>
|
||||
|
||||
#include "Common/Hook.h"
|
||||
#include "Common/Log.h"
|
||||
#include "Win32/Registry.h"
|
||||
|
||||
typedef long NTSTATUS;
|
||||
|
||||
namespace
|
||||
{
|
||||
struct RegistryKey
|
||||
{
|
||||
HKEY key;
|
||||
CStringW subKey;
|
||||
CStringW value;
|
||||
std::wstring subKey;
|
||||
std::wstring value;
|
||||
|
||||
RegistryKey(HKEY key, CStringW subKey, CStringW value) : key(key), subKey(subKey), value(value) {}
|
||||
RegistryKey(HKEY key, const std::wstring& subKey, const std::wstring& value)
|
||||
: key(key), subKey(subKey), value(value)
|
||||
{
|
||||
}
|
||||
|
||||
bool operator<(const RegistryKey& rhs) const
|
||||
{
|
||||
if (key < rhs.key) { return true; }
|
||||
if (key > rhs.key) { return false; }
|
||||
const int subKeyComp = subKey.CompareNoCase(rhs.subKey);
|
||||
const int subKeyComp = lstrcmpiW(subKey.c_str(), rhs.subKey.c_str());
|
||||
if (subKeyComp < 0) { return true; }
|
||||
if (subKeyComp > 0) { return false; }
|
||||
return value.CompareNoCase(rhs.value) < 0;
|
||||
return lstrcmpiW(value.c_str(), rhs.value.c_str());
|
||||
}
|
||||
|
||||
bool operator==(const RegistryKey& rhs) const
|
||||
{
|
||||
return key == rhs.key &&
|
||||
0 == subKey.CompareNoCase(rhs.subKey) &&
|
||||
0 == value.CompareNoCase(rhs.value);
|
||||
0 == lstrcmpiW(subKey.c_str(), rhs.subKey.c_str()) &&
|
||||
0 == lstrcmpiW(value.c_str(), rhs.value.c_str());
|
||||
}
|
||||
};
|
||||
|
||||
std::map<RegistryKey, DWORD> g_dwordValues;
|
||||
std::set<RegistryKey> g_unsetValues;
|
||||
|
||||
CStringW getKeyName(HKEY key)
|
||||
std::wstring getKeyName(HKEY key)
|
||||
{
|
||||
enum KEY_INFORMATION_CLASS
|
||||
{
|
||||
@ -77,11 +81,11 @@ namespace
|
||||
ULONG resultSize = 0;
|
||||
if (SUCCEEDED(ntQueryKey(key, KeyNameInformation, &keyName, sizeof(keyName), &resultSize)))
|
||||
{
|
||||
return CStringW(keyName.Name, keyName.NameLength / 2);
|
||||
return std::wstring(keyName.Name, keyName.NameLength / 2);
|
||||
}
|
||||
}
|
||||
|
||||
return CStringW();
|
||||
return std::wstring();
|
||||
}
|
||||
|
||||
LONG WINAPI regGetValueW(HKEY hkey, LPCWSTR lpSubKey, LPCWSTR lpValue,
|
||||
@ -139,12 +143,14 @@ namespace
|
||||
|
||||
if (hKey && lpValueName)
|
||||
{
|
||||
const CStringW keyName = getKeyName(hKey);
|
||||
const CStringW localMachinePrefix = "\\REGISTRY\\MACHINE\\";
|
||||
if (localMachinePrefix == keyName.Mid(0, localMachinePrefix.GetLength()))
|
||||
const std::wstring keyName = getKeyName(hKey);
|
||||
const std::wstring localMachinePrefix = L"\\REGISTRY\\MACHINE\\";
|
||||
if (localMachinePrefix == keyName.substr(0, localMachinePrefix.size()))
|
||||
{
|
||||
std::wostringstream oss;
|
||||
oss << lpValueName;
|
||||
auto it = g_unsetValues.find(RegistryKey(HKEY_LOCAL_MACHINE,
|
||||
keyName.Mid(localMachinePrefix.GetLength()), lpValueName));
|
||||
keyName.substr(localMachinePrefix.size()), oss.str()));
|
||||
if (it != g_unsetValues.end())
|
||||
{
|
||||
return ERROR_FILE_NOT_FOUND;
|
||||
@ -174,13 +180,21 @@ namespace Win32
|
||||
void setValue(HKEY key, const char* subKey, const char* valueName, DWORD value)
|
||||
{
|
||||
assert(key && subKey && valueName);
|
||||
g_dwordValues[RegistryKey(key, subKey, valueName)] = value;
|
||||
std::wostringstream subKeyW;
|
||||
subKeyW << subKey;
|
||||
std::wostringstream valueNameW;
|
||||
valueNameW << valueName;
|
||||
g_dwordValues[RegistryKey(key, subKeyW.str(), valueNameW.str())] = value;
|
||||
}
|
||||
|
||||
void unsetValue(HKEY key, const char* subKey, const char* valueName)
|
||||
{
|
||||
assert(key && subKey && valueName);
|
||||
g_unsetValues.insert(RegistryKey(key, subKey, valueName));
|
||||
std::wostringstream subKeyW;
|
||||
subKeyW << subKey;
|
||||
std::wostringstream valueNameW;
|
||||
valueNameW << valueName;
|
||||
g_unsetValues.insert(RegistryKey(key, subKeyW.str(), valueNameW.str()));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user