├── .gitignore ├── COPYING.LIB ├── Make.rules.in ├── Makefile.in ├── README ├── TODO ├── config.guess ├── config.sub ├── configure ├── configure.ac ├── documents └── mingw-osx-install.txt ├── gen-packagemap.pl ├── include ├── .gitignore ├── basetsd.h ├── common │ ├── ntgdi.h │ └── ntuser.h ├── config.h.in ├── guiddef.h ├── ntstatus.h ├── ntsyscall.h ├── poppack.h ├── pshpack1.h ├── pshpack2.h ├── pshpack4.h ├── pshpack8.h ├── uisyscall.h ├── windef.h ├── wingdi.h ├── winioctl.h ├── winnt.h ├── winternl.h └── winuser.h ├── install-sh ├── kernel ├── .gitignore ├── Makefile.in ├── alloc_bitmap.cpp ├── alloc_bitmap.h ├── atom.cpp ├── bitmap.cpp ├── block.cpp ├── client.c ├── client.h ├── completion.cpp ├── count_args.pl ├── debug.cpp ├── debug.h ├── driver.cpp ├── enc.c ├── event.cpp ├── event.h ├── fiber.cpp ├── fiber.h ├── fiber_test.cpp ├── file.cpp ├── file.h ├── job.cpp ├── kthread.cpp ├── list.h ├── mailslot.cpp ├── main.cpp ├── mem.cpp ├── mem.h ├── message.cpp ├── message.h ├── mutant.cpp ├── namedpipe.cpp ├── ntcall.cpp ├── ntcall.h ├── ntgdi.cpp ├── ntuser.cpp ├── ntwin32.h ├── null_display.cpp ├── null_display.h ├── objdir.cpp ├── objdir.h ├── object.cpp ├── object.h ├── object.inl ├── platform.cpp ├── platform.h ├── port.cpp ├── process.cpp ├── process.h ├── profile.cpp ├── ptrace_base.cpp ├── ptrace_base.h ├── ptrace_if.c ├── ptrace_if.h ├── queue.cpp ├── queue.h ├── random.cpp ├── reg.cpp ├── region.cpp ├── region.h ├── sdl.cpp ├── sdl.h ├── section.cpp ├── section.h ├── semaphore.cpp ├── skas.cpp ├── spy.cpp ├── spy.h ├── symlink.cpp ├── symlink.h ├── syscall.cpp ├── syscall_stat.pl ├── thread.cpp ├── thread.h ├── timer.cpp ├── timer.h ├── token.cpp ├── token.h ├── tt.cpp ├── unicode.cpp ├── unicode.h ├── win.h └── win32mgr.h ├── libmspack ├── .gitignore ├── Makefile.in ├── README ├── cab.h ├── cabc.c ├── cabd.c ├── chm.h ├── chmc.c ├── chmd.c ├── des.h ├── hlp.h ├── hlpc.c ├── hlpd.c ├── kwaj.h ├── kwajc.c ├── kwajd.c ├── lit.h ├── litc.c ├── litd.c ├── lzss.h ├── lzx.h ├── lzxc.c ├── lzxd.c ├── mspack.h ├── mszip.h ├── mszipc.c ├── mszipd.c ├── qtm.h ├── qtmd.c ├── sha.h ├── system.c ├── system.h ├── szdd.h ├── szddc.c └── szddd.c ├── libntreg ├── .gitignore ├── Makefile.in ├── ntreg.c └── ntreg.h ├── libudis86 ├── .gitignore ├── Makefile.in ├── decode.c ├── extern.h ├── input.c ├── input.h ├── mnemonics.dat ├── mnemonics.pl ├── opcmap.c ├── opcmap.h ├── syn-att.c ├── syn-intel.c ├── syn.c ├── syn.h ├── types.h └── udis86.c ├── packagemap.xml ├── programs ├── Makefile.in ├── clock │ ├── .gitignore │ ├── Makefile.in │ └── clock.c ├── minitris │ ├── .gitignore │ ├── Makefile.in │ └── minitris.c ├── minshell │ ├── .gitignore │ ├── Makefile.in │ └── minshell.c ├── pixels │ ├── .gitignore │ ├── Makefile.in │ └── pixels.c ├── winemine │ ├── .gitignore │ ├── Cs.rc │ ├── Da.rc │ ├── De.rc │ ├── En.rc │ ├── Es.rc │ ├── Fi.rc │ ├── Fr.rc │ ├── It.rc │ ├── Ja.rc │ ├── Ko.rc │ ├── Makefile.in │ ├── Nl.rc │ ├── No.rc │ ├── Pl.rc │ ├── Pt.rc │ ├── README │ ├── Ro.rc │ ├── Ru.rc │ ├── Si.rc │ ├── Tr.rc │ ├── Zh.rc │ ├── dialog.c │ ├── faces.bmp │ ├── leds.bmp │ ├── main.c │ ├── main.h │ ├── mines.bmp │ ├── resource.h │ ├── rsrc.rc │ ├── winemine.ico │ └── winemine.svg └── winlogon │ ├── .gitignore │ ├── Makefile.in │ └── winlogon.c ├── regedit ├── .gitignore ├── Makefile.in ├── main.cpp ├── regedit.pro ├── registryeditor.cpp ├── registryeditor.h ├── registryitem.cpp ├── registryitem.h ├── registrymodel.cpp ├── registrymodel.h ├── registrytreeview.cpp ├── registrytreeview.h ├── registryvalue.cpp └── registryvalue.h ├── ring3k-setup.in ├── ring3k.in ├── runtest ├── tests ├── .gitignore ├── Makefile.in ├── atom.c ├── completion.c ├── device.c ├── event.c ├── eventpair.c ├── file.c ├── font.c ├── gdi.c ├── gen_syscalls.pl ├── heap.c ├── hostnt.c ├── job.c ├── key.c ├── log.c ├── log.h ├── mailslot.c ├── mutant.c ├── native.c ├── ntapi.h ├── ntwin32.h ├── object.c ├── pipe.c ├── port.c ├── process.c ├── ps.c ├── reg.c ├── rtlapi.h ├── runnt.c ├── section.c ├── seh.c ├── sema.c ├── smss.c ├── syscall.c ├── thread.c ├── timer.c ├── token.c ├── user.c ├── virtual.c ├── win2k │ └── ntwin32.in ├── wine-atom.c ├── wine-port.c └── winxp │ └── ntwin32.in ├── tools ├── .gitignore ├── Makefile.in ├── advapi32.c ├── console.c ├── dumphandles.c ├── qdf.c ├── startcmd.c └── track.c └── unpack ├── .gitignore ├── Makefile.in └── unpack.c /.gitignore: -------------------------------------------------------------------------------- 1 | *.diff 2 | *.iso 3 | *.o 4 | *.a 5 | *.lib 6 | *.dll 7 | autom4te.cache 8 | config.log 9 | config.status 10 | drive 11 | Makefile 12 | Make.rules 13 | ring3k 14 | ring3k-setup 15 | reg.xml 16 | core-* 17 | -------------------------------------------------------------------------------- /Make.rules.in: -------------------------------------------------------------------------------- 1 | 2 | dummy: 3 | 4 | $(SUBDIRS): dummy 5 | @cd $@ && $(MAKE) 6 | 7 | $(SUBDIRS:%=%/__clean__): dummy 8 | @cd `dirname $@` && $(MAKE) clean 9 | 10 | $(SUBDIRS:%=%/__install__): dummy 11 | @cd `dirname $@` && $(MAKE) install 12 | 13 | $(SUBDIRS:%=%/__uninstall__): dummy 14 | @cd `dirname $@` && $(MAKE) uninstall 15 | 16 | install:: $(INSTALLSUBDIRS:%=%/__install__) dummy 17 | uninstall:: $(INSTALLSUBDIRS:%=%/__uninstall__) dummy 18 | clean:: $(SUBDIRS:%=%/__clean__) 19 | 20 | -------------------------------------------------------------------------------- /Makefile.in: -------------------------------------------------------------------------------- 1 | # 2 | # ring3k - a user mode kernel for windows executables 3 | # 4 | # Copyright 2006-2009 Mike McCormack 5 | # 6 | # This library is free software; you can redistribute it and/or 7 | # modify it under the terms of the GNU Lesser General Public 8 | # License as published by the Free Software Foundation; either 9 | # version 2.1 of the License, or (at your option) any later version. 10 | # 11 | # This library is distributed in the hope that it will be useful, 12 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 14 | # Lesser General Public License for more details. 15 | # 16 | # You should have received a copy of the GNU Lesser General Public 17 | # License along with this library; if not, write to the Free Software 18 | # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA 19 | # 20 | 21 | srcdir = @srcdir@ 22 | VPATH = @srcdir@ 23 | 24 | prefix = @prefix@ 25 | bindir = ${prefix}/bin 26 | 27 | INSTALL = @INSTALL@ 28 | INSTALL_SCRIPT = @INSTALL_SCRIPT@ 29 | 30 | LAUNCH_SCRIPT = ring3k 31 | SETUP_SCRIPT = ring3k-setup 32 | 33 | RM = rm -f 34 | 35 | SUBDIRS = \ 36 | libudis86 \ 37 | libmspack \ 38 | libntreg \ 39 | kernel \ 40 | programs \ 41 | tests \ 42 | tools \ 43 | regedit \ 44 | unpack 45 | 46 | INSTALLSUBDIRS = \ 47 | kernel \ 48 | programs \ 49 | unpack 50 | 51 | all: $(SUBDIRS) $(LAUNCH_SCRIPT) $(SETUP_SCRIPT) 52 | 53 | .PHONY: \ 54 | $(SUBDIRS) 55 | all \ 56 | clean \ 57 | distclean \ 58 | test 59 | 60 | $(LAUNCH_SCRIPT): ring3k.in 61 | cp -f $< $@ 62 | 63 | $(SETUP_SCRIPT): ring3k-setup.in 64 | cp -f $< $@ 65 | 66 | stat: 67 | cd kernel && make stat 68 | 69 | clean:: 70 | $(RM) $(LAUNCH_SCRIPT) $(SETUP_SCRIPT) 71 | 72 | distclean: clean 73 | rm -rf drive 74 | rm -rf config.status config.log autom4te.cache Make.rules 75 | find . -name Makefile -exec rm {} \; 76 | 77 | install:: $(LAUNCH_SCRIPT) $(SETUP_SCRIPT) 78 | mkdir -p $(DESTDIR)$(bindir) 79 | $(INSTALL_SCRIPT) $(INSTALL_FLAGS) $(LAUNCH_SCRIPT) $(DESTDIR)$(bindir) 80 | $(INSTALL_SCRIPT) $(INSTALL_FLAGS) $(SETUP_SCRIPT) $(DESTDIR)$(bindir) 81 | 82 | uninstall:: 83 | $(RM) $(DESTDIR)$(bindir)/$(LAUNCH_SCRIPT) 84 | $(RM) $(DESTDIR)$(bindir)/$(SETUP_SCRIPT) 85 | 86 | TESTLIST = \ 87 | completion \ 88 | device \ 89 | event \ 90 | file \ 91 | font \ 92 | gdi \ 93 | heap \ 94 | job \ 95 | mailslot \ 96 | mutant \ 97 | object \ 98 | port \ 99 | process \ 100 | reg \ 101 | section \ 102 | seh \ 103 | sema \ 104 | syscall \ 105 | thread \ 106 | timer \ 107 | token \ 108 | user \ 109 | virtual \ 110 | wine-port 111 | 112 | test: all 113 | @echo "Thread tracing tests" 114 | for tc in $(TESTLIST) ; do echo $$tc ; ./runtest $$tc || exit 1 ; done 115 | 116 | help: 117 | @echo "Available targets are:" 118 | @echo 119 | @echo " all Build ring3k and tests (default)" 120 | @echo " clean Clean temporary files and executables" 121 | @echo " distclean Clean everything" 122 | @echo " install Install" 123 | @echo " stat Display some statistics about the project" 124 | @echo " test Build and run regression tests (requires win2k.iso)" 125 | @echo " uninstall Remove installed files" 126 | @echo 127 | 128 | @MAKE_RULES@ 129 | -------------------------------------------------------------------------------- /TODO: -------------------------------------------------------------------------------- 1 | Things to do: 2 | 3 | - create a gdb stub 4 | - remove dependency of tests on native ntdll.dll 5 | - catch exceptions thrown by new 6 | - figure out how to run cmd.exe 7 | - make all waits safe for terminate (and suspend) 8 | write a test for thread exit issues and fix 9 | - implement mailslots 10 | - implement NtQueryInformationToken 0x20 11 (nil) 0 0x6f5fc 11 | - document registry format 12 | - check memory leaks 13 | - create a context_t to manage registers 14 | - default registry values 15 | - read/write native registry format 16 | - documentation in textinfo 17 | - fix make install target 18 | 19 | but one file gets installed into the "wrong" location 20 | actually it is the minitris.exe 21 | /usr/data/minitris.exe 22 | is obviously "wrong" :D 23 | should be using something like @DATADIR@/ring3k/ maybe? 24 | or rather the libdir/ring3k 25 | because it is an executeable. 26 | 27 | 28 | Semi Completed: 29 | - timers 30 | - preemptive scheduling 31 | - registry 32 | - directories/files 33 | - memory 34 | - tokens/security 35 | - object symbolic links 36 | - figure out what SeRmCommandPort is -> SeRm = Security Reference Monitor 37 | Implement a port server in kernel 38 | - figure out how ConnectNamePipe, WaitNamedPipe, CallNamedPipe work 39 | - separate registry binary and hex values so 40 | hex can be written 1 41 | - test program for named pipes 42 | - test program for mailslots 43 | - make object store hierachical 44 | - integrate NtCreateFile with the object management code 45 | - implement named pipes 46 | - fix cases where non-zero status can be success 47 | - use file_t* instead of fds in blocks and sections 48 | - move binary to root directory 49 | - figure out ntsvcs (http://www.hsc.fr/ressources/articles/win_net_srv/msrpc_pnp.html) 50 | - figure out why smss.exe is hitting a breakpoint at startup 51 | 52 | -------------------------------------------------------------------------------- /documents/mingw-osx-install.txt: -------------------------------------------------------------------------------- 1 | 2 | Build and install gmp 4.2.2 3 | --------------------------- 4 | ./configure --prefix=/opt/gmp-4.2.2 --enable-shared 5 | sudo make install 6 | 7 | Build and install mpfr 2.3.1 8 | ---------------------------- 9 | ./configure --prefix=/opt/mpfr-2.3.1 --enable-shared --with-gmp=/opt/gmp-4.2.2 10 | sudo make install 11 | 12 | Build and install gcc 4.3.0 (native) 13 | ------------------------------------ 14 | mkdir gcc-4.3.0-build 15 | ../gcc-4.3.0/configure --prefix=/opt/gcc-4.3.0 --enable-threads --disable-nls --enable-languages=c,c++ --with-gmp=/opt/gmp-4.2.2 --with-mpfr=/opt/mpfr-2.3.1/ 16 | sudo make install 17 | 18 | Build and install binutils (mingw32 cross) 19 | ------------------------------------------ 20 | mkdir binutils-2.18.50-build 21 | ../binutils-2.18.50/configure --prefix=/opt/mingw32 --target=i686-pc-mingw32 22 | sudo make install 23 | 24 | Download and extract mingw-runtime-3.14-src.tar.gz 25 | -------------------------------------------------- 26 | cp -R mingw-runtime-3.14/include /opt/mingw32/i686-pc-mingw32/ 27 | 28 | Download w32api-3.11.tar.gz 29 | cd /opt/mingw32/i686-pc-mingw32/ 30 | tar zxvf w32api-3.11.tar.gz 31 | 32 | Build and install gcc (mingw32 cross) 33 | ------------------------------------- 34 | 35 | mkdir gcc-4.3.0-mingw-build 36 | cd gcc-4.3.0-mingw-build 37 | PATH=$PATH:/opt/mingw32/bin CC=/opt/gcc-4.3.0/bin/gcc ../gcc-4.3.0/configure --with-gcc --target=i686-pc-mingw32 --prefix=/opt/mingw32 --enable-threads --disable-nls --enable-languages=c --disable-long-long --with-gmp=/opt/gmp-4.2.2 --with-mpfr=/opt/mpfr-2.3.1 38 | PATH=$PATH:/opt/mingw32/bin make 39 | sudo make install 40 | 41 | Build and install the mingw runtime 42 | ----------------------------------- 43 | PATH=/opt/mingw32/bin:$PATH AS=i686-pc-mingw32-as RANLIB=i686-pc-mingw32-ranlib CC=i686-pc-mingw32-gcc AR=i686-pc-mingw32-ar DLLTOOL=i686-pc-mingw32-dlltool LD=i686-pc-mingw32-ld ./configure --target=i686-pc-mingw32 --prefix=/opt/mingw32/i686-pc-mingw32/ 44 | 45 | -------------------------------------------------------------------------------- /gen-packagemap.pl: -------------------------------------------------------------------------------- 1 | #!/usr/bin/perl 2 | # generate a packagemap definition from the ring3k git repository 3 | 4 | open(IN,"git ls-tree -r --name-only HEAD|") || die "git ls-tree failed"; 5 | open(OUT,">packagemap.xml"); 6 | print OUT "\n"; 7 | print OUT "\n"; 8 | while() 9 | { 10 | chomp; 11 | my $file = $_; 12 | 13 | # ignore some files 14 | next if ($file =~ /\.gitignore$/ ); 15 | next if ($file =~ /README$/ ); 16 | next if ($file =~ /^COPYING\.LIB$/ ); 17 | next if ($file =~ /install-sh$/ ); 18 | next if ($file =~ /^documents/ ); 19 | next if ($file =~ /^configure$/ ); 20 | next if ($file =~ /^config\.sub$/ ); 21 | next if ($file =~ /^config\.guess$/ ); 22 | next if ($file =~ /^config\.status$/ ); 23 | next if ($file =~ /config\.h\.in$/ ); 24 | next if ($file =~ /^TODO$/ ); 25 | next if ($file =~ /\.rc$/ ); 26 | next if ($file =~ /\.bmp$/ ); 27 | next if ($file =~ /\.ico$/ ); 28 | next if ($file =~ /\.dat$/ ); 29 | next if ($file =~ /ntwin32\.in$/ ); 30 | 31 | # classify everything else 32 | if ($file =~ /^ring3k-setup\.in$/ ) { 33 | $type = "shell"; 34 | } elsif ($file =~ /^ring3k\.in$/ ) { 35 | $type = "shell"; 36 | } elsif ($file =~ /^runtest$/ ) { 37 | $type = "shell"; 38 | } elsif ($file =~ /\.cpp$/ ) { 39 | $type = "C++"; 40 | } elsif ($file =~ /kernel\/.*\.h$/ ) { 41 | $type = "C++"; 42 | } elsif ($file =~ /\.inl$/ ) { 43 | $type = "C++"; 44 | } elsif ($file =~ /\.h$/ ) { 45 | $type = "C"; 46 | } elsif ($file =~ /\.c$/ ) { 47 | $type = "C"; 48 | } elsif ($file =~ /Makefile\.in$/ ) { 49 | $type = "makefile"; 50 | } elsif ($file =~ /Make\.rules\.in$/ ) { 51 | $type = "makefile"; 52 | } elsif ($file =~ /\.pro$/ ) { 53 | $type = "makefile"; 54 | } elsif ($file =~ /^configure.ac$/ ) { 55 | $type = "autoconf"; 56 | } elsif ($file =~ /\.xml\.in$/ ) { 57 | $type = "xml"; 58 | } elsif ($file =~ /\.xml$/ ) { 59 | $type = "xml"; 60 | } elsif ($file =~ /\.pl$/ ) { 61 | $type = "perl"; 62 | } elsif ($file =~ /\.svg$/ ) { 63 | $type = "svg"; 64 | } else { 65 | print STDERR "unclassified file $file\n"; 66 | next; 67 | } 68 | 69 | print OUT " $file\n"; 70 | print OUT " $type\n"; 71 | } 72 | print OUT "\n"; 73 | close IN; 74 | close OUT; 75 | -------------------------------------------------------------------------------- /include/.gitignore: -------------------------------------------------------------------------------- 1 | config.h 2 | -------------------------------------------------------------------------------- /include/config.h.in: -------------------------------------------------------------------------------- 1 | /* include/config.h.in. Generated from configure.ac by autoheader. */ 2 | 3 | /* Symbol prefix */ 4 | #undef ASM_NAME_PREFIX 5 | 6 | /* Define to 1 if you have the header file. */ 7 | #undef HAVE_ASM_PTRACE_H 8 | 9 | /* Define to 1 if you have the `clone' function. */ 10 | #undef HAVE_CLONE 11 | 12 | /* Define if you have the Freetype 2 library */ 13 | #undef HAVE_FREETYPE 14 | 15 | /* Define to 1 if you have the header file. */ 16 | #undef HAVE_FREETYPE_FREETYPE_H 17 | 18 | /* Define to 1 if you have the `fstatat' function. */ 19 | #undef HAVE_FSTATAT 20 | 21 | /* Define to 1 if you have the header file. */ 22 | #undef HAVE_FT2BUILD_H 23 | 24 | /* Define to 1 if you have the header file. */ 25 | #undef HAVE_INTTYPES_H 26 | 27 | /* Define if you have the libxml2 library */ 28 | #undef HAVE_LIBXML2 29 | 30 | /* Define to 1 if you have the header file. */ 31 | #undef HAVE_LIBXML_PARSER_H 32 | 33 | /* Define to 1 if you have the header file. */ 34 | #undef HAVE_MEMORY_H 35 | 36 | /* Define if you have the SDL-1.2 library */ 37 | #undef HAVE_SDL 38 | 39 | /* Define to 1 if you have the header file. */ 40 | #undef HAVE_SDL_SDL_H 41 | 42 | /* Define to 1 if you have the `sigqueue' function. */ 43 | #undef HAVE_SIGQUEUE 44 | 45 | /* Define to 1 if you have the header file. */ 46 | #undef HAVE_STDINT_H 47 | 48 | /* Define to 1 if you have the header file. */ 49 | #undef HAVE_STDLIB_H 50 | 51 | /* Define to 1 if you have the header file. */ 52 | #undef HAVE_STRINGS_H 53 | 54 | /* Define to 1 if you have the header file. */ 55 | #undef HAVE_STRING_H 56 | 57 | /* Define to 1 if you have the header file. */ 58 | #undef HAVE_SYS_STAT_H 59 | 60 | /* Define to 1 if you have the header file. */ 61 | #undef HAVE_SYS_TYPES_H 62 | 63 | /* Define to 1 if you have the header file. */ 64 | #undef HAVE_UNISTD_H 65 | 66 | /* Define to 1 if you have the header file. */ 67 | #undef HAVE_VALGRIND_VALGRIND_H 68 | 69 | /* Define to the address where bug reports for this package should be sent. */ 70 | #undef PACKAGE_BUGREPORT 71 | 72 | /* Define to the full name of this package. */ 73 | #undef PACKAGE_NAME 74 | 75 | /* Define to the full name and version of this package. */ 76 | #undef PACKAGE_STRING 77 | 78 | /* Define to the one symbol short name of this package. */ 79 | #undef PACKAGE_TARNAME 80 | 81 | /* Define to the version of this package. */ 82 | #undef PACKAGE_VERSION 83 | 84 | /* Define to 1 if you have the ANSI C header files. */ 85 | #undef STDC_HEADERS 86 | -------------------------------------------------------------------------------- /include/guiddef.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2000 Alexandre Julliard 3 | * 4 | * This library is free software; you can redistribute it and/or 5 | * modify it under the terms of the GNU Lesser General Public 6 | * License as published by the Free Software Foundation; either 7 | * version 2.1 of the License, or (at your option) any later version. 8 | * 9 | * This library is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 12 | * Lesser General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU Lesser General Public 15 | * License along with this library; if not, write to the Free Software 16 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 17 | */ 18 | 19 | #ifndef GUID_DEFINED 20 | #define GUID_DEFINED 21 | typedef struct _GUID 22 | { 23 | unsigned long Data1; 24 | unsigned short Data2; 25 | unsigned short Data3; 26 | unsigned char Data4[ 8 ]; 27 | } GUID; 28 | #endif 29 | 30 | #ifndef __LPCGUID_DEFINED__ 31 | #define __LPCGUID_DEFINED__ 32 | typedef const GUID *LPCGUID; 33 | #endif 34 | 35 | #undef DEFINE_GUID 36 | 37 | #ifdef INITGUID 38 | #define DEFINE_GUID(name, l, w1, w2, b1, b2, b3, b4, b5, b6, b7, b8) \ 39 | const GUID name = \ 40 | { l, w1, w2, { b1, b2, b3, b4, b5, b6, b7, b8 } } 41 | #else 42 | #define DEFINE_GUID(name, l, w1, w2, b1, b2, b3, b4, b5, b6, b7, b8) \ 43 | extern const GUID name 44 | #endif 45 | 46 | #define DEFINE_OLEGUID(name, l, w1, w2) \ 47 | DEFINE_GUID(name, l, w1, w2, 0xC0,0,0,0,0,0,0,0x46) 48 | 49 | #ifndef _GUIDDEF_H_ 50 | #define _GUIDDEF_H_ 51 | 52 | typedef GUID *LPGUID; 53 | typedef GUID CLSID,*LPCLSID; 54 | #ifndef __IID_DEFINED__ 55 | #define __IID_DEFINED__ 56 | typedef GUID IID,*LPIID; 57 | #endif /* ndef __IID_DEFINED__ */ 58 | typedef GUID FMTID,*LPFMTID; 59 | 60 | #ifdef __midl_proxy 61 | #define __MIDL_CONST 62 | #else 63 | #define __MIDL_CONST const 64 | #endif 65 | 66 | #if defined(__cplusplus) && !defined(CINTERFACE) 67 | #define REFGUID const GUID & 68 | #define REFCLSID const CLSID & 69 | #define REFIID const IID & 70 | #define REFFMTID const FMTID & 71 | #else /* !defined(__cplusplus) && !defined(CINTERFACE) */ 72 | #define REFGUID const GUID* __MIDL_CONST 73 | #define REFCLSID const CLSID* __MIDL_CONST 74 | #define REFIID const IID* __MIDL_CONST 75 | #define REFFMTID const FMTID* __MIDL_CONST 76 | #endif /* !defined(__cplusplus) && !defined(CINTERFACE) */ 77 | 78 | #if defined(__cplusplus) && !defined(CINTERFACE) 79 | #define IsEqualGUID(rguid1, rguid2) (!memcmp(&(rguid1), &(rguid2), sizeof(GUID))) 80 | #else /* defined(__cplusplus) && !defined(CINTERFACE) */ 81 | #define IsEqualGUID(rguid1, rguid2) (!memcmp(rguid1, rguid2, sizeof(GUID))) 82 | #endif /* defined(__cplusplus) && !defined(CINTERFACE) */ 83 | #define IsEqualIID(riid1, riid2) IsEqualGUID(riid1, riid2) 84 | #define IsEqualCLSID(rclsid1, rclsid2) IsEqualGUID(rclsid1, rclsid2) 85 | 86 | #if defined(__cplusplus) && !defined(CINTERFACE) 87 | #include 88 | inline bool operator==(const GUID& guidOne, const GUID& guidOther) 89 | { 90 | return !memcmp(&guidOne,&guidOther,sizeof(GUID)); 91 | } 92 | inline bool operator!=(const GUID& guidOne, const GUID& guidOther) 93 | { 94 | return !(guidOne == guidOther); 95 | } 96 | #endif 97 | 98 | extern const IID GUID_NULL; 99 | #define IID_NULL GUID_NULL 100 | #define CLSID_NULL GUID_NULL 101 | #define FMTID_NULL GUID_NULL 102 | 103 | #endif /* _GUIDDEF_H_ */ 104 | -------------------------------------------------------------------------------- /include/poppack.h: -------------------------------------------------------------------------------- 1 | #pragma pack() 2 | -------------------------------------------------------------------------------- /include/pshpack1.h: -------------------------------------------------------------------------------- 1 | #pragma pack(1) 2 | -------------------------------------------------------------------------------- /include/pshpack2.h: -------------------------------------------------------------------------------- 1 | #pragma pack(2) 2 | -------------------------------------------------------------------------------- /include/pshpack4.h: -------------------------------------------------------------------------------- 1 | #pragma pack(4) 2 | -------------------------------------------------------------------------------- /include/pshpack8.h: -------------------------------------------------------------------------------- 1 | #pragma pack(8) 2 | -------------------------------------------------------------------------------- /kernel/.gitignore: -------------------------------------------------------------------------------- 1 | Makefile 2 | *.o 3 | enc 4 | fiber 5 | ring3k-bin 6 | ring3k-client 7 | .*.dpp 8 | .*.d 9 | -------------------------------------------------------------------------------- /kernel/alloc_bitmap.h: -------------------------------------------------------------------------------- 1 | /* 2 | * nt loader 3 | * 4 | * Copyright 2006-2008 Mike McCormack 5 | * 6 | * This library is free software; you can redistribute it and/or 7 | * modify it under the terms of the GNU Lesser General Public 8 | * License as published by the Free Software Foundation; either 9 | * version 2.1 of the License, or (at your option) any later version. 10 | * 11 | * This library is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 14 | * Lesser General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU Lesser General Public 17 | * License along with this library; if not, write to the Free Software 18 | * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA 19 | */ 20 | 21 | #ifndef __ALLOC_BITMAP__ 22 | #define __ALLOC_BITMAP__ 23 | 24 | #include 25 | 26 | // TODO: optimize 27 | class allocation_bitmap_t 28 | { 29 | static const size_t allocation_granularity = 8; 30 | size_t size; 31 | size_t array_size; 32 | size_t max_bits; 33 | unsigned char *bitmap; 34 | unsigned char *ptr; 35 | protected: 36 | bool bit_value( size_t n ) { return bitmap[n/8] & (1 << (n%8)); } 37 | void set_bit( size_t n ) { bitmap[n/8] |= (1 << (n%8)); } 38 | void clear_bit( size_t n ) { bitmap[n/8] &= ~(1 << (n%8)); } 39 | size_t count_zero_bits( size_t start, size_t max ); 40 | size_t count_one_bits( size_t start, size_t max ); 41 | void set_bits( size_t start, size_t count ); 42 | void clear_bits( size_t start, size_t count ); 43 | size_t bits_required( size_t len ); 44 | public: 45 | allocation_bitmap_t(); 46 | void set_area( void *_ptr, size_t _size ); 47 | unsigned char *alloc( size_t len ); 48 | void free( unsigned char *start ); 49 | void free( unsigned char *mem, size_t len ); 50 | void get_info( size_t& total, size_t& used, size_t& free ); 51 | static void test(); // unit test for validating the code 52 | }; 53 | 54 | #endif // __ALLOC_BITMAP__ 55 | 56 | -------------------------------------------------------------------------------- /kernel/atom.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * nt loader 3 | * 4 | * Copyright 2006-2008 Mike McCormack 5 | * 6 | * This library is free software; you can redistribute it and/or 7 | * modify it under the terms of the GNU Lesser General Public 8 | * License as published by the Free Software Foundation; either 9 | * version 2.1 of the License, or (at your option) any later version. 10 | * 11 | * This library is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 14 | * Lesser General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU Lesser General Public 17 | * License along with this library; if not, write to the Free Software 18 | * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA 19 | */ 20 | 21 | 22 | #include 23 | 24 | #include "ntstatus.h" 25 | #define WIN32_NO_STATUS 26 | #include "windef.h" 27 | #include "winternl.h" 28 | 29 | #include "debug.h" 30 | 31 | NTSTATUS NTAPI NtAddAtom( 32 | PWSTR String, 33 | ULONG StringLength, 34 | PUSHORT Atom) 35 | { 36 | trace("%p %lu %p\n", String, StringLength, Atom); 37 | return STATUS_NOT_IMPLEMENTED; 38 | } 39 | 40 | NTSTATUS NTAPI NtFindAtom( 41 | PWSTR String, 42 | ULONG StringLength, 43 | PUSHORT Atom) 44 | { 45 | trace("%p %lu %p\n", String, StringLength, Atom); 46 | return STATUS_NOT_IMPLEMENTED; 47 | } 48 | 49 | NTSTATUS NTAPI NtDeleteAtom( 50 | USHORT Atom) 51 | { 52 | trace("%u\n", Atom); 53 | return STATUS_NOT_IMPLEMENTED; 54 | } 55 | 56 | NTSTATUS NTAPI NtQueryInformationAtom( 57 | USHORT Atom, 58 | ATOM_INFORMATION_CLASS AtomInformationClass, 59 | PVOID AtomInformation, 60 | ULONG AtomInformationLength, 61 | PULONG ReturnLength) 62 | { 63 | trace("%u\n", Atom); 64 | return STATUS_NOT_IMPLEMENTED; 65 | } 66 | -------------------------------------------------------------------------------- /kernel/client.h: -------------------------------------------------------------------------------- 1 | /* 2 | * nt loader 3 | * 4 | * Copyright 2006-2008 Mike McCormack 5 | * 6 | * This library is free software; you can redistribute it and/or 7 | * modify it under the terms of the GNU Lesser General Public 8 | * License as published by the Free Software Foundation; either 9 | * version 2.1 of the License, or (at your option) any later version. 10 | * 11 | * This library is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 14 | * Lesser General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU Lesser General Public 17 | * License along with this library; if not, write to the Free Software 18 | * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA 19 | */ 20 | 21 | #ifndef __NTNATIVE_CLIENT_H__ 22 | #define __NTNATIVE_CLIENT_H__ 23 | 24 | enum tt_req_type { 25 | tt_req_exit, 26 | tt_req_map, 27 | tt_req_umap, 28 | tt_req_prot, 29 | }; 30 | 31 | struct tt_req_map { 32 | unsigned int pid; 33 | unsigned int fd; 34 | unsigned int addr; 35 | unsigned int len; 36 | unsigned int ofs; 37 | unsigned int prot; 38 | }; 39 | 40 | struct tt_req_umap { 41 | unsigned int addr; 42 | unsigned int len; 43 | }; 44 | 45 | struct tt_req_prot { 46 | unsigned int addr; 47 | unsigned int len; 48 | unsigned int prot; 49 | }; 50 | 51 | struct tt_req { 52 | enum tt_req_type type; 53 | union { 54 | struct tt_req_map map; 55 | struct tt_req_umap umap; 56 | struct tt_req_prot prot; 57 | } u; 58 | }; 59 | 60 | struct tt_reply { 61 | int r; 62 | }; 63 | 64 | #endif // __NTNATIVE_CLIENT_H__ 65 | 66 | -------------------------------------------------------------------------------- /kernel/count_args.pl: -------------------------------------------------------------------------------- 1 | #!/usr/bin/perl5 2 | # 3 | # System call args checker 4 | # Copyright (C) 2007 Mike McCormack 5 | # 6 | 7 | use strict; 8 | my @args; 9 | my $name; 10 | my $count; 11 | my %funcs; 12 | 13 | # 14 | # Count the number of args of each Nt function in winternl.h 15 | # 16 | open(WIN,"<../include/winternl.h") || die "winternl.h not found\n"; 17 | while() { 18 | next if ( ! s/^NTSTATUS[ ]*NTAPI[ ]*// ); 19 | next if ( ! /^Nt/ ); 20 | chomp; 21 | s/ //; 22 | $name = $_; 23 | $name =~ s/\(.*$//; 24 | @args = split /,/; 25 | $count = @args; 26 | $funcs{$name} = $count; 27 | #printf("%s -> %d\n", $name, $funcs{$name}); 28 | } 29 | close WIN; 30 | 31 | # 32 | # Check the number of args in each declaration in syscall.cpp 33 | # 34 | open(SYS,") { 36 | chomp; 37 | s/ //; 38 | next if ( ! s/[ ]*\),$// ); 39 | 40 | # check for functions that aren't declared that could be 41 | if ( s/^.*NUL\([ ]*// ) { 42 | $name = $_; 43 | next if ( !$funcs{$name} ); 44 | printf(" DEC( %s, %s ),\n", $name, $funcs{$name}); 45 | } 46 | 47 | # check for functions with the wrong number of args 48 | elsif ( s/^.*DEC\([ ]*// ) { 49 | ($name, $count) = split /,/; 50 | next if ( $count == $funcs{$name} ); 51 | printf ("args mismatch: %s %d != %d\n", $name, $count, $funcs{$name}); 52 | } 53 | } 54 | close SYS; 55 | -------------------------------------------------------------------------------- /kernel/debug.h: -------------------------------------------------------------------------------- 1 | /* 2 | * nt loader 3 | * 4 | * Copyright 2006-2008 Mike McCormack 5 | * 6 | * This library is free software; you can redistribute it and/or 7 | * modify it under the terms of the GNU Lesser General Public 8 | * License as published by the Free Software Foundation; either 9 | * version 2.1 of the License, or (at your option) any later version. 10 | * 11 | * This library is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 14 | * Lesser General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU Lesser General Public 17 | * License along with this library; if not, write to the Free Software 18 | * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA 19 | */ 20 | 21 | #ifndef _DEBUG_H_ 22 | #define _DEBUG_H_ 23 | 24 | #ifdef __cplusplus 25 | extern "C" { 26 | #endif 27 | 28 | void debugprintf(const char *file, const char *func, int line, const char *fmt, ...) __attribute__((format (printf,4,5))); 29 | void dump_mem(void *p, unsigned int len); 30 | void die(const char *fmt, ...) __attribute__((format (printf,1,2))) __attribute__((noreturn)); 31 | int dump_instruction(unsigned char *inst); 32 | void print_wide_string( unsigned short *str, int len ); 33 | 34 | extern int option_quiet; 35 | extern int option_debug; 36 | void dump_regs(CONTEXT *ctx); 37 | 38 | void debugger( void ); 39 | void debugger_backtrace(PCONTEXT ctx); 40 | 41 | #ifdef __cplusplus 42 | } 43 | #endif 44 | 45 | #define kalloc( size ) _kalloc( __FILE__, __LINE__, (size) ) 46 | #define kfree( mem ) _kfree( __FILE__, __LINE__, (mem) ) 47 | 48 | #define trace(...) debugprintf(__FILE__,__FUNCTION__,__LINE__,__VA_ARGS__) 49 | 50 | #endif // _DEBUG_H_ 51 | -------------------------------------------------------------------------------- /kernel/driver.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * nt loader 3 | * 4 | * Copyright 2006-2008 Mike McCormack 5 | * 6 | * This library is free software; you can redistribute it and/or 7 | * modify it under the terms of the GNU Lesser General Public 8 | * License as published by the Free Software Foundation; either 9 | * version 2.1 of the License, or (at your option) any later version. 10 | * 11 | * This library is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 14 | * Lesser General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU Lesser General Public 17 | * License along with this library; if not, write to the Free Software 18 | * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA 19 | */ 20 | 21 | 22 | #include 23 | 24 | #include "ntstatus.h" 25 | #define WIN32_NO_STATUS 26 | #include "windef.h" 27 | #include "winternl.h" 28 | 29 | #include "debug.h" 30 | 31 | NTSTATUS NTAPI NtLoadDriver( 32 | PUNICODE_STRING DriverServiceName) 33 | { 34 | trace("\n"); 35 | return STATUS_NOT_IMPLEMENTED; 36 | } 37 | 38 | NTSTATUS NTAPI NtUnloadDriver( 39 | PUNICODE_STRING DriverServiceName) 40 | { 41 | trace("\n"); 42 | return STATUS_NOT_IMPLEMENTED; 43 | } 44 | 45 | NTSTATUS NTAPI NtCancelDeviceWakeupRequest( 46 | HANDLE DeviceHandle) 47 | { 48 | trace("\n"); 49 | return STATUS_NOT_IMPLEMENTED; 50 | } 51 | 52 | NTSTATUS NTAPI NtGetDevicePowerState( 53 | HANDLE DeviceHandle, 54 | PDEVICE_POWER_STATE DevicePowerState) 55 | { 56 | trace("\n"); 57 | return STATUS_NOT_IMPLEMENTED; 58 | } 59 | 60 | NTSTATUS NTAPI NtInitiatePowerAction( 61 | POWER_ACTION SystemAction, 62 | SYSTEM_POWER_STATE MinSystemState, 63 | ULONG Flags, 64 | BOOLEAN Asynchronous) 65 | { 66 | trace("\n"); 67 | return STATUS_NOT_IMPLEMENTED; 68 | } 69 | 70 | NTSTATUS NTAPI NtPowerInformation( 71 | POWER_INFORMATION_LEVEL PowerInformationLevel, 72 | PVOID InputBuffer, 73 | ULONG InputBufferLength, 74 | PVOID OutputBuffer, 75 | ULONG OutputBufferLength) 76 | { 77 | trace("\n"); 78 | return STATUS_NOT_IMPLEMENTED; 79 | } 80 | 81 | NTSTATUS NTAPI NtSetSystemPowerState( 82 | POWER_ACTION SystemAction, 83 | SYSTEM_POWER_STATE MinSystemState, 84 | ULONG Flags) 85 | { 86 | trace("\n"); 87 | return STATUS_NOT_IMPLEMENTED; 88 | } 89 | 90 | BOOLEAN NTAPI NtIsSystemResumeAutomatic(void) 91 | { 92 | trace("\n"); 93 | return FALSE; 94 | } 95 | -------------------------------------------------------------------------------- /kernel/enc.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2006-2008 Mike McCormack 3 | * 4 | * This library is free software; you can redistribute it and/or 5 | * modify it under the terms of the GNU Lesser General Public 6 | * License as published by the Free Software Foundation; either 7 | * version 2.1 of the License, or (at your option) any later version. 8 | * 9 | * This library is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 12 | * Lesser General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU Lesser General Public 15 | * License along with this library; if not, write to the Free Software 16 | * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA 17 | */ 18 | 19 | #include 20 | int main(int argc, char **argv) 21 | { 22 | int i, j; 23 | 24 | for (i=1; i 25 | 26 | #include "ntstatus.h" 27 | #define WIN32_NO_STATUS 28 | #include "windef.h" 29 | #include "winternl.h" 30 | 31 | #include "object.h" 32 | 33 | class event_t : public sync_object_t { 34 | public: 35 | virtual ~event_t(); 36 | virtual BOOLEAN is_signalled( void ) = 0; 37 | virtual BOOLEAN satisfy( void ) = 0; 38 | virtual void set( PULONG prev ) = 0; 39 | virtual void reset( PULONG prev ) = 0; 40 | virtual void pulse( PULONG prev ) = 0; 41 | virtual void query(EVENT_BASIC_INFORMATION &info) = 0; 42 | virtual bool access_allowed( ACCESS_MASK required, ACCESS_MASK handle ) = 0; 43 | }; 44 | 45 | event_t* create_sync_event( PWSTR name, BOOL InitialState = 0 ); 46 | 47 | #endif // __EVENT_H__ 48 | -------------------------------------------------------------------------------- /kernel/fiber.h: -------------------------------------------------------------------------------- 1 | /* 2 | * fiber implementation 3 | * 4 | * Copyright 2006-2008 Mike McCormack 5 | * 6 | * This library is free software; you can redistribute it and/or 7 | * modify it under the terms of the GNU Lesser General Public 8 | * License as published by the Free Software Foundation; either 9 | * version 2.1 of the License, or (at your option) any later version. 10 | * 11 | * This library is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 14 | * Lesser General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU Lesser General Public 17 | * License along with this library; if not, write to the Free Software 18 | * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA 19 | */ 20 | 21 | // Fibers implement an infrastructure for cooperative multitasking 22 | // by allow multiple execution contexts in a single thread. 23 | // Being cooperative, they must be switched explicitly. 24 | // 25 | // Lots of gcc specific code here. 26 | // Tested on Linux. Windows has a native fiber implementation. 27 | 28 | #ifndef __FIBER_H__ 29 | #define __FIBER_H__ 30 | 31 | class fiber_t { 32 | struct fiber_stack_t { 33 | long ebp; 34 | long esi; 35 | long edi; 36 | long edx; 37 | long ecx; 38 | long ebx; 39 | long eax; 40 | long eip; 41 | }; 42 | 43 | private: // offset 0 = vtable pointer 44 | fiber_stack_t *stack_pointer; // offset 4 45 | fiber_t *next; // offset 8 46 | fiber_t *prev; 47 | void *stack; 48 | unsigned int stack_size; 49 | 50 | private: 51 | void remove_from_runlist(); 52 | void add_to_runlist(); 53 | fiber_t(); 54 | static int run_fiber( fiber_t* fiber ); 55 | 56 | public: 57 | static const unsigned int fiber_default_stack_size = 0x10000; 58 | static const unsigned int guard_size = 0x1000; 59 | 60 | public: 61 | static void fibers_init(); 62 | static void fibers_finish(); 63 | fiber_t( unsigned int size ); 64 | virtual ~fiber_t(); 65 | static void yield(); 66 | static bool last_fiber(); 67 | void start(); 68 | void stop(); 69 | virtual int run(); 70 | }; 71 | 72 | #endif // __FIBER_H__ 73 | -------------------------------------------------------------------------------- /kernel/fiber_test.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * nt loader 3 | * 4 | * Copyright 2006-2008 Mike McCormack 5 | * 6 | * This library is free software; you can redistribute it and/or 7 | * modify it under the terms of the GNU Lesser General Public 8 | * License as published by the Free Software Foundation; either 9 | * version 2.1 of the License, or (at your option) any later version. 10 | * 11 | * This library is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 14 | * Lesser General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU Lesser General Public 17 | * License along with this library; if not, write to the Free Software 18 | * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA 19 | */ 20 | 21 | #include 22 | #include "fiber.h" 23 | 24 | class fiber_test_t: public fiber_t 25 | { 26 | int num; 27 | public: 28 | fiber_test_t(int n); 29 | virtual int run(); 30 | }; 31 | 32 | fiber_test_t::fiber_test_t(int n) : 33 | fiber_t( fiber_default_stack_size ), 34 | num(n) 35 | { 36 | } 37 | 38 | int fiber_test_t::run() 39 | { 40 | int i; 41 | 42 | for (i=0; i<10; i++) 43 | { 44 | printf("fiber%d i=%d\n", num, i); 45 | fiber_t::yield(); 46 | } 47 | printf("fiber%d finished\n", num ); 48 | return 0; 49 | } 50 | 51 | int main(int argc, char **argv) 52 | { 53 | fiber_t::fibers_init(); 54 | fiber_t* t1 = new fiber_test_t(1); 55 | fiber_t* t2 = new fiber_test_t(2); 56 | printf("scheduling...\n"); 57 | t1->start(); 58 | t2->start(); 59 | while (!fiber_t::last_fiber()) 60 | fiber_t::yield(); 61 | delete t1; 62 | delete t2; 63 | fiber_t::fibers_finish(); 64 | printf("done\n"); 65 | return 0; 66 | } 67 | -------------------------------------------------------------------------------- /kernel/file.h: -------------------------------------------------------------------------------- 1 | /* 2 | * nt loader 3 | * 4 | * Copyright 2006-2008 Mike McCormack 5 | * 6 | * This library is free software; you can redistribute it and/or 7 | * modify it under the terms of the GNU Lesser General Public 8 | * License as published by the Free Software Foundation; either 9 | * version 2.1 of the License, or (at your option) any later version. 10 | * 11 | * This library is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 14 | * Lesser General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU Lesser General Public 17 | * License along with this library; if not, write to the Free Software 18 | * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA 19 | */ 20 | 21 | #ifndef __NTNATIVE_FILE_H__ 22 | #define __NTNATIVE_FILE_H__ 23 | 24 | #include 25 | #include 26 | #include 27 | 28 | #include "object.h" 29 | #include "event.h" 30 | 31 | class completion_port_t : public sync_object_t 32 | { 33 | public: 34 | virtual ~completion_port_t() = 0; 35 | virtual BOOLEAN is_signalled( void ) = 0; 36 | virtual BOOLEAN satisfy( void ) = 0; 37 | virtual void set(ULONG key, ULONG value, NTSTATUS status, ULONG info) = 0; 38 | virtual NTSTATUS remove(ULONG& key, ULONG& value, NTSTATUS& status, ULONG& info, PLARGE_INTEGER timeout) = 0; 39 | virtual bool access_allowed( ACCESS_MASK required, ACCESS_MASK handle ) = 0; 40 | }; 41 | 42 | void check_completions( void ); 43 | 44 | class io_object_t : virtual public object_t { 45 | completion_port_t *completion_port; 46 | ULONG completion_key; 47 | public: 48 | io_object_t(); 49 | virtual NTSTATUS read( PVOID buffer, ULONG length, ULONG *read ) = 0; 50 | virtual NTSTATUS write( PVOID buffer, ULONG length, ULONG *written ) = 0; 51 | void set_completion_port( completion_port_t *port, ULONG key ); 52 | virtual NTSTATUS set_position( LARGE_INTEGER& ofs ); 53 | virtual NTSTATUS fs_control( event_t* event, IO_STATUS_BLOCK iosb, ULONG FsControlCode, 54 | PVOID InputBuffer, ULONG InputBufferLength, PVOID OutputBuffer, ULONG OutputBufferLength ); 55 | virtual NTSTATUS set_pipe_info( FILE_PIPE_INFORMATION& pipe_info ); 56 | }; 57 | 58 | class file_t : public io_object_t { 59 | int fd; 60 | public: 61 | file_t( int fd ); 62 | ~file_t(); 63 | virtual NTSTATUS query_information( FILE_STANDARD_INFORMATION& std_info ); 64 | virtual NTSTATUS read( PVOID Buffer, ULONG Length, ULONG *read ); 65 | virtual NTSTATUS write( PVOID Buffer, ULONG Length, ULONG *written ); 66 | virtual NTSTATUS query_information( FILE_BASIC_INFORMATION& info ); 67 | virtual NTSTATUS query_information( FILE_ATTRIBUTE_TAG_INFORMATION& info ); 68 | virtual NTSTATUS set_position( LARGE_INTEGER& ofs ); 69 | virtual NTSTATUS remove(); 70 | int get_fd(); 71 | }; 72 | 73 | NTSTATUS open_file( file_t *&file, UNICODE_STRING& us ); 74 | void check_completions( void ); 75 | void init_drives(); 76 | 77 | #endif // __NTNATIVE_FILE_H__ 78 | -------------------------------------------------------------------------------- /kernel/job.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * nt loader 3 | * 4 | * Copyright 2006-2008 Mike McCormack 5 | * 6 | * This library is free software; you can redistribute it and/or 7 | * modify it under the terms of the GNU Lesser General Public 8 | * License as published by the Free Software Foundation; either 9 | * version 2.1 of the License, or (at your option) any later version. 10 | * 11 | * This library is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 14 | * Lesser General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU Lesser General Public 17 | * License along with this library; if not, write to the Free Software 18 | * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA 19 | */ 20 | 21 | 22 | #include 23 | 24 | #include "ntstatus.h" 25 | #define WIN32_NO_STATUS 26 | #include "windef.h" 27 | #include "winternl.h" 28 | 29 | #include "debug.h" 30 | 31 | NTSTATUS NTAPI NtCreateJobObject( 32 | PHANDLE JobHandle, 33 | ACCESS_MASK AccessMask, 34 | POBJECT_ATTRIBUTES ObjectAttributes) 35 | { 36 | trace("%p %08lx %p\n", JobHandle, AccessMask, ObjectAttributes); 37 | return STATUS_NOT_IMPLEMENTED; 38 | } 39 | 40 | NTSTATUS NTAPI NtOpenJobObject( 41 | PHANDLE JobHandle, 42 | ACCESS_MASK AccessMask, 43 | POBJECT_ATTRIBUTES ObjectAttributes) 44 | { 45 | trace("%p %08lx %p\n", JobHandle, AccessMask, ObjectAttributes); 46 | return STATUS_NOT_IMPLEMENTED; 47 | } 48 | 49 | NTSTATUS NTAPI NtAssignProcessToJobObject( 50 | HANDLE JobHandle, 51 | HANDLE ProcessHandle) 52 | { 53 | trace("%p %p\n", JobHandle, ProcessHandle); 54 | return STATUS_NOT_IMPLEMENTED; 55 | } 56 | 57 | NTSTATUS NTAPI NtTerminateJobObject( 58 | HANDLE JobHandle, 59 | NTSTATUS ExitStatus) 60 | { 61 | trace("%p %08lx\n", JobHandle, ExitStatus); 62 | return STATUS_NOT_IMPLEMENTED; 63 | } 64 | 65 | NTSTATUS NTAPI NtQueryInformationJobObject( 66 | HANDLE JobHandle, 67 | JOBOBJECTINFOCLASS InfoClass, 68 | PVOID JobObjectInformation, 69 | ULONG JobObjectInformationSize, 70 | PULONG ReturnLength) 71 | { 72 | trace("\n"); 73 | return STATUS_ACCESS_DENIED; 74 | } 75 | 76 | NTSTATUS NTAPI NtSetInformationJobObject( 77 | HANDLE JobHandle, 78 | JOBOBJECTINFOCLASS InfoClass, 79 | PVOID JobObjectInformation, 80 | ULONG JobObjectInformationSize) 81 | { 82 | return STATUS_NOT_IMPLEMENTED; 83 | } 84 | -------------------------------------------------------------------------------- /kernel/mailslot.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * nt loader 3 | * 4 | * Copyright 2006-2008 Mike McCormack 5 | * 6 | * This library is free software; you can redistribute it and/or 7 | * modify it under the terms of the GNU Lesser General Public 8 | * License as published by the Free Software Foundation; either 9 | * version 2.1 of the License, or (at your option) any later version. 10 | * 11 | * This library is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 14 | * Lesser General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU Lesser General Public 17 | * License along with this library; if not, write to the Free Software 18 | * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA 19 | */ 20 | 21 | 22 | #include 23 | #include 24 | 25 | #include "ntstatus.h" 26 | #define WIN32_NO_STATUS 27 | #include "windef.h" 28 | #include "winternl.h" 29 | 30 | #include "ntcall.h" 31 | #include "file.h" 32 | #include "debug.h" 33 | 34 | class mailslot_t : public io_object_t 35 | { 36 | public: 37 | virtual NTSTATUS read( PVOID Buffer, ULONG Length, ULONG *Read ); 38 | virtual NTSTATUS write( PVOID Buffer, ULONG Length, ULONG *Written ); 39 | }; 40 | 41 | NTSTATUS mailslot_t::read( PVOID Buffer, ULONG Length, ULONG *Read ) 42 | { 43 | trace("\n"); 44 | return STATUS_NOT_IMPLEMENTED; 45 | } 46 | 47 | NTSTATUS mailslot_t::write( PVOID Buffer, ULONG Length, ULONG *Written ) 48 | { 49 | trace("\n"); 50 | return STATUS_NOT_IMPLEMENTED; 51 | } 52 | 53 | class mailslot_factory : public object_factory 54 | { 55 | public: 56 | mailslot_factory() {} 57 | virtual NTSTATUS alloc_object(object_t** obj); 58 | }; 59 | 60 | NTSTATUS mailslot_factory::alloc_object(object_t** obj) 61 | { 62 | *obj = new mailslot_t; 63 | if (!*obj) 64 | return STATUS_NO_MEMORY; 65 | return STATUS_SUCCESS; 66 | } 67 | 68 | NTSTATUS NTAPI NtCreateMailslotFile( 69 | PHANDLE MailslotHandle, 70 | ACCESS_MASK AccessMask, 71 | POBJECT_ATTRIBUTES ObjectAttributes, 72 | PIO_STATUS_BLOCK IoStatusBlock, 73 | ULONG CreateOptions, 74 | ULONG InBufferSize, 75 | ULONG MaxMessageSize, 76 | PLARGE_INTEGER ReadTimeout) 77 | { 78 | trace("%p %08lx %p %p %08lx %lu %lu %p\n", MailslotHandle, AccessMask, 79 | ObjectAttributes, IoStatusBlock, CreateOptions, 80 | InBufferSize, MaxMessageSize, ReadTimeout); 81 | 82 | NTSTATUS r; 83 | 84 | r = verify_for_write( IoStatusBlock, sizeof *IoStatusBlock ); 85 | if (r < STATUS_SUCCESS) 86 | return r; 87 | 88 | if (!ObjectAttributes) 89 | return STATUS_INVALID_PARAMETER; 90 | 91 | object_attributes_t oa; 92 | r = oa.copy_from_user( ObjectAttributes ); 93 | if (r < STATUS_SUCCESS) 94 | return r; 95 | 96 | if (!oa.ObjectName) 97 | return STATUS_OBJECT_PATH_SYNTAX_BAD; 98 | 99 | // FIXME: these checks should be done in the object manager 100 | UNICODE_STRING &us = *oa.ObjectName; 101 | if (us.Length<2) 102 | return STATUS_OBJECT_PATH_SYNTAX_BAD; 103 | 104 | if (us.Length&1) 105 | return STATUS_OBJECT_NAME_INVALID; 106 | 107 | if (us.Length == 2 && us.Buffer[0] == '\\') 108 | return STATUS_OBJECT_TYPE_MISMATCH; 109 | 110 | PCWSTR ptr = (PCWSTR) L"\\??\\mailslot\\"; 111 | if (us.Length < 26 || memcmp(ptr, us.Buffer, 26)) 112 | return STATUS_OBJECT_NAME_NOT_FOUND; 113 | 114 | mailslot_factory factory; 115 | return factory.create( MailslotHandle, AccessMask, ObjectAttributes ); 116 | } 117 | 118 | -------------------------------------------------------------------------------- /kernel/ntwin32.h: -------------------------------------------------------------------------------- 1 | /* 2 | * nt loader 3 | * 4 | * Copyright 2006-2009 Mike McCormack 5 | * 6 | * This library is free software; you can redistribute it and/or 7 | * modify it under the terms of the GNU Lesser General Public 8 | * License as published by the Free Software Foundation; either 9 | * version 2.1 of the License, or (at your option) any later version. 10 | * 11 | * This library is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 14 | * Lesser General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU Lesser General Public 17 | * License along with this library; if not, write to the Free Software 18 | * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA 19 | */ 20 | 21 | #ifndef __RING3K_KERNEL_NTWIN32_H__ 22 | #define __RING3K_KERNEL_NTWIN32_H__ 23 | 24 | #include 25 | #define __ms_va_list va_list 26 | typedef void *LPSECURITY_ATTRIBUTES; 27 | #include "wingdi.h" 28 | #include "winuser.h" 29 | #include "ntgdi.h" 30 | #include "ntuser.h" 31 | 32 | #endif 33 | -------------------------------------------------------------------------------- /kernel/null_display.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * nt loader 3 | * 4 | * Copyright 2006-2009 Mike McCormack 5 | * 6 | * This library is free software; you can redistribute it and/or 7 | * modify it under the terms of the GNU Lesser General Public 8 | * License as published by the Free Software Foundation; either 9 | * version 2.1 of the License, or (at your option) any later version. 10 | * 11 | * This library is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 14 | * Lesser General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU Lesser General Public 17 | * License along with this library; if not, write to the Free Software 18 | * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA 19 | */ 20 | 21 | #include "config.h" 22 | 23 | #include 24 | #include 25 | #include 26 | #include 27 | 28 | #include "ntstatus.h" 29 | #define WIN32_NO_STATUS 30 | #include "windef.h" 31 | #include "winternl.h" 32 | 33 | #include "ntcall.h" 34 | #include "ntwin32.h" 35 | #include "mem.h" 36 | #include "section.h" 37 | #include "debug.h" 38 | #include "win32mgr.h" 39 | 40 | class win32k_null_t : public win32k_manager_t 41 | { 42 | public: 43 | virtual BOOL init(); 44 | virtual void fini(); 45 | virtual device_context_t* alloc_screen_dc_ptr(); 46 | virtual int getcaps( int index ); 47 | }; 48 | 49 | BOOL win32k_null_t::init() 50 | { 51 | return TRUE; 52 | } 53 | 54 | void win32k_null_t::fini() 55 | { 56 | } 57 | 58 | int win32k_null_t::getcaps( int index ) 59 | { 60 | trace("%d\n", index); 61 | return 0; 62 | } 63 | 64 | device_context_t* win32k_null_t::alloc_screen_dc_ptr() 65 | { 66 | // FIXME: make graphics functions more generic 67 | assert( 0 ); 68 | return 0; 69 | //return new device_context_t; 70 | } 71 | 72 | win32k_null_t win32k_manager_null; 73 | 74 | win32k_manager_t* init_null_win32k_manager() 75 | { 76 | return &win32k_manager_null; 77 | } 78 | 79 | -------------------------------------------------------------------------------- /kernel/null_display.h: -------------------------------------------------------------------------------- 1 | /* 2 | * null screen driver 3 | * 4 | * Copyright 2006-2009 Mike McCormack 5 | * 6 | * This library is free software; you can redistribute it and/or 7 | * modify it under the terms of the GNU Lesser General Public 8 | * License as published by the Free Software Foundation; either 9 | * version 2.1 of the License, or (at your option) any later version. 10 | * 11 | * This library is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 14 | * Lesser General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU Lesser General Public 17 | * License along with this library; if not, write to the Free Software 18 | * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA 19 | */ 20 | 21 | #ifndef __RING3K_NULL_H__ 22 | #define __RING3K_NULL_H__ 23 | 24 | win32k_manager_t* init_null_win32k_manager(); 25 | 26 | #endif // __RING3K_NULL_H__ 27 | -------------------------------------------------------------------------------- /kernel/objdir.h: -------------------------------------------------------------------------------- 1 | /* 2 | * nt loader 3 | * 4 | * Copyright 2006-2008 Mike McCormack 5 | * 6 | * This library is free software; you can redistribute it and/or 7 | * modify it under the terms of the GNU Lesser General Public 8 | * License as published by the Free Software Foundation; either 9 | * version 2.1 of the License, or (at your option) any later version. 10 | * 11 | * This library is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 14 | * Lesser General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU Lesser General Public 17 | * License along with this library; if not, write to the Free Software 18 | * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA 19 | */ 20 | 21 | #ifndef __NTNATIVE_OBJDIR_H__ 22 | #define __NTNATIVE_OBJDIR_H__ 23 | 24 | #include "object.h" 25 | 26 | class object_dir_t : virtual public object_t { 27 | protected: 28 | friend class object_t; 29 | static void set_obj_parent( object_t *child, object_dir_t *dir ); 30 | virtual void unlink( object_t *child ) = 0; 31 | public: 32 | object_dir_t(); 33 | virtual ~object_dir_t(); 34 | virtual bool access_allowed( ACCESS_MASK access, ACCESS_MASK handle_access ) = 0; 35 | virtual object_t *lookup( UNICODE_STRING& name, bool ignore_case ) = 0; 36 | virtual void append( object_t *child ) = 0; 37 | }; 38 | 39 | class object_dir_impl_t : public object_dir_t 40 | { 41 | object_list_t object_list; 42 | public: 43 | object_dir_impl_t(); 44 | virtual ~object_dir_impl_t(); 45 | virtual bool access_allowed( ACCESS_MASK access, ACCESS_MASK handle_access ); 46 | virtual void unlink( object_t *child ); 47 | virtual void append( object_t *child ); 48 | public: 49 | object_t *lookup( UNICODE_STRING& name, bool ignore_case ); 50 | NTSTATUS add( object_t *obj, UNICODE_STRING& name, bool ignore_case ); 51 | virtual NTSTATUS open( object_t*& obj, open_info_t& info ); 52 | }; 53 | 54 | object_t *create_directory_object( PCWSTR name ); 55 | NTSTATUS parse_path( const OBJECT_ATTRIBUTES& oa, object_dir_t*& dir, UNICODE_STRING& file ); 56 | 57 | #endif // __NTNATIVE_OBJDIR_H__ 58 | -------------------------------------------------------------------------------- /kernel/object.inl: -------------------------------------------------------------------------------- 1 | #ifndef __OBJECT_INL__ 2 | #define __OBJECT_INL__ 3 | 4 | #include "ntcall.h" 5 | 6 | template NTSTATUS nt_open_object( 7 | PHANDLE Handle, 8 | ACCESS_MASK DesiredAccess, 9 | POBJECT_ATTRIBUTES ObjectAttributes) 10 | { 11 | OBJECT_ATTRIBUTES oa; 12 | unicode_string_t us; 13 | NTSTATUS r; 14 | 15 | r = copy_from_user( &oa, ObjectAttributes, sizeof oa ); 16 | if (r != STATUS_SUCCESS) 17 | return r; 18 | 19 | if (oa.ObjectName) 20 | { 21 | r = us.copy_from_user( oa.ObjectName ); 22 | if (r != STATUS_SUCCESS) 23 | return r; 24 | oa.ObjectName = &us; 25 | } 26 | 27 | trace("object = %pus\n", oa.ObjectName ); 28 | 29 | object_t *object = NULL; 30 | 31 | r = get_named_object( &object, &oa ); 32 | if (r != STATUS_SUCCESS) 33 | return r; 34 | 35 | if (dynamic_cast( object )) 36 | { 37 | r = alloc_user_handle( object, DesiredAccess, Handle ); 38 | } 39 | else 40 | r = STATUS_OBJECT_TYPE_MISMATCH; 41 | 42 | release( object ); 43 | 44 | return r; 45 | } 46 | 47 | template NTSTATUS object_from_handle(T*& out, HANDLE handle, ACCESS_MASK access) 48 | { 49 | NTSTATUS r; 50 | object_t *obj = 0; 51 | 52 | r = current->process->handle_table.object_from_handle( obj, handle, access ); 53 | if (r != STATUS_SUCCESS) 54 | return r; 55 | 56 | out = dynamic_cast(obj); 57 | if (!out) 58 | return STATUS_OBJECT_TYPE_MISMATCH; 59 | 60 | return STATUS_SUCCESS; 61 | } 62 | 63 | #endif // __OBJECT_INL__ 64 | -------------------------------------------------------------------------------- /kernel/platform.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * nt loader 3 | * 4 | * Copyright 2006-2008 Mike McCormack 5 | * 6 | * This library is free software; you can redistribute it and/or 7 | * modify it under the terms of the GNU Lesser General Public 8 | * License as published by the Free Software Foundation; either 9 | * version 2.1 of the License, or (at your option) any later version. 10 | * 11 | * This library is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 14 | * Lesser General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU Lesser General Public 17 | * License along with this library; if not, write to the Free Software 18 | * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA 19 | */ 20 | 21 | #include 22 | #include 23 | #include 24 | #include 25 | #include "platform.h" 26 | 27 | void* mmap_anon(void *addr, size_t len, int prot, int fixed) 28 | { 29 | int flags = MAP_PRIVATE | MAP_ANON; 30 | if (fixed) 31 | flags |= MAP_FIXED; 32 | return ::mmap(addr, len, prot, MAP_PRIVATE | MAP_ANON, -1, 0); 33 | } 34 | 35 | -------------------------------------------------------------------------------- /kernel/platform.h: -------------------------------------------------------------------------------- 1 | /* 2 | * nt loader 3 | * 4 | * Copyright 2006-2008 Mike McCormack 5 | * 6 | * This library is free software; you can redistribute it and/or 7 | * modify it under the terms of the GNU Lesser General Public 8 | * License as published by the Free Software Foundation; either 9 | * version 2.1 of the License, or (at your option) any later version. 10 | * 11 | * This library is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 14 | * Lesser General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU Lesser General Public 17 | * License along with this library; if not, write to the Free Software 18 | * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA 19 | */ 20 | 21 | #ifndef __PLATFORM_H_ 22 | #define __PLATFORM_H_ 23 | 24 | extern "C" { 25 | 26 | void* mmap_anon(void *addr, size_t len, int prot, int fixed = 0); 27 | 28 | }; 29 | 30 | #endif /* __PLATFORM_H_ */ 31 | -------------------------------------------------------------------------------- /kernel/process.h: -------------------------------------------------------------------------------- 1 | /* 2 | * nt loader 3 | * 4 | * Copyright 2006-2008 Mike McCormack 5 | * 6 | * This library is free software; you can redistribute it and/or 7 | * modify it under the terms of the GNU Lesser General Public 8 | * License as published by the Free Software Foundation; either 9 | * version 2.1 of the License, or (at your option) any later version. 10 | * 11 | * This library is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 14 | * Lesser General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU Lesser General Public 17 | * License along with this library; if not, write to the Free Software 18 | * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA 19 | */ 20 | 21 | #ifndef __PROCESS_H__ 22 | #define __PROCESS_H__ 23 | 24 | #include "thread.h" 25 | 26 | class win32k_info_t; 27 | 28 | struct process_t : public sync_object_t { 29 | sibling_list_t threads; 30 | address_space *vm; 31 | object_t *exe; 32 | BYTE *pntdll; 33 | BYTE *pexe; 34 | 35 | // PROCESS_BASIC_INFORMATION 36 | NTSTATUS ExitStatus; 37 | section_t *peb_section; 38 | void* PebBaseAddress; 39 | ULONG id; 40 | 41 | handle_table_t handle_table; 42 | 43 | process_element_t entry[1]; 44 | 45 | // exception handling 46 | object_t *exception_port; 47 | 48 | KPRIORITY priority; 49 | ULONG hard_error_mode; 50 | 51 | win32k_info_t *win32k_info; 52 | 53 | ULONG execute_flags; 54 | 55 | HANDLE window_station; 56 | 57 | public: 58 | NTSTATUS create_exe_ppb( RTL_USER_PROCESS_PARAMETERS **pparams, UNICODE_STRING& name ); 59 | NTSTATUS create_parameters( 60 | RTL_USER_PROCESS_PARAMETERS **pparams, LPCWSTR ImageFile, LPCWSTR DllPath, 61 | LPCWSTR CurrentDirectory, LPCWSTR CommandLine, LPCWSTR WindowTitle, LPCWSTR Desktop); 62 | 63 | public: 64 | process_t(); 65 | ~process_t(); 66 | virtual BOOLEAN is_signalled( void ); 67 | void terminate( NTSTATUS status ); 68 | bool is_valid() {return id != 0; } 69 | }; 70 | 71 | extern process_list_t processes; 72 | 73 | NTSTATUS create_process( process_t **pprocess, object_t *section ); 74 | NTSTATUS set_exception_port( process_t *process, object_t *obj ); 75 | 76 | #endif // __PROCESS_H__ 77 | -------------------------------------------------------------------------------- /kernel/profile.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * nt loader 3 | * 4 | * Copyright 2006-2008 Mike McCormack 5 | * 6 | * This library is free software; you can redistribute it and/or 7 | * modify it under the terms of the GNU Lesser General Public 8 | * License as published by the Free Software Foundation; either 9 | * version 2.1 of the License, or (at your option) any later version. 10 | * 11 | * This library is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 14 | * Lesser General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU Lesser General Public 17 | * License along with this library; if not, write to the Free Software 18 | * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA 19 | */ 20 | 21 | 22 | #include 23 | 24 | #include "ntstatus.h" 25 | #define WIN32_NO_STATUS 26 | #include "windef.h" 27 | #include "winternl.h" 28 | 29 | #include "debug.h" 30 | 31 | NTSTATUS NTAPI NtCreateProfile( 32 | PHANDLE ProfileHandle, 33 | HANDLE ProcessHandle, 34 | PVOID Base, 35 | ULONG Size, 36 | ULONG BucketShift, 37 | PULONG Buffer, 38 | ULONG BufferLength, 39 | KPROFILE_SOURCE Source, 40 | ULONG ProcessorMask) 41 | { 42 | trace("\n"); 43 | return STATUS_NOT_IMPLEMENTED; 44 | } 45 | -------------------------------------------------------------------------------- /kernel/ptrace_base.h: -------------------------------------------------------------------------------- 1 | /* 2 | * nt loader 3 | * 4 | * Copyright 2006-2008 Mike McCormack 5 | * 6 | * This library is free software; you can redistribute it and/or 7 | * modify it under the terms of the GNU Lesser General Public 8 | * License as published by the Free Software Foundation; either 9 | * version 2.1 of the License, or (at your option) any later version. 10 | * 11 | * This library is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 14 | * Lesser General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU Lesser General Public 17 | * License along with this library; if not, write to the Free Software 18 | * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA 19 | */ 20 | 21 | #ifndef __NTNATIVE_PTRACE_BASE_H 22 | #define __NTNATIVE_PTRACE_BASE_H 23 | 24 | #include "config.h" 25 | 26 | class ptrace_address_space_impl: public address_space_impl 27 | { 28 | protected: 29 | static ptrace_address_space_impl *sig_target; 30 | static void cancel_timer(); 31 | static void sigitimer_handler(int signal); 32 | int get_context( PCONTEXT ctx ); 33 | int set_context( PCONTEXT ctx ); 34 | int ptrace_run( PCONTEXT ctx, int single_step, LARGE_INTEGER& timeout ); 35 | virtual pid_t get_child_pid() = 0; 36 | virtual void handle( int signal ); 37 | virtual void run( void *TebBaseAddress, PCONTEXT ctx, int single_step, LARGE_INTEGER& timeout, execution_context_t *exec ); 38 | virtual void alarm_timeout(LARGE_INTEGER& timeout); 39 | virtual int set_userspace_fs(void *TebBaseAddress, ULONG fs); 40 | virtual void init_context( CONTEXT& ctx ); 41 | virtual unsigned short get_userspace_fs() = 0; 42 | virtual unsigned short get_userspace_data_seg(); 43 | virtual unsigned short get_userspace_code_seg(); 44 | virtual int get_fault_info( void *& addr ); 45 | void wait_for_signal( pid_t pid, int signal ); 46 | public: 47 | static void set_signals(); 48 | }; 49 | 50 | 51 | #endif // __NTNATIVE_PTRACE_BASE_H 52 | -------------------------------------------------------------------------------- /kernel/queue.h: -------------------------------------------------------------------------------- 1 | /* 2 | * nt loader 3 | * 4 | * Copyright 2009 Mike McCormack 5 | * 6 | * This library is free software; you can redistribute it and/or 7 | * modify it under the terms of the GNU Lesser General Public 8 | * License as published by the Free Software Foundation; either 9 | * version 2.1 of the License, or (at your option) any later version. 10 | * 11 | * This library is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 14 | * Lesser General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU Lesser General Public 17 | * License along with this library; if not, write to the Free Software 18 | * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA 19 | */ 20 | 21 | #ifndef __RING3K_QUEUE__ 22 | #define __RING3K_QUEUE__ 23 | 24 | #include "ntwin32.h" 25 | 26 | class msg_tt; 27 | class msg_waiter_tt; 28 | class thread_message_queue_tt; 29 | 30 | typedef list_anchor msg_list_t; 31 | typedef list_iter msg_iter_t; 32 | typedef list_element msg_element_t; 33 | 34 | typedef list_anchor msg_waiter_list_t; 35 | typedef list_iter msg_waiter_iter_t; 36 | typedef list_element msg_waiter_element_t; 37 | 38 | class msg_waiter_tt 39 | { 40 | friend class thread_message_queue_tt; 41 | friend class list_anchor; 42 | msg_waiter_element_t entry[1]; 43 | thread_t *t; 44 | MSG& msg; 45 | public: 46 | msg_waiter_tt( MSG& m); 47 | }; 48 | 49 | class msg_tt { 50 | public: 51 | msg_element_t entry[1]; 52 | HWND hwnd; 53 | UINT message; 54 | WPARAM wparam; 55 | LPARAM lparam; 56 | DWORD time; 57 | public: 58 | msg_tt( HWND _hwnd, UINT Message, WPARAM Wparam, LPARAM Lparam ); 59 | }; 60 | 61 | class win_timer_tt; 62 | 63 | typedef list_anchor win_timer_list_t; 64 | typedef list_iter win_timer_iter_t; 65 | typedef list_element win_timer_element_t; 66 | 67 | class win_timer_tt { 68 | public: 69 | win_timer_element_t entry[1]; 70 | HWND hwnd; 71 | UINT id; 72 | void *lparam; 73 | UINT period; 74 | LARGE_INTEGER expiry; 75 | public: 76 | win_timer_tt( HWND Window, UINT Identifier ); 77 | void reset(); 78 | bool expired() const; 79 | }; 80 | 81 | // derived from Wine's struct thread_input 82 | // see wine/server/queue.c (by Alexandre Julliard) 83 | class thread_message_queue_tt : 84 | public sync_object_t, 85 | public timeout_t 86 | { 87 | bool quit_message; // is there a pending quit message? 88 | int exit_code; // exit code of pending quit message 89 | msg_list_t msg_list; 90 | msg_waiter_list_t waiter_list; 91 | win_timer_list_t timer_list; 92 | public: 93 | thread_message_queue_tt(); 94 | ~thread_message_queue_tt(); 95 | BOOL post_message( HWND Window, UINT Message, WPARAM Wparam, LPARAM Lparam ); 96 | void post_quit_message( ULONG exit_code ); 97 | bool get_quit_message( MSG &msg ); 98 | bool get_paint_message( HWND Window, MSG& msg ); 99 | virtual BOOLEAN is_signalled( void ); 100 | virtual void signal_timeout(); 101 | BOOLEAN get_message( MSG& Message, HWND Window, ULONG MinMessage, ULONG MaxMessage); 102 | BOOLEAN get_message_no_wait( MSG& Message, HWND Window, ULONG MinMessage, ULONG MaxMessage); 103 | bool get_posted_message( HWND Window, MSG& Message ); 104 | BOOLEAN set_timer( HWND Window, UINT Identifier, UINT Elapse, PVOID TimerProc ); 105 | BOOLEAN kill_timer( HWND Window, UINT Identifier ); 106 | win_timer_tt* find_timer( HWND Window, UINT Identifier ); 107 | void timer_add( win_timer_tt* timer ); 108 | bool get_timer_message( HWND Window, MSG& msg ); 109 | bool get_message_timeout( HWND Window, LARGE_INTEGER& timeout ); 110 | }; 111 | 112 | HWND find_window_to_repaint( HWND Window, thread_t *thread ); 113 | 114 | #endif // __RING3K_QUEUE__ 115 | -------------------------------------------------------------------------------- /kernel/random.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * nt loader 3 | * 4 | * Copyright 2006-2008 Mike McCormack 5 | * 6 | * This library is free software; you can redistribute it and/or 7 | * modify it under the terms of the GNU Lesser General Public 8 | * License as published by the Free Software Foundation; either 9 | * version 2.1 of the License, or (at your option) any later version. 10 | * 11 | * This library is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 14 | * Lesser General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU Lesser General Public 17 | * License along with this library; if not, write to the Free Software 18 | * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA 19 | */ 20 | 21 | 22 | #include 23 | 24 | #include "ntstatus.h" 25 | #define WIN32_NO_STATUS 26 | #include "windef.h" 27 | #include "winternl.h" 28 | 29 | #include "file.h" 30 | #include "debug.h" 31 | 32 | class random_dev_t : public io_object_t 33 | { 34 | public: 35 | random_dev_t(); 36 | virtual NTSTATUS read( PVOID Buffer, ULONG Length, ULONG *read ); 37 | virtual NTSTATUS write( PVOID Buffer, ULONG Length, ULONG *written ); 38 | }; 39 | 40 | random_dev_t::random_dev_t() 41 | { 42 | } 43 | 44 | NTSTATUS random_dev_t::read( PVOID Buffer, ULONG Length, ULONG *read ) 45 | { 46 | trace("random_dev_t\n"); 47 | return STATUS_NOT_IMPLEMENTED; 48 | } 49 | 50 | NTSTATUS random_dev_t::write( PVOID Buffer, ULONG Length, ULONG *written ) 51 | { 52 | trace("random_dev_t\n"); 53 | return STATUS_NOT_IMPLEMENTED; 54 | } 55 | 56 | class random_dev_factory_t: public object_factory 57 | { 58 | public: 59 | NTSTATUS alloc_object(object_t** obj); 60 | }; 61 | 62 | NTSTATUS random_dev_factory_t::alloc_object(object_t** obj) 63 | { 64 | *obj = new random_dev_t; 65 | return STATUS_SUCCESS; 66 | } 67 | 68 | void init_random() 69 | { 70 | random_dev_factory_t factory; 71 | unicode_string_t rand; 72 | rand.copy("\\Device\\KsecDD"); 73 | object_t *obj = 0; 74 | NTSTATUS r; 75 | r = factory.create_kernel( obj, rand ); 76 | if (r < STATUS_SUCCESS) 77 | die("failed to create random device\n"); 78 | } 79 | -------------------------------------------------------------------------------- /kernel/sdl.h: -------------------------------------------------------------------------------- 1 | /* 2 | * nt loader 3 | * 4 | * Copyright 2006-2008 Mike McCormack 5 | * 6 | * This library is free software; you can redistribute it and/or 7 | * modify it under the terms of the GNU Lesser General Public 8 | * License as published by the Free Software Foundation; either 9 | * version 2.1 of the License, or (at your option) any later version. 10 | * 11 | * This library is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 14 | * Lesser General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU Lesser General Public 17 | * License along with this library; if not, write to the Free Software 18 | * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA 19 | */ 20 | 21 | #ifndef __RING3K_SDL_H__ 22 | #define __RING3K_SDL_H__ 23 | 24 | win32k_manager_t* init_sdl_win32k_manager(); 25 | 26 | #endif // __RING3K_SDL_H__ 27 | -------------------------------------------------------------------------------- /kernel/section.h: -------------------------------------------------------------------------------- 1 | /* 2 | * nt loader 3 | * 4 | * Copyright 2006-2008 Mike McCormack 5 | * 6 | * This library is free software; you can redistribute it and/or 7 | * modify it under the terms of the GNU Lesser General Public 8 | * License as published by the Free Software Foundation; either 9 | * version 2.1 of the License, or (at your option) any later version. 10 | * 11 | * This library is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 14 | * Lesser General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU Lesser General Public 17 | * License along with this library; if not, write to the Free Software 18 | * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA 19 | */ 20 | 21 | #ifndef __SECTION_H__ 22 | #define __SECTION_H__ 23 | 24 | struct section_t : public object_t, public backing_store_t { 25 | int fd; 26 | BYTE *addr; 27 | size_t len; 28 | ULONG Attributes; 29 | ULONG Protect; 30 | public: 31 | section_t( int fd, BYTE *a, size_t l, ULONG attr, ULONG prot ); 32 | virtual ~section_t(); 33 | virtual NTSTATUS mapit( address_space *vm, BYTE *&addr, ULONG ZeroBits, ULONG State, ULONG Prot ); 34 | virtual void* get_kernel_address(); 35 | virtual NTSTATUS query( SECTION_BASIC_INFORMATION *basic ); 36 | virtual NTSTATUS query( SECTION_IMAGE_INFORMATION *image ); 37 | virtual const char *get_symbol( ULONG address ); 38 | virtual int get_fd(); 39 | virtual void addref(); 40 | virtual void release(); 41 | }; 42 | 43 | NTSTATUS create_section( object_t **obj, object_t *file, PLARGE_INTEGER psz, ULONG attribs, ULONG protect ); 44 | NTSTATUS create_section( section_t **section, object_t *file, PLARGE_INTEGER psz, ULONG attribs, ULONG protect ); 45 | NTSTATUS mapit( address_space *vm, object_t *obj, BYTE *&addr ); 46 | void *virtual_addr_to_offset( IMAGE_NT_HEADERS *nt, void *base, DWORD virtual_ofs ); 47 | DWORD get_proc_address(object_t *obj, const char *name); 48 | void *get_entry_point( process_t *p ); 49 | NTSTATUS section_from_handle( HANDLE, section_t*& section, ACCESS_MASK access ); 50 | 51 | #endif 52 | -------------------------------------------------------------------------------- /kernel/spy.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Message spying routines 3 | * 4 | * Copyright 1994, Bob Amstadt 5 | * 1995, Alex Korobka 6 | * 7 | * This library is free software; you can redistribute it and/or 8 | * modify it under the terms of the GNU Lesser General Public 9 | * License as published by the Free Software Foundation; either 10 | * version 2.1 of the License, or (at your option) any later version. 11 | * 12 | * This library is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 15 | * Lesser General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU Lesser General Public 18 | * License along with this library; if not, write to the Free Software 19 | * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA 20 | */ 21 | 22 | #ifndef __RING3K_SPY__ 23 | #define __RING3K_SPY__ 24 | 25 | const char *get_message_name( UINT message ); 26 | 27 | #endif // __RING3K_SPY__ 28 | -------------------------------------------------------------------------------- /kernel/symlink.h: -------------------------------------------------------------------------------- 1 | /* 2 | * nt loader 3 | * 4 | * Copyright 2006-2008 Mike McCormack 5 | * 6 | * This library is free software; you can redistribute it and/or 7 | * modify it under the terms of the GNU Lesser General Public 8 | * License as published by the Free Software Foundation; either 9 | * version 2.1 of the License, or (at your option) any later version. 10 | * 11 | * This library is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 14 | * Lesser General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU Lesser General Public 17 | * License along with this library; if not, write to the Free Software 18 | * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA 19 | */ 20 | 21 | #ifndef __NTNATIVE_SYMLINK__ 22 | #define __NTNATIVE_SYMLINK__ 23 | 24 | #include "object.h" 25 | 26 | class symlink_t : public object_t { 27 | unicode_string_t target; 28 | public: 29 | symlink_t( const UNICODE_STRING& us ); 30 | ~symlink_t(); 31 | unicode_string_t& get_target() {return target;} 32 | virtual NTSTATUS open( object_t *&out, open_info_t& info ); 33 | }; 34 | 35 | // from symlink.cpp 36 | NTSTATUS create_symlink( UNICODE_STRING& name, UNICODE_STRING& target ); 37 | 38 | #endif // __NTNATIVE_SYMLINK__ 39 | -------------------------------------------------------------------------------- /kernel/syscall_stat.pl: -------------------------------------------------------------------------------- 1 | #!/usr/bin/perl5 2 | use strict; 3 | 4 | sub count_syscalls($) { 5 | my $header = shift; 6 | my $functions; 7 | my $undeclared; 8 | my $declared; 9 | my $implemented; 10 | my $start; 11 | open(FILE,"<../include/$header.h") || die; 12 | while() { 13 | if (/NUL/) { 14 | $undeclared++; 15 | } 16 | if (/DEC/) { 17 | $declared++; 18 | } 19 | if (/IMP/) { 20 | $implemented++; 21 | } 22 | } 23 | close FILE; 24 | $functions = $undeclared + $declared + $implemented; 25 | printf ("%s:\n", $header); 26 | printf ("\tundeclared: %3d (%2.0f%%)\n", $undeclared, 100*$undeclared/$functions); 27 | printf ("\tdeclared: %3d (%2.0f%%)\n", $declared, 100*$declared/$functions); 28 | printf ("\timplemented: %3d (%2.0f%%)\n", $implemented, 100*$implemented/$functions); 29 | printf ("\ttotal: %3d\n", $functions); 30 | printf ("\n"); 31 | } 32 | 33 | count_syscalls("ntsyscall"); 34 | count_syscalls("uisyscall"); 35 | -------------------------------------------------------------------------------- /kernel/timer.h: -------------------------------------------------------------------------------- 1 | /* 2 | * nt loader 3 | * 4 | * Copyright 2006-2008 Mike McCormack 5 | * 6 | * This library is free software; you can redistribute it and/or 7 | * modify it under the terms of the GNU Lesser General Public 8 | * License as published by the Free Software Foundation; either 9 | * version 2.1 of the License, or (at your option) any later version. 10 | * 11 | * This library is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 14 | * Lesser General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU Lesser General Public 17 | * License along with this library; if not, write to the Free Software 18 | * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA 19 | */ 20 | 21 | #ifndef __TIMER_H__ 22 | #define __TIMER_H__ 23 | 24 | #include "list.h" 25 | 26 | class timeout_t; 27 | 28 | typedef list_element timeout_entry_t; 29 | typedef list_anchor timeout_list_t; 30 | typedef list_iter timeout_iter_t; 31 | 32 | class timeout_t 33 | { 34 | friend class list_anchor ; 35 | friend class list_iter ; 36 | timeout_entry_t entry[1]; 37 | private: 38 | static timeout_list_t g_timeouts; 39 | LARGE_INTEGER expires; 40 | protected: 41 | void add(); 42 | void remove(); 43 | //void set(); 44 | public: 45 | explicit timeout_t(PLARGE_INTEGER t = 0); 46 | void set(PLARGE_INTEGER t); 47 | virtual ~timeout_t(); 48 | static LARGE_INTEGER current_time(); 49 | static ULONG get_tick_count(); 50 | void do_timeout(); 51 | void set_timeout(PLARGE_INTEGER t); 52 | virtual void signal_timeout() = 0; 53 | //static bool timers_active(); 54 | static bool check_timers(LARGE_INTEGER& ret); 55 | bool has_expired(); 56 | void time_remaining( LARGE_INTEGER& remaining ); 57 | static bool queue_is_valid(); 58 | }; 59 | 60 | void get_system_time_of_day( SYSTEM_TIME_OF_DAY_INFORMATION& time_of_day ); 61 | 62 | #endif // __TIMER_H__ 63 | -------------------------------------------------------------------------------- /kernel/token.h: -------------------------------------------------------------------------------- 1 | /* 2 | * nt loader 3 | * 4 | * Copyright 2006-2008 Mike McCormack 5 | * 6 | * This library is free software; you can redistribute it and/or 7 | * modify it under the terms of the GNU Lesser General Public 8 | * License as published by the Free Software Foundation; either 9 | * version 2.1 of the License, or (at your option) any later version. 10 | * 11 | * This library is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 14 | * Lesser General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU Lesser General Public 17 | * License along with this library; if not, write to the Free Software 18 | * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA 19 | */ 20 | 21 | #ifndef __TOKEN_H__ 22 | #define __TOKEN_H__ 23 | 24 | class token_privileges_t; 25 | class sid_t; 26 | class acl_t; 27 | class sid_and_attributes_t; 28 | class token_groups_t; 29 | 30 | class token_t : public object_t { 31 | public: 32 | virtual ~token_t() = 0; 33 | virtual token_privileges_t& get_privs() = 0; 34 | virtual sid_t& get_owner() = 0; 35 | virtual sid_and_attributes_t& get_user() = 0; 36 | virtual sid_t& get_primary_group() = 0; 37 | virtual token_groups_t& get_groups() = 0; 38 | virtual acl_t& get_default_dacl() = 0; 39 | virtual NTSTATUS adjust(token_privileges_t& privs) = 0; 40 | }; 41 | 42 | #endif // __TOKEN_H__ 43 | -------------------------------------------------------------------------------- /kernel/unicode.h: -------------------------------------------------------------------------------- 1 | /* 2 | * UNICODE_STRING helper 3 | * 4 | * Copyright 2006-2008 Mike McCormack 5 | * 6 | * This library is free software; you can redistribute it and/or 7 | * modify it under the terms of the GNU Lesser General Public 8 | * License as published by the Free Software Foundation; either 9 | * version 2.1 of the License, or (at your option) any later version. 10 | * 11 | * This library is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 14 | * Lesser General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU Lesser General Public 17 | * License along with this library; if not, write to the Free Software 18 | * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA 19 | */ 20 | 21 | #ifndef __UNICODE_H__ 22 | #define __UNICODE_H__ 23 | 24 | #include "winternl.h" 25 | 26 | class unicode_string_t : public UNICODE_STRING 27 | { 28 | WCHAR *buf; 29 | protected: 30 | NTSTATUS copy_wstr_from_user(); 31 | ULONG utf8_to_wchar( const unsigned char *str, ULONG len, WCHAR *buf ); 32 | public: 33 | explicit unicode_string_t(); 34 | explicit unicode_string_t( const unicode_string_t& source ); 35 | explicit unicode_string_t( const UNICODE_STRING& source ); 36 | void set( PCWSTR str ); 37 | void set( const wchar_t* str ) { set( (PCWSTR) str ); } 38 | void set( UNICODE_STRING& us ); 39 | NTSTATUS copy_from_user(PUNICODE_STRING ptr); 40 | NTSTATUS copy( const UNICODE_STRING* ptr ); 41 | NTSTATUS copy( const char *ptr ); 42 | NTSTATUS copy( const unsigned char *ptr ); 43 | NTSTATUS copy( PCWSTR str ); 44 | NTSTATUS copy( const wchar_t* str ) {return copy( (PCWSTR) str );} 45 | bool is_equal( const UNICODE_STRING& ptr ) const; 46 | bool compare( PUNICODE_STRING b, BOOLEAN case_insensitive ) const; 47 | ~unicode_string_t(); 48 | unicode_string_t& operator=(const unicode_string_t& in); 49 | void clear(); 50 | NTSTATUS copy_wstr_from_user( PWSTR String, ULONG Length ); 51 | ULONG wchar_to_utf8( char *str, ULONG max ); 52 | }; 53 | 54 | class object_attributes_t : public OBJECT_ATTRIBUTES 55 | { 56 | unicode_string_t us; 57 | public: 58 | explicit object_attributes_t(); 59 | explicit object_attributes_t( const WCHAR *str ); 60 | ~object_attributes_t(); 61 | NTSTATUS copy_from_user( POBJECT_ATTRIBUTES oa ); 62 | object_attributes_t& operator=(const object_attributes_t& in); 63 | }; 64 | 65 | UINT strlenW( LPCWSTR str ); 66 | LPWSTR strcpyW( LPWSTR dest, LPCWSTR src ); 67 | LPWSTR strcatW( LPWSTR dest, LPCWSTR src ); 68 | 69 | #endif // __UNICODE_H__ 70 | -------------------------------------------------------------------------------- /kernel/win.h: -------------------------------------------------------------------------------- 1 | /* 2 | * nt loader 3 | * 4 | * Copyright 2006-2008 Mike McCormack 5 | * 6 | * This library is free software; you can redistribute it and/or 7 | * modify it under the terms of the GNU Lesser General Public 8 | * License as published by the Free Software Foundation; either 9 | * version 2.1 of the License, or (at your option) any later version. 10 | * 11 | * This library is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 14 | * Lesser General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU Lesser General Public 17 | * License along with this library; if not, write to the Free Software 18 | * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA 19 | */ 20 | 21 | #ifndef __RING3K_WIN_H__ 22 | #define __RING3K_WIN_H__ 23 | 24 | #include "ntwin32.h" 25 | #include "region.h" 26 | 27 | struct window_tt; 28 | class wndcls_tt; 29 | class message_tt; 30 | 31 | typedef list_anchor wndcls_list_tt; 32 | typedef list_element wndcls_entry_tt; 33 | typedef list_iter wndcls_iter_tt; 34 | 35 | class wndcls_tt : public CLASSINFO 36 | { 37 | // FIXME: all these have to go 38 | friend class list_anchor; 39 | friend class list_iter; 40 | wndcls_entry_tt entry[1]; 41 | unicode_string_t name; 42 | unicode_string_t menu; 43 | NTWNDCLASSEX info; 44 | ULONG refcount; 45 | public: 46 | void* operator new(size_t sz); 47 | void operator delete(void *p); 48 | wndcls_tt( NTWNDCLASSEX& ClassInfo, const UNICODE_STRING& ClassName, const UNICODE_STRING& MenuName, ATOM a ); 49 | static wndcls_tt* from_name( const UNICODE_STRING& wndcls_name ); 50 | ATOM get_atom() const {return atomWindowType;} 51 | const unicode_string_t& get_name() const {return name;} 52 | void addref() {refcount++;} 53 | void release() {refcount--;} 54 | PVOID get_wndproc() const { return info.WndProc; } 55 | }; 56 | 57 | class window_tt : public WND 58 | { 59 | // no virtual functions here, binary compatible with user side WND struct 60 | public: 61 | void* operator new(size_t sz); 62 | void operator delete(void *p); 63 | window_tt(); 64 | ~window_tt(); 65 | static window_tt* do_create( unicode_string_t& name, unicode_string_t& cls, NTCREATESTRUCT& cs ); 66 | NTSTATUS send( message_tt& msg ); 67 | void *get_wndproc() { return wndproc; } 68 | PWND get_wininfo(); 69 | thread_t* &get_win_thread() {return (thread_t*&)unk1; } 70 | region_tt* &get_invalid_region() {return (region_tt*&)unk2; } 71 | BOOLEAN show( INT Show ); 72 | void activate(); 73 | HGDIOBJ get_dc(); 74 | BOOLEAN destroy(); 75 | void set_window_pos( UINT flags ); 76 | static window_tt* find_window_to_repaint( HWND window, thread_t* thread ); 77 | static window_tt* find_window_to_repaint( window_tt* win, thread_t* thread ); 78 | void link_window( window_tt *parent ); 79 | void unlink_window(); 80 | BOOLEAN move_window( int x, int y, int width, int height, BOOLEAN repaint ); 81 | HWND from_point( POINT& pt ); 82 | bool on_access( BYTE* address, ULONG ip ); 83 | }; 84 | 85 | window_tt *window_from_handle( HANDLE handle ); 86 | 87 | // system wide callback functions registered with kernel by user32.dll 88 | extern PVOID g_funcs[9]; 89 | extern PVOID g_funcsW[20]; 90 | extern PVOID g_funcsA[20]; 91 | 92 | #endif // __RING3K_WIN_H__ 93 | -------------------------------------------------------------------------------- /libmspack/.gitignore: -------------------------------------------------------------------------------- 1 | .*.d 2 | *.o 3 | Makefile 4 | -------------------------------------------------------------------------------- /libmspack/Makefile.in: -------------------------------------------------------------------------------- 1 | srcdir = @srcdir@ 2 | VPATH = @srcdir@ 3 | 4 | DEPFLAG = -Wp,-MD,.$@.d 5 | CFLAGS = -O2 -Wall -I$(srcdir) $(DEPFLAG) 6 | CC = @HOSTCC@ 7 | 8 | SOURCE = \ 9 | cabc.c \ 10 | cabd.c \ 11 | cab.h \ 12 | chmc.c \ 13 | chmd.c \ 14 | chm.h \ 15 | des.h \ 16 | hlpc.c \ 17 | hlpd.c \ 18 | hlp.h \ 19 | kwajc.c \ 20 | kwajd.c \ 21 | kwaj.h \ 22 | litc.c \ 23 | litd.c \ 24 | lit.h \ 25 | lzss.h \ 26 | lzxc.c \ 27 | lzxd.c \ 28 | lzx.h \ 29 | mspack.h \ 30 | mszipc.c \ 31 | mszipd.c \ 32 | mszip.h \ 33 | qtmd.c \ 34 | qtm.h \ 35 | sha.h \ 36 | system.c \ 37 | system.h \ 38 | szddc.c \ 39 | szddd.c \ 40 | szdd.h 41 | 42 | OBJECTS = $(SOURCE:%.c=%.o) 43 | 44 | TARGET = libmspack.a 45 | all: $(TARGET) 46 | 47 | include $(wildcard .*.d) 48 | $(TARGET): $(OBJECTS) 49 | $(AR) -r $@ $^ 50 | 51 | clean: 52 | rm -rf $(TARGET) .*.d *.o 53 | 54 | -------------------------------------------------------------------------------- /libmspack/cabc.c: -------------------------------------------------------------------------------- 1 | /* This file is part of libmspack. 2 | * (C) 2003-2004 Stuart Caie. 3 | * 4 | * libmspack is free software; you can redistribute it and/or modify it under 5 | * the terms of the GNU Lesser General Public License (LGPL) version 2.1 6 | * 7 | * For further details, see the file COPYING.LIB distributed with libmspack 8 | */ 9 | 10 | /* CAB compression implementation */ 11 | 12 | #include 13 | #include 14 | 15 | struct mscab_compressor * 16 | mspack_create_cab_compressor(struct mspack_system *sys) 17 | { 18 | /* todo */ 19 | return NULL; 20 | } 21 | 22 | void mspack_destroy_cab_compressor(struct mscab_compressor *this) { 23 | /* todo */ 24 | } 25 | -------------------------------------------------------------------------------- /libmspack/chmc.c: -------------------------------------------------------------------------------- 1 | /* This file is part of libmspack. 2 | * (C) 2003-2004 Stuart Caie. 3 | * 4 | * libmspack is free software; you can redistribute it and/or modify it under 5 | * the terms of the GNU Lesser General Public License (LGPL) version 2.1 6 | * 7 | * For further details, see the file COPYING.LIB distributed with libmspack 8 | */ 9 | 10 | /* CHM compression implementation */ 11 | 12 | #include 13 | #include 14 | 15 | struct mschm_compressor * 16 | mspack_create_chm_compressor(struct mspack_system *sys) 17 | { 18 | /* todo */ 19 | return NULL; 20 | } 21 | 22 | void mspack_destroy_chm_compressor(struct mschm_compressor *this) { 23 | /* todo */ 24 | } 25 | -------------------------------------------------------------------------------- /libmspack/des.h: -------------------------------------------------------------------------------- 1 | /* This file is part of libmspack. 2 | * (C) 2003-2004 Stuart Caie. 3 | * 4 | * libmspack is free software; you can redistribute it and/or modify it under 5 | * the terms of the GNU Lesser General Public License (LGPL) version 2.1 6 | * 7 | * For further details, see the file COPYING.LIB distributed with libmspack 8 | */ 9 | 10 | #ifndef MSPACK_DES_H 11 | #define MSPACK_DES_H 1 12 | 13 | /* DES encryption / decryption definitions */ 14 | 15 | #endif 16 | -------------------------------------------------------------------------------- /libmspack/hlp.h: -------------------------------------------------------------------------------- 1 | /* This file is part of libmspack. 2 | * (C) 2003-2004 Stuart Caie. 3 | * 4 | * libmspack is free software; you can redistribute it and/or modify it under 5 | * the terms of the GNU Lesser General Public License (LGPL) version 2.1 6 | * 7 | * For further details, see the file COPYING.LIB distributed with libmspack 8 | */ 9 | 10 | #ifndef MSPACK_HLP_H 11 | #define MSPACK_HLP_H 1 12 | 13 | #include 14 | 15 | /* generic HLP definitions */ 16 | 17 | /* HLP compression definitions */ 18 | 19 | struct mshlp_compressor_p { 20 | struct mshlp_compressor base; 21 | struct mspack_system *system; 22 | /* todo */ 23 | }; 24 | 25 | /* HLP decompression definitions */ 26 | 27 | struct mshlp_decompressor_p { 28 | struct mshlp_decompressor base; 29 | struct mspack_system *system; 30 | /* todo */ 31 | }; 32 | 33 | #endif 34 | -------------------------------------------------------------------------------- /libmspack/hlpc.c: -------------------------------------------------------------------------------- 1 | /* This file is part of libmspack. 2 | * (C) 2003-2004 Stuart Caie. 3 | * 4 | * libmspack is free software; you can redistribute it and/or modify it under 5 | * the terms of the GNU Lesser General Public License (LGPL) version 2.1 6 | * 7 | * For further details, see the file COPYING.LIB distributed with libmspack 8 | */ 9 | 10 | /* HLP compression implementation */ 11 | 12 | #include 13 | #include 14 | 15 | struct mshlp_compressor * 16 | mspack_create_hlp_compressor(struct mspack_system *sys) 17 | { 18 | /* todo */ 19 | return NULL; 20 | } 21 | 22 | void mspack_destroy_hlp_compressor(struct mshlp_compressor *this) { 23 | /* todo */ 24 | } 25 | -------------------------------------------------------------------------------- /libmspack/hlpd.c: -------------------------------------------------------------------------------- 1 | /* This file is part of libmspack. 2 | * (C) 2003-2004 Stuart Caie. 3 | * 4 | * libmspack is free software; you can redistribute it and/or modify it under 5 | * the terms of the GNU Lesser General Public License (LGPL) version 2.1 6 | * 7 | * For further details, see the file COPYING.LIB distributed with libmspack 8 | */ 9 | 10 | /* HLP decompression implementation */ 11 | 12 | #include 13 | #include 14 | 15 | struct mshlp_decompressor * 16 | mspack_create_hlp_decompressor(struct mspack_system *sys) 17 | { 18 | /* todo */ 19 | return NULL; 20 | } 21 | 22 | void mspack_destroy_hlp_decompressor(struct mshlp_decompressor *this) { 23 | /* todo */ 24 | } 25 | -------------------------------------------------------------------------------- /libmspack/kwaj.h: -------------------------------------------------------------------------------- 1 | /* This file is part of libmspack. 2 | * (C) 2003-2004 Stuart Caie. 3 | * 4 | * libmspack is free software; you can redistribute it and/or modify it under 5 | * the terms of the GNU Lesser General Public License (LGPL) version 2.1 6 | * 7 | * For further details, see the file COPYING.LIB distributed with libmspack 8 | */ 9 | 10 | #ifndef MSPACK_KWAJ_H 11 | #define MSPACK_KWAJ_H 1 12 | 13 | #include 14 | #include 15 | 16 | /* generic KWAJ definitions */ 17 | 18 | /* KWAJ compression definitions */ 19 | 20 | struct mskwaj_compressor_p { 21 | struct mskwaj_compressor base; 22 | struct mspack_system *system; 23 | /* todo */ 24 | }; 25 | 26 | /* KWAJ decompression definitions */ 27 | 28 | struct mskwaj_decompressor_p { 29 | struct mskwaj_decompressor base; 30 | struct mspack_system *system; 31 | /* todo */ 32 | }; 33 | 34 | #endif 35 | -------------------------------------------------------------------------------- /libmspack/kwajc.c: -------------------------------------------------------------------------------- 1 | /* This file is part of libmspack. 2 | * (C) 2003-2004 Stuart Caie. 3 | * 4 | * libmspack is free software; you can redistribute it and/or modify it under 5 | * the terms of the GNU Lesser General Public License (LGPL) version 2.1 6 | * 7 | * For further details, see the file COPYING.LIB distributed with libmspack 8 | */ 9 | 10 | /* KWAJ compression implementation */ 11 | 12 | #include 13 | #include 14 | 15 | struct mskwaj_compressor * 16 | mspack_create_kwaj_compressor(struct mspack_system *sys) 17 | { 18 | /* todo */ 19 | return NULL; 20 | } 21 | 22 | void mspack_destroy_kwaj_compressor(struct mskwaj_compressor *this) { 23 | /* todo */ 24 | } 25 | -------------------------------------------------------------------------------- /libmspack/kwajd.c: -------------------------------------------------------------------------------- 1 | /* This file is part of libmspack. 2 | * (C) 2003-2004 Stuart Caie. 3 | * 4 | * libmspack is free software; you can redistribute it and/or modify it under 5 | * the terms of the GNU Lesser General Public License (LGPL) version 2.1 6 | * 7 | * For further details, see the file COPYING.LIB distributed with libmspack 8 | */ 9 | 10 | /* KWAJ decompression implementation */ 11 | 12 | #include 13 | #include 14 | 15 | struct mskwaj_decompressor * 16 | mspack_create_kwaj_decompressor(struct mspack_system *sys) 17 | { 18 | /* todo */ 19 | return NULL; 20 | } 21 | 22 | void mspack_destroy_kwaj_decompressor(struct mskwaj_decompressor *this) { 23 | /* todo */ 24 | } 25 | -------------------------------------------------------------------------------- /libmspack/lit.h: -------------------------------------------------------------------------------- 1 | /* This file is part of libmspack. 2 | * (C) 2003-2004 Stuart Caie. 3 | * 4 | * libmspack is free software; you can redistribute it and/or modify it under 5 | * the terms of the GNU Lesser General Public License (LGPL) version 2.1 6 | * 7 | * For further details, see the file COPYING.LIB distributed with libmspack 8 | */ 9 | 10 | #ifndef MSPACK_LIT_H 11 | #define MSPACK_LIT_H 1 12 | 13 | #include 14 | #include 15 | #include 16 | 17 | /* generic LIT definitions */ 18 | 19 | /* LIT compression definitions */ 20 | 21 | struct mslit_compressor_p { 22 | struct mslit_compressor base; 23 | struct mspack_system *system; 24 | /* todo */ 25 | }; 26 | 27 | /* LIT decompression definitions */ 28 | 29 | struct mslit_decompressor_p { 30 | struct mslit_decompressor base; 31 | struct mspack_system *system; 32 | /* todo */ 33 | }; 34 | 35 | #endif 36 | -------------------------------------------------------------------------------- /libmspack/litc.c: -------------------------------------------------------------------------------- 1 | /* This file is part of libmspack. 2 | * (C) 2003-2004 Stuart Caie. 3 | * 4 | * libmspack is free software; you can redistribute it and/or modify it under 5 | * the terms of the GNU Lesser General Public License (LGPL) version 2.1 6 | * 7 | * For further details, see the file COPYING.LIB distributed with libmspack 8 | */ 9 | 10 | /* LIT compression implementation */ 11 | 12 | #include 13 | #include 14 | 15 | struct mslit_compressor * 16 | mspack_create_lit_compressor(struct mspack_system *sys) 17 | { 18 | /* todo */ 19 | return NULL; 20 | } 21 | 22 | void mspack_destroy_lit_compressor(struct mslit_compressor *this) { 23 | /* todo */ 24 | } 25 | -------------------------------------------------------------------------------- /libmspack/litd.c: -------------------------------------------------------------------------------- 1 | /* This file is part of libmspack. 2 | * (C) 2003-2004 Stuart Caie. 3 | * 4 | * libmspack is free software; you can redistribute it and/or modify it under 5 | * the terms of the GNU Lesser General Public License (LGPL) version 2.1 6 | * 7 | * For further details, see the file COPYING.LIB distributed with libmspack 8 | */ 9 | 10 | /* LIT decompression implementation */ 11 | 12 | #include 13 | #include 14 | 15 | struct mslit_decompressor * 16 | mspack_create_lit_decompressor(struct mspack_system *sys) 17 | { 18 | /* todo */ 19 | return NULL; 20 | } 21 | 22 | void mspack_destroy_lit_decompressor(struct mslit_decompressor *this) { 23 | /* todo */ 24 | } 25 | -------------------------------------------------------------------------------- /libmspack/lzss.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mikemccormack/ring3k/21dbdbb0eba96960f3f1da314b25a4f731719576/libmspack/lzss.h -------------------------------------------------------------------------------- /libmspack/lzx.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mikemccormack/ring3k/21dbdbb0eba96960f3f1da314b25a4f731719576/libmspack/lzx.h -------------------------------------------------------------------------------- /libmspack/lzxc.c: -------------------------------------------------------------------------------- 1 | /* This file is part of libmspack. 2 | * (C) 2003-2004 Stuart Caie. 3 | * 4 | * The LZX method was created by Jonathan Forbes and Tomi Poutanen, adapted 5 | * by Microsoft Corporation. 6 | * 7 | * libmspack is free software; you can redistribute it and/or modify it under 8 | * the terms of the GNU Lesser General Public License (LGPL) version 2.1 9 | * 10 | * For further details, see the file COPYING.LIB distributed with libmspack 11 | */ 12 | 13 | /* LZX compression implementation */ 14 | 15 | #include 16 | #include 17 | 18 | /* todo */ 19 | -------------------------------------------------------------------------------- /libmspack/mszipc.c: -------------------------------------------------------------------------------- 1 | /* This file is part of libmspack. 2 | * (C) 2003-2004 Stuart Caie. 3 | * 4 | * The deflate method was created by Phil Katz. MSZIP is equivalent to the 5 | * deflate method. 6 | * 7 | * libmspack is free software; you can redistribute it and/or modify it under 8 | * the terms of the GNU Lesser General Public License (LGPL) version 2.1 9 | * 10 | * For further details, see the file COPYING.LIB distributed with libmspack 11 | */ 12 | 13 | /* MS-ZIP compression implementation */ 14 | 15 | #include 16 | #include 17 | 18 | /* todo */ 19 | -------------------------------------------------------------------------------- /libmspack/sha.h: -------------------------------------------------------------------------------- 1 | /* This file is part of libmspack. 2 | * (C) 2003-2004 Stuart Caie. 3 | * 4 | * libmspack is free software; you can redistribute it and/or modify it under 5 | * the terms of the GNU Lesser General Public License (LGPL) version 2.1 6 | * 7 | * For further details, see the file COPYING.LIB distributed with libmspack 8 | */ 9 | 10 | #ifndef MSPACK_LZSS_H 11 | #define MSPACK_LZSS_H 1 12 | 13 | /* SHA-1 message digest definitions */ 14 | 15 | #endif 16 | -------------------------------------------------------------------------------- /libmspack/system.h: -------------------------------------------------------------------------------- 1 | /* This file is part of libmspack. 2 | * (C) 2003-2004 Stuart Caie. 3 | * 4 | * libmspack is free software; you can redistribute it and/or modify it under 5 | * the terms of the GNU Lesser General Public License (LGPL) version 2.1 6 | * 7 | * For further details, see the file COPYING.LIB distributed with libmspack 8 | */ 9 | 10 | #ifndef MSPACK_SYSTEM_H 11 | #define MSPACK_SYSTEM_H 1 12 | 13 | /* ensure config.h is read before mspack.h */ 14 | #ifdef HAVE_CONFIG_H 15 | # include 16 | #endif 17 | 18 | #include 19 | 20 | /* fix for problem with GCC 4 and glibc (thanks to Ville Skytta) 21 | * http://bugzilla.redhat.com/bugzilla/show_bug.cgi?id=150429 22 | */ 23 | #ifdef read 24 | # undef read 25 | #endif 26 | 27 | #ifdef DEBUG 28 | # include 29 | # define D(x) do { printf("%s:%d ",__FILE__, __LINE__); \ 30 | printf x ; fputc('\n', stdout); fflush(stdout);} while (0); 31 | #else 32 | # define D(x) 33 | #endif 34 | 35 | /* endian-neutral reading of little-endian data */ 36 | #define __egi32(a,n) ( ((((unsigned char *) a)[n+3]) << 24) | \ 37 | ((((unsigned char *) a)[n+2]) << 16) | \ 38 | ((((unsigned char *) a)[n+1]) << 8) | \ 39 | ((((unsigned char *) a)[n+0]))) 40 | #define EndGetI64(a) ((((unsigned long long int) __egi32(a,4)) << 32) | \ 41 | ((unsigned int) __egi32(a,0))) 42 | #define EndGetI32(a) __egi32(a,0) 43 | #define EndGetI16(a) ((((a)[1])<<8)|((a)[0])) 44 | 45 | /* endian-neutral reading of big-endian data */ 46 | #define EndGetM32(a) (((((unsigned char *) a)[0]) << 24) | \ 47 | ((((unsigned char *) a)[1]) << 16) | \ 48 | ((((unsigned char *) a)[2]) << 8) | \ 49 | ((((unsigned char *) a)[3]))) 50 | #define EndGetM16(a) ((((a)[0])<<8)|((a)[1])) 51 | 52 | extern struct mspack_system *mspack_default_system; 53 | 54 | /* returns the length of a file opened for reading */ 55 | extern int mspack_sys_filelen(struct mspack_system *system, 56 | struct mspack_file *file, off_t *length); 57 | 58 | /* validates a system structure */ 59 | extern int mspack_valid_system(struct mspack_system *sys); 60 | 61 | #if HAVE_STRINGS_H 62 | # include 63 | #endif 64 | 65 | #if HAVE_STRING_H 66 | # include 67 | #endif 68 | 69 | #if HAVE_MEMCMP 70 | # define mspack_memcmp memcmp 71 | #else 72 | /* inline memcmp() */ 73 | static inline int mspack_memcmp(const void *s1, const void *s2, size_t n) { 74 | unsigned char *c1 = (unsigned char *) s1; 75 | unsigned char *c2 = (unsigned char *) s2; 76 | if (n == 0) return 0; 77 | while (--n && (*c1 == *c2)) c1++, c2++; 78 | return *c1 - *c2; 79 | } 80 | #endif 81 | 82 | #endif 83 | -------------------------------------------------------------------------------- /libmspack/szdd.h: -------------------------------------------------------------------------------- 1 | /* This file is part of libmspack. 2 | * (C) 2003-2004 Stuart Caie. 3 | * 4 | * libmspack is free software; you can redistribute it and/or modify it under 5 | * the terms of the GNU Lesser General Public License (LGPL) version 2.1 6 | * 7 | * For further details, see the file COPYING.LIB distributed with libmspack 8 | */ 9 | 10 | #ifndef MSPACK_SZDD_H 11 | #define MSPACK_SZDD_H 1 12 | 13 | #include 14 | 15 | /* generic SZDD definitions */ 16 | #define szddhead_Signature (0x00) 17 | #define szddhead_CompType (0x08) 18 | #define szddhead_FileChar (0x09) 19 | #define szddhead_FileLength (0x0A) 20 | #define szddhead_SIZEOF (0x0E) 21 | 22 | #define SZDD_COMPTYPE_A (0x41) 23 | 24 | /* SZDD compression definitions */ 25 | 26 | struct msszdd_compressor_p { 27 | struct msszdd_compressor base; 28 | struct mspack_system *system; 29 | int error; 30 | }; 31 | 32 | /* SZDD decompression definitions */ 33 | 34 | struct msszdd_decompressor_p { 35 | struct msszdd_decompressor base; 36 | struct mspack_system *system; 37 | int error; 38 | }; 39 | 40 | struct msszddd_header_p { 41 | struct msszddd_header base; 42 | struct mspack_file *fh; 43 | }; 44 | 45 | #endif 46 | -------------------------------------------------------------------------------- /libmspack/szddc.c: -------------------------------------------------------------------------------- 1 | /* This file is part of libmspack. 2 | * (C) 2003-2004 Stuart Caie. 3 | * 4 | * libmspack is free software; you can redistribute it and/or modify it under 5 | * the terms of the GNU Lesser General Public License (LGPL) version 2.1 6 | * 7 | * For further details, see the file COPYING.LIB distributed with libmspack 8 | */ 9 | 10 | /* SZDD compression implementation */ 11 | 12 | #include 13 | #include 14 | 15 | struct msszdd_compressor * 16 | mspack_create_szdd_compressor(struct mspack_system *sys) 17 | { 18 | /* todo */ 19 | return NULL; 20 | } 21 | 22 | void mspack_destroy_szdd_compressor(struct msszdd_compressor *this) { 23 | /* todo */ 24 | } 25 | -------------------------------------------------------------------------------- /libntreg/.gitignore: -------------------------------------------------------------------------------- 1 | *.o 2 | *.a 3 | .*.d 4 | -------------------------------------------------------------------------------- /libntreg/Makefile.in: -------------------------------------------------------------------------------- 1 | srcdir = @srcdir@ 2 | VPATH = @srcdir@ 3 | 4 | DEPFLAG = -Wp,-MD,.$@.d 5 | CFLAGS = -O2 -Wall -I$(srcdir) $(DEPFLAG) 6 | CC = @HOSTCC@ 7 | 8 | SOURCE = \ 9 | ntreg.c 10 | 11 | OBJECTS = $(SOURCE:%.c=%.o) 12 | 13 | TARGET = libntreg.a 14 | 15 | all: $(TARGET) 16 | 17 | -include $(OBJECTS:%=.%.d) 18 | 19 | $(TARGET): $(OBJECTS) 20 | $(AR) -r $@ $^ 21 | 22 | clean: 23 | rm -rf $(TARGET) .*.d *.o 24 | 25 | -------------------------------------------------------------------------------- /libudis86/.gitignore: -------------------------------------------------------------------------------- 1 | Makefile 2 | mnemonics.h 3 | mnemonics.c 4 | .*.d 5 | -------------------------------------------------------------------------------- /libudis86/Makefile.in: -------------------------------------------------------------------------------- 1 | # adapted from libudis86 Makefile 2 | 3 | srcdir = @srcdir@ 4 | VPATH = @srcdir@ 5 | 6 | CC = @CC@ 7 | DEPFLAG = -Wp,-MD,.$@.d 8 | CFLAGS = -I. -I$(srcdir) -Wall -O2 $(DEPFLAG) 9 | AR = ar 10 | RM = rm 11 | PERL = perl 12 | 13 | .SUFFIXES: .c .o 14 | 15 | SRCS = \ 16 | decode.c \ 17 | input.c \ 18 | opcmap.c \ 19 | syn.c \ 20 | syn-intel.c \ 21 | syn-att.c \ 22 | udis86.c 23 | 24 | OBJS = $(SRCS:%.c=%.o) mnemonics.o 25 | 26 | .PHONY: all clean 27 | 28 | all: libudis86.a 29 | 30 | include $(wildcard .*.d) 31 | 32 | libudis86.a: $(OBJS) 33 | $(AR) -r libudis86.a $(OBJS) 34 | 35 | $(SRCS:%=$(srcdir)/%): mnemonics.h 36 | 37 | mnemonics.c mnemonics.h: mnemonics.dat mnemonics.pl 38 | $(PERL) $(srcdir)/mnemonics.pl < $< 39 | 40 | clean: 41 | $(RM) -f core *.o *.a mnemonics.c mnemonics.h .*.d 42 | 43 | -------------------------------------------------------------------------------- /libudis86/extern.h: -------------------------------------------------------------------------------- 1 | /* ----------------------------------------------------------------------------- 2 | * extern.h 3 | * 4 | * Copyright (c) 2004, 2005, 2006, Vivek Mohan 5 | * All rights reserved. See LICENSE 6 | * ----------------------------------------------------------------------------- 7 | */ 8 | #ifndef UD_EXTERN_H 9 | #define UD_EXTERN_H 10 | 11 | #ifdef __cplusplus 12 | extern "C" { 13 | #endif 14 | 15 | #include 16 | #include "types.h" 17 | 18 | /* ============================= PUBLIC API ================================= */ 19 | 20 | extern void ud_init(struct ud*); 21 | 22 | extern void ud_set_mode(struct ud*, uint8_t); 23 | 24 | extern void ud_set_pc(struct ud*, uint64_t); 25 | 26 | extern void ud_set_input_hook(struct ud*, int (*)(struct ud*)); 27 | 28 | extern void ud_set_input_buffer(struct ud*, uint8_t*, size_t); 29 | 30 | #ifndef __UD_STANDALONE__ 31 | extern void ud_set_input_file(struct ud*, FILE*); 32 | #endif /* __UD_STANDALONE__ */ 33 | 34 | extern void ud_set_vendor(struct ud*, unsigned); 35 | 36 | extern void ud_set_syntax(struct ud*, void (*)(struct ud*)); 37 | 38 | extern void ud_input_skip(struct ud*, size_t); 39 | 40 | extern int ud_input_end(struct ud*); 41 | 42 | extern unsigned int ud_decode(struct ud*); 43 | 44 | extern unsigned int ud_disassemble(struct ud*); 45 | 46 | extern void ud_translate_intel(struct ud*); 47 | 48 | extern void ud_translate_att(struct ud*); 49 | 50 | extern char* ud_insn_asm(struct ud* u); 51 | 52 | extern uint8_t* ud_insn_ptr(struct ud* u); 53 | 54 | extern uint64_t ud_insn_off(struct ud*); 55 | 56 | extern char* ud_insn_hex(struct ud*); 57 | 58 | extern unsigned int ud_insn_len(struct ud* u); 59 | 60 | extern const char* ud_lookup_mnemonic(enum ud_mnemonic_code c); 61 | 62 | /* ========================================================================== */ 63 | 64 | #ifdef __cplusplus 65 | } 66 | #endif 67 | #endif 68 | -------------------------------------------------------------------------------- /libudis86/input.h: -------------------------------------------------------------------------------- 1 | /* ----------------------------------------------------------------------------- 2 | * input.h 3 | * 4 | * Copyright (c) 2006, Vivek Mohan 5 | * All rights reserved. See LICENSE 6 | * ----------------------------------------------------------------------------- 7 | */ 8 | #ifndef UD_INPUT_H 9 | #define UD_INPUT_H 10 | 11 | #include "types.h" 12 | 13 | uint8_t inp_next(struct ud*); 14 | uint8_t inp_peek(struct ud*); 15 | uint8_t inp_uint8(struct ud*); 16 | uint16_t inp_uint16(struct ud*); 17 | uint32_t inp_uint32(struct ud*); 18 | uint64_t inp_uint64(struct ud*); 19 | void inp_move(struct ud*, size_t); 20 | void inp_back(struct ud*); 21 | 22 | /* inp_init() - Initializes the input system. */ 23 | #define inp_init(u) \ 24 | do { \ 25 | u->inp_curr = 0; \ 26 | u->inp_fill = 0; \ 27 | u->inp_ctr = 0; \ 28 | u->inp_end = 0; \ 29 | } while (0) 30 | 31 | /* inp_start() - Should be called before each de-code operation. */ 32 | #define inp_start(u) u->inp_ctr = 0 33 | 34 | /* inp_back() - Resets the current pointer to its position before the current 35 | * instruction disassembly was started. 36 | */ 37 | #define inp_reset(u) \ 38 | do { \ 39 | u->inp_curr -= u->inp_ctr; \ 40 | u->inp_ctr = 0; \ 41 | } while (0) 42 | 43 | /* inp_sess() - Returns the pointer to current session. */ 44 | #define inp_sess(u) (u->inp_sess) 45 | 46 | /* inp_cur() - Returns the current input byte. */ 47 | #define inp_curr(u) ((u)->inp_cache[(u)->inp_curr]) 48 | 49 | #endif 50 | -------------------------------------------------------------------------------- /libudis86/mnemonics.pl: -------------------------------------------------------------------------------- 1 | #!/usr/bin/perl 2 | # 3 | # mnemonics.pl - generates mnemonic{.h,.c} from mnemonics.dat 4 | # 5 | # Copyright (c) 2002, 2003, 2004 Vivek Mohan 6 | # All rights reserved. 7 | # See (LICENSE) 8 | # 9 | # 10 | 11 | 12 | open(mnm_c,">mnemonics.c") || die "Couldn't create mnemonics.c."; 13 | open(mnm_h,">mnemonics.h") || die "Couldn't create mnemonics.h."; 14 | 15 | print mnm_c "/* Do not edit, generated by mnemonics.pl */ \n"; 16 | print mnm_c "const char* ud_mnemonics[] = \n{\n"; 17 | 18 | print mnm_h "/* Do not edit, Generated by mnemonics.pl */ \n\n"; 19 | print mnm_h "#ifndef UD_MNEMONICS_H\n"; 20 | print mnm_h "#define UD_MNEMONICS_H\n\n"; 21 | print mnm_h "extern const char* ud_mnemonics[];\n\n"; 22 | print mnm_h "enum ud_mnemonic_code \n{ \n"; 23 | 24 | while($mnm = ) { 25 | chop($mnm); 26 | print mnm_c " \"$mnm\",\n"; 27 | print mnm_h " UD_I$mnm,\n"; 28 | } 29 | 30 | print mnm_c " \"I3vil\",\n"; 31 | print mnm_h " UD_I3vil\n"; 32 | 33 | print mnm_c "};\n"; 34 | print mnm_h "};\n"; 35 | print mnm_h "#endif\n"; 36 | 37 | close(mnm_c); 38 | close(mnm_h); 39 | -------------------------------------------------------------------------------- /libudis86/opcmap.h: -------------------------------------------------------------------------------- 1 | /* ----------------------------------------------------------------------------- 2 | * opcmap.h 3 | * 4 | * Copyright (c) 2005, 2006, Vivek Mohan 5 | * All rights reserved. See LICENSE 6 | * ----------------------------------------------------------------------------- 7 | */ 8 | #ifndef UD_OPCMAP_H 9 | #define UD_OPCMAP_H 10 | 11 | #include "types.h" 12 | 13 | /* Prefixes/Macros */ 14 | 15 | #define Pnone 0x00 16 | #define Pa32 0x01 17 | #define P_A32(n) ((n) & 0x01) 18 | #define Po32 0x04 19 | #define P_O32(n) ((n) & 0x04) 20 | #define Pdef64 0x08 21 | #define P_DEF64(n) ((n) & 0x08) 22 | #define Pinv64 0x10 23 | #define P_INV64(n) ((n) & 0x10) 24 | #define Pc1 0x20 25 | #define P_C1(n) ((n) & 0x20) 26 | #define Pc2 0x40 27 | #define P_C2(n) ((n) & 0x40) 28 | #define Pc3 0x80 29 | #define P_C3(n) ((n) & 0x80) 30 | #define PdepM 0x100 31 | #define P_DEPM(n) ((n) & 0x100) 32 | #define REX(c) ((0x40 | c) << 16) 33 | #define P_REX(c) (c & 0xFF0000) 34 | #define P_REX_MASK(n) (0x40 | (0xF & ((n) >> 16))) 35 | #define _W 8 36 | #define _R 4 37 | #define _X 2 38 | #define _B 1 39 | #define P_REX_W(r) ((0xF & (r)) >> 3) 40 | #define P_REX_R(r) ((0x7 & (r)) >> 2) 41 | #define P_REX_X(r) ((0x3 & (r)) >> 1) 42 | #define P_REX_B(r) ((0x1 & (r)) >> 0) 43 | #define SIB_S(b) ((b) >> 6) 44 | #define SIB_I(b) (((b) >> 3) & 7) 45 | #define SIB_B(b) ((b) & 7) 46 | #define MODRM_REG(b) (((b) >> 3) & 7) 47 | #define MODRM_NNN(b) (((b) >> 3) & 7) 48 | #define MODRM_MOD(b) (((b) >> 6) & 3) 49 | #define MODRM_RM(b) ((b) & 7) 50 | 51 | #define SZ_Z 1 52 | #define SZ_V 2 53 | #define SZ_P 3 54 | #define SZ_WP 4 55 | #define SZ_DP 5 56 | #define SZ_MDQ 6 57 | #define SZ_RDQ 7 58 | #define SZ_B 8 59 | #define SZ_W 16 60 | #define SZ_D 32 61 | #define SZ_Q 64 62 | #define SZ_T 80 63 | 64 | /* ----------------------------------------------------------------------------- 65 | * Enumeration of types of the operands in the opcode map. The naming was 66 | * inspired by the AMD manuals. To understand the specifics, read the manuals. 67 | * ----------------------------------------------------------------------------- 68 | */ 69 | enum map_operand_type 70 | { 71 | OP_NONE = 0, 72 | OP_A, 73 | OP_E, 74 | OP_M, 75 | OP_G, 76 | OP_I, 77 | OP_AL, 78 | OP_CL, 79 | OP_DL, 80 | OP_BL, 81 | OP_AH, 82 | OP_CH, 83 | OP_DH, 84 | OP_BH, 85 | OP_ALr8b, 86 | OP_CLr9b, 87 | OP_DLr10b, 88 | OP_BLr11b, 89 | OP_AHr12b, 90 | OP_CHr13b, 91 | OP_DHr14b, 92 | OP_BHr15b, 93 | OP_AX, 94 | OP_CX, 95 | OP_DX, 96 | OP_BX, 97 | OP_SI, 98 | OP_DI, 99 | OP_SP, 100 | OP_BP, 101 | OP_rAX, 102 | OP_rCX, 103 | OP_rDX, 104 | OP_rBX, 105 | OP_rSP, 106 | OP_rBP, 107 | OP_rSI, 108 | OP_rDI, 109 | OP_rAXr8, 110 | OP_rCXr9, 111 | OP_rDXr10, 112 | OP_rBXr11, 113 | OP_rSPr12, 114 | OP_rBPr13, 115 | OP_rSIr14, 116 | OP_rDIr15, 117 | OP_eAX, 118 | OP_eCX, 119 | OP_eDX, 120 | OP_eBX, 121 | OP_eSP, 122 | OP_eBP, 123 | OP_eSI, 124 | OP_eDI, 125 | OP_ES, 126 | OP_CS, 127 | OP_SS, 128 | OP_DS, 129 | OP_FS, 130 | OP_GS, 131 | OP_ST0, 132 | OP_ST1, 133 | OP_ST2, 134 | OP_ST3, 135 | OP_ST4, 136 | OP_ST5, 137 | OP_ST6, 138 | OP_ST7, 139 | OP_J, 140 | OP_S, 141 | OP_O, 142 | OP_I1, 143 | OP_I3, 144 | OP_V, 145 | OP_W, 146 | OP_Q, 147 | OP_P, 148 | OP_R, 149 | OP_C, 150 | OP_D, 151 | OP_VR, 152 | OP_PR 153 | }; 154 | 155 | struct map_operand 156 | { 157 | enum map_operand_type type; 158 | uint8_t size; 159 | }; 160 | 161 | struct map_entry 162 | { 163 | enum ud_mnemonic_code mnemonic; 164 | struct map_operand operand1; 165 | struct map_operand operand2; 166 | struct map_operand operand3; 167 | uint32_t prefix; 168 | }; 169 | 170 | int ud_search_map(struct ud*); 171 | enum ud_mnemonic_code ud_map_get_3dnow(uint8_t); 172 | 173 | #endif 174 | -------------------------------------------------------------------------------- /libudis86/syn.c: -------------------------------------------------------------------------------- 1 | /* ----------------------------------------------------------------------------- 2 | * syn.c 3 | * 4 | * Copyright (c) 2002, 2003, 2004 Vivek Mohan 5 | * All rights reserved. See (LICENSE) 6 | * ----------------------------------------------------------------------------- 7 | */ 8 | 9 | /* ----------------------------------------------------------------------------- 10 | * Intel Register Table - Order Matters (types.h)! 11 | * ----------------------------------------------------------------------------- 12 | */ 13 | const char* ud_reg_tab[] = 14 | { 15 | "al", "cl", "dl", "bl", 16 | "ah", "ch", "dh", "bh", 17 | "spl", "bpl", "sil", "dil", 18 | "r8b", "r9b", "r10b", "r11b", 19 | "r12b", "r13b", "r14b", "r15b", 20 | 21 | "ax", "cx", "dx", "bx", 22 | "sp", "bp", "si", "di", 23 | "r8w", "r9w", "r10w", "r11w", 24 | "r12w", "r13W" , "r14w", "r15w", 25 | 26 | "eax", "ecx", "edx", "ebx", 27 | "esp", "ebp", "esi", "edi", 28 | "r8d", "r9d", "r10d", "r11d", 29 | "r12d", "r13d", "r14d", "r15d", 30 | 31 | "rax", "rcx", "rdx", "rbx", 32 | "rsp", "rbp", "rsi", "rdi", 33 | "r8", "r9", "r10", "r11", 34 | "r12", "r13", "r14", "r15", 35 | 36 | "es", "cs", "ss", "ds", 37 | "fs", "gs", 38 | 39 | "cr0", "cr1", "cr2", "cr3", 40 | "cr4", "cr5", "cr6", "cr7", 41 | "cr8", "cr9", "cr10", "cr11", 42 | "cr12", "cr13", "cr14", "cr15", 43 | 44 | "dr0", "dr1", "dr2", "dr3", 45 | "dr4", "dr5", "dr6", "dr7", 46 | "dr8", "dr9", "dr10", "dr11", 47 | "dr12", "dr13", "dr14", "dr15", 48 | 49 | "mm0", "mm1", "mm2", "mm3", 50 | "mm4", "mm5", "mm6", "mm7", 51 | 52 | "st0", "st1", "st2", "st3", 53 | "st4", "st5", "st6", "st7", 54 | 55 | "xmm0", "xmm1", "xmm2", "xmm3", 56 | "xmm4", "xmm5", "xmm6", "xmm7", 57 | "xmm8", "xmm9", "xmm10", "xmm11", 58 | "xmm12", "xmm13", "xmm14", "xmm15", 59 | 60 | "rip" 61 | }; 62 | -------------------------------------------------------------------------------- /libudis86/syn.h: -------------------------------------------------------------------------------- 1 | /* ----------------------------------------------------------------------------- 2 | * syn.h 3 | * 4 | * Copyright (c) 2006, Vivek Mohan 5 | * All rights reserved. See LICENSE 6 | * ----------------------------------------------------------------------------- 7 | */ 8 | #ifndef UD_SYN_H 9 | #define UD_SYN_H 10 | 11 | #include 12 | #include 13 | #include "types.h" 14 | 15 | extern const char* ud_reg_tab[]; 16 | 17 | static void mkasm(struct ud* u, const char* fmt, ...) 18 | { 19 | va_list ap; 20 | va_start(ap, fmt); 21 | u->insn_fill += vsprintf((char*) u->insn_buffer + u->insn_fill, fmt, ap); 22 | va_end(ap); 23 | } 24 | 25 | #endif 26 | -------------------------------------------------------------------------------- /programs/Makefile.in: -------------------------------------------------------------------------------- 1 | # 2 | # ring3k - a user mode kernel for windows executables 3 | # 4 | # Copyright 2006-2009 Mike McCormack 5 | # 6 | # This library is free software; you can redistribute it and/or 7 | # modify it under the terms of the GNU Lesser General Public 8 | # License as published by the Free Software Foundation; either 9 | # version 2.1 of the License, or (at your option) any later version. 10 | # 11 | # This library is distributed in the hope that it will be useful, 12 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 14 | # Lesser General Public License for more details. 15 | # 16 | # You should have received a copy of the GNU Lesser General Public 17 | # License along with this library; if not, write to the Free Software 18 | # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA 19 | # 20 | 21 | srcdir = @srcdir@ 22 | VPATH = @srcdir@ 23 | 24 | prefix = @prefix@ 25 | bindir = ${prefix}/bin 26 | 27 | MAKE = make 28 | RM = rm -f 29 | 30 | SUBDIRS = \ 31 | clock \ 32 | minitris \ 33 | minshell \ 34 | winemine \ 35 | winlogon 36 | 37 | all: $(SUBDIRS) 38 | 39 | .PHONY: \ 40 | all \ 41 | clean \ 42 | dummy \ 43 | test 44 | 45 | @MAKE_RULES@ 46 | -------------------------------------------------------------------------------- /programs/clock/.gitignore: -------------------------------------------------------------------------------- 1 | .*.d 2 | Makefile 3 | clock.exe 4 | -------------------------------------------------------------------------------- /programs/clock/Makefile.in: -------------------------------------------------------------------------------- 1 | srcdir = @srcdir@ 2 | VPATH = @srcdir@ 3 | 4 | DEPFLAG = -Wp,-MD,.$@.d 5 | CC=@MINGW32CC@ 6 | STRIP=@MINGW32STRIP@ 7 | CFLAGS=-Wall -O2 $(DEPFLAG) 8 | AS=@MINGW32AS@ 9 | AR=@MINGW32AR@ 10 | RANLIB=@MINGW32RANLIB@ 11 | WINDRES=@MINGW32WINDRES@ 12 | 13 | INSTALL = @INSTALL@ 14 | INSTALL_PROGRAM = @INSTALL_PROGRAM@ 15 | INSTALL_DATA = @INSTALL_DATA@ 16 | prefix = @prefix@ 17 | bindir = ${prefix}/bin 18 | datadir = ${prefix}/data 19 | 20 | SOURCE = \ 21 | clock.c 22 | 23 | TARGET = clock.exe 24 | 25 | all: $(TARGET) 26 | 27 | .PHONY: all clean 28 | 29 | OBJECTS += $(SOURCE:.c=.o) 30 | OBJECTS += $(RESOURCES:.rc=.res) 31 | 32 | %.res: %.rc 33 | $(WINDRES) -i $< -o $@ -O coff 34 | 35 | $(TARGET): $(OBJECTS) 36 | $(CC) -o $@ $^ -lgdi32 -luser32 -Wl,--subsystem=windows 37 | 38 | include $(wildcard .*.d) 39 | 40 | clean: 41 | rm -f $(OBJECTS) $(TARGET) .*.d 42 | 43 | install: 44 | 45 | uninstall: 46 | 47 | -------------------------------------------------------------------------------- /programs/minitris/.gitignore: -------------------------------------------------------------------------------- 1 | *.d 2 | Makefile 3 | *.exe 4 | *.o 5 | -------------------------------------------------------------------------------- /programs/minitris/Makefile.in: -------------------------------------------------------------------------------- 1 | # 2 | # Makefile for mintris gdi test game 3 | # Copyright 2008 Mike McCormack 4 | # 5 | 6 | srcdir = @srcdir@ 7 | VPATH = @srcdir@ 8 | 9 | DEPFLAG = -Wp,-MD,.$@.d 10 | CC = @MINGW32CC@ 11 | STRIP = @MINGW32STRIP@ 12 | CFLAGS = -Wall -O2 $(DEPFLAG) 13 | AS = @MINGW32AS@ 14 | AR = @MINGW32AR@ 15 | RANLIB = @MINGW32RANLIB@ 16 | WINDRES = @MINGW32WINDRES@ 17 | 18 | INSTALL = @INSTALL@ 19 | INSTALL_PROGRAM = @INSTALL_PROGRAM@ 20 | INSTALL_DATA = @INSTALL_DATA@ 21 | prefix = @prefix@ 22 | bindir = ${prefix}/bin 23 | datadir = ${prefix}/data 24 | 25 | SOURCE = \ 26 | minitris.c 27 | 28 | TARGET = minitris.exe 29 | 30 | OBJECTS = $(SOURCE:.c=.o) 31 | 32 | .PHONY: all clean 33 | 34 | all: $(SOURCE:.c=.exe) 35 | 36 | -include $(OBJECTS:%=$(dir %).$(notdir %).d) 37 | 38 | $(TARGET): $(OBJECTS) 39 | $(CC) $(CFLAGS) -o $@ $< -lgdi32 -luser32 -Wl,--subsystem=windows 40 | 41 | clean: 42 | rm -f *.o *.dll *.exe .*.d 43 | 44 | install: $(TARGET) 45 | mkdir -p $(DESTDIR)$(datadir) 46 | $(INSTALL_DATA) $(INSTALL_FLAGS) $< $(DESTDIR)$(datadir) 47 | -------------------------------------------------------------------------------- /programs/minshell/.gitignore: -------------------------------------------------------------------------------- 1 | *.exe 2 | .*.d 3 | -------------------------------------------------------------------------------- /programs/minshell/Makefile.in: -------------------------------------------------------------------------------- 1 | # 2 | # Makefile for minimal shell 3 | # Copyright 2008-2009 Mike McCormack 4 | # 5 | 6 | srcdir = @srcdir@ 7 | VPATH = @srcdir@ 8 | 9 | DEPFLAG = -Wp,-MD,.$@.d 10 | CC = @MINGW32CC@ 11 | STRIP = @MINGW32STRIP@ 12 | CFLAGS = -Wall -O2 $(DEPFLAG) 13 | AS = @MINGW32AS@ 14 | AR = @MINGW32AR@ 15 | RANLIB = @MINGW32RANLIB@ 16 | WINDRES = @MINGW32WINDRES@ 17 | 18 | INSTALL = @INSTALL@ 19 | INSTALL_PROGRAM = @INSTALL_PROGRAM@ 20 | INSTALL_DATA = @INSTALL_DATA@ 21 | prefix = @prefix@ 22 | bindir = ${prefix}/bin 23 | datadir = ${prefix}/data 24 | 25 | SOURCE = \ 26 | minshell.c 27 | 28 | TARGET = minshell.exe 29 | 30 | OBJECTS = $(SOURCE:.c=.o) 31 | 32 | .PHONY: all clean 33 | 34 | all: $(SOURCE:.c=.exe) 35 | 36 | -include $(OBJECTS:%=$(dir %).$(notdir %).d) 37 | 38 | $(TARGET): $(OBJECTS) 39 | $(CC) $(CFLAGS) -o $@ $< -lgdi32 -luser32 -Wl,--subsystem=windows 40 | 41 | clean: 42 | rm -f *.o *.dll *.exe .*.d 43 | 44 | install: $(TARGET) 45 | mkdir -p $(DESTDIR)$(datadir) 46 | $(INSTALL_DATA) $(INSTALL_FLAGS) $< $(DESTDIR)$(datadir) 47 | -------------------------------------------------------------------------------- /programs/minshell/minshell.c: -------------------------------------------------------------------------------- 1 | /* 2 | * minimal shell 3 | * 4 | * Copyright 2006-2009 Mike McCormack 5 | * 6 | * This library is free software; you can redistribute it and/or 7 | * modify it under the terms of the GNU Lesser General Public 8 | * License as published by the Free Software Foundation; either 9 | * version 2.1 of the License, or (at your option) any later version. 10 | * 11 | * This library is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 14 | * Lesser General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU Lesser General Public 17 | * License along with this library; if not, write to the Free Software 18 | * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA 19 | */ 20 | 21 | #include 22 | #include 23 | 24 | #define TERMINAL_WIDTH 80 25 | #define TERMINAL_HEIGHT 25 26 | 27 | char terminal_buffer[TERMINAL_WIDTH*TERMINAL_HEIGHT]; 28 | 29 | void dprintf( const char *format, ... ) 30 | { 31 | char str[0x100]; 32 | va_list va; 33 | va_start( va, format ); 34 | vsprintf( str, format, va ); 35 | va_end( va ); 36 | OutputDebugString( str ); 37 | } 38 | 39 | void do_paint( HWND hwnd ) 40 | { 41 | PAINTSTRUCT ps; 42 | int len = strlen( terminal_buffer ); 43 | BeginPaint( hwnd, &ps ); 44 | TextOut( ps.hdc, 0, 0, terminal_buffer, len ); 45 | EndPaint( hwnd, &ps ); 46 | } 47 | 48 | void do_addchar( HWND hwnd, UINT ch ) 49 | { 50 | int len = strlen( terminal_buffer ); 51 | // backspace 52 | if (ch == 0x08) 53 | { 54 | if (len <= 0) 55 | return; 56 | len--; 57 | } 58 | else 59 | { 60 | if (len >= sizeof terminal_buffer - 1) 61 | return; 62 | terminal_buffer[len] = ch; 63 | len++; 64 | } 65 | terminal_buffer[len] = 0; 66 | InvalidateRect( hwnd, 0, 0 ); 67 | } 68 | 69 | LRESULT CALLBACK minshell_wndproc(HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam) 70 | { 71 | switch (msg) 72 | { 73 | case WM_PAINT: 74 | do_paint( hwnd ); 75 | break; 76 | case WM_CHAR: 77 | do_addchar( hwnd, wparam ); 78 | break; 79 | case WM_CLOSE: 80 | PostQuitMessage( 1 ); 81 | } 82 | return DefWindowProc(hwnd, msg, wparam, lparam); 83 | } 84 | 85 | // normal windows program 86 | int window_winmain( HINSTANCE Instance ) 87 | { 88 | WNDCLASS wc; 89 | MSG msg; 90 | HWND hwnd; 91 | 92 | wc.style = 0; 93 | wc.lpfnWndProc = minshell_wndproc; 94 | wc.cbClsExtra = 0; 95 | wc.cbWndExtra = 0; 96 | wc.hInstance = Instance; 97 | wc.hIcon = 0; 98 | wc.hCursor = 0; 99 | wc.hbrBackground = GetStockObject( BLACK_BRUSH ); 100 | wc.lpszMenuName = 0; 101 | wc.lpszClassName = "MINSHELL"; 102 | if (!RegisterClass( &wc )) 103 | { 104 | dprintf("failed to register class\n"); 105 | //MessageBox( NULL, "Failed to register class", "Error", MB_OK ); 106 | return 0; 107 | } 108 | 109 | hwnd = CreateWindow("MINSHELL", "Minimal shell", WS_VISIBLE|WS_POPUP|WS_DLGFRAME, 110 | CW_USEDEFAULT, CW_USEDEFAULT, 300, 300, 111 | NULL, NULL, Instance, NULL); 112 | if (!hwnd) 113 | { 114 | dprintf("failed to create window\n"); 115 | //MessageBox( NULL, "Failed to create window", "Error", MB_OK ); 116 | return 0; 117 | } 118 | 119 | while (GetMessage( &msg, 0, 0, 0 )) 120 | { 121 | TranslateMessage( &msg ); 122 | DispatchMessage( &msg ); 123 | } 124 | 125 | return 0; 126 | } 127 | 128 | int APIENTRY WinMain( HINSTANCE Instance, HINSTANCE Prev, LPSTR CmdLine, int Show ) 129 | { 130 | // running as normal windows program 131 | return window_winmain( Instance ); 132 | } 133 | 134 | -------------------------------------------------------------------------------- /programs/pixels/.gitignore: -------------------------------------------------------------------------------- 1 | .*.d 2 | *.exe 3 | *.dll 4 | -------------------------------------------------------------------------------- /programs/pixels/Makefile.in: -------------------------------------------------------------------------------- 1 | # 2 | # Makefile for winlogon replacement 3 | # Copyright 2008-2009 Mike McCormack 4 | # 5 | 6 | srcdir = @srcdir@ 7 | VPATH = @srcdir@ 8 | 9 | DEPFLAG = -Wp,-MD,.$@.d 10 | CC = @MINGW32CC@ 11 | STRIP = @MINGW32STRIP@ 12 | CFLAGS = -Wall -O2 $(DEPFLAG) 13 | AS = @MINGW32AS@ 14 | AR = @MINGW32AR@ 15 | RANLIB = @MINGW32RANLIB@ 16 | WINDRES = @MINGW32WINDRES@ 17 | 18 | INSTALL = @INSTALL@ 19 | INSTALL_PROGRAM = @INSTALL_PROGRAM@ 20 | INSTALL_DATA = @INSTALL_DATA@ 21 | prefix = @prefix@ 22 | bindir = ${prefix}/bin 23 | datadir = ${prefix}/data 24 | 25 | SOURCE = \ 26 | pixels.c 27 | 28 | TARGET = pixels.exe 29 | 30 | OBJECTS = $(SOURCE:.c=.o) 31 | 32 | .PHONY: all clean 33 | 34 | all: $(SOURCE:.c=.exe) 35 | 36 | -include $(OBJECTS:%=$(dir %).$(notdir %).d) 37 | 38 | $(TARGET): $(OBJECTS) 39 | $(CC) $(CFLAGS) -o $@ $< -lgdi32 -luser32 -Wl,--subsystem=windows 40 | 41 | clean: 42 | rm -f *.o *.dll *.exe .*.d 43 | 44 | install: $(TARGET) 45 | mkdir -p $(DESTDIR)$(datadir) 46 | $(INSTALL_DATA) $(INSTALL_FLAGS) $< $(DESTDIR)$(datadir) 47 | -------------------------------------------------------------------------------- /programs/winemine/.gitignore: -------------------------------------------------------------------------------- 1 | *.res 2 | *.exe 3 | *.o.d 4 | -------------------------------------------------------------------------------- /programs/winemine/Cs.rc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mikemccormack/ring3k/21dbdbb0eba96960f3f1da314b25a4f731719576/programs/winemine/Cs.rc -------------------------------------------------------------------------------- /programs/winemine/Da.rc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mikemccormack/ring3k/21dbdbb0eba96960f3f1da314b25a4f731719576/programs/winemine/Da.rc -------------------------------------------------------------------------------- /programs/winemine/De.rc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mikemccormack/ring3k/21dbdbb0eba96960f3f1da314b25a4f731719576/programs/winemine/De.rc -------------------------------------------------------------------------------- /programs/winemine/En.rc: -------------------------------------------------------------------------------- 1 | /* 2 | * WineMine 3 | * English Language Support 4 | * 5 | * Copyright 2000 Joshua Thielen 6 | * Copyright 2003 Marcelo Duarte 7 | * 8 | * This library is free software; you can redistribute it and/or 9 | * modify it under the terms of the GNU Lesser General Public 10 | * License as published by the Free Software Foundation; either 11 | * version 2.1 of the License, or (at your option) any later version. 12 | * 13 | * This library is distributed in the hope that it will be useful, 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 16 | * Lesser General Public License for more details. 17 | * 18 | * You should have received a copy of the GNU Lesser General Public 19 | * License along with this library; if not, write to the Free Software 20 | * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA 21 | */ 22 | 23 | LANGUAGE LANG_ENGLISH, SUBLANG_DEFAULT 24 | 25 | STRINGTABLE { 26 | IDS_APPNAME, "WineMine" 27 | IDS_NOBODY, "Nobody" 28 | IDS_ABOUT, "Copyright 2000 Joshua Thielen" 29 | } 30 | 31 | MENU_WINEMINE MENU DISCARDABLE 32 | { 33 | POPUP "&Options" { 34 | MENUITEM "&New\tF2", IDM_NEW 35 | MENUITEM SEPARATOR 36 | MENUITEM "&Mark Question", IDM_MARKQ 37 | MENUITEM SEPARATOR 38 | MENUITEM "&Beginner", IDM_BEGINNER 39 | MENUITEM "&Advanced", IDM_ADVANCED 40 | MENUITEM "&Expert", IDM_EXPERT 41 | MENUITEM "&Custom", IDM_CUSTOM 42 | MENUITEM SEPARATOR 43 | MENUITEM "E&xit\tAlt+X", IDM_EXIT 44 | } 45 | POPUP "&Info" { 46 | MENUITEM "&Fastest Times", IDM_TIMES 47 | MENUITEM "&About", IDM_ABOUT 48 | } 49 | } 50 | 51 | DLG_TIMES DIALOG DISCARDABLE 0, 0, 160, 80 52 | STYLE DS_MODALFRAME | DS_3DLOOK | 53 | WS_VISIBLE | WS_CAPTION | WS_SYSMENU | WS_POPUP 54 | CAPTION "Fastest Times" 55 | { 56 | GROUPBOX "Fastest Times", IDIGNORE, 10, 10, 140, 45 57 | LTEXT "Beginner", IDIGNORE, 20, 20, 40, 8 58 | LTEXT "Advanced", IDIGNORE, 20, 30, 40, 8 59 | LTEXT "Expert", IDIGNORE, 20, 40, 40, 8 60 | LTEXT "999", IDC_TIME1, 70, 20, 15, 8 61 | LTEXT "999", IDC_TIME2, 70, 30, 15, 8 62 | LTEXT "999", IDC_TIME3, 70, 40, 15, 8 63 | LTEXT "", IDC_NAME1, 90, 20, 55, 8 64 | LTEXT "", IDC_NAME2, 90, 30, 55, 8 65 | LTEXT "", IDC_NAME3, 90, 40, 55, 8 66 | DEFPUSHBUTTON "OK", IDOK, 55, 60, 50, 15 67 | } 68 | 69 | DLG_CONGRATS DIALOG DISCARDABLE 0, 0, 160, 60 70 | STYLE DS_MODALFRAME | DS_3DLOOK | 71 | WS_VISIBLE | WS_CAPTION | WS_SYSMENU | WS_POPUP 72 | CAPTION "Congratulations!" 73 | { 74 | LTEXT "Please enter your name", IDIGNORE, 10, 10, 150, 10 75 | EDITTEXT IDC_EDITNAME, 25, 20, 110, 12 76 | DEFPUSHBUTTON "OK", IDOK, 60, 40, 40, 15 77 | } 78 | 79 | DLG_CUSTOM DIALOG DISCARDABLE 0, 0, 100, 100 80 | STYLE DS_MODALFRAME | DS_3DLOOK | 81 | WS_VISIBLE | WS_CAPTION | WS_SYSMENU | WS_POPUP 82 | CAPTION "Custom Game" 83 | { 84 | LTEXT "Rows", IDIGNORE, 5, 5, 30, 10 85 | LTEXT "Cols", IDIGNORE, 5, 35, 30, 10 86 | LTEXT "Mines", IDIGNORE, 5, 65, 30, 10 87 | EDITTEXT IDC_EDITROWS, 5, 15, 20, 12, ES_NUMBER 88 | EDITTEXT IDC_EDITCOLS, 5, 45, 20, 12, ES_NUMBER 89 | EDITTEXT IDC_EDITMINES, 5, 75, 20, 12, ES_NUMBER 90 | DEFPUSHBUTTON "OK", IDOK, 40, 30, 50, 15 91 | PUSHBUTTON "Cancel", IDCANCEL, 40, 50, 50, 15 92 | } 93 | -------------------------------------------------------------------------------- /programs/winemine/Es.rc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mikemccormack/ring3k/21dbdbb0eba96960f3f1da314b25a4f731719576/programs/winemine/Es.rc -------------------------------------------------------------------------------- /programs/winemine/Fi.rc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mikemccormack/ring3k/21dbdbb0eba96960f3f1da314b25a4f731719576/programs/winemine/Fi.rc -------------------------------------------------------------------------------- /programs/winemine/Fr.rc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mikemccormack/ring3k/21dbdbb0eba96960f3f1da314b25a4f731719576/programs/winemine/Fr.rc -------------------------------------------------------------------------------- /programs/winemine/It.rc: -------------------------------------------------------------------------------- 1 | /* 2 | * WineMine 3 | * Italian Language Support 4 | * 5 | * Copyright 2000 Joshua Thielen 6 | * Copyright 2003 Marcelo Duarte 7 | * Copyright 2003-2004 Ivan Leo Puoti 8 | * 9 | * This library is free software; you can redistribute it and/or 10 | * modify it under the terms of the GNU Lesser General Public 11 | * License as published by the Free Software Foundation; either 12 | * version 2.1 of the License, or (at your option) any later version. 13 | * 14 | * This library is distributed in the hope that it will be useful, 15 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 16 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 17 | * Lesser General Public License for more details. 18 | * 19 | * You should have received a copy of the GNU Lesser General Public 20 | * License along with this library; if not, write to the Free Software 21 | * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA 22 | */ 23 | 24 | LANGUAGE LANG_ITALIAN, SUBLANG_NEUTRAL 25 | 26 | STRINGTABLE { 27 | IDS_APPNAME, "WineMine" 28 | IDS_NOBODY, "Nobody" 29 | IDS_ABOUT, "Copyright 2000 Joshua Thielen" 30 | } 31 | 32 | MENU_WINEMINE MENU DISCARDABLE 33 | { 34 | POPUP "&Opzioni" { 35 | MENUITEM "&Nuovo\tF2", IDM_NEW 36 | MENUITEM SEPARATOR 37 | MENUITEM "&Contrassegna domanda", IDM_MARKQ 38 | MENUITEM SEPARATOR 39 | MENUITEM "&Principiante", IDM_BEGINNER 40 | MENUITEM "&Avanzato", IDM_ADVANCED 41 | MENUITEM "&Esperto", IDM_EXPERT 42 | MENUITEM "&Presonalizza", IDM_CUSTOM 43 | MENUITEM SEPARATOR 44 | MENUITEM "E&sci\tAlt+X", IDM_EXIT 45 | } 46 | POPUP "&Informazioni" { 47 | MENUITEM "&Tempi migliori", IDM_TIMES 48 | MENUITEM "&Informazioni su WineMine", IDM_ABOUT 49 | } 50 | } 51 | 52 | DLG_TIMES DIALOG DISCARDABLE 0, 0, 160, 80 53 | STYLE DS_MODALFRAME | DS_3DLOOK | 54 | WS_VISIBLE | WS_CAPTION | WS_SYSMENU | WS_POPUP 55 | CAPTION "Tempi migliori" 56 | { 57 | GROUPBOX "Tempi migliori", IDIGNORE, 10, 10, 140, 45 58 | LTEXT "Principiante", IDIGNORE, 20, 20, 40, 8 59 | LTEXT "Avanzato", IDIGNORE, 20, 30, 40, 8 60 | LTEXT "Esperto", IDIGNORE, 20, 40, 40, 8 61 | LTEXT "999", IDC_TIME1, 70, 20, 15, 8 62 | LTEXT "999", IDC_TIME2, 70, 30, 15, 8 63 | LTEXT "999", IDC_TIME3, 70, 40, 15, 8 64 | LTEXT "", IDC_NAME1, 90, 20, 55, 8 65 | LTEXT "", IDC_NAME2, 90, 30, 55, 8 66 | LTEXT "", IDC_NAME3, 90, 40, 55, 8 67 | DEFPUSHBUTTON "OK", IDOK, 55, 60, 50, 15 68 | } 69 | 70 | DLG_CONGRATS DIALOG DISCARDABLE 0, 0, 160, 60 71 | STYLE DS_MODALFRAME | DS_3DLOOK | 72 | WS_VISIBLE | WS_CAPTION | WS_SYSMENU | WS_POPUP 73 | CAPTION "Congratulazioni!" 74 | { 75 | LTEXT "Inserisci il tuo nome", IDIGNORE, 10, 10, 150, 10 76 | EDITTEXT IDC_EDITNAME, 25, 20, 110, 12 77 | DEFPUSHBUTTON "OK", IDOK, 60, 40, 40, 15 78 | } 79 | 80 | DLG_CUSTOM DIALOG DISCARDABLE 0, 0, 100, 100 81 | STYLE DS_MODALFRAME | DS_3DLOOK | 82 | WS_VISIBLE | WS_CAPTION | WS_SYSMENU | WS_POPUP 83 | CAPTION "Custom Game" 84 | { 85 | LTEXT "Righe", IDIGNORE, 5, 5, 30, 10 86 | LTEXT "Colonne", IDIGNORE, 5, 35, 30, 10 87 | LTEXT "Mine", IDIGNORE, 5, 65, 30, 10 88 | EDITTEXT IDC_EDITROWS, 5, 15, 20, 12, ES_NUMBER 89 | EDITTEXT IDC_EDITCOLS, 5, 45, 20, 12, ES_NUMBER 90 | EDITTEXT IDC_EDITMINES, 5, 75, 20, 12, ES_NUMBER 91 | DEFPUSHBUTTON "OK", IDOK, 40, 30, 50, 15 92 | PUSHBUTTON "Annulla", IDCANCEL, 40, 50, 50, 15 93 | } 94 | -------------------------------------------------------------------------------- /programs/winemine/Ja.rc: -------------------------------------------------------------------------------- 1 | /* 2 | * WineMine 3 | * Japanese Language Support 4 | * 5 | * Copyright 2000 Joshua Thielen 6 | * Copyright 2003 Marcelo Duarte 7 | * 8 | * This library is free software; you can redistribute it and/or 9 | * modify it under the terms of the GNU Lesser General Public 10 | * License as published by the Free Software Foundation; either 11 | * version 2.1 of the License, or (at your option) any later version. 12 | * 13 | * This library is distributed in the hope that it will be useful, 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 16 | * Lesser General Public License for more details. 17 | * 18 | * You should have received a copy of the GNU Lesser General Public 19 | * License along with this library; if not, write to the Free Software 20 | * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA 21 | */ 22 | 23 | /* UTF-8 */ 24 | #pragma code_page(65001) 25 | 26 | LANGUAGE LANG_JAPANESE, SUBLANG_DEFAULT 27 | 28 | STRINGTABLE { 29 | IDS_APPNAME, "WineMine" 30 | IDS_NOBODY, "Nobody" 31 | IDS_ABOUT, "Copyright 2000 Joshua Thielen" 32 | } 33 | 34 | MENU_WINEMINE MENU DISCARDABLE 35 | { 36 | POPUP "オプション(&O)" { 37 | MENUITEM "スタート(&N)\tF2", IDM_NEW 38 | MENUITEM SEPARATOR 39 | MENUITEM "?マークを使用(&M)", IDM_MARKQ 40 | MENUITEM SEPARATOR 41 | MENUITEM "初級(&B)", IDM_BEGINNER 42 | MENUITEM "中級(&A)", IDM_ADVANCED 43 | MENUITEM "上級(&E)", IDM_EXPERT 44 | MENUITEM "盤面の変更(&C)", IDM_CUSTOM 45 | MENUITEM SEPARATOR 46 | MENUITEM "終了(&X)\tAlt+X", IDM_EXIT 47 | } 48 | POPUP "情報(&I)" { 49 | MENUITEM "ハイスコア(&F)", IDM_TIMES 50 | MENUITEM "WineMine について(&A)", IDM_ABOUT 51 | } 52 | } 53 | 54 | DLG_TIMES DIALOG DISCARDABLE 0, 0, 160, 80 55 | STYLE DS_MODALFRAME | DS_3DLOOK | 56 | WS_VISIBLE | WS_CAPTION | WS_SYSMENU | WS_POPUP 57 | CAPTION "Fastest Times" 58 | { 59 | GROUPBOX "ハイスコア", IDIGNORE, 10, 10, 140, 45 60 | LTEXT "初級", IDIGNORE, 20, 20, 40, 8 61 | LTEXT "中級", IDIGNORE, 20, 30, 40, 8 62 | LTEXT "上級", IDIGNORE, 20, 40, 40, 8 63 | LTEXT "999", IDC_TIME1, 70, 20, 15, 8 64 | LTEXT "999", IDC_TIME2, 70, 30, 15, 8 65 | LTEXT "999", IDC_TIME3, 70, 40, 15, 8 66 | LTEXT "", IDC_NAME1, 90, 20, 55, 8 67 | LTEXT "", IDC_NAME2, 90, 30, 55, 8 68 | LTEXT "", IDC_NAME3, 90, 40, 55, 8 69 | DEFPUSHBUTTON "OK", IDOK, 55, 60, 50, 15 70 | } 71 | 72 | DLG_CONGRATS DIALOG DISCARDABLE 0, 0, 160, 60 73 | STYLE DS_MODALFRAME | DS_3DLOOK | 74 | WS_VISIBLE | WS_CAPTION | WS_SYSMENU | WS_POPUP 75 | CAPTION "おめでとう!" 76 | { 77 | LTEXT "名前を入力しましょう", IDIGNORE, 10, 10, 150, 10 78 | EDITTEXT IDC_EDITNAME, 25, 20, 110, 12 79 | DEFPUSHBUTTON "OK", IDOK, 60, 40, 40, 15 80 | } 81 | 82 | DLG_CUSTOM DIALOG DISCARDABLE 0, 0, 100, 100 83 | STYLE DS_MODALFRAME | DS_3DLOOK | 84 | WS_VISIBLE | WS_CAPTION | WS_SYSMENU | WS_POPUP 85 | CAPTION "盤面の変更" 86 | { 87 | LTEXT "Rows", IDIGNORE, 5, 5, 30, 10 88 | LTEXT "Cols", IDIGNORE, 5, 35, 30, 10 89 | LTEXT "Mines", IDIGNORE, 5, 65, 30, 10 90 | EDITTEXT IDC_EDITROWS, 5, 15, 20, 12, ES_NUMBER 91 | EDITTEXT IDC_EDITCOLS, 5, 45, 20, 12, ES_NUMBER 92 | EDITTEXT IDC_EDITMINES, 5, 75, 20, 12, ES_NUMBER 93 | DEFPUSHBUTTON "OK", IDOK, 40, 30, 50, 15 94 | PUSHBUTTON "Cancel", IDCANCEL, 40, 50, 50, 15 95 | } 96 | 97 | #pragma code_page(default) 98 | -------------------------------------------------------------------------------- /programs/winemine/Ko.rc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mikemccormack/ring3k/21dbdbb0eba96960f3f1da314b25a4f731719576/programs/winemine/Ko.rc -------------------------------------------------------------------------------- /programs/winemine/Makefile.in: -------------------------------------------------------------------------------- 1 | srcdir = @srcdir@ 2 | VPATH = @srcdir@ 3 | 4 | DEPFLAG = -Wp,-MD,.$@.d 5 | CC=@MINGW32CC@ 6 | STRIP=@MINGW32STRIP@ 7 | CFLAGS=-Wall -O2 $(DEPFLAG) 8 | AS=@MINGW32AS@ 9 | AR=@MINGW32AR@ 10 | RANLIB=@MINGW32RANLIB@ 11 | WINDRES=@MINGW32WINDRES@ 12 | 13 | INSTALL = @INSTALL@ 14 | INSTALL_PROGRAM = @INSTALL_PROGRAM@ 15 | INSTALL_DATA = @INSTALL_DATA@ 16 | prefix = @prefix@ 17 | bindir = ${prefix}/bin 18 | datadir = ${prefix}/data 19 | 20 | SOURCE = \ 21 | dialog.c \ 22 | main.c 23 | 24 | RESOURCES = rsrc.rc 25 | 26 | TARGET = winemine.exe 27 | 28 | all: $(TARGET) 29 | 30 | .PHONY: all clean 31 | 32 | OBJECTS += $(SOURCE:.c=.o) 33 | OBJECTS += $(RESOURCES:.rc=.res) 34 | 35 | %.res: %.rc 36 | $(WINDRES) -i $< -o $@ -O coff 37 | 38 | $(TARGET): $(OBJECTS) rsrc.res 39 | $(CC) -o $@ $^ -lgdi32 -luser32 -Wl,--subsystem=windows 40 | 41 | include $(wildcard .*.d) 42 | 43 | clean: 44 | rm -f $(OBJECTS) $(TARGET) .*.d 45 | 46 | install: 47 | 48 | uninstall: 49 | 50 | ISO = winemine.iso 51 | 52 | cdrom: 53 | genisoimage -r -J -input-charset utf-8 -o $(ISO) $(TARGET) 54 | 55 | -------------------------------------------------------------------------------- /programs/winemine/Nl.rc: -------------------------------------------------------------------------------- 1 | /* 2 | * WineMine (Dutch resources) 3 | * 4 | * Copyright 2003 Hans Leidekker 5 | * 6 | * This library is free software; you can redistribute it and/or 7 | * modify it under the terms of the GNU Lesser General Public 8 | * License as published by the Free Software Foundation; either 9 | * version 2.1 of the License, or (at your option) any later version. 10 | * 11 | * This library is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 14 | * Lesser General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU Lesser General Public 17 | * License along with this library; if not, write to the Free Software 18 | * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA 19 | */ 20 | 21 | LANGUAGE LANG_DUTCH, SUBLANG_NEUTRAL 22 | 23 | STRINGTABLE { 24 | IDS_APPNAME, "WineMine" 25 | IDS_NOBODY, "Nobody" 26 | IDS_ABOUT, "Copyright 2000 Joshua Thielen" 27 | } 28 | 29 | MENU_WINEMINE MENU DISCARDABLE 30 | { 31 | POPUP "&Opties" { 32 | MENUITEM "&Nieuw spel\tF2", IDM_NEW 33 | MENUITEM SEPARATOR 34 | MENUITEM "&Markeer vraag", IDM_MARKQ 35 | MENUITEM SEPARATOR 36 | MENUITEM "&Beginner", IDM_BEGINNER 37 | MENUITEM "&Gevorderde", IDM_ADVANCED 38 | MENUITEM "&Expert", IDM_EXPERT 39 | MENUITEM "Aa&ngepast spel", IDM_CUSTOM 40 | MENUITEM SEPARATOR 41 | MENUITEM "&Afsluiten\tAlt+X", IDM_EXIT 42 | } 43 | POPUP "&Info" { 44 | MENUITEM "&Snelste tijden", IDM_TIMES 45 | MENUITEM "&Info", IDM_ABOUT 46 | } 47 | } 48 | 49 | DLG_TIMES DIALOG DISCARDABLE 0, 0, 160, 80 50 | STYLE DS_MODALFRAME | DS_3DLOOK | 51 | WS_VISIBLE | WS_CAPTION | WS_SYSMENU | WS_POPUP 52 | CAPTION "Snelste tijden" 53 | { 54 | GROUPBOX "Snelste tijden", IDIGNORE, 10, 10, 140, 45 55 | LTEXT "Beginner", IDIGNORE, 20, 20, 40, 8 56 | LTEXT "Gevorderde", IDIGNORE, 20, 30, 40, 8 57 | LTEXT "Expert", IDIGNORE, 20, 40, 40, 8 58 | LTEXT "999", IDC_TIME1, 70, 20, 15, 8 59 | LTEXT "999", IDC_TIME2, 70, 30, 15, 8 60 | LTEXT "999", IDC_TIME3, 70, 40, 15, 8 61 | LTEXT "", IDC_NAME1, 90, 20, 55, 8 62 | LTEXT "", IDC_NAME2, 90, 30, 55, 8 63 | LTEXT "", IDC_NAME3, 90, 40, 55, 8 64 | DEFPUSHBUTTON "OK", IDOK, 55, 60, 50, 15 65 | } 66 | 67 | DLG_CONGRATS DIALOG DISCARDABLE 0, 0, 160, 60 68 | STYLE DS_MODALFRAME | DS_3DLOOK | 69 | WS_VISIBLE | WS_CAPTION | WS_SYSMENU | WS_POPUP 70 | CAPTION "Gefeliciteerd!" 71 | { 72 | LTEXT "Voer uw naam in", IDIGNORE, 10, 10, 150, 10 73 | EDITTEXT IDC_EDITNAME, 25, 20, 110, 12 74 | DEFPUSHBUTTON "OK", IDOK, 60, 40, 40, 15 75 | } 76 | 77 | DLG_CUSTOM DIALOG DISCARDABLE 0, 0, 100, 100 78 | STYLE DS_MODALFRAME | DS_3DLOOK | 79 | WS_VISIBLE | WS_CAPTION | WS_SYSMENU | WS_POPUP 80 | CAPTION "Aangepast spel" 81 | { 82 | LTEXT "Rijen", IDIGNORE, 5, 5, 30, 10 83 | LTEXT "Kolommen", IDIGNORE, 5, 35, 30, 10 84 | LTEXT "Mijnen", IDIGNORE, 5, 65, 30, 10 85 | EDITTEXT IDC_EDITROWS, 5, 15, 20, 12, ES_NUMBER 86 | EDITTEXT IDC_EDITCOLS, 5, 45, 20, 12, ES_NUMBER 87 | EDITTEXT IDC_EDITMINES, 5, 75, 20, 12, ES_NUMBER 88 | DEFPUSHBUTTON "OK", IDOK, 40, 30, 50, 15 89 | PUSHBUTTON "Annuleren", IDCANCEL, 40, 50, 50, 15 90 | } 91 | -------------------------------------------------------------------------------- /programs/winemine/No.rc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mikemccormack/ring3k/21dbdbb0eba96960f3f1da314b25a4f731719576/programs/winemine/No.rc -------------------------------------------------------------------------------- /programs/winemine/Pl.rc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mikemccormack/ring3k/21dbdbb0eba96960f3f1da314b25a4f731719576/programs/winemine/Pl.rc -------------------------------------------------------------------------------- /programs/winemine/Pt.rc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mikemccormack/ring3k/21dbdbb0eba96960f3f1da314b25a4f731719576/programs/winemine/Pt.rc -------------------------------------------------------------------------------- /programs/winemine/README: -------------------------------------------------------------------------------- 1 | WineMine README 2 | 3 | WineMine, copyright March 2000, Joshua Thielen 4 | WineMine is distributed under the terms of the LGPL. 5 | 6 | 7 | This is minesweeper for wine... 8 | Enjoy. I wrote it because it rhymes ;). 9 | 10 | KNOWN BUGS: 11 | No help file. 12 | 13 | Starting a new game causes the window to drop one pixel (Peter Hunnisett) 14 | I don't know if it's a window manager problem (KDE) 15 | 16 | UNKNOWN BUGS: 17 | ??? 18 | -------------------------------------------------------------------------------- /programs/winemine/Ro.rc: -------------------------------------------------------------------------------- 1 | /* 2 | * WineMine 3 | * Romanian Language Support 4 | * 5 | * Copyright 2007 Michael Stefaniuc 6 | * 7 | * This library is free software; you can redistribute it and/or 8 | * modify it under the terms of the GNU Lesser General Public 9 | * License as published by the Free Software Foundation; either 10 | * version 2.1 of the License, or (at your option) any later version. 11 | * 12 | * This library is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 15 | * Lesser General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU Lesser General Public 18 | * License along with this library; if not, write to the Free Software 19 | * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA 20 | */ 21 | 22 | LANGUAGE LANG_ROMANIAN, SUBLANG_NEUTRAL 23 | 24 | #pragma code_page(65001) 25 | 26 | STRINGTABLE { 27 | IDS_APPNAME, "WineMine" 28 | IDS_NOBODY, "Nimeni" 29 | IDS_ABOUT, "Copyright 2000 Joshua Thielen" 30 | } 31 | 32 | MENU_WINEMINE MENU DISCARDABLE 33 | { 34 | POPUP "&Opţiuni" { 35 | MENUITEM "&Nou\tF2", IDM_NEW 36 | MENUITEM SEPARATOR 37 | MENUITEM "&Mark Question", IDM_MARKQ 38 | MENUITEM SEPARATOR 39 | MENUITEM "&Începător", IDM_BEGINNER 40 | MENUITEM "&Avansat", IDM_ADVANCED 41 | MENUITEM "&Expert", IDM_EXPERT 42 | MENUITEM "&Personalizat", IDM_CUSTOM 43 | MENUITEM SEPARATOR 44 | MENUITEM "&Ieşire\tAlt+X", IDM_EXIT 45 | } 46 | POPUP "&Informaţii" { 47 | MENUITEM "&Scoruri maxime", IDM_TIMES 48 | MENUITEM "&Despre", IDM_ABOUT 49 | } 50 | } 51 | 52 | DLG_TIMES DIALOG DISCARDABLE 0, 0, 160, 80 53 | STYLE DS_MODALFRAME | DS_3DLOOK | 54 | WS_VISIBLE | WS_CAPTION | WS_SYSMENU | WS_POPUP 55 | CAPTION "Scoruri maxime" 56 | { 57 | GROUPBOX "Scoruri maxime", IDIGNORE, 10, 10, 140, 45 58 | LTEXT "&Începător", IDIGNORE, 20, 20, 40, 8 59 | LTEXT "Avansat", IDIGNORE, 20, 30, 40, 8 60 | LTEXT "Expert", IDIGNORE, 20, 40, 40, 8 61 | LTEXT "999", IDC_TIME1, 70, 20, 15, 8 62 | LTEXT "999", IDC_TIME2, 70, 30, 15, 8 63 | LTEXT "999", IDC_TIME3, 70, 40, 15, 8 64 | LTEXT "", IDC_NAME1, 90, 20, 55, 8 65 | LTEXT "", IDC_NAME2, 90, 30, 55, 8 66 | LTEXT "", IDC_NAME3, 90, 40, 55, 8 67 | DEFPUSHBUTTON "OK", IDOK, 55, 60, 50, 15 68 | } 69 | 70 | DLG_CONGRATS DIALOG DISCARDABLE 0, 0, 160, 60 71 | STYLE DS_MODALFRAME | DS_3DLOOK | 72 | WS_VISIBLE | WS_CAPTION | WS_SYSMENU | WS_POPUP 73 | CAPTION "Felicitări!" 74 | { 75 | LTEXT "Scrieţi-vă numele", IDIGNORE, 10, 10, 150, 10 76 | EDITTEXT IDC_EDITNAME, 25, 20, 110, 12 77 | DEFPUSHBUTTON "OK", IDOK, 60, 40, 40, 15 78 | } 79 | 80 | DLG_CUSTOM DIALOG DISCARDABLE 0, 0, 100, 100 81 | STYLE DS_MODALFRAME | DS_3DLOOK | 82 | WS_VISIBLE | WS_CAPTION | WS_SYSMENU | WS_POPUP 83 | CAPTION "Joc personalizat" 84 | { 85 | LTEXT "Linii", IDIGNORE, 5, 5, 30, 10 86 | LTEXT "Coloane", IDIGNORE, 5, 35, 30, 10 87 | LTEXT "Mine", IDIGNORE, 5, 65, 30, 10 88 | EDITTEXT IDC_EDITROWS, 5, 15, 20, 12, ES_NUMBER 89 | EDITTEXT IDC_EDITCOLS, 5, 45, 20, 12, ES_NUMBER 90 | EDITTEXT IDC_EDITMINES, 5, 75, 20, 12, ES_NUMBER 91 | DEFPUSHBUTTON "OK", IDOK, 40, 30, 50, 15 92 | PUSHBUTTON "Renunţă", IDCANCEL, 40, 50, 50, 15 93 | } 94 | 95 | #pragma code_page(default) 96 | -------------------------------------------------------------------------------- /programs/winemine/Ru.rc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mikemccormack/ring3k/21dbdbb0eba96960f3f1da314b25a4f731719576/programs/winemine/Ru.rc -------------------------------------------------------------------------------- /programs/winemine/Si.rc: -------------------------------------------------------------------------------- 1 | /* 2 | * WineMine 3 | * Slovenian Language Support 4 | * 5 | * Copyright 2003, 2008 Rok Mandeljc 6 | * 7 | * This library is free software; you can redistribute it and/or 8 | * modify it under the terms of the GNU Lesser General Public 9 | * License as published by the Free Software Foundation; either 10 | * version 2.1 of the License, or (at your option) any later version. 11 | * 12 | * This library is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 15 | * Lesser General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU Lesser General Public 18 | * License along with this library; if not, write to the Free Software 19 | * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA 20 | */ 21 | 22 | #pragma code_page(65001) 23 | 24 | LANGUAGE LANG_SLOVENIAN, SUBLANG_DEFAULT 25 | 26 | STRINGTABLE { 27 | IDS_APPNAME, "WineMine" 28 | IDS_NOBODY, "Nihče" 29 | IDS_ABOUT, "Copyright 2000 Joshua Thielen" 30 | } 31 | 32 | MENU_WINEMINE MENU DISCARDABLE 33 | { 34 | POPUP "&Možnosti" { 35 | MENUITEM "&Nova igra\tF2", IDM_NEW 36 | MENUITEM SEPARATOR 37 | MENUITEM "&Vprašaji", IDM_MARKQ 38 | MENUITEM SEPARATOR 39 | MENUITEM "&Začetnik", IDM_BEGINNER 40 | MENUITEM "&Napreden", IDM_ADVANCED 41 | MENUITEM "&Strokovnjak", IDM_EXPERT 42 | MENUITEM "&Poljubno", IDM_CUSTOM 43 | MENUITEM SEPARATOR 44 | MENUITEM "Iz&hod\tAlt+X", IDM_EXIT 45 | } 46 | POPUP "&Info" { 47 | MENUITEM "&Najboljši časi", IDM_TIMES 48 | MENUITEM "&O programu", IDM_ABOUT 49 | } 50 | } 51 | 52 | DLG_TIMES DIALOG DISCARDABLE 0, 0, 160, 80 53 | STYLE DS_MODALFRAME | DS_3DLOOK | 54 | WS_VISIBLE | WS_CAPTION | WS_SYSMENU | WS_POPUP 55 | CAPTION "Najboljši časi" 56 | { 57 | GROUPBOX "Najboljši časi", IDIGNORE, 10, 10, 140, 45 58 | LTEXT "Začetnik", IDIGNORE, 20, 20, 40, 8 59 | LTEXT "Napreden", IDIGNORE, 20, 30, 40, 8 60 | LTEXT "Strokovnjak", IDIGNORE, 20, 40, 40, 8 61 | LTEXT "999", IDC_TIME1, 70, 20, 15, 8 62 | LTEXT "999", IDC_TIME2, 70, 30, 15, 8 63 | LTEXT "999", IDC_TIME3, 70, 40, 15, 8 64 | LTEXT "", IDC_NAME1, 90, 20, 55, 8 65 | LTEXT "", IDC_NAME2, 90, 30, 55, 8 66 | LTEXT "", IDC_NAME3, 90, 40, 55, 8 67 | DEFPUSHBUTTON "V redu", IDOK, 55, 60, 50, 15 68 | } 69 | 70 | DLG_CONGRATS DIALOG DISCARDABLE 0, 0, 160, 60 71 | STYLE DS_MODALFRAME | DS_3DLOOK | 72 | WS_VISIBLE | WS_CAPTION | WS_SYSMENU | WS_POPUP 73 | CAPTION "Čestitamo!" 74 | { 75 | LTEXT "Vnesite svoje ime", IDIGNORE, 10, 10, 150, 10 76 | EDITTEXT IDC_EDITNAME, 25, 20, 110, 12 77 | DEFPUSHBUTTON "V redu", IDOK, 60, 40, 40, 15 78 | } 79 | 80 | DLG_CUSTOM DIALOG DISCARDABLE 0, 0, 100, 100 81 | STYLE DS_MODALFRAME | DS_3DLOOK | 82 | WS_VISIBLE | WS_CAPTION | WS_SYSMENU | WS_POPUP 83 | CAPTION "Poljubna igra" 84 | { 85 | LTEXT "Vrstice", IDIGNORE, 5, 5, 30, 10 86 | LTEXT "Stolpci", IDIGNORE, 5, 35, 30, 10 87 | LTEXT "Mine", IDIGNORE, 5, 65, 30, 10 88 | EDITTEXT IDC_EDITROWS, 5, 15, 20, 12, ES_NUMBER 89 | EDITTEXT IDC_EDITCOLS, 5, 45, 20, 12, ES_NUMBER 90 | EDITTEXT IDC_EDITMINES, 5, 75, 20, 12, ES_NUMBER 91 | DEFPUSHBUTTON "V redu", IDOK, 40, 30, 50, 15 92 | PUSHBUTTON "Prekliči", IDCANCEL, 40, 50, 50, 15 93 | } 94 | 95 | #pragma code_page(default) 96 | -------------------------------------------------------------------------------- /programs/winemine/Tr.rc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mikemccormack/ring3k/21dbdbb0eba96960f3f1da314b25a4f731719576/programs/winemine/Tr.rc -------------------------------------------------------------------------------- /programs/winemine/faces.bmp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mikemccormack/ring3k/21dbdbb0eba96960f3f1da314b25a4f731719576/programs/winemine/faces.bmp -------------------------------------------------------------------------------- /programs/winemine/leds.bmp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mikemccormack/ring3k/21dbdbb0eba96960f3f1da314b25a4f731719576/programs/winemine/leds.bmp -------------------------------------------------------------------------------- /programs/winemine/mines.bmp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mikemccormack/ring3k/21dbdbb0eba96960f3f1da314b25a4f731719576/programs/winemine/mines.bmp -------------------------------------------------------------------------------- /programs/winemine/resource.h: -------------------------------------------------------------------------------- 1 | /* 2 | * WineMine (resource.h) 3 | * 4 | * Copyright 2000 Joshua Thielen 5 | * 6 | * This library is free software; you can redistribute it and/or 7 | * modify it under the terms of the GNU Lesser General Public 8 | * License as published by the Free Software Foundation; either 9 | * version 2.1 of the License, or (at your option) any later version. 10 | * 11 | * This library is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 14 | * Lesser General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU Lesser General Public 17 | * License along with this library; if not, write to the Free Software 18 | * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA 19 | */ 20 | 21 | 22 | #define ID_TIMER 1000 23 | 24 | /* menu defines */ 25 | #define IDM_NEW 1001 26 | #define IDM_EXIT 1002 27 | #define IDM_TIMES 1003 28 | #define IDM_ABOUT 1004 29 | #define IDM_BEGINNER 1005 30 | #define IDM_ADVANCED 1006 31 | #define IDM_EXPERT 1007 32 | #define IDM_CUSTOM 1008 33 | #define IDM_MARKQ 1009 34 | 35 | #define IDC_TIME1 1011 36 | #define IDC_TIME2 1012 37 | #define IDC_TIME3 1013 38 | #define IDC_NAME1 1014 39 | #define IDC_NAME2 1015 40 | #define IDC_NAME3 1016 41 | 42 | #define IDC_EDITNAME 1021 43 | 44 | #define IDC_EDITCOLS 1031 45 | #define IDC_EDITROWS 1032 46 | #define IDC_EDITMINES 1033 47 | 48 | #define IDS_APPNAME 1101 49 | #define IDS_NOBODY 1102 50 | #define IDS_ABOUT 1103 51 | 52 | #define IDA_WINEMINE 1201 53 | -------------------------------------------------------------------------------- /programs/winemine/rsrc.rc: -------------------------------------------------------------------------------- 1 | /* 2 | * WineMine (rsrc.rc) 3 | * 4 | * Copyright 2000 Joshua Thielen 5 | * Copyright 2003 Marcelo Duarte 6 | * 7 | * This library is free software; you can redistribute it and/or 8 | * modify it under the terms of the GNU Lesser General Public 9 | * License as published by the Free Software Foundation; either 10 | * version 2.1 of the License, or (at your option) any later version. 11 | * 12 | * This library is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 15 | * Lesser General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU Lesser General Public 18 | * License along with this library; if not, write to the Free Software 19 | * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA 20 | */ 21 | 22 | #include 23 | #include 24 | 25 | #include "resource.h" 26 | 27 | #include "En.rc" 28 | 29 | LANGUAGE LANG_NEUTRAL,SUBLANG_NEUTRAL 30 | 31 | IDA_WINEMINE ACCELERATORS DISCARDABLE 32 | { 33 | VK_F2, IDM_NEW, VIRTKEY, NOINVERT 34 | "X", IDM_EXIT, VIRTKEY, ALT, NOINVERT 35 | } 36 | 37 | /* @makedep: winemine.ico */ 38 | WINEMINE ICON MOVEABLE winemine.ico 39 | 40 | /* @makedep: faces.bmp */ 41 | FACES BITMAP MOVEABLE faces.bmp 42 | 43 | /* @makedep: leds.bmp */ 44 | LEDS BITMAP MOVEABLE leds.bmp 45 | 46 | /* @makedep: mines.bmp */ 47 | MINES BITMAP MOVEABLE mines.bmp 48 | -------------------------------------------------------------------------------- /programs/winemine/winemine.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mikemccormack/ring3k/21dbdbb0eba96960f3f1da314b25a4f731719576/programs/winemine/winemine.ico -------------------------------------------------------------------------------- /programs/winlogon/.gitignore: -------------------------------------------------------------------------------- 1 | .*.d 2 | *.exe 3 | *.dll 4 | -------------------------------------------------------------------------------- /programs/winlogon/Makefile.in: -------------------------------------------------------------------------------- 1 | # 2 | # Makefile for winlogon replacement 3 | # Copyright 2008-2009 Mike McCormack 4 | # 5 | 6 | srcdir = @srcdir@ 7 | VPATH = @srcdir@ 8 | 9 | DEPFLAG = -Wp,-MD,.$@.d 10 | CC = @MINGW32CC@ 11 | STRIP = @MINGW32STRIP@ 12 | CFLAGS = -Wall -O2 $(DEPFLAG) 13 | AS = @MINGW32AS@ 14 | AR = @MINGW32AR@ 15 | RANLIB = @MINGW32RANLIB@ 16 | WINDRES = @MINGW32WINDRES@ 17 | 18 | INSTALL = @INSTALL@ 19 | INSTALL_PROGRAM = @INSTALL_PROGRAM@ 20 | INSTALL_DATA = @INSTALL_DATA@ 21 | prefix = @prefix@ 22 | bindir = ${prefix}/bin 23 | datadir = ${prefix}/data 24 | 25 | SOURCE = \ 26 | winlogon.c 27 | 28 | TARGET = winlogon.exe 29 | 30 | OBJECTS = $(SOURCE:.c=.o) 31 | 32 | .PHONY: all clean 33 | 34 | all: $(SOURCE:.c=.exe) 35 | 36 | -include $(OBJECTS:%=$(dir %).$(notdir %).d) 37 | 38 | $(TARGET): $(OBJECTS) 39 | $(CC) $(CFLAGS) -o $@ $< -lgdi32 -luser32 -Wl,--subsystem=windows 40 | 41 | clean: 42 | rm -f *.o *.dll *.exe .*.d 43 | 44 | install: $(TARGET) 45 | mkdir -p $(DESTDIR)$(datadir) 46 | $(INSTALL_DATA) $(INSTALL_FLAGS) $< $(DESTDIR)$(datadir) 47 | -------------------------------------------------------------------------------- /regedit/.gitignore: -------------------------------------------------------------------------------- 1 | Makefile.qmake 2 | regedit 3 | *.o 4 | moc_*.cpp 5 | -------------------------------------------------------------------------------- /regedit/Makefile.in: -------------------------------------------------------------------------------- 1 | 2 | QT_QMAKE = @QT_QMAKE@ 3 | MAKE = make 4 | RM = rm -f 5 | 6 | .PHONY: all clean install uninstall 7 | 8 | all: Makefile.qmake 9 | if test -f $< ;then $(MAKE) -f $< ; fi 10 | 11 | clean: Makefile.qmake 12 | if test -f $< ;then $(MAKE) -f $< $@; fi 13 | 14 | Makefile.qmake: regedit.pro 15 | $(QT_QMAKE) -makefile -o $@ $< 16 | 17 | install: 18 | uninstall: 19 | 20 | -------------------------------------------------------------------------------- /regedit/main.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Registry editor 3 | * 4 | * Copyright 2009 Mike McCormack 5 | * 6 | * This library is free software; you can redistribute it and/or 7 | * modify it under the terms of the GNU Lesser General Public 8 | * License as published by the Free Software Foundation; either 9 | * version 2.1 of the License, or (at your option) any later version. 10 | * 11 | * This library is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 14 | * Lesser General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU Lesser General Public 17 | * License along with this library; if not, write to the Free Software 18 | * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA 19 | */ 20 | 21 | #include 22 | #include 23 | #include 24 | #include 25 | #include 26 | #include 27 | #include 28 | #include 29 | #include "registryitem.h" 30 | #include "registrymodel.h" 31 | #include "registryvalue.h" 32 | #include "registryeditor.h" 33 | #include "ntreg.h" 34 | 35 | int main( int argc, char **argv ) 36 | { 37 | QApplication app(argc, argv); 38 | 39 | if (argc < 2) 40 | { 41 | fprintf(stderr, "Need the name of registry hive\n"); 42 | return 1; 43 | } 44 | 45 | struct hive *hive = 0; 46 | const char *filename = argv[1]; 47 | 48 | hive = open_hive(filename, HMODE_RO); 49 | if (!hive) 50 | { 51 | fprintf(stderr, "Failed to open hive\n"); 52 | return 1; 53 | } 54 | 55 | RegistryEditor *window = new RegistryEditor( hive ); 56 | window->show(); 57 | 58 | return app.exec(); 59 | } 60 | -------------------------------------------------------------------------------- /regedit/regedit.pro: -------------------------------------------------------------------------------- 1 | 2 | HEADERS += \ 3 | registryeditor.h \ 4 | registryitem.h \ 5 | registrymodel.h \ 6 | registrytreeview.h \ 7 | registryvalue.h 8 | 9 | SOURCES += \ 10 | main.cpp \ 11 | registryeditor.cpp \ 12 | registryitem.cpp \ 13 | registrymodel.cpp \ 14 | registrytreeview.cpp \ 15 | registryvalue.cpp 16 | 17 | INCLUDEPATH += ../libntreg 18 | 19 | LIBS += ../libntreg/libntreg.a 20 | 21 | CONFIG += qt 22 | 23 | -------------------------------------------------------------------------------- /regedit/registryeditor.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Registry editor 3 | * 4 | * Copyright 2009 Mike McCormack 5 | * 6 | * This library is free software; you can redistribute it and/or 7 | * modify it under the terms of the GNU Lesser General Public 8 | * License as published by the Free Software Foundation; either 9 | * version 2.1 of the License, or (at your option) any later version. 10 | * 11 | * This library is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 14 | * Lesser General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU Lesser General Public 17 | * License along with this library; if not, write to the Free Software 18 | * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA 19 | */ 20 | 21 | #include 22 | #include 23 | #include 24 | #include 25 | #include 26 | #include 27 | #include "registryeditor.h" 28 | 29 | RegistryEditor::RegistryEditor( struct hive* h ) : 30 | hive( h ) 31 | { 32 | QString kn( "\\" ); 33 | 34 | rootItem = new RegistryItem( hive, NULL, kn ); 35 | keyModel = new RegistryItemModel( rootItem, hive ); 36 | keylist = new RegistryTreeView; 37 | 38 | keylist->setModel( keyModel ); 39 | keylist->setWindowTitle(QObject::tr("Registry editor")); 40 | 41 | valueModel = new RegistryValueModel; 42 | 43 | valuelist = new QListView; 44 | valuelist->setModel( valueModel ); 45 | 46 | layout = new QHBoxLayout; 47 | 48 | bool r = connect( keylist, SIGNAL(onSelectionChanged(const QModelIndex&, const QModelIndex&)), 49 | this, SLOT(key_changed(const QModelIndex&, const QModelIndex&))); 50 | if (!r) 51 | throw; 52 | 53 | layout->addWidget( keylist ); 54 | layout->addWidget( valuelist ); 55 | 56 | setLayout( layout ); 57 | } 58 | 59 | void RegistryEditor::key_changed( const QModelIndex ¤t, const QModelIndex & /*previous*/ ) 60 | { 61 | fprintf(stderr,"key_changed %p\n", ¤t); 62 | RegistryItem *item = static_cast( current.internalPointer() ); 63 | QString path = item->getPath(); 64 | char *utf8_path = path.toUtf8().data(); 65 | fprintf(stderr, "path = %s\n", utf8_path); 66 | } 67 | -------------------------------------------------------------------------------- /regedit/registryeditor.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Registry editor 3 | * 4 | * Copyright 2009 Mike McCormack 5 | * 6 | * This library is free software; you can redistribute it and/or 7 | * modify it under the terms of the GNU Lesser General Public 8 | * License as published by the Free Software Foundation; either 9 | * version 2.1 of the License, or (at your option) any later version. 10 | * 11 | * This library is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 14 | * Lesser General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU Lesser General Public 17 | * License along with this library; if not, write to the Free Software 18 | * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA 19 | */ 20 | 21 | #ifndef __REGEDIT_REGISTRYEDITOR_H__ 22 | #define __REGEDIT_REGISTRYEDITOR_H__ 23 | 24 | #include 25 | #include 26 | #include 27 | #include 28 | #include 29 | #include "registryitem.h" 30 | #include "registrymodel.h" 31 | #include "registryvalue.h" 32 | #include "registrytreeview.h" 33 | #include "ntreg.h" 34 | 35 | class RegistryEditor : public QWidget 36 | { 37 | Q_OBJECT; 38 | private: 39 | struct hive *hive; 40 | RegistryItem *rootItem; 41 | RegistryItemModel *keyModel; 42 | RegistryTreeView *keylist; 43 | RegistryValueModel *valueModel; 44 | QListView *valuelist; 45 | QHBoxLayout *layout; 46 | public: 47 | RegistryEditor( struct hive * h ); 48 | protected slots: 49 | void key_changed(const QModelIndex& current, const QModelIndex& prev); 50 | }; 51 | 52 | #endif // __REGEDIT_REGISTRYEDITOR_H__ 53 | -------------------------------------------------------------------------------- /regedit/registryitem.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Registry editor 3 | * 4 | * Copyright 2009 Mike McCormack 5 | * 6 | * This library is free software; you can redistribute it and/or 7 | * modify it under the terms of the GNU Lesser General Public 8 | * License as published by the Free Software Foundation; either 9 | * version 2.1 of the License, or (at your option) any later version. 10 | * 11 | * This library is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 14 | * Lesser General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU Lesser General Public 17 | * License along with this library; if not, write to the Free Software 18 | * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA 19 | */ 20 | 21 | #include 22 | #include 23 | #include 24 | #include 25 | #include 26 | #include 27 | #include 28 | #include 29 | #include "registryitem.h" 30 | #include "ntreg.h" 31 | 32 | RegistryItem::RegistryItem( struct hive *h, RegistryItem* p, const QString& n ) : 33 | hive( h ), 34 | parent( p ), 35 | name( n ), 36 | enumerated( false ) 37 | { 38 | } 39 | 40 | RegistryItem::~RegistryItem() 41 | { 42 | } 43 | 44 | QString RegistryItem::getPath() const 45 | { 46 | QString path; 47 | if (parent) 48 | { 49 | path = parent->getPath(); 50 | path.append( name ); 51 | path.append( "\\" ); 52 | } 53 | else 54 | { 55 | path = name; 56 | } 57 | return path; 58 | } 59 | 60 | RegistryItem* RegistryItem::getParent() 61 | { 62 | return parent; 63 | } 64 | 65 | void RegistryItem::enumerateChildren() 66 | { 67 | if (enumerated) 68 | return; 69 | 70 | struct ex_data key; 71 | memset( &key, 0, sizeof key ); 72 | QString path = getPath(); 73 | char *utf8_path = strdup(path.toUtf8().data()); 74 | int i = 0; 75 | while (1) 76 | { 77 | int r = nk_get_subkey( hive, utf8_path, 0, i, &key ); 78 | if (r < 0) 79 | break; 80 | QString kn( key.name ); 81 | RegistryItem* item = new RegistryItem( hive, this, kn ); 82 | //free( key.name ); 83 | subkeys.append( item ); 84 | i++; 85 | } 86 | free( utf8_path ); 87 | enumerated = true; 88 | } 89 | 90 | 91 | RegistryItem* RegistryItem::getChild( int n ) 92 | { 93 | enumerateChildren(); 94 | return subkeys.at( n ); 95 | } 96 | 97 | int RegistryItem::getSubkeyCount() 98 | { 99 | enumerateChildren(); 100 | return subkeys.count(); 101 | } 102 | 103 | const QString& RegistryItem::getName() const 104 | { 105 | return name; 106 | } 107 | 108 | int RegistryItem::getNumber() const 109 | { 110 | if (!parent) 111 | return 0; 112 | return parent->subkeys.lastIndexOf( const_cast(this) ); 113 | } 114 | 115 | -------------------------------------------------------------------------------- /regedit/registryitem.h: -------------------------------------------------------------------------------- 1 | 2 | #ifndef __REGEDIT_REGISTRYITEM_H__ 3 | #define __REGEDIT_REGISTRYITEM_H__ 4 | 5 | #include 6 | #include 7 | #include 8 | #include "ntreg.h" 9 | 10 | class RegistryItem 11 | { 12 | struct hive *hive; 13 | RegistryItem* parent; 14 | QString name; 15 | bool enumerated; 16 | QList subkeys; 17 | public: 18 | RegistryItem( struct hive *h, RegistryItem* p, const QString& n ); 19 | ~RegistryItem(); 20 | QString getPath() const; 21 | RegistryItem* getParent(); 22 | RegistryItem* getChild( int n ); 23 | int getSubkeyCount(); 24 | const QString& getName() const; 25 | int getNumber() const; 26 | protected: 27 | void enumerateChildren(); 28 | }; 29 | 30 | #endif // __REGEDIT_REGISTRYITEM_H__ 31 | -------------------------------------------------------------------------------- /regedit/registrymodel.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Registry editor 3 | * 4 | * Copyright 2009 Mike McCormack 5 | * 6 | * This library is free software; you can redistribute it and/or 7 | * modify it under the terms of the GNU Lesser General Public 8 | * License as published by the Free Software Foundation; either 9 | * version 2.1 of the License, or (at your option) any later version. 10 | * 11 | * This library is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 14 | * Lesser General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU Lesser General Public 17 | * License along with this library; if not, write to the Free Software 18 | * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA 19 | */ 20 | 21 | #include 22 | #include 23 | #include 24 | #include 25 | #include "registryitem.h" 26 | #include "registrymodel.h" 27 | #include "ntreg.h" 28 | 29 | RegistryItemModel::RegistryItemModel(RegistryItem* r, struct hive *h) : 30 | hive( h ), 31 | root( r ) 32 | { 33 | } 34 | 35 | Qt::ItemFlags RegistryItemModel::flags(const QModelIndex &index) const 36 | { 37 | if (!index.isValid()) 38 | return 0; 39 | 40 | return Qt::ItemIsEnabled | Qt::ItemIsSelectable; 41 | } 42 | 43 | QVariant RegistryItemModel::headerData(int /*section*/, Qt::Orientation orientation, int role) const 44 | { 45 | if (orientation == Qt::Horizontal && role == Qt::DisplayRole) 46 | return "registry"; 47 | return QVariant(); 48 | } 49 | 50 | QModelIndex RegistryItemModel::index(int row, int column, const QModelIndex& parent) const 51 | { 52 | if (!hasIndex(row, column, parent)) 53 | return QModelIndex(); 54 | 55 | RegistryItem *parentItem, *item; 56 | if (!parent.isValid()) 57 | parentItem = root; 58 | else 59 | parentItem = static_cast( parent.internalPointer() ); 60 | 61 | item = parentItem->getChild( row ); 62 | 63 | if (!item) return QModelIndex(); 64 | 65 | assert( row == item->getNumber()); 66 | 67 | return createIndex( row, column, item ); 68 | } 69 | 70 | QModelIndex RegistryItemModel::parent(const QModelIndex &index) const 71 | { 72 | if (!index.isValid()) 73 | return QModelIndex(); 74 | RegistryItem* item = static_cast( index.internalPointer() ); 75 | RegistryItem* parent = item->getParent(); 76 | if (parent == root) 77 | return QModelIndex(); 78 | 79 | return createIndex( parent->getNumber(), 0, parent ); 80 | } 81 | 82 | int RegistryItemModel::columnCount(const QModelIndex& parent) const 83 | { 84 | if (!parent.isValid()) 85 | return 1; 86 | 87 | RegistryItem* parentItem = static_cast( parent.internalPointer() ); 88 | if (parentItem->getSubkeyCount()) 89 | return 1; 90 | else 91 | return 0; 92 | } 93 | 94 | int RegistryItemModel::rowCount(const QModelIndex& parent) const 95 | { 96 | if (parent.column()>0) 97 | return 0; 98 | 99 | RegistryItem* parentItem; 100 | if (!parent.isValid()) 101 | parentItem = root; 102 | else 103 | parentItem = static_cast( parent.internalPointer() ); 104 | 105 | return parentItem->getSubkeyCount(); 106 | } 107 | 108 | QVariant RegistryItemModel::data(const QModelIndex& index, int role) const 109 | { 110 | if (!index.isValid()) 111 | return QVariant(); 112 | if (role != Qt::DisplayRole) 113 | return QVariant(); 114 | 115 | RegistryItem* item = static_cast( index.internalPointer() ); 116 | return item->getName(); 117 | } 118 | -------------------------------------------------------------------------------- /regedit/registrymodel.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Registry editor 3 | * 4 | * Copyright 2009 Mike McCormack 5 | * 6 | * This library is free software; you can redistribute it and/or 7 | * modify it under the terms of the GNU Lesser General Public 8 | * License as published by the Free Software Foundation; either 9 | * version 2.1 of the License, or (at your option) any later version. 10 | * 11 | * This library is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 14 | * Lesser General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU Lesser General Public 17 | * License along with this library; if not, write to the Free Software 18 | * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA 19 | */ 20 | 21 | #ifndef __REGEDIT_REGISTRYMODEL_H__ 22 | #define __REGEDIT_REGISTRYMODEL_H__ 23 | 24 | #include 25 | #include 26 | #include "registryitem.h" 27 | #include "ntreg.h" 28 | 29 | class RegistryItemModel : public QAbstractItemModel 30 | { 31 | Q_OBJECT 32 | public: 33 | RegistryItemModel(RegistryItem* root, struct hive *h); 34 | ~RegistryItemModel() {} 35 | virtual Qt::ItemFlags flags(const QModelIndex &index) const; 36 | virtual QModelIndex index(int,int,const QModelIndex&) const; 37 | virtual int rowCount(const QModelIndex& index) const; 38 | virtual int columnCount(const QModelIndex& index) const; 39 | virtual QVariant data(const QModelIndex&, int) const; 40 | virtual QModelIndex parent(const QModelIndex & index) const; 41 | virtual QVariant headerData(int section, Qt::Orientation orientation, int role) const; 42 | private: 43 | struct hive *hive; 44 | RegistryItem *root; 45 | }; 46 | 47 | #endif // __REGEDIT_REGISTRYMODEL_H__ 48 | -------------------------------------------------------------------------------- /regedit/registrytreeview.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Registry editor 3 | * 4 | * Copyright 2009 Mike McCormack 5 | * 6 | * This library is free software; you can redistribute it and/or 7 | * modify it under the terms of the GNU Lesser General Public 8 | * License as published by the Free Software Foundation; either 9 | * version 2.1 of the License, or (at your option) any later version. 10 | * 11 | * This library is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 14 | * Lesser General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU Lesser General Public 17 | * License along with this library; if not, write to the Free Software 18 | * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA 19 | */ 20 | 21 | #include 22 | #include 23 | #include 24 | #include 25 | #include 26 | #include 27 | #include "registryeditor.h" 28 | 29 | void RegistryTreeView::currentChanged( const QModelIndex ¤t, const QModelIndex &previous ) 30 | { 31 | fprintf(stderr, "currentChanged\n"); 32 | onSelectionChanged( current, previous ); 33 | } 34 | 35 | -------------------------------------------------------------------------------- /regedit/registrytreeview.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Registry editor 3 | * 4 | * Copyright 2009 Mike McCormack 5 | * 6 | * This library is free software; you can redistribute it and/or 7 | * modify it under the terms of the GNU Lesser General Public 8 | * License as published by the Free Software Foundation; either 9 | * version 2.1 of the License, or (at your option) any later version. 10 | * 11 | * This library is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 14 | * Lesser General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU Lesser General Public 17 | * License along with this library; if not, write to the Free Software 18 | * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA 19 | */ 20 | 21 | #ifndef __REGEDIT_REGISTRYTREEVIEW_H__ 22 | #define __REGEDIT_REGISTRYTREEVIEW_H__ 23 | 24 | #include 25 | 26 | class RegistryTreeView : public QTreeView 27 | { 28 | Q_OBJECT 29 | public: 30 | void currentChanged ( const QModelIndex & current, const QModelIndex & previous ); 31 | signals: 32 | virtual void onSelectionChanged(const QModelIndex& current, const QModelIndex& prev); 33 | }; 34 | 35 | #endif // __REGEDIT_REGISTRYTREEVIEW_H__ 36 | -------------------------------------------------------------------------------- /regedit/registryvalue.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Registry editor 3 | * 4 | * Copyright 2009 Mike McCormack 5 | * 6 | * This library is free software; you can redistribute it and/or 7 | * modify it under the terms of the GNU Lesser General Public 8 | * License as published by the Free Software Foundation; either 9 | * version 2.1 of the License, or (at your option) any later version. 10 | * 11 | * This library is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 14 | * Lesser General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU Lesser General Public 17 | * License along with this library; if not, write to the Free Software 18 | * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA 19 | */ 20 | 21 | #include 22 | #include 23 | #include 24 | #include 25 | #include 26 | #include 27 | #include 28 | #include 29 | #include "registryitem.h" 30 | #include "registrymodel.h" 31 | #include "registryvalue.h" 32 | #include "ntreg.h" 33 | 34 | RegistryValueModel::RegistryValueModel() 35 | { 36 | } 37 | 38 | Qt::ItemFlags RegistryValueModel::flags(const QModelIndex &index) const 39 | { 40 | if (!index.isValid()) 41 | return 0; 42 | 43 | return Qt::ItemIsEnabled | Qt::ItemIsSelectable; 44 | } 45 | 46 | QVariant RegistryValueModel::headerData(int /*section*/, Qt::Orientation orientation, int role) const 47 | { 48 | if (orientation == Qt::Horizontal && role == Qt::DisplayRole) 49 | return "values"; 50 | return QVariant(); 51 | } 52 | 53 | QModelIndex RegistryValueModel::index(int row, int column, const QModelIndex& parent) const 54 | { 55 | if (!parent.isValid() && row == 0 && column == 0) 56 | return createIndex( row, column, NULL ); 57 | return QModelIndex(); 58 | } 59 | 60 | QModelIndex RegistryValueModel::parent(const QModelIndex &/*index*/) const 61 | { 62 | return QModelIndex(); 63 | } 64 | 65 | QVariant RegistryValueModel::data(const QModelIndex& index, int role) const 66 | { 67 | if (index.column() != 0) 68 | return QVariant(); 69 | if (role != Qt::DisplayRole) 70 | return QVariant(); 71 | if (index.row() == 0) 72 | return "@"; 73 | return QVariant(); 74 | } 75 | 76 | int RegistryValueModel::columnCount(const QModelIndex& parent) const 77 | { 78 | if (!parent.isValid()) 79 | return 1; 80 | else 81 | return 0; 82 | } 83 | 84 | int RegistryValueModel::rowCount(const QModelIndex& parent) const 85 | { 86 | if (!parent.isValid()) 87 | return 1; 88 | else 89 | return 0; 90 | } 91 | 92 | -------------------------------------------------------------------------------- /regedit/registryvalue.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Registry editor 3 | * 4 | * Copyright 2009 Mike McCormack 5 | * 6 | * This library is free software; you can redistribute it and/or 7 | * modify it under the terms of the GNU Lesser General Public 8 | * License as published by the Free Software Foundation; either 9 | * version 2.1 of the License, or (at your option) any later version. 10 | * 11 | * This library is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 14 | * Lesser General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU Lesser General Public 17 | * License along with this library; if not, write to the Free Software 18 | * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA 19 | */ 20 | 21 | #ifndef __REGEDIT_REGISTRYVALUE_H__ 22 | #define __REGEDIT_REGISTRYVALUE_H__ 23 | 24 | #include 25 | 26 | class RegistryValueModel : public QAbstractItemModel 27 | { 28 | Q_OBJECT 29 | public: 30 | RegistryValueModel(); 31 | virtual Qt::ItemFlags flags(const QModelIndex &index) const; 32 | virtual QModelIndex index(int,int,const QModelIndex&) const; 33 | virtual int rowCount(const QModelIndex& index) const; 34 | virtual int columnCount(const QModelIndex& index) const; 35 | virtual QVariant data(const QModelIndex&, int) const; 36 | virtual QModelIndex parent(const QModelIndex & index) const; 37 | virtual QVariant headerData(int section, Qt::Orientation orientation, int role) const; 38 | }; 39 | 40 | #endif // __REGEDIT_REGISTRYVALUE_H__ 41 | -------------------------------------------------------------------------------- /ring3k.in: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # 3 | # ring3k - a user mode kernel for windows executables 4 | # 5 | # Copyright 2007-2009 (C) Mike McCormack 6 | # 7 | # ring3k Launch script 8 | # 9 | # Checks that the c: drive directory is present 10 | # then launches the kernel binary 11 | 12 | 13 | # from Wine's launch script 14 | appdir="" 15 | case "$0" in 16 | */*) 17 | # $0 contains a path, use it 18 | appdir=`dirname "$0"` 19 | ;; 20 | *) 21 | # no directory in $0, search in PATH 22 | saved_ifs=$IFS 23 | IFS=: 24 | for d in $PATH 25 | do 26 | IFS=$saved_ifs 27 | if [ -x "$d/$0" ] 28 | then 29 | appdir="$d" 30 | break 31 | fi 32 | done 33 | ;; 34 | esac 35 | 36 | # find the kernel 37 | kernel="$appdir/ring3k-bin" 38 | if test \! -x "$kernel" 39 | then 40 | kernel="$appdir/kernel/ring3k-bin" 41 | if test \! -x "$appdir" 42 | then 43 | echo "ring3k-bin not found in $appdir" 44 | exit 1 45 | fi 46 | fi 47 | 48 | # check for a c: link 49 | if test \! -d "drive" 50 | then 51 | extract="$appdir/ring3k-setup" 52 | if test -r "$extract" 53 | then 54 | . "$extract" 55 | else 56 | echo "c: not present and ring3k-setup script not found" 57 | exit 2 58 | fi 59 | fi 60 | 61 | # update minitris when it changes to help testing ... 62 | #winlogon_replacement="programs/minitris/minitris.exe" 63 | #winlogon_replacement="programs/winemine/winemine.exe" 64 | winlogon_replacement="programs/clock/clock.exe" 65 | if test -f "$winlogon_replacement" 66 | then 67 | echo "Replacing winlogon.exe with $winlogon_replacement" 68 | cp -f "$winlogon_replacement" "drive/winnt/system32/winlogon.exe" 69 | fi 70 | 71 | exec "$kernel" $* 72 | -------------------------------------------------------------------------------- /runtest: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # 3 | # Copyright 2007-2009 (C) Mike McCormack 4 | # 5 | # Test launching script 6 | # Copies a test executable onto the c: drive and runs it 7 | # 8 | 9 | kernel="./kernel/ring3k-bin" 10 | if test \! -x "$kernel" 11 | then 12 | echo "kernel binary (ring3k-bin) not present" 13 | exit 1 14 | fi 15 | 16 | while test "x$1" != "x" 17 | do 18 | case $1 in 19 | -d) 20 | debug=1 21 | shift 22 | ;; 23 | -t) 24 | trace=1 25 | shift 26 | ;; 27 | --trace*) 28 | tracespec=$1 29 | shift 30 | ;; 31 | -v) 32 | valgrind=1 33 | shift 34 | ;; 35 | *) 36 | t="$1.exe" 37 | shift 38 | ;; 39 | esac 40 | done 41 | 42 | if [ ! -d drive ] 43 | then 44 | sh ring3k-setup 45 | fi 46 | 47 | if [ ! -d drive ] 48 | then 49 | exit 1 50 | fi 51 | 52 | # copy the test into the NT directory 53 | cp -f "tests/win2k/ntwin32.dll" drive 54 | cp -f "tests/$t" drive/tests 55 | ntexepath="\\??\\c:\\tests\\$t" 56 | exec ${valgrind:+"valgrind"} "$kernel" ${debug:+"-d"} ${tracespec} ${tt:+"-s"} ${quiet:+"-q"} ${trace:+"-t"} "$ntexepath" 57 | -------------------------------------------------------------------------------- /tests/.gitignore: -------------------------------------------------------------------------------- 1 | Makefile 2 | *.exe 3 | *.o 4 | *.s 5 | *.a 6 | .*.d 7 | *.bat 8 | *.lib 9 | *.dll 10 | -------------------------------------------------------------------------------- /tests/Makefile.in: -------------------------------------------------------------------------------- 1 | # 2 | # Makefile for regression tests 3 | # Copyright 2007-2008 Mike McCormack 4 | # 5 | 6 | srcdir = @srcdir@ 7 | VPATH = @srcdir@ 8 | 9 | DEPFLAG = -Wp,-MD,.$@.d 10 | CC=@MINGW32CC@ 11 | STRIP=@MINGW32STRIP@ 12 | CFLAGS=-Wall -O2 $(DEPFLAG) -I$(srcdir)/../include/common 13 | AS=@MINGW32AS@ 14 | AR=@MINGW32AR@ 15 | RANLIB=@MINGW32RANLIB@ 16 | WINDRES=@MINGW32WINDRES@ 17 | 18 | TESTS = \ 19 | atom.c \ 20 | completion.c \ 21 | device.c \ 22 | event.c \ 23 | eventpair.c \ 24 | file.c \ 25 | font.c \ 26 | gdi.c \ 27 | heap.c \ 28 | job.c \ 29 | key.c \ 30 | mailslot.c \ 31 | mutant.c \ 32 | object.c \ 33 | pipe.c \ 34 | port.c \ 35 | process.c \ 36 | reg.c \ 37 | section.c \ 38 | seh.c \ 39 | sema.c \ 40 | syscall.c \ 41 | thread.c \ 42 | timer.c \ 43 | token.c \ 44 | user.c \ 45 | virtual.c \ 46 | wine-atom.c \ 47 | wine-port.c 48 | 49 | SOURCE = \ 50 | $(TESTS) \ 51 | hostnt.c \ 52 | native.c \ 53 | ps.c \ 54 | runnt.c \ 55 | smss.c 56 | 57 | ISO = nttests.iso 58 | 59 | .PHONY: all clean 60 | 61 | NTWIN32LIB=win2k/ntwin32.dll 62 | 63 | all: $(SOURCE:.c=.exe) $(ISO) winxp/ntwin32.dll win2k/ntwin32.dll 64 | 65 | include $(wildcard .*.d) 66 | 67 | runtests.bat: Makefile 68 | echo @rem Generated by Makefile > $@ 69 | for f in $(TESTS:%.c=%.exe); do echo @hostnt.exe $$f >> $@ ; done 70 | 71 | # ntwin32.dll differs between windows versions 72 | win2k/ntwin32.dll: win2k/ntwin32.o 73 | $(CC) -o $@ -shared -nostartfiles -nodefaultlibs $< 74 | 75 | win2k/ntwin32.o: win2k/ntwin32.s 76 | $(AS) -o $@ $< 77 | 78 | win2k/ntwin32.s: win2k/ntwin32.in gen_syscalls.pl 79 | mkdir -p win2k 80 | perl $(srcdir)/gen_syscalls.pl $< > $@ 81 | 82 | winxp/ntwin32.dll: winxp/ntwin32.o 83 | $(CC) -o $@ -shared -nostartfiles -nodefaultlibs $< 84 | 85 | winxp/ntwin32.o: winxp/ntwin32.s 86 | $(AS) -o $@ $< 87 | 88 | winxp/ntwin32.s: winxp/ntwin32.in gen_syscalls.pl 89 | mkdir -p winxp 90 | perl $(srcdir)/gen_syscalls.pl $< > $@ 91 | 92 | dillo.exe: dillo.o 93 | $(CC) -o $@ $< -lntdll 94 | 95 | runnt.exe: runnt.o 96 | $(CC) -o $@ $< -lntdll -lkernel32 97 | 98 | hostnt.exe: hostnt.o 99 | $(CC) -o $@ $< -lntdll -lkernel32 100 | 101 | NATIVEEXEFLAGS = -lntdll -nostartfiles -nodefaultlibs -Wl,--subsystem=native -e _NtProcessStartup 102 | 103 | gdi.exe: gdi.o log.o $(NTWIN32LIB) 104 | $(CC) -o $@ $^ $(NATIVEEXEFLAGS) 105 | 106 | user.exe: user.o log.o $(NTWIN32LIB) 107 | $(CC) -o $@ $^ $(NATIVEEXEFLAGS) 108 | 109 | key.exe: key.o log.o $(NTWIN32LIB) 110 | $(CC) -o $@ $^ $(NATIVEEXEFLAGS) 111 | 112 | font.exe: font.o log.o $(NTWIN32LIB) 113 | $(CC) -o $@ $^ $(NATIVEEXEFLAGS) 114 | 115 | atom.exe: atom.o log.o $(NTWIN32LIB) 116 | $(CC) -o $@ $^ $(NATIVEEXEFLAGS) 117 | 118 | wine-atom.exe: wine-atom.o log.o $(NTWIN32LIB) 119 | $(CC) -o $@ $^ $(NATIVEEXEFLAGS) 120 | 121 | smss.exe: smss.o 122 | $(CC) -o $@ $^ $(NATIVEEXEFLAGS) -Wl,--major-image-version,5,--major-os-version,5,--major-subsystem-version,5 -Wl,--image-base,0x48580000 123 | 124 | %.exe: %.c log.o 125 | $(CC) $(CFLAGS) -o $@ log.o $< $(NATIVEEXEFLAGS) 126 | 127 | # build an with the tests so that they can be easily run in QEMU 128 | $(ISO): $(SOURCE:.c=.exe) $(NTWIN32LIB) 129 | cp -f $(NTWIN32LIB) ntwin32.dll 130 | genisoimage -r -J -input-charset utf-8 -o $(ISO) $(SOURCE:.c=.exe) ntwin32.dll 131 | 132 | clean: 133 | $(RM) *.exe *.o *.s *.a *.bat *.dll .*.d 134 | $(RM) win2k/*.a win2k/*.s win2k/*.lib win2k/*.dll win2k/*.o 135 | $(RM) winxp/*.a winxp/*.s winxp/*.lib winxp/*.dll winxp/*.o 136 | $(RM) $(ISO) 137 | -------------------------------------------------------------------------------- /tests/device.c: -------------------------------------------------------------------------------- 1 | /* 2 | * native test suite 3 | * 4 | * Copyright 2006-2008 Mike McCormack 5 | * 6 | * This library is free software; you can redistribute it and/or 7 | * modify it under the terms of the GNU Lesser General Public 8 | * License as published by the Free Software Foundation; either 9 | * version 2.1 of the License, or (at your option) any later version. 10 | * 11 | * This library is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 14 | * Lesser General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU Lesser General Public 17 | * License along with this library; if not, write to the Free Software 18 | * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA 19 | */ 20 | 21 | 22 | #include 23 | #include "ntapi.h" 24 | #include "log.h" 25 | 26 | WCHAR randev[] = L"\\Device\\KsecDD"; 27 | 28 | void test_open_random_number_device(void) 29 | { 30 | IO_STATUS_BLOCK iosb; 31 | OBJECT_ATTRIBUTES oa; 32 | UNICODE_STRING us; 33 | HANDLE file = 0; 34 | NTSTATUS r; 35 | 36 | init_oa( &oa, &us, randev ); 37 | 38 | r = NtOpenFile( &file, SYNCHRONIZE | FILE_READ_DATA, &oa, &iosb, 39 | FILE_SHARE_READ | FILE_SHARE_WRITE | FILE_SHARE_DELETE, 40 | FILE_SYNCHRONOUS_IO_ALERT ); 41 | ok( r == STATUS_SUCCESS, "failed to open file %08lx\n", r); 42 | 43 | r = NtClose( file ); 44 | ok( r == STATUS_SUCCESS, "return wrong %08lx\n", r); 45 | } 46 | 47 | void NtProcessStartup( void ) 48 | { 49 | log_init(); 50 | test_open_random_number_device(); 51 | log_fini(); 52 | } 53 | -------------------------------------------------------------------------------- /tests/eventpair.c: -------------------------------------------------------------------------------- 1 | /* 2 | * native test suite 3 | * 4 | * Copyright 2006-2008 Mike McCormack 5 | * 6 | * This library is free software; you can redistribute it and/or 7 | * modify it under the terms of the GNU Lesser General Public 8 | * License as published by the Free Software Foundation; either 9 | * version 2.1 of the License, or (at your option) any later version. 10 | * 11 | * This library is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 14 | * Lesser General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU Lesser General Public 17 | * License along with this library; if not, write to the Free Software 18 | * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA 19 | */ 20 | 21 | #include 22 | #include "ntapi.h" 23 | #include "log.h" 24 | 25 | static void test_eventpair(void) 26 | { 27 | NTSTATUS r; 28 | HANDLE eventpair; 29 | 30 | r = NtCreateEventPair( NULL, STANDARD_RIGHTS_ALL, NULL ); 31 | ok(r == STATUS_ACCESS_VIOLATION, "return wrong %08lx\n", r); 32 | 33 | r = NtCreateEventPair( &eventpair, STANDARD_RIGHTS_ALL, NULL ); 34 | ok(r == STATUS_SUCCESS, "return wrong %08lx\n", r); 35 | 36 | r = NtSetLowEventPair( eventpair ); 37 | ok(r == STATUS_SUCCESS, "return wrong %08lx\n", r); 38 | 39 | r = NtWaitLowEventPair( eventpair ); 40 | ok(r == STATUS_SUCCESS, "return wrong %08lx\n", r); 41 | 42 | r = NtSetHighEventPair( eventpair ); 43 | ok(r == STATUS_SUCCESS, "return wrong %08lx\n", r); 44 | 45 | r = NtWaitHighEventPair( eventpair ); 46 | ok(r == STATUS_SUCCESS, "return wrong %08lx\n", r); 47 | 48 | r = NtClose( eventpair ); 49 | ok(r == STATUS_SUCCESS, "return wrong %08lx\n", r); 50 | } 51 | 52 | 53 | void NtProcessStartup( void ) 54 | { 55 | log_init(); 56 | test_eventpair(); 57 | log_fini(); 58 | } 59 | -------------------------------------------------------------------------------- /tests/gen_syscalls.pl: -------------------------------------------------------------------------------- 1 | #!/usr/bin/perl 2 | # 3 | # nt loader 4 | # 5 | # Copyright 2006-2008 Mike McCormack 6 | # 7 | # This library is free software; you can redistribute it and/or 8 | # modify it under the terms of the GNU Lesser General Public 9 | # License as published by the Free Software Foundation; either 10 | # version 2.1 of the License, or (at your option) any later version. 11 | # 12 | # This library is distributed in the hope that it will be useful, 13 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 15 | # Lesser General Public License for more details. 16 | # 17 | # You should have received a copy of the GNU Lesser General Public 18 | # License along with this library; if not, write to the Free Software 19 | # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA 20 | 21 | my $infile = $ARGV[0]; 22 | open(IN,"<$infile") || die("failed to open $infile\n"); 23 | 24 | # need an entry point 25 | print <) { 35 | s/#.*$//; 36 | next if ( /^$/ ); 37 | ($ord, $func, $numargs) = split / /; 38 | $numargs *= 4; 39 | print < 22 | #include "ntapi.h" 23 | #include "log.h" 24 | 25 | void test_query_job(void) 26 | { 27 | NTSTATUS r; 28 | JOBOBJECT_BASIC_UI_RESTRICTIONS uir; 29 | 30 | uir.UIRestrictionsClass = ~0; 31 | r = NtQueryInformationJobObject(0, JobObjectBasicUIRestrictions, &uir, sizeof uir, 0); 32 | ok( r == STATUS_ACCESS_DENIED, "return wrong %08lx\n", r); 33 | ok( uir.UIRestrictionsClass == ~0, "restrictions wrong %08lx\n", uir.UIRestrictionsClass); 34 | } 35 | 36 | void NtProcessStartup( void ) 37 | { 38 | log_init(); 39 | test_query_job(); 40 | log_fini(); 41 | } 42 | -------------------------------------------------------------------------------- /tests/log.h: -------------------------------------------------------------------------------- 1 | /* 2 | * native test suite 3 | * 4 | * Copyright 2006-2008 Mike McCormack 5 | * 6 | * This library is free software; you can redistribute it and/or 7 | * modify it under the terms of the GNU Lesser General Public 8 | * License as published by the Free Software Foundation; either 9 | * version 2.1 of the License, or (at your option) any later version. 10 | * 11 | * This library is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 14 | * Lesser General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU Lesser General Public 17 | * License along with this library; if not, write to the Free Software 18 | * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA 19 | */ 20 | 21 | #ifndef __TEST_LOG_H__ 22 | #define __TEST_LOG_H__ 23 | 24 | NTSTATUS log_init( void ); 25 | NTSTATUS log_fini(void); 26 | 27 | void init_us( PUNICODE_STRING us, WCHAR *string ); 28 | void init_oa( OBJECT_ATTRIBUTES* oa, UNICODE_STRING* us, WCHAR *path ); 29 | 30 | extern ULONG pass_count, fail_count; 31 | 32 | void dprintf(char *string, ...) __attribute__((format (printf,1,2))); 33 | void dump_bin(void *ptr, ULONG sz); 34 | 35 | #define ok(cond, str, ...) \ 36 | do { \ 37 | if (!(cond)) { \ 38 | dprintf( "%d: " str, __LINE__, ## __VA_ARGS__ ); \ 39 | fail_count++; \ 40 | } else pass_count++; \ 41 | } while (0) 42 | 43 | #endif // __TEST_LOG_H__ 44 | -------------------------------------------------------------------------------- /tests/mutant.c: -------------------------------------------------------------------------------- 1 | /* 2 | * native test suite 3 | * 4 | * Copyright 2006-2008 Mike McCormack 5 | * 6 | * This library is free software; you can redistribute it and/or 7 | * modify it under the terms of the GNU Lesser General Public 8 | * License as published by the Free Software Foundation; either 9 | * version 2.1 of the License, or (at your option) any later version. 10 | * 11 | * This library is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 14 | * Lesser General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU Lesser General Public 17 | * License along with this library; if not, write to the Free Software 18 | * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA 19 | */ 20 | 21 | #include 22 | #include "ntapi.h" 23 | #include "log.h" 24 | 25 | #define MAGIC ((void*) 0xf00) 26 | 27 | void test_mutant() 28 | { 29 | NTSTATUS r; 30 | HANDLE mutant; 31 | 32 | r = NtCreateMutant( NULL, 0, NULL, 0 ); 33 | ok(r == STATUS_ACCESS_VIOLATION, "return wrong %08lx\n", r); 34 | 35 | mutant = MAGIC; 36 | r = NtCreateMutant( &mutant, 0, NULL, 0 ); 37 | ok(r == STATUS_SUCCESS, "return wrong %08lx\n", r); 38 | ok(mutant != MAGIC, "return wrong %08lx\n", r); 39 | 40 | r = NtClose( mutant ); 41 | ok(r == STATUS_SUCCESS, "return wrong %08lx\n", r); 42 | 43 | mutant = MAGIC; 44 | r = NtCreateMutant( &mutant, MUTANT_ALL_ACCESS, NULL, 0 ); 45 | ok(r == STATUS_SUCCESS, "return wrong %08lx\n", r); 46 | ok(mutant != MAGIC, "return wrong %08lx\n", r); 47 | 48 | r = NtReleaseMutant( mutant, NULL ); 49 | ok(r == STATUS_MUTANT_NOT_OWNED, "return wrong %08lx\n", r); 50 | 51 | r = NtReleaseMutant( mutant, MAGIC ); 52 | ok(r == STATUS_ACCESS_VIOLATION, "return wrong %08lx\n", r); 53 | 54 | r = NtWaitForSingleObject( mutant, 0, NULL ); 55 | ok(r == STATUS_SUCCESS, "return wrong %08lx\n", r); 56 | 57 | r = NtReleaseMutant( mutant, MAGIC ); 58 | ok(r == STATUS_ACCESS_VIOLATION, "return wrong %08lx\n", r); 59 | 60 | r = NtReleaseMutant( mutant, NULL ); 61 | ok(r == STATUS_SUCCESS, "return wrong %08lx\n", r); 62 | 63 | r = NtClose( mutant ); 64 | ok(r == STATUS_SUCCESS, "return wrong %08lx\n", r); 65 | 66 | } 67 | 68 | void NtProcessStartup( void ) 69 | { 70 | log_init(); 71 | test_mutant(); 72 | log_fini(); 73 | } 74 | -------------------------------------------------------------------------------- /tests/native.c: -------------------------------------------------------------------------------- 1 | /* 2 | * native test suite 3 | * 4 | * Copyright 2006-2008 Mike McCormack 5 | * 6 | * This library is free software; you can redistribute it and/or 7 | * modify it under the terms of the GNU Lesser General Public 8 | * License as published by the Free Software Foundation; either 9 | * version 2.1 of the License, or (at your option) any later version. 10 | * 11 | * This library is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 14 | * Lesser General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU Lesser General Public 17 | * License along with this library; if not, write to the Free Software 18 | * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA 19 | */ 20 | 21 | 22 | #include "ntapi.h" 23 | #include "log.h" 24 | 25 | void NtProcessStartup( void ) 26 | { 27 | NTSTATUS r = 0; 28 | 29 | r = log_init(); 30 | dprintf( "hello world\n"); 31 | log_fini(); 32 | } 33 | -------------------------------------------------------------------------------- /tests/ntwin32.h: -------------------------------------------------------------------------------- 1 | /* 2 | * nt loader 3 | * 4 | * Copyright 2006-2009 Mike McCormack 5 | * 6 | * This library is free software; you can redistribute it and/or 7 | * modify it under the terms of the GNU Lesser General Public 8 | * License as published by the Free Software Foundation; either 9 | * version 2.1 of the License, or (at your option) any later version. 10 | * 11 | * This library is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 14 | * Lesser General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU Lesser General Public 17 | * License along with this library; if not, write to the Free Software 18 | * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA 19 | */ 20 | 21 | #ifndef __RING3K_TEST_NTWIN32_H__ 22 | #define __RING3K_TEST_NTWIN32_H__ 23 | 24 | #include 25 | #include "wingdi.h" 26 | #include "winuser.h" 27 | #include "ntgdi.h" 28 | #include "ntuser.h" 29 | 30 | #endif 31 | -------------------------------------------------------------------------------- /tests/ps.c: -------------------------------------------------------------------------------- 1 | /* 2 | * native test suite 3 | * 4 | * Copyright 2006-2008 Mike McCormack 5 | * 6 | * This library is free software; you can redistribute it and/or 7 | * modify it under the terms of the GNU Lesser General Public 8 | * License as published by the Free Software Foundation; either 9 | * version 2.1 of the License, or (at your option) any later version. 10 | * 11 | * This library is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 14 | * Lesser General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU Lesser General Public 17 | * License along with this library; if not, write to the Free Software 18 | * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA 19 | */ 20 | 21 | 22 | #include 23 | #include "ntapi.h" 24 | #include "log.h" 25 | 26 | BYTE buffer[0x10000]; 27 | 28 | void list_processes(void) 29 | { 30 | PSYSTEM_PROCESS_INFORMATION pspi; 31 | ULONG ofs = 0, sz, i, j; 32 | NTSTATUS r; 33 | 34 | sz = 0; 35 | r = NtQuerySystemInformation( SystemProcessInformation, buffer, sizeof buffer, &sz ); 36 | ok( r == STATUS_SUCCESS, "NtQuerySystemInformation failed\n" ); 37 | if (r != STATUS_SUCCESS) 38 | return; 39 | 40 | for (i=0, ofs=0; ofsThreadCount, pspi->ProcessId, 44 | pspi->InheritedFromProcessId, pspi->ProcessName.Buffer); 45 | for (j=0; jThreadCount; j++) 46 | { 47 | dprintf("%p %p %p %08lx %08lx\n", 48 | pspi->Threads[j].StartAddress, 49 | pspi->Threads[j].ClientId.UniqueProcess, 50 | pspi->Threads[j].ClientId.UniqueThread, 51 | pspi->Threads[j].State, 52 | pspi->Threads[j].WaitReason); 53 | } 54 | if (!pspi->NextEntryDelta) 55 | break; 56 | ofs += pspi->NextEntryDelta; 57 | } 58 | } 59 | 60 | void NtProcessStartup( void ) 61 | { 62 | log_init(); 63 | list_processes(); 64 | log_fini(); 65 | } 66 | -------------------------------------------------------------------------------- /tests/rtlapi.h: -------------------------------------------------------------------------------- 1 | #ifndef __RTLAPI_H__ 2 | #define __RTLAPI_H__ 3 | 4 | #include 5 | 6 | int __cdecl swprintf(WCHAR *, const WCHAR *, ...); 7 | int __cdecl vsprintf(char *, const char *, va_list); 8 | int __cdecl sprintf(char *, const char *, ...); 9 | PVOID NTAPI RtlAllocateHeap(HANDLE,ULONG,SIZE_T); 10 | BOOLEAN NTAPI RtlFreeHeap(HANDLE,ULONG,PVOID); 11 | void NTAPI RtlInitUnicodeString(PUNICODE_STRING, PCWSTR); 12 | NTSTATUS NTAPI RtlCreateUserThread(HANDLE, const SECURITY_DESCRIPTOR *, BOOLEAN, PVOID, SIZE_T, SIZE_T, void *, void *, HANDLE *, CLIENT_ID *); 13 | BOOLEAN NTAPI RtlDosPathNameToNtPathName_U(PWSTR, PUNICODE_STRING, PWSTR *, CURDIR *); 14 | PVOID NTAPI RtlReAllocateHeap(HANDLE,ULONG,PVOID,SIZE_T); 15 | 16 | #endif 17 | -------------------------------------------------------------------------------- /tests/sema.c: -------------------------------------------------------------------------------- 1 | /* 2 | * native test suite 3 | * 4 | * Copyright 2006-2008 Mike McCormack 5 | * 6 | * This library is free software; you can redistribute it and/or 7 | * modify it under the terms of the GNU Lesser General Public 8 | * License as published by the Free Software Foundation; either 9 | * version 2.1 of the License, or (at your option) any later version. 10 | * 11 | * This library is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 14 | * Lesser General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU Lesser General Public 17 | * License along with this library; if not, write to the Free Software 18 | * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA 19 | */ 20 | 21 | 22 | #include 23 | #include "ntapi.h" 24 | #include "log.h" 25 | 26 | void test_sema( void ) 27 | { 28 | NTSTATUS r; 29 | HANDLE sema; 30 | ULONG count; 31 | 32 | r = NtReleaseSemaphore( 0, 0, NULL ); 33 | ok(r == STATUS_INVALID_PARAMETER, "return wrong %08lx\n", r); 34 | 35 | r = NtCreateSemaphore( NULL, SEMAPHORE_ALL_ACCESS, NULL, 0, 1 ); 36 | ok(r == STATUS_ACCESS_VIOLATION, "return wrong %08lx\n", r); 37 | 38 | r = NtCreateSemaphore( &sema, SEMAPHORE_ALL_ACCESS, NULL, 0, 2 ); 39 | ok(r == STATUS_SUCCESS, "return wrong %08lx\n", r); 40 | 41 | count = 0xf00; 42 | r = NtReleaseSemaphore( sema, 3, &count ); 43 | ok(r == STATUS_SEMAPHORE_LIMIT_EXCEEDED, "return wrong %08lx\n", r); 44 | ok(count == 0xf00, "count was %08lx\n", count); 45 | 46 | count = 0xf00; 47 | r = NtReleaseSemaphore( sema, 1, &count ); 48 | ok(r == STATUS_SUCCESS, "return wrong %08lx\n", r); 49 | ok(count == 0, "count was %08lx\n", count); 50 | 51 | count = 0xf00; 52 | r = NtReleaseSemaphore( sema, 0, &count ); 53 | ok(r == STATUS_INVALID_PARAMETER, "return wrong %08lx\n", r); 54 | ok(count == 0xf00, "count was %08lx\n", count); 55 | 56 | r = NtWaitForSingleObject( sema, 0, NULL ); 57 | ok(r == STATUS_SUCCESS, "return wrong %08lx\n", r); 58 | 59 | count = 0xf00; 60 | r = NtReleaseSemaphore( sema, 1, &count ); 61 | ok(r == STATUS_SUCCESS, "return wrong %08lx\n", r); 62 | ok(count == 0, "count was %08lx\n", count); 63 | 64 | count = 0xf00; 65 | r = NtReleaseSemaphore( sema, 1, &count ); 66 | ok(r == STATUS_SUCCESS, "return wrong %08lx\n", r); 67 | ok(count == 1, "count was %08lx\n", count); 68 | 69 | r = NtWaitForSingleObject( sema, 0, NULL ); 70 | ok(r == STATUS_SUCCESS, "return wrong %08lx\n", r); 71 | 72 | r = NtWaitForSingleObject( sema, 0, NULL ); 73 | ok(r == STATUS_SUCCESS, "return wrong %08lx\n", r); 74 | 75 | count = 0xf00; 76 | r = NtReleaseSemaphore( sema, 2, &count ); 77 | ok(r == STATUS_SUCCESS, "return wrong %08lx\n", r); 78 | ok(count == 0, "count was %08lx\n", count); 79 | 80 | r = NtReleaseSemaphore( sema, 1, &count ); 81 | ok(r == STATUS_SEMAPHORE_LIMIT_EXCEEDED, "return wrong %08lx\n", r); 82 | 83 | r = NtClose( sema ); 84 | ok(r == STATUS_SUCCESS, "return wrong %08lx\n", r); 85 | } 86 | 87 | void NtProcessStartup( void ) 88 | { 89 | log_init(); 90 | test_sema(); 91 | log_fini(); 92 | } 93 | -------------------------------------------------------------------------------- /tests/smss.c: -------------------------------------------------------------------------------- 1 | /* 2 | * A short smss.exe replacement to get the contents of the initial PPB 3 | * 4 | * Copyright 2009 Mike McCormack 5 | * 6 | * This library is free software; you can redistribute it and/or 7 | * modify it under the terms of the GNU Lesser General Public 8 | * License as published by the Free Software Foundation; either 9 | * version 2.1 of the License, or (at your option) any later version. 10 | * 11 | * This library is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 14 | * Lesser General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU Lesser General Public 17 | * License along with this library; if not, write to the Free Software 18 | * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA 19 | */ 20 | 21 | 22 | #include 23 | #include "ntapi.h" 24 | #include "rtlapi.h" 25 | 26 | void dprintf(char *fmt, ...) 27 | { 28 | static char buffer[0x100]; 29 | static WCHAR wbuffer[0x100]; 30 | UNICODE_STRING str; 31 | va_list va; 32 | int n; 33 | 34 | va_start(va, fmt); 35 | vsprintf(buffer, fmt, va); 36 | va_end(va); 37 | 38 | for (n=0; buffer[n] && n= STATUS_SUCCESS) 75 | { 76 | dprintf("NtCreateFile succeeded\n", r); 77 | dprintf("peb = %08lx\n", arg); 78 | dprintf("ppb = %08lx\n", arg[4]); 79 | 80 | NtCreateEvent(&event, EVENT_ALL_ACCESS, 0, 0, 0); 81 | 82 | /* write the ppb to a file */ 83 | offset.QuadPart = 0L; 84 | r = NtWriteFile( file, event, 0, 0, &iosb, arg[4], 0x1000, &offset, 0 ); 85 | dprintf("NtWriteFile returned %08lx\n", r); 86 | 87 | NtWaitForSingleObject( event, 0, 0 ); 88 | 89 | eof.EndOfFile.QuadPart = 0x1000; 90 | r = NtSetInformationFile( file, &iosb, &eof, sizeof eof, FileEndOfFileInformation ); 91 | dprintf("NtSetInformationFile returned %08lx\n", r); 92 | 93 | NtClose( file ); 94 | } 95 | else 96 | dprintf("NtCreateFile failed %08lx\n", r); 97 | 98 | 99 | /* sleep */ 100 | while (1) 101 | { 102 | timeout.QuadPart = -20000LL; 103 | NtDelayExecution( TRUE, &timeout ); 104 | } 105 | 106 | NtTerminateProcess( NtCurrentProcess(), 0 ); 107 | } 108 | -------------------------------------------------------------------------------- /tools/.gitignore: -------------------------------------------------------------------------------- 1 | .*.d 2 | *.exe 3 | *.dll 4 | -------------------------------------------------------------------------------- /tools/Makefile.in: -------------------------------------------------------------------------------- 1 | # 2 | # Makefile for testing tools 3 | # Copyright 2008 Mike McCormack 4 | # 5 | 6 | srcdir = @srcdir@ 7 | VPATH = @srcdir@ 8 | 9 | DEPFLAG = -Wp,-MD,.$@.d 10 | CC=@MINGW32CC@ 11 | STRIP=@MINGW32STRIP@ 12 | CFLAGS=-Wall -O2 $(DEPFLAG) 13 | AS=@MINGW32AS@ 14 | AR=@MINGW32AR@ 15 | RANLIB=@MINGW32RANLIB@ 16 | WINDRES=@MINGW32WINDRES@ 17 | 18 | INSTALL = @INSTALL@ 19 | INSTALL_PROGRAM = @INSTALL_PROGRAM@ 20 | INSTALL_DATA = @INSTALL_DATA@ 21 | prefix = @prefix@ 22 | bindir = ${prefix}/bin 23 | datadir = ${prefix}/data 24 | 25 | SOURCE = \ 26 | console.c \ 27 | dumphandles.c \ 28 | qdf.c \ 29 | startcmd.c \ 30 | track.c 31 | 32 | .PHONY: all clean 33 | 34 | NTWIN32LIB=../tests/win2k/ntwin32.dll 35 | 36 | all: $(SOURCE:.c=.exe) advapi32.dll 37 | 38 | include $(wildcard .*.d) 39 | 40 | advapi32.dll: advapi32.c 41 | $(CC) -o $@ -shared $< -e _DllMain@12 -Wl,--kill-at 42 | 43 | dumphandles.exe: dumphandles.c $(NTWIN32LIB) 44 | $(CC) $(CFLAGS) -o $@ $< $(NTWIN32LIB) -lntdll -lkernel32 -luser32 45 | 46 | qdf.exe: qdf.c 47 | $(CC) $(CFLAGS) -o $@ $< -luser32 -lkernel32 -lntdll -lgdi32 48 | 49 | startcmd.exe: startcmd.c 50 | $(CC) $(CFLAGS) -o $@ $< -lntdll -lkernel32 -lgdi32 -Wl,--subsystem=windows 51 | 52 | console.exe: console.c 53 | $(CC) $(CFLAGS) -o $@ $< -lntdll -lkernel32 -lgdi32 -Wl,--subsystem=windows 54 | 55 | track.exe: track.c 56 | $(CC) $(CFLAGS) -o $@ $< -lgdi32 -luser32 -Wl,--subsystem=windows 57 | 58 | clean: 59 | rm -f *.o *.dll *.exe .*.d 60 | 61 | -------------------------------------------------------------------------------- /tools/advapi32.c: -------------------------------------------------------------------------------- 1 | /* 2 | * advapi32 stub 3 | * 4 | * Useful for avoiding loading of rpcrt4 and use of named pipes during startup 5 | * Intended only as a debugging and development too. 6 | * Avoid extending, need to make the native advapi32 work. 7 | * 8 | * Copyright 2008 Mike McCormack 9 | * 10 | * This library is free software; you can redistribute it and/or 11 | * modify it under the terms of the GNU Lesser General Public 12 | * License as published by the Free Software Foundation; either 13 | * version 2.1 of the License, or (at your option) any later version. 14 | * 15 | * This library is distributed in the hope that it will be useful, 16 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 17 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 18 | * Lesser General Public License for more details. 19 | * 20 | * You should have received a copy of the GNU Lesser General Public 21 | * License along with this library; if not, write to the Free Software 22 | * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA 23 | */ 24 | 25 | #include 26 | 27 | BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved) 28 | { 29 | return TRUE; 30 | } 31 | 32 | __declspec(dllexport) 33 | HANDLE WINAPI RegisterEventSourceW( LPCWSTR lpUNCServerName, LPCWSTR lpSourceName ) 34 | { 35 | return 0; 36 | } 37 | 38 | __declspec(dllexport) 39 | BOOL WINAPI ReportEventW( HANDLE hEventLog, WORD wType, WORD wCategory, DWORD dwEventID, 40 | PSID lpUserSid, WORD wNumStrings, DWORD dwDataSize, LPCWSTR *lpStrings, LPVOID lpRawData ) 41 | { 42 | return TRUE; 43 | } 44 | 45 | __declspec(dllexport) 46 | BOOL WINAPI DeregisterEventSource( HANDLE hEventLog ) 47 | { 48 | return TRUE; 49 | } 50 | 51 | __declspec(dllexport) 52 | BOOL WINAPI 53 | GetTokenInformation( HANDLE token, TOKEN_INFORMATION_CLASS tokeninfoclass, 54 | LPVOID tokeninfo, DWORD tokeninfolength, LPDWORD retlen ) 55 | { 56 | *(BYTE*)0 = 1; 57 | return FALSE; 58 | } 59 | 60 | __declspec(dllexport) 61 | BOOL WINAPI 62 | OpenProcessToken( HANDLE ProcessHandle, DWORD DesiredAccess, 63 | HANDLE *TokenHandle ) 64 | { 65 | *(BYTE*)0 = 2; 66 | TokenHandle = (HANDLE)0xdeadbeef; 67 | return TRUE; 68 | } 69 | 70 | __declspec(dllexport) 71 | BOOL WINAPI 72 | OpenThreadToken( HANDLE ThreadHandle, DWORD DesiredAccess, 73 | BOOL OpenAsSelf, HANDLE *TokenHandle) 74 | { 75 | *(BYTE*)0 = 3; 76 | TokenHandle = (HANDLE)0xdeadbeef; 77 | return TRUE; 78 | } 79 | -------------------------------------------------------------------------------- /tools/console.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Create a console 3 | * 4 | * Copyright 2006-2008 Mike McCormack 5 | * 6 | * This library is free software; you can redistribute it and/or 7 | * modify it under the terms of the GNU Lesser General Public 8 | * License as published by the Free Software Foundation; either 9 | * version 2.1 of the License, or (at your option) any later version. 10 | * 11 | * This library is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 14 | * Lesser General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU Lesser General Public 17 | * License along with this library; if not, write to the Free Software 18 | * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA 19 | */ 20 | 21 | #include 22 | #include 23 | 24 | void init_window_station( void ) 25 | { 26 | SECURITY_ATTRIBUTES sa; 27 | HANDLE hwsta, hdesk; 28 | 29 | sa.nLength = sizeof sa; 30 | sa.lpSecurityDescriptor = 0; 31 | sa.bInheritHandle = TRUE; 32 | 33 | hwsta = CreateWindowStationW( L"winsta0", 0, MAXIMUM_ALLOWED, &sa ); 34 | SetProcessWindowStation( hwsta ); 35 | hdesk = CreateDesktopW( L"Winlogon", 0, 0, 0, MAXIMUM_ALLOWED, &sa ); 36 | SetThreadDesktop( hdesk ); 37 | } 38 | 39 | int main( int argc, char **argv ) 40 | { 41 | init_window_station(); 42 | 43 | AllocConsole(); 44 | freopen("CONOUT$", "wb", stdout); 45 | printf("hello\n"); 46 | 47 | /* 48 | HANDLE console = GetStdHandle( STD_OUTPUT_HANDLE ); 49 | ULONG written; 50 | WriteConsole(console, "hello\n", 6, &written, 0 ); 51 | */ 52 | 53 | Sleep(100*1000); 54 | return 0; 55 | } 56 | -------------------------------------------------------------------------------- /unpack/.gitignore: -------------------------------------------------------------------------------- 1 | Makefile 2 | *.o 3 | ring3k-unpack 4 | -------------------------------------------------------------------------------- /unpack/Makefile.in: -------------------------------------------------------------------------------- 1 | srcdir = @srcdir@ 2 | VPATH = @srcdir@ 3 | 4 | CC = @HOSTCC@ 5 | 6 | INSTALL = @INSTALL@ 7 | INSTALL_PROGRAM = @INSTALL_PROGRAM@ 8 | prefix = @prefix@ 9 | bindir = ${prefix}/bin 10 | 11 | CFLAGS += -Wall -O2 -I$(srcdir)/../libmspack -I../libmspack 12 | 13 | TARGET = ring3k-unpack 14 | 15 | $(TARGET): unpack.o ../libmspack/libmspack.a 16 | $(CC) -o $@ $^ 17 | 18 | install: $(TARGET) 19 | $(INSTALL_PROGRAM) $(INSTALL_FLAGS) $(TARGET) $(DESTDIR)$(bindir) 20 | 21 | clean: 22 | rm -f *.o $(TARGET) 23 | -------------------------------------------------------------------------------- /unpack/unpack.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | #include 6 | #include "mspack.h" 7 | 8 | void strlower( char *str ) 9 | { 10 | while (*str) 11 | { 12 | *str = tolower( *str ); 13 | str++; 14 | } 15 | } 16 | 17 | int main(int argc, char **argv) 18 | { 19 | struct mscab_decompressor* decomp; 20 | struct mscabd_cabinet *cab; 21 | struct mscabd_file *file; 22 | char *cabfile; 23 | char targetfile[1024]; 24 | char *targetdir = ""; 25 | int n, len; 26 | 27 | for (n=1; nopen( decomp, cabfile ); 51 | if (!cab) 52 | { 53 | fprintf(stderr, "failed to open %s\n", cabfile ); 54 | exit(1); 55 | } 56 | 57 | file = cab->files; 58 | if (!file) 59 | { 60 | fprintf(stderr, "no files in archive!\n"); 61 | exit(1); 62 | } 63 | 64 | if (file->next) 65 | { 66 | fprintf(stderr, "unpack doesn't handle multiple files\n"); 67 | exit(1); 68 | } 69 | 70 | len = strlen( targetdir ); 71 | if (len) 72 | { 73 | strcpy( targetfile, targetdir ); 74 | if (targetfile[len-1] != '/') 75 | targetfile[len++] = '/'; 76 | } 77 | strcpy( targetfile+len, file->filename ); 78 | strlower( targetfile+len ); 79 | 80 | decomp->extract( decomp, file, targetfile ); 81 | 82 | decomp->close( decomp, cab ); 83 | 84 | return 0; 85 | } 86 | --------------------------------------------------------------------------------