mirror of
https://github.com/FunkyFr3sh/cnc-ddraw.git
synced 2025-03-14 22:03:27 +01:00
add separate file for delayed imports
This commit is contained in:
parent
883aadd449
commit
8c587b21dd
@ -27,6 +27,7 @@
|
|||||||
<ClCompile Include="src\crc32.c" />
|
<ClCompile Include="src\crc32.c" />
|
||||||
<ClCompile Include="src\ddclipper.c" />
|
<ClCompile Include="src\ddclipper.c" />
|
||||||
<ClCompile Include="src\debug.c" />
|
<ClCompile Include="src\debug.c" />
|
||||||
|
<ClCompile Include="src\delay_imports.c" />
|
||||||
<ClCompile Include="src\detours\creatwth.cpp" />
|
<ClCompile Include="src\detours\creatwth.cpp" />
|
||||||
<ClCompile Include="src\detours\detours.cpp" />
|
<ClCompile Include="src\detours\detours.cpp" />
|
||||||
<ClCompile Include="src\detours\disasm.cpp" />
|
<ClCompile Include="src\detours\disasm.cpp" />
|
||||||
@ -80,6 +81,7 @@
|
|||||||
<ClInclude Include="inc\d3dcaps.h" />
|
<ClInclude Include="inc\d3dcaps.h" />
|
||||||
<ClInclude Include="inc\ddclipper.h" />
|
<ClInclude Include="inc\ddclipper.h" />
|
||||||
<ClInclude Include="inc\ddraw.h" />
|
<ClInclude Include="inc\ddraw.h" />
|
||||||
|
<ClInclude Include="inc\delay_imports.h" />
|
||||||
<ClInclude Include="inc\directinput.h" />
|
<ClInclude Include="inc\directinput.h" />
|
||||||
<ClInclude Include="inc\dllmain.h" />
|
<ClInclude Include="inc\dllmain.h" />
|
||||||
<ClInclude Include="inc\fps_limiter.h" />
|
<ClInclude Include="inc\fps_limiter.h" />
|
||||||
|
@ -168,6 +168,9 @@
|
|||||||
<ClCompile Include="src\keyboard.c">
|
<ClCompile Include="src\keyboard.c">
|
||||||
<Filter>Source Files</Filter>
|
<Filter>Source Files</Filter>
|
||||||
</ClCompile>
|
</ClCompile>
|
||||||
|
<ClCompile Include="src\delay_imports.c">
|
||||||
|
<Filter>Source Files</Filter>
|
||||||
|
</ClCompile>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<ClInclude Include="inc\debug.h">
|
<ClInclude Include="inc\debug.h">
|
||||||
@ -299,6 +302,9 @@
|
|||||||
<ClInclude Include="inc\d3dcaps.h">
|
<ClInclude Include="inc\d3dcaps.h">
|
||||||
<Filter>Header Files</Filter>
|
<Filter>Header Files</Filter>
|
||||||
</ClInclude>
|
</ClInclude>
|
||||||
|
<ClInclude Include="inc\delay_imports.h">
|
||||||
|
<Filter>Header Files</Filter>
|
||||||
|
</ClInclude>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<ResourceCompile Include="res.rc">
|
<ResourceCompile Include="res.rc">
|
||||||
|
21
inc/delay_imports.h
Normal file
21
inc/delay_imports.h
Normal file
@ -0,0 +1,21 @@
|
|||||||
|
#ifndef DELAY_IMPORTS_H
|
||||||
|
#define DELAY_IMPORTS_H
|
||||||
|
|
||||||
|
#define ThreadQuerySetWin32StartAddress 9
|
||||||
|
|
||||||
|
typedef NTSTATUS(WINAPI* RTLVERIFYVERSIONINFOPROC)(PRTL_OSVERSIONINFOEXW, ULONG, ULONGLONG);
|
||||||
|
typedef ULONGLONG(WINAPI* VERSETCONDITIONMASKPROC)(ULONGLONG, DWORD, BYTE);
|
||||||
|
typedef const char* (CDECL* WINE_GET_VERSIONPROC)();
|
||||||
|
typedef void (CDECL* WINE_GET_HOST_VERSIONPROC)(const char** sysname, const char** release);
|
||||||
|
typedef NTSTATUS(WINAPI* NTQUERYINFORMATIONTHREADPROC)(HANDLE, LONG, PVOID, ULONG, PULONG);
|
||||||
|
|
||||||
|
extern NTQUERYINFORMATIONTHREADPROC NtQueryInformationThread;
|
||||||
|
extern RTLVERIFYVERSIONINFOPROC RtlVerifyVersionInfo;
|
||||||
|
extern WINE_GET_VERSIONPROC wine_get_version;
|
||||||
|
extern WINE_GET_HOST_VERSIONPROC wine_get_host_version;
|
||||||
|
|
||||||
|
extern VERSETCONDITIONMASKPROC VerSetConditionMaskProc;
|
||||||
|
|
||||||
|
void imports_init();
|
||||||
|
|
||||||
|
#endif
|
@ -33,7 +33,6 @@
|
|||||||
#define VerSetConditionMask verhelp_set_mask
|
#define VerSetConditionMask verhelp_set_mask
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
void verhelp_init();
|
|
||||||
BOOL verhelp_verify_version(PRTL_OSVERSIONINFOEXW versionInfo, ULONG typeMask, ULONGLONG conditionMask);
|
BOOL verhelp_verify_version(PRTL_OSVERSIONINFOEXW versionInfo, ULONG typeMask, ULONGLONG conditionMask);
|
||||||
ULONGLONG verhelp_set_mask(ULONGLONG ConditionMask, DWORD TypeMask, BYTE Condition);
|
ULONGLONG verhelp_set_mask(ULONGLONG ConditionMask, DWORD TypeMask, BYTE Condition);
|
||||||
const char* verhelp_wine_get_version();
|
const char* verhelp_wine_get_version();
|
||||||
|
33
src/delay_imports.c
Normal file
33
src/delay_imports.c
Normal file
@ -0,0 +1,33 @@
|
|||||||
|
#include <windows.h>
|
||||||
|
#include "versionhelpers.h"
|
||||||
|
|
||||||
|
typedef NTSTATUS(WINAPI* RTLVERIFYVERSIONINFOPROC)(PRTL_OSVERSIONINFOEXW, ULONG, ULONGLONG);
|
||||||
|
typedef ULONGLONG(WINAPI* VERSETCONDITIONMASKPROC)(ULONGLONG, DWORD, BYTE);
|
||||||
|
typedef const char* (CDECL* WINE_GET_VERSIONPROC)();
|
||||||
|
typedef void (CDECL* WINE_GET_HOST_VERSIONPROC)(const char** sysname, const char** release);
|
||||||
|
typedef NTSTATUS(WINAPI* NTQUERYINFORMATIONTHREADPROC)(HANDLE, LONG, PVOID, ULONG, PULONG);
|
||||||
|
|
||||||
|
NTQUERYINFORMATIONTHREADPROC NtQueryInformationThread;
|
||||||
|
RTLVERIFYVERSIONINFOPROC RtlVerifyVersionInfo;
|
||||||
|
WINE_GET_VERSIONPROC wine_get_version;
|
||||||
|
WINE_GET_HOST_VERSIONPROC wine_get_host_version;
|
||||||
|
|
||||||
|
VERSETCONDITIONMASKPROC VerSetConditionMaskProc;
|
||||||
|
|
||||||
|
void imports_init()
|
||||||
|
{
|
||||||
|
HMODULE mod = GetModuleHandleA("ntdll.dll");
|
||||||
|
if (mod)
|
||||||
|
{
|
||||||
|
NtQueryInformationThread = (NTQUERYINFORMATIONTHREADPROC)GetProcAddress(mod, "NtQueryInformationThread");
|
||||||
|
RtlVerifyVersionInfo = (RTLVERIFYVERSIONINFOPROC)GetProcAddress(mod, "RtlVerifyVersionInfo");
|
||||||
|
wine_get_version = (WINE_GET_VERSIONPROC)GetProcAddress(mod, "wine_get_version");
|
||||||
|
wine_get_host_version = (WINE_GET_HOST_VERSIONPROC)GetProcAddress(mod, "wine_get_host_version");
|
||||||
|
}
|
||||||
|
|
||||||
|
mod = GetModuleHandleA("Kernel32.dll");
|
||||||
|
if (mod)
|
||||||
|
{
|
||||||
|
VerSetConditionMaskProc = (VERSETCONDITIONMASKPROC)GetProcAddress(mod, "VerSetConditionMask");
|
||||||
|
}
|
||||||
|
}
|
@ -12,6 +12,7 @@
|
|||||||
#include "indeo.h"
|
#include "indeo.h"
|
||||||
#include "utils.h"
|
#include "utils.h"
|
||||||
#include "versionhelpers.h"
|
#include "versionhelpers.h"
|
||||||
|
#include "delay_imports.h"
|
||||||
#include "keyboard.h"
|
#include "keyboard.h"
|
||||||
|
|
||||||
|
|
||||||
@ -33,7 +34,7 @@ BOOL WINAPI DllMain(HANDLE hDll, DWORD dwReason, LPVOID lpReserved)
|
|||||||
{
|
{
|
||||||
g_ddraw_module = hDll;
|
g_ddraw_module = hDll;
|
||||||
|
|
||||||
verhelp_init();
|
imports_init();
|
||||||
|
|
||||||
if (GetEnvironmentVariable("cnc_ddraw_config_init", NULL, 0))
|
if (GetEnvironmentVariable("cnc_ddraw_config_init", NULL, 0))
|
||||||
{
|
{
|
||||||
|
@ -1,33 +1,7 @@
|
|||||||
#include <windows.h>
|
#include <windows.h>
|
||||||
#include "versionhelpers.h"
|
#include "versionhelpers.h"
|
||||||
|
#include "delay_imports.h"
|
||||||
|
|
||||||
typedef NTSTATUS(WINAPI* RTLVERIFYVERSIONINFOPROC)(PRTL_OSVERSIONINFOEXW, ULONG, ULONGLONG);
|
|
||||||
typedef ULONGLONG(WINAPI* VERSETCONDITIONMASKPROC)(ULONGLONG, DWORD, BYTE);
|
|
||||||
typedef const char* (CDECL* WINE_GET_VERSIONPROC)();
|
|
||||||
typedef void (CDECL* WINE_GET_HOST_VERSIONPROC)(const char** sysname, const char** release);
|
|
||||||
|
|
||||||
static RTLVERIFYVERSIONINFOPROC RtlVerifyVersionInfo;
|
|
||||||
static VERSETCONDITIONMASKPROC VerSetConditionMaskProc;
|
|
||||||
static WINE_GET_VERSIONPROC wine_get_version;
|
|
||||||
static WINE_GET_HOST_VERSIONPROC wine_get_host_version;
|
|
||||||
|
|
||||||
/* GetProcAddress is rather slow so we use a function to initialize it once on startup */
|
|
||||||
void verhelp_init()
|
|
||||||
{
|
|
||||||
HMODULE mod = GetModuleHandleA("ntdll.dll");
|
|
||||||
if (mod)
|
|
||||||
{
|
|
||||||
RtlVerifyVersionInfo = (RTLVERIFYVERSIONINFOPROC)GetProcAddress(mod, "RtlVerifyVersionInfo");
|
|
||||||
wine_get_version = (WINE_GET_VERSIONPROC)GetProcAddress(mod, "wine_get_version");
|
|
||||||
wine_get_host_version = (WINE_GET_HOST_VERSIONPROC)GetProcAddress(mod, "wine_get_host_version");
|
|
||||||
}
|
|
||||||
|
|
||||||
mod = GetModuleHandleA("Kernel32.dll");
|
|
||||||
if (mod)
|
|
||||||
{
|
|
||||||
VerSetConditionMaskProc = (VERSETCONDITIONMASKPROC)GetProcAddress(mod, "VerSetConditionMask");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
BOOL verhelp_verify_version(PRTL_OSVERSIONINFOEXW versionInfo, ULONG typeMask, ULONGLONG conditionMask)
|
BOOL verhelp_verify_version(PRTL_OSVERSIONINFOEXW versionInfo, ULONG typeMask, ULONGLONG conditionMask)
|
||||||
{
|
{
|
||||||
|
Loading…
x
Reference in New Issue
Block a user