ansicon/makefile.vc

149 lines
3.7 KiB
Plaintext
Raw Normal View History

2010-11-15 21:51:38 +10:00
# VC makefile for ANSICON.
# Jason Hood, 15 November, 2010.
#
# Tested with:
# * Visual Studio 6.0 (VC6);
# * Visual C++ 2003 Toolkit (VC7);
# * Platform SDK for Windows Server 2003 R2 (VC8 64-bit);
# * Visual Studio 2008 Express SP1 (VC9);
# * Visual Studio 2010 Professional (VC10).
#
# Note that the 64-bit version still requires a 32-bit compiler.
#
# 22 & 23 November, 2012:
# determine if the PSDK is used automatically;
# use AC0000[00] (AnsiCon) as the base address;
# twiddle stuff around to support VC6 (with 2003 PSDK) for the 32-bit version;
# determine BITS automatically.
#
# 18 July, 2013:
# hide the commands (use V=1 to show them).
2010-11-15 21:51:38 +10:00
#BITS = 32
#BITS = 64
!IFNDEF BITS
!IF "$(CPU)" == "AMD64" || "$(PLATFORM)" == "x64"
BITS = 64
!ELSE
2010-11-15 21:51:38 +10:00
BITS = 32
!ENDIF
!ENDIF
2010-11-15 21:51:38 +10:00
!IF $(BITS) == 32
DIR = x86
!ELSE
!IF $(BITS) == 64
DIR = x64
RFLAGS = /D_WIN64
2010-11-15 21:51:38 +10:00
!ELSE
!ERROR BITS should be defined to 32 or 64.
!ENDIF
!ENDIF
# This is required for the 2003 Platform SDK, but not for Visual Studio 2010.
!IF "$(_NMAKE_VER)" == "7.00.8882"
!IF $(BITS) == 64
LIBS64 = bufferoverflowu.lib
# The 2003 Toolkit doesn't have MSVCRT.LIB, but VC98 does.
!ELSEIF !DEFINED(SHARE) && !DEFINED(MSVCDIR)
SHARE =
!ENDIF
!ENDIF
# Link with MSVCRT.LIB by default.
!IFNDEF SHARE
SHARE = /MD
!ENDIF
# Manifest tool to embed the manifest required by 2008.
MT = mt.exe
CFLAGS = /nologo /W3 /O2 $(SHARE) /D_CRT_SECURE_NO_WARNINGS
LIBS = advapi32.lib user32.lib $(LIBS64)
2010-11-15 21:51:38 +10:00
# Identify ansicon.exe using "ANSI" as a version number.
LINK = /link /version:20033.18771
X86OBJS = x86\injdll.obj x86\proctype.obj x86\util.obj
X64OBJS = x64\injdll.obj x64\proctype.obj x64\util.obj x64\procrva.obj
2010-12-12 21:58:35 +10:00
!IF !DEFINED(V)
V = 0
!ENDIF
!IF $(V) == 0
CCmsg = @
RCmsg = @echo $<&
LDmsg = @echo $@&
MTmsg = @echo Embedding manifest&
!ENDIF
2010-11-15 21:51:38 +10:00
{}.c{$(DIR)}.obj:
$(CCmsg)$(CC) /c $(CFLAGS) /Fo$@ $<
2010-11-15 21:51:38 +10:00
{}.rc{$(DIR)}.res:
$(RCmsg)$(RC) $(RFLAGS) /fo$@ $<
2010-11-15 21:51:38 +10:00
all: ansicon$(BITS)
ansicon32: x86 x86\ansicon.exe x86\ANSI32.dll x64 x64\ANSI32.dll
2010-11-15 21:51:38 +10:00
ansicon64: x64 x64\ansicon.exe x64\ANSI64.dll
2010-11-15 21:51:38 +10:00
x86:
mkdir x86
x86\ansicon.exe: x86\ansicon.obj $(X86OBJS) x86\procrva.obj x86\ansicon.res
$(LDmsg)$(CC) /nologo $(SHARE) /Fe$@ $** $(LIBS) $(LINK) /filealign:512
!IF "$(_NMAKE_VER)" == "9.00.30729.01"
$(MTmsg)$(MT) /nologo -manifest $@.manifest -outputresource:$@;1
@del $@.manifest
!ENDIF
2010-11-15 21:51:38 +10:00
2010-12-12 21:58:35 +10:00
x86\ANSI32.dll: x86\ANSI.obj $(X86OBJS) x86\ansi.res
$(LDmsg)$(CC) /nologo $(SHARE) /LD /Fe$@ $** $(LIBS) /link \
/base:0xAC0000 /filealign:512
!IF "$(_NMAKE_VER)" == "9.00.30729.01"
$(MTmsg)$(MT) /nologo -manifest $@.manifest -outputresource:$@;2
@del $@.manifest
!ENDIF
2010-11-15 21:51:38 +10:00
x64:
mkdir x64
x64\ansicon.exe: x64\ansicon.obj $(X64OBJS) x64\ansicon.res
$(LDmsg)$(CC) /nologo $(SHARE) /Fe$@ $** $(LIBS) $(LINK)
2010-11-15 21:51:38 +10:00
2010-12-12 21:58:35 +10:00
x64\ANSI64.dll: x64\ANSI.obj $(X64OBJS) x64\ansi.res
$(LDmsg)$(CC) /nologo $(SHARE) /LD /Fe$@ $** $(LIBS) /link \
/base:0xAC000000
2010-11-15 21:51:38 +10:00
x64\ANSI32.dll: x64\ANSI32.obj x64\proctype32.obj x86\injdll.obj x86\util.obj x86\ansi.res
$(LDmsg)$(CC) /nologo $(SHARE) /LD /Fe$@ $** $(LIBS) /link \
/base:0xAC0000 /filealign:512 /largeaddressaware
!IF "$(_NMAKE_VER)" == "9.00.30729.01"
$(MTmsg)$(MT) /nologo -manifest $@.manifest -outputresource:$@;2
@del $@.manifest
!ENDIF
2013-02-14 18:12:13 +10:00
Exclude modules from being hooked; hook only selected GUI programs. Added environment variable ANSICON_EXC to specify modules that should not be hooked. This should work around the nvd3d9wrap.dll issue. Since it helps to know what the modules are, logging is now always available, controlled by -l or ANSICON_LOG. A side-effect caused debugstr.c to move to util.c. GUI programs are once again not hooked, unless run by "ansicon" directly or in the ANSICON_GUI environment variable. Since not hooking still leaves ANSICON in the environment, created ANSICON_VER as a dynamic-only variable, which can also serve as a version check. Due to an email requesting a reverse video option, realised I always take the current attributes as default. This means if you turned on reverse and ran a program, it would take the reverse as its default. Created ANSICON_DEF variable to explicitly set the default attribute, using the current if it doesn't exist. The reverse video option is done via a "negative" attribute (e.g. "-m-f0" is reversed black on white, meaning you'll get white on black, with foreground sequences changing the background). (The difference from "\e[7m" is that it won't be reset on "\e[m".) A child program will inherit the parent's modes (but not shift); the parent will read the child's modes on exit (but not unload). The exception is "ansicon", which will always start with the default modes and leave the parent unchanged. Improved the AutoRun entry, only running "ansicon" if ANSICON_VER doesn't exist. The "ansicon" command is always first. Stopped -u implying -p; return the program's exit code; don't restore the original color when just using -p; output error messages to stderr.
2011-12-14 20:53:51 +10:00
ansicon.c: ansicon.h version.h
ansicon.rc: version.h
ANSI.c: ansicon.h version.h
ANSI.rc: version.h
util.c: ansicon.h version.h
injdll.c: ansicon.h
2010-12-12 21:58:35 +10:00
proctype.c: ansicon.h
procrva.c: ansicon.h
2010-12-12 21:58:35 +10:00
2012-04-10 15:39:58 +10:00
x64\ANSI32.obj: ANSI.c
$(CCmsg)$(CC) /DW32ON64 /c $(CFLAGS) /Fo$@ $?
2012-04-10 15:39:58 +10:00
x64\proctype32.obj: proctype.c
$(CCmsg)$(CC) /DW32ON64 /c $(CFLAGS) /Fo$@ $?
2012-04-10 15:39:58 +10:00
2010-11-15 21:51:38 +10:00
clean:
2010-12-12 21:58:35 +10:00
-del $(DIR)\*.obj $(DIR)\*.res $(DIR)\*.lib $(DIR)\*.exp
!IF $(BITS) == 32
-del x64\ansi32.obj x64\proctype32.obj
!ENDIF