2010-11-15 21:51:38 +10:00
|
|
|
# VC makefile for ANSICON.
|
|
|
|
# Jason Hood, 15 November, 2010.
|
2013-07-19 00:14:54 +10:00
|
|
|
#
|
|
|
|
# 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.
|
|
|
|
#
|
2012-11-24 23:41:29 +10:00
|
|
|
# 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.
|
2013-07-19 00:14:54 +10:00
|
|
|
#
|
|
|
|
# 18 July, 2013:
|
|
|
|
# hide the commands (use V=1 to show them).
|
2018-04-30 11:23:34 +10:00
|
|
|
#
|
|
|
|
# 30 April, 2018:
|
|
|
|
# use undocumented rc option /s to remove its logo;
|
|
|
|
# use a batch rule (even if this project is too small to make a difference).
|
2012-11-24 23:41:29 +10:00
|
|
|
|
2010-11-15 21:51:38 +10:00
|
|
|
#BITS = 32
|
|
|
|
#BITS = 64
|
|
|
|
|
|
|
|
!IFNDEF BITS
|
2014-02-10 16:33:42 +10:00
|
|
|
!IF "$(CPU)" == "AMD64" || "$(PLATFORM)" == "x64" || "$(PLATFORM)" == "X64"
|
2012-11-24 23:41:29 +10:00
|
|
|
BITS = 64
|
|
|
|
!ELSE
|
2010-11-15 21:51:38 +10:00
|
|
|
BITS = 32
|
|
|
|
!ENDIF
|
2012-11-24 23:41:29 +10:00
|
|
|
!ENDIF
|
2010-11-15 21:51:38 +10:00
|
|
|
|
|
|
|
!IF $(BITS) == 32
|
|
|
|
DIR = x86
|
|
|
|
!ELSE
|
|
|
|
!IF $(BITS) == 64
|
|
|
|
DIR = x64
|
2013-07-19 00:14:54 +10:00
|
|
|
RFLAGS = /D_WIN64
|
2010-11-15 21:51:38 +10:00
|
|
|
!ELSE
|
|
|
|
!ERROR BITS should be defined to 32 or 64.
|
|
|
|
!ENDIF
|
|
|
|
!ENDIF
|
|
|
|
|
2012-11-24 23:41:29 +10:00
|
|
|
# This is required for the 2003 Platform SDK, but not for Visual Studio 2010.
|
|
|
|
!IF "$(_NMAKE_VER)" == "7.00.8882"
|
2013-07-19 00:14:54 +10:00
|
|
|
!IF $(BITS) == 64
|
2012-11-24 23:41:29 +10:00
|
|
|
LIBS64 = bufferoverflowu.lib
|
2013-07-19 00:14:54 +10:00
|
|
|
# The 2003 Toolkit doesn't have MSVCRT.LIB, but VC98 does.
|
|
|
|
!ELSEIF !DEFINED(SHARE) && !DEFINED(MSVCDIR)
|
2012-11-24 23:41:29 +10:00
|
|
|
SHARE =
|
|
|
|
!ENDIF
|
|
|
|
!ENDIF
|
|
|
|
|
|
|
|
# Link with MSVCRT.LIB by default.
|
|
|
|
!IFNDEF SHARE
|
|
|
|
SHARE = /MD
|
|
|
|
!ENDIF
|
|
|
|
|
2013-07-19 00:14:54 +10:00
|
|
|
# Manifest tool to embed the manifest required by 2008.
|
|
|
|
MT = mt.exe
|
|
|
|
|
2018-04-30 11:23:34 +10:00
|
|
|
RFLAGS = /s
|
2013-07-19 00:14:54 +10:00
|
|
|
CFLAGS = /nologo /W3 /O2 $(SHARE) /D_CRT_SECURE_NO_WARNINGS
|
2018-04-30 11:06:18 +10:00
|
|
|
LIBS = advapi32.lib $(LIBS64)
|
2010-11-15 21:51:38 +10:00
|
|
|
|
2014-02-05 00:21:42 +10:00
|
|
|
# Identify ansicon.exe using "ANSI" as a version number.
|
|
|
|
LINK = /link /version:20033.18771
|
|
|
|
|
2018-05-04 11:45:10 +10:00
|
|
|
X86OBJS = x86\injdll.obj x86\procrva.obj x86\proctype.obj x86\util.obj
|
|
|
|
X64OBJS = x64\injdll.obj x64\procrva.obj x64\proctype.obj x64\util.obj
|
|
|
|
X6432OBJS = x86\injdll.obj x86\procrva.obj x64\proctype32.obj x86\util.obj
|
2010-12-12 21:58:35 +10:00
|
|
|
|
2013-07-19 00:14:54 +10:00
|
|
|
!IF !DEFINED(V)
|
|
|
|
V = 0
|
|
|
|
!ENDIF
|
|
|
|
!IF $(V) == 0
|
|
|
|
CCmsg = @
|
|
|
|
RCmsg = @echo $<&
|
|
|
|
LDmsg = @echo $@&
|
|
|
|
MTmsg = @echo Embedding manifest&
|
|
|
|
!ENDIF
|
|
|
|
|
2018-04-30 11:23:34 +10:00
|
|
|
{}.c{$(DIR)}.obj::
|
|
|
|
$(CCmsg)$(CC) /c $(CFLAGS) /Fo$(DIR)\ $<
|
2010-11-15 21:51:38 +10:00
|
|
|
|
|
|
|
{}.rc{$(DIR)}.res:
|
2013-07-19 00:14:54 +10:00
|
|
|
$(RCmsg)$(RC) $(RFLAGS) /fo$@ $<
|
2010-11-15 21:51:38 +10:00
|
|
|
|
|
|
|
all: ansicon$(BITS)
|
|
|
|
|
2013-07-19 00:14:54 +10:00
|
|
|
ansicon32: x86 x86\ansicon.exe x86\ANSI32.dll x64 x64\ANSI32.dll
|
2010-11-15 21:51:38 +10:00
|
|
|
|
2012-11-24 23:41:29 +10:00
|
|
|
ansicon64: x64 x64\ansicon.exe x64\ANSI64.dll
|
2010-11-15 21:51:38 +10:00
|
|
|
|
|
|
|
x86:
|
|
|
|
mkdir x86
|
|
|
|
|
2018-05-04 11:45:10 +10:00
|
|
|
x86\ansicon.exe: x86\ansicon.obj $(X86OBJS) x86\ansicon.res
|
2014-02-05 00:21:42 +10:00
|
|
|
$(LDmsg)$(CC) /nologo $(SHARE) /Fe$@ $** $(LIBS) $(LINK) /filealign:512
|
2013-07-19 00:14:54 +10:00
|
|
|
!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
|
2014-02-05 00:21:42 +10:00
|
|
|
$(LDmsg)$(CC) /nologo $(SHARE) /LD /Fe$@ $** $(LIBS) /link \
|
2014-02-08 18:30:53 +10:00
|
|
|
/base:0xAC0000 /filealign:512
|
2013-07-19 00:14:54 +10:00
|
|
|
!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
|
|
|
|
|
2014-02-08 01:10:51 +10:00
|
|
|
x64\ansicon.exe: x64\ansicon.obj $(X64OBJS) x64\ansicon.res
|
2014-02-05 00:21:42 +10:00
|
|
|
$(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
|
2014-02-05 00:21:42 +10:00
|
|
|
$(LDmsg)$(CC) /nologo $(SHARE) /LD /Fe$@ $** $(LIBS) /link \
|
2014-02-08 18:30:53 +10:00
|
|
|
/base:0xAC000000
|
2010-11-15 21:51:38 +10:00
|
|
|
|
2018-04-30 11:06:18 +10:00
|
|
|
x64\ANSI32.dll: x64\ANSI32.obj $(X6432OBJS) x86\ansi.res
|
2014-02-05 00:21:42 +10:00
|
|
|
$(LDmsg)$(CC) /nologo $(SHARE) /LD /Fe$@ $** $(LIBS) /link \
|
2014-02-08 18:30:53 +10:00
|
|
|
/base:0xAC0000 /filealign:512 /largeaddressaware
|
2013-07-19 00:14:54 +10:00
|
|
|
!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
|
2012-06-12 14:38:00 +10:00
|
|
|
util.c: ansicon.h version.h
|
2014-02-05 00:21:42 +10:00
|
|
|
injdll.c: ansicon.h
|
2010-12-12 21:58:35 +10:00
|
|
|
proctype.c: ansicon.h
|
2014-02-08 01:10:51 +10:00
|
|
|
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
|
2013-07-19 00:14:54 +10:00
|
|
|
$(CCmsg)$(CC) /DW32ON64 /c $(CFLAGS) /Fo$@ $?
|
2014-02-05 00:21:42 +10:00
|
|
|
|
2012-04-10 15:39:58 +10:00
|
|
|
x64\proctype32.obj: proctype.c
|
2013-07-19 00:14:54 +10:00
|
|
|
$(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
|
2012-11-24 23:41:29 +10:00
|
|
|
!IF $(BITS) == 32
|
|
|
|
-del x64\ansi32.obj x64\proctype32.obj
|
|
|
|
!ENDIF
|