summaryrefslogtreecommitdiff
path: root/payloads/libpayload/curses/PDCurses-3.4/win32
diff options
context:
space:
mode:
authorPatrick Georgi <patrick.georgi@secunet.com>2011-07-07 15:41:53 +0200
committerStefan Reinauer <stefan.reinauer@coreboot.org>2011-08-04 08:10:41 +0200
commit3b77b723ca209199c8a224702812441e2196d452 (patch)
treecbf3be2c724139ec80a33dbf8e002b7871ef9307 /payloads/libpayload/curses/PDCurses-3.4/win32
parent1ac19e28eed4f6c53a4f295eb55500c65fc80f8d (diff)
libpayload: Add PDCurses and ncurses' libform/libmenu
PDCurses provides an alternative implementation of the curses library standard in addition to tinycurses. Where tinycurses is really tiny, PDCurses is more complete and provides virtually unlimited windows and the full API. The PDCurses code is brought in "vanilla", with all local changes residing in curses/pdcurses-backend/ In addition to a curses library, this change also provides libpanel (as part of the PDCurses code), and libform and libmenu which were derived from ncurses-5.9. As they rely on ncurses internals (and PDCurses is not ncurses), more changes were required for these libraries to work. The build system is extended to install the right set of header files depending on the selected curses implementation. Change-Id: I9e5b920f94b6510da01da2f656196a993170d1c5 Signed-off-by: Patrick Georgi <patrick.georgi@secunet.com> Reviewed-on: http://review.coreboot.org/106 Tested-by: build bot (Jenkins) Reviewed-by: Marc Jones <marcj303@gmail.com>
Diffstat (limited to 'payloads/libpayload/curses/PDCurses-3.4/win32')
-rw-r--r--payloads/libpayload/curses/PDCurses-3.4/win32/README76
-rw-r--r--payloads/libpayload/curses/PDCurses-3.4/win32/bccwin32.mak85
-rw-r--r--payloads/libpayload/curses/PDCurses-3.4/win32/dmcwin32.mak253
-rw-r--r--payloads/libpayload/curses/PDCurses-3.4/win32/gccwin32.mak128
-rw-r--r--payloads/libpayload/curses/PDCurses-3.4/win32/lccwin32.mak273
-rw-r--r--payloads/libpayload/curses/PDCurses-3.4/win32/mingwin32.mak121
-rw-r--r--payloads/libpayload/curses/PDCurses-3.4/win32/pdcclip.c145
-rw-r--r--payloads/libpayload/curses/PDCurses-3.4/win32/pdcdisp.c117
-rw-r--r--payloads/libpayload/curses/PDCurses-3.4/win32/pdcgetsc.c57
-rw-r--r--payloads/libpayload/curses/PDCurses-3.4/win32/pdckbd.c656
-rw-r--r--payloads/libpayload/curses/PDCurses-3.4/win32/pdcscrn.c620
-rw-r--r--payloads/libpayload/curses/PDCurses-3.4/win32/pdcsetsc.c89
-rw-r--r--payloads/libpayload/curses/PDCurses-3.4/win32/pdcurses.icobin0 -> 1078 bytes
-rw-r--r--payloads/libpayload/curses/PDCurses-3.4/win32/pdcurses.rc28
-rw-r--r--payloads/libpayload/curses/PDCurses-3.4/win32/pdcutil.c25
-rw-r--r--payloads/libpayload/curses/PDCurses-3.4/win32/pdcwin.h17
-rw-r--r--payloads/libpayload/curses/PDCurses-3.4/win32/vcwin32.mak136
-rw-r--r--payloads/libpayload/curses/PDCurses-3.4/win32/wccwin32.mak51
18 files changed, 2877 insertions, 0 deletions
diff --git a/payloads/libpayload/curses/PDCurses-3.4/win32/README b/payloads/libpayload/curses/PDCurses-3.4/win32/README
new file mode 100644
index 0000000000..bfe2ad957f
--- /dev/null
+++ b/payloads/libpayload/curses/PDCurses-3.4/win32/README
@@ -0,0 +1,76 @@
+PDCurses for Win32
+==================
+
+This directory contains PDCurses source code files specific to Win32
+console mode (Win9x/Me/NT/2k/XP/Vista).
+
+
+Building
+--------
+
+. Choose the appropriate makefile for your compiler:
+
+ bccwin32.mak - Borland C++ 4.0.2+
+ dmcwin32.mak - Digital Mars
+ gccwin32.mak - Cygnus GNU Compiler
+ lccwin32.mak - LCC-Win32
+ mingwin32.mak - MinGW
+ vcwin32.mak - Microsoft Visual C++ 2.0+
+ wccwin32.mak - Watcom 10.6+
+
+. Optionally, you can build in a different directory than the platform
+ directory by setting PDCURSES_SRCDIR to point to the directory where
+ you unpacked PDCurses, and changing to your target directory:
+
+ set PDCURSES_SRCDIR=c:\pdcurses
+
+ This won't work with the LCC or Digital Mars makefiles, nor will the
+ options described below.
+
+. Build it:
+
+ make -f makefilename
+
+ (For Watcom, use "wmake" instead of "make"; for MSVC, "nmake".) You'll
+ get the libraries (pdcurses.lib or .a, depending on your compiler; and
+ panel.lib or .a), the demos (*.exe), and a lot of object files. Note
+ that the panel library is just a copy of the main library, provided
+ for convenience; both panel and curses functions are in the main
+ library.
+
+ You can also give the optional parameter "WIDE=Y", to build the
+ library with wide-character (Unicode) support:
+
+ make -f mingwin32.mak WIDE=Y
+
+ When built this way, the library is not compatible with Windows 9x,
+ unless you also link with the Microsoft Layer for Unicode (not
+ tested).
+
+ Another option, "UTF8=Y", makes PDCurses ignore the system locale, and
+ treat all narrow-character strings as UTF-8. This option has no effect
+ unless WIDE=Y is also set. Use it to get around the poor support for
+ UTF-8 in the Win32 console:
+
+ make -f mingwin32.mak WIDE=Y UTF8=Y
+
+ You can also use the optional parameter "DLL=Y" with Visual C++,
+ MinGW or Cygwin, to build the library as a DLL:
+
+ nmake -f vcwin32.mak WIDE=Y DLL=Y
+
+ When you build the library as a Windows DLL, you must always define
+ PDCURSES_DLL_BUILD when linking against it. (Or, if you only want to
+ use the DLL, you could add this definition to your curses.h.)
+
+
+Distribution Status
+-------------------
+
+The files in this directory are released to the Public Domain.
+
+
+Acknowledgements
+----------------
+
+Generic Win32 port was provided by Chris Szurgot <szurgot@itribe.net>
diff --git a/payloads/libpayload/curses/PDCurses-3.4/win32/bccwin32.mak b/payloads/libpayload/curses/PDCurses-3.4/win32/bccwin32.mak
new file mode 100644
index 0000000000..229ab4be5c
--- /dev/null
+++ b/payloads/libpayload/curses/PDCurses-3.4/win32/bccwin32.mak
@@ -0,0 +1,85 @@
+# Borland MAKE Makefile for PDCurses library - Win32 BC++ 4.0+
+#
+# Usage: make -f [path\]bccwin32.mak [DEBUG=] [WIDE=] [UTF8=] [target]
+#
+# where target can be any of:
+# [all|demos|pdcurses.lib|testcurs.exe...]
+
+O = obj
+
+!ifndef PDCURSES_SRCDIR
+PDCURSES_SRCDIR = ..
+!endif
+
+!include $(PDCURSES_SRCDIR)\version.mif
+!include $(PDCURSES_SRCDIR)\libobjs.mif
+
+osdir = $(PDCURSES_SRCDIR)\win32
+
+CC = bcc32 -q
+
+!ifdef DEBUG
+CFLAGS = -N -v -y -DPDCDEBUG
+!else
+CFLAGS = -O
+!endif
+
+!ifdef WIDE
+WIDEOPT = -DPDC_WIDE
+!endif
+
+!ifdef UTF8
+UTF8OPT = -DPDC_FORCE_UTF8
+!endif
+
+BUILD = $(CC) -I$(PDCURSES_SRCDIR) -c -Tpe -w32 $(CFLAGS) -w-par \
+$(WIDEOPT) $(UTF8OPT)
+
+LIBEXE = tlib /C /E /0 /a
+
+LIBCURSES = pdcurses.lib
+
+all: $(LIBCURSES) $(DEMOS)
+
+clean:
+ -del *.obj
+ -del *.lib
+ -del *.tds
+ -del *.exe
+
+$(LIBCURSES) : $(LIBOBJS) $(PDCOBJS)
+ -del $@
+ $(LIBEXE) $@ $(LIBOBJS) $(PDCOBJS)
+ -copy $(LIBCURSES) panel.lib
+
+.autodepend
+
+{$(srcdir)\}.c.obj:
+ $(BUILD) $<
+
+{$(osdir)\}.c.obj:
+ $(BUILD) $<
+
+{$(demodir)\}.c.obj:
+ $(BUILD) $<
+
+.c.obj:
+ $(BUILD) $<
+
+.obj.exe:
+ $(CC) -e$@ $** $(LIBCURSES)
+
+tuidemo.exe: tuidemo.obj tui.obj $(LIBCURSES)
+ $(CC) -e$@ $**
+
+tui.obj: $(demodir)\tui.c $(demodir)\tui.h $(PDCURSES_CURSES_H)
+ $(BUILD) -I$(demodir) $(demodir)\tui.c
+
+tuidemo.obj: $(demodir)\tuidemo.c $(PDCURSES_CURSES_H)
+ $(BUILD) -I$(demodir) $(demodir)\tuidemo.c
+
+PLATFORM1 = Borland C++ Win32
+PLATFORM2 = Borland C/C++ 5.5 for Win32
+ARCNAME = pdc$(VER)_bcc_w32
+
+!include $(PDCURSES_SRCDIR)\makedist.mif
diff --git a/payloads/libpayload/curses/PDCurses-3.4/win32/dmcwin32.mak b/payloads/libpayload/curses/PDCurses-3.4/win32/dmcwin32.mak
new file mode 100644
index 0000000000..23522cc94f
--- /dev/null
+++ b/payloads/libpayload/curses/PDCurses-3.4/win32/dmcwin32.mak
@@ -0,0 +1,253 @@
+# Makefile for PDCurses library - WIN32 Digital Mars
+#
+# Usage: make -f dmcwin32.mak [target]
+#
+# where target can be any of:
+# [all|demos|pdcurses.lib|testcurs.exe...]
+
+PDCURSES_SRCDIR = ..
+
+PDCURSES_CURSES_H = $(PDCURSES_SRCDIR)\curses.h
+PDCURSES_CURSPRIV_H = $(PDCURSES_SRCDIR)\curspriv.h
+PDCURSES_HEADERS = $(PDCURSES_CURSES_H) $(PDCURSES_CURSPRIV_H)
+
+PANEL_HEADER = $(PDCURSES_SRCDIR)\panel.h
+TERM_HEADER = $(PDCURSES_SRCDIR)\term.h
+
+srcdir = $(PDCURSES_SRCDIR)\pdcurses
+osdir = $(PDCURSES_SRCDIR)\win32
+demodir = $(PDCURSES_SRCDIR)\demos
+
+PDCURSES_WIN_H = $(osdir)\pdcwin.h
+
+CC = dmc
+
+CFLAGS = -c -o+space -Nc
+
+CPPFLAGS = -I$(PDCURSES_SRCDIR) #-DPDC_WIDE -DPDC_FORCE_UTF8
+
+LINK = dmc
+LIBEXE = lib
+
+LIBCURSES = pdcurses.lib
+
+BUILD = $(CC) $(CFLAGS) $(CPPFLAGS)
+
+DEMOS = testcurs.exe newdemo.exe xmas.exe tuidemo.exe \
+firework.exe ptest.exe rain.exe worm.exe
+
+all: $(LIBCURSES) $(DEMOS)
+
+clean:
+ -del *.obj
+ -del *.lib
+ -del *.exe
+ -del *.map
+ -del advapi32.def
+
+LIBOBJS = addch.obj addchstr.obj addstr.obj attr.obj beep.obj bkgd.obj \
+border.obj clear.obj color.obj delch.obj deleteln.obj deprec.obj getch.obj \
+getstr.obj getyx.obj inch.obj inchstr.obj initscr.obj inopts.obj \
+insch.obj insstr.obj instr.obj kernel.obj keyname.obj mouse.obj move.obj \
+outopts.obj overlay.obj pad.obj panel.obj printw.obj refresh.obj \
+scanw.obj scr_dump.obj scroll.obj slk.obj termattr.obj terminfo.obj \
+touch.obj util.obj window.obj debug.obj
+
+PDCOBJS = pdcclip.obj pdcdisp.obj pdcgetsc.obj pdckbd.obj pdcscrn.obj \
+pdcsetsc.obj pdcutil.obj
+
+DEMOOBJS = testcurs.obj newdemo.obj xmas.obj tuidemo.obj tui.obj \
+firework.obj ptest.obj rain.obj worm.obj
+
+$(LIBOBJS) $(PDCOBJS) : $(PDCURSES_HEADERS)
+$(PDCOBJS) : $(PDCURSES_WIN_H)
+panel.obj ptest.obj: $(PANEL_HEADER)
+terminfo.obj: $(TERM_HEADER)
+
+$(DEMOOBJS) : $(PDCURSES_CURSES_H)
+$(DEMOS) : $(LIBCURSES)
+
+$(LIBCURSES) : $(LIBOBJS) $(PDCOBJS)
+ $(LIBEXE) -c $@ $(LIBOBJS) $(PDCOBJS)
+ -copy $(LIBCURSES) panel.lib
+
+SRCBUILD = $(BUILD) $(srcdir)\$*.c
+OSBUILD = $(BUILD) $(osdir)\$*.c
+DEMOBUILD = $(LINK) $(CPPFLAGS) -o+space $@ $**
+
+addch.obj: $(srcdir)\addch.c
+ $(SRCBUILD)
+
+addchstr.obj: $(srcdir)\addchstr.c
+ $(SRCBUILD)
+
+addstr.obj: $(srcdir)\addstr.c
+ $(SRCBUILD)
+
+attr.obj: $(srcdir)\attr.c
+ $(SRCBUILD)
+
+beep.obj: $(srcdir)\beep.c
+ $(SRCBUILD)
+
+bkgd.obj: $(srcdir)\bkgd.c
+ $(SRCBUILD)
+
+border.obj: $(srcdir)\border.c
+ $(SRCBUILD)
+
+clear.obj: $(srcdir)\clear.c
+ $(SRCBUILD)
+
+color.obj: $(srcdir)\color.c
+ $(SRCBUILD)
+
+delch.obj: $(srcdir)\delch.c
+ $(SRCBUILD)
+
+deleteln.obj: $(srcdir)\deleteln.c
+ $(SRCBUILD)
+
+deprec.obj: $(srcdir)\deprec.c
+ $(SRCBUILD)
+
+getch.obj: $(srcdir)\getch.c
+ $(SRCBUILD)
+
+getstr.obj: $(srcdir)\getstr.c
+ $(SRCBUILD)
+
+getyx.obj: $(srcdir)\getyx.c
+ $(SRCBUILD)
+
+inch.obj: $(srcdir)\inch.c
+ $(SRCBUILD)
+
+inchstr.obj: $(srcdir)\inchstr.c
+ $(SRCBUILD)
+
+initscr.obj: $(srcdir)\initscr.c
+ $(SRCBUILD)
+
+inopts.obj: $(srcdir)\inopts.c
+ $(SRCBUILD)
+
+insch.obj: $(srcdir)\insch.c
+ $(SRCBUILD)
+
+insstr.obj: $(srcdir)\insstr.c
+ $(SRCBUILD)
+
+instr.obj: $(srcdir)\instr.c
+ $(SRCBUILD)
+
+kernel.obj: $(srcdir)\kernel.c
+ $(SRCBUILD)
+
+keyname.obj: $(srcdir)\keyname.c
+ $(SRCBUILD)
+
+mouse.obj: $(srcdir)\mouse.c
+ $(SRCBUILD)
+
+move.obj: $(srcdir)\move.c
+ $(SRCBUILD)
+
+outopts.obj: $(srcdir)\outopts.c
+ $(SRCBUILD)
+
+overlay.obj: $(srcdir)\overlay.c
+ $(SRCBUILD)
+
+pad.obj: $(srcdir)\pad.c
+ $(SRCBUILD)
+
+panel.obj: $(srcdir)\panel.c
+ $(SRCBUILD)
+
+printw.obj: $(srcdir)\printw.c
+ $(SRCBUILD)
+
+refresh.obj: $(srcdir)\refresh.c
+ $(SRCBUILD)
+
+scanw.obj: $(srcdir)\scanw.c
+ $(SRCBUILD)
+
+scr_dump.obj: $(srcdir)\scr_dump.c
+ $(SRCBUILD)
+
+scroll.obj: $(srcdir)\scroll.c
+ $(SRCBUILD)
+
+slk.obj: $(srcdir)\slk.c
+ $(SRCBUILD)
+
+termattr.obj: $(srcdir)\termattr.c
+ $(SRCBUILD)
+
+terminfo.obj: $(srcdir)\terminfo.c
+ $(SRCBUILD)
+
+touch.obj: $(srcdir)\touch.c
+ $(SRCBUILD)
+
+util.obj: $(srcdir)\util.c
+ $(SRCBUILD)
+
+window.obj: $(srcdir)\window.c
+ $(SRCBUILD)
+
+debug.obj: $(srcdir)\debug.c
+ $(SRCBUILD)
+
+pdcclip.obj: $(osdir)\pdcclip.c
+ $(OSBUILD)
+
+pdcdisp.obj: $(osdir)\pdcdisp.c
+ $(OSBUILD)
+
+pdcgetsc.obj: $(osdir)\pdcgetsc.c
+ $(OSBUILD)
+
+pdckbd.obj: $(osdir)\pdckbd.c
+ $(OSBUILD)
+
+pdcscrn.obj: $(osdir)\pdcscrn.c
+ $(OSBUILD)
+
+pdcsetsc.obj: $(osdir)\pdcsetsc.c
+ $(OSBUILD)
+
+pdcutil.obj: $(osdir)\pdcutil.c
+ $(OSBUILD)
+
+firework.exe: $(demodir)\firework.c
+ $(DEMOBUILD)
+
+newdemo.exe: $(demodir)\newdemo.c
+ $(DEMOBUILD)
+
+ptest.exe: $(demodir)\ptest.c
+ $(DEMOBUILD)
+
+rain.exe: $(demodir)\rain.c
+ $(DEMOBUILD)
+
+testcurs.exe: $(demodir)\testcurs.c
+ $(DEMOBUILD) advapi32.lib
+
+tuidemo.exe: tuidemo.obj tui.obj
+ $(DEMOBUILD)
+
+worm.exe: $(demodir)\worm.c
+ $(DEMOBUILD)
+
+xmas.exe: $(demodir)\xmas.c
+ $(DEMOBUILD)
+
+tui.obj: $(demodir)\tui.c $(demodir)\tui.h
+ $(BUILD) -I$(demodir) $(demodir)\$*.c
+
+tuidemo.obj: $(demodir)\tuidemo.c
+ $(BUILD) -I$(demodir) $(demodir)\$*.c
diff --git a/payloads/libpayload/curses/PDCurses-3.4/win32/gccwin32.mak b/payloads/libpayload/curses/PDCurses-3.4/win32/gccwin32.mak
new file mode 100644
index 0000000000..7504bb34fa
--- /dev/null
+++ b/payloads/libpayload/curses/PDCurses-3.4/win32/gccwin32.mak
@@ -0,0 +1,128 @@
+# GNU MAKE Makefile for PDCurses library - WIN32 Cygnus GCC
+#
+# Usage: make -f [path\]gccwin32.mak [DEBUG=Y] [DLL=Y] [WIDE=Y] [UTF8=Y] [tgt]
+#
+# where tgt can be any of:
+# [all|demos|pdcurses.a|testcurs.exe...]
+
+O = o
+
+ifndef PDCURSES_SRCDIR
+ PDCURSES_SRCDIR = ..
+endif
+
+include $(PDCURSES_SRCDIR)/version.mif
+include $(PDCURSES_SRCDIR)/libobjs.mif
+
+osdir = $(PDCURSES_SRCDIR)/win32
+
+PDCURSES_WIN_H = $(osdir)/pdcwin.h
+
+CC = gcc
+
+ifeq ($(DEBUG),Y)
+ CFLAGS = -g -Wall -DPDCDEBUG
+ LDFLAGS = -g
+else
+ CFLAGS = -O2 -Wall
+ LDFLAGS =
+endif
+
+CFLAGS += -I$(PDCURSES_SRCDIR)
+
+BASEDEF = $(PDCURSES_SRCDIR)/exp-base.def
+WIDEDEF = $(PDCURSES_SRCDIR)/exp-wide.def
+
+DEFDEPS = $(BASEDEF)
+
+ifeq ($(WIDE),Y)
+ CFLAGS += -DPDC_WIDE
+ DEFDEPS += $(WIDEDEF)
+endif
+
+ifeq ($(UTF8),Y)
+ CFLAGS += -DPDC_FORCE_UTF8
+endif
+
+DEFFILE = pdcurses.def
+
+LINK = gcc
+
+ifeq ($(DLL),Y)
+ CFLAGS += -DPDC_DLL_BUILD
+ LIBEXE = gcc $(DEFFILE)
+ LIBFLAGS = -Wl,--out-implib,pdcurses.a -shared -o
+ LIBCURSES = pdcurses.dll
+ LIBDEPS = $(LIBOBJS) $(PDCOBJS) $(DEFFILE)
+ CLEAN = $(LIBCURSES) *.a $(DEFFILE)
+else
+ LIBEXE = ar
+ LIBFLAGS = rcv
+ LIBCURSES = pdcurses.a
+ LIBDEPS = $(LIBOBJS) $(PDCOBJS)
+ CLEAN = *.a
+endif
+
+.PHONY: all libs clean demos dist
+
+all: libs demos
+
+libs: $(LIBCURSES)
+
+clean:
+ -rm -f *.o
+ -rm -f *.exe
+ -rm -f $(CLEAN)
+
+demos: $(DEMOS)
+ strip *.exe
+
+$(DEFFILE): $(DEFDEPS)
+ echo LIBRARY pdcurses > $@
+ echo EXPORTS >> $@
+ cat $(BASEDEF) >> $@
+ifeq ($(WIDE),Y)
+ cat $(WIDEDEF) >> $@
+endif
+
+$(LIBCURSES) : $(LIBDEPS)
+ $(LIBEXE) $(LIBFLAGS) $@ $?
+ -cp pdcurses.a panel.a
+
+$(LIBOBJS) $(PDCOBJS) : $(PDCURSES_HEADERS)
+$(PDCOBJS) : $(PDCURSES_WIN_H)
+$(DEMOS) : $(PDCURSES_CURSES_H) $(LIBCURSES)
+panel.o : $(PANEL_HEADER)
+terminfo.o: $(TERM_HEADER)
+
+$(LIBOBJS) : %.o: $(srcdir)/%.c
+ $(CC) -c $(CFLAGS) $<
+
+$(PDCOBJS) : %.o: $(osdir)/%.c
+ $(CC) -c $(CFLAGS) $<
+
+firework.exe newdemo.exe rain.exe testcurs.exe worm.exe xmas.exe \
+ptest.exe: %.exe: $(demodir)/%.c
+ $(CC) $(CFLAGS) -o$@ $< $(LIBCURSES)
+
+tuidemo.exe: tuidemo.o tui.o
+ $(LINK) $(LDFLAGS) -o$@ tuidemo.o tui.o $(LIBCURSES)
+
+tui.o: $(demodir)/tui.c $(demodir)/tui.h $(PDCURSES_CURSES_H)
+ $(CC) -c $(CFLAGS) -I$(demodir) -o$@ $<
+
+tuidemo.o: $(demodir)/tuidemo.c $(PDCURSES_CURSES_H)
+ $(CC) -c $(CFLAGS) -I$(demodir) -o$@ $<
+
+dist: $(PDCLIBS)
+ echo PDCurses $(VERDOT) for Cygnus Win32 > file_id.diz
+ echo ------------------------------------------ >> file_id.diz
+ echo Public Domain Curses library for >> file_id.diz
+ echo Cygnus GCC for Win32. >> file_id.diz
+ echo Source available in PDCURS$(VER).ZIP >> file_id.diz
+ echo Public Domain. >> file_id.diz
+ zip -9jX pdc$(VER)_cyg_w32 \
+ $(PDCURSES_SRCDIR)/README $(PDCURSES_SRCDIR)/HISTORY \
+ $(PDCURSES_SRCDIR)/curses.h $(PDCURSES_SRCDIR)/panel.h \
+ $(LIBCURSES) $(LIBPANEL) file_id.diz
+ rm file_id.diz
diff --git a/payloads/libpayload/curses/PDCurses-3.4/win32/lccwin32.mak b/payloads/libpayload/curses/PDCurses-3.4/win32/lccwin32.mak
new file mode 100644
index 0000000000..90c1c894d1
--- /dev/null
+++ b/payloads/libpayload/curses/PDCurses-3.4/win32/lccwin32.mak
@@ -0,0 +1,273 @@
+# Makefile for PDCurses library - WIN32 LCC-Win32
+#
+# Usage: make -f lccwin32.mak [target]
+#
+# where target can be any of:
+# [all|demos|pdcurses.lib|testcurs.exe...]
+
+PDCURSES_SRCDIR = ..
+
+PDCURSES_CURSES_H = $(PDCURSES_SRCDIR)\curses.h
+PDCURSES_CURSPRIV_H = $(PDCURSES_SRCDIR)\curspriv.h
+PDCURSES_HEADERS = $(PDCURSES_CURSES_H) $(PDCURSES_CURSPRIV_H)
+
+PANEL_HEADER = $(PDCURSES_SRCDIR)\panel.h
+TERM_HEADER = $(PDCURSES_SRCDIR)\term.h
+
+srcdir = $(PDCURSES_SRCDIR)\pdcurses
+osdir = $(PDCURSES_SRCDIR)\win32
+demodir = $(PDCURSES_SRCDIR)\demos
+
+PDCURSES_WIN_H = $(osdir)\pdcwin.h
+
+CC = lcc
+
+#CFLAGS = -c -g3 -A -ansic
+CFLAGS = -c -O -A -ansic
+
+CPPFLAGS = -I$(PDCURSES_SRCDIR) #-DPDC_WIDE -DPDC_FORCE_UTF8
+
+LINK = lcclnk
+LIBEXE = lcclib
+
+LIBCURSES = pdcurses.lib
+
+BUILD = $(CC) $(CFLAGS) $(CPPFLAGS)
+PDCLIBS = $(LIBCURSES)
+
+DEMOS = testcurs.exe newdemo.exe xmas.exe tuidemo.exe \
+firework.exe ptest.exe rain.exe worm.exe
+
+all: $(PDCLIBS) $(DEMOS)
+
+clean:
+ -del *.obj
+ -del *.lib
+ -del *.exe
+
+LIBOBJS = addch.obj addchstr.obj addstr.obj attr.obj beep.obj bkgd.obj \
+border.obj clear.obj color.obj delch.obj deleteln.obj deprec.obj getch.obj \
+getstr.obj getyx.obj inch.obj inchstr.obj initscr.obj inopts.obj \
+insch.obj insstr.obj instr.obj kernel.obj keyname.obj mouse.obj move.obj \
+outopts.obj overlay.obj pad.obj panel.obj printw.obj refresh.obj \
+scanw.obj scr_dump.obj scroll.obj slk.obj termattr.obj terminfo.obj \
+touch.obj util.obj window.obj debug.obj
+
+PDCOBJS = pdcclip.obj pdcdisp.obj pdcgetsc.obj pdckbd.obj pdcscrn.obj \
+pdcsetsc.obj pdcutil.obj
+
+DEMOOBJS = testcurs.obj newdemo.obj xmas.obj tuidemo.obj tui.obj \
+firework.obj ptest.obj rain.obj worm.obj
+
+$(LIBOBJS) $(PDCOBJS) : $(PDCURSES_HEADERS)
+$(PDCOBJS) : $(PDCURSES_WIN_H)
+panel.obj ptest.obj: $(PANEL_HEADER)
+terminfo.obj: $(TERM_HEADER)
+
+$(DEMOOBJS) : $(PDCURSES_CURSES_H)
+$(DEMOS) : $(LIBCURSES)
+
+$(LIBCURSES) : $(LIBOBJS) $(PDCOBJS)
+ $(LIBEXE) /out:$@ $(LIBOBJS) $(PDCOBJS)
+ -copy $(LIBCURSES) panel.lib
+
+SRCBUILD = $(BUILD) $(srcdir)\$*.c
+OSBUILD = $(BUILD) $(osdir)\$*.c
+
+addch.obj: $(srcdir)\addch.c
+ $(SRCBUILD)
+
+addchstr.obj: $(srcdir)\addchstr.c
+ $(SRCBUILD)
+
+addstr.obj: $(srcdir)\addstr.c
+ $(SRCBUILD)
+
+attr.obj: $(srcdir)\attr.c
+ $(SRCBUILD)
+
+beep.obj: $(srcdir)\beep.c
+ $(SRCBUILD)
+
+bkgd.obj: $(srcdir)\bkgd.c
+ $(SRCBUILD)
+
+border.obj: $(srcdir)\border.c
+ $(SRCBUILD)
+
+clear.obj: $(srcdir)\clear.c
+ $(SRCBUILD)
+
+color.obj: $(srcdir)\color.c
+ $(SRCBUILD)
+
+delch.obj: $(srcdir)\delch.c
+ $(SRCBUILD)
+
+deleteln.obj: $(srcdir)\deleteln.c
+ $(SRCBUILD)
+
+deprec.obj: $(srcdir)\deprec.c
+ $(SRCBUILD)
+
+getch.obj: $(srcdir)\getch.c
+ $(SRCBUILD)
+
+getstr.obj: $(srcdir)\getstr.c
+ $(SRCBUILD)
+
+getyx.obj: $(srcdir)\getyx.c
+ $(SRCBUILD)
+
+inch.obj: $(srcdir)\inch.c
+ $(SRCBUILD)
+
+inchstr.obj: $(srcdir)\inchstr.c
+ $(SRCBUILD)
+
+initscr.obj: $(srcdir)\initscr.c
+ $(SRCBUILD)
+
+inopts.obj: $(srcdir)\inopts.c
+ $(SRCBUILD)
+
+insch.obj: $(srcdir)\insch.c
+ $(SRCBUILD)
+
+insstr.obj: $(srcdir)\insstr.c
+ $(SRCBUILD)
+
+instr.obj: $(srcdir)\instr.c
+ $(SRCBUILD)
+
+kernel.obj: $(srcdir)\kernel.c
+ $(SRCBUILD)
+
+keyname.obj: $(srcdir)\keyname.c
+ $(SRCBUILD)
+
+mouse.obj: $(srcdir)\mouse.c
+ $(SRCBUILD)
+
+move.obj: $(srcdir)\move.c
+ $(SRCBUILD)
+
+outopts.obj: $(srcdir)\outopts.c
+ $(SRCBUILD)
+
+overlay.obj: $(srcdir)\overlay.c
+ $(SRCBUILD)
+
+pad.obj: $(srcdir)\pad.c
+ $(SRCBUILD)
+
+panel.obj: $(srcdir)\panel.c
+ $(SRCBUILD)
+
+printw.obj: $(srcdir)\printw.c
+ $(SRCBUILD)
+
+refresh.obj: $(srcdir)\refresh.c
+ $(SRCBUILD)
+
+scanw.obj: $(srcdir)\scanw.c
+ $(SRCBUILD)
+
+scr_dump.obj: $(srcdir)\scr_dump.c
+ $(SRCBUILD)
+
+scroll.obj: $(srcdir)\scroll.c
+ $(SRCBUILD)
+
+slk.obj: $(srcdir)\slk.c
+ $(SRCBUILD)
+
+termattr.obj: $(srcdir)\termattr.c
+ $(SRCBUILD)
+
+terminfo.obj: $(srcdir)\terminfo.c
+ $(SRCBUILD)
+
+touch.obj: $(srcdir)\touch.c
+ $(SRCBUILD)
+
+util.obj: $(srcdir)\util.c
+ $(SRCBUILD)
+
+window.obj: $(srcdir)\window.c
+ $(SRCBUILD)
+
+debug.obj: $(srcdir)\debug.c
+ $(SRCBUILD)
+
+pdcclip.obj: $(osdir)\pdcclip.c
+ $(OSBUILD)
+
+pdcdisp.obj: $(osdir)\pdcdisp.c
+ $(OSBUILD)
+
+pdcgetsc.obj: $(osdir)\pdcgetsc.c
+ $(OSBUILD)
+
+pdckbd.obj: $(osdir)\pdckbd.c
+ $(OSBUILD)
+
+pdcscrn.obj: $(osdir)\pdcscrn.c
+ $(OSBUILD)
+
+pdcsetsc.obj: $(osdir)\pdcsetsc.c
+ $(OSBUILD)
+
+pdcutil.obj: $(osdir)\pdcutil.c
+ $(OSBUILD)
+
+firework.exe: firework.obj
+ $(LINK) -o $@ firework.obj $(LIBCURSES)
+
+newdemo.exe: newdemo.obj
+ $(LINK) -o $@ newdemo.obj $(LIBCURSES)
+
+ptest.exe: ptest.obj
+ $(LINK) -o $@ ptest.obj $(LIBCURSES)
+
+rain.exe: rain.obj
+ $(LINK) -o $@ rain.obj $(LIBCURSES)
+
+testcurs.exe: testcurs.obj
+ $(LINK) -o $@ testcurs.obj $(LIBCURSES)
+
+tuidemo.exe: tuidemo.obj tui.obj
+ $(LINK) -o $@ tuidemo.obj tui.obj $(LIBCURSES)
+
+worm.exe: worm.obj
+ $(LINK) -o $@ worm.obj $(LIBCURSES)
+
+xmas.exe: xmas.obj
+ $(LINK) -o $@ xmas.obj $(LIBCURSES)
+
+firework.obj: $(demodir)\firework.c
+ $(BUILD) $(demodir)\$*.c
+
+newdemo.obj: $(demodir)\newdemo.c
+ $(BUILD) $(demodir)\$*.c
+
+ptest.obj: $(demodir)\ptest.c
+ $(BUILD) $(demodir)\$*.c
+
+rain.obj: $(demodir)\rain.c
+ $(BUILD) $(demodir)\$*.c
+
+testcurs.obj: $(demodir)\testcurs.c
+ $(BUILD) $(demodir)\$*.c
+
+tui.obj: $(demodir)\tui.c $(demodir)\tui.h
+ $(BUILD) -I$(demodir) $(demodir)\$*.c
+
+tuidemo.obj: $(demodir)\tuidemo.c
+ $(BUILD) -I$(demodir) $(demodir)\$*.c
+
+worm.obj: $(demodir)\worm.c
+ $(BUILD) $(demodir)\$*.c
+
+xmas.obj: $(demodir)\xmas.c
+ $(BUILD) $(demodir)\$*.c
diff --git a/payloads/libpayload/curses/PDCurses-3.4/win32/mingwin32.mak b/payloads/libpayload/curses/PDCurses-3.4/win32/mingwin32.mak
new file mode 100644
index 0000000000..7fb17e8fc8
--- /dev/null
+++ b/payloads/libpayload/curses/PDCurses-3.4/win32/mingwin32.mak
@@ -0,0 +1,121 @@
+# GNU MAKE Makefile for PDCurses library - WIN32 MinGW GCC
+#
+# Usage: make -f [path\]mingwin32.mak [DEBUG=Y] [DLL=Y] [WIDE=Y] [UTF8=Y] [tgt]
+#
+# where tgt can be any of:
+# [all|demos|pdcurses.a|testcurs.exe...]
+
+O = o
+
+ifndef PDCURSES_SRCDIR
+ PDCURSES_SRCDIR = ..
+endif
+
+include $(PDCURSES_SRCDIR)/version.mif
+include $(PDCURSES_SRCDIR)/libobjs.mif
+
+osdir = $(PDCURSES_SRCDIR)/win32
+
+PDCURSES_WIN_H = $(osdir)/pdcwin.h
+
+CC = gcc
+
+ifeq ($(DEBUG),Y)
+ CFLAGS = -g -Wall -DPDCDEBUG
+ LDFLAGS = -g
+else
+ CFLAGS = -O2 -Wall
+ LDFLAGS =
+endif
+
+CFLAGS += -I$(PDCURSES_SRCDIR)
+
+BASEDEF = $(PDCURSES_SRCDIR)\exp-base.def
+WIDEDEF = $(PDCURSES_SRCDIR)\exp-wide.def
+
+DEFDEPS = $(BASEDEF)
+
+ifeq ($(WIDE),Y)
+ CFLAGS += -DPDC_WIDE
+ DEFDEPS += $(WIDEDEF)
+endif
+
+ifeq ($(UTF8),Y)
+ CFLAGS += -DPDC_FORCE_UTF8
+endif
+
+DEFFILE = pdcurses.def
+
+LINK = gcc
+
+ifeq ($(DLL),Y)
+ CFLAGS += -DPDC_DLL_BUILD
+ LIBEXE = gcc $(DEFFILE)
+ LIBFLAGS = -Wl,--out-implib,pdcurses.a -shared -o
+ LIBCURSES = pdcurses.dll
+ LIBDEPS = $(LIBOBJS) $(PDCOBJS) $(DEFFILE)
+ CLEAN = $(LIBCURSES) *.a $(DEFFILE)
+else
+ LIBEXE = ar
+ LIBFLAGS = rcv
+ LIBCURSES = pdcurses.a
+ LIBDEPS = $(LIBOBJS) $(PDCOBJS)
+ CLEAN = *.a
+endif
+
+.PHONY: all libs clean demos dist
+
+all: libs demos
+
+libs: $(LIBCURSES)
+
+clean:
+ -del *.o
+ -del *.exe
+ -del $(CLEAN)
+
+demos: $(DEMOS)
+ strip *.exe
+
+$(DEFFILE): $(DEFDEPS)
+ echo LIBRARY pdcurses > $@
+ echo EXPORTS >> $@
+ type $(BASEDEF) >> $@
+ifeq ($(WIDE),Y)
+ type $(WIDEDEF) >> $@
+endif
+
+$(LIBCURSES) : $(LIBDEPS)
+ $(LIBEXE) $(LIBFLAGS) $@ $?
+ -copy pdcurses.a panel.a
+
+$(LIBOBJS) $(PDCOBJS) : $(PDCURSES_HEADERS)
+$(PDCOBJS) : $(PDCURSES_WIN_H)
+$(DEMOS) : $(PDCURSES_CURSES_H) $(LIBCURSES)
+panel.o : $(PANEL_HEADER)
+terminfo.o: $(TERM_HEADER)
+
+$(LIBOBJS) : %.o: $(srcdir)/%.c
+ $(CC) -c $(CFLAGS) $<
+
+$(PDCOBJS) : %.o: $(osdir)/%.c
+ $(CC) -c $(CFLAGS) $<
+
+firework.exe newdemo.exe rain.exe testcurs.exe worm.exe xmas.exe \
+ptest.exe: %.exe: $(demodir)/%.c
+ $(CC) $(CFLAGS) -o$@ $< $(LIBCURSES)
+
+tuidemo.exe: tuidemo.o tui.o
+ $(LINK) $(LDFLAGS) -o$@ tuidemo.o tui.o $(LIBCURSES)
+
+tui.o: $(demodir)/tui.c $(demodir)/tui.h $(PDCURSES_CURSES_H)
+ $(CC) -c $(CFLAGS) -I$(demodir) -o$@ $<
+
+tuidemo.o: $(demodir)/tuidemo.c $(PDCURSES_CURSES_H)
+ $(CC) -c $(CFLAGS) -I$(demodir) -o$@ $<
+
+PLATFORM1 = MinGW Win32
+PLATFORM2 = MinGW for Win32
+ARCNAME = pdc$(VER)_ming_w32
+
+include $(PDCURSES_SRCDIR)/makedist.mif
diff --git a/payloads/libpayload/curses/PDCurses-3.4/win32/pdcclip.c b/payloads/libpayload/curses/PDCurses-3.4/win32/pdcclip.c
new file mode 100644
index 0000000000..35b6bba514
--- /dev/null
+++ b/payloads/libpayload/curses/PDCurses-3.4/win32/pdcclip.c
@@ -0,0 +1,145 @@
+/* Public Domain Curses */
+
+#include "pdcwin.h"
+
+RCSID("$Id: pdcclip.c,v 1.30 2008/07/14 04:24:52 wmcbrine Exp $")
+
+/*man-start**************************************************************
+
+ Name: clipboard
+
+ Synopsis:
+ int PDC_getclipboard(char **contents, long *length);
+ int PDC_setclipboard(const char *contents, long length);
+ int PDC_freeclipboard(char *contents);
+ int PDC_clearclipboard(void);
+
+ Description:
+ PDC_getclipboard() gets the textual contents of the system's
+ clipboard. This function returns the contents of the clipboard
+ in the contents argument. It is the responsibilitiy of the
+ caller to free the memory returned, via PDC_freeclipboard().
+ The length of the clipboard contents is returned in the length
+ argument.
+
+ PDC_setclipboard copies the supplied text into the system's
+ clipboard, emptying the clipboard prior to the copy.
+
+ PDC_clearclipboard() clears the internal clipboard.
+
+ Return Values:
+ indicator of success/failure of call.
+ PDC_CLIP_SUCCESS the call was successful
+ PDC_CLIP_MEMORY_ERROR unable to allocate sufficient memory for
+ the clipboard contents
+ PDC_CLIP_EMPTY the clipboard contains no text
+ PDC_CLIP_ACCESS_ERROR no clipboard support
+
+ Portability X/Open BSD SYS V
+ PDC_getclipboard - - -
+ PDC_setclipboard - - -
+ PDC_freeclipboard - - -
+ PDC_clearclipboard - - -
+
+**man-end****************************************************************/
+
+#ifdef PDC_WIDE
+# define PDC_TEXT CF_UNICODETEXT
+#else
+# define PDC_TEXT CF_OEMTEXT
+#endif
+
+int PDC_getclipboard(char **contents, long *length)
+{
+ HANDLE handle;
+ long len;
+
+ PDC_LOG(("PDC_getclipboard() - called\n"));
+
+ if (!OpenClipboard(NULL))
+ return PDC_CLIP_ACCESS_ERROR;
+
+ if ((handle = GetClipboardData(PDC_TEXT)) == NULL)
+ {
+ CloseClipboard();
+ return PDC_CLIP_EMPTY;
+ }
+
+#ifdef PDC_WIDE
+ len = wcslen((wchar_t *)handle) * 3;
+#else
+ len = strlen((char *)handle);
+#endif
+ *contents = (char *)GlobalAlloc(GMEM_FIXED, len + 1);
+
+ if (!*contents)
+ {
+ CloseClipboard();
+ return PDC_CLIP_MEMORY_ERROR;
+ }
+
+#ifdef PDC_WIDE
+ len = PDC_wcstombs((char *)*contents, (wchar_t *)handle, len);
+#else
+ strcpy((char *)*contents, (char *)handle);
+#endif
+ *length = len;
+ CloseClipboard();
+
+ return PDC_CLIP_SUCCESS;
+}
+
+int PDC_setclipboard(const char *contents, long length)
+{
+ HGLOBAL ptr1;
+ LPTSTR ptr2;
+
+ PDC_LOG(("PDC_setclipboard() - called\n"));
+
+ if (!OpenClipboard(NULL))
+ return PDC_CLIP_ACCESS_ERROR;
+
+ ptr1 = GlobalAlloc(GMEM_MOVEABLE|GMEM_DDESHARE,
+ (length + 1) * sizeof(TCHAR));
+
+ if (!ptr1)
+ return PDC_CLIP_MEMORY_ERROR;
+
+ ptr2 = GlobalLock(ptr1);
+
+#ifdef PDC_WIDE
+ PDC_mbstowcs((wchar_t *)ptr2, contents, length);
+#else
+ memcpy((char *)ptr2, contents, length + 1);
+#endif
+ GlobalUnlock(ptr1);
+ EmptyClipboard();
+
+ if (!SetClipboardData(PDC_TEXT, ptr1))
+ {
+ GlobalFree(ptr1);
+ return PDC_CLIP_ACCESS_ERROR;
+ }
+
+ CloseClipboard();
+ GlobalFree(ptr1);
+
+ return PDC_CLIP_SUCCESS;
+}
+
+int PDC_freeclipboard(char *contents)
+{
+ PDC_LOG(("PDC_freeclipboard() - called\n"));
+
+ GlobalFree(contents);
+ return PDC_CLIP_SUCCESS;
+}
+
+int PDC_clearclipboard(void)
+{
+ PDC_LOG(("PDC_clearclipboard() - called\n"));
+
+ EmptyClipboard();
+
+ return PDC_CLIP_SUCCESS;
+}
diff --git a/payloads/libpayload/curses/PDCurses-3.4/win32/pdcdisp.c b/payloads/libpayload/curses/PDCurses-3.4/win32/pdcdisp.c
new file mode 100644
index 0000000000..c2ad8142c6
--- /dev/null
+++ b/payloads/libpayload/curses/PDCurses-3.4/win32/pdcdisp.c
@@ -0,0 +1,117 @@
+/* Public Domain Curses */
+
+#include "pdcwin.h"
+
+RCSID("$Id: pdcdisp.c,v 1.47 2008/07/14 04:24:52 wmcbrine Exp $")
+
+#include <stdlib.h>
+#include <string.h>
+
+#ifdef CHTYPE_LONG
+
+# define A(x) ((chtype)x | A_ALTCHARSET)
+
+chtype acs_map[128] =
+{
+ A(0), A(1), A(2), A(3), A(4), A(5), A(6), A(7), A(8), A(9), A(10),
+ A(11), A(12), A(13), A(14), A(15), A(16), A(17), A(18), A(19),
+ A(20), A(21), A(22), A(23), A(24), A(25), A(26), A(27), A(28),
+ A(29), A(30), A(31), ' ', '!', '"', '#', '$', '%', '&', '\'', '(',
+ ')', '*',
+
+# ifdef PDC_WIDE
+ 0x2192, 0x2190, 0x2191, 0x2193,
+# else
+ A(0x1a), A(0x1b), A(0x18), A(0x19),
+# endif
+
+ '/',
+
+# ifdef PDC_WIDE
+ 0x2588,
+# else
+ 0xdb,
+# endif
+
+ '1', '2', '3', '4', '5', '6', '7', '8', '9', ':', ';', '<', '=',
+ '>', '?', '@', 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J',
+ 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W',
+ 'X', 'Y', 'Z', '[', '\\', ']', '^', '_',
+
+# ifdef PDC_WIDE
+ 0x2666, 0x2592,
+# else
+ A(0x04), 0xb1,
+# endif
+
+ 'b', 'c', 'd', 'e',
+
+# ifdef PDC_WIDE
+ 0x00b0, 0x00b1, 0x2591, 0x00a4, 0x2518, 0x2510, 0x250c, 0x2514,
+ 0x253c, 0x23ba, 0x23bb, 0x2500, 0x23bc, 0x23bd, 0x251c, 0x2524,
+ 0x2534, 0x252c, 0x2502, 0x2264, 0x2265, 0x03c0, 0x2260, 0x00a3,
+ 0x00b7,
+# else
+ 0xf8, 0xf1, 0xb0, A(0x0f), 0xd9, 0xbf, 0xda, 0xc0, 0xc5, 0x2d, 0x2d,
+ 0xc4, 0x2d, 0x5f, 0xc3, 0xb4, 0xc1, 0xc2, 0xb3, 0xf3, 0xf2, 0xe3,
+ 0xd8, 0x9c, 0xf9,
+# endif
+
+ A(127)
+};
+
+# undef A
+
+#endif
+
+/* position hardware cursor at (y, x) */
+
+void PDC_gotoyx(int row, int col)
+{
+ COORD coord;
+
+ PDC_LOG(("PDC_gotoyx() - called: row %d col %d from row %d col %d\n",
+ row, col, SP->cursrow, SP->curscol));
+
+ coord.X = col;
+ coord.Y = row;
+
+ SetConsoleCursorPosition(pdc_con_out, coord);
+}
+
+/* update the given physical line to look like the corresponding line in
+ curscr */
+
+void PDC_transform_line(int lineno, int x, int len, const chtype *srcp)
+{
+ CHAR_INFO ci[512];
+ int j;
+ COORD bufSize, bufPos;
+ SMALL_RECT sr;
+
+ PDC_LOG(("PDC_transform_line() - called: lineno=%d\n", lineno));
+
+ bufPos.X = bufPos.Y = 0;
+
+ bufSize.X = len;
+ bufSize.Y = 1;
+
+ sr.Top = lineno;
+ sr.Bottom = lineno;
+ sr.Left = x;
+ sr.Right = x + len - 1;
+
+ for (j = 0; j < len; j++)
+ {
+ chtype ch = srcp[j];
+
+ ci[j].Attributes = pdc_atrtab[ch >> PDC_ATTR_SHIFT];
+#ifdef CHTYPE_LONG
+ if (ch & A_ALTCHARSET && !(ch & 0xff80))
+ ch = acs_map[ch & 0x7f];
+#endif
+ ci[j].Char.UnicodeChar = ch & A_CHARTEXT;
+ }
+
+ WriteConsoleOutput(pdc_con_out, ci, bufSize, bufPos, &sr);
+}
diff --git a/payloads/libpayload/curses/PDCurses-3.4/win32/pdcgetsc.c b/payloads/libpayload/curses/PDCurses-3.4/win32/pdcgetsc.c
new file mode 100644
index 0000000000..15f0dc5f80
--- /dev/null
+++ b/payloads/libpayload/curses/PDCurses-3.4/win32/pdcgetsc.c
@@ -0,0 +1,57 @@
+/* Public Domain Curses */
+
+#include "pdcwin.h"
+
+RCSID("$Id: pdcgetsc.c,v 1.36 2008/07/14 04:24:52 wmcbrine Exp $")
+
+/* get the cursor size/shape */
+
+int PDC_get_cursor_mode(void)
+{
+ CONSOLE_CURSOR_INFO ci;
+
+ PDC_LOG(("PDC_get_cursor_mode() - called\n"));
+
+ GetConsoleCursorInfo(pdc_con_out, &ci);
+
+ return ci.dwSize;
+}
+
+/* return number of screen rows */
+
+int PDC_get_rows(void)
+{
+ CONSOLE_SCREEN_BUFFER_INFO scr;
+
+ PDC_LOG(("PDC_get_rows() - called\n"));
+
+ GetConsoleScreenBufferInfo(pdc_con_out, &scr);
+
+ return scr.srWindow.Bottom - scr.srWindow.Top + 1;
+}
+
+/* return number of buffer rows */
+
+int PDC_get_buffer_rows(void)
+{
+ CONSOLE_SCREEN_BUFFER_INFO scr;
+
+ PDC_LOG(("PDC_get_buffer_rows() - called\n"));
+
+ GetConsoleScreenBufferInfo(pdc_con_out, &scr);
+
+ return scr.dwSize.Y;
+}
+
+/* return width of screen/viewport */
+
+int PDC_get_columns(void)
+{
+ CONSOLE_SCREEN_BUFFER_INFO scr;
+
+ PDC_LOG(("PDC_get_columns() - called\n"));
+
+ GetConsoleScreenBufferInfo(pdc_con_out, &scr);
+
+ return scr.srWindow.Right - scr.srWindow.Left + 1;
+}
diff --git a/payloads/libpayload/curses/PDCurses-3.4/win32/pdckbd.c b/payloads/libpayload/curses/PDCurses-3.4/win32/pdckbd.c
new file mode 100644
index 0000000000..1c5b05b0fe
--- /dev/null
+++ b/payloads/libpayload/curses/PDCurses-3.4/win32/pdckbd.c
@@ -0,0 +1,656 @@
+/* Public Domain Curses */
+
+#include "pdcwin.h"
+
+RCSID("$Id: pdckbd.c,v 1.115 2008/07/20 20:12:04 wmcbrine Exp $")
+
+/*man-start**************************************************************
+
+ Name: pdckbd
+
+ Synopsis:
+ unsigned long PDC_get_input_fd(void);
+
+ Description:
+ PDC_get_input_fd() returns the file descriptor that PDCurses
+ reads its input from. It can be used for select().
+
+ Portability X/Open BSD SYS V
+ PDC_get_input_fd - - -
+
+**man-end****************************************************************/
+
+unsigned long pdc_key_modifiers = 0L;
+
+/* These variables are used to store information about the next
+ Input Event. */
+
+static INPUT_RECORD save_ip;
+static MOUSE_STATUS old_mouse_status;
+static DWORD event_count = 0;
+static SHORT left_key;
+static int key_count = 0;
+static int save_press = 0;
+
+#define KEV save_ip.Event.KeyEvent
+#define MEV save_ip.Event.MouseEvent
+
+/************************************************************************
+ * Table for key code translation of function keys in keypad mode *
+ * These values are for strict IBM keyboard compatibles only *
+ ************************************************************************/
+
+typedef struct
+{
+ unsigned short normal;
+ unsigned short shift;
+ unsigned short control;
+ unsigned short alt;
+ unsigned short extended;
+} KPTAB;
+
+static KPTAB kptab[] =
+{
+ {0, 0, 0, 0, 0 }, /* 0 */
+ {0, 0, 0, 0, 0 }, /* 1 VK_LBUTTON */
+ {0, 0, 0, 0, 0 }, /* 2 VK_RBUTTON */
+ {0, 0, 0, 0, 0 }, /* 3 VK_CANCEL */
+ {0, 0, 0, 0, 0 }, /* 4 VK_MBUTTON */
+ {0, 0, 0, 0, 0 }, /* 5 */
+ {0, 0, 0, 0, 0 }, /* 6 */
+ {0, 0, 0, 0, 0 }, /* 7 */
+ {0x08, 0x08, 0x7F, ALT_BKSP, 0 }, /* 8 VK_BACK */
+ {0x09, KEY_BTAB, CTL_TAB, ALT_TAB, 999 }, /* 9 VK_TAB */
+ {0, 0, 0, 0, 0 }, /* 10 */
+ {0, 0, 0, 0, 0 }, /* 11 */
+ {KEY_B2, 0x35, CTL_PAD5, ALT_PAD5, 0 }, /* 12 VK_CLEAR */
+ {0x0D, 0x0D, CTL_ENTER, ALT_ENTER, 1 }, /* 13 VK_RETURN */
+ {0, 0, 0, 0, 0 }, /* 14 */
+ {0, 0, 0, 0, 0 }, /* 15 */
+ {0, 0, 0, 0, 0 }, /* 16 VK_SHIFT HANDLED SEPARATELY */
+ {0, 0, 0, 0, 0 }, /* 17 VK_CONTROL HANDLED SEPARATELY */
+ {0, 0, 0, 0, 0 }, /* 18 VK_MENU HANDLED SEPARATELY */
+ {0, 0, 0, 0, 0 }, /* 19 VK_PAUSE */
+ {0, 0, 0, 0, 0 }, /* 20 VK_CAPITAL HANDLED SEPARATELY */
+ {0, 0, 0, 0, 0 }, /* 21 VK_HANGUL */
+ {0, 0, 0, 0, 0 }, /* 22 */
+ {0, 0, 0, 0, 0 }, /* 23 VK_JUNJA */
+ {0, 0, 0, 0, 0 }, /* 24 VK_FINAL */
+ {0, 0, 0, 0, 0 }, /* 25 VK_HANJA */
+ {0, 0, 0, 0, 0 }, /* 26 */
+ {0x1B, 0x1B, 0x1B, ALT_ESC, 0 }, /* 27 VK_ESCAPE */
+ {0, 0, 0, 0, 0 }, /* 28 VK_CONVERT */
+ {0, 0, 0, 0, 0 }, /* 29 VK_NONCONVERT */
+ {0, 0, 0, 0, 0 }, /* 30 VK_ACCEPT */
+ {0, 0, 0, 0, 0 }, /* 31 VK_MODECHANGE */
+ {0x20, 0x20, 0x20, 0x20, 0 }, /* 32 VK_SPACE */
+ {KEY_A3, 0x39, CTL_PAD9, ALT_PAD9, 3 }, /* 33 VK_PRIOR */
+ {KEY_C3, 0x33, CTL_PAD3, ALT_PAD3, 4 }, /* 34 VK_NEXT */
+ {KEY_C1, 0x31, CTL_PAD1, ALT_PAD1, 5 }, /* 35 VK_END */
+ {KEY_A1, 0x37, CTL_PAD7, ALT_PAD7, 6 }, /* 36 VK_HOME */
+ {KEY_B1, 0x34, CTL_PAD4, ALT_PAD4, 7 }, /* 37 VK_LEFT */
+ {KEY_A2, 0x38, CTL_PAD8, ALT_PAD8, 8 }, /* 38 VK_UP */
+ {KEY_B3, 0x36, CTL_PAD6, ALT_PAD6, 9 }, /* 39 VK_RIGHT */
+ {KEY_C2, 0x32, CTL_PAD2, ALT_PAD2, 10 }, /* 40 VK_DOWN */
+ {0, 0, 0, 0, 0 }, /* 41 VK_SELECT */
+ {0, 0, 0, 0, 0 }, /* 42 VK_PRINT */
+ {0, 0, 0, 0, 0 }, /* 43 VK_EXECUTE */
+ {0, 0, 0, 0, 0 }, /* 44 VK_SNAPSHOT*/
+ {PAD0, 0x30, CTL_PAD0, ALT_PAD0, 11 }, /* 45 VK_INSERT */
+ {PADSTOP, 0x2E, CTL_PADSTOP, ALT_PADSTOP,12 }, /* 46 VK_DELETE */
+ {0, 0, 0, 0, 0 }, /* 47 VK_HELP */
+ {0x30, 0x29, 0, ALT_0, 0 }, /* 48 */
+ {0x31, 0x21, 0, ALT_1, 0 }, /* 49 */
+ {0x32, 0x40, 0, ALT_2, 0 }, /* 50 */
+ {0x33, 0x23, 0, ALT_3, 0 }, /* 51 */
+ {0x34, 0x24, 0, ALT_4, 0 }, /* 52 */
+ {0x35, 0x25, 0, ALT_5, 0 }, /* 53 */
+ {0x36, 0x5E, 0, ALT_6, 0 }, /* 54 */
+ {0x37, 0x26, 0, ALT_7, 0 }, /* 55 */
+ {0x38, 0x2A, 0, ALT_8, 0 }, /* 56 */
+ {0x39, 0x28, 0, ALT_9, 0 }, /* 57 */
+ {0, 0, 0, 0, 0 }, /* 58 */
+ {0, 0, 0, 0, 0 }, /* 59 */
+ {0, 0, 0, 0, 0 }, /* 60 */
+ {0, 0, 0, 0, 0 }, /* 61 */
+ {0, 0, 0, 0, 0 }, /* 62 */
+ {0, 0, 0, 0, 0 }, /* 63 */
+ {0, 0, 0, 0, 0 }, /* 64 */
+ {0x61, 0x41, 0x01, ALT_A, 0 }, /* 65 */
+ {0x62, 0x42, 0x02, ALT_B, 0 }, /* 66 */
+ {0x63, 0x43, 0x03, ALT_C, 0 }, /* 67 */
+ {0x64, 0x44, 0x04, ALT_D, 0 }, /* 68 */
+ {0x65, 0x45, 0x05, ALT_E, 0 }, /* 69 */
+ {0x66, 0x46, 0x06, ALT_F, 0 }, /* 70 */
+ {0x67, 0x47, 0x07, ALT_G, 0 }, /* 71 */
+ {0x68, 0x48, 0x08, ALT_H, 0 }, /* 72 */
+ {0x69, 0x49, 0x09, ALT_I, 0 }, /* 73 */
+ {0x6A, 0x4A, 0x0A, ALT_J, 0 }, /* 74 */
+ {0x6B, 0x4B, 0x0B, ALT_K, 0 }, /* 75 */
+ {0x6C, 0x4C, 0x0C, ALT_L, 0 }, /* 76 */
+ {0x6D, 0x4D, 0x0D, ALT_M, 0 }, /* 77 */
+ {0x6E, 0x4E, 0x0E, ALT_N, 0 }, /* 78 */
+ {0x6F, 0x4F, 0x0F, ALT_O, 0 }, /* 79 */
+ {0x70, 0x50, 0x10, ALT_P, 0 }, /* 80 */
+ {0x71, 0x51, 0x11, ALT_Q, 0 }, /* 81 */
+ {0x72, 0x52, 0x12, ALT_R, 0 }, /* 82 */
+ {0x73, 0x53, 0x13, ALT_S, 0 }, /* 83 */
+ {0x74, 0x54, 0x14, ALT_T, 0 }, /* 84 */
+ {0x75, 0x55, 0x15, ALT_U, 0 }, /* 85 */
+ {0x76, 0x56, 0x16, ALT_V, 0 }, /* 86 */
+ {0x77, 0x57, 0x17, ALT_W, 0 }, /* 87 */
+ {0x78, 0x58, 0x18, ALT_X, 0 }, /* 88 */
+ {0x79, 0x59, 0x19, ALT_Y, 0 }, /* 89 */
+ {0x7A, 0x5A, 0x1A, ALT_Z, 0 }, /* 90 */
+ {0, 0, 0, 0, 0 }, /* 91 VK_LWIN */
+ {0, 0, 0, 0, 0 }, /* 92 VK_RWIN */
+ {0, 0, 0, 0, 0 }, /* 93 VK_APPS */
+ {0, 0, 0, 0, 0 }, /* 94 */
+ {0, 0, 0, 0, 0 }, /* 95 */
+ {0x30, 0, CTL_PAD0, ALT_PAD0, 0 }, /* 96 VK_NUMPAD0 */
+ {0x31, 0, CTL_PAD1, ALT_PAD1, 0 }, /* 97 VK_NUMPAD1 */
+ {0x32, 0, CTL_PAD2, ALT_PAD2, 0 }, /* 98 VK_NUMPAD2 */
+ {0x33, 0, CTL_PAD3, ALT_PAD3, 0 }, /* 99 VK_NUMPAD3 */
+ {0x34, 0, CTL_PAD4, ALT_PAD4, 0 }, /* 100 VK_NUMPAD4 */
+ {0x35, 0, CTL_PAD5, ALT_PAD5, 0 }, /* 101 VK_NUMPAD5 */
+ {0x36, 0, CTL_PAD6, ALT_PAD6, 0 }, /* 102 VK_NUMPAD6 */
+ {0x37, 0, CTL_PAD7, ALT_PAD7, 0 }, /* 103 VK_NUMPAD7 */
+ {0x38, 0, CTL_PAD8, ALT_PAD8, 0 }, /* 104 VK_NUMPAD8 */
+ {0x39, 0, CTL_PAD9, ALT_PAD9, 0 }, /* 105 VK_NUMPAD9 */
+ {PADSTAR, SHF_PADSTAR,CTL_PADSTAR, ALT_PADSTAR,999 }, /* 106 VK_MULTIPLY*/
+ {PADPLUS, SHF_PADPLUS,CTL_PADPLUS, ALT_PADPLUS,999 }, /* 107 VK_ADD */
+ {0, 0, 0, 0, 0 }, /* 108 VK_SEPARATOR */
+ {PADMINUS, SHF_PADMINUS,CTL_PADMINUS,ALT_PADMINUS,999}, /* 109 VK_SUBTRACT*/
+ {0x2E, 0, CTL_PADSTOP, ALT_PADSTOP,0 }, /* 110 VK_DECIMAL */
+ {PADSLASH, SHF_PADSLASH,CTL_PADSLASH,ALT_PADSLASH,2 }, /* 111 VK_DIVIDE */
+ {KEY_F(1), KEY_F(13), KEY_F(25), KEY_F(37), 0 }, /* 112 VK_F1 */
+ {KEY_F(2), KEY_F(14), KEY_F(26), KEY_F(38), 0 }, /* 113 VK_F2 */
+ {KEY_F(3), KEY_F(15), KEY_F(27), KEY_F(39), 0 }, /* 114 VK_F3 */
+ {KEY_F(4), KEY_F(16), KEY_F(28), KEY_F(40), 0 }, /* 115 VK_F4 */
+ {KEY_F(5), KEY_F(17), KEY_F(29), KEY_F(41), 0 }, /* 116 VK_F5 */
+ {KEY_F(6), KEY_F(18), KEY_F(30), KEY_F(42), 0 }, /* 117 VK_F6 */
+ {KEY_F(7), KEY_F(19), KEY_F(31), KEY_F(43), 0 }, /* 118 VK_F7 */
+ {KEY_F(8), KEY_F(20), KEY_F(32), KEY_F(44), 0 }, /* 119 VK_F8 */
+ {KEY_F(9), KEY_F(21), KEY_F(33), KEY_F(45), 0 }, /* 120 VK_F9 */
+ {KEY_F(10), KEY_F(22), KEY_F(34), KEY_F(46), 0 }, /* 121 VK_F10 */
+ {KEY_F(11), KEY_F(23), KEY_F(35), KEY_F(47), 0 }, /* 122 VK_F11 */
+ {KEY_F(12), KEY_F(24), KEY_F(36), KEY_F(48), 0 }, /* 123 VK_F12 */
+
+ /* 124 through 218 */
+
+ {0, 0, 0, 0, 0}, {0, 0, 0, 0, 0}, {0, 0, 0, 0, 0}, {0, 0, 0, 0, 0},
+ {0, 0, 0, 0, 0}, {0, 0, 0, 0, 0}, {0, 0, 0, 0, 0}, {0, 0, 0, 0, 0},
+ {0, 0, 0, 0, 0}, {0, 0, 0, 0, 0}, {0, 0, 0, 0, 0}, {0, 0, 0, 0, 0},
+ {0, 0, 0, 0, 0}, {0, 0, 0, 0, 0}, {0, 0, 0, 0, 0}, {0, 0, 0, 0, 0},
+ {0, 0, 0, 0, 0}, {0, 0, 0, 0, 0}, {0, 0, 0, 0, 0}, {0, 0, 0, 0, 0},
+ {0, 0, 0, 0, 0}, {0, 0, 0, 0, 0}, {0, 0, 0, 0, 0}, {0, 0, 0, 0, 0},
+ {0, 0, 0, 0, 0}, {0, 0, 0, 0, 0}, {0, 0, 0, 0, 0}, {0, 0, 0, 0, 0},
+ {0, 0, 0, 0, 0}, {0, 0, 0, 0, 0}, {0, 0, 0, 0, 0}, {0, 0, 0, 0, 0},
+ {0, 0, 0, 0, 0}, {0, 0, 0, 0, 0}, {0, 0, 0, 0, 0}, {0, 0, 0, 0, 0},
+ {0, 0, 0, 0, 0}, {0, 0, 0, 0, 0}, {0, 0, 0, 0, 0}, {0, 0, 0, 0, 0},
+ {0, 0, 0, 0, 0}, {0, 0, 0, 0, 0}, {0, 0, 0, 0, 0}, {0, 0, 0, 0, 0},
+ {0, 0, 0, 0, 0}, {0, 0, 0, 0, 0}, {0, 0, 0, 0, 0}, {0, 0, 0, 0, 0},
+ {0, 0, 0, 0, 0}, {0, 0, 0, 0, 0}, {0, 0, 0, 0, 0}, {0, 0, 0, 0, 0},
+ {0, 0, 0, 0, 0}, {0, 0, 0, 0, 0}, {0, 0, 0, 0, 0}, {0, 0, 0, 0, 0},
+ {0, 0, 0, 0, 0}, {0, 0, 0, 0, 0}, {0, 0, 0, 0, 0}, {0, 0, 0, 0, 0},
+ {0, 0, 0, 0, 0}, {0, 0, 0, 0, 0}, {0, 0, 0, 0, 0}, {0, 0, 0, 0, 0},
+ {0, 0, 0, 0, 0}, {0, 0, 0, 0, 0}, {0, 0, 0, 0, 0}, {0, 0, 0, 0, 0},
+ {0, 0, 0, 0, 0}, {0, 0, 0, 0, 0}, {0, 0, 0, 0, 0}, {0, 0, 0, 0, 0},
+ {0, 0, 0, 0, 0}, {0, 0, 0, 0, 0}, {0, 0, 0, 0, 0}, {0, 0, 0, 0, 0},
+ {0, 0, 0, 0, 0}, {0, 0, 0, 0, 0}, {0, 0, 0, 0, 0}, {0, 0, 0, 0, 0},
+ {0, 0, 0, 0, 0}, {0, 0, 0, 0, 0}, {0, 0, 0, 0, 0}, {0, 0, 0, 0, 0},
+ {0, 0, 0, 0, 0}, {0, 0, 0, 0, 0}, {0, 0, 0, 0, 0}, {0, 0, 0, 0, 0},
+ {0, 0, 0, 0, 0}, {0, 0, 0, 0, 0}, {0, 0, 0, 0, 0}, {0, 0, 0, 0, 0},
+ {0, 0, 0, 0, 0}, {0, 0, 0, 0, 0}, {0, 0, 0, 0, 0},
+
+ {0x5B, 0x7B, 0x1B, ALT_LBRACKET,0 }, /* 219 */
+ {0x5C, 0x7C, 0x1C, ALT_BSLASH, 0 }, /* 220 */
+ {0x5D, 0x7D, 0x1D, ALT_RBRACKET,0 }, /* 221 */
+ {0, 0, 0x27, ALT_FQUOTE, 0 }, /* 222 */
+ {0, 0, 0, 0, 0 }, /* 223 */
+ {0, 0, 0, 0, 0 }, /* 224 */
+ {0, 0, 0, 0, 0 } /* 225 */
+};
+
+static KPTAB ext_kptab[] =
+{
+ {0, 0, 0, 0, }, /* MUST BE EMPTY */
+ {PADENTER, SHF_PADENTER, CTL_PADENTER, ALT_PADENTER}, /* 13 */
+ {PADSLASH, SHF_PADSLASH, CTL_PADSLASH, ALT_PADSLASH}, /* 111 */
+ {KEY_PPAGE, KEY_SPREVIOUS, CTL_PGUP, ALT_PGUP }, /* 33 */
+ {KEY_NPAGE, KEY_SNEXT, CTL_PGDN, ALT_PGDN }, /* 34 */
+ {KEY_END, KEY_SEND, CTL_END, ALT_END }, /* 35 */
+ {KEY_HOME, KEY_SHOME, CTL_HOME, ALT_HOME }, /* 36 */
+ {KEY_LEFT, KEY_SLEFT, CTL_LEFT, ALT_LEFT }, /* 37 */
+ {KEY_UP, KEY_SUP, CTL_UP, ALT_UP }, /* 38 */
+ {KEY_RIGHT, KEY_SRIGHT, CTL_RIGHT, ALT_RIGHT }, /* 39 */
+ {KEY_DOWN, KEY_SDOWN, CTL_DOWN, ALT_DOWN }, /* 40 */
+ {KEY_IC, KEY_SIC, CTL_INS, ALT_INS }, /* 45 */
+ {KEY_DC, KEY_SDC, CTL_DEL, ALT_DEL }, /* 46 */
+ {PADSLASH, SHF_PADSLASH, CTL_PADSLASH, ALT_PADSLASH}, /* 191 */
+};
+
+/* End of kptab[] */
+
+unsigned long PDC_get_input_fd(void)
+{
+ PDC_LOG(("PDC_get_input_fd() - called\n"));
+
+ return 0L;
+}
+
+void PDC_set_keyboard_binary(bool on)
+{
+ PDC_LOG(("PDC_set_keyboard_binary() - called\n"));
+}
+
+/* check if a key or mouse event is waiting */
+
+bool PDC_check_key(void)
+{
+ if (key_count > 0)
+ return TRUE;
+
+ GetNumberOfConsoleInputEvents(pdc_con_in, &event_count);
+
+ return (event_count != 0);
+}
+
+/* _get_key_count returns 0 if save_ip doesn't contain an event which
+ should be passed back to the user. This function filters "useless"
+ events.
+
+ The function returns the number of keys waiting. This may be > 1
+ if the repetition of real keys pressed so far are > 1.
+
+ Returns 0 on NUMLOCK, CAPSLOCK, SCROLLLOCK.
+
+ Returns 1 for SHIFT, ALT, CTRL only if no other key has been pressed
+ in between, and SP->return_key_modifiers is set; these are returned
+ on keyup.
+
+ Normal keys are returned on keydown only. The number of repetitions
+ are returned. Dead keys (diacritics) are omitted. See below for a
+ description.
+*/
+
+static int _get_key_count(void)
+{
+ int num_keys = 0, vk;
+
+ PDC_LOG(("_get_key_count() - called\n"));
+
+ vk = KEV.wVirtualKeyCode;
+
+ if (KEV.bKeyDown)
+ {
+ /* key down */
+
+ save_press = 0;
+
+ if (vk == VK_CAPITAL || vk == VK_NUMLOCK || vk == VK_SCROLL)
+ {
+ /* throw away these modifiers */
+ }
+ else if (vk == VK_SHIFT || vk == VK_CONTROL || vk == VK_MENU)
+ {
+ /* These keys are returned on keyup only. */
+
+ save_press = vk;
+ switch (vk)
+ {
+ case VK_SHIFT:
+ left_key = GetKeyState(VK_LSHIFT);
+ break;
+ case VK_CONTROL:
+ left_key = GetKeyState(VK_LCONTROL);
+ break;
+ case VK_MENU:
+ left_key = GetKeyState(VK_LMENU);
+ }
+ }
+ else
+ {
+ /* Check for diacritics. These are dead keys. Some locales
+ have modified characters like umlaut-a, which is an "a"
+ with two dots on it. In some locales you have to press a
+ special key (the dead key) immediately followed by the
+ "a" to get a composed umlaut-a. The special key may have
+ a normal meaning with different modifiers. */
+
+ if (KEV.uChar.UnicodeChar || !(MapVirtualKey(vk, 2) & 0x80000000))
+ num_keys = KEV.wRepeatCount;
+ }
+ }
+ else
+ {
+ /* key up */
+
+ /* Only modifier keys or the results of ALT-numpad entry are
+ returned on keyup */
+
+ if ((vk == VK_MENU && KEV.uChar.UnicodeChar) ||
+ ((vk == VK_SHIFT || vk == VK_CONTROL || vk == VK_MENU) &&
+ vk == save_press))
+ {
+ save_press = 0;
+ num_keys = 1;
+ }
+ }
+
+ PDC_LOG(("_get_key_count() - returning: num_keys %d\n", num_keys));
+
+ return num_keys;
+}
+
+/* _process_key_event returns -1 if the key in save_ip should be
+ ignored. Otherwise it returns the keycode which should be returned
+ by PDC_get_key(). save_ip must be a key event.
+
+ CTRL-ALT support has been disabled, when is it emitted plainly? */
+
+static int _process_key_event(void)
+{
+ int key = (unsigned short)KEV.uChar.UnicodeChar;
+ WORD vk = KEV.wVirtualKeyCode;
+ DWORD state = KEV.dwControlKeyState;
+
+ int idx;
+ BOOL enhanced;
+
+ SP->key_code = TRUE;
+
+ /* Save the key modifiers if required. Do this first to allow to
+ detect e.g. a pressed CTRL key after a hit of NUMLOCK. */
+
+ if (SP->save_key_modifiers)
+ {
+ if (state & (LEFT_ALT_PRESSED|RIGHT_ALT_PRESSED))
+ pdc_key_modifiers |= PDC_KEY_MODIFIER_ALT;
+
+ if (state & SHIFT_PRESSED)
+ pdc_key_modifiers |= PDC_KEY_MODIFIER_SHIFT;
+
+ if (state & (LEFT_CTRL_PRESSED|RIGHT_CTRL_PRESSED))
+ pdc_key_modifiers |= PDC_KEY_MODIFIER_CONTROL;
+
+ if (state & NUMLOCK_ON)
+ pdc_key_modifiers |= PDC_KEY_MODIFIER_NUMLOCK;
+ }
+
+ /* Handle modifier keys hit by themselves */
+
+ switch (vk)
+ {
+ case VK_SHIFT: /* shift */
+ if (!SP->return_key_modifiers)
+ return -1;
+
+ return (left_key & 0x8000) ? KEY_SHIFT_L : KEY_SHIFT_R;
+
+ case VK_CONTROL: /* control */
+ if (!SP->return_key_modifiers)
+ return -1;
+
+ return (left_key & 0x8000) ? KEY_CONTROL_L : KEY_CONTROL_R;
+
+ case VK_MENU: /* alt */
+ if (!key)
+ {
+ if (!SP->return_key_modifiers)
+ return -1;
+
+ return (left_key & 0x8000) ? KEY_ALT_L : KEY_ALT_R;
+ }
+ }
+
+ /* The system may emit Ascii or Unicode characters depending on
+ whether ReadConsoleInputA or ReadConsoleInputW is used.
+
+ Normally, if key != 0 then the system did the translation
+ successfully. But this is not true for LEFT_ALT (different to
+ RIGHT_ALT). In case of LEFT_ALT we can get key != 0. So
+ check for this first. */
+
+ if (key && ( !(state & LEFT_ALT_PRESSED) ||
+ (state & RIGHT_ALT_PRESSED) ))
+ {
+ /* This code should catch all keys returning a printable
+ character. Characters above 0x7F should be returned as
+ positive codes. But if'ndef NUMKEYPAD we have to return
+ extended keycodes for keypad codes. */
+
+#ifndef NUMKEYPAD
+ if (kptab[vk].extended == 0)
+#endif
+ {
+ SP->key_code = FALSE;
+ return key;
+ }
+ }
+
+ /* This case happens if a functional key has been entered. */
+
+ if ((state & ENHANCED_KEY) && (kptab[vk].extended != 999))
+ {
+ enhanced = TRUE;
+ idx = kptab[vk].extended;
+ }
+ else
+ {
+ enhanced = FALSE;
+ idx = vk;
+ }
+
+ if (state & SHIFT_PRESSED)
+ key = enhanced ? ext_kptab[idx].shift : kptab[idx].shift;
+
+ else if (state & (LEFT_CTRL_PRESSED|RIGHT_CTRL_PRESSED))
+ key = enhanced ? ext_kptab[idx].control : kptab[idx].control;
+
+ else if (state & (LEFT_ALT_PRESSED|RIGHT_ALT_PRESSED))
+ key = enhanced ? ext_kptab[idx].alt : kptab[idx].alt;
+
+ else
+ key = enhanced ? ext_kptab[idx].normal : kptab[idx].normal;
+
+ if (key < KEY_CODE_YES)
+ SP->key_code = FALSE;
+
+ return key;
+}
+
+static int _process_mouse_event(void)
+{
+ static const DWORD button_mask[] = {1, 4, 2};
+ short action, shift_flags = 0;
+ int i;
+
+ save_press = 0;
+ SP->key_code = TRUE;
+
+ memset(&pdc_mouse_status, 0, sizeof(MOUSE_STATUS));
+
+ /* Handle scroll wheel */
+
+ if (MEV.dwEventFlags == 4)
+ {
+ pdc_mouse_status.changes = (MEV.dwButtonState & 0xFF000000) ?
+ PDC_MOUSE_WHEEL_DOWN : PDC_MOUSE_WHEEL_UP;
+
+ pdc_mouse_status.x = -1;
+ pdc_mouse_status.y = -1;
+
+ memset(&old_mouse_status, 0, sizeof(old_mouse_status));
+
+ return KEY_MOUSE;
+ }
+
+ action = (MEV.dwEventFlags == 2) ? BUTTON_DOUBLE_CLICKED :
+ ((MEV.dwEventFlags == 1) ? BUTTON_MOVED : BUTTON_PRESSED);
+
+ for (i = 0; i < 3; i++)
+ pdc_mouse_status.button[i] =
+ (MEV.dwButtonState & button_mask[i]) ? action : 0;
+
+ if (action == BUTTON_PRESSED && MEV.dwButtonState & 7 && SP->mouse_wait)
+ {
+ /* Check for a click -- a PRESS followed immediately by a release */
+
+ if (!event_count)
+ {
+ napms(SP->mouse_wait);
+
+ GetNumberOfConsoleInputEvents(pdc_con_in, &event_count);
+ }
+
+ if (event_count)
+ {
+ INPUT_RECORD ip;
+ DWORD count;
+ bool have_click = FALSE;
+
+ PeekConsoleInput(pdc_con_in, &ip, 1, &count);
+
+ for (i = 0; i < 3; i++)
+ {
+ if (pdc_mouse_status.button[i] == BUTTON_PRESSED &&
+ !(ip.Event.MouseEvent.dwButtonState & button_mask[i]))
+ {
+ pdc_mouse_status.button[i] = BUTTON_CLICKED;
+ have_click = TRUE;
+ }
+ }
+
+ /* If a click was found, throw out the event */
+
+ if (have_click)
+ ReadConsoleInput(pdc_con_in, &ip, 1, &count);
+ }
+ }
+
+ pdc_mouse_status.x = MEV.dwMousePosition.X;
+ pdc_mouse_status.y = MEV.dwMousePosition.Y;
+
+ pdc_mouse_status.changes = 0;
+
+ for (i = 0; i < 3; i++)
+ {
+ if (old_mouse_status.button[i] != pdc_mouse_status.button[i])
+ pdc_mouse_status.changes |= (1 << i);
+
+ if (pdc_mouse_status.button[i] == BUTTON_MOVED)
+ {
+ /* Discard non-moved "moves" */
+
+ if (pdc_mouse_status.x == old_mouse_status.x &&
+ pdc_mouse_status.y == old_mouse_status.y)
+ return -1;
+
+ /* Motion events always flag the button as changed */
+
+ pdc_mouse_status.changes |= (1 << i);
+ pdc_mouse_status.changes |= PDC_MOUSE_MOVED;
+ break;
+ }
+ }
+
+ old_mouse_status = pdc_mouse_status;
+
+ /* Treat click events as release events for comparison purposes */
+
+ for (i = 0; i < 3; i++)
+ {
+ if (old_mouse_status.button[i] == BUTTON_CLICKED ||
+ old_mouse_status.button[i] == BUTTON_DOUBLE_CLICKED)
+ old_mouse_status.button[i] = BUTTON_RELEASED;
+ }
+
+ /* Check for SHIFT/CONTROL/ALT */
+
+ if (MEV.dwControlKeyState & (LEFT_ALT_PRESSED|RIGHT_ALT_PRESSED))
+ shift_flags |= BUTTON_ALT;
+
+ if (MEV.dwControlKeyState & (LEFT_CTRL_PRESSED|RIGHT_CTRL_PRESSED))
+ shift_flags |= BUTTON_CONTROL;
+
+ if (MEV.dwControlKeyState & SHIFT_PRESSED)
+ shift_flags |= BUTTON_SHIFT;
+
+ if (shift_flags)
+ {
+ for (i = 0; i < 3; i++)
+ {
+ if (pdc_mouse_status.changes & (1 << i))
+ pdc_mouse_status.button[i] |= shift_flags;
+ }
+ }
+
+ return KEY_MOUSE;
+}
+
+/* return the next available key or mouse event */
+
+int PDC_get_key(void)
+{
+ pdc_key_modifiers = 0L;
+
+ if (!key_count)
+ {
+ DWORD count;
+
+ ReadConsoleInput(pdc_con_in, &save_ip, 1, &count);
+ event_count--;
+
+ if (save_ip.EventType == MOUSE_EVENT)
+ key_count = 1;
+ else if (save_ip.EventType == KEY_EVENT)
+ key_count = _get_key_count();
+ }
+
+ if (key_count)
+ {
+ key_count--;
+
+ switch (save_ip.EventType)
+ {
+ case KEY_EVENT:
+ return _process_key_event();
+
+ case MOUSE_EVENT:
+ return _process_mouse_event();
+ }
+ }
+
+ return -1;
+}
+
+/* discard any pending keyboard or mouse input -- this is the core
+ routine for flushinp() */
+
+void PDC_flushinp(void)
+{
+ PDC_LOG(("PDC_flushinp() - called\n"));
+
+ FlushConsoleInputBuffer(pdc_con_in);
+}
+
+int PDC_mouse_set(void)
+{
+ /* If turning on mouse input: Set ENABLE_MOUSE_INPUT, and clear
+ all other flags, including the extended flags;
+ If turning off the mouse: Set QuickEdit Mode to the status it
+ had on startup, and clear all other flags */
+
+ SetConsoleMode(pdc_con_in, SP->_trap_mbe ?
+ (ENABLE_MOUSE_INPUT|0x0080) : (pdc_quick_edit|0x0080));
+
+ memset(&old_mouse_status, 0, sizeof(old_mouse_status));
+
+ return OK;
+}
+
+int PDC_modifiers_set(void)
+{
+ return OK;
+}
diff --git a/payloads/libpayload/curses/PDCurses-3.4/win32/pdcscrn.c b/payloads/libpayload/curses/PDCurses-3.4/win32/pdcscrn.c
new file mode 100644
index 0000000000..b48ddaafd9
--- /dev/null
+++ b/payloads/libpayload/curses/PDCurses-3.4/win32/pdcscrn.c
@@ -0,0 +1,620 @@
+/* Public Domain Curses */
+
+#include "pdcwin.h"
+
+RCSID("$Id: pdcscrn.c,v 1.92 2008/07/20 20:12:04 wmcbrine Exp $")
+
+#ifdef CHTYPE_LONG
+# define PDC_OFFSET 32
+#else
+# define PDC_OFFSET 8
+#endif
+
+/* COLOR_PAIR to attribute encoding table. */
+
+unsigned char *pdc_atrtab = (unsigned char *)NULL;
+
+HANDLE pdc_con_out = INVALID_HANDLE_VALUE;
+HANDLE pdc_con_in = INVALID_HANDLE_VALUE;
+
+DWORD pdc_quick_edit;
+
+static short curstoreal[16], realtocurs[16] =
+{
+ COLOR_BLACK, COLOR_BLUE, COLOR_GREEN, COLOR_CYAN, COLOR_RED,
+ COLOR_MAGENTA, COLOR_YELLOW, COLOR_WHITE, COLOR_BLACK + 8,
+ COLOR_BLUE + 8, COLOR_GREEN + 8, COLOR_CYAN + 8, COLOR_RED + 8,
+ COLOR_MAGENTA + 8, COLOR_YELLOW + 8, COLOR_WHITE + 8
+};
+
+enum { PDC_RESTORE_NONE, PDC_RESTORE_BUFFER, PDC_RESTORE_WINDOW };
+
+/* Struct for storing console registry keys, and for use with the
+ undocumented WM_SETCONSOLEINFO message. Originally by James Brown,
+ www.catch22.net. */
+
+static struct
+{
+ ULONG Length;
+ COORD ScreenBufferSize;
+ COORD WindowSize;
+ ULONG WindowPosX;
+ ULONG WindowPosY;
+
+ COORD FontSize;
+ ULONG FontFamily;
+ ULONG FontWeight;
+ WCHAR FaceName[32];
+
+ ULONG CursorSize;
+ ULONG FullScreen;
+ ULONG QuickEdit;
+ ULONG AutoPosition;
+ ULONG InsertMode;
+
+ USHORT ScreenColors;
+ USHORT PopupColors;
+ ULONG HistoryNoDup;
+ ULONG HistoryBufferSize;
+ ULONG NumberOfHistoryBuffers;
+
+ COLORREF ColorTable[16];
+
+ ULONG CodePage;
+ HWND Hwnd;
+
+ WCHAR ConsoleTitle[0x100];
+} console_info;
+
+static CONSOLE_SCREEN_BUFFER_INFO orig_scr;
+
+static CHAR_INFO *ci_save = NULL;
+static DWORD old_console_mode = 0;
+
+static bool is_nt;
+
+static HWND _find_console_handle(void)
+{
+ TCHAR orgtitle[1024], temptitle[1024];
+ HWND wnd;
+
+ GetConsoleTitle(orgtitle, 1024);
+
+ wsprintf(temptitle, TEXT("%d/%d"), GetTickCount(), GetCurrentProcessId());
+ SetConsoleTitle(temptitle);
+
+ Sleep(40);
+
+ wnd = FindWindow(NULL, temptitle);
+
+ SetConsoleTitle(orgtitle);
+
+ return wnd;
+}
+
+/* Undocumented console message */
+
+#define WM_SETCONSOLEINFO (WM_USER + 201)
+
+/* Wrapper around WM_SETCONSOLEINFO. We need to create the necessary
+ section (file-mapping) object in the context of the process which
+ owns the console, before posting the message. Originally by JB. */
+
+static void _set_console_info(void)
+{
+ CONSOLE_SCREEN_BUFFER_INFO csbi;
+ CONSOLE_CURSOR_INFO cci;
+ DWORD dwConsoleOwnerPid;
+ HANDLE hProcess;
+ HANDLE hSection, hDupSection;
+ PVOID ptrView;
+
+ /* Each-time initialization for console_info */
+
+ GetConsoleCursorInfo(pdc_con_out, &cci);
+ console_info.CursorSize = cci.dwSize;
+
+ GetConsoleScreenBufferInfo(pdc_con_out, &csbi);
+ console_info.ScreenBufferSize = csbi.dwSize;
+
+ console_info.WindowSize.X = csbi.srWindow.Right - csbi.srWindow.Left + 1;
+ console_info.WindowSize.Y = csbi.srWindow.Bottom - csbi.srWindow.Top + 1;
+
+ console_info.WindowPosX = csbi.srWindow.Left;
+ console_info.WindowPosY = csbi.srWindow.Top;
+
+ /* Open the process which "owns" the console */
+
+ GetWindowThreadProcessId(console_info.Hwnd, &dwConsoleOwnerPid);
+
+ hProcess = OpenProcess(PROCESS_ALL_ACCESS, FALSE, dwConsoleOwnerPid);
+
+ /* Create a SECTION object backed by page-file, then map a view of
+ this section into the owner process so we can write the contents
+ of the CONSOLE_INFO buffer into it */
+
+ hSection = CreateFileMapping(INVALID_HANDLE_VALUE, 0, PAGE_READWRITE,
+ 0, sizeof(console_info), 0);
+
+ /* Copy our console structure into the section-object */
+
+ ptrView = MapViewOfFile(hSection, FILE_MAP_WRITE|FILE_MAP_READ,
+ 0, 0, sizeof(console_info));
+
+ memcpy(ptrView, &console_info, sizeof(console_info));
+
+ UnmapViewOfFile(ptrView);
+
+ /* Map the memory into owner process */
+
+ DuplicateHandle(GetCurrentProcess(), hSection, hProcess, &hDupSection,
+ 0, FALSE, DUPLICATE_SAME_ACCESS);
+
+ /* Send console window the "update" message */
+
+ SendMessage(console_info.Hwnd, WM_SETCONSOLEINFO, (WPARAM)hDupSection, 0);
+
+ CloseHandle(hSection);
+ CloseHandle(hProcess);
+}
+
+/* One-time initialization for console_info -- color table and font info
+ from the registry; other values from functions. */
+
+static void _init_console_info(void)
+{
+ DWORD scrnmode, len;
+ HKEY reghnd;
+ int i;
+
+ console_info.Hwnd = _find_console_handle();
+ console_info.Length = sizeof(console_info);
+
+ GetConsoleMode(pdc_con_in, &scrnmode);
+ console_info.QuickEdit = !!(scrnmode & 0x0040);
+ console_info.InsertMode = !!(scrnmode & 0x0020);
+
+ console_info.FullScreen = FALSE;
+ console_info.AutoPosition = 0x10000;
+ console_info.ScreenColors = SP->orig_back << 4 | SP->orig_fore;
+ console_info.PopupColors = 0xf5;
+
+ console_info.HistoryNoDup = FALSE;
+ console_info.HistoryBufferSize = 50;
+ console_info.NumberOfHistoryBuffers = 4;
+
+ console_info.CodePage = GetConsoleOutputCP();
+
+ RegOpenKeyEx(HKEY_CURRENT_USER, TEXT("Console"), 0,
+ KEY_QUERY_VALUE, &reghnd);
+
+ len = sizeof(DWORD);
+
+ /* Default color table */
+
+ for (i = 0; i < 16; i++)
+ {
+ char tname[13];
+
+ sprintf(tname, "ColorTable%02d", i);
+ RegQueryValueExA(reghnd, tname, NULL, NULL,
+ (LPBYTE)(&(console_info.ColorTable[i])), &len);
+ }
+
+ /* Font info */
+
+ RegQueryValueEx(reghnd, TEXT("FontSize"), NULL, NULL,
+ (LPBYTE)(&console_info.FontSize), &len);
+ RegQueryValueEx(reghnd, TEXT("FontFamily"), NULL, NULL,
+ (LPBYTE)(&console_info.FontFamily), &len);
+ RegQueryValueEx(reghnd, TEXT("FontWeight"), NULL, NULL,
+ (LPBYTE)(&console_info.FontWeight), &len);
+
+ len = sizeof(WCHAR) * 32;
+ RegQueryValueExW(reghnd, L"FaceName", NULL, NULL,
+ (LPBYTE)(console_info.FaceName), &len);
+
+ RegCloseKey(reghnd);
+}
+
+/* close the physical screen -- may restore the screen to its state
+ before PDC_scr_open(); miscellaneous cleanup */
+
+void PDC_scr_close(void)
+{
+ COORD origin;
+ SMALL_RECT rect;
+
+ PDC_LOG(("PDC_scr_close() - called\n"));
+
+ PDC_reset_shell_mode();
+
+ if (SP->_restore != PDC_RESTORE_NONE)
+ {
+ if (SP->_restore == PDC_RESTORE_WINDOW)
+ {
+ rect.Top = orig_scr.srWindow.Top;
+ rect.Left = orig_scr.srWindow.Left;
+ rect.Bottom = orig_scr.srWindow.Bottom;
+ rect.Right = orig_scr.srWindow.Right;
+ }
+ else /* PDC_RESTORE_BUFFER */
+ {
+ rect.Top = rect.Left = 0;
+ rect.Bottom = orig_scr.dwSize.Y - 1;
+ rect.Right = orig_scr.dwSize.X - 1;
+ }
+
+ origin.X = origin.Y = 0;
+
+ if (!WriteConsoleOutput(pdc_con_out, ci_save, orig_scr.dwSize,
+ origin, &rect))
+ return;
+ }
+
+ if (SP->visibility != 1)
+ curs_set(1);
+
+ /* Position cursor to the bottom left of the screen. */
+
+ PDC_gotoyx(PDC_get_buffer_rows() - 2, 0);
+}
+
+void PDC_scr_free(void)
+{
+ if (SP)
+ free(SP);
+ if (pdc_atrtab)
+ free(pdc_atrtab);
+
+ pdc_atrtab = (unsigned char *)NULL;
+}
+
+/* open the physical screen -- allocate SP, miscellaneous intialization,
+ and may save the existing screen for later restoration */
+
+int PDC_scr_open(int argc, char **argv)
+{
+ COORD bufsize, origin;
+ SMALL_RECT rect;
+ const char *str;
+ CONSOLE_SCREEN_BUFFER_INFO csbi;
+ int i;
+
+ PDC_LOG(("PDC_scr_open() - called\n"));
+
+ SP = calloc(1, sizeof(SCREEN));
+ pdc_atrtab = calloc(PDC_COLOR_PAIRS * PDC_OFFSET, 1);
+
+ if (!SP || !pdc_atrtab)
+ return ERR;
+
+ for (i = 0; i < 16; i++)
+ curstoreal[realtocurs[i]] = i;
+
+ pdc_con_out = GetStdHandle(STD_OUTPUT_HANDLE);
+ pdc_con_in = GetStdHandle(STD_INPUT_HANDLE);
+
+ if (GetFileType(pdc_con_in) != FILE_TYPE_CHAR)
+ {
+ fprintf(stderr, "\nRedirection is not supported.\n");
+ exit(1);
+ }
+
+ is_nt = !(GetVersion() & 0x80000000);
+
+ GetConsoleScreenBufferInfo(pdc_con_out, &csbi);
+ GetConsoleScreenBufferInfo(pdc_con_out, &orig_scr);
+ GetConsoleMode(pdc_con_in, &old_console_mode);
+
+ /* preserve QuickEdit Mode setting for use in PDC_mouse_set() when
+ the mouse is not enabled -- other console input settings are
+ cleared */
+
+ pdc_quick_edit = old_console_mode & 0x0040;
+
+ SP->lines = (str = getenv("LINES")) ? atoi(str) : PDC_get_rows();
+ SP->cols = (str = getenv("COLS")) ? atoi(str) : PDC_get_columns();
+
+ SP->mouse_wait = PDC_CLICK_PERIOD;
+ SP->audible = TRUE;
+
+ if (SP->lines < 2 || SP->lines > csbi.dwMaximumWindowSize.Y)
+ {
+ fprintf(stderr, "LINES value must be >= 2 and <= %d: got %d\n",
+ csbi.dwMaximumWindowSize.Y, SP->lines);
+
+ return ERR;
+ }
+
+ if (SP->cols < 2 || SP->cols > csbi.dwMaximumWindowSize.X)
+ {
+ fprintf(stderr, "COLS value must be >= 2 and <= %d: got %d\n",
+ csbi.dwMaximumWindowSize.X, SP->cols);
+
+ return ERR;
+ }
+
+ SP->orig_fore = csbi.wAttributes & 0x0f;
+ SP->orig_back = (csbi.wAttributes & 0xf0) >> 4;
+
+ SP->orig_attr = TRUE;
+
+ SP->_restore = PDC_RESTORE_NONE;
+
+ if (getenv("PDC_RESTORE_SCREEN"))
+ {
+ /* Attempt to save the complete console buffer */
+
+ ci_save = malloc(orig_scr.dwSize.X * orig_scr.dwSize.Y *
+ sizeof(CHAR_INFO));
+
+ if (!ci_save)
+ {
+ PDC_LOG(("PDC_scr_open() - malloc failure (1)\n"));
+
+ return ERR;
+ }
+
+ bufsize.X = orig_scr.dwSize.X;
+ bufsize.Y = orig_scr.dwSize.Y;
+
+ origin.X = origin.Y = 0;
+
+ rect.Top = rect.Left = 0;
+ rect.Bottom = orig_scr.dwSize.Y - 1;
+ rect.Right = orig_scr.dwSize.X - 1;
+
+ if (!ReadConsoleOutput(pdc_con_out, ci_save, bufsize, origin, &rect))
+ {
+ /* We can't save the complete buffer, so try and save just
+ the displayed window */
+
+ free(ci_save);
+ ci_save = NULL;
+
+ bufsize.X = orig_scr.srWindow.Right - orig_scr.srWindow.Left + 1;
+ bufsize.Y = orig_scr.srWindow.Bottom - orig_scr.srWindow.Top + 1;
+
+ ci_save = malloc(bufsize.X * bufsize.Y * sizeof(CHAR_INFO));
+
+ if (!ci_save)
+ {
+ PDC_LOG(("PDC_scr_open() - malloc failure (2)\n"));
+
+ return ERR;
+ }
+
+ origin.X = origin.Y = 0;
+
+ rect.Top = orig_scr.srWindow.Top;
+ rect.Left = orig_scr.srWindow.Left;
+ rect.Bottom = orig_scr.srWindow.Bottom;
+ rect.Right = orig_scr.srWindow.Right;
+
+ if (!ReadConsoleOutput(pdc_con_out, ci_save, bufsize,
+ origin, &rect))
+ {
+#ifdef PDCDEBUG
+ CHAR LastError[256];
+
+ FormatMessage(FORMAT_MESSAGE_FROM_SYSTEM, NULL,
+ GetLastError(), MAKELANGID(LANG_NEUTRAL,
+ SUBLANG_DEFAULT), LastError, 256, NULL);
+
+ PDC_LOG(("PDC_scr_open() - %s\n", LastError));
+#endif
+ free(ci_save);
+ ci_save = NULL;
+
+ return ERR;
+ }
+
+ SP->_restore = PDC_RESTORE_WINDOW;
+ }
+ else
+ SP->_restore = PDC_RESTORE_BUFFER;
+ }
+
+ SP->_preserve = (getenv("PDC_PRESERVE_SCREEN") != NULL);
+
+ PDC_reset_prog_mode();
+
+ SP->mono = FALSE;
+
+ return OK;
+}
+
+ /* Calls SetConsoleWindowInfo with the given parameters, but fits them
+ if a scoll bar shrinks the maximum possible value. The rectangle
+ must at least fit in a half-sized window. */
+
+static BOOL _fit_console_window(HANDLE con_out, CONST SMALL_RECT *rect)
+{
+ SMALL_RECT run;
+ SHORT mx, my;
+
+ if (SetConsoleWindowInfo(con_out, TRUE, rect))
+ return TRUE;
+
+ run = *rect;
+ run.Right /= 2;
+ run.Bottom /= 2;
+
+ mx = run.Right;
+ my = run.Bottom;
+
+ if (!SetConsoleWindowInfo(con_out, TRUE, &run))
+ return FALSE;
+
+ for (run.Right = rect->Right; run.Right >= mx; run.Right--)
+ if (SetConsoleWindowInfo(con_out, TRUE, &run))
+ break;
+
+ if (run.Right < mx)
+ return FALSE;
+
+ for (run.Bottom = rect->Bottom; run.Bottom >= my; run.Bottom--)
+ if (SetConsoleWindowInfo(con_out, TRUE, &run))
+ return TRUE;
+
+ return FALSE;
+}
+
+/* the core of resize_term() */
+
+int PDC_resize_screen(int nlines, int ncols)
+{
+ SMALL_RECT rect;
+ COORD size, max;
+
+ if (nlines < 2 || ncols < 2)
+ return ERR;
+
+ max = GetLargestConsoleWindowSize(pdc_con_out);
+
+ rect.Left = rect.Top = 0;
+ rect.Right = ncols - 1;
+
+ if (rect.Right > max.X)
+ rect.Right = max.X;
+
+ rect.Bottom = nlines - 1;
+
+ if (rect.Bottom > max.Y)
+ rect.Bottom = max.Y;
+
+ size.X = rect.Right + 1;
+ size.Y = rect.Bottom + 1;
+
+ _fit_console_window(pdc_con_out, &rect);
+ SetConsoleScreenBufferSize(pdc_con_out, size);
+ _fit_console_window(pdc_con_out, &rect);
+ SetConsoleScreenBufferSize(pdc_con_out, size);
+ SetConsoleActiveScreenBuffer(pdc_con_out);
+
+ return OK;
+}
+
+void PDC_reset_prog_mode(void)
+{
+ PDC_LOG(("PDC_reset_prog_mode() - called.\n"));
+
+ if (is_nt)
+ {
+ COORD bufsize;
+ SMALL_RECT rect;
+
+ bufsize.X = orig_scr.srWindow.Right - orig_scr.srWindow.Left + 1;
+ bufsize.Y = orig_scr.srWindow.Bottom - orig_scr.srWindow.Top + 1;
+
+ rect.Top = rect.Left = 0;
+ rect.Bottom = bufsize.Y - 1;
+ rect.Right = bufsize.X - 1;
+
+ SetConsoleScreenBufferSize(pdc_con_out, bufsize);
+ SetConsoleWindowInfo(pdc_con_out, TRUE, &rect);
+ SetConsoleScreenBufferSize(pdc_con_out, bufsize);
+ SetConsoleActiveScreenBuffer(pdc_con_out);
+ }
+
+ PDC_mouse_set();
+}
+
+void PDC_reset_shell_mode(void)
+{
+ PDC_LOG(("PDC_reset_shell_mode() - called.\n"));
+
+ if (is_nt)
+ {
+ SetConsoleScreenBufferSize(pdc_con_out, orig_scr.dwSize);
+ SetConsoleWindowInfo(pdc_con_out, TRUE, &orig_scr.srWindow);
+ SetConsoleScreenBufferSize(pdc_con_out, orig_scr.dwSize);
+ SetConsoleWindowInfo(pdc_con_out, TRUE, &orig_scr.srWindow);
+ SetConsoleActiveScreenBuffer(pdc_con_out);
+ }
+
+ SetConsoleMode(pdc_con_in, old_console_mode);
+}
+
+void PDC_restore_screen_mode(int i)
+{
+}
+
+void PDC_save_screen_mode(int i)
+{
+}
+
+void PDC_init_pair(short pair, short fg, short bg)
+{
+ unsigned char att, temp_bg;
+ chtype i;
+
+ fg = curstoreal[fg];
+ bg = curstoreal[bg];
+
+ for (i = 0; i < PDC_OFFSET; i++)
+ {
+ att = fg | (bg << 4);
+
+ if (i & (A_REVERSE >> PDC_ATTR_SHIFT))
+ att = bg | (fg << 4);
+ if (i & (A_UNDERLINE >> PDC_ATTR_SHIFT))
+ att = 1;
+ if (i & (A_INVIS >> PDC_ATTR_SHIFT))
+ {
+ temp_bg = att >> 4;
+ att = temp_bg << 4 | temp_bg;
+ }
+ if (i & (A_BOLD >> PDC_ATTR_SHIFT))
+ att |= 8;
+ if (i & (A_BLINK >> PDC_ATTR_SHIFT))
+ att |= 128;
+
+ pdc_atrtab[pair * PDC_OFFSET + i] = att;
+ }
+}
+
+int PDC_pair_content(short pair, short *fg, short *bg)
+{
+ *fg = realtocurs[pdc_atrtab[pair * PDC_OFFSET] & 0x0F];
+ *bg = realtocurs[(pdc_atrtab[pair * PDC_OFFSET] & 0xF0) >> 4];
+
+ return OK;
+}
+
+bool PDC_can_change_color(void)
+{
+ return is_nt;
+}
+
+int PDC_color_content(short color, short *red, short *green, short *blue)
+{
+ DWORD col;
+
+ if (!console_info.Hwnd)
+ _init_console_info();
+
+ col = console_info.ColorTable[curstoreal[color]];
+
+ *red = DIVROUND(GetRValue(col) * 1000, 255);
+ *green = DIVROUND(GetGValue(col) * 1000, 255);
+ *blue = DIVROUND(GetBValue(col) * 1000, 255);
+
+ return OK;
+}
+
+int PDC_init_color(short color, short red, short green, short blue)
+{
+ if (!console_info.Hwnd)
+ _init_console_info();
+
+ console_info.ColorTable[curstoreal[color]] =
+ RGB(DIVROUND(red * 255, 1000),
+ DIVROUND(green * 255, 1000),
+ DIVROUND(blue * 255, 1000));
+
+ _set_console_info();
+
+ return OK;
+}
diff --git a/payloads/libpayload/curses/PDCurses-3.4/win32/pdcsetsc.c b/payloads/libpayload/curses/PDCurses-3.4/win32/pdcsetsc.c
new file mode 100644
index 0000000000..cfb12315e4
--- /dev/null
+++ b/payloads/libpayload/curses/PDCurses-3.4/win32/pdcsetsc.c
@@ -0,0 +1,89 @@
+/* Public Domain Curses */
+
+#include "pdcwin.h"
+
+RCSID("$Id: pdcsetsc.c,v 1.40 2008/07/14 04:24:52 wmcbrine Exp $")
+
+/*man-start**************************************************************
+
+ Name: pdcsetsc
+
+ Synopsis:
+ int PDC_set_blink(bool blinkon);
+ void PDC_set_title(const char *title);
+
+ Description:
+ PDC_set_blink() toggles whether the A_BLINK attribute sets an
+ actual blink mode (TRUE), or sets the background color to high
+ intensity (FALSE). The default is platform-dependent (FALSE in
+ most cases). It returns OK if it could set the state to match
+ the given parameter, ERR otherwise. Current platforms also
+ adjust the value of COLORS according to this function -- 16 for
+ FALSE, and 8 for TRUE.
+
+ PDC_set_title() sets the title of the window in which the curses
+ program is running. This function may not do anything on some
+ platforms. (Currently it only works in Win32 and X11.)
+
+ Portability X/Open BSD SYS V
+ PDC_set_blink - - -
+ PDC_set_title - - -
+
+**man-end****************************************************************/
+
+int PDC_curs_set(int visibility)
+{
+ CONSOLE_CURSOR_INFO cci;
+ int ret_vis;
+
+ PDC_LOG(("PDC_curs_set() - called: visibility=%d\n", visibility));
+
+ ret_vis = SP->visibility;
+
+ if (GetConsoleCursorInfo(pdc_con_out, &cci) == FALSE)
+ return ERR;
+
+ switch(visibility)
+ {
+ case 0: /* invisible */
+ cci.bVisible = FALSE;
+ break;
+ case 2: /* highly visible */
+ cci.bVisible = TRUE;
+ cci.dwSize = 95;
+ break;
+ default: /* normal visibility */
+ cci.bVisible = TRUE;
+ cci.dwSize = SP->orig_cursor;
+ break;
+ }
+
+ if (SetConsoleCursorInfo(pdc_con_out, &cci) == FALSE)
+ return ERR;
+
+ SP->visibility = visibility;
+ return ret_vis;
+}
+
+void PDC_set_title(const char *title)
+{
+#ifdef PDC_WIDE
+ wchar_t wtitle[512];
+#endif
+ PDC_LOG(("PDC_set_title() - called:<%s>\n", title));
+
+#ifdef PDC_WIDE
+ PDC_mbstowcs(wtitle, title, 511);
+ SetConsoleTitleW(wtitle);
+#else
+ SetConsoleTitleA(title);
+#endif
+}
+
+int PDC_set_blink(bool blinkon)
+{
+ if (pdc_color_started)
+ COLORS = 16;
+
+ return blinkon ? ERR : OK;
+}
diff --git a/payloads/libpayload/curses/PDCurses-3.4/win32/pdcurses.ico b/payloads/libpayload/curses/PDCurses-3.4/win32/pdcurses.ico
new file mode 100644
index 0000000000..53a6dde3c9
--- /dev/null
+++ b/payloads/libpayload/curses/PDCurses-3.4/win32/pdcurses.ico
Binary files differ
diff --git a/payloads/libpayload/curses/PDCurses-3.4/win32/pdcurses.rc b/payloads/libpayload/curses/PDCurses-3.4/win32/pdcurses.rc
new file mode 100644
index 0000000000..1b8bba4bfc
--- /dev/null
+++ b/payloads/libpayload/curses/PDCurses-3.4/win32/pdcurses.rc
@@ -0,0 +1,28 @@
+#include "winver.h"
+
+1 VERSIONINFO
+ FILEVERSION 3,4,0,0
+ PRODUCTVERSION 3,4,0,0
+ FILEFLAGSMASK 0x3fL
+ FILEFLAGS 0x0L
+ FILEOS VOS_UNKNOWN
+ FILETYPE VFT_DLL
+ FILESUBTYPE 0x0L
+BEGIN
+ BLOCK "StringFileInfo"
+ BEGIN
+ BLOCK "040904b0"
+ BEGIN
+ VALUE "Maintainer", "William McBrine\0"
+ VALUE "FileDescription", "Public Domain Curses\0"
+ VALUE "FileVersion", "3.4.0\0"
+ VALUE "InternalName", "PDCurses\0"
+ VALUE "LegalCopyright", "Public Domain\0"
+ VALUE "OriginalFilename", "PDCURSES.DLL\0"
+ VALUE "ProductName", "Public Domain Curses Library\0"
+ VALUE "ProductVersion", "3.4.0\0"
+ END
+ END
+END
+
+1 ICON DISCARDABLE "PDCURSES.ico"
diff --git a/payloads/libpayload/curses/PDCurses-3.4/win32/pdcutil.c b/payloads/libpayload/curses/PDCurses-3.4/win32/pdcutil.c
new file mode 100644
index 0000000000..f7be019e8e
--- /dev/null
+++ b/payloads/libpayload/curses/PDCurses-3.4/win32/pdcutil.c
@@ -0,0 +1,25 @@
+/* Public Domain Curses */
+
+#include "pdcwin.h"
+
+RCSID("$Id: pdcutil.c,v 1.14 2008/07/14 04:24:52 wmcbrine Exp $")
+
+void PDC_beep(void)
+{
+ PDC_LOG(("PDC_beep() - called\n"));
+
+/* MessageBeep(MB_OK); */
+ MessageBeep(0XFFFFFFFF);
+}
+
+void PDC_napms(int ms)
+{
+ PDC_LOG(("PDC_napms() - called: ms=%d\n", ms));
+
+ Sleep(ms);
+}
+
+const char *PDC_sysname(void)
+{
+ return "Win32";
+}
diff --git a/payloads/libpayload/curses/PDCurses-3.4/win32/pdcwin.h b/payloads/libpayload/curses/PDCurses-3.4/win32/pdcwin.h
new file mode 100644
index 0000000000..bb3396f078
--- /dev/null
+++ b/payloads/libpayload/curses/PDCurses-3.4/win32/pdcwin.h
@@ -0,0 +1,17 @@
+/* Public Domain Curses */
+
+/* $Id: pdcwin.h,v 1.6 2008/07/13 06:36:32 wmcbrine Exp $ */
+
+#ifdef PDC_WIDE
+# define UNICODE
+#endif
+
+#include <windows.h>
+#undef MOUSE_MOVED
+#include <curspriv.h>
+
+extern unsigned char *pdc_atrtab;
+extern HANDLE pdc_con_out, pdc_con_in;
+extern DWORD pdc_quick_edit;
+
+extern int PDC_get_buffer_rows(void);
diff --git a/payloads/libpayload/curses/PDCurses-3.4/win32/vcwin32.mak b/payloads/libpayload/curses/PDCurses-3.4/win32/vcwin32.mak
new file mode 100644
index 0000000000..b8dc4043b7
--- /dev/null
+++ b/payloads/libpayload/curses/PDCurses-3.4/win32/vcwin32.mak
@@ -0,0 +1,136 @@
+# Visual C++ NMakefile for PDCurses library - Win32 VC++ 2.0+
+#
+# Usage: nmake -f [path\]vcwin32.mak [DEBUG=] [DLL=] [WIDE=] [UTF8=] [target]
+#
+# where target can be any of:
+# [all|demos|pdcurses.lib|testcurs.exe...]
+
+O = obj
+
+!ifndef PDCURSES_SRCDIR
+PDCURSES_SRCDIR = ..
+!endif
+
+!include $(PDCURSES_SRCDIR)\version.mif
+!include $(PDCURSES_SRCDIR)\libobjs.mif
+
+osdir = $(PDCURSES_SRCDIR)\win32
+
+PDCURSES_WIN_H = $(osdir)\pdcwin.h
+
+CC = cl.exe -nologo
+
+!ifdef DEBUG
+CFLAGS = -Z7 -DPDCDEBUG
+LDFLAGS = -debug -pdb:none
+!else
+CFLAGS = -O1
+LDFLAGS =
+!endif
+
+BASEDEF = $(PDCURSES_SRCDIR)\exp-base.def
+WIDEDEF = $(PDCURSES_SRCDIR)\exp-wide.def
+
+DEFDEPS = $(BASEDEF)
+
+!ifdef WIDE
+WIDEOPT = -DPDC_WIDE
+DEFDEPS = $(DEFDEPS) $(WIDEDEF)
+!endif
+
+!ifdef UTF8
+UTF8OPT = -DPDC_FORCE_UTF8
+!endif
+
+DEFFILE = pdcurses.def
+SHL_LD = link $(LDFLAGS) /NOLOGO /DLL /OUT:pdcurses.dll /DEF:$(DEFFILE)
+
+LINK = link.exe -nologo
+
+CCLIBS = user32.lib advapi32.lib
+# may need to add msvcrt.lib for VC 2.x, VC 5.0 doesn't want it
+#CCLIBS = msvcrt.lib user32.lib advapi32.lib
+
+LIBEXE = lib -nologo
+
+LIBCURSES = pdcurses.lib
+CURSESDLL = pdcurses.dll
+
+!ifdef DLL
+DLLOPT = -DPDC_DLL_BUILD
+PDCLIBS = $(CURSESDLL)
+!else
+PDCLIBS = $(LIBCURSES)
+!endif
+
+BUILD = $(CC) -I$(PDCURSES_SRCDIR) -c $(CFLAGS) $(DLLOPT) \
+$(WIDEOPT) $(UTF8OPT)
+
+all: $(PDCLIBS) $(DEMOS)
+
+clean:
+ -del *.obj
+ -del *.lib
+ -del *.exe
+ -del *.dll
+ -del *.exp
+ -del *.res
+ -del *.def
+
+DEMOOBJS = $(DEMOS:.exe=.obj) tui.obj
+
+$(LIBOBJS) $(PDCOBJS) : $(PDCURSES_HEADERS)
+$(PDCOBJS) : $(PDCURSES_WIN_H)
+$(DEMOOBJS) : $(PDCURSES_CURSES_H)
+$(DEMOS) : $(LIBCURSES)
+panel.obj : $(PANEL_HEADER)
+terminfo.obj: $(TERM_HEADER)
+
+!ifndef DLL
+$(LIBCURSES) : $(LIBOBJS) $(PDCOBJS)
+ $(LIBEXE) -out:$@ $(LIBOBJS) $(PDCOBJS)
+ -copy $(LIBCURSES) panel.lib
+!endif
+
+$(DEFFILE) : $(DEFDEPS)
+ echo LIBRARY pdcurses > $(DEFFILE)
+ echo EXPORTS >> $(DEFFILE)
+ type $(BASEDEF) >> $(DEFFILE)
+!ifdef WIDE
+ type $(WIDEDEF) >> $(DEFFILE)
+!endif
+
+$(CURSESDLL) : $(LIBOBJS) $(PDCOBJS) $(DEFFILE) pdcurses.obj
+ $(SHL_LD) $(LIBOBJS) $(PDCOBJS) pdcurses.obj $(CCLIBS)
+ -copy $(LIBCURSES) panel.lib
+
+pdcurses.res pdcurses.obj: $(osdir)\pdcurses.rc $(osdir)\pdcurses.ico
+ rc /r /fopdcurses.res $(osdir)\pdcurses.rc
+ cvtres /MACHINE:IX86 /NOLOGO /OUT:pdcurses.obj pdcurses.res
+
+{$(srcdir)\}.c{}.obj::
+ $(BUILD) $<
+
+{$(osdir)\}.c{}.obj::
+ $(BUILD) $<
+
+{$(demodir)\}.c{}.obj::
+ $(BUILD) $<
+
+.obj.exe:
+ $(LINK) $(LDFLAGS) $< $(LIBCURSES) $(CCLIBS)
+
+tuidemo.exe: tuidemo.obj tui.obj
+ $(LINK) $(LDFLAGS) $*.obj tui.obj $(LIBCURSES) $(CCLIBS)
+
+tui.obj: $(demodir)\tui.c $(demodir)\tui.h
+ $(BUILD) -I$(demodir) $(demodir)\tui.c
+
+tuidemo.obj: $(demodir)\tuidemo.c
+ $(BUILD) -I$(demodir) $(demodir)\tuidemo.c
+
+PLATFORM1 = Visual C++
+PLATFORM2 = Microsoft Visual C/C++ for Win32
+ARCNAME = pdc$(VER)_vc_w32
+
+!include $(PDCURSES_SRCDIR)\makedist.mif
diff --git a/payloads/libpayload/curses/PDCurses-3.4/win32/wccwin32.mak b/payloads/libpayload/curses/PDCurses-3.4/win32/wccwin32.mak
new file mode 100644
index 0000000000..1363897be0
--- /dev/null
+++ b/payloads/libpayload/curses/PDCurses-3.4/win32/wccwin32.mak
@@ -0,0 +1,51 @@
+# Watcom WMAKE Makefile for PDCurses library - Win32 Watcom C/C++ 10.6+
+#
+# Usage: wmake -f [win32\]wccwin32.mak [DEBUG=Y] [WIDE=Y] [UTF8=Y] [target]
+#
+# where target can be any of:
+# [all|demos|pdcurses.lib|testcurs.exe...]
+
+!ifdef %PDCURSES_SRCDIR
+PDCURSES_SRCDIR = $(%PDCURSES_SRCDIR)
+!else
+PDCURSES_SRCDIR = ..
+!endif
+
+!include $(PDCURSES_SRCDIR)\version.mif
+
+osdir = $(PDCURSES_SRCDIR)\win32
+
+CC = wcc386
+TARGET = nt
+
+CFLAGS = /ei /zq /wx /i=$(PDCURSES_SRCDIR)
+
+!ifeq DEBUG Y
+CFLAGS += /d2 /DPDCDEBUG
+LDFLAGS = D W A op q sys $(TARGET)
+!else
+CFLAGS += /oneatx
+LDFLAGS = op q sys $(TARGET)
+!endif
+
+!ifeq WIDE Y
+CFLAGS += /DPDC_WIDE
+!endif
+
+!ifeq UTF8 Y
+CFLAGS += /DPDC_FORCE_UTF8
+!endif
+
+LIBEXE = wlib /q /n /t
+
+!include $(PDCURSES_SRCDIR)\watcom.mif
+
+$(LIBCURSES) : $(LIBOBJS) $(PDCOBJS)
+ $(LIBEXE) $@ $(LIBOBJS) $(PDCOBJS)
+ -copy $(LIBCURSES) panel.lib
+
+PLATFORM1 = Watcom C++ Win32
+PLATFORM2 = Open Watcom 1.6 for Win32
+ARCNAME = pdc$(VER)_wcc_w32
+
+!include $(PDCURSES_SRCDIR)\makedist.mif