From db70ec8ea1cc2ec95434a86db53ca67142c406f0 Mon Sep 17 00:00:00 2001 From: Alexandre Julliard Date: Tue, 2 Dec 2003 05:33:26 +0000 Subject: [PATCH] Use normal dll imports instead of GetProcAddress hacks. --- programs/avitools/Makefile.in | 8 ++--- programs/avitools/aviinfo.c | 45 +++++------------------ programs/avitools/aviplay.c | 67 ++++++++--------------------------- programs/avitools/icinfo.c | 26 +++----------- 4 files changed, 31 insertions(+), 115 deletions(-) diff --git a/programs/avitools/Makefile.in b/programs/avitools/Makefile.in index ba8fdda68e1..f6ab98554f2 100644 --- a/programs/avitools/Makefile.in +++ b/programs/avitools/Makefile.in @@ -18,10 +18,10 @@ C_SRCS = \ all: $(PROGRAMS:%=%$(DLLEXT)) $(PROGRAMS:.exe=$(EXEEXT)) aviinfo.exe.spec.c: aviinfo.o $(WINEBUILD) - $(WINEBUILD) $(DEFS) $(DLLFLAGS) -o $@ --exe aviinfo.exe --exe-mode gui aviinfo.o -L$(DLLDIR) -lkernel32 + $(WINEBUILD) $(DEFS) $(DLLFLAGS) -o $@ --exe aviinfo.exe --exe-mode gui aviinfo.o -L$(DLLDIR) -lavifil32 -lkernel32 aviplay.exe.spec.c: aviplay.o $(WINEBUILD) - $(WINEBUILD) $(DEFS) $(DLLFLAGS) -o $@ --exe aviplay.exe --exe-mode gui aviplay.o -L$(DLLDIR) -lddraw -lkernel32 + $(WINEBUILD) $(DEFS) $(DLLFLAGS) -o $@ --exe aviplay.exe --exe-mode gui aviplay.o -L$(DLLDIR) -lavifil32 -lddraw -lkernel32 icinfo.exe.spec.c: icinfo.o $(WINEBUILD) $(WINEBUILD) $(DEFS) $(DLLFLAGS) -o $@ --exe icinfo.exe --exe-mode gui icinfo.o -L$(DLLDIR) -lmsvfw32 -lkernel32 @@ -36,10 +36,10 @@ icinfo.exe.so: icinfo.o icinfo.exe.spec.o $(LDDLL) -o $@ icinfo.o icinfo.exe.spec.o $(ALL_LIBS) -lc aviinfo.exe: aviinfo.o - $(CC) -o $@ aviinfo.o -lkernel32 $(ALL_LIBS) + $(CC) -o $@ aviinfo.o -lavifil32 -lkernel32 $(ALL_LIBS) aviplay.exe: aviplay.o - $(CC) -o $@ aviplay.o -lddraw -lkernel32 $(ALL_LIBS) + $(CC) -o $@ aviplay.o -lavifil32 -lddraw -lkernel32 $(ALL_LIBS) icinfo.exe: icinfo.o $(CC) -o $@ icinfo.o -lmsvfw32 -lkernel32 $(ALL_LIBS) diff --git a/programs/avitools/aviinfo.c b/programs/avitools/aviinfo.c index 86c22e44ea7..d4ec09c02f1 100644 --- a/programs/avitools/aviinfo.c +++ b/programs/avitools/aviinfo.c @@ -29,51 +29,22 @@ int PASCAL WinMain(HINSTANCE hInstance, HINSTANCE prev, LPSTR cmdline, int show) { int n; HRESULT hres; - HMODULE avifil32 = LoadLibrary("avifil32.dll"); PAVIFILE avif; PAVISTREAM vids,auds; AVIFILEINFO afi; AVISTREAMINFO asi; -void (WINAPI *fnAVIFileInit)(void); -void (WINAPI *fnAVIFileExit)(void); -ULONG (WINAPI *fnAVIFileRelease)(PAVIFILE); -ULONG (WINAPI *fnAVIStreamRelease)(PAVISTREAM); -HRESULT (WINAPI *fnAVIFileOpen)(PAVIFILE * ppfile,LPCTSTR szFile,UINT uMode,LPCLSID lpHandler); -HRESULT (WINAPI *fnAVIFileInfo)(PAVIFILE ppfile,AVIFILEINFO *afi,LONG size); -HRESULT (WINAPI *fnAVIFileGetStream)(PAVIFILE ppfile,PAVISTREAM *afi,DWORD fccType,LONG lParam); -HRESULT (WINAPI *fnAVIStreamInfo)(PAVISTREAM iface,AVISTREAMINFO *afi,LONG size); - -#define XX(x) fn##x = (void*)GetProcAddress(avifil32,#x);assert(fn##x); -#ifdef UNICODE -# define XXT(x) fn##x = (void*)GetProcAddress(avifil32,#x"W");assert(fn##x); -#else -# define XXT(x) fn##x = (void*)GetProcAddress(avifil32,#x"A");assert(fn##x); -#endif - /* Non character dependent routines: */ - XX (AVIFileInit); - XX (AVIFileExit); - XX (AVIFileRelease); - XX (AVIStreamRelease); - XX (AVIFileGetStream); - /* A/W routines: */ - XXT(AVIFileOpen); - XXT(AVIFileInfo); - XXT(AVIStreamInfo); -#undef XX -#undef XXT - - fnAVIFileInit(); + AVIFileInit(); if (GetFileAttributes(cmdline) == INVALID_FILE_ATTRIBUTES) { fprintf(stderr,"Usage: aviinfo \n"); exit(1); } - hres = fnAVIFileOpen(&avif,cmdline,OF_READ,NULL); + hres = AVIFileOpen(&avif,cmdline,OF_READ,NULL); if (hres) { fprintf(stderr,"AVIFileOpen: 0x%08lx\n",hres); exit(1); } - hres = fnAVIFileInfo(avif,&afi,sizeof(afi)); + hres = AVIFileInfo(avif,&afi,sizeof(afi)); if (hres) { fprintf(stderr,"AVIFileInfo: 0x%08lx\n",hres); exit(1); @@ -105,12 +76,12 @@ HRESULT (WINAPI *fnAVIStreamInfo)(PAVISTREAM iface,AVISTREAMINFO *afi,LONG size) char buf[5]; PAVISTREAM ast; - hres = fnAVIFileGetStream(avif,&ast,0,n); + hres = AVIFileGetStream(avif,&ast,0,n); if (hres) { fprintf(stderr,"AVIFileGetStream %d: 0x%08lx\n",n,hres); exit(1); } - hres = fnAVIStreamInfo(ast,&asi,sizeof(asi)); + hres = AVIStreamInfo(ast,&asi,sizeof(asi)); if (hres) { fprintf(stderr,"AVIStreamInfo %d: 0x%08lx\n",n,hres); exit(1); @@ -150,9 +121,9 @@ HRESULT (WINAPI *fnAVIStreamInfo)(PAVISTREAM iface,AVISTREAMINFO *afi,LONG size) break; } } - fnAVIStreamRelease(ast); + AVIStreamRelease(ast); } - fnAVIFileRelease(avif); - fnAVIFileExit(); + AVIFileRelease(avif); + AVIFileExit(); return 0; } diff --git a/programs/avitools/aviplay.c b/programs/avitools/aviplay.c index dd6abd3571e..8d08378fcf7 100644 --- a/programs/avitools/aviplay.c +++ b/programs/avitools/aviplay.c @@ -52,7 +52,6 @@ int PASCAL WinMain(HINSTANCE hInstance, HINSTANCE prev, LPSTR cmdline, int show) LONG cnt; BITMAPINFOHEADER *bmi; HRESULT hres; - HMODULE avifil32 = LoadLibrary("avifil32.dll"); PAVIFILE avif; PAVISTREAM vids=NULL,auds=NULL; AVIFILEINFO afi; @@ -64,55 +63,17 @@ int PASCAL WinMain(HINSTANCE hInstance, HINSTANCE prev, LPSTR cmdline, int show) LPDIRECTDRAWPALETTE dpal; PALETTEENTRY palent[256]; - -void (WINAPI *fnAVIFileInit)(void); -void (WINAPI *fnAVIFileExit)(void); -ULONG (WINAPI *fnAVIFileRelease)(PAVIFILE); -ULONG (WINAPI *fnAVIStreamRelease)(PAVISTREAM); -HRESULT (WINAPI *fnAVIFileOpen)(PAVIFILE * ppfile,LPCTSTR szFile,UINT uMode,LPCLSID lpHandler); -HRESULT (WINAPI *fnAVIFileInfo)(PAVIFILE ppfile,AVIFILEINFO *afi,LONG size); -HRESULT (WINAPI *fnAVIFileGetStream)(PAVIFILE ppfile,PAVISTREAM *afi,DWORD fccType,LONG lParam); -HRESULT (WINAPI *fnAVIStreamInfo)(PAVISTREAM iface,AVISTREAMINFO *afi,LONG size); -HRESULT (WINAPI *fnAVIStreamReadFormat)(PAVISTREAM iface,LONG pos,LPVOID format,LPLONG size); -PGETFRAME (WINAPI *fnAVIStreamGetFrameOpen)(PAVISTREAM iface,LPBITMAPINFOHEADER wanted); -LPVOID (WINAPI *fnAVIStreamGetFrame)(PGETFRAME pg,LONG pos); -HRESULT (WINAPI *fnAVIStreamGetFrameClose)(PGETFRAME pg); - -#define XX(x) fn##x = (void*)GetProcAddress(avifil32,#x);assert(fn##x); -#ifdef UNICODE -# define XXT(x) fn##x = (void*)GetProcAddress(avifil32,#x"W");assert(fn##x); -#else -# define XXT(x) fn##x = (void*)GetProcAddress(avifil32,#x"A");assert(fn##x); -#endif - /* non character dependend routines: */ - XX (AVIFileInit); - XX (AVIFileExit); - XX (AVIFileRelease); - XX (AVIFileGetStream); - XX (AVIStreamRelease); - XX (AVIStreamReadFormat); - XX (AVIStreamGetFrameOpen); - XX (AVIStreamGetFrame); - XX (AVIStreamGetFrameClose); - /* A/W routines: */ - XXT(AVIFileOpen); - XXT(AVIFileInfo); - XXT(AVIStreamInfo); -#undef XX -#undef XXT - - - fnAVIFileInit(); + AVIFileInit(); if (GetFileAttributes(cmdline) == INVALID_FILE_ATTRIBUTES) { fprintf(stderr,"Usage: aviplay \n"); exit(1); } - hres = fnAVIFileOpen(&avif,cmdline,OF_READ,NULL); + hres = AVIFileOpen(&avif,cmdline,OF_READ,NULL); if (hres) { fprintf(stderr,"AVIFileOpen: 0x%08lx\n",hres); exit(1); } - hres = fnAVIFileInfo(avif,&afi,sizeof(afi)); + hres = AVIFileInfo(avif,&afi,sizeof(afi)); if (hres) { fprintf(stderr,"AVIFileInfo: 0x%08lx\n",hres); exit(1); @@ -121,12 +82,12 @@ HRESULT (WINAPI *fnAVIStreamGetFrameClose)(PGETFRAME pg); char buf[5]; PAVISTREAM ast; - hres = fnAVIFileGetStream(avif,&ast,0,n); + hres = AVIFileGetStream(avif,&ast,0,n); if (hres) { fprintf(stderr,"AVIFileGetStream %d: 0x%08lx\n",n,hres); exit(1); } - hres = fnAVIStreamInfo(ast,&asi,sizeof(asi)); + hres = AVIStreamInfo(ast,&asi,sizeof(asi)); if (hres) { fprintf(stderr,"AVIStreamInfo %d: 0x%08lx\n",n,hres); exit(1); @@ -148,7 +109,7 @@ HRESULT (WINAPI *fnAVIStreamGetFrameClose)(PGETFRAME pg); type[4]='\0';memcpy(type,&(asi.fccType),4); fprintf(stderr,"Unhandled streamtype %s\n",type); - fnAVIStreamRelease(ast); + AVIStreamRelease(ast); break; } } @@ -160,7 +121,7 @@ HRESULT (WINAPI *fnAVIStreamGetFrameClose)(PGETFRAME pg); } cnt = sizeof(BITMAPINFOHEADER)+256*sizeof(RGBQUAD); bmi = HeapAlloc(GetProcessHeap(),0,cnt); - hres = fnAVIStreamReadFormat(vids,0,bmi,&cnt); + hres = AVIStreamReadFormat(vids,0,bmi,&cnt); if (hres) { fprintf(stderr,"AVIStreamReadFormat vids: 0x%08lx\n",hres); exit(1); @@ -170,7 +131,7 @@ HRESULT (WINAPI *fnAVIStreamGetFrameClose)(PGETFRAME pg); /* recalculate the image size */ bmi->biSizeImage = ((bmi->biWidth*bmi->biBitCount+31)&~0x1f)*bmi->biPlanes*bmi->biHeight/8; bytesline = ((bmi->biWidth*bmi->biBitCount+31)&~0x1f)*bmi->biPlanes/8; - vidgetframe = fnAVIStreamGetFrameOpen(vids,bmi); + vidgetframe = AVIStreamGetFrameOpen(vids,bmi); if (!vidgetframe) { fprintf(stderr,"AVIStreamGetFrameOpen: failed\n"); exit(1); @@ -224,7 +185,7 @@ HRESULT (WINAPI *fnAVIStreamGetFrameClose)(PGETFRAME pg); LPVOID decodedbits; /* video stuff */ - if (!(decodedframe=fnAVIStreamGetFrame(vidgetframe,pos++))) + if (!(decodedframe=AVIStreamGetFrame(vidgetframe,pos++))) break; lpbmi = (LPBITMAPINFOHEADER)decodedframe; decodedbits = (LPVOID)(((DWORD)decodedframe)+lpbmi->biSize); @@ -270,15 +231,15 @@ HRESULT (WINAPI *fnAVIStreamGetFrameClose)(PGETFRAME pg); IDirectDrawSurface_Unlock(dsurf,dsdesc.lpSurface); } tend = time(NULL); - fnAVIStreamGetFrameClose(vidgetframe); + AVIStreamGetFrameClose(vidgetframe); IDirectDrawSurface_Release(dsurf); IDirectDraw_RestoreDisplayMode(ddraw); IDirectDraw_Release(ddraw); - if (vids) fnAVIStreamRelease(vids); - if (auds) fnAVIStreamRelease(auds); + if (vids) AVIStreamRelease(vids); + if (auds) AVIStreamRelease(auds); fprintf(stderr,"%d frames at %g frames/s\n",pos,pos*1.0/(tend-tstart)); - fnAVIFileRelease(avif); - fnAVIFileExit(); + AVIFileRelease(avif); + AVIFileExit(); return 0; } diff --git a/programs/avitools/icinfo.c b/programs/avitools/icinfo.c index 7bad5ac1095..b4c2c4a3661 100644 --- a/programs/avitools/icinfo.c +++ b/programs/avitools/icinfo.c @@ -27,21 +27,6 @@ int PASCAL WinMain(HINSTANCE hInstance, HINSTANCE prev, LPSTR cmdline, int show) { int n=0,doabout=0,doconfigure=0; char buf[128],type[5],handler[5]; - HMODULE msvfw32 = LoadLibrary("msvfw32.dll"); - -BOOL (VFWAPI *fnICInfo)(DWORD fccType, DWORD fccHandler, ICINFO * lpicinfo); -LRESULT (VFWAPI *fnICClose)(HIC hic); -HIC (VFWAPI *fnICOpen)(DWORD fccType, DWORD fccHandler, UINT wMode); -LRESULT (VFWAPI *fnICGetInfo)(HIC hic,ICINFO *picinfo, DWORD cb); -LRESULT (VFWAPI *fnICSendMessage)(HIC hic, UINT msg, DWORD dw1, DWORD dw2); - -#define XX(x) fn##x = (void*)GetProcAddress(msvfw32,#x); - XX(ICInfo); - XX(ICOpen); - XX(ICClose); - XX(ICGetInfo); - XX(ICSendMessage); -#undef XX if (strstr(cmdline,"-about")) doabout = 1; @@ -54,12 +39,12 @@ LRESULT (VFWAPI *fnICSendMessage)(HIC hic, UINT msg, DWORD dw1, DWORD dw2); HIC hic; ii.dwSize = sizeof(ii); - if (!fnICInfo(ICTYPE_VIDEO,n++,&ii)) + if (!ICInfo(ICTYPE_VIDEO,n++,&ii)) break; - if (!(hic=fnICOpen(ii.fccType,ii.fccHandler,ICMODE_QUERY))) + if (!(hic=ICOpen(ii.fccType,ii.fccHandler,ICMODE_QUERY))) continue; - if (!fnICGetInfo(hic,&ii,sizeof(ii))) { - fnICClose(hic); + if (!ICGetInfo(hic,&ii,sizeof(ii))) { + ICClose(hic); continue; } #define w2s(w,s) WideCharToMultiByte(0,0,w,-1,s,128,0,NULL) @@ -87,8 +72,7 @@ LRESULT (VFWAPI *fnICSendMessage)(HIC hic, UINT msg, DWORD dw1, DWORD dw2); if (doabout) ICAbout(hic,0); if (doconfigure && ICQueryConfigure(hic)) ICConfigure(hic,0); - fnICClose(hic); + ICClose(hic); } return 0; } -