Created
January 19, 2019 08:29
-
-
Save Barakat/eeff552350e69fbb5dccc364c5685a73 to your computer and use it in GitHub Desktop.
Visual Studio 2005 CRT imports IsDebuggerPresent which is missing on Windows 95. This is a workaround, compile the following code as static library and pass it to the linker before kernel32.lib
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
.386 | |
.model flat | |
extern _IsDebuggerPresentProxy@0:proc | |
public __imp__IsDebuggerPresent@0 | |
public _IsDebuggerPresent@0 | |
.data | |
__imp__IsDebuggerPresent@0 dd flat:_IsDebuggerPresent@0 | |
.code | |
_IsDebuggerPresent@0: | |
jmp _IsDebuggerPresentProxy@0 | |
end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include "stdafx.h" // Includes Windows.h | |
EXTERN_C BOOL WINAPI IsDebuggerPresentProxy() | |
{ | |
HMODULE kernel32 = LoadLibraryA("KERNEL32.DLL"); | |
if (kernel32) | |
{ | |
typedef BOOL (WINAPI *IsDebuggerPresent_t)(); | |
IsDebuggerPresent_t is_debugger_present = reinterpret_cast<IsDebuggerPresent_t>( | |
GetProcAddress(kernel32, "IsDebuggerPresent") | |
); | |
BOOL debugger_present = FALSE; | |
// KERNEL32.IsDebuggerPresent is missing on Windows 95 | |
if (is_debugger_present) | |
{ | |
debugger_present = is_debugger_present(); | |
} | |
FreeLibrary(kernel32); | |
return debugger_present; | |
} | |
return FALSE; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment