diff --git a/Makefile.mingw b/Makefile.mingw
index 13f14bcfa..efcae9bf2 100644
--- a/Makefile.mingw
+++ b/Makefile.mingw
@@ -61,7 +61,8 @@ endif
SRCS = $(CSRCS) $(CPPSRCS) $(ASRCS)
CPPOBJFILES = $(notdir $(CPPSRCS:%.cpp=%.o))
COBJFILES = $(notdir $(CSRCS:%.c=%.o))
-AOBJFILES = $(notdir $(ASRCS:%.nas=%.o))
+# win32/wrappers.nas should be built *only* for Visual C++ 2005 to enable execution on Windows 95
+AOBJFILES = $(filter-out %/wrappers.o,$(notdir $(ASRCS:%.nas=%.o)))
RCOBJFILES = $(notdir $(RCSRCS:%.rc=%.o))
COBJS = $(addprefix $(OBJDIR)/,$(CPPOBJFILES) $(COBJFILES) $(RCOBJFILES))
diff --git a/docs/rh-log.txt b/docs/rh-log.txt
index 1c87d3b3e..bc5eafd8c 100644
--- a/docs/rh-log.txt
+++ b/docs/rh-log.txt
@@ -1,3 +1,10 @@
+August 1, 2006
+- It turns out that the Visual C++ 2005 runtime calls IsDebuggerPresent, which
+ is not available under Windows 95. Since this is (or at least should be) the
+ only thing preventing us from running under Windows 95, I added a stub that
+ replaces __imp__IsDebuggerPresent@0 with a pointer to a function that checks
+ for the real thing.
+
August 1, 2006 (Changes by Graf Zahl)
- Fixed: The pickup message for Hexen's fighter's axe was assigned to the
AxePuff, not the weapon itself.
diff --git a/src/thingdef.cpp b/src/thingdef.cpp
index 9deb90f80..19dcf156c 100644
--- a/src/thingdef.cpp
+++ b/src/thingdef.cpp
@@ -2491,8 +2491,6 @@ static void ActorActiveSound (AActor *defaults, Baggage &bag)
//==========================================================================
static void ActorDropItem (AActor *defaults, Baggage &bag)
{
- bool res;
-
// create a linked list of dropitems
if (!bag.DropItemSet)
{
diff --git a/src/win32/i_main.cpp b/src/win32/i_main.cpp
index 18aeb6d54..4fb7e33b7 100644
--- a/src/win32/i_main.cpp
+++ b/src/win32/i_main.cpp
@@ -91,8 +91,6 @@ DWORD MainThreadID;
HMODULE hwtsapi32; // handle to wtsapi32.dll
-BOOL (*pIsDebuggerPresent)(VOID);
-
extern UINT TimerPeriod;
extern HCURSOR TheArrowCursor, TheInvisibleCursor;
@@ -218,10 +216,6 @@ void DoMain (HINSTANCE hInstance)
// Since we need to remain binary compatible with older versions of Windows, we
// need to extract the ProcessIdToSessionId function from kernel32.dll manually.
HMODULE kernel = GetModuleHandle ("kernel32.dll");
- if (kernel != 0)
- {
- pIsDebuggerPresent = (BOOL(*)())GetProcAddress (kernel, "IsDebuggerPresent");
- }
// NASM does not support creating writeable code sections (even though this
// is a perfectly valid configuration for Microsoft's COFF format), so I
diff --git a/src/win32/wrappers.nas b/src/win32/wrappers.nas
new file mode 100644
index 000000000..8cd87560b
--- /dev/null
+++ b/src/win32/wrappers.nas
@@ -0,0 +1,39 @@
+; The Visual C++ CRT unconditionally links to IsDebuggerPresent.
+; This function is not available under Windows 95, so here is a
+; lowlevel replacement for it.
+
+extern __imp__GetModuleHandleA@4
+extern __imp__GetProcAddress@8
+
+ SECTION .data
+
+global __imp__IsDebuggerPresent@0
+__imp__IsDebuggerPresent@0:
+ dd IsDebuggerPresent_Check
+
+ SECTION .rdata
+
+StrKERNEL32:
+ db "KERNEL32",0
+
+StrIsDebuggerPresent:
+ db "IsDebuggerPresent",0
+
+ SECTION .text
+
+IsDebuggerPresent_No:
+ xor eax,eax
+ ret
+
+IsDebuggerPresent_Check:
+ push StrKERNEL32
+ call [__imp__GetModuleHandleA@4]
+ push StrIsDebuggerPresent
+ push eax
+ call [__imp__GetProcAddress@8]
+ test eax,eax
+ jne near .itis
+ mov eax,IsDebuggerPresent_No
+.itis
+ mov [__imp__IsDebuggerPresent@0],eax
+ jmp eax
diff --git a/zdoom.vcproj b/zdoom.vcproj
index 49669e3bb..135097062 100644
--- a/zdoom.vcproj
+++ b/zdoom.vcproj
@@ -106,6 +106,7 @@
TerminalServerAware="2"
OptimizeReferences="2"
EnableCOMDATFolding="2"
+ SetChecksum="true"
/>
+
+
+
+
+
+
+
+
+
+
+
+
+
+