diff --git a/glide3x/h3/glide3/src/Makefile.mingw b/glide3x/h3/glide3/src/Makefile.mingw index 88cfbc9..86755e9 100644 --- a/glide3x/h3/glide3/src/Makefile.mingw +++ b/glide3x/h3/glide3/src/Makefile.mingw @@ -211,6 +211,9 @@ GLIDE_OBJECTS += \ ../../minihwc/gdebug.o \ ../../minihwc/minihwc.o \ ../../minihwc/win_mode.o +# so that we don't need win9x ddk: +GLIDE_OBJECTS += \ + ../../minihwc/win9x.o TEXUS_SOURCES = \ $(FX_GLIDE_SW)/texus2/lib/texuslib.c \ @@ -291,6 +294,9 @@ xtexdl_3dnow.o: xtexdl.asm xdrawtri.o: xdrawtri.asm $(AS) -o $@ $(ASFLAGS) -D__MINGW32__ $< +../../minihwc/win9x.o: ../../minihwc/win9x.asm + $(AS) -o $@ -O2 -fwin32 $< + $(GLIDE_OBJECTS): fxinline.h fxgasm.h fxinline.h: fxgasm.exe diff --git a/glide3x/h3/glide3/src/Makefile.win32 b/glide3x/h3/glide3/src/Makefile.win32 index 84e455b..8999be5 100644 --- a/glide3x/h3/glide3/src/Makefile.win32 +++ b/glide3x/h3/glide3/src/Makefile.win32 @@ -186,6 +186,9 @@ GLIDE_OBJECTS += \ ..\..\minihwc\gdebug.obj \ ..\..\minihwc\minihwc.obj \ ..\..\minihwc\win_mode.obj +# so that we don't need win9x ddk: +GLIDE_OBJECTS += \ + ..\..\minihwc\win9x.obj TEXUS_SOURCES = \ $(FX_GLIDE_SW)\texus2\lib\texuslib.c \ @@ -259,6 +262,9 @@ xdraw3_3dnow.obj: xdraw3.asm xtexdl_3dnow.obj: xtexdl.asm $(AS) -o $@ $(ASFLAGS) -DGL_AMD3D=1 $< +..\..\minihwc\win9x.obj: ..\..\minihwc\win9x.asm + $(AS) -o $@ -O2 -fwin32 $< + $(GLIDE_OBJECTS): fxinline.h fxgasm.h fxinline.h: fxgasm.exe diff --git a/glide3x/h3/minihwc/minihwc.c b/glide3x/h3/minihwc/minihwc.c index cdf170e..4380a84 100644 --- a/glide3x/h3/minihwc/minihwc.c +++ b/glide3x/h3/minihwc/minihwc.c @@ -549,11 +549,17 @@ #include #include "qmodes.h" +#if 0 /* moved to asm so we don't need w9x ddk headers. */ #define IS_32 #define Not_VxD #include #include #include +#else +extern DWORD __cdecl CM_Get_DevNode_Key(DWORD,PCHAR,PVOID,ULONG,ULONG); +#define CM_REGISTRY_HARDWARE 0 +#define CM_REGISTRY_SOFTWARE 1 +#endif #endif diff --git a/glide3x/h3/minihwc/win9x.asm b/glide3x/h3/minihwc/win9x.asm new file mode 100644 index 0000000..2e4637b --- /dev/null +++ b/glide3x/h3/minihwc/win9x.asm @@ -0,0 +1,90 @@ +; this is here so that the win9x parts of minihwc.c && +; win_mode.c can compile without the win9x ddk headers. + +extern __imp__CreateFileA@28 +extern __imp__CloseHandle@4 +extern __imp__DeviceIoControl@32 + +global _CM_Get_DevNode_Key + +section .text +align 16 +;CM_Get_DevNode_Key(DWORD, PCHAR, PVOID, ULONG, ULONG) +_CM_Get_DevNode_Key: + push ebp + mov ebp,esp + ;struct _IOCTLPKT { DWORD stack, servicenum; } pkt; + ;DWORD stack; + sub esp,12 + mov dword [ebp-4],ebp + mov eax,dword [ebp-4] + mov dword [ebp-8],0x8000003d ; servicenum + add eax,8 + mov dword [ebp-12],eax + lea eax,[ebp-12] + push eax + call _CM_IoctlHandler@4 + mov esp,ebp + pop ebp + ret +align 16 +;DWORD __stdcall CM_IOCTLHandler(struct _IOCTLPKT *) +_CM_IoctlHandler@4: + ;HANDLE hCONFIGMG; DWORD rc,rcsize; + sub esp,8 + push esi + push 0 + push 0 + push 3 + push 0 + push 3 + push 0xc0000000 ; GENERIC_READ|GENERIC_WRITE + push LC0 + ; rc= ERR, rcsize = 0; + mov dword [esp+0x20],19 ; CONFIGMG error + mov dword [esp+0x24],0 + call [__imp__CreateFileA@28] + mov esi,eax + cmp esi,0xffffffff + jne .L0 + mov eax,19 + pop esi + add esp,8 + ret 4 +.L0: + lea eax,[esp+8] + push 0 + push eax + mov eax,dword [esp+24] + lea ecx,[esp+12] + push 4 + mov edx,dword [eax+4] + push ecx + push 4 + push eax + push edx + push esi + ;DeviceIoControl(hCONFIGMG, + ; pkt->servicenum, &pkt->stack, sizeof(pkt->stack), + ; &rc, sizeof(rc), &rcsize,NULL); + call [__imp__DeviceIoControl@32] + test eax,eax + jne .L1 + mov dword [esp+0x4],19 +.L1: + push esi + call [__imp__CloseHandle@4] + mov eax,dword [esp+0x8] + cmp eax,4 + mov eax,19 + jne .L2 + mov eax,dword [esp+4] +.L2: + pop esi + add esp,8 + ret 4 +align 16 + +section .rdata +LC0: db `\\\\.\\CONFIGMG\0` + align 16,db 0 diff --git a/glide3x/h3/minihwc/win_mode.c b/glide3x/h3/minihwc/win_mode.c index 1f62758..0f5a7b4 100644 --- a/glide3x/h3/minihwc/win_mode.c +++ b/glide3x/h3/minihwc/win_mode.c @@ -30,11 +30,17 @@ DECLARE_HANDLE(HMONITOR); #include #include #include "qmodes.h" +#if 0 /* moved to asm so we don't need w9x ddk headers. */ #define IS_32 #define Not_VxD #include #include #include +#else +extern DWORD __cdecl CM_Get_DevNode_Key(DWORD,PCHAR,PVOID,ULONG,ULONG); +#define CM_REGISTRY_HARDWARE 0 +#define CM_REGISTRY_SOFTWARE 1 +#endif #ifndef IDirectDraw7_CreateSurface /* ddraw.h not from dx7 sdk */ typedef BOOL (FAR PASCAL * LPDDENUMCALLBACKEXA)(GUID FAR *, LPSTR, LPSTR, LPVOID, HMONITOR); diff --git a/glide3x/h5/glide3/src/Makefile.mingw b/glide3x/h5/glide3/src/Makefile.mingw index 866d0a0..05a9c1b 100644 --- a/glide3x/h5/glide3/src/Makefile.mingw +++ b/glide3x/h5/glide3/src/Makefile.mingw @@ -245,6 +245,9 @@ GLIDE_OBJECTS += \ ../../minihwc/gdebug.o \ ../../minihwc/minihwc.o \ ../../minihwc/win_mode.o +# so that we don't need win9x ddk: +GLIDE_OBJECTS += \ + ../../minihwc/win9x.o TEXUS_SOURCES = \ $(FX_GLIDE_SW)/texus2/lib/texuslib.c \ @@ -331,6 +334,9 @@ xtexdl_sse2.o: xtexdl.asm xdrawtri.o: xdrawtri.asm $(AS) -o $@ $(ASFLAGS) -D__MINGW32__ $< +../../minihwc/win9x.o: ../../minihwc/win9x.asm + $(AS) -o $@ -O2 -fwin32 $< + $(GLIDE_OBJECTS): fxinline.h fxgasm.h fxbldno.h fxinline.h: fxgasm.exe diff --git a/glide3x/h5/glide3/src/Makefile.win32 b/glide3x/h5/glide3/src/Makefile.win32 index 99e7d51..d10506d 100644 --- a/glide3x/h5/glide3/src/Makefile.win32 +++ b/glide3x/h5/glide3/src/Makefile.win32 @@ -220,6 +220,9 @@ GLIDE_OBJECTS += \ ..\..\minihwc\gdebug.obj \ ..\..\minihwc\minihwc.obj \ ..\..\minihwc\win_mode.obj +# so that we don't need win9x ddk: +GLIDE_OBJECTS += \ + ..\..\minihwc\win9x.obj TEXUS_SOURCES = \ $(FX_GLIDE_SW)\texus2\lib\texuslib.c \ @@ -299,6 +302,9 @@ xdraw3_sse.obj: xdraw3.asm xtexdl_sse2.obj: xtexdl.asm $(AS) -o $@ $(ASFLAGS) -DGL_SSE2=1 $< +..\..\minihwc\win9x.obj: ..\..\minihwc\win9x.asm + $(AS) -o $@ -O2 -fwin32 $< + $(GLIDE_OBJECTS): fxinline.h fxgasm.h fxbldno.h fxinline.h: fxgasm.exe diff --git a/glide3x/h5/minihwc/minihwc.c b/glide3x/h5/minihwc/minihwc.c index a603bdd..1a8d6a2 100644 --- a/glide3x/h5/minihwc/minihwc.c +++ b/glide3x/h5/minihwc/minihwc.c @@ -767,11 +767,17 @@ #include #include "qmodes.h" +#if 0 /* moved to asm so we don't need w9x ddk headers. */ #define IS_32 #define Not_VxD #include #include #include +#else +extern DWORD __cdecl CM_Get_DevNode_Key(DWORD,PCHAR,PVOID,ULONG,ULONG); +#define CM_REGISTRY_HARDWARE 0 +#define CM_REGISTRY_SOFTWARE 1 +#endif #endif diff --git a/glide3x/h5/minihwc/win9x.asm b/glide3x/h5/minihwc/win9x.asm new file mode 100644 index 0000000..2e4637b --- /dev/null +++ b/glide3x/h5/minihwc/win9x.asm @@ -0,0 +1,90 @@ +; this is here so that the win9x parts of minihwc.c && +; win_mode.c can compile without the win9x ddk headers. + +extern __imp__CreateFileA@28 +extern __imp__CloseHandle@4 +extern __imp__DeviceIoControl@32 + +global _CM_Get_DevNode_Key + +section .text +align 16 +;CM_Get_DevNode_Key(DWORD, PCHAR, PVOID, ULONG, ULONG) +_CM_Get_DevNode_Key: + push ebp + mov ebp,esp + ;struct _IOCTLPKT { DWORD stack, servicenum; } pkt; + ;DWORD stack; + sub esp,12 + mov dword [ebp-4],ebp + mov eax,dword [ebp-4] + mov dword [ebp-8],0x8000003d ; servicenum + add eax,8 + mov dword [ebp-12],eax + lea eax,[ebp-12] + push eax + call _CM_IoctlHandler@4 + mov esp,ebp + pop ebp + ret +align 16 +;DWORD __stdcall CM_IOCTLHandler(struct _IOCTLPKT *) +_CM_IoctlHandler@4: + ;HANDLE hCONFIGMG; DWORD rc,rcsize; + sub esp,8 + push esi + push 0 + push 0 + push 3 + push 0 + push 3 + push 0xc0000000 ; GENERIC_READ|GENERIC_WRITE + push LC0 + ; rc= ERR, rcsize = 0; + mov dword [esp+0x20],19 ; CONFIGMG error + mov dword [esp+0x24],0 + call [__imp__CreateFileA@28] + mov esi,eax + cmp esi,0xffffffff + jne .L0 + mov eax,19 + pop esi + add esp,8 + ret 4 +.L0: + lea eax,[esp+8] + push 0 + push eax + mov eax,dword [esp+24] + lea ecx,[esp+12] + push 4 + mov edx,dword [eax+4] + push ecx + push 4 + push eax + push edx + push esi + ;DeviceIoControl(hCONFIGMG, + ; pkt->servicenum, &pkt->stack, sizeof(pkt->stack), + ; &rc, sizeof(rc), &rcsize,NULL); + call [__imp__DeviceIoControl@32] + test eax,eax + jne .L1 + mov dword [esp+0x4],19 +.L1: + push esi + call [__imp__CloseHandle@4] + mov eax,dword [esp+0x8] + cmp eax,4 + mov eax,19 + jne .L2 + mov eax,dword [esp+4] +.L2: + pop esi + add esp,8 + ret 4 +align 16 + +section .rdata +LC0: db `\\\\.\\CONFIGMG\0` + align 16,db 0 diff --git a/glide3x/h5/minihwc/win_mode.c b/glide3x/h5/minihwc/win_mode.c index 851994a..76e9b32 100644 --- a/glide3x/h5/minihwc/win_mode.c +++ b/glide3x/h5/minihwc/win_mode.c @@ -34,11 +34,6 @@ DECLARE_HANDLE(HMONITOR); #include "qmodes.h" #include "minihwc.h" #include "setmode.h" -#define IS_32 -#define Not_VxD -#include -#include -#include #undef GETENV #define GETENV hwcGetenv