├── .gitignore ├── AUTHORS ├── COPYING ├── ChangeLog ├── Makefile.msvc ├── Makefile.msvc.Debug ├── Makefile.msvc.Release ├── Makefile32-7.msvc ├── Makefile32-7.msvc.Debug ├── Makefile32-7.msvc.Release ├── Makefile64-7.msvc ├── Makefile64-7.msvc.Debug ├── Makefile64-7.msvc.Release ├── Makefile64.msvc ├── Makefile64.msvc.Debug ├── Makefile64.msvc.Release ├── README.md ├── aes.cpp ├── aes.h ├── ansi_cprng.cpp ├── ansi_cprng.h ├── bins ├── linux32 │ ├── ida70 │ │ └── x86emu_qt.so │ ├── ida71 │ │ └── x86emu_qt.so │ ├── ida72 │ │ └── x86emu_qt.so │ ├── ida73 │ │ └── x86emu_qt.so │ ├── ida74 │ │ └── x86emu_qt.so │ └── ida75 │ │ └── x86emu_qt.so ├── linux64 │ ├── ida70 │ │ └── x86emu_qt64.so │ ├── ida71 │ │ └── x86emu_qt64.so │ ├── ida72 │ │ └── x86emu_qt64.so │ ├── ida73 │ │ └── x86emu_qt64.so │ ├── ida74 │ │ └── x86emu_qt64.so │ └── ida75 │ │ └── x86emu_qt64.so ├── mac32 │ ├── ida70 │ │ └── x86emu_qt.dylib │ ├── ida71 │ │ └── x86emu_qt.dylib │ ├── ida72 │ │ └── x86emu_qt.dylib │ ├── ida73 │ │ └── x86emu_qt.dylib │ ├── ida74 │ │ └── x86emu_qt.dylib │ └── ida75 │ │ └── x86emu_qt.dylib ├── mac64 │ ├── ida70 │ │ └── x86emu_qt64.dylib │ ├── ida71 │ │ └── x86emu_qt64.dylib │ ├── ida72 │ │ └── x86emu_qt64.dylib │ ├── ida73 │ │ └── x86emu_qt64.dylib │ ├── ida74 │ │ └── x86emu_qt64.dylib │ └── ida75 │ │ └── x86emu_qt64.dylib ├── win32 │ ├── ida70 │ │ └── x86emu_qt.dll │ ├── ida71 │ │ └── x86emu_qt.dll │ ├── ida72 │ │ └── x86emu_qt.dll │ ├── ida73 │ │ └── x86emu_qt.dll │ ├── ida74 │ │ └── x86emu_qt.dll │ ├── ida75 │ │ └── x86emu_qt.dll │ ├── ida80 │ │ └── x86emu_qt.dll │ ├── ida81 │ │ └── x86emu_qt.dll │ └── ida82 │ │ └── x86emu_qt.dll └── win64 │ ├── ida70 │ └── x86emu_qt64.dll │ ├── ida71 │ └── x86emu_qt64.dll │ ├── ida72 │ └── x86emu_qt64.dll │ ├── ida73 │ └── x86emu_qt64.dll │ ├── ida74 │ └── x86emu_qt64.dll │ ├── ida75 │ └── x86emu_qt64.dll │ ├── ida80 │ └── x86emu_qt64.dll │ ├── ida81 │ └── x86emu_qt64.dll │ └── ida82 │ └── x86emu_qt64.dll ├── break.cpp ├── break.h ├── bsd_syscalls.h ├── buffer.cpp ├── buffer.h ├── build.linux32 ├── build.linux64 ├── build.mac32 ├── build.mac64 ├── build.win32 ├── build.win64 ├── build7.linux32 ├── build7.linux64 ├── build7.mac32 ├── build7.mac64 ├── build7.win32 ├── build7.win64 ├── cgc_syscalls.h ├── context.cpp ├── context.h ├── cpu.cpp ├── cpu.h ├── dialog.rc ├── elf32.h ├── elf_common.h ├── emu_script.cpp ├── emu_script.h ├── emufuncs.cpp ├── emufuncs.h ├── emuheap.cpp ├── emuheap.h ├── emuthreads.cpp ├── emuthreads.h ├── hooklist.cpp ├── hooklist.h ├── image.h ├── linux_syscalls.h ├── memmgr.cpp ├── memmgr.h ├── peutils.cpp ├── peutils.h ├── resource.h ├── sdk_versions.h ├── seh.cpp ├── seh.h ├── x86defs.h ├── x86emu.cpp ├── x86emu.idc ├── x86emu.pro ├── x86emu.sln ├── x86emu.vcxproj ├── x86emu.vcxproj.filters ├── x86emu.vcxproj.user ├── x86emu32-7.pro ├── x86emu64-7.pro ├── x86emu64.pro ├── x86emu_ui.cpp ├── x86emu_ui.h ├── x86emu_ui_qt.cpp └── x86emu_ui_qt.h /.gitignore: -------------------------------------------------------------------------------- 1 | # Prerequisites 2 | *.d 3 | 4 | # Compiled Object files 5 | *.slo 6 | *.lo 7 | *.o 8 | *.obj 9 | *.ko 10 | *.elf 11 | 12 | # Precompiled Headers 13 | *.gch 14 | *.pch 15 | 16 | # Compiled Dynamic libraries 17 | *.so 18 | *.dylib 19 | *.dll 20 | *.so.* 21 | *.dylib 22 | 23 | # Fortran module files 24 | *.mod 25 | *.smod 26 | 27 | # Compiled Static libraries 28 | *.lai 29 | *.la 30 | *.a 31 | *.lib 32 | *.lo 33 | 34 | # Executables 35 | *.exe 36 | *.out 37 | *.app 38 | *.i*86 39 | *.x86_64 40 | *.hex 41 | 42 | # Linker output 43 | *.ilk 44 | *.map 45 | *.exp 46 | 47 | # Debug files 48 | *.dSYM/ 49 | *.su 50 | *.idb 51 | *.pdb 52 | 53 | # Kernel Module Compile Results 54 | *.mod* 55 | *.cmd 56 | .tmp_versions/ 57 | modules.order 58 | Module.symvers 59 | Mkfile.old 60 | dkms.conf 61 | 62 | #Backup and other non-project files 63 | *.bak 64 | *.txt 65 | -------------------------------------------------------------------------------- /AUTHORS: -------------------------------------------------------------------------------- 1 | Chris Eagle, cseagle at gmail d0t com -------------------------------------------------------------------------------- /Makefile.msvc: -------------------------------------------------------------------------------- 1 | ############################################################################# 2 | # Makefile for building: x86emu_qt 3 | # Generated by qmake (3.0) (Qt 5.4.1) 4 | # Project: x86emu.pro 5 | # Template: lib 6 | # Command: C:\Qt\5.4.1\qtbase\bin\qmake.exe -platform win32-msvc2010 -o Makefile.msvc x86emu.pro 7 | ############################################################################# 8 | 9 | MAKEFILE = Makefile.msvc 10 | 11 | first: release 12 | install: release-install 13 | uninstall: release-uninstall 14 | QMAKE = C:\Qt\5.4.1\qtbase\bin\qmake.exe 15 | DEL_FILE = del 16 | CHK_DIR_EXISTS= if not exist 17 | MKDIR = mkdir 18 | COPY = copy /y 19 | COPY_FILE = $(COPY) 20 | COPY_DIR = xcopy /s /q /y /i 21 | INSTALL_FILE = $(COPY_FILE) 22 | INSTALL_PROGRAM = $(COPY_FILE) 23 | INSTALL_DIR = $(COPY_DIR) 24 | DEL_FILE = del 25 | SYMLINK = copy /y 26 | DEL_DIR = rmdir 27 | MOVE = move 28 | SUBTARGETS = \ 29 | release \ 30 | debug 31 | 32 | 33 | release: FORCE 34 | @set MAKEFLAGS=$(MAKEFLAGS) 35 | $(MAKE) -f $(MAKEFILE).Release 36 | release-make_first: FORCE 37 | @set MAKEFLAGS=$(MAKEFLAGS) 38 | $(MAKE) -f $(MAKEFILE).Release 39 | release-all: FORCE 40 | @set MAKEFLAGS=$(MAKEFLAGS) 41 | $(MAKE) -f $(MAKEFILE).Release all 42 | release-clean: FORCE 43 | @set MAKEFLAGS=$(MAKEFLAGS) 44 | $(MAKE) -f $(MAKEFILE).Release clean 45 | release-distclean: FORCE 46 | @set MAKEFLAGS=$(MAKEFLAGS) 47 | $(MAKE) -f $(MAKEFILE).Release distclean 48 | release-install: FORCE 49 | @set MAKEFLAGS=$(MAKEFLAGS) 50 | $(MAKE) -f $(MAKEFILE).Release install 51 | release-uninstall: FORCE 52 | @set MAKEFLAGS=$(MAKEFLAGS) 53 | $(MAKE) -f $(MAKEFILE).Release uninstall 54 | debug: FORCE 55 | @set MAKEFLAGS=$(MAKEFLAGS) 56 | $(MAKE) -f $(MAKEFILE).Debug 57 | debug-make_first: FORCE 58 | @set MAKEFLAGS=$(MAKEFLAGS) 59 | $(MAKE) -f $(MAKEFILE).Debug 60 | debug-all: FORCE 61 | @set MAKEFLAGS=$(MAKEFLAGS) 62 | $(MAKE) -f $(MAKEFILE).Debug all 63 | debug-clean: FORCE 64 | @set MAKEFLAGS=$(MAKEFLAGS) 65 | $(MAKE) -f $(MAKEFILE).Debug clean 66 | debug-distclean: FORCE 67 | @set MAKEFLAGS=$(MAKEFLAGS) 68 | $(MAKE) -f $(MAKEFILE).Debug distclean 69 | debug-install: FORCE 70 | @set MAKEFLAGS=$(MAKEFLAGS) 71 | $(MAKE) -f $(MAKEFILE).Debug install 72 | debug-uninstall: FORCE 73 | @set MAKEFLAGS=$(MAKEFLAGS) 74 | $(MAKE) -f $(MAKEFILE).Debug uninstall 75 | 76 | Makefile.msvc: x86emu.pro C:\Qt\5.4.1\qtbase\mkspecs\win32-msvc2010\qmake.conf C:\Qt\5.4.1\qtbase\mkspecs\features\spec_pre.prf \ 77 | C:\Qt\5.4.1\qtbase\mkspecs\common\shell-win32.conf \ 78 | C:\Qt\5.4.1\qtbase\mkspecs\qconfig.pri \ 79 | C:\Qt\5.4.1\qtbase\mkspecs\modules\qt_lib_bootstrap_private.pri \ 80 | C:\Qt\5.4.1\qtbase\mkspecs\modules\qt_lib_concurrent.pri \ 81 | C:\Qt\5.4.1\qtbase\mkspecs\modules\qt_lib_concurrent_private.pri \ 82 | C:\Qt\5.4.1\qtbase\mkspecs\modules\qt_lib_core.pri \ 83 | C:\Qt\5.4.1\qtbase\mkspecs\modules\qt_lib_core_private.pri \ 84 | C:\Qt\5.4.1\qtbase\mkspecs\modules\qt_lib_gui.pri \ 85 | C:\Qt\5.4.1\qtbase\mkspecs\modules\qt_lib_gui_private.pri \ 86 | C:\Qt\5.4.1\qtbase\mkspecs\modules\qt_lib_network.pri \ 87 | C:\Qt\5.4.1\qtbase\mkspecs\modules\qt_lib_network_private.pri \ 88 | C:\Qt\5.4.1\qtbase\mkspecs\modules\qt_lib_platformsupport_private.pri \ 89 | C:\Qt\5.4.1\qtbase\mkspecs\modules\qt_lib_printsupport.pri \ 90 | C:\Qt\5.4.1\qtbase\mkspecs\modules\qt_lib_printsupport_private.pri \ 91 | C:\Qt\5.4.1\qtbase\mkspecs\modules\qt_lib_sql.pri \ 92 | C:\Qt\5.4.1\qtbase\mkspecs\modules\qt_lib_sql_private.pri \ 93 | C:\Qt\5.4.1\qtbase\mkspecs\modules\qt_lib_testlib.pri \ 94 | C:\Qt\5.4.1\qtbase\mkspecs\modules\qt_lib_testlib_private.pri \ 95 | C:\Qt\5.4.1\qtbase\mkspecs\modules\qt_lib_widgets.pri \ 96 | C:\Qt\5.4.1\qtbase\mkspecs\modules\qt_lib_widgets_private.pri \ 97 | C:\Qt\5.4.1\qtbase\mkspecs\modules\qt_lib_xml.pri \ 98 | C:\Qt\5.4.1\qtbase\mkspecs\modules\qt_lib_xml_private.pri \ 99 | C:\Qt\5.4.1\qtbase\mkspecs\modules\qt_tool_qdoc.pri \ 100 | C:\Qt\5.4.1\qtbase\mkspecs\modules\qt_tool_qlalr.pri \ 101 | C:\Qt\5.4.1\qtbase\mkspecs\modules\qt_tool_syncqt.pri \ 102 | C:\Qt\5.4.1\qtbase\mkspecs\modules\qt_tool_uic.pri \ 103 | C:\Qt\5.4.1\qtbase\mkspecs\features\qt_functions.prf \ 104 | C:\Qt\5.4.1\qtbase\mkspecs\features\qt_config.prf \ 105 | C:\Qt\5.4.1\qtbase\mkspecs\features\win32\qt_config.prf \ 106 | C:\Qt\5.4.1\qtbase\mkspecs\win32-msvc2010\qmake.conf \ 107 | C:\Qt\5.4.1\qtbase\mkspecs\features\spec_post.prf \ 108 | C:\Qt\5.4.1\qtbase\mkspecs\features\exclusive_builds.prf \ 109 | C:\Qt\5.4.1\qtbase\mkspecs\features\default_pre.prf \ 110 | C:\Qt\5.4.1\qtbase\mkspecs\features\win32\default_pre.prf \ 111 | C:\Qt\5.4.1\qtbase\mkspecs\features\resolve_config.prf \ 112 | C:\Qt\5.4.1\qtbase\mkspecs\features\exclusive_builds_post.prf \ 113 | C:\Qt\5.4.1\qtbase\mkspecs\features\default_post.prf \ 114 | C:\Qt\5.4.1\qtbase\mkspecs\features\qt.prf \ 115 | C:\Qt\5.4.1\qtbase\mkspecs\features\resources.prf \ 116 | C:\Qt\5.4.1\qtbase\mkspecs\features\moc.prf \ 117 | C:\Qt\5.4.1\qtbase\mkspecs\features\uic.prf \ 118 | C:\Qt\5.4.1\qtbase\mkspecs\features\win32\rtti.prf \ 119 | C:\Qt\5.4.1\qtbase\mkspecs\features\precompile_header.prf \ 120 | C:\Qt\5.4.1\qtbase\mkspecs\features\warn_on.prf \ 121 | C:\Qt\5.4.1\qtbase\mkspecs\features\win32\windows.prf \ 122 | C:\Qt\5.4.1\qtbase\mkspecs\features\testcase_targets.prf \ 123 | C:\Qt\5.4.1\qtbase\mkspecs\features\exceptions.prf \ 124 | C:\Qt\5.4.1\qtbase\mkspecs\features\yacc.prf \ 125 | C:\Qt\5.4.1\qtbase\mkspecs\features\lex.prf \ 126 | x86emu.pro \ 127 | C:/Qt/5.4.1/qtbase/lib/Qt5Widgets.prl \ 128 | C:/Qt/5.4.1/qtbase/lib/Qt5Gui.prl \ 129 | C:/Qt/5.4.1/qtbase/lib/Qt5Core.prl 130 | $(QMAKE) -platform win32-msvc2010 -o Makefile.msvc x86emu.pro 131 | C:\Qt\5.4.1\qtbase\mkspecs\features\spec_pre.prf: 132 | C:\Qt\5.4.1\qtbase\mkspecs\common\shell-win32.conf: 133 | C:\Qt\5.4.1\qtbase\mkspecs\qconfig.pri: 134 | C:\Qt\5.4.1\qtbase\mkspecs\modules\qt_lib_bootstrap_private.pri: 135 | C:\Qt\5.4.1\qtbase\mkspecs\modules\qt_lib_concurrent.pri: 136 | C:\Qt\5.4.1\qtbase\mkspecs\modules\qt_lib_concurrent_private.pri: 137 | C:\Qt\5.4.1\qtbase\mkspecs\modules\qt_lib_core.pri: 138 | C:\Qt\5.4.1\qtbase\mkspecs\modules\qt_lib_core_private.pri: 139 | C:\Qt\5.4.1\qtbase\mkspecs\modules\qt_lib_gui.pri: 140 | C:\Qt\5.4.1\qtbase\mkspecs\modules\qt_lib_gui_private.pri: 141 | C:\Qt\5.4.1\qtbase\mkspecs\modules\qt_lib_network.pri: 142 | C:\Qt\5.4.1\qtbase\mkspecs\modules\qt_lib_network_private.pri: 143 | C:\Qt\5.4.1\qtbase\mkspecs\modules\qt_lib_platformsupport_private.pri: 144 | C:\Qt\5.4.1\qtbase\mkspecs\modules\qt_lib_printsupport.pri: 145 | C:\Qt\5.4.1\qtbase\mkspecs\modules\qt_lib_printsupport_private.pri: 146 | C:\Qt\5.4.1\qtbase\mkspecs\modules\qt_lib_sql.pri: 147 | C:\Qt\5.4.1\qtbase\mkspecs\modules\qt_lib_sql_private.pri: 148 | C:\Qt\5.4.1\qtbase\mkspecs\modules\qt_lib_testlib.pri: 149 | C:\Qt\5.4.1\qtbase\mkspecs\modules\qt_lib_testlib_private.pri: 150 | C:\Qt\5.4.1\qtbase\mkspecs\modules\qt_lib_widgets.pri: 151 | C:\Qt\5.4.1\qtbase\mkspecs\modules\qt_lib_widgets_private.pri: 152 | C:\Qt\5.4.1\qtbase\mkspecs\modules\qt_lib_xml.pri: 153 | C:\Qt\5.4.1\qtbase\mkspecs\modules\qt_lib_xml_private.pri: 154 | C:\Qt\5.4.1\qtbase\mkspecs\modules\qt_tool_qdoc.pri: 155 | C:\Qt\5.4.1\qtbase\mkspecs\modules\qt_tool_qlalr.pri: 156 | C:\Qt\5.4.1\qtbase\mkspecs\modules\qt_tool_syncqt.pri: 157 | C:\Qt\5.4.1\qtbase\mkspecs\modules\qt_tool_uic.pri: 158 | C:\Qt\5.4.1\qtbase\mkspecs\features\qt_functions.prf: 159 | C:\Qt\5.4.1\qtbase\mkspecs\features\qt_config.prf: 160 | C:\Qt\5.4.1\qtbase\mkspecs\features\win32\qt_config.prf: 161 | C:\Qt\5.4.1\qtbase\mkspecs\win32-msvc2010\qmake.conf: 162 | C:\Qt\5.4.1\qtbase\mkspecs\features\spec_post.prf: 163 | C:\Qt\5.4.1\qtbase\mkspecs\features\exclusive_builds.prf: 164 | C:\Qt\5.4.1\qtbase\mkspecs\features\default_pre.prf: 165 | C:\Qt\5.4.1\qtbase\mkspecs\features\win32\default_pre.prf: 166 | C:\Qt\5.4.1\qtbase\mkspecs\features\resolve_config.prf: 167 | C:\Qt\5.4.1\qtbase\mkspecs\features\exclusive_builds_post.prf: 168 | C:\Qt\5.4.1\qtbase\mkspecs\features\default_post.prf: 169 | C:\Qt\5.4.1\qtbase\mkspecs\features\qt.prf: 170 | C:\Qt\5.4.1\qtbase\mkspecs\features\resources.prf: 171 | C:\Qt\5.4.1\qtbase\mkspecs\features\moc.prf: 172 | C:\Qt\5.4.1\qtbase\mkspecs\features\uic.prf: 173 | C:\Qt\5.4.1\qtbase\mkspecs\features\win32\rtti.prf: 174 | C:\Qt\5.4.1\qtbase\mkspecs\features\precompile_header.prf: 175 | C:\Qt\5.4.1\qtbase\mkspecs\features\warn_on.prf: 176 | C:\Qt\5.4.1\qtbase\mkspecs\features\win32\windows.prf: 177 | C:\Qt\5.4.1\qtbase\mkspecs\features\testcase_targets.prf: 178 | C:\Qt\5.4.1\qtbase\mkspecs\features\exceptions.prf: 179 | C:\Qt\5.4.1\qtbase\mkspecs\features\yacc.prf: 180 | C:\Qt\5.4.1\qtbase\mkspecs\features\lex.prf: 181 | x86emu.pro: 182 | C:/Qt/5.4.1/qtbase/lib/Qt5Widgets.prl: 183 | C:/Qt/5.4.1/qtbase/lib/Qt5Gui.prl: 184 | C:/Qt/5.4.1/qtbase/lib/Qt5Core.prl: 185 | qmake: FORCE 186 | @$(QMAKE) -platform win32-msvc2010 -o Makefile.msvc x86emu.pro 187 | 188 | qmake_all: FORCE 189 | 190 | make_first: release-make_first debug-make_first FORCE 191 | all: release-all debug-all FORCE 192 | clean: release-clean debug-clean FORCE 193 | -$(DEL_FILE) .\bin\x86emu_qt.exp 194 | distclean: release-distclean debug-distclean FORCE 195 | -$(DEL_FILE) Makefile.msvc 196 | 197 | release-mocclean: 198 | @set MAKEFLAGS=$(MAKEFLAGS) 199 | $(MAKE) -f $(MAKEFILE).Release mocclean 200 | debug-mocclean: 201 | @set MAKEFLAGS=$(MAKEFLAGS) 202 | $(MAKE) -f $(MAKEFILE).Debug mocclean 203 | mocclean: release-mocclean debug-mocclean 204 | 205 | release-mocables: 206 | @set MAKEFLAGS=$(MAKEFLAGS) 207 | $(MAKE) -f $(MAKEFILE).Release mocables 208 | debug-mocables: 209 | @set MAKEFLAGS=$(MAKEFLAGS) 210 | $(MAKE) -f $(MAKEFILE).Debug mocables 211 | mocables: release-mocables debug-mocables 212 | 213 | check: first 214 | FORCE: 215 | 216 | $(MAKEFILE).Release: Makefile.msvc 217 | $(MAKEFILE).Debug: Makefile.msvc 218 | -------------------------------------------------------------------------------- /Makefile32-7.msvc: -------------------------------------------------------------------------------- 1 | ############################################################################# 2 | # Makefile for building: x86emu_qt 3 | # Generated by qmake (3.0) (Qt 5.4.1) 4 | # Project: x86emu32-7.pro 5 | # Template: lib 6 | # Command: C:\Qt\5.4.1\qtbase\bin\qmake.exe -platform win32-msvc2013 -o Makefile32-7.msvc x86emu32-7.pro 7 | ############################################################################# 8 | 9 | MAKEFILE = Makefile32-7.msvc 10 | 11 | first: release 12 | install: release-install 13 | uninstall: release-uninstall 14 | QMAKE = C:\Qt\5.4.1\qtbase\bin\qmake.exe 15 | DEL_FILE = del 16 | CHK_DIR_EXISTS= if not exist 17 | MKDIR = mkdir 18 | COPY = copy /y 19 | COPY_FILE = $(COPY) 20 | COPY_DIR = xcopy /s /q /y /i 21 | INSTALL_FILE = $(COPY_FILE) 22 | INSTALL_PROGRAM = $(COPY_FILE) 23 | INSTALL_DIR = $(COPY_DIR) 24 | DEL_FILE = del 25 | SYMLINK = copy /y 26 | DEL_DIR = rmdir 27 | MOVE = move 28 | SUBTARGETS = \ 29 | release \ 30 | debug 31 | 32 | 33 | release: FORCE 34 | @set MAKEFLAGS=$(MAKEFLAGS) 35 | $(MAKE) -f $(MAKEFILE).Release 36 | release-make_first: FORCE 37 | @set MAKEFLAGS=$(MAKEFLAGS) 38 | $(MAKE) -f $(MAKEFILE).Release 39 | release-all: FORCE 40 | @set MAKEFLAGS=$(MAKEFLAGS) 41 | $(MAKE) -f $(MAKEFILE).Release all 42 | release-clean: FORCE 43 | @set MAKEFLAGS=$(MAKEFLAGS) 44 | $(MAKE) -f $(MAKEFILE).Release clean 45 | release-distclean: FORCE 46 | @set MAKEFLAGS=$(MAKEFLAGS) 47 | $(MAKE) -f $(MAKEFILE).Release distclean 48 | release-install: FORCE 49 | @set MAKEFLAGS=$(MAKEFLAGS) 50 | $(MAKE) -f $(MAKEFILE).Release install 51 | release-uninstall: FORCE 52 | @set MAKEFLAGS=$(MAKEFLAGS) 53 | $(MAKE) -f $(MAKEFILE).Release uninstall 54 | debug: FORCE 55 | @set MAKEFLAGS=$(MAKEFLAGS) 56 | $(MAKE) -f $(MAKEFILE).Debug 57 | debug-make_first: FORCE 58 | @set MAKEFLAGS=$(MAKEFLAGS) 59 | $(MAKE) -f $(MAKEFILE).Debug 60 | debug-all: FORCE 61 | @set MAKEFLAGS=$(MAKEFLAGS) 62 | $(MAKE) -f $(MAKEFILE).Debug all 63 | debug-clean: FORCE 64 | @set MAKEFLAGS=$(MAKEFLAGS) 65 | $(MAKE) -f $(MAKEFILE).Debug clean 66 | debug-distclean: FORCE 67 | @set MAKEFLAGS=$(MAKEFLAGS) 68 | $(MAKE) -f $(MAKEFILE).Debug distclean 69 | debug-install: FORCE 70 | @set MAKEFLAGS=$(MAKEFLAGS) 71 | $(MAKE) -f $(MAKEFILE).Debug install 72 | debug-uninstall: FORCE 73 | @set MAKEFLAGS=$(MAKEFLAGS) 74 | $(MAKE) -f $(MAKEFILE).Debug uninstall 75 | 76 | Makefile32-7.msvc: x86emu32-7.pro C:\Qt\5.4.1\qtbase\mkspecs\win32-msvc2013\qmake.conf C:\Qt\5.4.1\qtbase\mkspecs\features\spec_pre.prf \ 77 | C:\Qt\5.4.1\qtbase\mkspecs\common\shell-win32.conf \ 78 | C:\Qt\5.4.1\qtbase\mkspecs\qconfig.pri \ 79 | C:\Qt\5.4.1\qtbase\mkspecs\modules\qt_lib_bootstrap_private.pri \ 80 | C:\Qt\5.4.1\qtbase\mkspecs\modules\qt_lib_concurrent.pri \ 81 | C:\Qt\5.4.1\qtbase\mkspecs\modules\qt_lib_concurrent_private.pri \ 82 | C:\Qt\5.4.1\qtbase\mkspecs\modules\qt_lib_core.pri \ 83 | C:\Qt\5.4.1\qtbase\mkspecs\modules\qt_lib_core_private.pri \ 84 | C:\Qt\5.4.1\qtbase\mkspecs\modules\qt_lib_gui.pri \ 85 | C:\Qt\5.4.1\qtbase\mkspecs\modules\qt_lib_gui_private.pri \ 86 | C:\Qt\5.4.1\qtbase\mkspecs\modules\qt_lib_network.pri \ 87 | C:\Qt\5.4.1\qtbase\mkspecs\modules\qt_lib_network_private.pri \ 88 | C:\Qt\5.4.1\qtbase\mkspecs\modules\qt_lib_platformsupport_private.pri \ 89 | C:\Qt\5.4.1\qtbase\mkspecs\modules\qt_lib_printsupport.pri \ 90 | C:\Qt\5.4.1\qtbase\mkspecs\modules\qt_lib_printsupport_private.pri \ 91 | C:\Qt\5.4.1\qtbase\mkspecs\modules\qt_lib_sql.pri \ 92 | C:\Qt\5.4.1\qtbase\mkspecs\modules\qt_lib_sql_private.pri \ 93 | C:\Qt\5.4.1\qtbase\mkspecs\modules\qt_lib_testlib.pri \ 94 | C:\Qt\5.4.1\qtbase\mkspecs\modules\qt_lib_testlib_private.pri \ 95 | C:\Qt\5.4.1\qtbase\mkspecs\modules\qt_lib_widgets.pri \ 96 | C:\Qt\5.4.1\qtbase\mkspecs\modules\qt_lib_widgets_private.pri \ 97 | C:\Qt\5.4.1\qtbase\mkspecs\modules\qt_lib_xml.pri \ 98 | C:\Qt\5.4.1\qtbase\mkspecs\modules\qt_lib_xml_private.pri \ 99 | C:\Qt\5.4.1\qtbase\mkspecs\modules\qt_tool_qdoc.pri \ 100 | C:\Qt\5.4.1\qtbase\mkspecs\modules\qt_tool_qlalr.pri \ 101 | C:\Qt\5.4.1\qtbase\mkspecs\modules\qt_tool_syncqt.pri \ 102 | C:\Qt\5.4.1\qtbase\mkspecs\modules\qt_tool_uic.pri \ 103 | C:\Qt\5.4.1\qtbase\mkspecs\features\qt_functions.prf \ 104 | C:\Qt\5.4.1\qtbase\mkspecs\features\qt_config.prf \ 105 | C:\Qt\5.4.1\qtbase\mkspecs\features\win32\qt_config.prf \ 106 | C:\Qt\5.4.1\qtbase\mkspecs\win32-msvc2013\qmake.conf \ 107 | C:\Qt\5.4.1\qtbase\mkspecs\features\spec_post.prf \ 108 | C:\Qt\5.4.1\qtbase\mkspecs\features\exclusive_builds.prf \ 109 | C:\Qt\5.4.1\qtbase\mkspecs\features\default_pre.prf \ 110 | C:\Qt\5.4.1\qtbase\mkspecs\features\win32\default_pre.prf \ 111 | C:\Qt\5.4.1\qtbase\mkspecs\features\resolve_config.prf \ 112 | C:\Qt\5.4.1\qtbase\mkspecs\features\exclusive_builds_post.prf \ 113 | C:\Qt\5.4.1\qtbase\mkspecs\features\default_post.prf \ 114 | C:\Qt\5.4.1\qtbase\mkspecs\features\qt.prf \ 115 | C:\Qt\5.4.1\qtbase\mkspecs\features\resources.prf \ 116 | C:\Qt\5.4.1\qtbase\mkspecs\features\moc.prf \ 117 | C:\Qt\5.4.1\qtbase\mkspecs\features\uic.prf \ 118 | C:\Qt\5.4.1\qtbase\mkspecs\features\win32\rtti.prf \ 119 | C:\Qt\5.4.1\qtbase\mkspecs\features\precompile_header.prf \ 120 | C:\Qt\5.4.1\qtbase\mkspecs\features\warn_on.prf \ 121 | C:\Qt\5.4.1\qtbase\mkspecs\features\win32\windows.prf \ 122 | C:\Qt\5.4.1\qtbase\mkspecs\features\testcase_targets.prf \ 123 | C:\Qt\5.4.1\qtbase\mkspecs\features\exceptions.prf \ 124 | C:\Qt\5.4.1\qtbase\mkspecs\features\yacc.prf \ 125 | C:\Qt\5.4.1\qtbase\mkspecs\features\lex.prf \ 126 | x86emu32-7.pro 127 | $(QMAKE) -platform win32-msvc2013 -o Makefile32-7.msvc x86emu32-7.pro 128 | C:\Qt\5.4.1\qtbase\mkspecs\features\spec_pre.prf: 129 | C:\Qt\5.4.1\qtbase\mkspecs\common\shell-win32.conf: 130 | C:\Qt\5.4.1\qtbase\mkspecs\qconfig.pri: 131 | C:\Qt\5.4.1\qtbase\mkspecs\modules\qt_lib_bootstrap_private.pri: 132 | C:\Qt\5.4.1\qtbase\mkspecs\modules\qt_lib_concurrent.pri: 133 | C:\Qt\5.4.1\qtbase\mkspecs\modules\qt_lib_concurrent_private.pri: 134 | C:\Qt\5.4.1\qtbase\mkspecs\modules\qt_lib_core.pri: 135 | C:\Qt\5.4.1\qtbase\mkspecs\modules\qt_lib_core_private.pri: 136 | C:\Qt\5.4.1\qtbase\mkspecs\modules\qt_lib_gui.pri: 137 | C:\Qt\5.4.1\qtbase\mkspecs\modules\qt_lib_gui_private.pri: 138 | C:\Qt\5.4.1\qtbase\mkspecs\modules\qt_lib_network.pri: 139 | C:\Qt\5.4.1\qtbase\mkspecs\modules\qt_lib_network_private.pri: 140 | C:\Qt\5.4.1\qtbase\mkspecs\modules\qt_lib_platformsupport_private.pri: 141 | C:\Qt\5.4.1\qtbase\mkspecs\modules\qt_lib_printsupport.pri: 142 | C:\Qt\5.4.1\qtbase\mkspecs\modules\qt_lib_printsupport_private.pri: 143 | C:\Qt\5.4.1\qtbase\mkspecs\modules\qt_lib_sql.pri: 144 | C:\Qt\5.4.1\qtbase\mkspecs\modules\qt_lib_sql_private.pri: 145 | C:\Qt\5.4.1\qtbase\mkspecs\modules\qt_lib_testlib.pri: 146 | C:\Qt\5.4.1\qtbase\mkspecs\modules\qt_lib_testlib_private.pri: 147 | C:\Qt\5.4.1\qtbase\mkspecs\modules\qt_lib_widgets.pri: 148 | C:\Qt\5.4.1\qtbase\mkspecs\modules\qt_lib_widgets_private.pri: 149 | C:\Qt\5.4.1\qtbase\mkspecs\modules\qt_lib_xml.pri: 150 | C:\Qt\5.4.1\qtbase\mkspecs\modules\qt_lib_xml_private.pri: 151 | C:\Qt\5.4.1\qtbase\mkspecs\modules\qt_tool_qdoc.pri: 152 | C:\Qt\5.4.1\qtbase\mkspecs\modules\qt_tool_qlalr.pri: 153 | C:\Qt\5.4.1\qtbase\mkspecs\modules\qt_tool_syncqt.pri: 154 | C:\Qt\5.4.1\qtbase\mkspecs\modules\qt_tool_uic.pri: 155 | C:\Qt\5.4.1\qtbase\mkspecs\features\qt_functions.prf: 156 | C:\Qt\5.4.1\qtbase\mkspecs\features\qt_config.prf: 157 | C:\Qt\5.4.1\qtbase\mkspecs\features\win32\qt_config.prf: 158 | C:\Qt\5.4.1\qtbase\mkspecs\win32-msvc2013\qmake.conf: 159 | C:\Qt\5.4.1\qtbase\mkspecs\features\spec_post.prf: 160 | C:\Qt\5.4.1\qtbase\mkspecs\features\exclusive_builds.prf: 161 | C:\Qt\5.4.1\qtbase\mkspecs\features\default_pre.prf: 162 | C:\Qt\5.4.1\qtbase\mkspecs\features\win32\default_pre.prf: 163 | C:\Qt\5.4.1\qtbase\mkspecs\features\resolve_config.prf: 164 | C:\Qt\5.4.1\qtbase\mkspecs\features\exclusive_builds_post.prf: 165 | C:\Qt\5.4.1\qtbase\mkspecs\features\default_post.prf: 166 | C:\Qt\5.4.1\qtbase\mkspecs\features\qt.prf: 167 | C:\Qt\5.4.1\qtbase\mkspecs\features\resources.prf: 168 | C:\Qt\5.4.1\qtbase\mkspecs\features\moc.prf: 169 | C:\Qt\5.4.1\qtbase\mkspecs\features\uic.prf: 170 | C:\Qt\5.4.1\qtbase\mkspecs\features\win32\rtti.prf: 171 | C:\Qt\5.4.1\qtbase\mkspecs\features\precompile_header.prf: 172 | C:\Qt\5.4.1\qtbase\mkspecs\features\warn_on.prf: 173 | C:\Qt\5.4.1\qtbase\mkspecs\features\win32\windows.prf: 174 | C:\Qt\5.4.1\qtbase\mkspecs\features\testcase_targets.prf: 175 | C:\Qt\5.4.1\qtbase\mkspecs\features\exceptions.prf: 176 | C:\Qt\5.4.1\qtbase\mkspecs\features\yacc.prf: 177 | C:\Qt\5.4.1\qtbase\mkspecs\features\lex.prf: 178 | x86emu32-7.pro: 179 | qmake: FORCE 180 | @$(QMAKE) -platform win32-msvc2013 -o Makefile32-7.msvc x86emu32-7.pro 181 | 182 | qmake_all: FORCE 183 | 184 | make_first: release-make_first debug-make_first FORCE 185 | all: release-all debug-all FORCE 186 | clean: release-clean debug-clean FORCE 187 | -$(DEL_FILE) bin\x86emu_qt.exp 188 | distclean: release-distclean debug-distclean FORCE 189 | -$(DEL_FILE) Makefile32-7.msvc 190 | 191 | release-mocclean: 192 | @set MAKEFLAGS=$(MAKEFLAGS) 193 | $(MAKE) -f $(MAKEFILE).Release mocclean 194 | debug-mocclean: 195 | @set MAKEFLAGS=$(MAKEFLAGS) 196 | $(MAKE) -f $(MAKEFILE).Debug mocclean 197 | mocclean: release-mocclean debug-mocclean 198 | 199 | release-mocables: 200 | @set MAKEFLAGS=$(MAKEFLAGS) 201 | $(MAKE) -f $(MAKEFILE).Release mocables 202 | debug-mocables: 203 | @set MAKEFLAGS=$(MAKEFLAGS) 204 | $(MAKE) -f $(MAKEFILE).Debug mocables 205 | mocables: release-mocables debug-mocables 206 | 207 | check: first 208 | FORCE: 209 | 210 | $(MAKEFILE).Release: Makefile32-7.msvc 211 | $(MAKEFILE).Debug: Makefile32-7.msvc 212 | -------------------------------------------------------------------------------- /Makefile64-7.msvc: -------------------------------------------------------------------------------- 1 | ############################################################################# 2 | # Makefile for building: x86emu_qt64 3 | # Generated by qmake (3.0) (Qt 5.4.1) 4 | # Project: x86emu64-7.pro 5 | # Template: lib 6 | # Command: C:\Qt\5.4.1\qtbase\bin\qmake.exe -platform win32-msvc2013 -o Makefile64-7.msvc x86emu64-7.pro 7 | ############################################################################# 8 | 9 | MAKEFILE = Makefile64-7.msvc 10 | 11 | first: release 12 | install: release-install 13 | uninstall: release-uninstall 14 | QMAKE = C:\Qt\5.4.1\qtbase\bin\qmake.exe 15 | DEL_FILE = del 16 | CHK_DIR_EXISTS= if not exist 17 | MKDIR = mkdir 18 | COPY = copy /y 19 | COPY_FILE = $(COPY) 20 | COPY_DIR = xcopy /s /q /y /i 21 | INSTALL_FILE = $(COPY_FILE) 22 | INSTALL_PROGRAM = $(COPY_FILE) 23 | INSTALL_DIR = $(COPY_DIR) 24 | DEL_FILE = del 25 | SYMLINK = copy /y 26 | DEL_DIR = rmdir 27 | MOVE = move 28 | SUBTARGETS = \ 29 | release \ 30 | debug 31 | 32 | 33 | release: FORCE 34 | @set MAKEFLAGS=$(MAKEFLAGS) 35 | $(MAKE) -f $(MAKEFILE).Release 36 | release-make_first: FORCE 37 | @set MAKEFLAGS=$(MAKEFLAGS) 38 | $(MAKE) -f $(MAKEFILE).Release 39 | release-all: FORCE 40 | @set MAKEFLAGS=$(MAKEFLAGS) 41 | $(MAKE) -f $(MAKEFILE).Release all 42 | release-clean: FORCE 43 | @set MAKEFLAGS=$(MAKEFLAGS) 44 | $(MAKE) -f $(MAKEFILE).Release clean 45 | release-distclean: FORCE 46 | @set MAKEFLAGS=$(MAKEFLAGS) 47 | $(MAKE) -f $(MAKEFILE).Release distclean 48 | release-install: FORCE 49 | @set MAKEFLAGS=$(MAKEFLAGS) 50 | $(MAKE) -f $(MAKEFILE).Release install 51 | release-uninstall: FORCE 52 | @set MAKEFLAGS=$(MAKEFLAGS) 53 | $(MAKE) -f $(MAKEFILE).Release uninstall 54 | debug: FORCE 55 | @set MAKEFLAGS=$(MAKEFLAGS) 56 | $(MAKE) -f $(MAKEFILE).Debug 57 | debug-make_first: FORCE 58 | @set MAKEFLAGS=$(MAKEFLAGS) 59 | $(MAKE) -f $(MAKEFILE).Debug 60 | debug-all: FORCE 61 | @set MAKEFLAGS=$(MAKEFLAGS) 62 | $(MAKE) -f $(MAKEFILE).Debug all 63 | debug-clean: FORCE 64 | @set MAKEFLAGS=$(MAKEFLAGS) 65 | $(MAKE) -f $(MAKEFILE).Debug clean 66 | debug-distclean: FORCE 67 | @set MAKEFLAGS=$(MAKEFLAGS) 68 | $(MAKE) -f $(MAKEFILE).Debug distclean 69 | debug-install: FORCE 70 | @set MAKEFLAGS=$(MAKEFLAGS) 71 | $(MAKE) -f $(MAKEFILE).Debug install 72 | debug-uninstall: FORCE 73 | @set MAKEFLAGS=$(MAKEFLAGS) 74 | $(MAKE) -f $(MAKEFILE).Debug uninstall 75 | 76 | Makefile64-7.msvc: x86emu64-7.pro C:\Qt\5.4.1\qtbase\mkspecs\win32-msvc2013\qmake.conf C:\Qt\5.4.1\qtbase\mkspecs\features\spec_pre.prf \ 77 | C:\Qt\5.4.1\qtbase\mkspecs\common\shell-win32.conf \ 78 | C:\Qt\5.4.1\qtbase\mkspecs\qconfig.pri \ 79 | C:\Qt\5.4.1\qtbase\mkspecs\modules\qt_lib_bootstrap_private.pri \ 80 | C:\Qt\5.4.1\qtbase\mkspecs\modules\qt_lib_concurrent.pri \ 81 | C:\Qt\5.4.1\qtbase\mkspecs\modules\qt_lib_concurrent_private.pri \ 82 | C:\Qt\5.4.1\qtbase\mkspecs\modules\qt_lib_core.pri \ 83 | C:\Qt\5.4.1\qtbase\mkspecs\modules\qt_lib_core_private.pri \ 84 | C:\Qt\5.4.1\qtbase\mkspecs\modules\qt_lib_gui.pri \ 85 | C:\Qt\5.4.1\qtbase\mkspecs\modules\qt_lib_gui_private.pri \ 86 | C:\Qt\5.4.1\qtbase\mkspecs\modules\qt_lib_network.pri \ 87 | C:\Qt\5.4.1\qtbase\mkspecs\modules\qt_lib_network_private.pri \ 88 | C:\Qt\5.4.1\qtbase\mkspecs\modules\qt_lib_platformsupport_private.pri \ 89 | C:\Qt\5.4.1\qtbase\mkspecs\modules\qt_lib_printsupport.pri \ 90 | C:\Qt\5.4.1\qtbase\mkspecs\modules\qt_lib_printsupport_private.pri \ 91 | C:\Qt\5.4.1\qtbase\mkspecs\modules\qt_lib_sql.pri \ 92 | C:\Qt\5.4.1\qtbase\mkspecs\modules\qt_lib_sql_private.pri \ 93 | C:\Qt\5.4.1\qtbase\mkspecs\modules\qt_lib_testlib.pri \ 94 | C:\Qt\5.4.1\qtbase\mkspecs\modules\qt_lib_testlib_private.pri \ 95 | C:\Qt\5.4.1\qtbase\mkspecs\modules\qt_lib_widgets.pri \ 96 | C:\Qt\5.4.1\qtbase\mkspecs\modules\qt_lib_widgets_private.pri \ 97 | C:\Qt\5.4.1\qtbase\mkspecs\modules\qt_lib_xml.pri \ 98 | C:\Qt\5.4.1\qtbase\mkspecs\modules\qt_lib_xml_private.pri \ 99 | C:\Qt\5.4.1\qtbase\mkspecs\modules\qt_tool_qdoc.pri \ 100 | C:\Qt\5.4.1\qtbase\mkspecs\modules\qt_tool_qlalr.pri \ 101 | C:\Qt\5.4.1\qtbase\mkspecs\modules\qt_tool_syncqt.pri \ 102 | C:\Qt\5.4.1\qtbase\mkspecs\modules\qt_tool_uic.pri \ 103 | C:\Qt\5.4.1\qtbase\mkspecs\features\qt_functions.prf \ 104 | C:\Qt\5.4.1\qtbase\mkspecs\features\qt_config.prf \ 105 | C:\Qt\5.4.1\qtbase\mkspecs\features\win32\qt_config.prf \ 106 | C:\Qt\5.4.1\qtbase\mkspecs\win32-msvc2013\qmake.conf \ 107 | C:\Qt\5.4.1\qtbase\mkspecs\features\spec_post.prf \ 108 | C:\Qt\5.4.1\qtbase\mkspecs\features\exclusive_builds.prf \ 109 | C:\Qt\5.4.1\qtbase\mkspecs\features\default_pre.prf \ 110 | C:\Qt\5.4.1\qtbase\mkspecs\features\win32\default_pre.prf \ 111 | C:\Qt\5.4.1\qtbase\mkspecs\features\resolve_config.prf \ 112 | C:\Qt\5.4.1\qtbase\mkspecs\features\exclusive_builds_post.prf \ 113 | C:\Qt\5.4.1\qtbase\mkspecs\features\default_post.prf \ 114 | C:\Qt\5.4.1\qtbase\mkspecs\features\qt.prf \ 115 | C:\Qt\5.4.1\qtbase\mkspecs\features\resources.prf \ 116 | C:\Qt\5.4.1\qtbase\mkspecs\features\moc.prf \ 117 | C:\Qt\5.4.1\qtbase\mkspecs\features\uic.prf \ 118 | C:\Qt\5.4.1\qtbase\mkspecs\features\win32\rtti.prf \ 119 | C:\Qt\5.4.1\qtbase\mkspecs\features\precompile_header.prf \ 120 | C:\Qt\5.4.1\qtbase\mkspecs\features\warn_on.prf \ 121 | C:\Qt\5.4.1\qtbase\mkspecs\features\win32\windows.prf \ 122 | C:\Qt\5.4.1\qtbase\mkspecs\features\testcase_targets.prf \ 123 | C:\Qt\5.4.1\qtbase\mkspecs\features\exceptions.prf \ 124 | C:\Qt\5.4.1\qtbase\mkspecs\features\yacc.prf \ 125 | C:\Qt\5.4.1\qtbase\mkspecs\features\lex.prf \ 126 | x86emu64-7.pro 127 | $(QMAKE) -platform win32-msvc2013 -o Makefile64-7.msvc x86emu64-7.pro 128 | C:\Qt\5.4.1\qtbase\mkspecs\features\spec_pre.prf: 129 | C:\Qt\5.4.1\qtbase\mkspecs\common\shell-win32.conf: 130 | C:\Qt\5.4.1\qtbase\mkspecs\qconfig.pri: 131 | C:\Qt\5.4.1\qtbase\mkspecs\modules\qt_lib_bootstrap_private.pri: 132 | C:\Qt\5.4.1\qtbase\mkspecs\modules\qt_lib_concurrent.pri: 133 | C:\Qt\5.4.1\qtbase\mkspecs\modules\qt_lib_concurrent_private.pri: 134 | C:\Qt\5.4.1\qtbase\mkspecs\modules\qt_lib_core.pri: 135 | C:\Qt\5.4.1\qtbase\mkspecs\modules\qt_lib_core_private.pri: 136 | C:\Qt\5.4.1\qtbase\mkspecs\modules\qt_lib_gui.pri: 137 | C:\Qt\5.4.1\qtbase\mkspecs\modules\qt_lib_gui_private.pri: 138 | C:\Qt\5.4.1\qtbase\mkspecs\modules\qt_lib_network.pri: 139 | C:\Qt\5.4.1\qtbase\mkspecs\modules\qt_lib_network_private.pri: 140 | C:\Qt\5.4.1\qtbase\mkspecs\modules\qt_lib_platformsupport_private.pri: 141 | C:\Qt\5.4.1\qtbase\mkspecs\modules\qt_lib_printsupport.pri: 142 | C:\Qt\5.4.1\qtbase\mkspecs\modules\qt_lib_printsupport_private.pri: 143 | C:\Qt\5.4.1\qtbase\mkspecs\modules\qt_lib_sql.pri: 144 | C:\Qt\5.4.1\qtbase\mkspecs\modules\qt_lib_sql_private.pri: 145 | C:\Qt\5.4.1\qtbase\mkspecs\modules\qt_lib_testlib.pri: 146 | C:\Qt\5.4.1\qtbase\mkspecs\modules\qt_lib_testlib_private.pri: 147 | C:\Qt\5.4.1\qtbase\mkspecs\modules\qt_lib_widgets.pri: 148 | C:\Qt\5.4.1\qtbase\mkspecs\modules\qt_lib_widgets_private.pri: 149 | C:\Qt\5.4.1\qtbase\mkspecs\modules\qt_lib_xml.pri: 150 | C:\Qt\5.4.1\qtbase\mkspecs\modules\qt_lib_xml_private.pri: 151 | C:\Qt\5.4.1\qtbase\mkspecs\modules\qt_tool_qdoc.pri: 152 | C:\Qt\5.4.1\qtbase\mkspecs\modules\qt_tool_qlalr.pri: 153 | C:\Qt\5.4.1\qtbase\mkspecs\modules\qt_tool_syncqt.pri: 154 | C:\Qt\5.4.1\qtbase\mkspecs\modules\qt_tool_uic.pri: 155 | C:\Qt\5.4.1\qtbase\mkspecs\features\qt_functions.prf: 156 | C:\Qt\5.4.1\qtbase\mkspecs\features\qt_config.prf: 157 | C:\Qt\5.4.1\qtbase\mkspecs\features\win32\qt_config.prf: 158 | C:\Qt\5.4.1\qtbase\mkspecs\win32-msvc2013\qmake.conf: 159 | C:\Qt\5.4.1\qtbase\mkspecs\features\spec_post.prf: 160 | C:\Qt\5.4.1\qtbase\mkspecs\features\exclusive_builds.prf: 161 | C:\Qt\5.4.1\qtbase\mkspecs\features\default_pre.prf: 162 | C:\Qt\5.4.1\qtbase\mkspecs\features\win32\default_pre.prf: 163 | C:\Qt\5.4.1\qtbase\mkspecs\features\resolve_config.prf: 164 | C:\Qt\5.4.1\qtbase\mkspecs\features\exclusive_builds_post.prf: 165 | C:\Qt\5.4.1\qtbase\mkspecs\features\default_post.prf: 166 | C:\Qt\5.4.1\qtbase\mkspecs\features\qt.prf: 167 | C:\Qt\5.4.1\qtbase\mkspecs\features\resources.prf: 168 | C:\Qt\5.4.1\qtbase\mkspecs\features\moc.prf: 169 | C:\Qt\5.4.1\qtbase\mkspecs\features\uic.prf: 170 | C:\Qt\5.4.1\qtbase\mkspecs\features\win32\rtti.prf: 171 | C:\Qt\5.4.1\qtbase\mkspecs\features\precompile_header.prf: 172 | C:\Qt\5.4.1\qtbase\mkspecs\features\warn_on.prf: 173 | C:\Qt\5.4.1\qtbase\mkspecs\features\win32\windows.prf: 174 | C:\Qt\5.4.1\qtbase\mkspecs\features\testcase_targets.prf: 175 | C:\Qt\5.4.1\qtbase\mkspecs\features\exceptions.prf: 176 | C:\Qt\5.4.1\qtbase\mkspecs\features\yacc.prf: 177 | C:\Qt\5.4.1\qtbase\mkspecs\features\lex.prf: 178 | x86emu64-7.pro: 179 | qmake: FORCE 180 | @$(QMAKE) -platform win32-msvc2013 -o Makefile64-7.msvc x86emu64-7.pro 181 | 182 | qmake_all: FORCE 183 | 184 | make_first: release-make_first debug-make_first FORCE 185 | all: release-all debug-all FORCE 186 | clean: release-clean debug-clean FORCE 187 | -$(DEL_FILE) bin\x86emu_qt64.exp 188 | distclean: release-distclean debug-distclean FORCE 189 | -$(DEL_FILE) Makefile64-7.msvc 190 | 191 | release-mocclean: 192 | @set MAKEFLAGS=$(MAKEFLAGS) 193 | $(MAKE) -f $(MAKEFILE).Release mocclean 194 | debug-mocclean: 195 | @set MAKEFLAGS=$(MAKEFLAGS) 196 | $(MAKE) -f $(MAKEFILE).Debug mocclean 197 | mocclean: release-mocclean debug-mocclean 198 | 199 | release-mocables: 200 | @set MAKEFLAGS=$(MAKEFLAGS) 201 | $(MAKE) -f $(MAKEFILE).Release mocables 202 | debug-mocables: 203 | @set MAKEFLAGS=$(MAKEFLAGS) 204 | $(MAKE) -f $(MAKEFILE).Debug mocables 205 | mocables: release-mocables debug-mocables 206 | 207 | check: first 208 | FORCE: 209 | 210 | $(MAKEFILE).Release: Makefile64-7.msvc 211 | $(MAKEFILE).Debug: Makefile64-7.msvc 212 | -------------------------------------------------------------------------------- /Makefile64.msvc: -------------------------------------------------------------------------------- 1 | ############################################################################# 2 | # Makefile for building: x86emu_qt 3 | # Generated by qmake (2.01a) (Qt 4.6.3) on: Wed Jul 5 23:51:33 2017 4 | # Project: x86emu64.pro 5 | # Template: lib 6 | # Command: c:\Qt\4.6.3\bin\qmake.exe -spec c:\Qt\4.6.3\mkspecs\win32-msvc2010 -win32 -o Makefile64.msvc x86emu64.pro 7 | ############################################################################# 8 | 9 | first: release 10 | install: release-install 11 | uninstall: release-uninstall 12 | MAKEFILE = Makefile64.msvc 13 | QMAKE = c:\Qt\4.6.3\bin\qmake.exe 14 | DEL_FILE = del 15 | CHK_DIR_EXISTS= if not exist 16 | MKDIR = mkdir 17 | COPY = copy /y 18 | COPY_FILE = $(COPY) 19 | COPY_DIR = xcopy /s /q /y /i 20 | INSTALL_FILE = $(COPY_FILE) 21 | INSTALL_PROGRAM = $(COPY_FILE) 22 | INSTALL_DIR = $(COPY_DIR) 23 | DEL_FILE = del 24 | SYMLINK = 25 | DEL_DIR = rmdir 26 | MOVE = move 27 | CHK_DIR_EXISTS= if not exist 28 | MKDIR = mkdir 29 | SUBTARGETS = \ 30 | release \ 31 | debug 32 | 33 | release: $(MAKEFILE).Release FORCE 34 | $(MAKE) -f $(MAKEFILE).Release 35 | release-make_default: $(MAKEFILE).Release FORCE 36 | $(MAKE) -f $(MAKEFILE).Release 37 | release-make_first: $(MAKEFILE).Release FORCE 38 | $(MAKE) -f $(MAKEFILE).Release first 39 | release-all: $(MAKEFILE).Release FORCE 40 | $(MAKE) -f $(MAKEFILE).Release all 41 | release-clean: $(MAKEFILE).Release FORCE 42 | $(MAKE) -f $(MAKEFILE).Release clean 43 | release-distclean: $(MAKEFILE).Release FORCE 44 | $(MAKE) -f $(MAKEFILE).Release distclean 45 | release-install: $(MAKEFILE).Release FORCE 46 | $(MAKE) -f $(MAKEFILE).Release install 47 | release-uninstall: $(MAKEFILE).Release FORCE 48 | $(MAKE) -f $(MAKEFILE).Release uninstall 49 | debug: $(MAKEFILE).Debug FORCE 50 | $(MAKE) -f $(MAKEFILE).Debug 51 | debug-make_default: $(MAKEFILE).Debug FORCE 52 | $(MAKE) -f $(MAKEFILE).Debug 53 | debug-make_first: $(MAKEFILE).Debug FORCE 54 | $(MAKE) -f $(MAKEFILE).Debug first 55 | debug-all: $(MAKEFILE).Debug FORCE 56 | $(MAKE) -f $(MAKEFILE).Debug all 57 | debug-clean: $(MAKEFILE).Debug FORCE 58 | $(MAKE) -f $(MAKEFILE).Debug clean 59 | debug-distclean: $(MAKEFILE).Debug FORCE 60 | $(MAKE) -f $(MAKEFILE).Debug distclean 61 | debug-install: $(MAKEFILE).Debug FORCE 62 | $(MAKE) -f $(MAKEFILE).Debug install 63 | debug-uninstall: $(MAKEFILE).Debug FORCE 64 | $(MAKE) -f $(MAKEFILE).Debug uninstall 65 | 66 | Makefile64.msvc: x86emu64.pro c:\Qt\4.6.3\mkspecs\win32-msvc2010\qmake.conf c:\Qt\4.6.3\mkspecs\qconfig.pri \ 67 | c:\Qt\4.6.3\mkspecs\features\qt_functions.prf \ 68 | c:\Qt\4.6.3\mkspecs\features\qt_config.prf \ 69 | c:\Qt\4.6.3\mkspecs\features\exclusive_builds.prf \ 70 | c:\Qt\4.6.3\mkspecs\features\default_pre.prf \ 71 | c:\Qt\4.6.3\mkspecs\features\win32\default_pre.prf \ 72 | c:\Qt\4.6.3\mkspecs\features\release.prf \ 73 | c:\Qt\4.6.3\mkspecs\features\debug_and_release.prf \ 74 | c:\Qt\4.6.3\mkspecs\features\default_post.prf \ 75 | c:\Qt\4.6.3\mkspecs\features\win32\default_post.prf \ 76 | c:\Qt\4.6.3\mkspecs\features\dll.prf \ 77 | c:\Qt\4.6.3\mkspecs\features\shared.prf \ 78 | c:\Qt\4.6.3\mkspecs\features\qt.prf \ 79 | c:\Qt\4.6.3\mkspecs\features\win32\thread.prf \ 80 | c:\Qt\4.6.3\mkspecs\features\moc.prf \ 81 | c:\Qt\4.6.3\mkspecs\features\win32\rtti.prf \ 82 | c:\Qt\4.6.3\mkspecs\features\win32\exceptions.prf \ 83 | c:\Qt\4.6.3\mkspecs\features\win32\stl.prf \ 84 | c:\Qt\4.6.3\mkspecs\features\win32\embed_manifest_exe.prf \ 85 | c:\Qt\4.6.3\mkspecs\features\win32\embed_manifest_dll.prf \ 86 | c:\Qt\4.6.3\mkspecs\features\warn_on.prf \ 87 | c:\Qt\4.6.3\mkspecs\features\win32\windows.prf \ 88 | c:\Qt\4.6.3\mkspecs\features\resources.prf \ 89 | c:\Qt\4.6.3\mkspecs\features\uic.prf \ 90 | c:\Qt\4.6.3\mkspecs\features\yacc.prf \ 91 | c:\Qt\4.6.3\mkspecs\features\lex.prf \ 92 | c:\Qt\4.6.3\mkspecs\features\include_source_dir.prf 93 | $(QMAKE) -spec c:\Qt\4.6.3\mkspecs\win32-msvc2010 -win32 -o Makefile64.msvc x86emu64.pro 94 | c:\Qt\4.6.3\mkspecs\qconfig.pri: 95 | c:\Qt\4.6.3\mkspecs\features\qt_functions.prf: 96 | c:\Qt\4.6.3\mkspecs\features\qt_config.prf: 97 | c:\Qt\4.6.3\mkspecs\features\exclusive_builds.prf: 98 | c:\Qt\4.6.3\mkspecs\features\default_pre.prf: 99 | c:\Qt\4.6.3\mkspecs\features\win32\default_pre.prf: 100 | c:\Qt\4.6.3\mkspecs\features\release.prf: 101 | c:\Qt\4.6.3\mkspecs\features\debug_and_release.prf: 102 | c:\Qt\4.6.3\mkspecs\features\default_post.prf: 103 | c:\Qt\4.6.3\mkspecs\features\win32\default_post.prf: 104 | c:\Qt\4.6.3\mkspecs\features\dll.prf: 105 | c:\Qt\4.6.3\mkspecs\features\shared.prf: 106 | c:\Qt\4.6.3\mkspecs\features\qt.prf: 107 | c:\Qt\4.6.3\mkspecs\features\win32\thread.prf: 108 | c:\Qt\4.6.3\mkspecs\features\moc.prf: 109 | c:\Qt\4.6.3\mkspecs\features\win32\rtti.prf: 110 | c:\Qt\4.6.3\mkspecs\features\win32\exceptions.prf: 111 | c:\Qt\4.6.3\mkspecs\features\win32\stl.prf: 112 | c:\Qt\4.6.3\mkspecs\features\win32\embed_manifest_exe.prf: 113 | c:\Qt\4.6.3\mkspecs\features\win32\embed_manifest_dll.prf: 114 | c:\Qt\4.6.3\mkspecs\features\warn_on.prf: 115 | c:\Qt\4.6.3\mkspecs\features\win32\windows.prf: 116 | c:\Qt\4.6.3\mkspecs\features\resources.prf: 117 | c:\Qt\4.6.3\mkspecs\features\uic.prf: 118 | c:\Qt\4.6.3\mkspecs\features\yacc.prf: 119 | c:\Qt\4.6.3\mkspecs\features\lex.prf: 120 | c:\Qt\4.6.3\mkspecs\features\include_source_dir.prf: 121 | qmake: qmake_all FORCE 122 | @$(QMAKE) -spec c:\Qt\4.6.3\mkspecs\win32-msvc2010 -win32 -o Makefile64.msvc x86emu64.pro 123 | 124 | qmake_all: FORCE 125 | 126 | make_default: release-make_default debug-make_default FORCE 127 | make_first: release-make_first debug-make_first FORCE 128 | all: release-all debug-all FORCE 129 | clean: release-clean debug-clean FORCE 130 | -$(DEL_FILE) .\bin\x86emu_qt.exp 131 | distclean: release-distclean debug-distclean FORCE 132 | -$(DEL_FILE) Makefile64.msvc 133 | 134 | check: first 135 | 136 | release-mocclean: $(MAKEFILE).Release 137 | $(MAKE) -f $(MAKEFILE).Release mocclean 138 | debug-mocclean: $(MAKEFILE).Debug 139 | $(MAKE) -f $(MAKEFILE).Debug mocclean 140 | mocclean: release-mocclean debug-mocclean 141 | 142 | release-mocables: $(MAKEFILE).Release 143 | $(MAKE) -f $(MAKEFILE).Release mocables 144 | debug-mocables: $(MAKEFILE).Debug 145 | $(MAKE) -f $(MAKEFILE).Debug mocables 146 | mocables: release-mocables debug-mocables 147 | FORCE: 148 | 149 | $(MAKEFILE).Release: Makefile64.msvc 150 | $(MAKEFILE).Debug: Makefile64.msvc 151 | -------------------------------------------------------------------------------- /Makefile64.msvc.Debug: -------------------------------------------------------------------------------- 1 | ############################################################################# 2 | # Makefile for building: x86emu_qt 3 | # Generated by qmake (2.01a) (Qt 4.6.3) on: Wed Jul 5 23:51:33 2017 4 | # Project: x86emu64.pro 5 | # Template: lib 6 | ############################################################################# 7 | 8 | ####### Compiler, tools and options 9 | 10 | CC = cl 11 | CXX = cl 12 | DEFINES = -DWIN32 -DQT_LARGEFILE_SUPPORT -D__IDP__ -D__QT__ -D__EA64__ -D__NT__ -DWIN32 -D_CRT_SECURE_NO_WARNINGS -DQT_DLL -DQT_GUI_LIB -DQT_CORE_LIB -DQT_THREAD_SUPPORT 13 | CFLAGS = -nologo -Zm200 -Zc:wchar_t- -Zi -MDd -W3 $(DEFINES) 14 | CXXFLAGS = -nologo -Zm200 -Zc:wchar_t- -Zi -MDd -GR -EHsc -W3 -w34100 -w34189 $(DEFINES) 15 | INCPATH = -I"c:\Qt\4.6.3\include\QtCore" -I"c:\Qt\4.6.3\include\QtGui" -I"c:\Qt\4.6.3\include" -I"..\..\include" -I"c:\Qt\4.6.3\include\ActiveQt" -I"debug" -I"c:\Qt\4.6.3\mkspecs\win32-msvc2010" 16 | LINK = link 17 | LFLAGS = /LIBPATH:"c:\Qt\4.6.3\lib" /NOLOGO /DEBUG /DLL 18 | LIBS = comdlg32.lib gdi32.lib user32.lib advapi32.lib ida.lib ws2_32.lib /LIBPATH:../../lib/x86_win_vc_64 c:\Qt\4.6.3\lib\QtGuid4.lib c:\Qt\4.6.3\lib\QtCored4.lib 19 | QMAKE = c:\Qt\4.6.3\bin\qmake.exe 20 | IDC = c:\Qt\4.6.3\bin\idc.exe 21 | IDL = midl 22 | ZIP = zip -r -9 23 | DEF_FILE = 24 | RES_FILE = 25 | COPY = copy /y 26 | COPY_FILE = $(COPY) 27 | COPY_DIR = xcopy /s /q /y /i 28 | DEL_FILE = del 29 | DEL_DIR = rmdir 30 | MOVE = move 31 | CHK_DIR_EXISTS= if not exist 32 | MKDIR = mkdir 33 | INSTALL_FILE = $(COPY_FILE) 34 | INSTALL_PROGRAM = $(COPY_FILE) 35 | INSTALL_DIR = $(COPY_DIR) 36 | 37 | ####### Output directory 38 | 39 | OBJECTS_DIR = p64 40 | 41 | ####### Files 42 | 43 | SOURCES = x86emu.cpp \ 44 | x86emu_ui_qt.cpp \ 45 | emufuncs.cpp \ 46 | cpu.cpp \ 47 | emuheap.cpp \ 48 | memmgr.cpp \ 49 | seh.cpp \ 50 | break.cpp \ 51 | hooklist.cpp \ 52 | buffer.cpp \ 53 | emuthreads.cpp \ 54 | peutils.cpp \ 55 | emu_script.cpp \ 56 | context.cpp \ 57 | aes.cpp \ 58 | ansi_cprng.cpp debug\moc_x86emu_ui_qt.cpp 59 | OBJECTS = p64\x86emu.obj \ 60 | p64\x86emu_ui_qt.obj \ 61 | p64\emufuncs.obj \ 62 | p64\cpu.obj \ 63 | p64\emuheap.obj \ 64 | p64\memmgr.obj \ 65 | p64\seh.obj \ 66 | p64\break.obj \ 67 | p64\hooklist.obj \ 68 | p64\buffer.obj \ 69 | p64\emuthreads.obj \ 70 | p64\peutils.obj \ 71 | p64\emu_script.obj \ 72 | p64\context.obj \ 73 | p64\aes.obj \ 74 | p64\ansi_cprng.obj \ 75 | p64\moc_x86emu_ui_qt.obj 76 | DIST = 77 | QMAKE_TARGET = x86emu_qt 78 | DESTDIR = .\bin\ #avoid trailing-slash linebreak 79 | TARGET = x86emu_qt.p64 80 | DESTDIR_TARGET = .\bin\x86emu_qt.p64 81 | 82 | ####### Implicit rules 83 | 84 | .SUFFIXES: .c .cpp .cc .cxx 85 | 86 | {.}.cpp{p64\}.obj:: 87 | $(CXX) -c $(CXXFLAGS) $(INCPATH) -Fop64\ @<< 88 | $< 89 | << 90 | 91 | {.}.cc{p64\}.obj:: 92 | $(CXX) -c $(CXXFLAGS) $(INCPATH) -Fop64\ @<< 93 | $< 94 | << 95 | 96 | {.}.cxx{p64\}.obj:: 97 | $(CXX) -c $(CXXFLAGS) $(INCPATH) -Fop64\ @<< 98 | $< 99 | << 100 | 101 | {.}.c{p64\}.obj:: 102 | $(CC) -c $(CFLAGS) $(INCPATH) -Fop64\ @<< 103 | $< 104 | << 105 | 106 | {debug}.cpp{p64\}.obj:: 107 | $(CXX) -c $(CXXFLAGS) $(INCPATH) -Fop64\ @<< 108 | $< 109 | << 110 | 111 | {debug}.cc{p64\}.obj:: 112 | $(CXX) -c $(CXXFLAGS) $(INCPATH) -Fop64\ @<< 113 | $< 114 | << 115 | 116 | {debug}.cxx{p64\}.obj:: 117 | $(CXX) -c $(CXXFLAGS) $(INCPATH) -Fop64\ @<< 118 | $< 119 | << 120 | 121 | {debug}.c{p64\}.obj:: 122 | $(CC) -c $(CFLAGS) $(INCPATH) -Fop64\ @<< 123 | $< 124 | << 125 | 126 | ####### Build rules 127 | 128 | first: all 129 | all: Makefile64.msvc.Debug $(DESTDIR_TARGET) 130 | 131 | $(DESTDIR_TARGET): $(OBJECTS) 132 | $(LINK) $(LFLAGS) /OUT:$(DESTDIR_TARGET) @<< 133 | $(OBJECTS) $(LIBS) 134 | << 135 | 136 | 137 | qmake: FORCE 138 | @$(QMAKE) -spec c:\Qt\4.6.3\mkspecs\win32-msvc2010 -win32 -o Makefile64.msvc.Debug x86emu64.pro 139 | 140 | dist: 141 | $(ZIP) x86emu_qt.zip $(SOURCES) $(DIST) x86emu64.pro c:\Qt\4.6.3\mkspecs\qconfig.pri c:\Qt\4.6.3\mkspecs\features\qt_functions.prf c:\Qt\4.6.3\mkspecs\features\qt_config.prf c:\Qt\4.6.3\mkspecs\features\exclusive_builds.prf c:\Qt\4.6.3\mkspecs\features\default_pre.prf c:\Qt\4.6.3\mkspecs\features\win32\default_pre.prf c:\Qt\4.6.3\mkspecs\features\debug.prf c:\Qt\4.6.3\mkspecs\features\debug_and_release.prf c:\Qt\4.6.3\mkspecs\features\default_post.prf c:\Qt\4.6.3\mkspecs\features\win32\default_post.prf c:\Qt\4.6.3\mkspecs\features\build_pass.prf c:\Qt\4.6.3\mkspecs\features\dll.prf c:\Qt\4.6.3\mkspecs\features\shared.prf c:\Qt\4.6.3\mkspecs\features\qt.prf c:\Qt\4.6.3\mkspecs\features\win32\thread.prf c:\Qt\4.6.3\mkspecs\features\moc.prf c:\Qt\4.6.3\mkspecs\features\win32\rtti.prf c:\Qt\4.6.3\mkspecs\features\win32\exceptions.prf c:\Qt\4.6.3\mkspecs\features\win32\stl.prf c:\Qt\4.6.3\mkspecs\features\win32\embed_manifest_exe.prf c:\Qt\4.6.3\mkspecs\features\win32\embed_manifest_dll.prf c:\Qt\4.6.3\mkspecs\features\warn_on.prf c:\Qt\4.6.3\mkspecs\features\win32\windows.prf c:\Qt\4.6.3\mkspecs\features\resources.prf c:\Qt\4.6.3\mkspecs\features\uic.prf c:\Qt\4.6.3\mkspecs\features\yacc.prf c:\Qt\4.6.3\mkspecs\features\lex.prf c:\Qt\4.6.3\mkspecs\features\include_source_dir.prf HEADERS RESOURCES IMAGES SOURCES OBJECTIVE_SOURCES FORMS YACCSOURCES YACCSOURCES LEXSOURCES 142 | 143 | clean: compiler_clean 144 | -$(DEL_FILE) p64\x86emu.obj p64\x86emu_ui_qt.obj p64\emufuncs.obj p64\cpu.obj p64\emuheap.obj p64\memmgr.obj p64\seh.obj p64\break.obj p64\hooklist.obj p64\buffer.obj p64\emuthreads.obj p64\peutils.obj p64\emu_script.obj p64\context.obj p64\aes.obj p64\ansi_cprng.obj p64\moc_x86emu_ui_qt.obj 145 | -$(DEL_FILE) .\bin\x86emu_qt.exp .\bin\x86emu_qt.pdb .\bin\x86emu_qt.ilk vc*.pdb vc*.idb 146 | 147 | distclean: clean 148 | -$(DEL_FILE) $(DESTDIR_TARGET) 149 | -$(DEL_FILE) Makefile64.msvc.Debug 150 | 151 | check: first 152 | 153 | mocclean: compiler_moc_header_clean compiler_moc_source_clean 154 | 155 | mocables: compiler_moc_header_make_all compiler_moc_source_make_all 156 | 157 | compiler_moc_header_make_all: debug\moc_x86emu_ui_qt.cpp 158 | compiler_moc_header_clean: 159 | -$(DEL_FILE) debug\moc_x86emu_ui_qt.cpp 160 | debug\moc_x86emu_ui_qt.cpp: x86defs.h \ 161 | sdk_versions.h \ 162 | x86emu_ui.h \ 163 | x86emu_ui_qt.h 164 | C:\Qt\4.6.3\bin\moc.exe $(DEFINES) $(INCPATH) -D_MSC_VER=1600 -DWIN32 x86emu_ui_qt.h -o debug\moc_x86emu_ui_qt.cpp 165 | 166 | compiler_rcc_make_all: 167 | compiler_rcc_clean: 168 | compiler_image_collection_make_all: qmake_image_collection.cpp 169 | compiler_image_collection_clean: 170 | -$(DEL_FILE) qmake_image_collection.cpp 171 | compiler_moc_source_make_all: 172 | compiler_moc_source_clean: 173 | compiler_uic_make_all: 174 | compiler_uic_clean: 175 | compiler_yacc_decl_make_all: 176 | compiler_yacc_decl_clean: 177 | compiler_yacc_impl_make_all: 178 | compiler_yacc_impl_clean: 179 | compiler_lex_make_all: 180 | compiler_lex_clean: 181 | compiler_clean: compiler_moc_header_clean 182 | 183 | 184 | 185 | ####### Compile 186 | 187 | p64\x86emu.obj: x86emu.cpp image.h \ 188 | x86emu_ui.h \ 189 | x86emu_ui_qt.h \ 190 | x86defs.h \ 191 | sdk_versions.h \ 192 | emufuncs.h \ 193 | buffer.h \ 194 | peutils.h \ 195 | hooklist.h \ 196 | emuheap.h \ 197 | break.h \ 198 | emuthreads.h \ 199 | cpu.h \ 200 | elf32.h \ 201 | elf_common.h \ 202 | emu_script.h \ 203 | memmgr.h 204 | 205 | p64\x86emu_ui_qt.obj: x86emu_ui_qt.cpp x86emu_ui_qt.h \ 206 | x86defs.h \ 207 | sdk_versions.h \ 208 | x86emu_ui.h \ 209 | cpu.h \ 210 | emufuncs.h \ 211 | buffer.h \ 212 | peutils.h \ 213 | hooklist.h \ 214 | emuthreads.h 215 | 216 | p64\emufuncs.obj: emufuncs.cpp image.h \ 217 | x86emu_ui.h \ 218 | cpu.h \ 219 | x86defs.h \ 220 | sdk_versions.h \ 221 | context.h \ 222 | emufuncs.h \ 223 | buffer.h \ 224 | peutils.h \ 225 | hooklist.h \ 226 | emuheap.h \ 227 | emuthreads.h \ 228 | memmgr.h \ 229 | linux_syscalls.h \ 230 | bsd_syscalls.h \ 231 | cgc_syscalls.h \ 232 | ansi_cprng.h 233 | 234 | p64\cpu.obj: cpu.cpp cpu.h \ 235 | x86defs.h \ 236 | sdk_versions.h \ 237 | seh.h \ 238 | context.h \ 239 | buffer.h \ 240 | emuthreads.h \ 241 | emuheap.h \ 242 | memmgr.h \ 243 | hooklist.h \ 244 | emufuncs.h \ 245 | peutils.h 246 | 247 | p64\emuheap.obj: emuheap.cpp emuheap.h \ 248 | buffer.h \ 249 | memmgr.h \ 250 | x86defs.h \ 251 | sdk_versions.h 252 | 253 | p64\memmgr.obj: memmgr.cpp memmgr.h \ 254 | x86defs.h \ 255 | sdk_versions.h \ 256 | peutils.h \ 257 | buffer.h 258 | 259 | p64\seh.obj: seh.cpp cpu.h \ 260 | x86defs.h \ 261 | sdk_versions.h \ 262 | seh.h \ 263 | context.h \ 264 | buffer.h 265 | 266 | p64\break.obj: break.cpp x86defs.h \ 267 | sdk_versions.h 268 | 269 | p64\hooklist.obj: hooklist.cpp x86defs.h \ 270 | sdk_versions.h \ 271 | hooklist.h \ 272 | buffer.h 273 | 274 | p64\buffer.obj: buffer.cpp buffer.h 275 | 276 | p64\emuthreads.obj: emuthreads.cpp x86defs.h \ 277 | sdk_versions.h \ 278 | emuthreads.h \ 279 | cpu.h \ 280 | buffer.h \ 281 | seh.h \ 282 | context.h \ 283 | memmgr.h 284 | 285 | p64\peutils.obj: peutils.cpp image.h \ 286 | peutils.h \ 287 | buffer.h \ 288 | sdk_versions.h 289 | 290 | p64\emu_script.obj: emu_script.cpp cpu.h \ 291 | x86defs.h \ 292 | sdk_versions.h \ 293 | emu_script.h 294 | 295 | p64\context.obj: context.cpp cpu.h \ 296 | x86defs.h \ 297 | sdk_versions.h \ 298 | context.h 299 | 300 | p64\aes.obj: aes.cpp 301 | 302 | p64\ansi_cprng.obj: ansi_cprng.cpp ansi_cprng.h \ 303 | aes.h 304 | 305 | p64\moc_x86emu_ui_qt.obj: debug\moc_x86emu_ui_qt.cpp 306 | 307 | ####### Install 308 | 309 | install: FORCE 310 | 311 | uninstall: FORCE 312 | 313 | FORCE: 314 | 315 | -------------------------------------------------------------------------------- /Makefile64.msvc.Release: -------------------------------------------------------------------------------- 1 | ############################################################################# 2 | # Makefile for building: x86emu_qt 3 | # Generated by qmake (2.01a) (Qt 4.6.3) on: Wed Jul 5 23:51:33 2017 4 | # Project: x86emu64.pro 5 | # Template: lib 6 | ############################################################################# 7 | 8 | ####### Compiler, tools and options 9 | 10 | CC = cl 11 | CXX = cl 12 | DEFINES = -DWIN32 -DQT_LARGEFILE_SUPPORT -D__IDP__ -D__QT__ -D__EA64__ -D__NT__ -DWIN32 -D_CRT_SECURE_NO_WARNINGS -DQT_DLL -DQT_NO_DEBUG -DQT_GUI_LIB -DQT_CORE_LIB -DQT_THREAD_SUPPORT 13 | CFLAGS = -nologo -Zm200 -Zc:wchar_t- -O2 -MD -W3 $(DEFINES) 14 | CXXFLAGS = -nologo -Zm200 -Zc:wchar_t- -O2 -MD -GR -EHsc -W3 -w34100 -w34189 $(DEFINES) 15 | INCPATH = -I"c:\Qt\4.6.3\include\QtCore" -I"c:\Qt\4.6.3\include\QtGui" -I"c:\Qt\4.6.3\include" -I"..\..\include" -I"c:\Qt\4.6.3\include\ActiveQt" -I"release" -I"c:\Qt\4.6.3\mkspecs\win32-msvc2010" 16 | LINK = link 17 | LFLAGS = /LIBPATH:"c:\Qt\4.6.3\lib" /NOLOGO /INCREMENTAL:NO /DLL 18 | LIBS = comdlg32.lib gdi32.lib user32.lib advapi32.lib ida.lib ws2_32.lib /LIBPATH:../../lib/x86_win_vc_64 c:\Qt\4.6.3\lib\QtGui4.lib c:\Qt\4.6.3\lib\QtCore4.lib 19 | QMAKE = c:\Qt\4.6.3\bin\qmake.exe 20 | IDC = c:\Qt\4.6.3\bin\idc.exe 21 | IDL = midl 22 | ZIP = zip -r -9 23 | DEF_FILE = 24 | RES_FILE = 25 | COPY = copy /y 26 | COPY_FILE = $(COPY) 27 | COPY_DIR = xcopy /s /q /y /i 28 | DEL_FILE = del 29 | DEL_DIR = rmdir 30 | MOVE = move 31 | CHK_DIR_EXISTS= if not exist 32 | MKDIR = mkdir 33 | INSTALL_FILE = $(COPY_FILE) 34 | INSTALL_PROGRAM = $(COPY_FILE) 35 | INSTALL_DIR = $(COPY_DIR) 36 | 37 | ####### Output directory 38 | 39 | OBJECTS_DIR = p64 40 | 41 | ####### Files 42 | 43 | SOURCES = x86emu.cpp \ 44 | x86emu_ui_qt.cpp \ 45 | emufuncs.cpp \ 46 | cpu.cpp \ 47 | emuheap.cpp \ 48 | memmgr.cpp \ 49 | seh.cpp \ 50 | break.cpp \ 51 | hooklist.cpp \ 52 | buffer.cpp \ 53 | emuthreads.cpp \ 54 | peutils.cpp \ 55 | emu_script.cpp \ 56 | context.cpp \ 57 | aes.cpp \ 58 | ansi_cprng.cpp release\moc_x86emu_ui_qt.cpp 59 | OBJECTS = p64\x86emu.obj \ 60 | p64\x86emu_ui_qt.obj \ 61 | p64\emufuncs.obj \ 62 | p64\cpu.obj \ 63 | p64\emuheap.obj \ 64 | p64\memmgr.obj \ 65 | p64\seh.obj \ 66 | p64\break.obj \ 67 | p64\hooklist.obj \ 68 | p64\buffer.obj \ 69 | p64\emuthreads.obj \ 70 | p64\peutils.obj \ 71 | p64\emu_script.obj \ 72 | p64\context.obj \ 73 | p64\aes.obj \ 74 | p64\ansi_cprng.obj \ 75 | p64\moc_x86emu_ui_qt.obj 76 | DIST = 77 | QMAKE_TARGET = x86emu_qt 78 | DESTDIR = .\bin\ #avoid trailing-slash linebreak 79 | TARGET = x86emu_qt.p64 80 | DESTDIR_TARGET = .\bin\x86emu_qt.p64 81 | 82 | ####### Implicit rules 83 | 84 | .SUFFIXES: .c .cpp .cc .cxx 85 | 86 | {release}.cpp{p64\}.obj:: 87 | $(CXX) -c $(CXXFLAGS) $(INCPATH) -Fop64\ @<< 88 | $< 89 | << 90 | 91 | {release}.cc{p64\}.obj:: 92 | $(CXX) -c $(CXXFLAGS) $(INCPATH) -Fop64\ @<< 93 | $< 94 | << 95 | 96 | {release}.cxx{p64\}.obj:: 97 | $(CXX) -c $(CXXFLAGS) $(INCPATH) -Fop64\ @<< 98 | $< 99 | << 100 | 101 | {release}.c{p64\}.obj:: 102 | $(CC) -c $(CFLAGS) $(INCPATH) -Fop64\ @<< 103 | $< 104 | << 105 | 106 | {.}.cpp{p64\}.obj:: 107 | $(CXX) -c $(CXXFLAGS) $(INCPATH) -Fop64\ @<< 108 | $< 109 | << 110 | 111 | {.}.cc{p64\}.obj:: 112 | $(CXX) -c $(CXXFLAGS) $(INCPATH) -Fop64\ @<< 113 | $< 114 | << 115 | 116 | {.}.cxx{p64\}.obj:: 117 | $(CXX) -c $(CXXFLAGS) $(INCPATH) -Fop64\ @<< 118 | $< 119 | << 120 | 121 | {.}.c{p64\}.obj:: 122 | $(CC) -c $(CFLAGS) $(INCPATH) -Fop64\ @<< 123 | $< 124 | << 125 | 126 | ####### Build rules 127 | 128 | first: all 129 | all: Makefile64.msvc.Release $(DESTDIR_TARGET) 130 | 131 | $(DESTDIR_TARGET): $(OBJECTS) 132 | $(LINK) $(LFLAGS) /OUT:$(DESTDIR_TARGET) @<< 133 | $(OBJECTS) $(LIBS) 134 | << 135 | 136 | 137 | qmake: FORCE 138 | @$(QMAKE) -spec c:\Qt\4.6.3\mkspecs\win32-msvc2010 -win32 -o Makefile64.msvc.Release x86emu64.pro 139 | 140 | dist: 141 | $(ZIP) x86emu_qt.zip $(SOURCES) $(DIST) x86emu64.pro c:\Qt\4.6.3\mkspecs\qconfig.pri c:\Qt\4.6.3\mkspecs\features\qt_functions.prf c:\Qt\4.6.3\mkspecs\features\qt_config.prf c:\Qt\4.6.3\mkspecs\features\exclusive_builds.prf c:\Qt\4.6.3\mkspecs\features\default_pre.prf c:\Qt\4.6.3\mkspecs\features\win32\default_pre.prf c:\Qt\4.6.3\mkspecs\features\release.prf c:\Qt\4.6.3\mkspecs\features\debug_and_release.prf c:\Qt\4.6.3\mkspecs\features\default_post.prf c:\Qt\4.6.3\mkspecs\features\win32\default_post.prf c:\Qt\4.6.3\mkspecs\features\build_pass.prf c:\Qt\4.6.3\mkspecs\features\dll.prf c:\Qt\4.6.3\mkspecs\features\shared.prf c:\Qt\4.6.3\mkspecs\features\qt.prf c:\Qt\4.6.3\mkspecs\features\win32\thread.prf c:\Qt\4.6.3\mkspecs\features\moc.prf c:\Qt\4.6.3\mkspecs\features\win32\rtti.prf c:\Qt\4.6.3\mkspecs\features\win32\exceptions.prf c:\Qt\4.6.3\mkspecs\features\win32\stl.prf c:\Qt\4.6.3\mkspecs\features\win32\embed_manifest_exe.prf c:\Qt\4.6.3\mkspecs\features\win32\embed_manifest_dll.prf c:\Qt\4.6.3\mkspecs\features\warn_on.prf c:\Qt\4.6.3\mkspecs\features\win32\windows.prf c:\Qt\4.6.3\mkspecs\features\resources.prf c:\Qt\4.6.3\mkspecs\features\uic.prf c:\Qt\4.6.3\mkspecs\features\yacc.prf c:\Qt\4.6.3\mkspecs\features\lex.prf c:\Qt\4.6.3\mkspecs\features\include_source_dir.prf HEADERS RESOURCES IMAGES SOURCES OBJECTIVE_SOURCES FORMS YACCSOURCES YACCSOURCES LEXSOURCES 142 | 143 | clean: compiler_clean 144 | -$(DEL_FILE) p64\x86emu.obj p64\x86emu_ui_qt.obj p64\emufuncs.obj p64\cpu.obj p64\emuheap.obj p64\memmgr.obj p64\seh.obj p64\break.obj p64\hooklist.obj p64\buffer.obj p64\emuthreads.obj p64\peutils.obj p64\emu_script.obj p64\context.obj p64\aes.obj p64\ansi_cprng.obj p64\moc_x86emu_ui_qt.obj 145 | -$(DEL_FILE) .\bin\x86emu_qt.exp 146 | 147 | distclean: clean 148 | -$(DEL_FILE) $(DESTDIR_TARGET) 149 | -$(DEL_FILE) Makefile64.msvc.Release 150 | 151 | check: first 152 | 153 | mocclean: compiler_moc_header_clean compiler_moc_source_clean 154 | 155 | mocables: compiler_moc_header_make_all compiler_moc_source_make_all 156 | 157 | compiler_moc_header_make_all: release\moc_x86emu_ui_qt.cpp 158 | compiler_moc_header_clean: 159 | -$(DEL_FILE) release\moc_x86emu_ui_qt.cpp 160 | release\moc_x86emu_ui_qt.cpp: x86defs.h \ 161 | sdk_versions.h \ 162 | x86emu_ui.h \ 163 | x86emu_ui_qt.h 164 | C:\Qt\4.6.3\bin\moc.exe $(DEFINES) $(INCPATH) -D_MSC_VER=1600 -DWIN32 x86emu_ui_qt.h -o release\moc_x86emu_ui_qt.cpp 165 | 166 | compiler_rcc_make_all: 167 | compiler_rcc_clean: 168 | compiler_image_collection_make_all: qmake_image_collection.cpp 169 | compiler_image_collection_clean: 170 | -$(DEL_FILE) qmake_image_collection.cpp 171 | compiler_moc_source_make_all: 172 | compiler_moc_source_clean: 173 | compiler_uic_make_all: 174 | compiler_uic_clean: 175 | compiler_yacc_decl_make_all: 176 | compiler_yacc_decl_clean: 177 | compiler_yacc_impl_make_all: 178 | compiler_yacc_impl_clean: 179 | compiler_lex_make_all: 180 | compiler_lex_clean: 181 | compiler_clean: compiler_moc_header_clean 182 | 183 | 184 | 185 | ####### Compile 186 | 187 | p64\x86emu.obj: x86emu.cpp image.h \ 188 | x86emu_ui.h \ 189 | x86emu_ui_qt.h \ 190 | x86defs.h \ 191 | sdk_versions.h \ 192 | emufuncs.h \ 193 | buffer.h \ 194 | peutils.h \ 195 | hooklist.h \ 196 | emuheap.h \ 197 | break.h \ 198 | emuthreads.h \ 199 | cpu.h \ 200 | elf32.h \ 201 | elf_common.h \ 202 | emu_script.h \ 203 | memmgr.h 204 | 205 | p64\x86emu_ui_qt.obj: x86emu_ui_qt.cpp x86emu_ui_qt.h \ 206 | x86defs.h \ 207 | sdk_versions.h \ 208 | x86emu_ui.h \ 209 | cpu.h \ 210 | emufuncs.h \ 211 | buffer.h \ 212 | peutils.h \ 213 | hooklist.h \ 214 | emuthreads.h 215 | 216 | p64\emufuncs.obj: emufuncs.cpp image.h \ 217 | x86emu_ui.h \ 218 | cpu.h \ 219 | x86defs.h \ 220 | sdk_versions.h \ 221 | context.h \ 222 | emufuncs.h \ 223 | buffer.h \ 224 | peutils.h \ 225 | hooklist.h \ 226 | emuheap.h \ 227 | emuthreads.h \ 228 | memmgr.h \ 229 | linux_syscalls.h \ 230 | bsd_syscalls.h \ 231 | cgc_syscalls.h \ 232 | ansi_cprng.h 233 | 234 | p64\cpu.obj: cpu.cpp cpu.h \ 235 | x86defs.h \ 236 | sdk_versions.h \ 237 | seh.h \ 238 | context.h \ 239 | buffer.h \ 240 | emuthreads.h \ 241 | emuheap.h \ 242 | memmgr.h \ 243 | hooklist.h \ 244 | emufuncs.h \ 245 | peutils.h 246 | 247 | p64\emuheap.obj: emuheap.cpp emuheap.h \ 248 | buffer.h \ 249 | memmgr.h \ 250 | x86defs.h \ 251 | sdk_versions.h 252 | 253 | p64\memmgr.obj: memmgr.cpp memmgr.h \ 254 | x86defs.h \ 255 | sdk_versions.h \ 256 | peutils.h \ 257 | buffer.h 258 | 259 | p64\seh.obj: seh.cpp cpu.h \ 260 | x86defs.h \ 261 | sdk_versions.h \ 262 | seh.h \ 263 | context.h \ 264 | buffer.h 265 | 266 | p64\break.obj: break.cpp x86defs.h \ 267 | sdk_versions.h 268 | 269 | p64\hooklist.obj: hooklist.cpp x86defs.h \ 270 | sdk_versions.h \ 271 | hooklist.h \ 272 | buffer.h 273 | 274 | p64\buffer.obj: buffer.cpp buffer.h 275 | 276 | p64\emuthreads.obj: emuthreads.cpp x86defs.h \ 277 | sdk_versions.h \ 278 | emuthreads.h \ 279 | cpu.h \ 280 | buffer.h \ 281 | seh.h \ 282 | context.h \ 283 | memmgr.h 284 | 285 | p64\peutils.obj: peutils.cpp image.h \ 286 | peutils.h \ 287 | buffer.h \ 288 | sdk_versions.h 289 | 290 | p64\emu_script.obj: emu_script.cpp cpu.h \ 291 | x86defs.h \ 292 | sdk_versions.h \ 293 | emu_script.h 294 | 295 | p64\context.obj: context.cpp cpu.h \ 296 | x86defs.h \ 297 | sdk_versions.h \ 298 | context.h 299 | 300 | p64\aes.obj: aes.cpp 301 | 302 | p64\ansi_cprng.obj: ansi_cprng.cpp ansi_cprng.h \ 303 | aes.h 304 | 305 | p64\moc_x86emu_ui_qt.obj: release\moc_x86emu_ui_qt.cpp 306 | 307 | ####### Install 308 | 309 | install: FORCE 310 | 311 | uninstall: FORCE 312 | 313 | FORCE: 314 | 315 | -------------------------------------------------------------------------------- /aes.h: -------------------------------------------------------------------------------- 1 | #ifndef _AES_H_ 2 | #define _AES_H_ 3 | 4 | void AES128_ECB_encrypt(unsigned char* input, const unsigned char* key, unsigned char *output); 5 | 6 | #endif //_AES_H_ 7 | -------------------------------------------------------------------------------- /ansi_cprng.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | #include "ansi_cprng.h" 5 | #include "aes.h" 6 | 7 | //aes 128 based rng 8 | //see http://csrc.nist.gov/groups/STM/cavp/documents/rng/931rngext.pdf 9 | //test vectors http://csrc.nist.gov/groups/STM/cavp/documents/rng/RNGVS.pdf B.2.9 and B.2.10 10 | 11 | static void xor_16(uint8_t *v1, uint8_t *v2, uint8_t *vout) { 12 | uint32_t *u1 = (uint32_t*)v1; 13 | uint32_t *u2 = (uint32_t*)v2; 14 | uint32_t *v = (uint32_t*)vout; 15 | v[0] = u1[0] ^ u2[0]; 16 | v[1] = u1[1] ^ u2[1]; 17 | v[2] = u1[2] ^ u2[2]; 18 | v[3] = u1[3] ^ u2[3]; 19 | } 20 | 21 | /* 22 | * seed should be 48 bytes in 3x16 byte blocks 23 | * V : K : DT 24 | */ 25 | int ctx_init(cprng_ctx *ctx, uint8_t *seed, uint32_t slen) { 26 | ctx->flags = CPRNG_INVALID; 27 | if (slen != (3 * CPRNG_BLOCK_SIZE)) { 28 | return 0; 29 | } 30 | 31 | if (memcmp(seed, seed + CPRNG_BLOCK_SIZE, CPRNG_BLOCK_SIZE) == 0) { 32 | return 0; 33 | } 34 | 35 | memcpy(ctx->V, seed, CPRNG_BLOCK_SIZE); 36 | memcpy(ctx->K, seed + CPRNG_BLOCK_SIZE, CPRNG_BLOCK_SIZE); 37 | memcpy(ctx->DT, seed + (2 * CPRNG_BLOCK_SIZE), CPRNG_BLOCK_SIZE); 38 | 39 | memset(ctx->data, 0, CPRNG_BLOCK_SIZE); 40 | memset(ctx->last_data, 0, CPRNG_BLOCK_SIZE); 41 | ctx->data_idx = CPRNG_BLOCK_SIZE; 42 | 43 | ctx->flags = CPRNG_VALID; 44 | 45 | return 1; 46 | } 47 | 48 | /* 49 | * Returns 16 bytes of random data per call 50 | * returns 0 if generation succeeded, -1 if something went wrong 51 | */ 52 | static int _get_more_bytes(cprng_ctx *ctx) { 53 | uint8_t tmp[CPRNG_BLOCK_SIZE]; 54 | 55 | /* 56 | * Start by encrypting the counter value 57 | * This gives us an intermediate value I 58 | */ 59 | memcpy(tmp, ctx->DT, CPRNG_BLOCK_SIZE); 60 | AES128_ECB_encrypt(tmp, ctx->K, ctx->I); 61 | 62 | /* 63 | * Next xor I with our secret vector V 64 | * encrypt that result to obtain our 65 | * pseudo random data which we output 66 | */ 67 | xor_16(ctx->I, ctx->V, tmp); 68 | AES128_ECB_encrypt(tmp, ctx->K, ctx->data); 69 | 70 | /* 71 | * First check that we didn't produce the same 72 | * random data that we did last time around 73 | */ 74 | if (!memcmp(ctx->data, ctx->last_data, CPRNG_BLOCK_SIZE)) { 75 | ctx->flags = CPRNG_INVALID; 76 | return -1; 77 | } 78 | memcpy(ctx->last_data, ctx->data, CPRNG_BLOCK_SIZE); 79 | 80 | /* 81 | * Lastly xor the random data with I 82 | * and encrypt that to obtain a new secret vector V 83 | */ 84 | xor_16(ctx->data, ctx->I, tmp); 85 | AES128_ECB_encrypt(tmp, ctx->K, ctx->V); 86 | 87 | /* 88 | * DT++ 89 | * DT is a big-endian 128 bit integer 90 | * this is ripple addition across 16 bytes 91 | */ 92 | int i = CPRNG_BLOCK_SIZE; 93 | do { 94 | ctx->DT[--i] += 1; 95 | } while (ctx->DT[i] == 0 && i > 0); 96 | 97 | ctx->data_idx = 0; 98 | return 0; 99 | } 100 | 101 | int get_prng_bytes(cprng_ctx *ctx, uint8_t *buf, uint32_t nbytes) { 102 | if (ctx->flags == CPRNG_INVALID) { 103 | return -1; 104 | } 105 | 106 | uint8_t *ptr = buf; 107 | uint32_t byte_count = (uint32_t)nbytes; 108 | 109 | while (byte_count > 0) { 110 | uint32_t avail = sizeof(ctx->data) - ctx->data_idx; 111 | if (avail == 0 && _get_more_bytes(ctx) < 0) { 112 | memset(buf, 0, nbytes); 113 | return -1; 114 | } 115 | if (byte_count <= avail) { 116 | //everything we need is available 117 | memcpy(ptr, ctx->data + ctx->data_idx, byte_count); 118 | ctx->data_idx += byte_count; 119 | break; 120 | } 121 | else { 122 | //take everything that's available 123 | memcpy(ptr, ctx->data + ctx->data_idx, avail); 124 | ctx->data_idx += avail; 125 | ptr += avail; 126 | byte_count -= avail; 127 | } 128 | } 129 | 130 | return (int)nbytes; 131 | } 132 | 133 | -------------------------------------------------------------------------------- /ansi_cprng.h: -------------------------------------------------------------------------------- 1 | #ifndef __ANSI_CPRNG_H 2 | #define __ANSI_CPRNG_H 3 | 4 | #define CPRNG_BLOCK_SIZE 16 5 | #define CPRNG_VALID 0 6 | #define CPRNG_INVALID 1 7 | 8 | struct cprng_ctx { 9 | unsigned int data_idx; 10 | unsigned int flags; 11 | unsigned char I[CPRNG_BLOCK_SIZE]; 12 | unsigned char V[CPRNG_BLOCK_SIZE]; 13 | unsigned char K[CPRNG_BLOCK_SIZE]; 14 | unsigned char DT[CPRNG_BLOCK_SIZE]; 15 | unsigned char data[CPRNG_BLOCK_SIZE]; 16 | unsigned char last_data[CPRNG_BLOCK_SIZE]; 17 | }; 18 | 19 | int ctx_init(cprng_ctx *ctx, unsigned char *seed, unsigned int slen); 20 | int get_prng_bytes(cprng_ctx *ctx, unsigned char *buf, unsigned int nbytes); 21 | #define is_valid(ctx) (ctx->flags == CPRNG_VALID) 22 | 23 | #endif 24 | 25 | -------------------------------------------------------------------------------- /bins/linux32/ida70/x86emu_qt.so: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cseagle/x86emu/b5487828eaa310dc418520fcb657918403b8fb3e/bins/linux32/ida70/x86emu_qt.so -------------------------------------------------------------------------------- /bins/linux32/ida71/x86emu_qt.so: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cseagle/x86emu/b5487828eaa310dc418520fcb657918403b8fb3e/bins/linux32/ida71/x86emu_qt.so -------------------------------------------------------------------------------- /bins/linux32/ida72/x86emu_qt.so: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cseagle/x86emu/b5487828eaa310dc418520fcb657918403b8fb3e/bins/linux32/ida72/x86emu_qt.so -------------------------------------------------------------------------------- /bins/linux32/ida73/x86emu_qt.so: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cseagle/x86emu/b5487828eaa310dc418520fcb657918403b8fb3e/bins/linux32/ida73/x86emu_qt.so -------------------------------------------------------------------------------- /bins/linux32/ida74/x86emu_qt.so: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cseagle/x86emu/b5487828eaa310dc418520fcb657918403b8fb3e/bins/linux32/ida74/x86emu_qt.so -------------------------------------------------------------------------------- /bins/linux32/ida75/x86emu_qt.so: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cseagle/x86emu/b5487828eaa310dc418520fcb657918403b8fb3e/bins/linux32/ida75/x86emu_qt.so -------------------------------------------------------------------------------- /bins/linux64/ida70/x86emu_qt64.so: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cseagle/x86emu/b5487828eaa310dc418520fcb657918403b8fb3e/bins/linux64/ida70/x86emu_qt64.so -------------------------------------------------------------------------------- /bins/linux64/ida71/x86emu_qt64.so: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cseagle/x86emu/b5487828eaa310dc418520fcb657918403b8fb3e/bins/linux64/ida71/x86emu_qt64.so -------------------------------------------------------------------------------- /bins/linux64/ida72/x86emu_qt64.so: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cseagle/x86emu/b5487828eaa310dc418520fcb657918403b8fb3e/bins/linux64/ida72/x86emu_qt64.so -------------------------------------------------------------------------------- /bins/linux64/ida73/x86emu_qt64.so: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cseagle/x86emu/b5487828eaa310dc418520fcb657918403b8fb3e/bins/linux64/ida73/x86emu_qt64.so -------------------------------------------------------------------------------- /bins/linux64/ida74/x86emu_qt64.so: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cseagle/x86emu/b5487828eaa310dc418520fcb657918403b8fb3e/bins/linux64/ida74/x86emu_qt64.so -------------------------------------------------------------------------------- /bins/linux64/ida75/x86emu_qt64.so: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cseagle/x86emu/b5487828eaa310dc418520fcb657918403b8fb3e/bins/linux64/ida75/x86emu_qt64.so -------------------------------------------------------------------------------- /bins/mac32/ida70/x86emu_qt.dylib: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cseagle/x86emu/b5487828eaa310dc418520fcb657918403b8fb3e/bins/mac32/ida70/x86emu_qt.dylib -------------------------------------------------------------------------------- /bins/mac32/ida71/x86emu_qt.dylib: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cseagle/x86emu/b5487828eaa310dc418520fcb657918403b8fb3e/bins/mac32/ida71/x86emu_qt.dylib -------------------------------------------------------------------------------- /bins/mac32/ida72/x86emu_qt.dylib: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cseagle/x86emu/b5487828eaa310dc418520fcb657918403b8fb3e/bins/mac32/ida72/x86emu_qt.dylib -------------------------------------------------------------------------------- /bins/mac32/ida73/x86emu_qt.dylib: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cseagle/x86emu/b5487828eaa310dc418520fcb657918403b8fb3e/bins/mac32/ida73/x86emu_qt.dylib -------------------------------------------------------------------------------- /bins/mac32/ida74/x86emu_qt.dylib: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cseagle/x86emu/b5487828eaa310dc418520fcb657918403b8fb3e/bins/mac32/ida74/x86emu_qt.dylib -------------------------------------------------------------------------------- /bins/mac32/ida75/x86emu_qt.dylib: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cseagle/x86emu/b5487828eaa310dc418520fcb657918403b8fb3e/bins/mac32/ida75/x86emu_qt.dylib -------------------------------------------------------------------------------- /bins/mac64/ida70/x86emu_qt64.dylib: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cseagle/x86emu/b5487828eaa310dc418520fcb657918403b8fb3e/bins/mac64/ida70/x86emu_qt64.dylib -------------------------------------------------------------------------------- /bins/mac64/ida71/x86emu_qt64.dylib: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cseagle/x86emu/b5487828eaa310dc418520fcb657918403b8fb3e/bins/mac64/ida71/x86emu_qt64.dylib -------------------------------------------------------------------------------- /bins/mac64/ida72/x86emu_qt64.dylib: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cseagle/x86emu/b5487828eaa310dc418520fcb657918403b8fb3e/bins/mac64/ida72/x86emu_qt64.dylib -------------------------------------------------------------------------------- /bins/mac64/ida73/x86emu_qt64.dylib: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cseagle/x86emu/b5487828eaa310dc418520fcb657918403b8fb3e/bins/mac64/ida73/x86emu_qt64.dylib -------------------------------------------------------------------------------- /bins/mac64/ida74/x86emu_qt64.dylib: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cseagle/x86emu/b5487828eaa310dc418520fcb657918403b8fb3e/bins/mac64/ida74/x86emu_qt64.dylib -------------------------------------------------------------------------------- /bins/mac64/ida75/x86emu_qt64.dylib: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cseagle/x86emu/b5487828eaa310dc418520fcb657918403b8fb3e/bins/mac64/ida75/x86emu_qt64.dylib -------------------------------------------------------------------------------- /bins/win32/ida70/x86emu_qt.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cseagle/x86emu/b5487828eaa310dc418520fcb657918403b8fb3e/bins/win32/ida70/x86emu_qt.dll -------------------------------------------------------------------------------- /bins/win32/ida71/x86emu_qt.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cseagle/x86emu/b5487828eaa310dc418520fcb657918403b8fb3e/bins/win32/ida71/x86emu_qt.dll -------------------------------------------------------------------------------- /bins/win32/ida72/x86emu_qt.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cseagle/x86emu/b5487828eaa310dc418520fcb657918403b8fb3e/bins/win32/ida72/x86emu_qt.dll -------------------------------------------------------------------------------- /bins/win32/ida73/x86emu_qt.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cseagle/x86emu/b5487828eaa310dc418520fcb657918403b8fb3e/bins/win32/ida73/x86emu_qt.dll -------------------------------------------------------------------------------- /bins/win32/ida74/x86emu_qt.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cseagle/x86emu/b5487828eaa310dc418520fcb657918403b8fb3e/bins/win32/ida74/x86emu_qt.dll -------------------------------------------------------------------------------- /bins/win32/ida75/x86emu_qt.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cseagle/x86emu/b5487828eaa310dc418520fcb657918403b8fb3e/bins/win32/ida75/x86emu_qt.dll -------------------------------------------------------------------------------- /bins/win32/ida80/x86emu_qt.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cseagle/x86emu/b5487828eaa310dc418520fcb657918403b8fb3e/bins/win32/ida80/x86emu_qt.dll -------------------------------------------------------------------------------- /bins/win32/ida81/x86emu_qt.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cseagle/x86emu/b5487828eaa310dc418520fcb657918403b8fb3e/bins/win32/ida81/x86emu_qt.dll -------------------------------------------------------------------------------- /bins/win32/ida82/x86emu_qt.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cseagle/x86emu/b5487828eaa310dc418520fcb657918403b8fb3e/bins/win32/ida82/x86emu_qt.dll -------------------------------------------------------------------------------- /bins/win64/ida70/x86emu_qt64.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cseagle/x86emu/b5487828eaa310dc418520fcb657918403b8fb3e/bins/win64/ida70/x86emu_qt64.dll -------------------------------------------------------------------------------- /bins/win64/ida71/x86emu_qt64.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cseagle/x86emu/b5487828eaa310dc418520fcb657918403b8fb3e/bins/win64/ida71/x86emu_qt64.dll -------------------------------------------------------------------------------- /bins/win64/ida72/x86emu_qt64.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cseagle/x86emu/b5487828eaa310dc418520fcb657918403b8fb3e/bins/win64/ida72/x86emu_qt64.dll -------------------------------------------------------------------------------- /bins/win64/ida73/x86emu_qt64.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cseagle/x86emu/b5487828eaa310dc418520fcb657918403b8fb3e/bins/win64/ida73/x86emu_qt64.dll -------------------------------------------------------------------------------- /bins/win64/ida74/x86emu_qt64.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cseagle/x86emu/b5487828eaa310dc418520fcb657918403b8fb3e/bins/win64/ida74/x86emu_qt64.dll -------------------------------------------------------------------------------- /bins/win64/ida75/x86emu_qt64.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cseagle/x86emu/b5487828eaa310dc418520fcb657918403b8fb3e/bins/win64/ida75/x86emu_qt64.dll -------------------------------------------------------------------------------- /bins/win64/ida80/x86emu_qt64.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cseagle/x86emu/b5487828eaa310dc418520fcb657918403b8fb3e/bins/win64/ida80/x86emu_qt64.dll -------------------------------------------------------------------------------- /bins/win64/ida81/x86emu_qt64.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cseagle/x86emu/b5487828eaa310dc418520fcb657918403b8fb3e/bins/win64/ida81/x86emu_qt64.dll -------------------------------------------------------------------------------- /bins/win64/ida82/x86emu_qt64.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cseagle/x86emu/b5487828eaa310dc418520fcb657918403b8fb3e/bins/win64/ida82/x86emu_qt64.dll -------------------------------------------------------------------------------- /break.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | break.cpp 3 | Breakpoint implementation for IdaPro x86 emulator 4 | Copyright (c) 2004-2022, Chris Eagle 5 | 6 | This program is free software; you can redistribute it and/or modify it 7 | under the terms of the GNU General Public License as published by the Free 8 | Software Foundation; either version 2 of the License, or (at your option) 9 | any later version. 10 | 11 | This program is distributed in the hope that it will be useful, but WITHOUT 12 | ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 13 | FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for 14 | more details. 15 | 16 | You should have received a copy of the GNU General Public License along with 17 | this program; if not, write to the Free Software Foundation, Inc., 59 Temple 18 | Place, Suite 330, Boston, MA 02111-1307 USA 19 | */ 20 | 21 | #include 22 | #include 23 | #include 24 | #include 25 | 26 | #include "x86defs.h" 27 | 28 | //predefined breakpoint color 29 | #define COLOR_WHITE 0xFFFFFF 30 | #define COLOR_RED 0xFF0000 31 | #define COLOR_BLACK 0 32 | 33 | static unsigned int *bp_list = 0; 34 | 35 | static unsigned int count = 0; 36 | static unsigned int size = 0; 37 | 38 | static bool isEmuBreakpoint(unsigned int addr) { 39 | for (unsigned int i = 0; i < count; i++) { 40 | if (bp_list[i] == addr) return true; 41 | } 42 | return false; 43 | } 44 | 45 | void addBreakpoint(unsigned int addr) { 46 | if (isEmuBreakpoint(addr)) return; 47 | if (count == size) { 48 | bp_list = (unsigned int*) realloc(bp_list, (size + 10) * sizeof(unsigned int)); 49 | size += 10; 50 | } 51 | bp_list[count++] = addr; 52 | set_item_color(addr, COLOR_RED); 53 | } 54 | 55 | void removeBreakpoint(unsigned int addr) { 56 | for (unsigned int i = 0; i < count; i++) { 57 | if (bp_list[i] == addr) { 58 | set_item_color(addr, COLOR_WHITE); 59 | bp_list[i] = bp_list[--count]; 60 | break; 61 | } 62 | } 63 | } 64 | 65 | bool isBreakpoint(unsigned int addr) { 66 | for (unsigned int i = 0; i < count; i++) { 67 | if (bp_list[i] == addr) return true; 68 | } 69 | return dbg ? exist_bpt(addr) : false; 70 | } 71 | 72 | 73 | 74 | -------------------------------------------------------------------------------- /break.h: -------------------------------------------------------------------------------- 1 | /* 2 | break.h 3 | Headers for x86 emulator 4 | Copyright (c) 2004-2022, Chris Eagle 5 | 6 | This program is free software; you can redistribute it and/or modify it 7 | under the terms of the GNU General Public License as published by the Free 8 | Software Foundation; either version 2 of the License, or (at your option) 9 | any later version. 10 | 11 | This program is distributed in the hope that it will be useful, but WITHOUT 12 | ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 13 | FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for 14 | more details. 15 | 16 | You should have received a copy of the GNU General Public License along with 17 | this program; if not, write to the Free Software Foundation, Inc., 59 Temple 18 | Place, Suite 330, Boston, MA 02111-1307 USA 19 | */ 20 | 21 | 22 | 23 | #ifndef __BREAKPOINTS_H 24 | #define __BREAKPOINTS_H 25 | 26 | void addBreakpoint(unsigned int addr); 27 | void removeBreakpoint(unsigned int addr); 28 | bool isBreakpoint(unsigned int addr); 29 | 30 | #endif 31 | -------------------------------------------------------------------------------- /bsd_syscalls.h: -------------------------------------------------------------------------------- 1 | 2 | #ifndef __BSD_SYSCALLS 3 | #define __BSD_SYSCALLS 4 | 5 | #define BSD_SYS_EXIT 1 6 | #define BSD_SYS_FORK 2 7 | #define BSD_SYS_READ 3 8 | #define BSD_SYS_WRITE 4 9 | 10 | #define BSD_SYS_OPEN 5 11 | #define BSD_SYS_CLOSE 6 12 | #define BSD_SYS_WAIT4 7 13 | 14 | #define BSD_SYS_CHDIR 12 15 | 16 | #define BSD_SYS_OLD_LSEEK 19 17 | 18 | #define BSD_SYS_SETUID 23 19 | #define BSD_SYS_GETUID 24 20 | #define BSD_SYS_GETEUID 25 21 | 22 | #define BSD_SYS_RECVFROM 29 23 | #define BSD_SYS_ACCEPT 30 24 | #define BSD_SYS_GETPEERNAME 31 25 | 26 | #define BSD_SYS_GETEGID 43 27 | 28 | #define BSD_SYS_SETGID 181 29 | #define BSD_SYS_SETEGID 182 30 | #define BSD_SYS_SETEUID 183 31 | #define BSD_SYS_GETGID 47 32 | 33 | #define BSD_SYS_SETREUID 126 34 | #define BSD_SYS_SETREGID 127 35 | 36 | #define BSD_SYS_SETGROUPS 80 37 | 38 | #define BSD_SYS_SENDTO 133 39 | #define BSD_SYS_SHUTDOWN 134 40 | 41 | #define BSD_SYS_SETRESUID 311 42 | #define BSD_SYS_GETRESUID 360 43 | 44 | #define BSD_SYS_SETRESGID 312 45 | #define BSD_SYS_GETRESGID 361 46 | 47 | #define BSD_SYS_KILL 37 48 | #define BSD_SYS_GETPPID 39 49 | 50 | #define BSD_SYS_EXECVE 59 51 | 52 | #define BSD_SYS_MPROTECT 74 53 | 54 | #define BSD_SYS_DUP2 90 55 | 56 | #define BSD_SYS_SOCKET 97 57 | #define BSD_SYS_CONNECT 98 58 | #define BSD_SYS_BIND 104 59 | #define BSD_SYS_SETSOCKOPT 105 60 | #define BSD_SYS_LISTEN 106 61 | 62 | #define BSD_SYS_LSEEK 199 63 | 64 | #define BSD_SYS_NANOSLEEP 240 65 | #define BSD_SYS_SIGACTION 416 66 | 67 | #endif 68 | -------------------------------------------------------------------------------- /buffer.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | Source for x86 emulator IdaPro plugin 3 | File: buffer.cpp 4 | Copyright (c) 2005-2022 Chris Eagle 5 | 6 | This program is free software; you can redistribute it and/or modify it 7 | under the terms of the GNU General Public License as published by the Free 8 | Software Foundation; either version 2 of the License, or (at your option) 9 | any later version. 10 | 11 | This program is distributed in the hope that it will be useful, but WITHOUT 12 | ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 13 | FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for 14 | more details. 15 | 16 | You should have received a copy of the GNU General Public License along with 17 | this program; if not, write to the Free Software Foundation, Inc., 59 Temple 18 | Place, Suite 330, Boston, MA 02111-1307 USA 19 | */ 20 | 21 | #include 22 | #include 23 | #include "buffer.h" 24 | 25 | #define BLOCK_SIZE 0x100 //keep this a power of two 26 | 27 | Buffer::Buffer() { 28 | init(BLOCK_SIZE); 29 | } 30 | 31 | Buffer::Buffer(unsigned int magic) { 32 | init(BLOCK_SIZE); 33 | this->magic = magic; 34 | write(&magic, sizeof(magic)); 35 | } 36 | 37 | Buffer::Buffer(unsigned char *buf, size_t len) { 38 | init(len); 39 | if (!error) { 40 | if (len >= 4) { //check for presence of BUFFER_MAGIC 41 | unsigned int m = *(unsigned int*)buf; 42 | if ((m & BUFFER_MAGIC_MASK) == BUFFER_MAGIC) { 43 | magic = m; 44 | len -= 4; //adjust length 45 | buf += 4; //adjust buffer start 46 | } 47 | } 48 | memcpy(bptr, buf, len); 49 | } 50 | wptr = sz; 51 | } 52 | 53 | void Buffer::init(size_t size) { 54 | bptr = (unsigned char *)malloc(size); 55 | sz = bptr ? size : 0; 56 | rptr = wptr = 0; 57 | error = sz != size; 58 | magic = 0; 59 | } 60 | 61 | Buffer::~Buffer() { 62 | free(bptr); 63 | } 64 | 65 | int Buffer::read(void *data, size_t len) { 66 | if ((rptr + len) <= sz) { 67 | memcpy(data, bptr + rptr, len); 68 | rptr += len; 69 | return 0; 70 | } 71 | error = true; 72 | return 1; 73 | } 74 | 75 | bool Buffer::rewind(size_t amt) { 76 | if (rptr >= amt) { 77 | rptr -= amt; 78 | return true; 79 | } 80 | return false; 81 | } 82 | 83 | int Buffer::write(const void *data, size_t len) { 84 | if (!check_size(wptr + len)) { 85 | memcpy(bptr + wptr, data, len); 86 | wptr += len; 87 | return 0; 88 | } 89 | error = true; 90 | return 1; 91 | } 92 | 93 | int Buffer::readString(char **str) { 94 | size_t len; 95 | if (read(&len, sizeof(len)) == 0) { 96 | *str = (char*)malloc(len); 97 | if (*str && read(*str, len) == 0) return 0; 98 | free(*str); 99 | } 100 | error = true; 101 | return 1; 102 | } 103 | 104 | int Buffer::writeString(const char *str) { 105 | size_t len = strlen(str) + 1; 106 | if (write(&len, sizeof(len)) == 0) { 107 | return write(str, len); 108 | } 109 | error = true; 110 | return 1; 111 | } 112 | 113 | unsigned char *Buffer::get_buf() { 114 | return bptr; 115 | } 116 | 117 | size_t Buffer::get_wlen() { 118 | return wptr; 119 | } 120 | 121 | size_t Buffer::get_rlen() { 122 | return rptr; 123 | } 124 | 125 | int Buffer::check_size(size_t max) { 126 | if (max <= sz) return 0; 127 | max = (max + BLOCK_SIZE) & ~(BLOCK_SIZE - 1); //round up to next BLOCK_SIZE 128 | unsigned char *tmp = (unsigned char *)realloc(bptr, max); 129 | if (tmp) { 130 | bptr = tmp; 131 | sz = max; 132 | return 0; 133 | } 134 | error = true; 135 | return 1; 136 | } 137 | 138 | unsigned int Buffer::getVersion() { 139 | return ((magic & BUFFER_MAGIC_MASK) == BUFFER_MAGIC) ? (magic & ~BUFFER_MAGIC_MASK) : 0; 140 | } 141 | 142 | -------------------------------------------------------------------------------- /buffer.h: -------------------------------------------------------------------------------- 1 | /* 2 | Source for x86 emulator IdaPro plugin 3 | File: buffer.h 4 | Copyright (c) 2005-2022 Chris Eagle 5 | 6 | This program is free software; you can redistribute it and/or modify it 7 | under the terms of the GNU General Public License as published by the Free 8 | Software Foundation; either version 2 of the License, or (at your option) 9 | any later version. 10 | 11 | This program is distributed in the hope that it will be useful, but WITHOUT 12 | ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 13 | FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for 14 | more details. 15 | 16 | You should have received a copy of the GNU General Public License along with 17 | this program; if not, write to the Free Software Foundation, Inc., 59 Temple 18 | Place, Suite 330, Boston, MA 02111-1307 USA 19 | */ 20 | 21 | #ifndef __BUFFER_H 22 | #define __BUFFER_H 23 | 24 | #include 25 | 26 | #define BUFFER_MAGIC 0x861DA000 27 | #define BUFFER_MAGIC_MASK 0xFFFFF000 28 | #define VERSION(n) (BUFFER_MAGIC | n) 29 | 30 | class Buffer { 31 | public: 32 | Buffer(); 33 | Buffer(unsigned int magic); 34 | Buffer(unsigned char *buf, size_t len); 35 | ~Buffer(); 36 | 37 | int read(void *data, size_t len); 38 | bool rewind(size_t amt); 39 | int write(const void *data, size_t len); 40 | int readString(char **str); 41 | int writeString(const char *str); 42 | 43 | unsigned char *get_buf(); 44 | size_t get_wlen(); 45 | size_t get_rlen(); 46 | bool has_error() {return error;}; 47 | void reset_error() {error = false;}; 48 | unsigned int getMagic() {return magic;}; 49 | unsigned int getVersion(); 50 | 51 | private: 52 | Buffer(const Buffer & /*b*/) {}; 53 | int check_size(size_t max); 54 | void init(size_t size); 55 | 56 | unsigned int magic; 57 | unsigned char *bptr; 58 | size_t rptr; 59 | size_t wptr; 60 | size_t sz; 61 | bool error; 62 | }; 63 | 64 | #endif 65 | 66 | -------------------------------------------------------------------------------- /build.linux32: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | qmake -o Makefile.g++32 x86emu.pro -platform linux-g++ 4 | gmake -f Makefile.g++32 clean 5 | gmake -f Makefile.g++32 6 | cp ./bin/libx86emu_qt.so.1.0.0 ./bin/x86emu_qt.plx 7 | -------------------------------------------------------------------------------- /build.linux64: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | qmake -o Makefile.g++64 x86emu64.pro -platform linux-g++ 4 | gmake -f Makefile.g++64 clean 5 | gmake -f Makefile.g++64 6 | cp ./bin/libx86emu_qt.so.1.0.0 ./bin/x86emu_qt.plx64 7 | -------------------------------------------------------------------------------- /build.mac32: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | if [ -z "$1" ]; then 4 | echo "missing qt mkspec argument (macx-g++ or macx-clang-32)" 5 | exit 6 | fi 7 | 8 | qmake -o Makefile.mac32 x86emu.pro -platform $1 9 | make -f Makefile.mac32 clean 10 | make -f Makefile.mac32 11 | cp ./bin/libx86emu_qt.1.0.0.dylib ./bin/x86emu_qt.pmc 12 | -------------------------------------------------------------------------------- /build.mac64: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | if [ -z "$1" ]; then 4 | echo "missing qt mkspec argument (macx-g++ or macx-clang-32)" 5 | exit 6 | fi 7 | 8 | qmake -o Makefile.mac64 x86emu64.pro -platform $1 9 | make -f Makefile.mac64 clean 10 | make -f Makefile.mac64 11 | cp ./bin/libx86emu_qt.1.0.0.dylib ./bin/x86emu_qt.pmc64 12 | -------------------------------------------------------------------------------- /build.win32: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | qmake -o Makefile.msvc x86emu.pro -platform win32-msvc2010 4 | nmake -f Makefile.msvc clean 5 | nmake -f Makefile.msvc 6 | -------------------------------------------------------------------------------- /build.win64: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | qmake -o Makefile64.msvc x86emu64.pro -platform win32-msvc2010 4 | nmake -f Makefile64.msvc clean 5 | nmake -f Makefile64.msvc 6 | -------------------------------------------------------------------------------- /build7.linux32: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | export IDAVER=`pwd | grep -o -E "idasdk[0-9]{2}" | cut -c 7-`0 4 | 5 | qmake -o Makefile.g++32 x86emu32-7.pro -platform linux-g++ 6 | gmake -f Makefile.g++32 clean 7 | gmake -f Makefile.g++32 8 | cp ./bin/libx86emu_qt.so.1.0.0 ./bin/x86emu_qt.so 9 | -------------------------------------------------------------------------------- /build7.linux64: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | export IDAVER=`pwd | grep -o -E "idasdk[0-9]{2}" | cut -c 7-`0 4 | 5 | qmake -o Makefile.g++64 x86emu64-7.pro -platform linux-g++ 6 | gmake -f Makefile.g++64 clean 7 | gmake -f Makefile.g++64 8 | cp ./bin/libx86emu_qt64.so.1.0.0 ./bin/x86emu_qt64.so 9 | -------------------------------------------------------------------------------- /build7.mac32: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | if [ -z "$1" ]; then 4 | echo "missing qt mkspec argument (macx-g++, macx-clang-32, or macx-clang (7.0))" 5 | exit 6 | fi 7 | 8 | export IDAVER=`pwd | grep -o -E "idasdk[0-9]{2}" | cut -c 7-`0 9 | 10 | qmake -o Makefile.mac32 x86emu32-7.pro -platform $1 11 | make -f Makefile.mac32 clean 12 | make -f Makefile.mac32 13 | cp ./bin/libx86emu_qt.1.0.0.dylib ./bin/x86emu_qt.dylib 14 | -------------------------------------------------------------------------------- /build7.mac64: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | if [ -z "$1" ]; then 4 | echo "missing qt mkspec argument (macx-g++, macx-clang-32, or macx-clang (7.0))" 5 | exit 6 | fi 7 | 8 | export IDAVER=`pwd | grep -o -E "idasdk[0-9]{2}" | cut -c 7-`0 9 | 10 | qmake -o Makefile.mac64 x86emu64-7.pro -platform $1 11 | make -f Makefile.mac64 clean 12 | make -f Makefile.mac64 13 | cp ./bin/libx86emu_qt64.1.0.0.dylib ./bin/x86emu_qt64.dylib 14 | -------------------------------------------------------------------------------- /build7.win32: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | qmake -o Makefile32-7.msvc x86emu32-7.pro -platform win32-msvc2013 4 | nmake -f Makefile32-7.msvc clean 5 | nmake -f Makefile32-7.msvc 6 | -------------------------------------------------------------------------------- /build7.win64: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | qmake -o Makefile64-7.msvc x86emu64-7.pro -platform win32-msvc2013 4 | nmake -f Makefile64-7.msvc clean 5 | nmake -f Makefile64-7.msvc 6 | -------------------------------------------------------------------------------- /cgc_syscalls.h: -------------------------------------------------------------------------------- 1 | 2 | #ifndef __CGC_SYSCALLS 3 | #define __CGC_SYSCALLS 4 | 5 | #define CGC_SYS_TERMINATE 1 6 | #define CGC_SYS_TRANSMIT 2 7 | #define CGC_SYS_RECEIVE 3 8 | #define CGC_SYS_FDWAIT 4 9 | #define CGC_SYS_ALLOCATE 5 10 | #define CGC_SYS_DEALLOCATE 6 11 | #define CGC_SYS_RANDOM 7 12 | 13 | 14 | //error numbers 15 | #define CGC_EBADF 1 16 | #define CGC_EFAULT 2 17 | #define CGC_EINVAL 3 18 | #define CGC_ENOMEM 4 19 | #define CGC_ENOSYS 5 20 | #define CGC_EPIPE 6 21 | 22 | #define GDT_ENTRY_TLS_MIN 6 23 | #define GDT_ENTRY_TLS_MAX 8 24 | 25 | #define CGC_FD_SETSIZE 1024 26 | 27 | typedef long int cgc_fd_mask; 28 | 29 | #define CGC_NFDBITS (8 * sizeof(cgc_fd_mask)) 30 | 31 | struct cgc_fd_set { 32 | cgc_fd_mask _fd_bits[CGC_FD_SETSIZE / CGC_NFDBITS]; 33 | }; 34 | 35 | #define CGC_FD_ZERO(set) \ 36 | do { \ 37 | int __i; \ 38 | for (__i = 0; __i < (CGC_FD_SETSIZE / CGC_NFDBITS); __i++) \ 39 | (set)->_fd_bits[__i] = 0; \ 40 | } while (0) 41 | #define CGC_FD_SET(b, set) \ 42 | ((set)->_fd_bits[b / CGC_NFDBITS] |= (1 << (b & (CGC_NFDBITS - 1)))) 43 | #define CGC_FD_CLR(b, set) \ 44 | ((set)->_fd_bits[b / CGC_NFDBITS] &= ~(1 << (b & (CGC_NFDBITS - 1)))) 45 | #define CGC_FD_ISSET(b, set) \ 46 | ((set)->_fd_bits[b / CGC_NFDBITS] & (1 << (b & (CGC_NFDBITS - 1)))) 47 | 48 | struct cgc_timeval { 49 | int tv_sec; 50 | int tv_usec; 51 | }; 52 | 53 | #endif 54 | -------------------------------------------------------------------------------- /context.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | Source for x86 emulator IdaPro plugin 3 | File: context.cpp 4 | Copyright (c) 2006-2022, Chris Eagle 5 | 6 | This program is free software; you can redistribute it and/or modify it 7 | under the terms of the GNU General Public License as published by the Free 8 | Software Foundation; either version 2 of the License, or (at your option) 9 | any later version. 10 | 11 | This program is distributed in the hope that it will be useful, but WITHOUT 12 | ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 13 | FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for 14 | more details. 15 | 16 | You should have received a copy of the GNU General Public License along with 17 | this program; if not, write to the Free Software Foundation, Inc., 59 Temple 18 | Place, Suite 330, Boston, MA 02111-1307 USA 19 | */ 20 | 21 | #include "cpu.h" 22 | #include "context.h" 23 | 24 | //Copy current CPU state into CONTEXT structure for Windows Exception Handling 25 | //Note that the global ctx struct is the only place that Debug and Floating 26 | //point registers are currently defined 27 | void regsToContext(Registers *regs, WIN_CONTEXT *ctx) { 28 | ctx->Dr0 = regs->debug_regs[DR0]; 29 | ctx->Dr1 = regs->debug_regs[DR1]; 30 | ctx->Dr2 = regs->debug_regs[DR2]; 31 | ctx->Dr3 = regs->debug_regs[DR3]; 32 | ctx->Dr6 = regs->debug_regs[DR6]; 33 | ctx->Dr7 = regs->debug_regs[DR7]; 34 | ctx->Eax = regs->general[EAX]; 35 | ctx->Ebx = regs->general[EBX]; 36 | ctx->Ecx = regs->general[ECX]; 37 | ctx->Edx = regs->general[EDX]; 38 | ctx->Edi = regs->general[EDI]; 39 | ctx->Esi = regs->general[ESI]; 40 | ctx->Ebp = regs->general[EBP]; 41 | ctx->Esp = regs->general[ESP]; 42 | // ctx->Eip = eip; 43 | ctx->Eip = regs->eip; //use address at which exception occurred 44 | ctx->EFlags = regs->eflags; 45 | ctx->SegSs = regs->segReg[SS]; 46 | ctx->SegCs = regs->segReg[CS]; 47 | ctx->SegDs = regs->segReg[DS]; 48 | ctx->SegEs = regs->segReg[ES]; 49 | ctx->SegFs = regs->segReg[FS]; 50 | ctx->SegGs = regs->segReg[GS]; 51 | } 52 | 53 | //Copy from CONTEXT structure into CPU state for Windows Exception Handling 54 | //Note that the global ctx struct is the only place that Debug and Floating 55 | //point registers are currently defined 56 | void contextToRegs(WIN_CONTEXT *ctx, Registers *regs) { 57 | regs->debug_regs[DR0] = ctx->Dr0; 58 | regs->debug_regs[DR1] = ctx->Dr1; 59 | regs->debug_regs[DR2] = ctx->Dr2; 60 | regs->debug_regs[DR3] = ctx->Dr3; 61 | regs->debug_regs[DR6] = ctx->Dr6; 62 | regs->debug_regs[DR7] = ctx->Dr7; 63 | regs->general[EAX] = ctx->Eax; 64 | regs->general[EBX] = ctx->Ebx; 65 | regs->general[ECX] = ctx->Ecx; 66 | regs->general[EDX] = ctx->Edx; 67 | regs->general[EDI] = ctx->Edi; 68 | regs->general[ESI] = ctx->Esi; 69 | regs->general[EBP] = ctx->Ebp; 70 | regs->general[ESP] = ctx->Esp; 71 | regs->eip = ctx->Eip; 72 | regs->eflags = ctx->EFlags; 73 | regs->segReg[SS] = ctx->SegSs; 74 | regs->segReg[CS] = ctx->SegCs; 75 | regs->segReg[DS] = ctx->SegDs; 76 | regs->segReg[ES] = ctx->SegEs; 77 | regs->segReg[FS] = ctx->SegFs; 78 | regs->segReg[GS] = ctx->SegGs; 79 | } 80 | 81 | void initContext(WIN_CONTEXT *ctx) { 82 | memset(ctx, 0, sizeof(WIN_CONTEXT)); 83 | } 84 | 85 | void copyContextToMem(WIN_CONTEXT *ctx, unsigned int addr) { 86 | unsigned char *ptr = (unsigned char*) ctx; 87 | for (unsigned int i = 0; i < sizeof(WIN_CONTEXT); i++) { 88 | writeMem(addr++, *ptr++, SIZE_BYTE); 89 | } 90 | } 91 | /* 92 | unsigned int pushContext() { 93 | unsigned int ctx_size = (sizeof(CONTEXT) + 3) & ~3; //round up to next unsigned int 94 | unsigned int addr = esp - ctx_size; 95 | copyContextToMem(addr); 96 | esp = addr; 97 | return esp; 98 | } 99 | */ 100 | -------------------------------------------------------------------------------- /context.h: -------------------------------------------------------------------------------- 1 | /* 2 | Source for x86 emulator IdaPro plugin 3 | File: context.h 4 | Copyright (c) 2006-2022, Chris Eagle 5 | 6 | This program is free software; you can redistribute it and/or modify it 7 | under the terms of the GNU General Public License as published by the Free 8 | Software Foundation; either version 2 of the License, or (at your option) 9 | any later version. 10 | 11 | This program is distributed in the hope that it will be useful, but WITHOUT 12 | ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 13 | FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for 14 | more details. 15 | 16 | You should have received a copy of the GNU General Public License along with 17 | this program; if not, write to the Free Software Foundation, Inc., 59 Temple 18 | Place, Suite 330, Boston, MA 02111-1307 USA 19 | */ 20 | 21 | #ifndef __WIN_CONTEXT_H 22 | #define __WIN_CONTEXT_H 23 | 24 | #define SIZEOF_387_REGS 80 25 | #define MAXIMUM_EXTENSION 512 26 | 27 | struct WIN_FLOATING_SAVE_AREA { 28 | unsigned int ControlWord; 29 | unsigned int StatusWord; 30 | unsigned int TagWord; 31 | unsigned int ErrorOffset; 32 | unsigned int ErrorSelector; 33 | unsigned int DataOffset; 34 | unsigned int DataSelector; 35 | unsigned char RegisterArea[SIZEOF_387_REGS]; 36 | unsigned int Cr0NpxState; 37 | }; 38 | 39 | struct WIN_CONTEXT { 40 | 41 | unsigned int ContextFlags; 42 | 43 | unsigned int Dr0; 44 | unsigned int Dr1; 45 | unsigned int Dr2; 46 | unsigned int Dr3; 47 | unsigned int Dr6; 48 | unsigned int Dr7; 49 | 50 | WIN_FLOATING_SAVE_AREA FloatSave; 51 | 52 | unsigned int SegGs; 53 | unsigned int SegFs; 54 | unsigned int SegEs; 55 | unsigned int SegDs; 56 | 57 | unsigned int Edi; //0x9C 58 | unsigned int Esi; //0xA0 59 | unsigned int Ebx; //0xA4 60 | unsigned int Edx; //0xA8 61 | unsigned int Ecx; //0xAC 62 | unsigned int Eax; //0xB0 63 | 64 | unsigned int Ebp; //0xB4 65 | unsigned int Eip; //0xB8 66 | unsigned int SegCs; 67 | unsigned int EFlags; 68 | unsigned int Esp; 69 | unsigned int SegSs; 70 | 71 | unsigned char ExtendedRegisters[MAXIMUM_EXTENSION]; 72 | 73 | }; 74 | 75 | void regsToContext(Registers *regs, WIN_CONTEXT *ctx); 76 | void contextToRegs(WIN_CONTEXT *ctx, Registers *regs); 77 | void initContext(WIN_CONTEXT *ctx); 78 | void copyContextToMem(WIN_CONTEXT *ctx, unsigned int addr); 79 | 80 | 81 | #endif 82 | -------------------------------------------------------------------------------- /cpu.h: -------------------------------------------------------------------------------- 1 | /* 2 | Headers for x86 emulator 3 | Copyright (c) 2003-2022 Chris Eagle 4 | 5 | This program is free software; you can redistribute it and/or modify it 6 | under the terms of the GNU General Public License as published by the Free 7 | Software Foundation; either version 2 of the License, or (at your option) 8 | any later version. 9 | 10 | This program is distributed in the hope that it will be useful, but WITHOUT 11 | ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 12 | FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for 13 | more details. 14 | 15 | You should have received a copy of the GNU General Public License along with 16 | this program; if not, write to the Free Software Foundation, Inc., 59 Temple 17 | Place, Suite 330, Boston, MA 02111-1307 USA 18 | */ 19 | 20 | #ifndef __CPU_H 21 | #define __CPU_H 22 | 23 | #include "x86defs.h" 24 | 25 | #define CPU_VERSION VERSION(1) 26 | 27 | typedef struct _DescriptorTableReg_t { 28 | unsigned int base; 29 | unsigned short limit; 30 | } DescriptorTableReg; 31 | 32 | struct Registers { 33 | unsigned int debug_regs[8]; 34 | unsigned int general[8]; 35 | unsigned int initial_eip; 36 | unsigned int eip; 37 | unsigned int eflags; 38 | unsigned int control[5]; 39 | unsigned int segBase[6]; //cached segment base addresses 40 | unsigned short segReg[6]; 41 | DescriptorTableReg gdtr; 42 | DescriptorTableReg idtr; 43 | }; 44 | 45 | extern Registers cpu; 46 | 47 | union FpuMmxRegister { 48 | long double fp; 49 | unsigned char b[10]; //only use 8 of these for mmx 50 | unsigned short s[4]; 51 | unsigned int i[2]; 52 | unsigned long long ll; 53 | }; 54 | 55 | struct FloatingPointUnit { 56 | FpuMmxRegister r[8]; 57 | unsigned short control; 58 | unsigned short status; 59 | unsigned short tag; 60 | unsigned int lastIP; 61 | unsigned int lastIPseg; 62 | unsigned int lastDataPointer; 63 | unsigned int lastDataSeg; 64 | unsigned short opcode; 65 | }; 66 | 67 | extern FloatingPointUnit fpu; 68 | 69 | struct SSE2Registers { 70 | unsigned int mxcsr; 71 | union { 72 | unsigned char b[8][16]; 73 | unsigned short w[8][8]; 74 | unsigned int i[8][4]; 75 | float f[8][4]; 76 | unsigned long long ll[8][2]; 77 | double d[8][2]; 78 | } xmm; 79 | }; 80 | 81 | extern SSE2Registers sse2; 82 | 83 | extern ll_union tsc; 84 | 85 | //masks to clear out bytes appropriate to the sizes above 86 | extern unsigned int SIZE_MASKS[5]; 87 | 88 | //masks to clear out bytes appropriate to the sizes above 89 | extern unsigned int SIGN_BITS[5]; 90 | 91 | //masks to clear out bytes appropriate to the sizes above 92 | extern unsigned long long CARRY_BITS[5]; 93 | 94 | extern unsigned char BITS[5]; 95 | 96 | extern unsigned int importSavePoint; 97 | 98 | extern unsigned int shouldBreak; 99 | extern bool breakOnExceptions; 100 | 101 | typedef struct _IntrRecord_t { 102 | bool hasError; 103 | struct _IntrRecord_t *next; 104 | } IntrRecord; 105 | 106 | typedef struct _AddrInfo_t { 107 | unsigned int addr; 108 | unsigned char type; 109 | unsigned char modrm; 110 | } AddrInfo; 111 | 112 | //struct to describe an instruction being decoded 113 | typedef struct _inst { 114 | AddrInfo source; 115 | AddrInfo dest; 116 | unsigned int opsize; //operand size for this instruction 117 | unsigned int prefix; //any prefix flags 118 | unsigned char opcode; //opcode, first or second unsigned char (if first == 0x0F) 119 | } inst; 120 | 121 | // Status codes returned by the database blob reading routine 122 | enum { 123 | X86EMULOAD_OK, // state loaded ok 124 | X86EMULOAD_VERSION_INCOMPATIBLE, // incompatible version 125 | X86EMULOAD_CORRUPT, // corrupt/truncated 126 | X86EMULOAD_UNKNOWN_HOOKFN, // contains hook to unknown hook function 127 | X86EMULOAD_NO_NETNODE, // no save data present 128 | X86EMUSAVE_OK, // state save success 129 | X86EMUSAVE_FAILED // state save failed (buffer problems) 130 | }; 131 | 132 | void initProgram(unsigned int entry, unsigned int idtBase, unsigned int idtLimit); 133 | void enableSEH(); 134 | 135 | void resetCpu(); 136 | 137 | void push(unsigned int val, unsigned char size); 138 | unsigned int pop(unsigned char size); 139 | unsigned char readByte(unsigned int addr); 140 | void writeByte(unsigned int addr, unsigned char val); 141 | unsigned int readDword(unsigned int addr); 142 | void writeDword(unsigned int addr, unsigned int val); 143 | void writeMem(unsigned int addr, unsigned int val, unsigned char size); 144 | unsigned int readMem(unsigned int addr, unsigned char size); 145 | 146 | int executeInstruction(); 147 | void doInterruptReturn(); 148 | 149 | void initGDTR(unsigned int gdtBase, unsigned int gdtLimit); 150 | unsigned int getGdtDescBase(unsigned int desc); 151 | unsigned int getGdtDescLimit(unsigned int desc); 152 | void setGdtDesc(unsigned int desc, unsigned int base, unsigned int limit); 153 | 154 | typedef int (*operand_func)(void); 155 | 156 | #ifdef __IDP__ 157 | 158 | int saveState(netnode &f); 159 | int loadState(netnode &f); 160 | 161 | #endif 162 | 163 | #endif 164 | 165 | -------------------------------------------------------------------------------- /elf32.h: -------------------------------------------------------------------------------- 1 | /*- 2 | * Copyright (c) 1996-1998 John D. Polstra. 3 | * All rights reserved. 4 | * 5 | * Redistribution and use in source and binary forms, with or without 6 | * modification, are permitted provided that the following conditions 7 | * are met: 8 | * 1. Redistributions of source code must retain the above copyright 9 | * notice, this list of conditions and the following disclaimer. 10 | * 2. Redistributions in binary form must reproduce the above copyright 11 | * notice, this list of conditions and the following disclaimer in the 12 | * documentation and/or other materials provided with the distribution. 13 | * 14 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND 15 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 16 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 17 | * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 18 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 19 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 20 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 21 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 22 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 23 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 24 | * SUCH DAMAGE. 25 | * 26 | * $FreeBSD: src/sys/sys/elf32.h,v 1.8 2002/05/30 08:32:18 dfr Exp $ 27 | */ 28 | 29 | #ifndef _SYS_ELF32_H_ 30 | #define _SYS_ELF32_H_ 1 31 | 32 | #include "elf_common.h" 33 | 34 | /* 35 | * ELF definitions common to all 32-bit architectures. 36 | */ 37 | 38 | typedef u_int32_t Elf32_Addr; 39 | typedef u_int16_t Elf32_Half; 40 | typedef u_int32_t Elf32_Off; 41 | typedef int32_t Elf32_Sword; 42 | typedef u_int32_t Elf32_Word; 43 | typedef u_int32_t Elf32_Size; 44 | typedef Elf32_Off Elf32_Hashelt; 45 | 46 | /* 47 | * ELF header. 48 | */ 49 | 50 | typedef struct { 51 | unsigned char e_ident[EI_NIDENT]; /* File identification. */ 52 | Elf32_Half e_type; /* File type. */ 53 | Elf32_Half e_machine; /* Machine architecture. */ 54 | Elf32_Word e_version; /* ELF format version. */ 55 | Elf32_Addr e_entry; /* Entry point. */ 56 | Elf32_Off e_phoff; /* Program header file offset. */ 57 | Elf32_Off e_shoff; /* Section header file offset. */ 58 | Elf32_Word e_flags; /* Architecture-specific flags. */ 59 | Elf32_Half e_ehsize; /* Size of ELF header in bytes. */ 60 | Elf32_Half e_phentsize; /* Size of program header entry. */ 61 | Elf32_Half e_phnum; /* Number of program header entries. */ 62 | Elf32_Half e_shentsize; /* Size of section header entry. */ 63 | Elf32_Half e_shnum; /* Number of section header entries. */ 64 | Elf32_Half e_shstrndx; /* Section name strings section. */ 65 | } Elf32_Ehdr; 66 | 67 | /* 68 | * Section header. 69 | */ 70 | 71 | typedef struct { 72 | Elf32_Word sh_name; /* Section name (index into the 73 | section header string table). */ 74 | Elf32_Word sh_type; /* Section type. */ 75 | Elf32_Word sh_flags; /* Section flags. */ 76 | Elf32_Addr sh_addr; /* Address in memory image. */ 77 | Elf32_Off sh_offset; /* Offset in file. */ 78 | Elf32_Size sh_size; /* Size in bytes. */ 79 | Elf32_Word sh_link; /* Index of a related section. */ 80 | Elf32_Word sh_info; /* Depends on section type. */ 81 | Elf32_Size sh_addralign; /* Alignment in bytes. */ 82 | Elf32_Size sh_entsize; /* Size of each entry in section. */ 83 | } Elf32_Shdr; 84 | 85 | /* 86 | * Program header. 87 | */ 88 | 89 | typedef struct { 90 | Elf32_Word p_type; /* Entry type. */ 91 | Elf32_Off p_offset; /* File offset of contents. */ 92 | Elf32_Addr p_vaddr; /* Virtual address in memory image. */ 93 | Elf32_Addr p_paddr; /* Physical address (not used). */ 94 | Elf32_Size p_filesz; /* Size of contents in file. */ 95 | Elf32_Size p_memsz; /* Size of contents in memory. */ 96 | Elf32_Word p_flags; /* Access permission flags. */ 97 | Elf32_Size p_align; /* Alignment in memory and file. */ 98 | } Elf32_Phdr; 99 | 100 | /* 101 | * Dynamic structure. The ".dynamic" section contains an array of them. 102 | */ 103 | 104 | typedef struct { 105 | Elf32_Sword d_tag; /* Entry type. */ 106 | union { 107 | Elf32_Size d_val; /* Integer value. */ 108 | Elf32_Addr d_ptr; /* Address value. */ 109 | } d_un; 110 | } Elf32_Dyn; 111 | 112 | /* 113 | * Relocation entries. 114 | */ 115 | 116 | /* Relocations that don't need an addend field. */ 117 | typedef struct { 118 | Elf32_Addr r_offset; /* Location to be relocated. */ 119 | Elf32_Word r_info; /* Relocation type and symbol index. */ 120 | } Elf32_Rel; 121 | 122 | /* Relocations that need an addend field. */ 123 | typedef struct { 124 | Elf32_Addr r_offset; /* Location to be relocated. */ 125 | Elf32_Word r_info; /* Relocation type and symbol index. */ 126 | Elf32_Sword r_addend; /* Addend. */ 127 | } Elf32_Rela; 128 | 129 | /* Macros for accessing the fields of r_info. */ 130 | #define ELF32_R_SYM(info) ((info) >> 8) 131 | #define ELF32_R_TYPE(info) ((unsigned char)(info)) 132 | 133 | /* Macro for constructing r_info from field values. */ 134 | #define ELF32_R_INFO(sym, type) (((sym) << 8) + (unsigned char)(type)) 135 | 136 | /* 137 | * Symbol table entries. 138 | */ 139 | 140 | typedef struct { 141 | Elf32_Word st_name; /* String table index of name. */ 142 | Elf32_Addr st_value; /* Symbol value. */ 143 | Elf32_Size st_size; /* Size of associated object. */ 144 | unsigned char st_info; /* Type and binding information. */ 145 | unsigned char st_other; /* Reserved (not used). */ 146 | Elf32_Half st_shndx; /* Section index of symbol. */ 147 | } Elf32_Sym; 148 | 149 | /* Macros for accessing the fields of st_info. */ 150 | #define ELF32_ST_BIND(info) ((info) >> 4) 151 | #define ELF32_ST_TYPE(info) ((info) & 0xf) 152 | 153 | /* Macro for constructing st_info from field values. */ 154 | #define ELF32_ST_INFO(bind, type) (((bind) << 4) + ((type) & 0xf)) 155 | 156 | #endif /* !_SYS_ELF32_H_ */ 157 | -------------------------------------------------------------------------------- /emu_script.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | Scripting support for the x86 emulator IdaPro plugin 3 | Copyright (c) 2008-2022 Chris Eagle 4 | 5 | This program is free software; you can redistribute it and/or modify it 6 | under the terms of the GNU General Public License as published by the Free 7 | Software Foundation; either version 2 of the License, or (at your option) 8 | any later version. 9 | 10 | This program is distributed in the hope that it will be useful, but WITHOUT 11 | ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 12 | FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for 13 | more details. 14 | 15 | You should have received a copy of the GNU General Public License along with 16 | this program; if not, write to the Free Software Foundation, Inc., 59 Temple 17 | Place, Suite 330, Boston, MA 02111-1307 USA 18 | */ 19 | 20 | #include 21 | #include 22 | 23 | #include "cpu.h" 24 | #include "emu_script.h" 25 | #include "sdk_versions.h" 26 | 27 | bool set_idc_func_ex(const char *name, idc_func_t *fp, const char *args, int extfunc_flags) { 28 | ext_idcfunc_t func; 29 | func.name = name; 30 | func.fptr = fp; 31 | func.args = args; 32 | func.defvals = NULL; 33 | func.ndefvals = 0; 34 | func.flags = extfunc_flags; 35 | return add_idc_func(func); 36 | } 37 | 38 | /* 39 | * prototypes for functions in x86emu.cpp that we use 40 | * to implement some of the scripted behavior 41 | */ 42 | void run(); 43 | void trace(); 44 | void stepOne(); 45 | void traceOne(); 46 | void emuSyncDisplay(); 47 | void setIdcRegister(unsigned int idc_reg_num, unsigned int newVal); 48 | void addBreakpoint(unsigned int addr); 49 | 50 | /* 51 | * native implementation of EmuRun. 52 | */ 53 | static error_t idaapi idc_emu_run(idc_value_t * /*argv*/, idc_value_t * /*res*/) { 54 | run(); 55 | return eOk; 56 | } 57 | 58 | /* 59 | * native implementation of EmuStepOne. 60 | */ 61 | static error_t idaapi idc_emu_step(idc_value_t * /*argv*/, idc_value_t * /*res*/) { 62 | stepOne(); 63 | return eOk; 64 | } 65 | 66 | /* 67 | * native implementation of EmuTraceOne. 68 | */ 69 | static error_t idaapi idc_emu_trace_one(idc_value_t * /*argv*/, idc_value_t * /*res*/) { 70 | traceOne(); 71 | return eOk; 72 | } 73 | 74 | /* 75 | * native implementation of EmuTrace. 76 | */ 77 | static error_t idaapi idc_emu_trace(idc_value_t * /*argv*/, idc_value_t * /*res*/) { 78 | trace(); 79 | return eOk; 80 | } 81 | 82 | /* 83 | * native implementation of EmuSync. 84 | */ 85 | static error_t idaapi idc_emu_sync(idc_value_t * /*argv*/, idc_value_t * /*res*/) { 86 | emuSyncDisplay(); 87 | return eOk; 88 | } 89 | 90 | /* 91 | * native implementation of EmuGetReg. Converts a register constant 92 | * into the appropriate offset into the cpu struct and returns the 93 | * value of the indicated register. Returns -1 if an invalid register 94 | * number is specified. 95 | */ 96 | static error_t idaapi idc_emu_getreg(idc_value_t *argv, idc_value_t *res) { 97 | res->vtype = VT_LONG; 98 | if (argv[0].vtype == VT_LONG) { 99 | unsigned int regnum = (unsigned int)argv[0].num; 100 | switch (regnum) { 101 | case EAX_REG: case ECX_REG: case EDX_REG: case EBX_REG: 102 | case ESP_REG: case EBP_REG: case ESI_REG: case EDI_REG: 103 | res->num = cpu.general[regnum - EAX_REG]; 104 | break; 105 | case EIP_REG: 106 | res->num = cpu.eip; 107 | break; 108 | case EFLAGS_REG: 109 | res->num = cpu.eflags; 110 | break; 111 | case CS_REG: case SS_REG: case DS_REG: case ES_REG: case FS_REG: case GS_REG: 112 | res->num = cpu.segReg[regnum - CS_REG]; 113 | break; 114 | case CS_BASE: case SS_BASE: case DS_BASE: case ES_BASE: case FS_BASE: case GS_BASE: 115 | res->num = cpu.segBase[regnum - CS_BASE]; 116 | break; 117 | case DR0_REG: case DR1_REG: case DR2_REG: case DR3_REG: 118 | case DR4_REG: case DR5_REG: case DR6_REG: case DR7_REG: 119 | res->num = cpu.debug_regs[regnum - DR0_REG]; 120 | break; 121 | default: 122 | res->num = -1; 123 | break; 124 | } 125 | } 126 | else { 127 | res->num = -1; 128 | } 129 | return eOk; 130 | } 131 | 132 | /* 133 | * native implementation of EmuSetReg. Converts a register constant 134 | * into the appropriate offset into the cpu struct and sets the 135 | * value of the indicated register. Returns 0 on success and -1 if an 136 | * invalid register number is specified. 137 | */ 138 | static error_t idaapi idc_emu_setreg(idc_value_t *argv, idc_value_t *res) { 139 | res->vtype = VT_LONG; 140 | res->num = 0; 141 | if (argv[0].vtype == VT_LONG && argv[1].vtype == VT_LONG) { 142 | unsigned int regnum = (unsigned int)argv[0].num; 143 | unsigned int regval = (unsigned int)argv[1].num; 144 | switch (regnum) { 145 | case EAX_REG: case ECX_REG: case EDX_REG: case EBX_REG: 146 | case ESP_REG: case EBP_REG: case ESI_REG: case EDI_REG: 147 | case EIP_REG: 148 | case EFLAGS_REG: 149 | //these registers are all displayed so we need to update the 150 | //respective control as well as set the register 151 | setIdcRegister(regnum, regval); 152 | break; 153 | case CS_REG: case SS_REG: case DS_REG: case ES_REG: case FS_REG: case GS_REG: 154 | cpu.segReg[regnum - CS_REG] = regval; 155 | break; 156 | case CS_BASE: case SS_BASE: case DS_BASE: case ES_BASE: case FS_BASE: case GS_BASE: 157 | cpu.segBase[regnum - CS_BASE] = regval; 158 | break; 159 | case DR0_REG: case DR1_REG: case DR2_REG: case DR3_REG: 160 | case DR4_REG: case DR5_REG: case DR6_REG: case DR7_REG: 161 | cpu.debug_regs[regnum - DR0_REG] = regval; 162 | break; 163 | default: 164 | res->num = -1; 165 | break; 166 | } 167 | } 168 | else { 169 | res->num = -1; 170 | } 171 | return eOk; 172 | } 173 | 174 | /* 175 | * native implementation of EmuAddBpt. Adds an emulator breakpoint 176 | * at the specified address. 177 | */ 178 | static error_t idaapi idc_emu_addbpt(idc_value_t *argv, idc_value_t *res) { 179 | res->vtype = VT_LONG; 180 | if (argv[0].vtype == VT_LONG) { 181 | unsigned int addr = (unsigned int)argv[0].num; 182 | addBreakpoint(addr); 183 | res->num = 1; 184 | } 185 | else { 186 | res->num = 0; 187 | } 188 | return eOk; 189 | } 190 | 191 | /* 192 | * Register new IDC functions for use with the emulator 193 | */ 194 | void register_funcs() { 195 | static const char idc_void[] = { 0 }; 196 | // static const char idc_str_args[] = { VT_STR, 0 }; 197 | static const char idc_long[] = { VT_LONG, 0 }; 198 | static const char idc_long_long[] = { VT_LONG, VT_LONG, 0 }; 199 | set_idc_func_ex("EmuRun", idc_emu_run, idc_void, EXTFUN_BASE); 200 | set_idc_func_ex("EmuTrace", idc_emu_trace, idc_void, EXTFUN_BASE); 201 | set_idc_func_ex("EmuStepOne", idc_emu_step, idc_void, EXTFUN_BASE); 202 | set_idc_func_ex("EmuTraceOne", idc_emu_trace_one, idc_void, EXTFUN_BASE); 203 | set_idc_func_ex("EmuSync", idc_emu_sync, idc_void, EXTFUN_BASE); 204 | set_idc_func_ex("EmuGetReg", idc_emu_getreg, idc_long, EXTFUN_BASE); 205 | set_idc_func_ex("EmuSetReg", idc_emu_setreg, idc_long_long, EXTFUN_BASE); 206 | set_idc_func_ex("EmuAddBpt", idc_emu_addbpt, idc_long, EXTFUN_BASE); 207 | } 208 | 209 | /* 210 | * Unregister IDC functions when the plugin is unloaded 211 | */ 212 | void unregister_funcs() { 213 | set_idc_func_ex("EmuRun", NULL, NULL, 0); 214 | set_idc_func_ex("EmuTrace", NULL, NULL, 0); 215 | set_idc_func_ex("EmuStepOne", NULL, NULL, 0); 216 | set_idc_func_ex("EmuTraceOne", NULL, NULL, 0); 217 | set_idc_func_ex("EmuSync", NULL, NULL, 0); 218 | set_idc_func_ex("EmuGetReg", NULL, NULL, 0); 219 | set_idc_func_ex("EmuSetReg", NULL, NULL, 0); 220 | set_idc_func_ex("EmuAddBpt", NULL, NULL, 0); 221 | } 222 | -------------------------------------------------------------------------------- /emu_script.h: -------------------------------------------------------------------------------- 1 | /* 2 | Scripting support for the x86 emulator IdaPro plugin 3 | Copyright (c) 2008-2022 Chris Eagle 4 | 5 | This program is free software; you can redistribute it and/or modify it 6 | under the terms of the GNU General Public License as published by the Free 7 | Software Foundation; either version 2 of the License, or (at your option) 8 | any later version. 9 | 10 | This program is distributed in the hope that it will be useful, but WITHOUT 11 | ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 12 | FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for 13 | more details. 14 | 15 | You should have received a copy of the GNU General Public License along with 16 | this program; if not, write to the Free Software Foundation, Inc., 59 Temple 17 | Place, Suite 330, Boston, MA 02111-1307 USA 18 | */ 19 | 20 | #ifndef __EMU_SCRIPT_H 21 | #define __EMU_SCRIPT_H 22 | 23 | /* add IDC functions for interacting with the emulator 24 | EmuRun(); 25 | EmuTrace(); 26 | EmuStepOne(); 27 | EmuTraceOne(); 28 | EmuSync(); 29 | EmuGetReg(regno); 30 | EmuSetReg(regno, value); 31 | EmuAddBpt(addr); 32 | */ 33 | 34 | #define EAX_REG 0 35 | #define ECX_REG 1 36 | #define EDX_REG 2 37 | #define EBX_REG 3 38 | #define ESP_REG 4 39 | #define EBP_REG 5 40 | #define ESI_REG 6 41 | #define EDI_REG 7 42 | 43 | #define EIP_REG 8 44 | #define EFLAGS_REG 9 45 | 46 | #define CS_REG 10 47 | #define SS_REG 11 48 | #define DS_REG 12 49 | #define ES_REG 13 50 | #define FS_REG 14 51 | #define GS_REG 15 52 | 53 | #define CS_BASE 20 54 | #define SS_BASE 21 55 | #define DS_BASE 22 56 | #define ES_BASE 23 57 | #define FS_BASE 24 58 | #define GS_BASE 25 59 | 60 | #define CR0_REG 30 61 | #define CR1_REG 31 62 | #define CR2_REG 32 63 | #define CR3_REG 33 64 | #define CR4_REG 34 65 | 66 | #define DR0_REG 40 67 | #define DR1_REG 41 68 | #define DR2_REG 42 69 | #define DR3_REG 43 70 | #define DR4_REG 44 71 | #define DR5_REG 45 72 | #define DR6_REG 46 73 | #define DR7_REG 47 74 | 75 | void register_funcs(); 76 | void unregister_funcs(); 77 | 78 | #endif 79 | -------------------------------------------------------------------------------- /emufuncs.h: -------------------------------------------------------------------------------- 1 | /* 2 | Source for x86 emulator IdaPro plugin 3 | File: emufuncs.h 4 | Copyright (c) 2004-2022 Chris Eagle 5 | 6 | This program is free software; you can redistribute it and/or modify it 7 | under the terms of the GNU General Public License as published by the Free 8 | Software Foundation; either version 2 of the License, or (at your option) 9 | any later version. 10 | 11 | This program is distributed in the hope that it will be useful, but WITHOUT 12 | ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 13 | FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for 14 | more details. 15 | 16 | You should have received a copy of the GNU General Public License along with 17 | this program; if not, write to the Free Software Foundation, Inc., 59 Temple 18 | Place, Suite 330, Boston, MA 02111-1307 USA 19 | */ 20 | 21 | #ifndef __EMULATE_FUNCS_H 22 | #define __EMULATE_FUNCS_H 23 | 24 | #include 25 | #include 26 | 27 | #include 28 | #include 29 | #include "buffer.h" 30 | #include "peutils.h" 31 | #include "hooklist.h" 32 | 33 | #include "sdk_versions.h" 34 | 35 | #define CALL_CDECL 0 36 | #define CALL_STDCALL 1 37 | 38 | struct FunctionInfo { 39 | char *fname; 40 | unsigned int result; 41 | unsigned int stackItems; 42 | unsigned int callingConvention; 43 | #if IDA_SDK_VERSION >= 650 44 | tinfo_t ftype; 45 | #else 46 | const type_t *type; 47 | const p_list *fields; 48 | #endif 49 | FunctionInfo *next; 50 | }; 51 | 52 | void emu_lstrlen(unsigned int addr = 0); 53 | void emu_lstrcpyW(unsigned int addr = 0); 54 | void emu_lstrcpy(unsigned int addr = 0); 55 | void emu_strcpy(unsigned int addr = 0); 56 | void emu_strncpy(unsigned int addr = 0); 57 | void emu_lstrcat(unsigned int addr = 0); 58 | void emu_strcat(unsigned int addr = 0); 59 | void emu_wcsset(unsigned int addr = 0); 60 | void emu_strlwr(unsigned int addr); 61 | 62 | void emu_CreateThread(unsigned int addr = 0); 63 | 64 | void emu_HeapCreate(unsigned int addr = 0); 65 | void emu_HeapDestroy(unsigned int addr = 0); 66 | void emu_HeapAlloc(unsigned int addr = 0); 67 | void emu_HeapFree(unsigned int addr = 0); 68 | void emu_HeapSize(unsigned int addr = 0); 69 | void emu_GetProcessHeap(unsigned int addr = 0); 70 | 71 | void emu_GlobalAlloc(unsigned int addr = 0); 72 | void emu_GlobalFree(unsigned int addr = 0); 73 | void emu_GlobalLock(unsigned int addr = 0); 74 | 75 | void emu_NtAllocateVirtualMemory(unsigned int addr = 0); 76 | void emu_LdrLoadDll(unsigned int addr = 0); 77 | void emu_LdrGetProcedureAddress(unsigned int addr = 0); 78 | 79 | void emu_VirtualAlloc(unsigned int addr = 0); 80 | void emu_VirtualFree(unsigned int addr = 0); 81 | void emu_VirtualProtect(unsigned int addr = 0); 82 | void emu_LocalLock(unsigned int addr = 0); 83 | void emu_LocalUnlock(unsigned int addr = 0); 84 | void emu_LocalAlloc(unsigned int addr = 0); 85 | void emu_LocalReAlloc(unsigned int addr = 0); 86 | void emu_LocalFree(unsigned int addr = 0); 87 | void emu_GetProcAddress(unsigned int addr = 0); 88 | void emu_GetModuleHandleA(unsigned int addr = 0); 89 | void emu_GetModuleHandleW(unsigned int addr = 0); 90 | void emu_FreeLibrary(unsigned int addr = 0); 91 | void emu_LoadLibraryA(unsigned int addr = 0); 92 | void emu_LoadLibraryW(unsigned int addr = 0); 93 | void emu_LoadLibraryExA(unsigned int addr = 0); 94 | void emu_LoadLibraryExW(unsigned int addr = 0); 95 | 96 | void emu_malloc(unsigned int addr = 0); 97 | void emu_calloc(unsigned int addr = 0); 98 | void emu_realloc(unsigned int addr = 0); 99 | void emu_free(unsigned int addr = 0); 100 | 101 | void emu_IsDebuggerPresent(unsigned int addr = 0); 102 | void emu_CheckRemoteDebuggerPresent(unsigned int addr = 0); 103 | 104 | void emu_CloseHandle(unsigned int addr = 0); 105 | void emu_NtQuerySystemInformation(unsigned int addr = 0); 106 | void emu_NtQueryInformationProcess(unsigned int addr = 0); 107 | void emu_NtSetInformationThread(unsigned int addr = 0); 108 | void emu_GetCurrentProcessId(unsigned int addr = 0); 109 | void emu_GetCurrentProcess(unsigned int addr = 0); 110 | void emu_GetCurrentThreadId(unsigned int addr = 0); 111 | void emu_GetThreadContext(unsigned int addr = 0); 112 | 113 | void emu_RevertToSelf(unsigned int addr); 114 | void emu_AreAnyAccessesGranted(unsigned int addr); 115 | void emu_GetBkMode(unsigned int addr); 116 | void emu_GdiFlush(unsigned int addr); 117 | void emu_GetROP2(unsigned int addr); 118 | void emu_GetBkColor(unsigned int addr); 119 | void emu_GdiGetBatchLimit(unsigned int addr); 120 | 121 | void emu_StrChrIW(unsigned int addr); 122 | void emu_StrChrIA(unsigned int addr); 123 | void emu_StrCmpIW(unsigned int addr); 124 | void emu_StrCmpNIW(unsigned int addr); 125 | void emu_StrCmpW(unsigned int addr); 126 | void emu_StrCmpNW(unsigned int addr); 127 | void emu_StrCpyW(unsigned int addr); 128 | void emu_StrSpnA(unsigned int addr); 129 | void emu_StrCSpnIA(unsigned int addr); 130 | void emu_StrCSpnIW(unsigned int addr); 131 | 132 | void emu_GetACP(unsigned int addr); 133 | void emu_GetClientRect(unsigned int addr); 134 | void emu_IsCharUpperA(unsigned int addr); 135 | void emu_IsCharAlphaA(unsigned int addr); 136 | void emu_GetIconInfo(unsigned int addr); 137 | void emu_GetWindow(unsigned int addr); 138 | void emu_IsChild(unsigned int addr); 139 | void emu_GetTopWindow(unsigned int addr); 140 | void emu_GetWindowContextHelpId(unsigned int addr); 141 | void emu_WindowFromDC(unsigned int addr); 142 | void emu_GetWindowPlacement(unsigned int addr); 143 | void emu_CopyIcon(unsigned int addr); 144 | void emu_IsIconic(unsigned int addr); 145 | void emu_GetGUIThreadInfo(unsigned int addr); 146 | void emu_GetDC(unsigned int addr); 147 | void emu_GetTitleBarInfo(unsigned int addr); 148 | void emu_IsWindowUnicode(unsigned int addr); 149 | void emu_IsMenu(unsigned int addr); 150 | void emu_GetWindowRect(unsigned int addr); 151 | void emu_IsWindowVisible(unsigned int addr); 152 | void emu_GetForegroundWindow(unsigned int addr); 153 | void emu_InSendMessage(unsigned int addr); 154 | void emu_GetWindowTextA(unsigned int addr); 155 | void emu_IsUserAnAdmin(unsigned int addr); 156 | 157 | void emu_GetVersionExA(unsigned int addr); 158 | void emu_GetVersion(unsigned int addr); 159 | void emu_GetTickCount(unsigned int addr); 160 | 161 | void emu_GetSystemTimeAsFileTime(unsigned int addr); 162 | void emu_QueryPerformanceCounter(unsigned int addr); 163 | 164 | void emu_InterlockedIncrement(unsigned int addr); 165 | void emu_InterlockedDecrement(unsigned int addr); 166 | void emu_EncodePointer(unsigned int addr); 167 | void emu_DecodePointer(unsigned int addr); 168 | 169 | void emu_InitializeCriticalSection(unsigned int addr); 170 | void emu_InitializeCriticalSectionAndSpinCount(unsigned int addr); 171 | void emu_TryEnterCriticalSection(unsigned int addr); 172 | void emu_EnterCriticalSection(unsigned int addr); 173 | void emu_LeaveCriticalSection(unsigned int addr); 174 | void emu_DeleteCriticalSection(unsigned int addr); 175 | 176 | void emu_AddVectoredExceptionHandler(unsigned int addr); 177 | void emu_RemoveVectoredExceptionHandler(unsigned int addr); 178 | 179 | void emu_Sleep(unsigned int addr); 180 | 181 | void emu_GetLastError(unsigned int addr); 182 | void emu_SetLastError(unsigned int addr); 183 | 184 | void emu_TlsAlloc(unsigned int addr); 185 | void emu_TlsFree(unsigned int addr); 186 | void emu_TlsGetValue(unsigned int addr); 187 | void emu_TlsSetValue(unsigned int addr); 188 | 189 | void emu_FlsAlloc(unsigned int addr); 190 | void emu_FlsFree(unsigned int addr); 191 | void emu_FlsGetValue(unsigned int addr); 192 | void emu_FlsSetValue(unsigned int addr); 193 | 194 | void emu_GetEnvironmentStringsA(unsigned int addr); 195 | void emu_GetEnvironmentStringsW(unsigned int addr); 196 | void emu_FreeEnvironmentStringsA(unsigned int addr); 197 | void emu_FreeEnvironmentStringsW(unsigned int addr); 198 | void emu_GetCommandLineA(unsigned int addr); 199 | void emu_GetCommandLineW(unsigned int addr); 200 | 201 | void emu_GetStdHandle(unsigned int addr); 202 | void emu_GetStartupInfoA(unsigned int addr); 203 | void emu_GetStartupInfoW(unsigned int addr); 204 | 205 | void emu_GetCPInfo(unsigned int addr); 206 | void emu_WideCharToMultiByte(unsigned int addr); 207 | void emu_MultiByteToWideChar(unsigned int addr); 208 | void emu_GetStringTypeW(unsigned int addr); 209 | void emu_GetStringTypeA(unsigned int addr); 210 | void emu_LCMapStringW(unsigned int addr); 211 | void emu_LCMapStringA(unsigned int addr); 212 | 213 | void emu_GetLocaleInfoA(unsigned int addr); 214 | void emu_GetLocaleInfoW(unsigned int addr); 215 | 216 | void emu_GetWindowsDirectoryA(unsigned int addr); 217 | void emu_GetWindowsDirectoryW(unsigned int addr); 218 | void emu_GetSystemDirectoryA(unsigned int addr); 219 | void emu_GetSystemDirectoryW(unsigned int addr); 220 | 221 | unsigned int addHeapCommon(unsigned int maxSize, unsigned int base = 0); 222 | 223 | void syscall(); 224 | void linuxSysenter(); 225 | void windowsSysenter(); 226 | 227 | void makeImportLabel(unsigned int addr, unsigned int val); 228 | void saveModuleList(Buffer &b); 229 | void loadModuleList(Buffer &b); 230 | void saveModuleData(Buffer &b); 231 | void loadModuleData(Buffer &b); 232 | 233 | struct HandleNode { 234 | char *moduleName; 235 | unsigned int handle; 236 | unsigned int id; 237 | unsigned int maxAddr; 238 | unsigned int ordinal_base; 239 | unsigned int NoF; //NumberOfFunctions 240 | unsigned int NoN; //NumberOfNames 241 | unsigned int eat; //AddressOfFunctions export address table 242 | unsigned int ent; //AddressOfNames export name table 243 | unsigned int eot; //AddressOfNameOrdinals export ordinal table 244 | HandleNode *next; 245 | }; 246 | 247 | unsigned int getHandle(HandleNode *m); 248 | unsigned int getModuleEnd(unsigned int handle); 249 | unsigned int getId(HandleNode *m); 250 | HandleNode *addModule(const char *mod, bool loading, int id, bool addToPeb = true); 251 | void addModuleToPeb(unsigned int handle, const char *name, bool loading = false); 252 | void addModuleToPeb(HandleNode *hn, bool loading, unsigned int unicodeName = 0); 253 | HandleNode *addNewModuleNode(const char *mod, unsigned int h, unsigned int id); 254 | 255 | hookfunc checkForHook(char *funcName, unsigned int funcAddr, unsigned int moduleId); 256 | void doImports(unsigned int import_drectory, unsigned int size, unsigned int image_base); 257 | void doImports(PETables &pe); 258 | bool isModuleAddress(unsigned int addr); 259 | char *reverseLookupExport(unsigned int addr); 260 | 261 | FunctionInfo *getFunctionInfo(const char *name); 262 | void clearFunctionInfoList(void); 263 | void addFunctionInfo(const char *name, unsigned int result, unsigned int nitems, unsigned int callType); 264 | void saveFunctionInfo(Buffer &b); 265 | void loadFunctionInfo(Buffer &b); 266 | char *getFunctionPrototype(FunctionInfo *f); 267 | char *getFunctionReturnType(FunctionInfo *f); 268 | 269 | char *getString(unsigned int addr); 270 | void init_til(const char *tilFile); 271 | 272 | typedef void (*unemulatedCB)(unsigned int addr, const char *name); 273 | 274 | void setUnemulatedCB(unemulatedCB cb); 275 | 276 | unsigned int myGetProcAddress(unsigned int hModule, unsigned int lpProcName); 277 | unsigned int myGetProcAddress(unsigned int hModule, const char *procName); 278 | unsigned int myGetModuleHandle(const char *modName); 279 | 280 | typedef enum {NEVER, ASK, ALWAYS} emu_Actions; 281 | 282 | extern int emu_alwaysLoadLibrary; 283 | extern int emu_alwaysGetModuleHandle; 284 | extern unsigned int pCmdLineA; 285 | 286 | bool is_valid_address(uint32_t addr); 287 | 288 | void init_cgc_random(unsigned char *seed, unsigned int slen); 289 | void save_cgc_rand_state(); 290 | bool restore_cgc_rand_state(); 291 | void init_negotiator(unsigned char *seed, uint32_t slen); 292 | unsigned int cgc_random(unsigned int buf, unsigned int count, unsigned int rnd_bytes = 0); 293 | bool cgc_global_init(const char *seed, const char *nseed, const char *host, uint16_t port, uint32_t bin_type); 294 | void cgc_cleanup(); 295 | extern bool is_cgc_pov; 296 | 297 | #endif 298 | -------------------------------------------------------------------------------- /emuheap.h: -------------------------------------------------------------------------------- 1 | /* 2 | Source for x86 emulator IdaPro plugin 3 | File: emuheap.h 4 | Copyright (c) 2004-2022, Chris Eagle 5 | 6 | This program is free software; you can redistribute it and/or modify it 7 | under the terms of the GNU General Public License as published by the Free 8 | Software Foundation; either version 2 of the License, or (at your option) 9 | any later version. 10 | 11 | This program is distributed in the hope that it will be useful, but WITHOUT 12 | ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 13 | FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for 14 | more details. 15 | 16 | You should have received a copy of the GNU General Public License along with 17 | this program; if not, write to the Free Software Foundation, Inc., 59 Temple 18 | Place, Suite 330, Boston, MA 02111-1307 USA 19 | */ 20 | 21 | #ifndef __EMUHEAP_H 22 | #define __EMUHEAP_H 23 | 24 | #include "buffer.h" 25 | 26 | #define HEAP_ERROR 0xFFFFFFFF 27 | #define HEAP_MAGIC 0xDEADBEEF 28 | 29 | class MallocNode { 30 | friend class HeapBase; 31 | friend class EmuHeap; 32 | public: 33 | MallocNode(unsigned int size, unsigned int base); 34 | MallocNode(Buffer &b); 35 | 36 | void save(Buffer &b); 37 | 38 | const MallocNode *nextNode() const {return next;}; 39 | int getBase() const {return base;}; 40 | int getSize() const {return size;}; 41 | 42 | private: 43 | unsigned int base; 44 | unsigned int size; 45 | MallocNode *next; 46 | }; 47 | 48 | struct LargeBlock { 49 | unsigned int base; 50 | unsigned int size; 51 | }; 52 | 53 | class HeapBase { 54 | public: 55 | // HeapBase(); 56 | // HeapBase(unsigned int baseAddr, unsigned int currSize, unsigned int maxSize, HeapBase *next = 0); 57 | // HeapBase(char *seg, unsigned int sz); 58 | virtual ~HeapBase(); 59 | virtual unsigned int malloc(unsigned int size) = 0; 60 | virtual unsigned int calloc(unsigned int nmemb, unsigned int size) = 0; 61 | virtual unsigned int free(unsigned int addr) = 0; 62 | virtual unsigned int realloc(unsigned int ptr, unsigned int size) = 0; 63 | 64 | virtual unsigned int getHeapBase() {return base;}; 65 | virtual unsigned int getHeapSize() {return max - base;}; 66 | HeapBase *getNextHeap() {return nextHeap;}; 67 | 68 | virtual unsigned int sizeOf(unsigned int addr) = 0; 69 | 70 | //careful to avoid memory leaks when calling this! 71 | void setNextHeap(HeapBase *heap) {nextHeap = heap;}; 72 | 73 | const MallocNode *heapHead() {return head;}; 74 | 75 | virtual void save(Buffer &b) = 0; 76 | 77 | static void saveHeapLayout(Buffer &b); 78 | // virtual void loadHeapLayout(Buffer &b) = 0; 79 | static unsigned int addHeap(unsigned int sz, unsigned int base = 0); //returns hHeap 80 | virtual unsigned int destroyHeap(unsigned int hHeap) = 0; 81 | virtual unsigned int getPrimaryHeap() = 0; 82 | static HeapBase *getHeap() {return primaryHeap;}; 83 | virtual HeapBase *findHeap(unsigned int hHeap) = 0; 84 | // static void initHeap(char *name, unsigned int maxSize = 0x100000); 85 | 86 | protected: 87 | virtual bool checkHeapSize(unsigned int newsize) = 0; 88 | virtual MallocNode *findMallocNode(unsigned int addr) = 0; 89 | virtual unsigned int findBlock(unsigned int size) = 0; 90 | virtual void insert(MallocNode *node) = 0; 91 | virtual void readHeap(Buffer &b, unsigned int num_blocks) = 0; 92 | virtual void writeHeap(Buffer &b) = 0; 93 | 94 | segment_t *h; 95 | unsigned int base; 96 | unsigned int max; 97 | unsigned int size; 98 | MallocNode *head; 99 | LargeBlock *large; 100 | unsigned int numLarge; 101 | HeapBase *nextHeap; 102 | static HeapBase *primaryHeap; 103 | }; 104 | 105 | void createLegacyHeap(Buffer &b); 106 | 107 | class EmuHeap : public HeapBase { 108 | public: 109 | EmuHeap(unsigned int baseAddr, unsigned int currSize, unsigned int maxSize, EmuHeap *next = 0); 110 | EmuHeap(const char *seg, unsigned int sz); 111 | EmuHeap(Buffer &b); 112 | ~EmuHeap(); 113 | unsigned int malloc(unsigned int size); 114 | unsigned int calloc(unsigned int nmemb, unsigned int size); 115 | unsigned int free(unsigned int addr); 116 | unsigned int realloc(unsigned int ptr, unsigned int size); 117 | 118 | unsigned int getHeapBase() {return base;}; 119 | unsigned int getHeapSize() {return max - base;}; 120 | HeapBase *getNextHeap() {return nextHeap;}; 121 | 122 | unsigned int sizeOf(unsigned int addr); 123 | 124 | //careful to avoid memory leaks when calling this! 125 | void setNextHeap(HeapBase *heap) {nextHeap = heap;}; 126 | 127 | const MallocNode *heapHead() {return head;}; 128 | 129 | void save(Buffer &b); 130 | 131 | static void loadHeapLayout(Buffer &b); 132 | // unsigned int addHeap(unsigned int sz); //returns hHeap 133 | unsigned int destroyHeap(unsigned int hHeap); 134 | unsigned int getPrimaryHeap(); 135 | // static HeapBase *getHeap() {return primaryHeap;}; 136 | HeapBase *findHeap(unsigned int hHeap); 137 | static void initHeap(const char *name, unsigned int maxSize = 0x100000); 138 | 139 | protected: 140 | EmuHeap(Buffer &b, unsigned int num_blocks); 141 | 142 | bool checkHeapSize(unsigned int newsize); 143 | MallocNode *findMallocNode(unsigned int addr); 144 | unsigned int findBlock(unsigned int size); 145 | void insert(MallocNode *node); 146 | void readHeap(Buffer &b, unsigned int num_blocks); 147 | void writeHeap(Buffer &b); 148 | }; 149 | 150 | 151 | #endif 152 | -------------------------------------------------------------------------------- /emuthreads.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | Source for x86 emulator IdaPro plugin 3 | File: emuthreads.cpp 4 | Copyright (c) 2006-2022, Chris Eagle 5 | 6 | This program is free software; you can redistribute it and/or modify it 7 | under the terms of the GNU General Public License as published by the Free 8 | Software Foundation; either version 2 of the License, or (at your option) 9 | any later version. 10 | 11 | This program is distributed in the hope that it will be useful, but WITHOUT 12 | ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 13 | FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for 14 | more details. 15 | 16 | You should have received a copy of the GNU General Public License along with 17 | this program; if not, write to the Free Software Foundation, Inc., 59 Temple 18 | Place, Suite 330, Boston, MA 02111-1307 USA 19 | */ 20 | 21 | #ifndef _MSC_VER 22 | #ifndef USE_DANGEROUS_FUNCTIONS 23 | #define USE_DANGEROUS_FUNCTIONS 1 24 | #endif 25 | #endif 26 | 27 | #include "x86defs.h" 28 | #include "emuthreads.h" 29 | #include "seh.h" 30 | #include "memmgr.h" 31 | 32 | #include 33 | #include 34 | 35 | #define DEFAULT_STACK_SIZE 0x100000 36 | 37 | ThreadNode *threadList = NULL; 38 | ThreadNode *activeThread = NULL; 39 | 40 | /* 41 | * Figure out a new, unused thread id to assign to the new thread 42 | */ 43 | unsigned int getNewThreadHandle() { 44 | return threadList ? (threadList->handle + 4) : THREAD_HANDLE_BASE; 45 | } 46 | 47 | /* 48 | * Figure out a new, unused thread id to assign to the new thread 49 | */ 50 | unsigned int getNewThreadId() { 51 | unsigned int tid = 0; 52 | do { 53 | getRandomBytes(&tid, 2); 54 | tid = (tid % 3000) + 1000; 55 | for (ThreadNode *tn = threadList; tn; tn = tn->next) { 56 | if (tn->id == tid) { 57 | tid = 0; 58 | break; 59 | } 60 | } 61 | } while (tid == 0); 62 | return tid; 63 | } 64 | 65 | /* 66 | * we need to find a memory hole in which to allocate a new stack 67 | * for a new thread. This is not a great algorithm, but it should 68 | * work well enough for now. Need to deconflict with heap space. 69 | * Should really rewrite to allocate space from emulation heap. 70 | * Should also look for holes created by destroyed threads 71 | */ 72 | unsigned int getNewStackLocation() { 73 | int count = 1; 74 | char buf[16]; 75 | segment_t *s = get_segm_by_name(".stack"); 76 | unsigned int top = (unsigned int)s->endEA + 0xFFFF; 77 | while (getseg(top)) { 78 | top += 0x10000; 79 | count++; 80 | } 81 | ::qsnprintf(buf, sizeof(buf), ".stack%d", count); 82 | MemMgr::mmap(top - 0xFFFF, 0x10000, 0, 0, buf); 83 | formatStack(top - 0xFFFF, top + 1); 84 | return top + 1; 85 | } 86 | 87 | /* 88 | * This constructor should be used for only one thread, the main thread 89 | * which is declared as a global in cpu.cpp 90 | */ 91 | ThreadNode::ThreadNode() { 92 | id = getNewThreadId(); 93 | handle = getNewThreadHandle(); 94 | hasStarted = 1; 95 | threadArg = 0; 96 | next = NULL; 97 | } 98 | 99 | ThreadNode::ThreadNode(unsigned int threadFunc, unsigned int threadArg) { 100 | next = NULL; 101 | id = getNewThreadId(); 102 | handle = getNewThreadHandle(); 103 | hasStarted = 0; 104 | regs = cpu; 105 | regs.eip = threadFunc; 106 | this->threadArg = threadArg; 107 | 108 | //create thread stack 109 | unsigned int top; 110 | regs.general[ESP] = top = getNewStackLocation(); 111 | //the rest should really only be done for Windows binaries 112 | if (usingSEH()) { 113 | char buf[32]; 114 | unsigned int teb = get_long(fsBase + TEB_LINEAR_ADDR); 115 | unsigned int peb = get_long(teb + TEB_PEB_PTR); 116 | unsigned int newTeb = 0x7ffdf000; 117 | unsigned int prev; 118 | do { 119 | prev = newTeb; 120 | if (newTeb == peb || newTeb == fsBase) { 121 | newTeb -= 0x1000; 122 | } 123 | else { 124 | for (ThreadNode *tn = threadList; tn; tn = tn->next) { 125 | if (newTeb == tn->regs.segBase[FS]) { 126 | newTeb -= 0x1000; 127 | } 128 | } 129 | } 130 | } while (newTeb != prev); 131 | regs.segBase[FS] = newTeb; 132 | ::qsnprintf(buf, sizeof(buf), ".teb_%x", handle); 133 | if (getseg(newTeb)) { 134 | //clear previously used page 135 | for (int i = 0; i < 0x1000; i += 4) { 136 | patch_long(newTeb + i, 0); 137 | } 138 | } 139 | else { 140 | //map a page in for the new teb 141 | MemMgr::mmap(newTeb, 0x1000, 0, 0, buf); 142 | } 143 | regs.general[ESP] -= 32; 144 | } 145 | } 146 | 147 | ThreadNode::ThreadNode(Buffer &b, unsigned int /*currentActive*/) { 148 | next = NULL; 149 | b.read((char*)&handle, sizeof(handle)); 150 | b.read((char*)&id, sizeof(id)); 151 | b.read((char*)&hasStarted, sizeof(hasStarted)); 152 | b.read((char*)&threadArg, sizeof(threadArg)); 153 | b.read((char*)®s, sizeof(regs)); 154 | } 155 | 156 | void ThreadNode::save(Buffer &b, bool /*saveStack*/) { 157 | b.write((char*)&handle, sizeof(handle)); 158 | b.write((char*)&id, sizeof(id)); 159 | b.write((char*)&hasStarted, sizeof(hasStarted)); 160 | b.write((char*)&threadArg, sizeof(threadArg)); 161 | b.write((char*)®s, sizeof(regs)); 162 | } 163 | 164 | /* 165 | * return thread handle for new thread 166 | */ 167 | ThreadNode *emu_create_thread(unsigned int threadFunc, unsigned int threadArg) { 168 | ThreadNode *tn = new ThreadNode(threadFunc, threadArg); 169 | tn->next = threadList; 170 | threadList = tn; 171 | return tn; 172 | } 173 | 174 | /* 175 | * destroy the thread indicated by threadId. Should add code to 176 | * prevent destruction of the main thread 177 | * return the next thread to run (currently always the main thread) 178 | */ 179 | ThreadNode *emu_destroy_thread(unsigned int threadId) { 180 | ThreadNode *prev = NULL; 181 | ThreadNode *tn = NULL, *mainThread = NULL; 182 | for (tn = threadList; tn; tn = tn->next) { 183 | //doing the following test first prevents the main thread 184 | //from being destroyed 185 | if (tn->handle == THREAD_HANDLE_BASE) { 186 | mainThread = tn; 187 | } 188 | else if (tn->handle == threadId) { 189 | ThreadNode *delThread = tn; 190 | //free up thread stack 191 | #ifdef SEGDEL_PERM 192 | del_segm(tn->regs.general[ESP] - 1, SEGDEL_PERM | SEGDEL_SILENT); 193 | #else 194 | del_segm(tn->regs.general[ESP] - 1, 1); 195 | #endif 196 | if (prev) { 197 | prev->next = tn->next; 198 | tn = prev; 199 | } 200 | else { 201 | tn = threadList = tn->next; 202 | } 203 | msg("Destroyed thread 0x%x\n", tn->handle); 204 | /* //delete threads stack segment 205 | delete delThread->stack; 206 | */ 207 | delete delThread; 208 | } 209 | prev = tn; 210 | } 211 | //cause a break since we are switching threads 212 | shouldBreak = 1; 213 | return mainThread; 214 | } 215 | 216 | /* 217 | * switch threads 218 | */ 219 | void emu_switch_threads(ThreadNode *new_thread) { 220 | if (activeThread != new_thread) { 221 | if (activeThread) { 222 | memcpy(&activeThread->regs, &cpu, sizeof(Registers)); 223 | } 224 | activeThread = new_thread; 225 | memcpy(&cpu, &new_thread->regs, sizeof(Registers)); 226 | 227 | if (!new_thread->hasStarted) { 228 | push(new_thread->threadArg, SIZE_DWORD); 229 | //push special thread return address 230 | push(THREAD_MAGIC, SIZE_DWORD); 231 | new_thread->hasStarted = 1; 232 | } 233 | } 234 | } 235 | 236 | /* 237 | * locate the thread with the given handle 238 | */ 239 | ThreadNode *findThread(unsigned int handle) { 240 | for (ThreadNode *tn = threadList; tn; tn = tn->next) { 241 | if (tn->handle == handle) return tn; 242 | } 243 | return NULL; 244 | } 245 | 246 | -------------------------------------------------------------------------------- /emuthreads.h: -------------------------------------------------------------------------------- 1 | /* 2 | Source for x86 emulator IdaPro plugin 3 | File: emuthreads.h 4 | Copyright (c) 2006-2022, Chris Eagle 5 | 6 | This program is free software; you can redistribute it and/or modify it 7 | under the terms of the GNU General Public License as published by the Free 8 | Software Foundation; either version 2 of the License, or (at your option) 9 | any later version. 10 | 11 | This program is distributed in the hope that it will be useful, but WITHOUT 12 | ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 13 | FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for 14 | more details. 15 | 16 | You should have received a copy of the GNU General Public License along with 17 | this program; if not, write to the Free Software Foundation, Inc., 59 Temple 18 | Place, Suite 330, Boston, MA 02111-1307 USA 19 | */ 20 | 21 | #ifndef __EMU_THREADS_H 22 | #define __EMU_THREADS_H 23 | 24 | #include "cpu.h" 25 | #include "buffer.h" 26 | 27 | #define THREAD_MAGIC 0xDEADBEEF 28 | #define THREAD_ID_BASE 0x500 29 | #define THREAD_HANDLE_BASE 0xdc 30 | 31 | class ThreadNode { 32 | public: 33 | ThreadNode(); 34 | ThreadNode(unsigned int threadFunc, unsigned int threadArg); 35 | ThreadNode(Buffer &b, unsigned int currentActive); 36 | 37 | void save(Buffer &b, bool saveStack); 38 | 39 | unsigned int handle; 40 | unsigned int id; 41 | unsigned int hasStarted; 42 | unsigned int threadArg; 43 | Registers regs; 44 | ThreadNode *next; 45 | }; 46 | 47 | extern ThreadNode *threadList; 48 | extern ThreadNode *activeThread; 49 | 50 | /* 51 | * return thread handle for new thread 52 | */ 53 | ThreadNode *emu_create_thread(unsigned int threadFunc, unsigned int threadArg); 54 | 55 | /* 56 | * destroy the thread indicated by threadId 57 | */ 58 | ThreadNode *emu_destroy_thread(unsigned int threadId); 59 | 60 | /* 61 | * switch threads 62 | */ 63 | void emu_switch_threads(ThreadNode *new_thread); 64 | 65 | /* 66 | * locate the thread with the given handle 67 | */ 68 | ThreadNode *findThread(unsigned int handle); 69 | 70 | #define TEB_SEH_FRAME 0 71 | #define TEB_STACK_TOP 4 72 | #define TEB_STACK_BOTTOM 8 73 | #define TEB_FIBER_DATA 16 74 | #define TEB_LINEAR_ADDR 24 75 | #define TEB_ENV_PTR 28 76 | #define TEB_PROCESS_ID 32 77 | #define TEB_THREAD_ID 36 78 | #define TEB_PEB_PTR 48 79 | #define TEB_LAST_ERROR 52 80 | #define TEB_TLS_ARRAY 0xE10 81 | #define TEB_TLS_EXPANSION 0xf94 82 | 83 | #define PEB_DEBUG_FLAG 3 84 | #define PEB_IMAGE_BASE 8 85 | #define PEB_LDR_DATA 12 86 | #define PEB_PROCESS_PARMS 16 87 | #define PEB_PROCESS_HEAP 0x18 88 | #define PEB_FASTPEBLOCK 0x1C 89 | #define PEB_FASTPEBLOCK_FUNC 0x20 90 | #define PEB_FASTPEBUNLOCK_FUNC 0x24 91 | #define PEB_TLS_BITMAP 0x40 92 | #define PEB_TLS_BITMAP_BITS 0x44 93 | #define PEB_NUM_PROCESSORS 0x64 94 | #define PEB_NUM_HEAPS 0x88 95 | #define PEB_MAX_HEAPS 0x8C 96 | #define PEB_OS_MAJOR 0xA4 97 | #define PEB_OS_MINOR 0xA8 98 | #define PEB_OS_BUILD 0xAC 99 | #define PEB_OS_PLATFORM_ID 0xB0 100 | #define PEB_TLS_EXP_BITMAP 0x150 101 | #define PEB_TLS_EXP_BITMAP_BITS 0x154 102 | 103 | #define SIZEOF_PEB 0x1E8 104 | 105 | //PEB_CMD_LINE points to a UNICODE_STRING 106 | #define PARMS_CMD_LINE 0x40 107 | #define PARMS_ENV_PTR 0x48 108 | 109 | #define SIZEOF_PROCESS_PARAMETERS 0x290 110 | 111 | 112 | #endif 113 | -------------------------------------------------------------------------------- /hooklist.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | Source for x86 emulator IdaPro plugin 3 | File: hooklist.cpp 4 | Copyright (c) 2004-2022, Chris Eagle 5 | 6 | This program is free software; you can redistribute it and/or modify it 7 | under the terms of the GNU General Public License as published by the Free 8 | Software Foundation; either version 2 of the License, or (at your option) 9 | any later version. 10 | 11 | This program is distributed in the hope that it will be useful, but WITHOUT 12 | ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 13 | FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for 14 | more details. 15 | 16 | You should have received a copy of the GNU General Public License along with 17 | this program; if not, write to the Free Software Foundation, Inc., 59 Temple 18 | Place, Suite 330, Boston, MA 02111-1307 USA 19 | */ 20 | 21 | #include 22 | #include 23 | 24 | #include "x86defs.h" 25 | 26 | #include "hooklist.h" 27 | 28 | #ifndef NULL 29 | #define NULL 0 30 | #endif 31 | 32 | static HookNode *hookList = NULL; 33 | 34 | HookNode::HookNode(const char *fName, unsigned int addr, hookfunc func, unsigned int id, HookNode *nxt) : 35 | funcAddr(addr), func(func), moduleId(id), next(nxt) { 36 | funcName = _strdup(fName); 37 | } 38 | 39 | HookNode::~HookNode() { 40 | free(funcName); 41 | } 42 | 43 | hookfunc addHook(const char *fName, unsigned int funcAddr, hookfunc func, unsigned int id) { 44 | hookList = new HookNode(fName, funcAddr, func, id, hookList); 45 | return func; 46 | // msg("x86emu: hooked %s at %X\n", fName, funcAddr); 47 | } 48 | 49 | void freeHookList() { 50 | for (HookNode *p = hookList; p; hookList = p) { 51 | p = p->next; 52 | delete hookList; 53 | } 54 | hookList = NULL; 55 | } 56 | 57 | void loadHookList(Buffer &b) { 58 | int n; 59 | freeHookList(); 60 | b.read((char*)&n, sizeof(n)); 61 | for (int i = 0; i < n; i++) { 62 | unsigned int addr; 63 | b.read((char*)&addr, sizeof(addr)); 64 | char *name; 65 | b.readString(&name); 66 | hookfunc hf = findAvailableHookFunc(name); 67 | if (hf) { 68 | //need to find a way to pass valid id here 69 | msg("x86emu: Adding hook for %s at %X\n", name, addr); 70 | addHook(name, addr, hf, 0); 71 | } 72 | free(name); 73 | } 74 | } 75 | 76 | Buffer *getHookListBlob(Buffer &b) { 77 | Buffer *r = new Buffer(); 78 | int n; 79 | b.read((char*)&n, sizeof(n)); 80 | r->write((char*)&n, sizeof(n)); 81 | for (int i = 0; i < n; i++) { 82 | unsigned int addr; 83 | b.read((char*)&addr, sizeof(addr)); 84 | r->write((char*)&addr, sizeof(addr)); 85 | char *name; 86 | b.readString(&name); 87 | r->writeString(name); 88 | free(name); 89 | } 90 | return r; 91 | } 92 | 93 | void saveHookList(Buffer &b) { 94 | int n = 0; 95 | HookNode *h; 96 | for (h = hookList; h; h = h->next) n++; 97 | b.write((char*)&n, sizeof(n)); 98 | for (h = hookList; h; h = h->next) { 99 | b.write((char*)&h->funcAddr, sizeof(h->funcAddr)); 100 | b.writeString(h->funcName); 101 | } 102 | } 103 | 104 | void removeHook(unsigned int funcAddr) { 105 | HookNode *prev = NULL, *curr = hookList; 106 | while (curr) { 107 | if (curr->funcAddr == funcAddr) { 108 | if (prev) { 109 | prev->next = curr->next; 110 | } 111 | else { 112 | hookList = curr->next; 113 | } 114 | delete curr; 115 | break; 116 | } 117 | prev = curr; 118 | curr = curr->next; 119 | } 120 | } 121 | 122 | hookfunc findHookedFunc(unsigned int funcAddr) { 123 | for (HookNode *n = hookList; n; n = n->next) { 124 | if (n->funcAddr == funcAddr) { 125 | return n->func; 126 | } 127 | } 128 | return NULL; 129 | } 130 | 131 | hookfunc findAvailableHookFunc(const char *funcName) { 132 | for (int i = 0; hookTable[i].fName; i++) { 133 | if (!strcmp(hookTable[i].fName, funcName)) return hookTable[i].func; 134 | } 135 | return NULL; 136 | } 137 | 138 | HookNode *findHookByAddr(unsigned int funcAddr) { 139 | for (HookNode *n = hookList; n; n = n->next) { 140 | if (n->funcAddr == funcAddr) { 141 | return n; 142 | } 143 | } 144 | return NULL; 145 | } 146 | 147 | HookNode *findHookByName(const char *fName) { 148 | for (HookNode *n = hookList; n; n = n->next) { 149 | if (!strcmp(n->funcName, fName)) { 150 | return n; 151 | } 152 | } 153 | return NULL; 154 | } 155 | 156 | HookNode *getNext(HookNode *n) { 157 | return n ? n->next : hookList; 158 | } 159 | 160 | -------------------------------------------------------------------------------- /hooklist.h: -------------------------------------------------------------------------------- 1 | /* 2 | Source for x86 emulator IdaPro plugin 3 | File: hooklist.h 4 | Copyright (c) 2004-2022, Chris Eagle 5 | 6 | This program is free software; you can redistribute it and/or modify it 7 | under the terms of the GNU General Public License as published by the Free 8 | Software Foundation; either version 2 of the License, or (at your option) 9 | any later version. 10 | 11 | This program is distributed in the hope that it will be useful, but WITHOUT 12 | ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 13 | FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for 14 | more details. 15 | 16 | You should have received a copy of the GNU General Public License along with 17 | this program; if not, write to the Free Software Foundation, Inc., 59 Temple 18 | Place, Suite 330, Boston, MA 02111-1307 USA 19 | */ 20 | 21 | #ifndef __HOOK_LIST_H 22 | #define __HOOK_LIST_H 23 | 24 | #include "buffer.h" 25 | 26 | typedef void (*hookfunc)(unsigned int addr); 27 | 28 | /* 29 | * These are used to setup hooking dialog menu entries 30 | */ 31 | typedef struct _HookEntry_t { 32 | const char *fName; 33 | hookfunc func; 34 | } HookEntry; 35 | 36 | extern HookEntry hookTable[]; 37 | 38 | class HookNode { 39 | friend hookfunc addHook(const char *fName, unsigned int funcAddr, hookfunc func, unsigned int id); 40 | friend void removeHook(unsigned int funcAddr); 41 | friend void freeHookList(); 42 | friend void loadHookList(Buffer &b); 43 | friend void saveHookList(Buffer &b); 44 | friend Buffer *getHookListBlob(Buffer &b); 45 | friend hookfunc findHookedFunc(unsigned int funcAddr); 46 | friend hookfunc findAvailableHookFunc(const char *funcName); 47 | friend HookNode *findHookByAddr(unsigned int addr); 48 | friend HookNode *findHookByName(const char *fName); 49 | friend HookNode *getNext(HookNode *n); 50 | 51 | public: 52 | HookNode(const char *fName, unsigned int addr, hookfunc func, unsigned int id, HookNode *nxt); 53 | ~HookNode(); 54 | unsigned int getAddr() {return funcAddr;} 55 | const char *getName() {return funcName;} 56 | 57 | private: 58 | char *funcName; 59 | unsigned int funcAddr; 60 | hookfunc func; 61 | unsigned int moduleId; 62 | HookNode *next; 63 | }; 64 | 65 | hookfunc addHook(const char *fName, unsigned int funcAddr, hookfunc func, unsigned int id); 66 | HookNode *findHookByAddr(unsigned int addr); 67 | void loadHookList(Buffer &b); 68 | void saveHookList(Buffer &b); 69 | hookfunc findHookedFunc(unsigned int funcAddr); 70 | hookfunc findAvailableHookFunc(const char *funcName); 71 | 72 | #endif 73 | 74 | -------------------------------------------------------------------------------- /memmgr.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | Source for x86 emulator IdaPro plugin 3 | File: memmgr.cpp 4 | Copyright (c) 2004-2022, Chris Eagle 5 | 6 | This program is free software; you can redistribute it and/or modify it 7 | under the terms of the GNU General Public License as published by the Free 8 | Software Foundation; either version 2 of the License, or (at your option) 9 | any later version. 10 | 11 | This program is distributed in the hope that it will be useful, but WITHOUT 12 | ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 13 | FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for 14 | more details. 15 | 16 | You should have received a copy of the GNU General Public License along with 17 | this program; if not, write to the Free Software Foundation, Inc., 59 Temple 18 | Place, Suite 330, Boston, MA 02111-1307 USA 19 | */ 20 | 21 | #define NO_OBSOLETE_FUNCS 22 | 23 | #include 24 | #include 25 | #include 26 | #include 27 | 28 | #include 29 | 30 | #include "memmgr.h" 31 | #include "peutils.h" 32 | #include "sdk_versions.h" 33 | 34 | //lifted from intel.hpp 35 | #define R_fs 33 36 | 37 | #define SEGDEL_KEEP SEGMOD_KEEP 38 | #define SEGDEL_SILENT SEGMOD_SILENT 39 | 40 | #define SEG_RESERVE 200 41 | 42 | static bool haveTEB = false; 43 | static sel_t tebSel = 0; 44 | 45 | void createNewSegment(const char *name, uint32_t base, uint32_t size) { 46 | //msg("createNewSegment: %s\n", name); 47 | //create the new segment 48 | segment_t s; 49 | memset(&s, 0, sizeof(s)); 50 | if (strcmp(name, ".teb") == 0) { 51 | haveTEB = true; 52 | tebSel = s.sel = allocate_selector(base >> 4); 53 | set_default_segreg_value(NULL, R_fs, s.sel); 54 | } 55 | s.startEA = base; 56 | s.endEA = base + size; 57 | s.align = saRelPara; 58 | s.comb = scPub; 59 | s.perm = SEGPERM_WRITE | SEGPERM_READ | SEGPERM_EXEC; 60 | s.bitness = 1; //== 32 61 | s.type = SEG_CODE; 62 | s.color = DEFCOLOR; 63 | 64 | // if (add_segm_ex(&s, name, "DATA", ADDSEG_QUIET | ADDSEG_NOSREG)) { 65 | if (add_segm_ex(&s, name, "CODE", ADDSEG_QUIET | ADDSEG_NOSREG)) { 66 | //zero out the newly created segment 67 | zero_fill(base, size); 68 | if (haveTEB) { 69 | set_default_segreg_value(&s, R_fs, tebSel); 70 | } 71 | } 72 | } 73 | 74 | void createOverlaySegment(const char *name, uint32_t base, uint32_t size) { 75 | //create the new segment 76 | segment_t *current = getseg(base); 77 | if (current == NULL) { 78 | //not an overlay 79 | return; 80 | } 81 | segment_t s = *current; 82 | s.startEA = base; 83 | s.endEA = base + size; 84 | //all other attributes come from existing segment 85 | 86 | // if (add_segm_ex(&s, name, "DATA", ADDSEG_QUIET | ADDSEG_NOSREG)) { 87 | add_segm_ex(&s, name, "CODE", ADDSEG_QUIET | ADDSEG_NOSREG); 88 | } 89 | 90 | segment_t *next_seg(ea_t addr) { 91 | return get_next_seg(addr); 92 | } 93 | 94 | segment_t *prev_seg(ea_t addr) { 95 | return get_prev_seg(addr); 96 | } 97 | 98 | /* 99 | static const char memmgr_node_name[] = "$ X86emu memory manager"; 100 | 101 | //The IDA database node identifier into which the plug-in will 102 | //store its state information when the database is saved. 103 | static netnode memmgr_node(x86emu_node_name); 104 | 105 | MemMgr::MemMgr() { 106 | if (netnode_exist(memmgr_node)) { 107 | } 108 | else { 109 | memmgr_node.create(memmgr_node_name); 110 | } 111 | } 112 | */ 113 | 114 | void MemMgr::reserve(uint32_t addr, uint32_t size) { 115 | segment_t *s = getseg(addr); 116 | if (s) { 117 | size = (size + 0xFFF) & 0xFFFFF000; 118 | uint32_t end = addr + size; 119 | if (end > s->endEA) { 120 | segment_t *n = next_seg(addr); 121 | if (n) { 122 | if (n->startEA <= end) { 123 | //no room so fail 124 | return; 125 | } 126 | } 127 | else { 128 | if (end < s->startEA) { 129 | //end wrapped around so fail 130 | return; 131 | } 132 | } 133 | netnode segnode(s->startEA); 134 | segnode.altset(SEG_RESERVE, end, 'Z'); 135 | } 136 | } 137 | } 138 | 139 | uint32_t MemMgr::mapFixed(uint32_t addr, uint32_t size, uint32_t /*prot*/, uint32_t flags, const char *name) { 140 | if (addr == 0 || (flags & MM_MAP_FIXED) == 0) { 141 | return (uint32_t)BADADDR; 142 | } 143 | uint32_t end = addr + size; 144 | segment_t *s = getseg(addr); 145 | segment_t *n = next_seg(addr); 146 | 147 | while (n && end >= n->endEA) { 148 | //range completely consumes next segment 149 | del_segm(n->startEA, SEGDEL_KEEP | SEGDEL_SILENT); 150 | n = next_seg(addr); 151 | } 152 | if (n && end > n->startEA) { 153 | //range partly overlaps next segment 154 | set_segm_start(n->startEA, end, SEGMOD_SILENT); 155 | } 156 | 157 | if (s) { 158 | if (s->startEA < addr) { 159 | //may need to split segment 160 | //addr == s->startEA 161 | if (end >= s->endEA) { 162 | //new extends beyond end of s 163 | set_segm_end(s->startEA, addr, SEGMOD_SILENT); 164 | } 165 | else { 166 | //old completely overlaps new 167 | } 168 | } 169 | else { 170 | //addr == s->startEA 171 | if (end >= s->endEA) { 172 | //new completely overlaps s 173 | del_segm(s->startEA, SEGDEL_KEEP | SEGDEL_SILENT); 174 | } 175 | else { 176 | //need to move startEA 177 | set_segm_start(s->startEA, end, SEGMOD_SILENT); 178 | } 179 | } 180 | } 181 | 182 | uint32_t suffix = (addr >> 12) & 0xFFFFF; 183 | if (name == NULL) { 184 | char segName[64]; 185 | ::qsnprintf(segName, sizeof(segName), "mmap_%05x", suffix); 186 | createNewSegment(segName, addr, size); 187 | } 188 | else { 189 | createNewSegment(name, addr, size); 190 | } 191 | return addr; 192 | } 193 | 194 | //search up from bottom for block of size 195 | uint32_t MemMgr::search_up(uint32_t bottom, uint32_t size, uint32_t top) { 196 | size = (size + 0xfff) & 0xfffff000; 197 | top = top & 0xfffff000; 198 | uint32_t addr = (bottom + 0xfff) & 0xfffff000; 199 | uint32_t max_low_addr = top - size; 200 | if (max_low_addr > top || max_low_addr < bottom) { 201 | //ENOMEM 202 | return (uint32_t)BADADDR; 203 | } 204 | while (addr <= max_low_addr) { 205 | //is there already a segment here? 206 | segment_t *s = getseg(addr); 207 | if (s == NULL) { 208 | //find next segment to compute any gap 209 | segment_t *n = next_seg(addr); 210 | uint32_t avail = 0; 211 | if (n) { 212 | //if there is a next seg we are bounded by its lower limit 213 | uint32_t effectiveStart = (uint32_t)s->startEA & 0xfffff000; 214 | avail = effectiveStart - addr; 215 | } 216 | else { 217 | avail = top - addr; 218 | } 219 | if (avail >= size) { 220 | return addr; 221 | } 222 | if (n == NULL) { 223 | return (uint32_t)BADADDR; 224 | } 225 | s = n; 226 | } 227 | //move up to page rounded end of next seg and try again 228 | addr = (0xFFF + (uint32_t)s->endEA) & 0xFFFFF000; 229 | } 230 | return (uint32_t)BADADDR; 231 | } 232 | 233 | //search down from top for block of size 234 | uint32_t MemMgr::search_down(uint32_t top, uint32_t size, uint32_t bottom) { 235 | size = (size + 0xfff) & 0xfffff000; 236 | uint32_t min_high_addr = bottom + size; 237 | if (min_high_addr > top || min_high_addr < bottom) { 238 | //ENOMEM 239 | return (uint32_t)BADADDR; 240 | } 241 | uint32_t addr = top & 0xfffff000; 242 | while (addr >= min_high_addr) { 243 | //is there already a segment here? 244 | segment_t *s = getseg(addr); 245 | if (s) { 246 | //if so drop down to page rounded start of seg 247 | addr = s->startEA & 0xFFFFF000; 248 | } 249 | //find previous segment to compute any gap 250 | segment_t *p = prev_seg(addr); 251 | uint32_t avail = 0; 252 | if (p) { 253 | //if there is a prev seg we are bounded by its upper limit 254 | uint32_t effectiveEnd = (0xfff + (uint32_t)p->endEA) & 0xfffff000; 255 | avail = addr - effectiveEnd; 256 | } 257 | else { 258 | //if there is no previous seg we are bounded by "limit" 259 | avail = addr - bottom; 260 | } 261 | if (avail >= size) { 262 | return addr - size; 263 | } 264 | if (p == NULL) { 265 | //fail because we were bounded by lower limit and avail was too small 266 | return (uint32_t)BADADDR; 267 | } 268 | //drop down to page rounded start of prev seg and try again 269 | addr = p->startEA & 0xFFFFF000; 270 | } 271 | return (uint32_t)BADADDR; 272 | } 273 | 274 | //addr must be page aligned 275 | uint32_t MemMgr::mmap(uint32_t addr, uint32_t size, uint32_t prot, uint32_t flags, const char *name) { 276 | if (flags & MM_MAP_FIXED) { 277 | return mapFixed(addr, size, prot, flags, name); 278 | } 279 | uint32_t growth = (uint32_t)kernel_node.altval(OS_VMA_GROWTH); 280 | //uint32_t page_size = (uint32_t)kernel_node.altval(OS_PAGE_SIZE); 281 | //uint32_t page_mask = ~(page_size - 1); 282 | uint32_t upper_limit = (uint32_t)kernel_node.altval(OS_VMA_HIGH); 283 | uint32_t lower_limit = (uint32_t)kernel_node.altval(OS_VMA_LOW); 284 | if (addr) { 285 | //addr is a hint in this case 286 | //always try search up w/ addr as lower limit then fall back below 287 | addr = search_up(addr, size, upper_limit); 288 | if (addr == BADADDR) { 289 | addr = 0; //forces fallback below 290 | } 291 | } 292 | if (addr == 0) { 293 | if (growth == OS_VMA_GROWS_DOWN) { 294 | addr = search_down(upper_limit, size, lower_limit); 295 | } 296 | else { 297 | addr = search_up(lower_limit, size, upper_limit); 298 | } 299 | } 300 | if (addr != BADADDR) { 301 | uint32_t suffix = (addr >> 12) & 0xFFFFF; 302 | if (name == NULL) { 303 | char segName[64]; 304 | ::qsnprintf(segName, sizeof(segName), "mmap_%05x", suffix); 305 | createNewSegment(segName, addr, size); 306 | } 307 | else { 308 | createNewSegment(name, addr, size); 309 | } 310 | } 311 | return addr; 312 | } 313 | 314 | uint32_t MemMgr::munmap(uint32_t addr, uint32_t size, bool keep) { 315 | addr &= 0xFFFFF000; //unmap from page boundary 316 | size = (size + 0xFFF) & 0xFFFFF000; 317 | uint32_t end = addr + size; 318 | for (segment_t *s = getseg(addr); addr < end; s = getseg(addr)) { 319 | uint32_t segend = (uint32_t)s->endEA; 320 | if (s == NULL) { 321 | s = get_next_seg(addr); 322 | addr = s ? (uint32_t)s->startEA : end; 323 | continue; 324 | } 325 | if (addr != s->startEA) { 326 | //need to truncate or split segment 327 | if (end < segend) { 328 | char segname[64]; 329 | qsnprintf(segname, sizeof(segname), "mmap_%x", end >> 12); 330 | createOverlaySegment(segname, end, segend - end); 331 | } 332 | set_segm_end(s->startEA, addr, keep ? SEGMOD_KEEP : SEGMOD_KILL); 333 | } 334 | else { 335 | //delete whole or only first part of segment 336 | if (end < segend) { 337 | set_segm_start(s->startEA, end, keep ? SEGMOD_KEEP : SEGMOD_KILL); 338 | } 339 | else { 340 | del_segm(addr, keep ? SEGMOD_KEEP : SEGMOD_KILL); 341 | } 342 | } 343 | addr = segend; 344 | } 345 | return 0; 346 | } 347 | 348 | -------------------------------------------------------------------------------- /memmgr.h: -------------------------------------------------------------------------------- 1 | /* 2 | Source for x86 emulator IdaPro plugin 3 | File: memmgr.h 4 | Copyright (c) 2004-2022, Chris Eagle 5 | 6 | This program is free software; you can redistribute it and/or modify it 7 | under the terms of the GNU General Public License as published by the Free 8 | Software Foundation; either version 2 of the License, or (at your option) 9 | any later version. 10 | 11 | This program is distributed in the hope that it will be useful, but WITHOUT 12 | ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 13 | FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for 14 | more details. 15 | 16 | You should have received a copy of the GNU General Public License along with 17 | this program; if not, write to the Free Software Foundation, Inc., 59 Temple 18 | Place, Suite 330, Boston, MA 02111-1307 USA 19 | */ 20 | 21 | #ifndef __MEMMGR_H 22 | #define __MEMMGR_H 23 | 24 | #include 25 | #include "x86defs.h" 26 | 27 | #define LINUX_PROT_READ 0x1 /* Page can be read. */ 28 | #define LINUX_PROT_WRITE 0x2 /* Page can be written. */ 29 | #define LINUX_PROT_EXEC 0x4 /* Page can be executed. */ 30 | #define LINUX_PROT_NONE 0x0 /* Page can not be accessed. */ 31 | #define LINUX_PROT_GROWSDOWN 0x01000000 /* Extend change to start of 32 | growsdown vma (mprotect only). */ 33 | #define LINUX_PROT_GROWSUP 0x02000000 /* Extend change to start of 34 | growsup vma (mprotect only). */ 35 | 36 | #define RWX (LINUX_PROT_READ | LINUX_PROT_WRITE | LINUX_PROT_EXEC) 37 | #define RW (LINUX_PROT_READ | LINUX_PROT_WRITE) 38 | 39 | /* Sharing types (must choose one and only one of these). */ 40 | #define LINUX_MAP_SHARED 0x01 /* Share changes. */ 41 | #define LINUX_MAP_PRIVATE 0x02 /* Changes are private. */ 42 | #define LINUX_MAP_TYPE 0x0f /* Mask for type of mapping. */ 43 | #define LINUX_PROT_GROWSDOWN 0x01000000 /* Extend change to start of 44 | growsdown vma (mprotect only). */ 45 | #define LINUX_PROT_GROWSUP 0x02000000 /* Extend change to start of 46 | growsup vma (mprotect only). */ 47 | 48 | /* Sharing types (must choose one and only one of these). */ 49 | #define LINUX_MAP_SHARED 0x01 /* Share changes. */ 50 | #define LINUX_MAP_PRIVATE 0x02 /* Changes are private. */ 51 | #define LINUX_MAP_TYPE 0x0f /* Mask for type of mapping. */ 52 | 53 | /* Other flags. */ 54 | #define LINUX_MAP_FIXED 0x10 /* Interpret addr exactly. */ 55 | #define LINUX_MAP_FILE 0 56 | #define LINUX_MAP_ANONYMOUS 0x20 /* Don't use a file. */ 57 | #define LINUX_MAP_ANON LINUX_MAP_ANONYMOUS 58 | 59 | /* These are Linux-specific. */ 60 | #define LINUX_MAP_GROWSDOWN 0x00100 /* Stack-like segment. */ 61 | #define LINUX_MAP_DENYWRITE 0x00800 /* ETXTBSY */ 62 | #define LINUX_MAP_EXECUTABLE 0x01000 /* Mark it as an executable. */ 63 | #define LINUX_MAP_LOCKED 0x02000 /* Lock the mapping. */ 64 | #define LINUX_MAP_NORESERVE 0x04000 /* Don't check for reservations. */ 65 | #define LINUX_MAP_POPULATE 0x08000 /* Populate (prefault) pagetables. */ 66 | #define LINUX_MAP_NONBLOCK 0x10000 /* Do not block on IO. */ 67 | #define LINUX_MAP_STACK 0x20000 /* Allocation is for a stack. */ 68 | 69 | //for access 70 | #define LINUX_R_OK 4 /* Test for read permission. */ 71 | #define LINUX_W_OK 2 /* Test for write permission. */ 72 | #define LINUX_X_OK 1 /* Test for execute permission. */ 73 | #define LINUX_F_OK 0 /* Test for existence. */ 74 | 75 | #define MM_MAP_FIXED LINUX_MAP_FIXED 76 | #define MM_MAP_ANONYMOUS LINUX_MAP_ANONYMOUS 77 | 78 | void createNewSegment(const char *name, uint32_t base, uint32_t size); 79 | 80 | class MemMgr { 81 | static uint32_t search_up(uint32_t addr, uint32_t size, uint32_t limit); 82 | static uint32_t search_down(uint32_t addr, uint32_t size, uint32_t limit); 83 | public: 84 | static void reserve(uint32_t addr, uint32_t size); 85 | static uint32_t mmap(uint32_t addr, uint32_t size, uint32_t prot, uint32_t flags, const char *segName = NULL); 86 | static uint32_t mapFixed(uint32_t addr, uint32_t size, uint32_t prot, uint32_t flags, const char *segName = NULL); 87 | static uint32_t munmap(uint32_t addr, uint32_t size, bool keep = true); 88 | }; 89 | 90 | #endif 91 | -------------------------------------------------------------------------------- /peutils.h: -------------------------------------------------------------------------------- 1 | /* 2 | Source for x86 emulator IdaPro plugin 3 | Copyright (c) 2005-2022 Chris Eagle 4 | 5 | This program is free software; you can redistribute it and/or modify it 6 | under the terms of the GNU General Public License as published by the Free 7 | Software Foundation; either version 2 of the License, or (at your option) 8 | any later version. 9 | 10 | This program is distributed in the hope that it will be useful, but WITHOUT 11 | ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 12 | FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for 13 | more details. 14 | 15 | You should have received a copy of the GNU General Public License along with 16 | this program; if not, write to the Free Software Foundation, Inc., 59 Temple 17 | Place, Suite 330, Boston, MA 02111-1307 USA 18 | */ 19 | 20 | #ifndef __PE_UTILS_H 21 | #define __PE_UTILS_H 22 | 23 | #include 24 | #include 25 | 26 | #include "buffer.h" 27 | 28 | struct _IMAGE_NT_HEADERS; 29 | struct _IMAGE_SECTION_HEADER; 30 | struct _IMAGE_EXPORT_DIRECTORY; 31 | 32 | typedef struct _IMAGE_NT_HEADERS IMAGE_NT_HEADERS32; 33 | typedef struct _IMAGE_SECTION_HEADER IMAGE_SECTION_HEADER; 34 | 35 | //IMAGE_NT_HEADERS.FileHeader.Characteristics dw offset 4 + 0x12 = 0x16 = 22 36 | //exe will have the following set 37 | #define _IMAGE_FILE_EXECUTABLE_IMAGE 2 38 | //dll will have the following set IN ADDITION to _IMAGE_FILE_EXECUTABLE_IMAGE 39 | #define _IMAGE_FILE_DLL 0x2000 40 | 41 | //IMAGE_NT_HEADERS.OptionalHeader.Subsystem dw offset 0x18 + 0x44 = 0x5C = 92 42 | #define _IMAGE_SUBSYSTEM_WINDOWS_GUI 2 43 | #define _IMAGE_SUBSYSTEM_WINDOWS_CUI 3 44 | 45 | #define _DLL_PROCESS_ATTACH 1 46 | #define _DLL_PROCESS_DETACH 0 47 | #define _DLL_THREAD_ATTACH 2 48 | #define _DLL_THREAD_DETACH 3 49 | 50 | #define _SW_HIDE 0 51 | #define _SW_MAXIMIZE 3 52 | #define _SW_MINIMIZE 6 53 | #define _SW_RESTORE 9 54 | #define _SW_SHOW 5 55 | #define _SW_SHOWMAXIMIZED 3 56 | #define _SW_SHOWMINIMIZED 2 57 | #define _SW_SHOWMINNOACTIVE 7 58 | #define _SW_SHOWNA 8 59 | #define _SW_SHOWNOACTIVATE 4 60 | #define _SW_SHOWNORMAL 1 61 | 62 | struct thunk_rec { 63 | char *dll_name; 64 | unsigned int iat_base; //base VA for iat 65 | unsigned int iat_size; 66 | unsigned int *iat; 67 | // char **names; 68 | thunk_rec *next; 69 | }; 70 | 71 | class PETables { 72 | public: 73 | PETables(); 74 | ~PETables(); 75 | unsigned int rvaToFileOffset(unsigned int rva); 76 | void setBase(unsigned int b) {base = b;}; 77 | void setNtHeaders(IMAGE_NT_HEADERS32 *inth); 78 | void setSectionHeaders(unsigned int nsecs, IMAGE_SECTION_HEADER *ish); 79 | void buildThunks(FILE *f); 80 | void destroy(); 81 | void loadTables(Buffer &b); 82 | void saveTables(Buffer &b); 83 | 84 | unsigned int valid; 85 | unsigned int base; 86 | IMAGE_NT_HEADERS32 *nt; 87 | IMAGE_SECTION_HEADER *sections; 88 | unsigned short num_sections; 89 | thunk_rec *imports; 90 | }; 91 | 92 | struct DllList { 93 | char *dllName; 94 | unsigned int handle; 95 | unsigned int id; 96 | unsigned int maxAddr; 97 | IMAGE_NT_HEADERS32 *nt; 98 | IMAGE_SECTION_HEADER *sections; 99 | _IMAGE_EXPORT_DIRECTORY *exportdir; 100 | unsigned int NoF; //NumberOfFunctions 101 | unsigned int NoN; //NumberOfNames 102 | unsigned int *eat; // AddressOfFunctions export address table 103 | unsigned int *ent; // AddressOfNames export name table 104 | unsigned short *eot; // AddressOfNameOrdinals export ordinal table 105 | DllList *next; 106 | }; 107 | 108 | unsigned int loadIntoIdb(FILE *dll); 109 | void applyPEHeaderTemplates(unsigned int mz_addr); 110 | void createSegment(unsigned int start, unsigned int size, unsigned char *content, 111 | unsigned int clen = 0, const char *name = NULL); 112 | void zero_fill(ea_t base, size_t size); 113 | 114 | #endif 115 | -------------------------------------------------------------------------------- /resource.h: -------------------------------------------------------------------------------- 1 | //{{NO_DEPENDENCIES}} 2 | // Microsoft Visual C++ generated include file. 3 | // Used by dialog.rc 4 | // 5 | #define ID_DESTROY 3 6 | #define IDD_EMUDIALOG 101 7 | #define IDD_SEGMENTDIALOG 103 8 | #define IDR_IDAMENU 104 9 | #define IDD_MEMORY 105 10 | #define IDD_SET_MEMORY 107 11 | #define IDD_UNEMULATED 108 12 | #define IDD_SWITCH_THREAD 109 13 | #define IDD_INPUTDIALOG 110 14 | #define IDD_MMAP 111 15 | #define IDC_STEP 1000 16 | #define ID_OK 1000 17 | #define IDC_STEP_CURSOR 1001 18 | #define ID_CANCEL 1001 19 | #define IDC_JUMP_CURSOR 1001 20 | #define IDC_MESSAGE 1002 21 | #define IDC_RUN 1003 22 | #define IDC_DATA 1003 23 | #define IDC_SKIP 1004 24 | #define IDC_MMAP_SIZE 1004 25 | #define IDC_RUN_TO_CURSOR 1005 26 | #define IDC_MESSAGE2 1005 27 | #define IDC_HIDE 1006 28 | #define IDC_RUN2 1006 29 | #define IDC_BREAK 1006 30 | #define IDC_EAX 1007 31 | #define IDC_EBX 1008 32 | #define IDC_ECX 1009 33 | #define IDC_EDX 1010 34 | #define IDC_EBP 1011 35 | #define IDC_ESP 1012 36 | #define IDC_ESI 1013 37 | #define IDC_EDI 1014 38 | #define IDC_EIP 1015 39 | #define IDC_EFLAGS 1016 40 | #define IDC_MEMORY 1018 41 | #define IDC_PUSH 1019 42 | #define IDC_DUMP 1020 43 | #define IDC_SEGMENTS 1021 44 | #define IDC_CS_REG 1022 45 | #define IDC_SS_REG 1023 46 | #define IDC_DS_REG 1024 47 | #define IDC_STACKTOP 1024 48 | #define IDC_ES_REG 1025 49 | #define IDC_STACKSIZE 1025 50 | #define IDC_FS_REG 1026 51 | #define IDC_HEAPBASE 1026 52 | #define IDC_GS_REG 1027 53 | #define IDC_HEAPSIZE 1027 54 | #define IDC_CS_BASE 1028 55 | #define IDC_SS_BASE 1029 56 | #define IDC_DS_BASE 1030 57 | #define IDC_ES_BASE 1031 58 | #define IDC_FS_BASE 1032 59 | #define IDC_GS_BASE 1033 60 | #define IDC_MEM_ADDR 1037 61 | #define IDC_MEM_VALUES 1038 62 | #define IDC_HEX_BYTES 1039 63 | #define IDC_HEX_WORDS 1040 64 | #define IDC_MEM_ASCII 1041 65 | #define IDC_HEX_DWORDS 1042 66 | #define IDC_MEM_ASCIIZ 1043 67 | #define IDC_SET_MEMORY 1044 68 | #define IDC_MEM_LOADFILE 1044 69 | #define IDC_RETURN_VALUE 1044 70 | #define IDC_CLEAR_STACK 1045 71 | #define IDC_CALL_CDECL 1046 72 | #define IDC_CALL_STDCALL 1047 73 | #define IDC_PARM_LIST 1050 74 | #define IDC_THREAD_LIST 1051 75 | #define IDC_RETURN_LABEL 1052 76 | #define IDC_MMAP_BASE 1054 77 | #define IDC_RESET 40002 78 | #define IDC_EDITSTACK 40003 79 | #define IDC_SETTINGS 40005 80 | #define IDC_VIRTUAL_ALLOC 40009 81 | #define IDC_VIRTUAL_FREE 40010 82 | #define IDC_MALLOC 40011 83 | #define IDC_CALLOC 40012 84 | #define IDC_REALLOC 40013 85 | #define IDC_FREE 40014 86 | #define IDC_HOOK 40015 87 | #define IDC_SETGETPROC 40016 88 | #define IDC_AUTOHOOK 40019 89 | #define IDC_GPA 40020 90 | #define IDC_MEMEX 40021 91 | #define IDC_BKPTEX 40022 92 | #define IDC_DIVEX 40023 93 | #define IDC_DEBUGEX 40024 94 | #define IDC_BREAKPOINT 40025 95 | #define IDC_CLEARBREAK 40026 96 | #define IDC_PATCHHOOK 40027 97 | #define IDC_EXPORT 40028 98 | #define IDC_SWITCH 40030 99 | #define IDC_HEAP_LIST 40031 100 | #define IDC_HEADERS 40032 101 | #define IDC_TRACE 40033 102 | #define IDC_TRACK 40034 103 | #define IDC_DUMP_PE 40035 104 | #define IDC_HEAP_BLOCK 40036 105 | #define IDC_STACK_BLOCK 40037 106 | #define IDC_MMAP_BLOCK 40038 107 | #define ID_FUNCTIONS_PUSH 40041 108 | #define ID_PUSH_PUSHMAINARGS 40042 109 | #define ID_PUSH_PUSHWINMAINARGS 40043 110 | #define ID_PUSH_PUSHDLLMAINARGS 40044 111 | #define ID_Menu 40045 112 | #define IDC_LOADLIB 40047 113 | #define ID_EMULATE_BREAKONEXCEPTIONS 40048 114 | #define IDC_LOGLIB 40049 115 | 116 | //Fix for Visual C++ Express Edition 117 | #ifndef IDC_STATIC 118 | #define IDC_STATIC (-1) 119 | #endif 120 | 121 | // Next default values for new objects 122 | // 123 | #ifdef APSTUDIO_INVOKED 124 | #ifndef APSTUDIO_READONLY_SYMBOLS 125 | #define _APS_NEXT_RESOURCE_VALUE 110 126 | #define _APS_NEXT_COMMAND_VALUE 40049 127 | #define _APS_NEXT_CONTROL_VALUE 1055 128 | #define _APS_NEXT_SYMED_VALUE 101 129 | #endif 130 | #endif 131 | -------------------------------------------------------------------------------- /sdk_versions.h: -------------------------------------------------------------------------------- 1 | /* 2 | Source for x86 emulator IdaPro plugin 3 | File: sdk_versions.h 4 | Copyright (c) 2004-2022, Chris Eagle 5 | 6 | This program is free software; you can redistribute it and/or modify it 7 | under the terms of the GNU General Public License as published by the Free 8 | Software Foundation; either version 2 of the License, or (at your option) 9 | any later version. 10 | 11 | This program is distributed in the hope that it will be useful, but WITHOUT 12 | ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 13 | FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for 14 | more details. 15 | 16 | You should have received a copy of the GNU General Public License along with 17 | this program; if not, write to the Free Software Foundation, Inc., 59 Temple 18 | Place, Suite 330, Boston, MA 02111-1307 USA 19 | */ 20 | 21 | #ifndef __SDK_VERSIONS_H 22 | #define __SDK_VERSIONS_H 23 | 24 | #include 25 | #include 26 | #include 27 | #include 28 | 29 | /* 30 | //Ida 4.3 31 | #define IDP_INTERFACE_VERSION 61 32 | 33 | //Ida 4.4 34 | #define IDP_INTERFACE_VERSION 62 35 | 36 | //Ida 4.5 37 | #define IDP_INTERFACE_VERSION 63 38 | 39 | //Ida 4.6 40 | #define IDP_INTERFACE_VERSION 66 41 | 42 | //Ida 4.6sp1 43 | #define IDP_INTERFACE_VERSION 67 44 | 45 | //Ida 4.7 46 | #define IDP_INTERFACE_VERSION 70 47 | 48 | //Ida 4.8 49 | #define IDP_INTERFACE_VERSION 75 50 | 51 | //Ida 4.9, 4.9sp, 5.0, 5.1 52 | #define IDP_INTERFACE_VERSION 76 53 | */ 54 | 55 | #define SDK_VERSION_430 61 56 | #define SDK_VERSION_440 62 57 | #define SDK_VERSION_450 63 58 | #define SDK_VERSION_460 66 59 | #define SDK_VERSION_460sp1 67 60 | #define SDK_VERSION_470 70 61 | #define SDK_VERSION_480 75 62 | #define SDK_VERSION_490 76 63 | #define SDK_VERSION_500 76 64 | #define SDK_VERSION_510 76 65 | 66 | //prior to SDK490, SDK versions can be mapped to IDP_INTERFACE_VERSION 67 | #if IDP_INTERFACE_VERSION == SDK_VERSION_430 68 | #define IDA_SDK_VERSION 430 69 | #endif 70 | #if IDP_INTERFACE_VERSION == SDK_VERSION_440 71 | #define IDA_SDK_VERSION 440 72 | #endif 73 | #if IDP_INTERFACE_VERSION == SDK_VERSION_450 74 | #define IDA_SDK_VERSION 450 75 | #endif 76 | #if IDP_INTERFACE_VERSION == SDK_VERSION_460 77 | #define IDA_SDK_VERSION 460 78 | #endif 79 | #if IDP_INTERFACE_VERSION == SDK_VERSION_460sp1 80 | #define IDA_SDK_VERSION 461 81 | #endif 82 | #if IDP_INTERFACE_VERSION == SDK_VERSION_470 83 | #define IDA_SDK_VERSION 470 84 | #endif 85 | #if IDP_INTERFACE_VERSION == SDK_VERSION_480 86 | #define IDA_SDK_VERSION 480 87 | #endif 88 | 89 | /* beginning with SDK520, IDA_SDK_VERSION is defined in pro.h */ 90 | #ifndef IDA_SDK_VERSION //SDK520 and later 91 | #if IDP_INTERFACE_VERSION == 76 //SDK490 and later 92 | 93 | #ifdef DOUNK_SIMPLE //defined in bytes.hpp in SDK510 94 | #define IDA_SDK_VERSION 510 95 | #else //DOUNK_SIMPLE 96 | 97 | #ifdef SEGDEL_PERM //defined in segment.hpp in SDK500 98 | #define IDA_SDK_VERSION 500 99 | #else //SEGDEL_PERM 100 | #define IDA_SDK_VERSION 490 101 | #endif //SEGDEL_PERM 102 | 103 | #endif //DOUNK_SIMPLE 104 | 105 | #endif //IDP_INTERFACE_VERSION == 76 106 | #endif //IDA_SDK_VERSION 107 | 108 | #endif 109 | -------------------------------------------------------------------------------- /seh.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | Source for x86 emulator IdaPro plugin 3 | File: seh.cpp 4 | Copyright (c) 2004-2022, Chris Eagle 5 | 6 | This program is free software; you can redistribute it and/or modify it 7 | under the terms of the GNU General Public License as published by the Free 8 | Software Foundation; either version 2 of the License, or (at your option) 9 | any later version. 10 | 11 | This program is distributed in the hope that it will be useful, but WITHOUT 12 | ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 13 | FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for 14 | more details. 15 | 16 | You should have received a copy of the GNU General Public License along with 17 | this program; if not, write to the Free Software Foundation, Inc., 59 Temple 18 | Place, Suite 330, Boston, MA 02111-1307 USA 19 | */ 20 | 21 | #include "cpu.h" 22 | #include "seh.h" 23 | 24 | static int seh_enable = 0; 25 | static WIN_CONTEXT ctx; 26 | 27 | typedef struct _VehNode { 28 | unsigned int handler; 29 | struct _VehNode *next; 30 | } VehNode; 31 | 32 | static VehNode *vehList; 33 | 34 | struct WIN_CONTEXT *getContext() { 35 | return &ctx; 36 | } 37 | 38 | int usingSEH() { 39 | return seh_enable; 40 | } 41 | 42 | VehNode *findVehHandler(unsigned int handler) { 43 | for (VehNode *h = vehList; h; h = h->next) { 44 | if (h->handler == handler) { 45 | return h; 46 | } 47 | } 48 | return NULL; 49 | } 50 | 51 | void saveSEHState(Buffer &b) { 52 | int dummy; 53 | b.write(&dummy, sizeof(dummy)); 54 | b.write(&seh_enable, sizeof(seh_enable)); 55 | b.write(&ctx, sizeof(ctx)); 56 | } 57 | 58 | void loadSEHState(Buffer &b) { 59 | unsigned int dummy; 60 | b.read(&dummy, sizeof(dummy)); 61 | b.read(&seh_enable, sizeof(seh_enable)); 62 | b.read(&ctx, sizeof(ctx)); 63 | } 64 | 65 | void saveVEHState(Buffer &b) { 66 | for (VehNode *v = vehList; v; v = v->next) { 67 | b.write(&v->handler, sizeof(unsigned int)); 68 | } 69 | } 70 | 71 | void loadVEHState(Buffer &b) { 72 | unsigned int dummy; 73 | while (b.read(&dummy, sizeof(dummy)) == 0) { 74 | addVectoredExceptionHandler(0, dummy); 75 | } 76 | b.reset_error(); 77 | } 78 | 79 | //Copy current CPU state into CONTEXT structure for Windows Exception Handling 80 | //Note that the global ctx struct is the only place that Debug and Floating 81 | //point registers are currently defined 82 | void cpuToContext() { 83 | regsToContext(&cpu, &ctx); 84 | ctx.Eip = cpu.initial_eip; //use address at which exception occurred 85 | } 86 | 87 | //Copy from CONTEXT structure into CPU state for Windows Exception Handling 88 | //Note that the global ctx struct is the only place that Debug and Floating 89 | //point registers are currently defined 90 | void contextToCpu() { 91 | contextToRegs(&ctx, &cpu); 92 | } 93 | 94 | void initContext() { 95 | initContext(&ctx); 96 | } 97 | 98 | void popContext() { 99 | unsigned char *ptr = (unsigned char*) &ctx; 100 | unsigned int addr, i; 101 | unsigned int ctx_size = (sizeof(WIN_CONTEXT) + 3) & ~3; //round up to next unsigned int 102 | addr = esp; 103 | for (i = 0; i < sizeof(WIN_CONTEXT); i++) { 104 | *ptr++ = (unsigned char) readMem(addr++, SIZE_BYTE); 105 | } 106 | esp += ctx_size; 107 | contextToCpu(); 108 | } 109 | 110 | void getContextToMem(unsigned int addr) { 111 | // unsigned char *ptr = (unsigned char*) &ctx; 112 | cpuToContext(); 113 | copyContextToMem(&ctx, addr); 114 | } 115 | 116 | unsigned int pushContext() { 117 | unsigned int ctx_size = (sizeof(WIN_CONTEXT) + 3) & ~3; //round up to next unsigned int 118 | unsigned int addr = esp - ctx_size; 119 | getContextToMem(addr); 120 | esp = addr; 121 | return esp; 122 | } 123 | 124 | void popExceptionRecord(EXCEPTION_RECORD *rec) { 125 | unsigned char *ptr = (unsigned char*) &rec; 126 | unsigned int addr, i; 127 | unsigned int rec_size = (sizeof(EXCEPTION_RECORD) + 3) & ~3; //round up to next unsigned int 128 | addr = esp; 129 | for (i = 0; i < sizeof(EXCEPTION_RECORD); i++) { 130 | *ptr++ = (unsigned char) readMem(addr++, SIZE_BYTE); 131 | } 132 | esp += rec_size; 133 | } 134 | 135 | unsigned int pushExceptionRecord(EXCEPTION_RECORD *rec) { 136 | unsigned char *ptr = (unsigned char*) rec; 137 | unsigned int addr, i; 138 | unsigned int rec_size = (sizeof(EXCEPTION_RECORD) + 3) & ~3; //round up to next unsigned int 139 | addr = esp -= rec_size; 140 | for (i = 0; i < sizeof(EXCEPTION_RECORD); i++) { 141 | writeMem(addr++, *ptr++, SIZE_BYTE); 142 | } 143 | return esp; 144 | } 145 | 146 | void doSehException(EXCEPTION_RECORD *rec) { 147 | unsigned int err_ptr = readMem(fsBase, SIZE_DWORD); 148 | unsigned int handler = readMem(err_ptr + 4, SIZE_DWORD); //err->handler 149 | 150 | //do sanity checks on handler here? 151 | 152 | cpuToContext(); 153 | unsigned int ctx_ptr = pushContext(); 154 | unsigned int rec_ptr = pushExceptionRecord(rec); 155 | 156 | push(ctx_ptr, SIZE_DWORD); 157 | push(err_ptr, SIZE_DWORD); //err_ptr == fsBase?? 158 | push(rec_ptr, SIZE_DWORD); 159 | push(SEH_MAGIC, SIZE_DWORD); //handler return address 160 | //need to execute exception handler here setup flag to trap ret 161 | //set eip to start of exception handler and resume fetching 162 | cpu.eip = handler; 163 | } 164 | 165 | static unsigned int currentVehHandler; 166 | 167 | void doVehException(EXCEPTION_RECORD *rec, unsigned int handler) { 168 | cpuToContext(); 169 | unsigned int ctx_ptr = pushContext(); 170 | unsigned int rec_ptr = pushExceptionRecord(rec); 171 | 172 | push(ctx_ptr, SIZE_DWORD); 173 | push(rec_ptr, SIZE_DWORD); 174 | push(esp, SIZE_DWORD); 175 | push(VEH_MAGIC, SIZE_DWORD); //handler return address 176 | //need to execute exception handler here setup flag to trap ret 177 | //set eip to start of exception handler and resume fetching 178 | cpu.eip = handler; 179 | } 180 | 181 | void doException(EXCEPTION_RECORD *rec) { 182 | if (vehList) { 183 | if (currentVehHandler == 0) { 184 | currentVehHandler = vehList->handler; 185 | doVehException(rec, currentVehHandler); 186 | } 187 | else { 188 | VehNode *v = findVehHandler(currentVehHandler); 189 | if (v) { 190 | v = v->next; 191 | } 192 | if (v) { 193 | currentVehHandler = v->handler; 194 | doVehException(rec, currentVehHandler); 195 | } 196 | else { 197 | currentVehHandler = 0xffffffff; 198 | } 199 | } 200 | } 201 | else { 202 | currentVehHandler = 0xffffffff; 203 | } 204 | if (currentVehHandler == 0xffffffff) { 205 | doSehException(rec); 206 | } 207 | } 208 | 209 | void sehReturn() { 210 | EXCEPTION_RECORD rec; 211 | 212 | //need to check eax here to see if exception was handled 213 | //or if it needs to be kicked up to next SEH handler 214 | 215 | esp += 3 * SIZE_DWORD; //clear off exception pointers 216 | 217 | popExceptionRecord(&rec); 218 | 219 | popContext(); 220 | contextToCpu(); 221 | //eip is now restored to pre exception location 222 | 223 | //need to fake an iret here 224 | doInterruptReturn(); //this clobbers EIP, CS, EFLAGS 225 | //so restore them here from ctx values 226 | cpu.eip = ctx.Eip; 227 | cpu.eflags = ctx.EFlags; 228 | _cs = ctx.SegCs; 229 | msg("Performing SEH return\n"); 230 | currentVehHandler = 0; 231 | } 232 | 233 | void vehReturn() { 234 | EXCEPTION_RECORD rec; 235 | 236 | //need to check eax here to see if exception was handled 237 | //or if it needs to be kicked up to next SEH handler 238 | unsigned int res = eax; 239 | 240 | esp += 3 * SIZE_DWORD; //clear off exception pointers 241 | 242 | popExceptionRecord(&rec); 243 | 244 | popContext(); 245 | contextToCpu(); 246 | //eip is now restored to pre exception location 247 | 248 | //need to fake an iret here 249 | doInterruptReturn(); //this clobbers EIP, CS, EFLAGS 250 | //so restore them here from ctx values 251 | cpu.eip = ctx.Eip; 252 | cpu.eflags = ctx.EFlags; 253 | _cs = ctx.SegCs; 254 | msg("Performing VEH return\n"); 255 | 256 | if (res == EXCEPTION_CONTINUE_EXECUTION) { 257 | currentVehHandler = 0; 258 | } 259 | else { //res == EXCEPTION_CONTINUE_SEARCH 260 | doException(&rec); 261 | } 262 | } 263 | 264 | void generateException(unsigned int code) { 265 | if (seh_enable) { 266 | EXCEPTION_RECORD rec; 267 | rec.exceptionCode = code; 268 | rec.exceptionFlags = CONTINUABLE; //nothing sophisticated here 269 | rec.exceptionRecord = 0; //NULL 270 | rec.exceptionAddress = cpu.initial_eip; 271 | rec.numberParameters = 0; 272 | doException(&rec); 273 | } 274 | } 275 | 276 | void breakpointException() { 277 | generateException(BREAKPOINT_EXCEPTION); 278 | } 279 | 280 | void debugException() { 281 | generateException(DEBUG_EXCEPTION); 282 | } 283 | 284 | void divzeroException() { 285 | generateException(DIV_ZERO_EXCEPTION); 286 | } 287 | 288 | void memoryAccessException() { 289 | generateException(MEM_ACCESS); 290 | } 291 | 292 | void IllegalOpcodeException() { 293 | generateException(UNDEFINED_OPCODE_EXCEPTION); 294 | } 295 | 296 | void enableSEH() { 297 | initContext(); 298 | seh_enable = 1; 299 | } 300 | 301 | void sehBegin(unsigned int interrupt_number) { 302 | msg("Initiating SEH processing of INT %d\n", interrupt_number); 303 | switch (interrupt_number) { 304 | case 0: 305 | generateException(DIV_ZERO_EXCEPTION); 306 | break; 307 | case 1: 308 | generateException(DEBUG_EXCEPTION); 309 | break; 310 | case 3: 311 | generateException(BREAKPOINT_EXCEPTION); 312 | break; 313 | case 6: 314 | generateException(UNDEFINED_OPCODE_EXCEPTION); 315 | break; 316 | case 14: 317 | generateException(MEM_ACCESS); 318 | break; 319 | } 320 | } 321 | 322 | void addVectoredExceptionHandler(bool first, unsigned int handler) { 323 | VehNode *n = (VehNode*)malloc(sizeof(VehNode)); 324 | n->handler = handler; 325 | if (first) { 326 | n->next = vehList; 327 | vehList = n; 328 | } 329 | else { 330 | n->next = NULL; 331 | if (vehList) { 332 | VehNode *h; 333 | for (h = vehList; h->next; h = h->next) {} 334 | h->next = n; 335 | } 336 | else { 337 | vehList = n; 338 | } 339 | } 340 | } 341 | 342 | void removeVectoredExceptionHandler(unsigned int handler) { 343 | VehNode *p = NULL; 344 | for (VehNode *h = vehList; h->next; h = h->next) { 345 | if (h->handler == handler) { 346 | if (p) { 347 | p->next = h->next; 348 | } 349 | else { 350 | vehList = p->next; 351 | } 352 | free(h); 353 | break; 354 | } 355 | p = h; 356 | } 357 | } 358 | -------------------------------------------------------------------------------- /seh.h: -------------------------------------------------------------------------------- 1 | /* 2 | Source for x86 emulator IdaPro plugin 3 | File: seh.h 4 | Copyright (c) 2004-2022, Chris Eagle 5 | 6 | This program is free software; you can redistribute it and/or modify it 7 | under the terms of the GNU General Public License as published by the Free 8 | Software Foundation; either version 2 of the License, or (at your option) 9 | any later version. 10 | 11 | This program is distributed in the hope that it will be useful, but WITHOUT 12 | ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 13 | FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for 14 | more details. 15 | 16 | You should have received a copy of the GNU General Public License along with 17 | this program; if not, write to the Free Software Foundation, Inc., 59 Temple 18 | Place, Suite 330, Boston, MA 02111-1307 USA 19 | */ 20 | 21 | #ifndef __WIN_SEH_H 22 | #define __WIN_SEH_H 23 | 24 | #include "context.h" 25 | #include "buffer.h" 26 | 27 | #define SEH_MAGIC 0xBABEFACE 28 | #define VEH_MAGIC 0xFACEBABE 29 | 30 | #define SIZEOF_387_REGS 80 31 | #define MAXIMUM_EXTENSION 512 32 | 33 | //Some exception codes 34 | 35 | //Read or write memory violation 36 | #define MEM_ACCESS 0xC0000005 37 | 38 | //Illegal instruction 39 | #define UNDEFINED_OPCODE_EXCEPTION 0xC000001D 40 | 41 | //Divide by zero 42 | #define DIV_ZERO_EXCEPTION 0xC0000094 43 | 44 | //Divide overflow 45 | #define DIV_OFLOW 0xC0000095 46 | 47 | //The stack went beyond the maximum available size 48 | #define STACK_OVERFLOW 0xC00000FD 49 | 50 | //Violation of a guard page in memory set up using Virtual Alloc 51 | #define GUARD_ERROR 0x80000001 52 | 53 | //The following only occur whilst dealing with exceptions:- 54 | 55 | //A non-continuable exception: the handler should not try to deal with it 56 | #define NON_CONT 0xC0000025 57 | 58 | //Exception code used the by system during exception handling. This code might 59 | //be used if the system encounters an unexpected return from a handler. It is 60 | //also used if no Exception Record is supplied when calling RtlUnwind. 61 | #define EXC_EXC 0xC0000026 62 | 63 | //The following are used in debugging:- 64 | 65 | //Breakpoint occurred because there was an INT3 in the code 66 | #define BREAKPOINT_EXCEPTION 0x80000003 67 | 68 | //Single step during debugging 69 | #define DEBUG_EXCEPTION 0x80000004 70 | 71 | #define CONTINUABLE 0 72 | #define NON_CONTINUABLE 1 73 | #define STACK_UNWINDING 2 74 | 75 | #define EXCEPTION_CONTINUE_EXECUTION 0xffffffff 76 | #define EXCEPTION_CONTINUE_SEARCH 0 77 | 78 | #define MAXIMUM_PARMS 15 79 | 80 | struct EXCEPTION_RECORD { 81 | unsigned int exceptionCode; 82 | unsigned int exceptionFlags; 83 | unsigned int exceptionRecord; //struct _EXCEPTION_RECORD *ExceptionRecord 84 | unsigned int exceptionAddress; 85 | unsigned int numberParameters; 86 | unsigned int exceptionInformation[MAXIMUM_PARMS]; 87 | }; 88 | 89 | struct EXCEPTION_POINTERS { 90 | EXCEPTION_RECORD *exceptionRecord; 91 | WIN_CONTEXT *contextRecord; 92 | }; 93 | 94 | struct ERR { 95 | unsigned int nextErr; //struct _ERR *nextErr; 96 | unsigned int handler; //pointer to handler 97 | }; 98 | 99 | int usingSEH(); 100 | void sehBegin(unsigned int interrupt_number); 101 | void sehReturn(); 102 | void vehReturn(); 103 | void breakpointException(); 104 | void debugException(); 105 | void divzeroException(); 106 | void memoryAccessException(); 107 | void enableSEH(); 108 | void saveSEHState(Buffer &b); 109 | void loadSEHState(Buffer &b); 110 | void saveVEHState(Buffer &b); 111 | void loadVEHState(Buffer &b); 112 | struct WIN_CONTEXT *getContext(); 113 | 114 | void addVectoredExceptionHandler(bool first, unsigned int handler); 115 | void removeVectoredExceptionHandler(unsigned int handler); 116 | 117 | #endif 118 | -------------------------------------------------------------------------------- /x86emu.idc: -------------------------------------------------------------------------------- 1 | /* 2 | Scripting support for the x86 emulator IdaPro plugin 3 | Copyright (c) 2008 Chris Eagle 4 | 5 | This program is free software; you can redistribute it and/or modify it 6 | under the terms of the GNU General Public License as published by the Free 7 | Software Foundation; either version 2 of the License, or (at your option) 8 | any later version. 9 | 10 | This program is distributed in the hope that it will be useful, but WITHOUT 11 | ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 12 | FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for 13 | more details. 14 | 15 | You should have received a copy of the GNU General Public License along with 16 | this program; if not, write to the Free Software Foundation, Inc., 59 Temple 17 | Place, Suite 330, Boston, MA 02111-1307 USA 18 | */ 19 | 20 | #ifndef __EMU_SCRIPT_H 21 | #define __EMU_SCRIPT_H 22 | 23 | #define EAX_REG 0 24 | #define ECX_REG 1 25 | #define EDX_REG 2 26 | #define EBX_REG 3 27 | #define ESP_REG 4 28 | #define EBP_REG 5 29 | #define ESI_REG 6 30 | #define EDI_REG 7 31 | 32 | #define EIP_REG 8 33 | #define EFLAGS_REG 9 34 | 35 | #define CS_REG 10 36 | #define SS_REG 11 37 | #define DS_REG 12 38 | #define ES_REG 13 39 | #define FS_REG 14 40 | #define GS_REG 15 41 | 42 | #define CS_BASE 20 43 | #define SS_BASE 21 44 | #define DS_BASE 22 45 | #define ES_BASE 23 46 | #define FS_BASE 24 47 | #define GS_BASE 25 48 | 49 | #define CR0_REG 30 50 | #define CR1_REG 31 51 | #define CR2_REG 32 52 | #define CR3_REG 33 53 | #define CR4_REG 34 54 | 55 | #define DR0_REG 40 56 | #define DR1_REG 41 57 | #define DR2_REG 42 58 | #define DR3_REG 43 59 | #define DR4_REG 44 60 | #define DR5_REG 45 61 | #define DR6_REG 46 62 | #define DR7_REG 47 63 | 64 | #endif 65 | -------------------------------------------------------------------------------- /x86emu.pro: -------------------------------------------------------------------------------- 1 | 2 | #your Ida SDK location either relative to ida-x86emu/trunk 3 | #or absolute 4 | SDK = ../.. 5 | 6 | OBJECTS_DIR = p32 7 | 8 | #Need to change the following to your Ida install location 9 | win32:IDA_APP = "C:/Program Files (x86)/Ida" 10 | linux-g++:IDA_APP = /opt/ida-$$(IDA_VERSION) 11 | macx:IDA_APP = "/Applications/IDA\ Pro\ $$(IDA_VERSION)/idaq.app/Contents" 12 | 13 | #Need to change the following to your Qt install location 14 | macx: { 15 | greaterThan(QT_MAJOR_VERSION, 4):QT_LOC = /Users/qt-5.4.1/5.4/clang_64/lib 16 | lessThan(QT_MAJOR_VERSION, 5):QT_LOC = /usr/local/qt/lib 17 | QT_TAIL = .framework/Versions/$$QT_MAJOR_VERSION/Headers 18 | #create our own list of Qt modules 19 | MODS = QtGui QtCore 20 | greaterThan(QT_MAJOR_VERSION, 4):MODS += QtWidgets 21 | } 22 | 23 | defineReplace(makeIncludes) { 24 | variable = $$1 25 | modules = $$eval($$variable) 26 | dirs = 27 | for(module, modules) { 28 | dir = $${QT_LOC}/$${module}$${QT_TAIL} 29 | dirs += $$dir 30 | } 31 | return($$dirs) 32 | } 33 | 34 | TEMPLATE = lib 35 | 36 | #QT += core gui 37 | greaterThan(QT_MAJOR_VERSION, 4):QT += widgets 38 | 39 | CONFIG += qt dll 40 | 41 | INCLUDEPATH += $${SDK}/include 42 | 43 | DESTDIR = bin 44 | 45 | #DEFINES += DEBUG 46 | DEFINES += __IDP__ __QT__ 47 | win32:DEFINES += __NT__ WIN32 48 | win32:DEFINES -= UNICODE 49 | win32:DEFINES += _CRT_SECURE_NO_WARNINGS 50 | linux-g++:DEFINES += __LINUX__ 51 | macx:DEFINES += __MAC__ 52 | 53 | win32:LIBS += comdlg32.lib gdi32.lib user32.lib advapi32.lib ida.lib ws2_32.lib 54 | win32-msvc2010: { 55 | exists( $${SDK}/lib/vc.w32/ida.lib ) { 56 | LIBS += -L$${SDK}/lib/vc.w32 57 | } else { 58 | LIBS += -L$${SDK}/lib/x86_win_vc_32 59 | } 60 | } 61 | linux-g++:LIBS += -L$${IDA_APP} -lida 62 | macx:LIBS += -L$${IDA_APP}/MacOs -lida 63 | 64 | #don't let qmake force search any libs other than the 65 | #ones that ship with Ida 66 | linux-g++:QMAKE_LFLAGS_RPATH = 67 | linux-g++:QMAKE_LIBDIR_QT = 68 | 69 | macx:QMAKE_INCDIR = $$makeIncludes(MODS) 70 | #add QTs actual include file location this way since -F is not 71 | #handled by QMAKE_INCDIR 72 | macx:QMAKE_CXXFLAGS += -m32 -F$${QT_LOC} 73 | 74 | linux-g++:QMAKE_CXXFLAGS = -m32 75 | 76 | linux-g++|macx: { 77 | QMAKE_CXXFLAGS += -m32 78 | QMAKE_CFLAGS += -m32 79 | QMAKE_LFLAGS += -m32 80 | } 81 | 82 | macx:QMAKE_LFLAGS += -F$${IDA_APP}/Frameworks 83 | macx:QMAKE_LIBDIR_QT = 84 | 85 | SOURCES = x86emu.cpp \ 86 | x86emu_ui_qt.cpp \ 87 | emufuncs.cpp \ 88 | cpu.cpp \ 89 | emuheap.cpp \ 90 | memmgr.cpp \ 91 | seh.cpp \ 92 | break.cpp \ 93 | hooklist.cpp \ 94 | buffer.cpp \ 95 | emuthreads.cpp \ 96 | peutils.cpp \ 97 | emu_script.cpp \ 98 | context.cpp \ 99 | aes.cpp \ 100 | ansi_cprng.cpp 101 | 102 | HEADERS = aes.h \ 103 | ansi_cprng.h \ 104 | break.h \ 105 | bsd_syscalls.h \ 106 | buffer.h \ 107 | cgc_syscalls.h \ 108 | context.h \ 109 | cpu.h \ 110 | elf32.h \ 111 | elf_common.h \ 112 | emu_script.h \ 113 | emufuncs.h \ 114 | emuheap.h \ 115 | emuthreads.h \ 116 | hooklist.h \ 117 | image.h \ 118 | linux_syscalls.h \ 119 | memmgr.h \ 120 | peutils.h \ 121 | sdk_versions.h \ 122 | seh.h \ 123 | x86emu_ui_qt.h \ 124 | x86defs.h 125 | 126 | win32:TARGET_EXT=.plw 127 | linux-g++:TARGET_EXT=.plx 128 | macx:TARGET_EXT=.pmc 129 | 130 | TARGET = x86emu_qt 131 | -------------------------------------------------------------------------------- /x86emu.sln: -------------------------------------------------------------------------------- 1 |  2 | Microsoft Visual Studio Solution File, Format Version 11.00 3 | # Visual Studio 2010 4 | Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "x86emu", "x86emu.vcxproj", "{7B4A96A3-659F-44A7-8A1E-B99CB16DD02E}" 5 | EndProject 6 | Global 7 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 8 | Debug|Win32 = Debug|Win32 9 | Release|Win32 = Release|Win32 10 | Release64|Win32 = Release64|Win32 11 | EndGlobalSection 12 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 13 | {7B4A96A3-659F-44A7-8A1E-B99CB16DD02E}.Debug|Win32.ActiveCfg = Debug|Win32 14 | {7B4A96A3-659F-44A7-8A1E-B99CB16DD02E}.Debug|Win32.Build.0 = Debug|Win32 15 | {7B4A96A3-659F-44A7-8A1E-B99CB16DD02E}.Release|Win32.ActiveCfg = Release|Win32 16 | {7B4A96A3-659F-44A7-8A1E-B99CB16DD02E}.Release|Win32.Build.0 = Release|Win32 17 | {7B4A96A3-659F-44A7-8A1E-B99CB16DD02E}.Release64|Win32.ActiveCfg = Release64|Win32 18 | {7B4A96A3-659F-44A7-8A1E-B99CB16DD02E}.Release64|Win32.Build.0 = Release64|Win32 19 | EndGlobalSection 20 | GlobalSection(SolutionProperties) = preSolution 21 | HideSolutionNode = FALSE 22 | EndGlobalSection 23 | EndGlobal 24 | -------------------------------------------------------------------------------- /x86emu.vcxproj.filters: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | {66bf7bc0-eeba-4bc3-9122-b703939aded1} 6 | cpp;c;cxx;rc;def;r;odl;idl;hpj;bat 7 | 8 | 9 | {6231a689-590d-458b-b802-12bd4f39ff5a} 10 | h;hpp;hxx;hm;inl 11 | 12 | 13 | {80893d90-0de1-4ed1-b3e2-6b799d770fe6} 14 | ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe 15 | 16 | 17 | 18 | 19 | Source Files 20 | 21 | 22 | Source Files 23 | 24 | 25 | Source Files 26 | 27 | 28 | Source Files 29 | 30 | 31 | Source Files 32 | 33 | 34 | Source Files 35 | 36 | 37 | Source Files 38 | 39 | 40 | Source Files 41 | 42 | 43 | Source Files 44 | 45 | 46 | Source Files 47 | 48 | 49 | Source Files 50 | 51 | 52 | Source Files 53 | 54 | 55 | Source Files 56 | 57 | 58 | Source Files 59 | 60 | 61 | Source Files 62 | 63 | 64 | Source Files 65 | 66 | 67 | 68 | 69 | Header Files 70 | 71 | 72 | Header Files 73 | 74 | 75 | Header Files 76 | 77 | 78 | Header Files 79 | 80 | 81 | Header Files 82 | 83 | 84 | Header Files 85 | 86 | 87 | Header Files 88 | 89 | 90 | Header Files 91 | 92 | 93 | Header Files 94 | 95 | 96 | Header Files 97 | 98 | 99 | Header Files 100 | 101 | 102 | Header Files 103 | 104 | 105 | Header Files 106 | 107 | 108 | Header Files 109 | 110 | 111 | Header Files 112 | 113 | 114 | Header Files 115 | 116 | 117 | Header Files 118 | 119 | 120 | Header Files 121 | 122 | 123 | Header Files 124 | 125 | 126 | Header Files 127 | 128 | 129 | Header Files 130 | 131 | 132 | 133 | 134 | Resource Files 135 | 136 | 137 | -------------------------------------------------------------------------------- /x86emu.vcxproj.user: -------------------------------------------------------------------------------- 1 |  2 | 3 | -------------------------------------------------------------------------------- /x86emu32-7.pro: -------------------------------------------------------------------------------- 1 | 2 | #your Ida SDK location either relative to x86emu 3 | #or absolute 4 | SDK = ../.. 5 | 6 | OBJECTS_DIR = p32-7 7 | 8 | #Need to change the following to your Ida install location 9 | linux-g++:IDA_APP = /opt/ida-$$(IDA_VERSION) 10 | macx:IDA_APP = "/Applications/IDA\ Pro\ $$(IDA_VERSION)/ida.app/Contents" 11 | 12 | #Need to change the following to your Qt install location 13 | macx: { 14 | greaterThan(QT_MAJOR_VERSION, 4):QT_LOC = /Users/qt-5.4.1/5.4/clang_64/lib 15 | lessThan(QT_MAJOR_VERSION, 5):QT_LOC = /usr/local/qt/lib 16 | QT_TAIL = .framework/Versions/$$QT_MAJOR_VERSION/Headers 17 | #create our own list of Qt modules 18 | MODS = QtGui QtCore 19 | greaterThan(QT_MAJOR_VERSION, 4):MODS += QtWidgets 20 | } 21 | 22 | defineReplace(makeIncludes) { 23 | variable = $$1 24 | modules = $$eval($$variable) 25 | dirs = 26 | for(module, modules) { 27 | dir = $${QT_LOC}/$${module}$${QT_TAIL} 28 | dirs += $$dir 29 | } 30 | return($$dirs) 31 | } 32 | 33 | TEMPLATE = lib 34 | 35 | greaterThan(QT_MAJOR_VERSION, 4):QT += widgets 36 | 37 | CONFIG += qt dll 38 | 39 | INCLUDEPATH += $${SDK}/include 40 | 41 | DESTDIR = bin 42 | 43 | DEFINES += __IDP__ __QT__ __X64__ 44 | win32:DEFINES += __NT__ WIN32 45 | win32:DEFINES -= UNICODE 46 | win32:DEFINES += _CRT_SECURE_NO_WARNINGS 47 | win32:QMAKE_TARGET.arch = x86_64 48 | linux-g++:DEFINES += __LINUX__ 49 | macx:DEFINES += __MAC__ 50 | 51 | win32:LIBS += comdlg32.lib gdi32.lib user32.lib advapi32.lib ida.lib ws2_32.lib 52 | win32-msvc2013: { 53 | exists( $${SDK}/lib/vc.w64/ida.lib ) { 54 | LIBS += -L$${SDK}/lib/vc.w64 55 | } else { 56 | LIBS += -L$${SDK}/lib/x64_win_vc_32 57 | LIBS += -L$${SDK}/lib/x64_win_qt 58 | } 59 | QMAKE_LFLAGS_RPATH = 60 | QMAKE_LIBDIR_QT = 61 | } 62 | linux-g++:LIBS += -L$${IDA_APP} -lida 63 | macx:LIBS += -L$${IDA_APP}/MacOs -lida 64 | 65 | #don't let qmake force search any libs other than the 66 | #ones that ship with Ida 67 | linux-g++:QMAKE_LFLAGS_RPATH = 68 | linux-g++:QMAKE_LIBDIR_QT = 69 | 70 | macx:QMAKE_INCDIR = $$makeIncludes(MODS) 71 | #add QTs actual include file location this way since -F is not 72 | #handled by QMAKE_INCDIR 73 | macx:QMAKE_CXXFLAGS += -m64 -F$${QT_LOC} -stdlib=libc++ 74 | 75 | linux-g++:QMAKE_CXXFLAGS = -m64 76 | 77 | SDKVER = $$(IDAVER) 78 | linux-g++|macx: { 79 | QMAKE_CXXFLAGS += -m64 80 | QMAKE_CFLAGS += -m64 81 | QMAKE_LFLAGS += -m64 82 | greaterThan(SDKVER, 720):QMAKE_CXXFLAGS += -std=c++11 83 | } 84 | 85 | macx:QMAKE_LFLAGS += -F$${IDA_APP}/Frameworks 86 | macx:QMAKE_LIBDIR_QT = 87 | macx:QMAKE_MACOSX_DEPLOYMENT_TARGET = 10.9 88 | 89 | SOURCES = x86emu.cpp \ 90 | x86emu_ui_qt.cpp \ 91 | emufuncs.cpp \ 92 | cpu.cpp \ 93 | emuheap.cpp \ 94 | memmgr.cpp \ 95 | seh.cpp \ 96 | break.cpp \ 97 | hooklist.cpp \ 98 | buffer.cpp \ 99 | emuthreads.cpp \ 100 | peutils.cpp \ 101 | emu_script.cpp \ 102 | context.cpp \ 103 | aes.cpp \ 104 | ansi_cprng.cpp 105 | 106 | HEADERS = aes.h \ 107 | ansi_cprng.h \ 108 | break.h \ 109 | bsd_syscalls.h \ 110 | buffer.h \ 111 | cgc_syscalls.h \ 112 | context.h \ 113 | cpu.h \ 114 | elf32.h \ 115 | elf_common.h \ 116 | emu_script.h \ 117 | emufuncs.h \ 118 | emuheap.h \ 119 | emuthreads.h \ 120 | hooklist.h \ 121 | image.h \ 122 | linux_syscalls.h \ 123 | memmgr.h \ 124 | peutils.h \ 125 | sdk_versions.h \ 126 | seh.h \ 127 | x86emu_ui_qt.h \ 128 | x86defs.h 129 | 130 | win32:TARGET_EXT=.dll 131 | linux-g++:TARGET_EXT=.so 132 | macx:TARGET_EXT=.dylib 133 | 134 | TARGET = x86emu_qt 135 | -------------------------------------------------------------------------------- /x86emu64-7.pro: -------------------------------------------------------------------------------- 1 | 2 | #your Ida SDK location either relative to x86emu 3 | #or absolute 4 | SDK = ../.. 5 | 6 | OBJECTS_DIR = p64-7 7 | 8 | #Need to change the following to your Ida install location 9 | linux-g++:IDA_APP = /opt/ida-$$(IDA_VERSION) 10 | macx:IDA_APP = "/Applications/IDA\ Pro\ $$(IDA_VERSION)/ida64.app/Contents" 11 | 12 | #Need to change the following to your Qt install location 13 | macx: { 14 | greaterThan(QT_MAJOR_VERSION, 4):QT_LOC = /Users/qt-5.4.1/5.4/clang_64/lib 15 | lessThan(QT_MAJOR_VERSION, 5):QT_LOC = /usr/local/qt/lib 16 | QT_TAIL = .framework/Versions/$$QT_MAJOR_VERSION/Headers 17 | #create our own list of Qt modules 18 | MODS = QtGui QtCore 19 | greaterThan(QT_MAJOR_VERSION, 4):MODS += QtWidgets 20 | } 21 | 22 | defineReplace(makeIncludes) { 23 | variable = $$1 24 | modules = $$eval($$variable) 25 | dirs = 26 | for(module, modules) { 27 | dir = $${QT_LOC}/$${module}$${QT_TAIL} 28 | dirs += $$dir 29 | } 30 | return($$dirs) 31 | } 32 | 33 | TEMPLATE = lib 34 | 35 | greaterThan(QT_MAJOR_VERSION, 4):QT += widgets 36 | 37 | CONFIG += qt dll 38 | 39 | INCLUDEPATH += $${SDK}/include 40 | 41 | DESTDIR = bin 42 | 43 | DEFINES += __IDP__ __QT__ __EA64__ __X64__ 44 | win32:DEFINES += __NT__ WIN32 45 | win32:DEFINES -= UNICODE 46 | win32:DEFINES += _CRT_SECURE_NO_WARNINGS 47 | win32:QMAKE_TARGET.arch = x86_64 48 | linux-g++:DEFINES += __LINUX__ 49 | macx:DEFINES += __MAC__ 50 | 51 | win32:LIBS += comdlg32.lib gdi32.lib user32.lib advapi32.lib ida.lib ws2_32.lib 52 | win32-msvc2013: { 53 | exists( $${SDK}/lib/vc.w64/ida.lib ) { 54 | LIBS += -L$${SDK}/lib/vc.w64 55 | } else { 56 | LIBS += -L$${SDK}/lib/x64_win_vc_64 57 | LIBS += -L$${SDK}/lib/x64_win_qt 58 | } 59 | QMAKE_LFLAGS_RPATH = 60 | QMAKE_LIBDIR_QT = 61 | } 62 | linux-g++:LIBS += -L$${IDA_APP} -lida64 63 | macx:LIBS += -L$${IDA_APP}/MacOs -lida64 64 | 65 | #don't let qmake force search any libs other than the 66 | #ones that ship with Ida 67 | linux-g++:QMAKE_LFLAGS_RPATH = 68 | linux-g++:QMAKE_LIBDIR_QT = 69 | 70 | macx:QMAKE_INCDIR = $$makeIncludes(MODS) 71 | #add QTs actual include file location this way since -F is not 72 | #handled by QMAKE_INCDIR 73 | macx:QMAKE_CXXFLAGS += -m64 -F$${QT_LOC} -stdlib=libc++ 74 | 75 | linux-g++:QMAKE_CXXFLAGS = -m64 76 | 77 | SDKVER = $$(IDAVER) 78 | linux-g++|macx: { 79 | QMAKE_CXXFLAGS += -m64 80 | QMAKE_CFLAGS += -m64 81 | QMAKE_LFLAGS += -m64 82 | greaterThan(SDKVER, 720):QMAKE_CXXFLAGS += -std=c++11 83 | } 84 | 85 | macx:QMAKE_LFLAGS += -F$${IDA_APP}/Frameworks 86 | macx:QMAKE_LIBDIR_QT = 87 | macx:QMAKE_MACOSX_DEPLOYMENT_TARGET = 10.9 88 | 89 | SOURCES = x86emu.cpp \ 90 | x86emu_ui_qt.cpp \ 91 | emufuncs.cpp \ 92 | cpu.cpp \ 93 | emuheap.cpp \ 94 | memmgr.cpp \ 95 | seh.cpp \ 96 | break.cpp \ 97 | hooklist.cpp \ 98 | buffer.cpp \ 99 | emuthreads.cpp \ 100 | peutils.cpp \ 101 | emu_script.cpp \ 102 | context.cpp \ 103 | aes.cpp \ 104 | ansi_cprng.cpp 105 | 106 | HEADERS = aes.h \ 107 | ansi_cprng.h \ 108 | break.h \ 109 | bsd_syscalls.h \ 110 | buffer.h \ 111 | cgc_syscalls.h \ 112 | context.h \ 113 | cpu.h \ 114 | elf32.h \ 115 | elf_common.h \ 116 | emu_script.h \ 117 | emufuncs.h \ 118 | emuheap.h \ 119 | emuthreads.h \ 120 | hooklist.h \ 121 | image.h \ 122 | linux_syscalls.h \ 123 | memmgr.h \ 124 | peutils.h \ 125 | sdk_versions.h \ 126 | seh.h \ 127 | x86emu_ui_qt.h \ 128 | x86defs.h 129 | 130 | win32:TARGET_EXT=.dll 131 | linux-g++:TARGET_EXT=.so 132 | macx:TARGET_EXT=.dylib 133 | 134 | TARGET = x86emu_qt64 135 | -------------------------------------------------------------------------------- /x86emu64.pro: -------------------------------------------------------------------------------- 1 | 2 | #your Ida SDK location either relative to x86emu 3 | #or absolute 4 | SDK = ../.. 5 | 6 | OBJECTS_DIR = p64 7 | 8 | #Need to change the following to your Ida install location 9 | win32:IDA_APP = "C:/Program Files (x86)/Ida" 10 | linux-g++:IDA_APP = /opt/ida-$$(IDA_VERSION) 11 | macx:IDA_APP = "/Applications/IDA\ Pro\ $$(IDA_VERSION)/idaq.app/Contents" 12 | 13 | #Need to change the following to your Qt install location 14 | macx: { 15 | greaterThan(QT_MAJOR_VERSION, 4):QT_LOC = /Users/qt-5.4.1/5.4/clang_64/lib 16 | lessThan(QT_MAJOR_VERSION, 5):QT_LOC = /usr/local/qt/lib 17 | QT_TAIL = .framework/Versions/$$QT_MAJOR_VERSION/Headers 18 | #create our own list of Qt modules 19 | MODS = QtGui QtCore 20 | greaterThan(QT_MAJOR_VERSION, 4):MODS += QtWidgets 21 | } 22 | 23 | defineReplace(makeIncludes) { 24 | variable = $$1 25 | modules = $$eval($$variable) 26 | dirs = 27 | for(module, modules) { 28 | dir = $${QT_LOC}/$${module}$${QT_TAIL} 29 | dirs += $$dir 30 | } 31 | return($$dirs) 32 | } 33 | 34 | TEMPLATE = lib 35 | 36 | greaterThan(QT_MAJOR_VERSION, 4):QT += widgets 37 | 38 | CONFIG += qt dll 39 | 40 | INCLUDEPATH += $${SDK}/include 41 | 42 | DESTDIR = bin 43 | 44 | DEFINES += __IDP__ __QT__ __EA64__ 45 | win32:DEFINES += __NT__ WIN32 46 | win32:DEFINES -= UNICODE 47 | win32:DEFINES += _CRT_SECURE_NO_WARNINGS 48 | linux-g++:DEFINES += __LINUX__ 49 | macx:DEFINES += __MAC__ 50 | 51 | win32:LIBS += comdlg32.lib gdi32.lib user32.lib advapi32.lib ida.lib ws2_32.lib 52 | win32-msvc2010: { 53 | exists( $${SDK}/lib/vc.w64/ida.lib ) { 54 | LIBS += -L$${SDK}/lib/vc.w64 55 | } else { 56 | LIBS += -L$${SDK}/lib/x86_win_vc_64 57 | } 58 | } 59 | linux-g++:LIBS += -L$${IDA_APP} -lida64 60 | macx:LIBS += -L$${IDA_APP}/MacOs -lida64 61 | 62 | #don't let qmake force search any libs other than the 63 | #ones that ship with Ida 64 | linux-g++:QMAKE_LFLAGS_RPATH = 65 | linux-g++:QMAKE_LIBDIR_QT = 66 | 67 | macx:QMAKE_INCDIR = $$makeIncludes(MODS) 68 | #add QTs actual include file location this way since -F is not 69 | #handled by QMAKE_INCDIR 70 | macx:QMAKE_CXXFLAGS += -m32 -F$${QT_LOC} 71 | 72 | linux-g++:QMAKE_CXXFLAGS = -m32 73 | 74 | linux-g++|macx: { 75 | QMAKE_CXXFLAGS += -m32 76 | QMAKE_CFLAGS += -m32 77 | QMAKE_LFLAGS += -m32 78 | } 79 | 80 | macx:QMAKE_LFLAGS += -F$${IDA_APP}/Frameworks 81 | macx:QMAKE_LIBDIR_QT = 82 | 83 | SOURCES = x86emu.cpp \ 84 | x86emu_ui_qt.cpp \ 85 | emufuncs.cpp \ 86 | cpu.cpp \ 87 | emuheap.cpp \ 88 | memmgr.cpp \ 89 | seh.cpp \ 90 | break.cpp \ 91 | hooklist.cpp \ 92 | buffer.cpp \ 93 | emuthreads.cpp \ 94 | peutils.cpp \ 95 | emu_script.cpp \ 96 | context.cpp \ 97 | aes.cpp \ 98 | ansi_cprng.cpp 99 | 100 | HEADERS = aes.h \ 101 | ansi_cprng.h \ 102 | break.h \ 103 | bsd_syscalls.h \ 104 | buffer.h \ 105 | cgc_syscalls.h \ 106 | context.h \ 107 | cpu.h \ 108 | elf32.h \ 109 | elf_common.h \ 110 | emu_script.h \ 111 | emufuncs.h \ 112 | emuheap.h \ 113 | emuthreads.h \ 114 | hooklist.h \ 115 | image.h \ 116 | linux_syscalls.h \ 117 | memmgr.h \ 118 | peutils.h \ 119 | sdk_versions.h \ 120 | seh.h \ 121 | x86emu_ui_qt.h \ 122 | x86defs.h 123 | 124 | win32:TARGET_EXT=.p64 125 | linux-g++:TARGET_EXT=.plx64 126 | macx:TARGET_EXT=.pmc64 127 | 128 | TARGET = x86emu_qt 129 | -------------------------------------------------------------------------------- /x86emu_ui.h: -------------------------------------------------------------------------------- 1 | /* 2 | Source for x86 emulator IdaPro plugin 3 | Copyright (c) 2010 Chris Eagle 4 | 5 | This program is free software; you can redistribute it and/or modify it 6 | under the terms of the GNU General Public License as published by the Free 7 | Software Foundation; either version 2 of the License, or (at your option) 8 | any later version. 9 | 10 | This program is distributed in the hope that it will be useful, but WITHOUT 11 | ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 12 | FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for 13 | more details. 14 | 15 | You should have received a copy of the GNU General Public License along with 16 | this program; if not, write to the Free Software Foundation, Inc., 59 Temple 17 | Place, Suite 330, Boston, MA 02111-1307 USA 18 | */ 19 | 20 | #ifndef __X86EMU_UI_H 21 | #define __X86EMU_UI_H 22 | 23 | void setEmulatorTitle(const char *title); 24 | void updateRegisterDisplay(int r); 25 | void handleUnemulatedFunction(unsigned int addr, const char *name); 26 | bool createEmulatorWindow(); 27 | void destroyEmulatorWindow(); 28 | void displayEmulatorWindow(); 29 | char *inputBox(const char *boxTitle, const char *msg, const char *init); 30 | char *getOpenFileName(const char *title, char *fileName, int nameLen, const char *filter, char *initDir = 0); 31 | char *getSaveFileName(const char *title, char *fileName, int nameSize, const char *filter); 32 | char *getDirectoryName(const char *title, char *dirName, int nameSize); 33 | void showErrorMessage(const char *msg); 34 | void showInformationMessage(const char *title, const char *msg); 35 | bool getMmapBlockData(unsigned int *base, unsigned int *size); 36 | void showWaitCursor(); 37 | void restoreCursor(); 38 | 39 | void cacheMainWindowHandle(); 40 | 41 | #endif 42 | 43 | -------------------------------------------------------------------------------- /x86emu_ui_qt.h: -------------------------------------------------------------------------------- 1 | /* 2 | Source for x86 emulator IdaPro plugin 3 | Copyright (c) 2010 Chris Eagle 4 | 5 | This program is free software; you can redistribute it and/or modify it 6 | under the terms of the GNU General Public License as published by the Free 7 | Software Foundation; either version 2 of the License, or (at your option) 8 | any later version. 9 | 10 | This program is distributed in the hope that it will be useful, but WITHOUT 11 | ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 12 | FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for 13 | more details. 14 | 15 | You should have received a copy of the GNU General Public License along with 16 | this program; if not, write to the Free Software Foundation, Inc., 59 Temple 17 | Place, Suite 330, Boston, MA 02111-1307 USA 18 | */ 19 | 20 | #ifndef __X86EMU_QT_H__ 21 | #define __X86EMU_QT_H__ 22 | 23 | #ifdef __QT__ 24 | #ifndef QT_NAMESPACE 25 | #define QT_NAMESPACE QT 26 | #endif 27 | #endif 28 | 29 | #include 30 | #include 31 | #include 32 | #include 33 | #include 34 | #include 35 | #include 36 | #include 37 | #include 38 | #include 39 | #include 40 | 41 | #include "x86defs.h" 42 | #include "x86emu_ui.h" 43 | 44 | using namespace QT; 45 | 46 | class AllIntValidator : public QValidator { 47 | Q_OBJECT 48 | public: 49 | AllIntValidator(QObject *parent = 0) : QValidator(parent) {} 50 | State validate(QString &input, int &pos) const; 51 | }; 52 | 53 | class X86Dialog : public QMainWindow { 54 | Q_OBJECT 55 | public: 56 | X86Dialog(QWidget *parent = 0); 57 | public slots: 58 | void changeEax(); 59 | void changeEbx(); 60 | void changeEcx(); 61 | void changeEdx(); 62 | void changeEbp(); 63 | void changeEsp(); 64 | void changeEdi(); 65 | void changeEsi(); 66 | void changeEip(); 67 | void changeEflags(); 68 | void settings(); 69 | void dumpRange(); 70 | void dumpEmbededPE(); 71 | void grabStackBlock(); 72 | void grabHeapBlock(); 73 | void grabMmapBlock(); 74 | void buildMainArgs(); 75 | void buildWinMainArgs(); 76 | void buildDllMainArgs(); 77 | void reset(); 78 | void trackExec(); 79 | void traceExec(); 80 | void logLibraryCalls(); 81 | void breakOnExceptions(); 82 | void breakOnSyscall(); 83 | void logSystemCalls(); 84 | void setImportAddressSavePoint(); 85 | void setBreak(); 86 | void clearBreak(); 87 | void memoryException(); 88 | void exportLookup(); 89 | void switchThreads(); 90 | void hideEmu(); 91 | void heapList(); 92 | void step(); 93 | void skip(); 94 | void run(); 95 | void doBreak(); 96 | void runCursor(); 97 | void jumpCursor(); 98 | void pushData(); 99 | void setMemory(); 100 | void segments(); 101 | void loadLibrary(); 102 | 103 | public: 104 | QLineEdit *QEAX; 105 | QLineEdit *QEBX; 106 | QLineEdit *QECX; 107 | QLineEdit *QEDX; 108 | QLineEdit *QEFLAGS; 109 | QLineEdit *QEBP; 110 | QLineEdit *QESP; 111 | QLineEdit *QESI; 112 | QLineEdit *QEDI; 113 | QLineEdit *QEIP; 114 | private: 115 | QAction *emulateTrack_fetched_bytesAction; 116 | QAction *emulateTrace_executionAction; 117 | QAction *emulateLogLibraryAction; 118 | QAction *emulateBreakOnExceptionsAction; 119 | QAction *emulateBreakSyscallAction; 120 | QAction *emulateLogSyscallsAction; 121 | QPushButton *BREAK; 122 | }; 123 | 124 | class SegmentsDialog : public QDialog { 125 | Q_OBJECT 126 | public: 127 | SegmentsDialog(QWidget *parent = 0); 128 | 129 | public: 130 | QLineEdit *qcs_reg; 131 | QLineEdit *qgs_reg; 132 | QLineEdit *qss_reg; 133 | QLineEdit *qds_reg; 134 | QLineEdit *qes_reg; 135 | QLineEdit *qfs_reg; 136 | QLineEdit *qds_base; 137 | QLineEdit *qcs_base; 138 | QLineEdit *qgs_base; 139 | QLineEdit *qfs_base; 140 | QLineEdit *qss_base; 141 | QLineEdit *qes_base; 142 | 143 | private slots: 144 | void do_ok(); 145 | }; 146 | 147 | class MemConfigDialog : public QDialog { 148 | Q_OBJECT 149 | public: 150 | MemConfigDialog(QWidget *parent = 0); 151 | QLineEdit *heap_base; 152 | QLineEdit *heap_size; 153 | QLineEdit *stack_top; 154 | QLineEdit *stack_size; 155 | private slots: 156 | void do_ok(); 157 | }; 158 | 159 | class UnemulatedDialog : public QDialog { 160 | Q_OBJECT 161 | public: 162 | UnemulatedDialog(QWidget *parent, const char *name, unsigned int addr); 163 | const char *fname; 164 | char *functionCall; 165 | 166 | public: 167 | QRadioButton *is_cdecl; 168 | QRadioButton *is_stdcall; 169 | QPushButton *ue_okay; 170 | QSpinBox *ue_args; 171 | QLineEdit *ue_return; 172 | QListWidget *parm_list; 173 | 174 | private slots: 175 | void do_ok(); 176 | }; 177 | 178 | class ThreadsDialog : public QDialog { 179 | Q_OBJECT 180 | public: 181 | QListWidget *thread_list; 182 | 183 | ThreadsDialog(QWidget *parent = 0); 184 | 185 | private slots: 186 | void switchThread(); 187 | void destroy(); 188 | }; 189 | 190 | class MmapDialog : public QDialog { 191 | Q_OBJECT 192 | public: 193 | MmapDialog(QWidget *parent = 0); 194 | 195 | QLineEdit *mmap_base; 196 | QLineEdit *mmap_size; 197 | 198 | private slots: 199 | void do_ok(); 200 | }; 201 | 202 | class SetMemoryDialog : public QDialog { 203 | Q_OBJECT 204 | public: 205 | SetMemoryDialog(QWidget *parent = 0); 206 | QRadioButton *type_dword; 207 | QRadioButton *type_word; 208 | QRadioButton *type_byte; 209 | QRadioButton *type_ascii; 210 | QRadioButton *type_asciiz; 211 | QRadioButton *type_file; 212 | QLineEdit *mem_start; 213 | QLineEdit *mem_values; 214 | 215 | private slots: 216 | void do_ok(); 217 | }; 218 | 219 | #endif 220 | --------------------------------------------------------------------------------