mirror of
https://github.com/mpv-player/mpv
synced 2025-02-09 00:17:07 +00:00
windows xp support
git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@12057 b3059339-0415-0410-9bf9-f77b7e298cf2
This commit is contained in:
parent
a977756617
commit
543c00752d
@ -5,6 +5,9 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
#include <windows.h>
|
#include <windows.h>
|
||||||
|
#include <ddk/ntddk.h>
|
||||||
|
#include "../dhahelperwin/dhahelper.h"
|
||||||
|
|
||||||
/*
|
/*
|
||||||
This is the request structure that applications use
|
This is the request structure that applications use
|
||||||
to request services from the MAPDEV VxD.
|
to request services from the MAPDEV VxD.
|
||||||
@ -32,9 +35,20 @@ typedef struct _MapDevRequest
|
|||||||
#define CTL_CODE( DeviceType, Function, Method, Access ) ( \
|
#define CTL_CODE( DeviceType, Function, Method, Access ) ( \
|
||||||
((DeviceType)<<16) | ((Access)<<14) | ((Function)<<2) | (Method) )
|
((DeviceType)<<16) | ((Access)<<14) | ((Function)<<2) | (Method) )
|
||||||
|
|
||||||
|
|
||||||
|
int IsWinNT(){
|
||||||
|
OSVERSIONINFO OSVersionInfo;
|
||||||
|
OSVersionInfo.dwOSVersionInfoSize = sizeof(OSVERSIONINFO);
|
||||||
|
GetVersionEx(&OSVersionInfo);
|
||||||
|
return OSVersionInfo.dwPlatformId == VER_PLATFORM_WIN32_NT;
|
||||||
|
}
|
||||||
|
|
||||||
|
static HANDLE hDriver = INVALID_HANDLE_VALUE;
|
||||||
|
|
||||||
|
|
||||||
/* Memory Map a piece of Real Memory */
|
/* Memory Map a piece of Real Memory */
|
||||||
void *map_phys_mem(unsigned long base, unsigned long size) {
|
void *map_phys_mem(unsigned long base, unsigned long size) {
|
||||||
|
if(!IsWinNT()){
|
||||||
HANDLE hDevice ;
|
HANDLE hDevice ;
|
||||||
PVOID inBuf[1] ; /* buffer for struct pointer to VxD */
|
PVOID inBuf[1] ; /* buffer for struct pointer to VxD */
|
||||||
DWORD RetInfo[2] ; /* buffer to receive data from VxD */
|
DWORD RetInfo[2] ; /* buffer to receive data from VxD */
|
||||||
@ -63,6 +77,26 @@ void *map_phys_mem(unsigned long base, unsigned long size) {
|
|||||||
fprintf(stderr, "Failed to map device\n") ; exit(1) ; }
|
fprintf(stderr, "Failed to map device\n") ; exit(1) ; }
|
||||||
|
|
||||||
return (void*)req.mdr_LinearAddress ;
|
return (void*)req.mdr_LinearAddress ;
|
||||||
|
}
|
||||||
|
else{
|
||||||
|
dhahelper_t dhahelper_priv;
|
||||||
|
DWORD dwBytesReturned;
|
||||||
|
dhahelper_priv.size = size;
|
||||||
|
dhahelper_priv.base = base;
|
||||||
|
if(hDriver==INVALID_HANDLE_VALUE)hDriver = CreateFile("\\\\.\\DHAHELPER",GENERIC_READ | GENERIC_WRITE,0,NULL,OPEN_EXISTING,FILE_ATTRIBUTE_NORMAL,NULL);
|
||||||
|
if (!DeviceIoControl(hDriver, IOCTL_DHAHELPER_MAPPHYSTOLIN, &dhahelper_priv,sizeof(dhahelper_t), &dhahelper_priv, sizeof(dhahelper_t),&dwBytesReturned, NULL)){
|
||||||
|
printf("unable to map thre requested memory region\n");
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
else return dhahelper_priv.ptr;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void unmap_phys_mem(void *ptr, unsigned long size) { }
|
void unmap_phys_mem(void *ptr, unsigned long size) {
|
||||||
|
if(IsWinNT()){
|
||||||
|
dhahelper_t dhahelper_priv;
|
||||||
|
DWORD dwBytesReturned;
|
||||||
|
dhahelper_priv.ptr = ptr;
|
||||||
|
DeviceIoControl(hDriver, IOCTL_DHAHELPER_UNMAPPHYSADDR, &dhahelper_priv,sizeof(dhahelper_t), NULL, 0, &dwBytesReturned, NULL);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
@ -4,15 +4,35 @@
|
|||||||
Modified for readability by Nick Kurshev
|
Modified for readability by Nick Kurshev
|
||||||
*/
|
*/
|
||||||
#include <windows.h>
|
#include <windows.h>
|
||||||
|
#include <ddk/ntddk.h>
|
||||||
|
#include "../dhahelperwin/dhahelper.h"
|
||||||
|
|
||||||
|
static HANDLE hDriver;
|
||||||
|
extern int IsWinNT();
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/* Nothing to do for Win9x. For WinNT I have no solution */
|
|
||||||
|
|
||||||
static __inline__ int enable_os_io(void)
|
static __inline__ int enable_os_io(void)
|
||||||
{
|
{
|
||||||
|
if(IsWinNT()){
|
||||||
|
DWORD dwBytesReturned;
|
||||||
|
hDriver = CreateFile("\\\\.\\DHAHELPER",GENERIC_READ | GENERIC_WRITE,0,NULL,OPEN_EXISTING,FILE_ATTRIBUTE_NORMAL,NULL);
|
||||||
|
if(!DeviceIoControl(hDriver, IOCTL_DHAHELPER_ENABLEDIRECTIO, NULL,0, NULL, 0, &dwBytesReturned, NULL)){
|
||||||
|
printf("unable to enable directio please install dhahelper.sys\n");
|
||||||
|
return(1);
|
||||||
|
}
|
||||||
|
}
|
||||||
return(0);
|
return(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
static __inline__ int disable_os_io(void)
|
static __inline__ int disable_os_io(void)
|
||||||
{
|
{
|
||||||
|
if(IsWinNT()){
|
||||||
|
DWORD dwBytesReturned;
|
||||||
|
DeviceIoControl(hDriver, IOCTL_DHAHELPER_DISABLEDIRECTIO, NULL,0, NULL, 0, &dwBytesReturned, NULL);
|
||||||
|
CloseHandle(hDriver);
|
||||||
|
}
|
||||||
return(0);
|
return(0);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user