diff --git a/Makefile b/Makefile
index 7c0dd2be5f..812f29e556 100644
--- a/Makefile
+++ b/Makefile
@@ -4,7 +4,7 @@ TARGET ?= ddraw.dll
LDFLAGS ?= -Wl,--enable-stdcall-fixup -s -static -shared
CFLAGS ?= -Iinc -O2 -Wall -std=c99
-LIBS = -lgdi32 -lwinmm -lole32 -lmsimg32
+LIBS = -lgdi32 -lwinmm -lole32 -lmsimg32 -lavifil32
COMMIT := $(shell git describe --match=NeVeRmAtCh --always --dirty || echo UNKNOWN)
BRANCH := $(shell git rev-parse --abbrev-ref HEAD || echo UNKNOWN)
diff --git a/cnc-ddraw.vcxproj b/cnc-ddraw.vcxproj
index 85475c25c7..94df66d0a1 100644
--- a/cnc-ddraw.vcxproj
+++ b/cnc-ddraw.vcxproj
@@ -223,7 +223,7 @@
Windows
- winmm.lib;kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies)
+ avifil32.lib;winmm.lib;kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies)
exports.def
@@ -265,7 +265,7 @@ echo #define GIT_BRANCH "%GIT_BRANCH%" >> %DST_FILE%
Windows
true
true
- winmm.lib;kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies)
+ avifil32.lib;winmm.lib;kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies)
exports.def
@@ -307,7 +307,7 @@ echo #define GIT_BRANCH "%GIT_BRANCH%" >> %DST_FILE%
Windows
true
true
- winmm.lib;kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies)
+ avifil32.lib;winmm.lib;kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies)
exports.def
@@ -349,7 +349,7 @@ echo #define GIT_BRANCH "%GIT_BRANCH%" >> %DST_FILE%
Windows
true
true
- winmm.lib;kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies)
+ avifil32.lib;winmm.lib;kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies)
exports.def
@@ -391,7 +391,7 @@ echo #define GIT_BRANCH "%GIT_BRANCH%" >> %DST_FILE%
Windows
true
true
- winmm.lib;kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies)
+ avifil32.lib;winmm.lib;kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies)
exports.def
diff --git a/inc/IDirectDrawSurface.h b/inc/IDirectDrawSurface.h
index e20b5068c1..d8eb99f548 100644
--- a/inc/IDirectDrawSurface.h
+++ b/inc/IDirectDrawSurface.h
@@ -9,6 +9,11 @@
#include "IDirectDraw.h"
+typedef struct DDBITMAPINFO{
+ BITMAPINFOHEADER bmiHeader;
+ RGBQUAD bmiColors[256];
+} DDBITMAPINFO;
+
struct IDirectDrawSurfaceImpl;
struct IDirectDrawSurfaceImplVtbl;
diff --git a/inc/hook.h b/inc/hook.h
index f362562814..219361c0fa 100644
--- a/inc/hook.h
+++ b/inc/hook.h
@@ -2,6 +2,7 @@
#define HOOK_H
#include
+#include
#define HOOK_SKIP_2 0x00000001l
@@ -83,6 +84,8 @@ typedef HRESULT(WINAPI* COCREATEINSTANCEPROC)(REFCLSID, LPUNKNOWN, DWORD, REFIID
typedef MCIERROR(WINAPI* MCISENDCOMMANDAPROC)(MCIDEVICEID, UINT, DWORD_PTR, DWORD_PTR);
typedef LPTOP_LEVEL_EXCEPTION_FILTER(WINAPI* SETUNHANDLEDEXCEPTIONFILTERPROC)(LPTOP_LEVEL_EXCEPTION_FILTER);
+typedef PGETFRAME (WINAPI* AVISTREAMGETFRAMEOPENPROC)(PAVISTREAM, LPBITMAPINFOHEADER);
+
extern GETCURSORPOSPROC real_GetCursorPos;
extern CLIPCURSORPROC real_ClipCursor;
extern SHOWCURSORPROC real_ShowCursor;
@@ -140,6 +143,7 @@ extern GETVERSIONEXAPROC real_GetVersionExA;
extern COCREATEINSTANCEPROC real_CoCreateInstance;
extern MCISENDCOMMANDAPROC real_mciSendCommandA;
extern SETUNHANDLEDEXCEPTIONFILTERPROC real_SetUnhandledExceptionFilter;
+extern AVISTREAMGETFRAMEOPENPROC real_AVIStreamGetFrameOpen;
extern BOOL g_hook_active;
extern HOOKLIST g_hook_hooklist[];
diff --git a/inc/winapi_hooks.h b/inc/winapi_hooks.h
index d9426fa3d1..3d2cbae35e 100644
--- a/inc/winapi_hooks.h
+++ b/inc/winapi_hooks.h
@@ -2,6 +2,7 @@
#define WINAPI_HOOKS_H
#include
+#include
BOOL WINAPI fake_GetCursorPos(LPPOINT lpPoint);
@@ -93,4 +94,6 @@ MCIERROR WINAPI fake_mciSendCommandA(MCIDEVICEID IDDevice, UINT uMsg, DWORD_PTR
LPTOP_LEVEL_EXCEPTION_FILTER WINAPI fake_SetUnhandledExceptionFilter(
LPTOP_LEVEL_EXCEPTION_FILTER lpTopLevelExceptionFilter);
+PGETFRAME WINAPI fake_AVIStreamGetFrameOpen(PAVISTREAM pavi, LPBITMAPINFOHEADER lpbiWanted);
+
#endif
diff --git a/src/ddsurface.c b/src/ddsurface.c
index c13480ab7e..ae4fcfd852 100644
--- a/src/ddsurface.c
+++ b/src/ddsurface.c
@@ -1467,10 +1467,9 @@ HRESULT dd_CreateSurface(
DWORD aligned_width = dst_surface->pitch / dst_surface->bytes_pp;
- DWORD bmi_size = sizeof(BITMAPINFOHEADER) + sizeof(RGBQUAD) * 256;
DWORD bmp_size = dst_surface->pitch * (dst_surface->height + g_config.guard_lines);
- dst_surface->bmi = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, bmi_size);
+ dst_surface->bmi = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(DDBITMAPINFO));
dst_surface->bmi->bmiHeader.biSize = sizeof(BITMAPINFOHEADER);
dst_surface->bmi->bmiHeader.biWidth = aligned_width;
dst_surface->bmi->bmiHeader.biHeight = -((int)dst_surface->height + g_config.guard_lines);
diff --git a/src/hook.c b/src/hook.c
index 3b7745fb5e..7d90641a95 100644
--- a/src/hook.c
+++ b/src/hook.c
@@ -73,6 +73,7 @@ GETVERSIONEXAPROC real_GetVersionExA = GetVersionExA;
COCREATEINSTANCEPROC real_CoCreateInstance = CoCreateInstance;
MCISENDCOMMANDAPROC real_mciSendCommandA = mciSendCommandA;
SETUNHANDLEDEXCEPTIONFILTERPROC real_SetUnhandledExceptionFilter = SetUnhandledExceptionFilter;
+AVISTREAMGETFRAMEOPENPROC real_AVIStreamGetFrameOpen = AVIStreamGetFrameOpen;
#if (_WIN32_WINNT >= _WIN32_WINNT_WIN2K)
SETWINDOWLONGWPROC real_SetWindowLongW = SetWindowLongW;
@@ -142,6 +143,13 @@ HOOKLIST g_hook_hooklist[] =
{ "", NULL, NULL, 0 }
}
},
+ {
+ "Avifil32.dll",
+ {
+ { "AVIStreamGetFrameOpen", (PROC)fake_AVIStreamGetFrameOpen, (PROC*)&real_AVIStreamGetFrameOpen, 0 },
+ { "", NULL, NULL, 0 }
+ }
+ },
{
"dinput.dll",
{
diff --git a/src/winapi_hooks.c b/src/winapi_hooks.c
index 7dff04dbd4..78cce33457 100644
--- a/src/winapi_hooks.c
+++ b/src/winapi_hooks.c
@@ -1,6 +1,7 @@
#include
#include
#include
+#include
#include "debug.h"
#include "config.h"
#include "dd.h"
@@ -2174,3 +2175,27 @@ LPTOP_LEVEL_EXCEPTION_FILTER WINAPI fake_SetUnhandledExceptionFilter(
return old;
//return real_SetUnhandledExceptionFilter(lpTopLevelExceptionFilter);
}
+
+PGETFRAME WINAPI fake_AVIStreamGetFrameOpen(PAVISTREAM pavi, LPBITMAPINFOHEADER lpbiWanted)
+{
+ if (g_ddraw.ref && g_ddraw.primary && (!lpbiWanted || (DWORD)lpbiWanted == 1))
+ {
+ DDBITMAPINFO bmi;
+ memcpy(&bmi, g_ddraw.primary->bmi, sizeof(DDBITMAPINFO));
+
+ bmi.bmiHeader.biHeight = 0;
+ bmi.bmiHeader.biWidth = 0;
+
+ if (g_ddraw.bpp == 8 && g_ddraw.primary->palette)
+ {
+ memcpy(&bmi.bmiColors[0], g_ddraw.primary->palette->data_rgb, sizeof(bmi.bmiColors));
+ }
+
+ PGETFRAME result = real_AVIStreamGetFrameOpen(pavi, (LPBITMAPINFOHEADER)&bmi);
+
+ if (result)
+ return result;
+ }
+
+ return real_AVIStreamGetFrameOpen(pavi, lpbiWanted);
+}