├── .gitignore ├── .travis.yml ├── CMakeLists.txt ├── LICENSE ├── README.md ├── build_for_windows └── helpers │ └── MakeDef.py ├── capstone-3.0.3 ├── capstone-3.0.3.tgz └── setup_capstone.sh ├── debian └── control ├── docs ├── Manual.docx ├── Manual.pdf ├── ROP_In_MSF.docx ├── ROP_In_MSF.pdf └── gadgets.txt ├── gtest-1.6.0 ├── CHANGES ├── CMakeLists.txt ├── CONTRIBUTORS ├── COPYING ├── Makefile.am ├── Makefile.in ├── README ├── aclocal.m4 ├── build-aux │ ├── config.guess │ ├── config.h.in │ ├── config.sub │ ├── depcomp │ ├── install-sh │ ├── ltmain.sh │ └── missing ├── cmake │ └── internal_utils.cmake ├── codegear │ ├── gtest.cbproj │ ├── gtest.groupproj │ ├── gtest_all.cc │ ├── gtest_link.cc │ ├── gtest_main.cbproj │ └── gtest_unittest.cbproj ├── configure ├── configure.ac ├── fused-src │ └── gtest │ │ ├── gtest-all.cc │ │ ├── gtest.h │ │ └── gtest_main.cc ├── include │ └── gtest │ │ ├── gtest-death-test.h │ │ ├── gtest-message.h │ │ ├── gtest-param-test.h │ │ ├── gtest-param-test.h.pump │ │ ├── gtest-printers.h │ │ ├── gtest-spi.h │ │ ├── gtest-test-part.h │ │ ├── gtest-typed-test.h │ │ ├── gtest.h │ │ ├── gtest_pred_impl.h │ │ ├── gtest_prod.h │ │ └── internal │ │ ├── gtest-death-test-internal.h │ │ ├── gtest-filepath.h │ │ ├── gtest-internal.h │ │ ├── gtest-linked_ptr.h │ │ ├── gtest-param-util-generated.h │ │ ├── gtest-param-util-generated.h.pump │ │ ├── gtest-param-util.h │ │ ├── gtest-port.h │ │ ├── gtest-string.h │ │ ├── gtest-tuple.h │ │ ├── gtest-tuple.h.pump │ │ ├── gtest-type-util.h │ │ └── gtest-type-util.h.pump ├── m4 │ ├── acx_pthread.m4 │ ├── gtest.m4 │ ├── libtool.m4 │ ├── ltoptions.m4 │ ├── ltsugar.m4 │ ├── ltversion.m4 │ └── lt~obsolete.m4 ├── make │ └── Makefile ├── msvc │ ├── gtest-md.sln │ ├── gtest-md.vcproj │ ├── gtest.sln │ ├── gtest.vcproj │ ├── gtest_main-md.vcproj │ ├── gtest_main.vcproj │ ├── gtest_prod_test-md.vcproj │ ├── gtest_prod_test.vcproj │ ├── gtest_unittest-md.vcproj │ └── gtest_unittest.vcproj ├── samples │ ├── prime_tables.h │ ├── sample1.cc │ ├── sample1.h │ ├── sample10_unittest.cc │ ├── sample1_unittest.cc │ ├── sample2.cc │ ├── sample2.h │ ├── sample2_unittest.cc │ ├── sample3-inl.h │ ├── sample3_unittest.cc │ ├── sample4.cc │ ├── sample4.h │ ├── sample4_unittest.cc │ ├── sample5_unittest.cc │ ├── sample6_unittest.cc │ ├── sample7_unittest.cc │ ├── sample8_unittest.cc │ └── sample9_unittest.cc ├── scripts │ ├── fuse_gtest_files.py │ ├── gen_gtest_pred_impl.py │ ├── gtest-config.in │ ├── pump.py │ └── test │ │ └── Makefile ├── src │ ├── gtest-all.cc │ ├── gtest-death-test.cc │ ├── gtest-filepath.cc │ ├── gtest-internal-inl.h │ ├── gtest-port.cc │ ├── gtest-printers.cc │ ├── gtest-test-part.cc │ ├── gtest-typed-test.cc │ ├── gtest.cc │ └── gtest_main.cc ├── test │ ├── gtest-death-test_ex_test.cc │ ├── gtest-death-test_test.cc │ ├── gtest-filepath_test.cc │ ├── gtest-linked_ptr_test.cc │ ├── gtest-listener_test.cc │ ├── gtest-message_test.cc │ ├── gtest-options_test.cc │ ├── gtest-param-test2_test.cc │ ├── gtest-param-test_test.cc │ ├── gtest-param-test_test.h │ ├── gtest-port_test.cc │ ├── gtest-printers_test.cc │ ├── gtest-test-part_test.cc │ ├── gtest-tuple_test.cc │ ├── gtest-typed-test2_test.cc │ ├── gtest-typed-test_test.cc │ ├── gtest-typed-test_test.h │ ├── gtest-unittest-api_test.cc │ ├── gtest_all_test.cc │ ├── gtest_break_on_failure_unittest.py │ ├── gtest_break_on_failure_unittest_.cc │ ├── gtest_catch_exceptions_test.py │ ├── gtest_catch_exceptions_test_.cc │ ├── gtest_color_test.py │ ├── gtest_color_test_.cc │ ├── gtest_env_var_test.py │ ├── gtest_env_var_test_.cc │ ├── gtest_environment_test.cc │ ├── gtest_filter_unittest.py │ ├── gtest_filter_unittest_.cc │ ├── gtest_help_test.py │ ├── gtest_help_test_.cc │ ├── gtest_list_tests_unittest.py │ ├── gtest_list_tests_unittest_.cc │ ├── gtest_main_unittest.cc │ ├── gtest_no_test_unittest.cc │ ├── gtest_output_test.py │ ├── gtest_output_test_.cc │ ├── gtest_output_test_golden_lin.txt │ ├── gtest_pred_impl_unittest.cc │ ├── gtest_prod_test.cc │ ├── gtest_repeat_test.cc │ ├── gtest_shuffle_test.py │ ├── gtest_shuffle_test_.cc │ ├── gtest_sole_header_test.cc │ ├── gtest_stress_test.cc │ ├── gtest_test_utils.py │ ├── gtest_throw_on_failure_ex_test.cc │ ├── gtest_throw_on_failure_test.py │ ├── gtest_throw_on_failure_test_.cc │ ├── gtest_uninitialized_test.py │ ├── gtest_uninitialized_test_.cc │ ├── gtest_unittest.cc │ ├── gtest_xml_outfile1_test_.cc │ ├── gtest_xml_outfile2_test_.cc │ ├── gtest_xml_outfiles_test.py │ ├── gtest_xml_output_unittest.py │ ├── gtest_xml_output_unittest_.cc │ ├── gtest_xml_test_utils.py │ ├── production.cc │ └── production.h └── xcode │ ├── Config │ ├── DebugProject.xcconfig │ ├── FrameworkTarget.xcconfig │ ├── General.xcconfig │ ├── ReleaseProject.xcconfig │ ├── StaticLibraryTarget.xcconfig │ └── TestTarget.xcconfig │ ├── Resources │ └── Info.plist │ ├── Samples │ └── FrameworkSample │ │ ├── Info.plist │ │ ├── WidgetFramework.xcodeproj │ │ └── project.pbxproj │ │ ├── runtests.sh │ │ ├── widget.cc │ │ ├── widget.h │ │ └── widget_test.cc │ ├── Scripts │ ├── runtests.sh │ └── versiongenerate.py │ └── gtest.xcodeproj │ └── project.pbxproj ├── install_deps.sh ├── install_vex.sh ├── libs ├── CMakeLists.txt ├── ExprParser │ ├── CMakeLists.txt │ ├── ExprAST.h │ ├── ExprParser.cpp │ └── ExprParser.h ├── IR │ ├── BasicIR.cpp │ ├── BasicIR.h │ ├── CMakeLists.txt │ ├── Helpers.cpp │ ├── Helpers.h │ ├── IR.proto │ ├── IRMatcher.cpp │ ├── IRMatcher.h │ ├── Input.cpp │ ├── Input.h │ ├── Output.cpp │ ├── Output.h │ ├── Serial.cpp │ ├── Serial.h │ ├── VexIR.cpp │ ├── VexIR.h │ ├── decodeLib.h │ ├── decodeToIR.cpp │ ├── decodeToIR.h │ ├── dumpIRToProto.cpp │ ├── printIR.cpp │ └── printOp.cpp ├── MachOLib │ ├── CMakeLists.txt │ ├── DataFile.cpp │ ├── DataFile.h │ ├── dyld_decache.cpp │ ├── dyld_decache.h │ ├── env_flags.h │ ├── fat.h │ ├── loader.h │ ├── log.cc │ ├── log.h │ ├── mach-o.cc │ ├── mach-o.h │ ├── machine.h │ ├── read_fat.cc │ ├── read_fat.h │ └── vm_prot.h ├── RopLib │ ├── CMakeLists.txt │ ├── RopLib.cpp │ ├── RopLib.h │ └── RopLib_internal.h ├── VEE │ ├── CMakeLists.txt │ ├── Conditions.cpp │ ├── Conditions.h │ ├── VEE.cpp │ ├── VEE.h │ ├── VEECC.cpp │ ├── VEEHelpers.cpp │ ├── VEEHelpers.h │ ├── VEEOps.cpp │ ├── VEEOps.h │ ├── VEEState.cpp │ ├── VEElua.cpp │ └── VEElua.h ├── elfio │ ├── elf_types.hpp │ ├── elfio.hpp │ ├── elfio_dump.hpp │ ├── elfio_dynamic.hpp │ ├── elfio_header.hpp │ ├── elfio_note.hpp │ ├── elfio_relocation.hpp │ ├── elfio_section.hpp │ ├── elfio_segment.hpp │ ├── elfio_strings.hpp │ ├── elfio_symbols.hpp │ └── elfio_utils.hpp ├── getExecSections │ ├── CMakeLists.txt │ ├── getExec.cpp │ └── getExec.h └── pe-parse │ ├── CMakeFiles │ ├── 3.2.2 │ │ ├── CMakeCCompiler.cmake │ │ ├── CMakeCXXCompiler.cmake │ │ ├── CMakeDetermineCompilerABI_C.bin │ │ ├── CMakeDetermineCompilerABI_CXX.bin │ │ ├── CMakeSystem.cmake │ │ ├── CompilerIdC │ │ │ └── CMakeCCompilerId.c │ │ └── CompilerIdCXX │ │ │ └── CMakeCXXCompilerId.cpp │ ├── cmake.check_cache │ ├── feature_tests.bin │ ├── feature_tests.c │ ├── feature_tests.cxx │ └── progress.marks │ ├── CMakeLists.txt │ ├── LICENSE.txt │ └── parser-library │ ├── CMakeFiles │ ├── pe-parser-library.dir │ │ └── progress.make │ └── progress.marks │ ├── CMakeLists.txt │ ├── buffer.cpp │ ├── nt-headers.h │ ├── parse.cpp │ ├── parse.h │ └── to_string.h ├── lua-5.3.0 ├── CMakeLists.txt ├── Makefile ├── README ├── doc │ ├── contents.html │ ├── logo.gif │ ├── lua.1 │ ├── lua.css │ ├── luac.1 │ ├── manual.css │ ├── manual.html │ ├── osi-certified-72x60.png │ └── readme.html └── src │ ├── CMakeLists.txt │ ├── Makefile │ ├── lapi.c │ ├── lapi.h │ ├── lauxlib.c │ ├── lauxlib.h │ ├── lbaselib.c │ ├── lbitlib.c │ ├── lcode.c │ ├── lcode.h │ ├── lcorolib.c │ ├── lctype.c │ ├── lctype.h │ ├── ldblib.c │ ├── ldebug.c │ ├── ldebug.h │ ├── ldo.c │ ├── ldo.h │ ├── ldump.c │ ├── lfunc.c │ ├── lfunc.h │ ├── lgc.c │ ├── lgc.h │ ├── linit.c │ ├── liolib.c │ ├── llex.c │ ├── llex.h │ ├── llimits.h │ ├── lmathlib.c │ ├── lmem.c │ ├── lmem.h │ ├── loadlib.c │ ├── lobject.c │ ├── lobject.h │ ├── lopcodes.c │ ├── lopcodes.h │ ├── loslib.c │ ├── lparser.c │ ├── lparser.h │ ├── lprefix.h │ ├── lstate.c │ ├── lstate.h │ ├── lstring.c │ ├── lstring.h │ ├── lstrlib.c │ ├── ltable.c │ ├── ltable.h │ ├── ltablib.c │ ├── ltm.c │ ├── ltm.h │ ├── lua.c │ ├── lua.h │ ├── lua.hpp │ ├── luac.c │ ├── luaconf.h │ ├── lualib.h │ ├── lundump.c │ ├── lundump.h │ ├── lutf8lib.c │ ├── lvm.c │ ├── lvm.h │ ├── lzio.c │ └── lzio.h ├── make.sh ├── package.sh ├── recompile.sh ├── scripts ├── arm │ └── call_reg.lua ├── lang │ ├── from_msf │ │ ├── adobe_mp4 │ │ │ └── deref_pop_ret │ │ ├── general_rwrite │ │ ├── general_vwrite │ │ ├── ibm_tivoli │ │ │ └── pop_many_ret │ │ ├── java_docbase_bof │ │ │ ├── add_eax_ret │ │ │ ├── deref_eax │ │ │ └── deref_eax4 │ │ ├── ms10_002_ie_object │ │ │ ├── jmp_eax │ │ │ ├── pop_eax_ret │ │ │ ├── pop_ebp_ret │ │ │ ├── pop_edi_ret │ │ │ └── pushad_ret │ │ └── vlc_amv │ │ │ └── add_xor_inc_ret │ ├── mem_equiv │ ├── mem_equiv_eps │ ├── pvtfinder │ ├── reg_equiv │ ├── reg_equiv_eps │ ├── wild_binary_ops │ └── wild_reg_assign ├── valu │ ├── add.lua │ ├── and.lua │ ├── div.lua │ ├── mul.lua │ ├── or.lua │ ├── shl.lua │ ├── shr.lua │ ├── sub.lua │ └── xor.lua ├── x64 │ └── call_reg.lua └── x86 │ ├── call_reg.lua │ ├── pop_ecx.lua │ ├── pvtdown.lua │ ├── pvtfinder.lua │ ├── pvtfinder2.lua │ ├── transfer_arith_with_branch.lua │ ├── vcall.lua │ └── vcall2.lua ├── tests ├── ELF │ ├── ls_ARM │ ├── ls_x64 │ └── ls_x86 ├── MachO │ └── ls_FAT_x86_x64 ├── Makefile ├── bigOne.asm ├── bigOne.bin ├── testAdd.asm ├── testAdd.bin ├── testAdd.lua ├── testAdd64.asm ├── testAnd.asm ├── testAnd.bin ├── testArm.bin ├── testConds.lua ├── testDiv.asm ├── testDiv.bin ├── testJ1.asm ├── testJ1.bin ├── testLAdd.asm ├── testLAdd.bin ├── testMem.asm ├── testMul.asm ├── testMul.bin ├── testMul8.asm ├── testMul8.bin ├── testOr.asm ├── testOr.bin ├── testSkyWipe.asm ├── testSub.asm ├── testSub.bin ├── testWat.asm ├── testWat.bin └── testXor.asm └── tools ├── BlockExtract ├── BlockExtract.cpp └── CMakeLists.txt ├── BlockReader ├── BlockReader.cpp └── CMakeLists.txt ├── CMakeLists.txt ├── ImgTool ├── CMakeLists.txt └── ImgTool.cpp ├── RopScore ├── CMakeLists.txt └── RopScore.cpp ├── RopTool ├── CMakeLists.txt └── RopTool.cpp ├── TestLua ├── CMakeLists.txt ├── TestLua.cpp └── test.lua ├── TestParse ├── CMakeLists.txt └── TestParse.cpp ├── VEEShell ├── CMakeLists.txt └── shell.cpp └── VEXBlobEater ├── CMakeLists.txt ├── blobEater.cpp ├── blobeater.h ├── getopt.c └── getopt.h /.gitignore: -------------------------------------------------------------------------------- 1 | # Compiled Object files 2 | *.slo 3 | *.lo 4 | *.o 5 | *.obj 6 | 7 | # Precompiled Headers 8 | *.gch 9 | *.pch 10 | 11 | # Compiled Dynamic libraries 12 | *.so 13 | *.dylib 14 | *.dll 15 | 16 | # Fortran module files 17 | *.mod 18 | 19 | # Compiled Static libraries 20 | *.lai 21 | *.la 22 | *.a 23 | *.lib 24 | 25 | # Executables 26 | *.exe 27 | *.out 28 | *.app 29 | 30 | # Cmake 31 | CMakeOutput.log 32 | -------------------------------------------------------------------------------- /.travis.yml: -------------------------------------------------------------------------------- 1 | language: cpp 2 | cache: apt 3 | os: 4 | - linux 5 | compiler: 6 | - gcc 7 | - clang 8 | before_install: 9 | - if [ "$TRAVIS_OS_NAME" = "linux" ]; then sudo ./install_deps.sh; fi 10 | script: 11 | - "./make.sh" 12 | env: 13 | global: 14 | - secure: "VxSxKAmeeMNhtVOjCmVyEqTeiTzHLK/XNCxad93rhu9sMnkKiTbSUxrbjxZ1laGX2JXsIwrhYdcyIknqCIkwYbuOi4AE1gyP6slrNmd/rHQRNUVpaHoPzD5B3083oEFY1mSn/eoDmgrcfTPPCALYjadzmk3IviMVkF9lyVSyu8n0kwW3s0oT+Q4gkVuEZ1VSPcJ7BU4vcny6m3wFMbRh+4rP62j9MKVeT3gUrv+rg89ySxd7yIj6HiU2nnNblkYVSoJeCVqsYl/0iTXBD3CwPeZc7c62uTabIjIcWx9z1r5iniWIH7wpwokYpNF4EMCTOKGtBQHn4OPwLlil2wA23DtYYqTZc3QHSAlZEHVLWpZpxlgbndsLG6MHOy6vsaR6Oxf8k6+ZOcSRP8D5T9nM2nYdf9llE5oNgrYGHWN1ZrIHakWUvLE+kx5A7qZG7mcbJqr5YIOrozt5YOWkbvZZjFUaAYt4fzHrMdSFV8c4Yay9Qvqv82aIJiE24R9cXpwek5+h5mAFbD6OvfH3YA40TKdVoY8JHPJ1j9NLPfcIrzKdnwyeh31iys8CNqfKUfda11kG88rm5Eo1VWEn7s86QlV40jW101Q4G9uy0yv53H10mhPnSuaWHENd/t9Kr+/hVK55bc2IRiMZ2z03icXCt2KrCSxkazWpwEtLGlquqm0=" 15 | addons: 16 | coverity_scan: 17 | project: 18 | name: "trailofbits/codereason" 19 | description: "Build submitted via Travis CI" 20 | notification_email: dan@trailofbits.com 21 | build_command_prepend: "sudo ./install_deps.sh" 22 | build_command: "./make.sh" 23 | branch_pattern: coverity 24 | -------------------------------------------------------------------------------- /CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required (VERSION 2.8) 2 | 3 | project (codeReason) 4 | set(CMAKE_BUILD_TYPE Debug) 5 | 6 | #lets use boost for smart pointers 7 | set(BOOST_USE_MULTITHREADED ON) 8 | if(WIN32) 9 | set(Boost_USE_STATIC_LIBS ON) 10 | endif(WIN32) 11 | find_package(Boost COMPONENTS thread system filesystem program_options date_time regex REQUIRED) 12 | find_package(Threads REQUIRED) 13 | find_package(Protobuf REQUIRED) 14 | 15 | #find the place where VEX lives ... 16 | #find_path(VEX_INCLUDE_DIR libvex.h REQUIRED PATHS ./libvex/VEX/pub NO_DEFAULT_PATH) 17 | 18 | #define capstone's includes 19 | set(CAPSTONE_SRC_DIR "./capstone-3.0.3/capstone-3.0.3") 20 | set(PE-PARSE_SRC_DIR "./libs/pe-parse/parser-library") 21 | set(ELFIO_INCLUDE_DIR "./libs/elfio") 22 | 23 | # libvex defines 24 | set(LIBVEX_BUILD_DIR "./libvex/build") 25 | 26 | #include_directories(${VEX_INCLUDE_DIR}) 27 | include_directories(${Boost_INCLUDE_DIRS}) 28 | include_directories(${PROTOBUF_INCLUDE_DIR}) 29 | include_directories(${ELFIO_INCLUDE_DIR}) 30 | 31 | IF(WIN32) 32 | #on win32, vex is pre-built 33 | #find_library(VEX_LIB VEX.lib HINTS ./build_for_windows/lib32 NO_DEFAULT_PATH) 34 | ELSE(WIN32) 35 | find_library(VEX_LIB libvex.so HINTS ${LIBVEX_BUILD_DIR} NO_DEFAULT_PATH) 36 | find_library(CAPSTONE_LIB libcapstone.a HINTS ${CAPSTONE_SRC_DIR} NO_DEFAULT_PATH) 37 | find_library(PE-PARSE_LIB libpe-parser-library.a HINTS ${PE-PARSE_SRC_DIR} NO_DEFAULT_PATH) 38 | ENDIF(WIN32) 39 | 40 | #add_definitions(-D__i386__) 41 | # gtest fix on osx 42 | IF(APPLE) 43 | add_definitions(-DGTEST_USE_OWN_TR1_TUPLE=1) 44 | ENDIF(APPLE) 45 | 46 | set(EXECUTABLE_OUTPUT_PATH ${PROJECT_BINARY_DIR}/bin) 47 | set(LIBRARY_OUTPUT_PATH ${PROJECT_BINARY_DIR}/lib) 48 | 49 | set(gtest_force_shared_crt ON) 50 | 51 | add_subdirectory(tools) 52 | add_subdirectory(libs) 53 | add_subdirectory(lua-5.3.0) 54 | add_subdirectory(gtest-1.6.0) 55 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2014 Andrew Ruef 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy of 6 | this software and associated documentation files (the "Software"), to deal in 7 | the Software without restriction, including without limitation the rights to 8 | use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of 9 | the Software, and to permit persons to whom the Software is furnished to do so, 10 | subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS 17 | FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR 18 | COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER 19 | IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 20 | CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 21 | -------------------------------------------------------------------------------- /build_for_windows/helpers/MakeDef.py: -------------------------------------------------------------------------------- 1 | f = file("a.tmp", "r") 2 | l = f.readline() 3 | k = 1 4 | o = file("VEX.def", "w") 5 | o.write("LIBRARY VEX\n") 6 | o.write("\n") 7 | o.write("EXPORTS\n") 8 | while len(l) > 0: 9 | j = l.find("\n") 10 | s = l[:j] 11 | u = "\t%s @%i\n" % (s, k) 12 | #print u 13 | k = k + 1 14 | o.write(u) 15 | l = f.readline() 16 | -------------------------------------------------------------------------------- /capstone-3.0.3/capstone-3.0.3.tgz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lifting-bits/codereason/5c9d51fe61895ebe29cd9b6d8e60dc49d0162ea2/capstone-3.0.3/capstone-3.0.3.tgz -------------------------------------------------------------------------------- /capstone-3.0.3/setup_capstone.sh: -------------------------------------------------------------------------------- 1 | #/bin/bash 2 | 3 | # make Capstone 4 | rm -rf capstone-3.0.3 5 | tar -xf capstone-3.0.3.tgz 6 | cd capstone-3.0.3 7 | cd include 8 | mkdir capstone 9 | cp -R *.h capstone 10 | cd .. 11 | ./make.sh 12 | 13 | -------------------------------------------------------------------------------- /debian/control: -------------------------------------------------------------------------------- 1 | Package: codereason 2 | Section: devel 3 | Priority: optional 4 | Architecture: amd64 5 | Maintainer: Andrew Ruef 6 | Description: CodeReason Framework 7 | CodeReason analyzes the semantics of native x86 and ARM code. 8 | -------------------------------------------------------------------------------- /docs/Manual.docx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lifting-bits/codereason/5c9d51fe61895ebe29cd9b6d8e60dc49d0162ea2/docs/Manual.docx -------------------------------------------------------------------------------- /docs/Manual.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lifting-bits/codereason/5c9d51fe61895ebe29cd9b6d8e60dc49d0162ea2/docs/Manual.pdf -------------------------------------------------------------------------------- /docs/ROP_In_MSF.docx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lifting-bits/codereason/5c9d51fe61895ebe29cd9b6d8e60dc49d0162ea2/docs/ROP_In_MSF.docx -------------------------------------------------------------------------------- /docs/ROP_In_MSF.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lifting-bits/codereason/5c9d51fe61895ebe29cd9b6d8e60dc49d0162ea2/docs/ROP_In_MSF.pdf -------------------------------------------------------------------------------- /docs/gadgets.txt: -------------------------------------------------------------------------------- 1 | #1: pop eax 2 | pop edi 3 | pop esi 4 | pop ebx 5 | pop ebp 6 | ret 7 | encoding: 8 | 9 | ret 10 | encoding: 11 | 12 | jmp [eax] 13 | encoding: 14 | 15 | neg eax 16 | ret 17 | encoding: 18 | 19 | inc ebx 20 | ret 21 | 22 | 23 | -------------------------------------------------------------------------------- /gtest-1.6.0/CONTRIBUTORS: -------------------------------------------------------------------------------- 1 | # This file contains a list of people who've made non-trivial 2 | # contribution to the Google C++ Testing Framework project. People 3 | # who commit code to the project are encouraged to add their names 4 | # here. Please keep the list sorted by first names. 5 | 6 | Ajay Joshi 7 | Balázs Dán 8 | Bharat Mediratta 9 | Chandler Carruth 10 | Chris Prince 11 | Chris Taylor 12 | Dan Egnor 13 | Eric Roman 14 | Hady Zalek 15 | Jeffrey Yasskin 16 | Jói Sigurðsson 17 | Keir Mierle 18 | Keith Ray 19 | Kenton Varda 20 | Manuel Klimek 21 | Markus Heule 22 | Mika Raento 23 | Miklós Fazekas 24 | Pasi Valminen 25 | Patrick Hanna 26 | Patrick Riley 27 | Peter Kaminski 28 | Preston Jackson 29 | Rainer Klaffenboeck 30 | Russ Cox 31 | Russ Rufer 32 | Sean Mcafee 33 | Sigurður Ásgeirsson 34 | Tracy Bialik 35 | Vadim Berman 36 | Vlad Losev 37 | Zhanyong Wan 38 | -------------------------------------------------------------------------------- /gtest-1.6.0/COPYING: -------------------------------------------------------------------------------- 1 | Copyright 2008, Google Inc. 2 | All rights reserved. 3 | 4 | Redistribution and use in source and binary forms, with or without 5 | modification, are permitted provided that the following conditions are 6 | met: 7 | 8 | * Redistributions of source code must retain the above copyright 9 | notice, this list of conditions and the following disclaimer. 10 | * Redistributions in binary form must reproduce the above 11 | copyright notice, this list of conditions and the following disclaimer 12 | in the documentation and/or other materials provided with the 13 | distribution. 14 | * Neither the name of Google Inc. nor the names of its 15 | contributors may be used to endorse or promote products derived from 16 | this software without specific prior written permission. 17 | 18 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 19 | "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 20 | LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 21 | A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 22 | OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 23 | SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 24 | LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 25 | DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 26 | THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 27 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 28 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 29 | -------------------------------------------------------------------------------- /gtest-1.6.0/build-aux/config.h.in: -------------------------------------------------------------------------------- 1 | /* build-aux/config.h.in. Generated from configure.ac by autoheader. */ 2 | 3 | /* Define to 1 if you have the header file. */ 4 | #undef HAVE_DLFCN_H 5 | 6 | /* Define to 1 if you have the header file. */ 7 | #undef HAVE_INTTYPES_H 8 | 9 | /* Define to 1 if you have the header file. */ 10 | #undef HAVE_MEMORY_H 11 | 12 | /* Define if you have POSIX threads libraries and header files. */ 13 | #undef HAVE_PTHREAD 14 | 15 | /* Define to 1 if you have the header file. */ 16 | #undef HAVE_STDINT_H 17 | 18 | /* Define to 1 if you have the header file. */ 19 | #undef HAVE_STDLIB_H 20 | 21 | /* Define to 1 if you have the header file. */ 22 | #undef HAVE_STRINGS_H 23 | 24 | /* Define to 1 if you have the header file. */ 25 | #undef HAVE_STRING_H 26 | 27 | /* Define to 1 if you have the header file. */ 28 | #undef HAVE_SYS_STAT_H 29 | 30 | /* Define to 1 if you have the header file. */ 31 | #undef HAVE_SYS_TYPES_H 32 | 33 | /* Define to 1 if you have the header file. */ 34 | #undef HAVE_UNISTD_H 35 | 36 | /* Define to the sub-directory in which libtool stores uninstalled libraries. 37 | */ 38 | #undef LT_OBJDIR 39 | 40 | /* Name of package */ 41 | #undef PACKAGE 42 | 43 | /* Define to the address where bug reports for this package should be sent. */ 44 | #undef PACKAGE_BUGREPORT 45 | 46 | /* Define to the full name of this package. */ 47 | #undef PACKAGE_NAME 48 | 49 | /* Define to the full name and version of this package. */ 50 | #undef PACKAGE_STRING 51 | 52 | /* Define to the one symbol short name of this package. */ 53 | #undef PACKAGE_TARNAME 54 | 55 | /* Define to the home page for this package. */ 56 | #undef PACKAGE_URL 57 | 58 | /* Define to the version of this package. */ 59 | #undef PACKAGE_VERSION 60 | 61 | /* Define to necessary symbol if this constant uses a non-standard name on 62 | your system. */ 63 | #undef PTHREAD_CREATE_JOINABLE 64 | 65 | /* Define to 1 if you have the ANSI C header files. */ 66 | #undef STDC_HEADERS 67 | 68 | /* Version number of package */ 69 | #undef VERSION 70 | -------------------------------------------------------------------------------- /gtest-1.6.0/codegear/gtest.groupproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | {c1d923e0-6cba-4332-9b6f-3420acbf5091} 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | Default.Personality 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | -------------------------------------------------------------------------------- /gtest-1.6.0/codegear/gtest_all.cc: -------------------------------------------------------------------------------- 1 | // Copyright 2009, Google Inc. 2 | // All rights reserved. 3 | // 4 | // Redistribution and use in source and binary forms, with or without 5 | // modification, are permitted provided that the following conditions are 6 | // met: 7 | // 8 | // * Redistributions of source code must retain the above copyright 9 | // notice, this list of conditions and the following disclaimer. 10 | // * Redistributions in binary form must reproduce the above 11 | // copyright notice, this list of conditions and the following disclaimer 12 | // in the documentation and/or other materials provided with the 13 | // distribution. 14 | // * Neither the name of Google Inc. nor the names of its 15 | // contributors may be used to endorse or promote products derived from 16 | // this software without specific prior written permission. 17 | // 18 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 19 | // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 20 | // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 21 | // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 22 | // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 23 | // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 24 | // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 25 | // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 26 | // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 27 | // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 28 | // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 29 | // 30 | // Author: Josh Kelley (joshkel@gmail.com) 31 | // 32 | // Google C++ Testing Framework (Google Test) 33 | // 34 | // C++Builder's IDE cannot build a static library from files with hyphens 35 | // in their name. See http://qc.codegear.com/wc/qcmain.aspx?d=70977 . 36 | // This file serves as a workaround. 37 | 38 | #include "src/gtest-all.cc" 39 | -------------------------------------------------------------------------------- /gtest-1.6.0/codegear/gtest_link.cc: -------------------------------------------------------------------------------- 1 | // Copyright 2009, Google Inc. 2 | // All rights reserved. 3 | // 4 | // Redistribution and use in source and binary forms, with or without 5 | // modification, are permitted provided that the following conditions are 6 | // met: 7 | // 8 | // * Redistributions of source code must retain the above copyright 9 | // notice, this list of conditions and the following disclaimer. 10 | // * Redistributions in binary form must reproduce the above 11 | // copyright notice, this list of conditions and the following disclaimer 12 | // in the documentation and/or other materials provided with the 13 | // distribution. 14 | // * Neither the name of Google Inc. nor the names of its 15 | // contributors may be used to endorse or promote products derived from 16 | // this software without specific prior written permission. 17 | // 18 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 19 | // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 20 | // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 21 | // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 22 | // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 23 | // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 24 | // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 25 | // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 26 | // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 27 | // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 28 | // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 29 | // 30 | // Author: Josh Kelley (joshkel@gmail.com) 31 | // 32 | // Google C++ Testing Framework (Google Test) 33 | // 34 | // Links gtest.lib and gtest_main.lib into the current project in C++Builder. 35 | // This means that these libraries can't be renamed, but it's the only way to 36 | // ensure that Debug versus Release test builds are linked against the 37 | // appropriate Debug or Release build of the libraries. 38 | 39 | #pragma link "gtest.lib" 40 | #pragma link "gtest_main.lib" 41 | -------------------------------------------------------------------------------- /gtest-1.6.0/fused-src/gtest/gtest_main.cc: -------------------------------------------------------------------------------- 1 | // Copyright 2006, Google Inc. 2 | // All rights reserved. 3 | // 4 | // Redistribution and use in source and binary forms, with or without 5 | // modification, are permitted provided that the following conditions are 6 | // met: 7 | // 8 | // * Redistributions of source code must retain the above copyright 9 | // notice, this list of conditions and the following disclaimer. 10 | // * Redistributions in binary form must reproduce the above 11 | // copyright notice, this list of conditions and the following disclaimer 12 | // in the documentation and/or other materials provided with the 13 | // distribution. 14 | // * Neither the name of Google Inc. nor the names of its 15 | // contributors may be used to endorse or promote products derived from 16 | // this software without specific prior written permission. 17 | // 18 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 19 | // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 20 | // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 21 | // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 22 | // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 23 | // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 24 | // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 25 | // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 26 | // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 27 | // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 28 | // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 29 | 30 | #include 31 | 32 | #include "gtest/gtest.h" 33 | 34 | GTEST_API_ int main(int argc, char **argv) { 35 | std::cout << "Running main() from gtest_main.cc\n"; 36 | 37 | testing::InitGoogleTest(&argc, argv); 38 | return RUN_ALL_TESTS(); 39 | } 40 | -------------------------------------------------------------------------------- /gtest-1.6.0/include/gtest/gtest_prod.h: -------------------------------------------------------------------------------- 1 | // Copyright 2006, Google Inc. 2 | // All rights reserved. 3 | // 4 | // Redistribution and use in source and binary forms, with or without 5 | // modification, are permitted provided that the following conditions are 6 | // met: 7 | // 8 | // * Redistributions of source code must retain the above copyright 9 | // notice, this list of conditions and the following disclaimer. 10 | // * Redistributions in binary form must reproduce the above 11 | // copyright notice, this list of conditions and the following disclaimer 12 | // in the documentation and/or other materials provided with the 13 | // distribution. 14 | // * Neither the name of Google Inc. nor the names of its 15 | // contributors may be used to endorse or promote products derived from 16 | // this software without specific prior written permission. 17 | // 18 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 19 | // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 20 | // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 21 | // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 22 | // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 23 | // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 24 | // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 25 | // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 26 | // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 27 | // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 28 | // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 29 | // 30 | // Author: wan@google.com (Zhanyong Wan) 31 | // 32 | // Google C++ Testing Framework definitions useful in production code. 33 | 34 | #ifndef GTEST_INCLUDE_GTEST_GTEST_PROD_H_ 35 | #define GTEST_INCLUDE_GTEST_GTEST_PROD_H_ 36 | 37 | // When you need to test the private or protected members of a class, 38 | // use the FRIEND_TEST macro to declare your tests as friends of the 39 | // class. For example: 40 | // 41 | // class MyClass { 42 | // private: 43 | // void MyMethod(); 44 | // FRIEND_TEST(MyClassTest, MyMethod); 45 | // }; 46 | // 47 | // class MyClassTest : public testing::Test { 48 | // // ... 49 | // }; 50 | // 51 | // TEST_F(MyClassTest, MyMethod) { 52 | // // Can call MyClass::MyMethod() here. 53 | // } 54 | 55 | #define FRIEND_TEST(test_case_name, test_name)\ 56 | friend class test_case_name##_##test_name##_Test 57 | 58 | #endif // GTEST_INCLUDE_GTEST_GTEST_PROD_H_ 59 | -------------------------------------------------------------------------------- /gtest-1.6.0/m4/ltversion.m4: -------------------------------------------------------------------------------- 1 | # ltversion.m4 -- version numbers -*- Autoconf -*- 2 | # 3 | # Copyright (C) 2004 Free Software Foundation, Inc. 4 | # Written by Scott James Remnant, 2004 5 | # 6 | # This file is free software; the Free Software Foundation gives 7 | # unlimited permission to copy and/or distribute it, with or without 8 | # modifications, as long as this notice is preserved. 9 | 10 | # Generated from ltversion.in. 11 | 12 | # serial 3017 ltversion.m4 13 | # This file is part of GNU Libtool 14 | 15 | m4_define([LT_PACKAGE_VERSION], [2.2.6b]) 16 | m4_define([LT_PACKAGE_REVISION], [1.3017]) 17 | 18 | AC_DEFUN([LTVERSION_VERSION], 19 | [macro_version='2.2.6b' 20 | macro_revision='1.3017' 21 | _LT_DECL(, macro_version, 0, [Which release of libtool.m4 was used?]) 22 | _LT_DECL(, macro_revision, 0) 23 | ]) 24 | -------------------------------------------------------------------------------- /gtest-1.6.0/msvc/gtest-md.sln: -------------------------------------------------------------------------------- 1 | Microsoft Visual Studio Solution File, Format Version 8.00 2 | Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "gtest-md", "gtest-md.vcproj", "{C8F6C172-56F2-4E76-B5FA-C3B423B31BE8}" 3 | ProjectSection(ProjectDependencies) = postProject 4 | EndProjectSection 5 | EndProject 6 | Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "gtest_main-md", "gtest_main-md.vcproj", "{3AF54C8A-10BF-4332-9147-F68ED9862033}" 7 | ProjectSection(ProjectDependencies) = postProject 8 | EndProjectSection 9 | EndProject 10 | Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "gtest_prod_test-md", "gtest_prod_test-md.vcproj", "{24848551-EF4F-47E8-9A9D-EA4D49BC3ECB}" 11 | ProjectSection(ProjectDependencies) = postProject 12 | EndProjectSection 13 | EndProject 14 | Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "gtest_unittest-md", "gtest_unittest-md.vcproj", "{4D9FDFB5-986A-4139-823C-F4EE0ED481A2}" 15 | ProjectSection(ProjectDependencies) = postProject 16 | EndProjectSection 17 | EndProject 18 | Global 19 | GlobalSection(SolutionConfiguration) = preSolution 20 | Debug = Debug 21 | Release = Release 22 | EndGlobalSection 23 | GlobalSection(ProjectConfiguration) = postSolution 24 | {C8F6C172-56F2-4E76-B5FA-C3B423B31BE8}.Debug.ActiveCfg = Debug|Win32 25 | {C8F6C172-56F2-4E76-B5FA-C3B423B31BE8}.Debug.Build.0 = Debug|Win32 26 | {C8F6C172-56F2-4E76-B5FA-C3B423B31BE8}.Release.ActiveCfg = Release|Win32 27 | {C8F6C172-56F2-4E76-B5FA-C3B423B31BE8}.Release.Build.0 = Release|Win32 28 | {3AF54C8A-10BF-4332-9147-F68ED9862033}.Debug.ActiveCfg = Debug|Win32 29 | {3AF54C8A-10BF-4332-9147-F68ED9862033}.Debug.Build.0 = Debug|Win32 30 | {3AF54C8A-10BF-4332-9147-F68ED9862033}.Release.ActiveCfg = Release|Win32 31 | {3AF54C8A-10BF-4332-9147-F68ED9862033}.Release.Build.0 = Release|Win32 32 | {24848551-EF4F-47E8-9A9D-EA4D49BC3ECB}.Debug.ActiveCfg = Debug|Win32 33 | {24848551-EF4F-47E8-9A9D-EA4D49BC3ECB}.Debug.Build.0 = Debug|Win32 34 | {24848551-EF4F-47E8-9A9D-EA4D49BC3ECB}.Release.ActiveCfg = Release|Win32 35 | {24848551-EF4F-47E8-9A9D-EA4D49BC3ECB}.Release.Build.0 = Release|Win32 36 | {4D9FDFB5-986A-4139-823C-F4EE0ED481A2}.Debug.ActiveCfg = Debug|Win32 37 | {4D9FDFB5-986A-4139-823C-F4EE0ED481A2}.Debug.Build.0 = Debug|Win32 38 | {4D9FDFB5-986A-4139-823C-F4EE0ED481A2}.Release.ActiveCfg = Release|Win32 39 | {4D9FDFB5-986A-4139-823C-F4EE0ED481A2}.Release.Build.0 = Release|Win32 40 | EndGlobalSection 41 | GlobalSection(ExtensibilityGlobals) = postSolution 42 | EndGlobalSection 43 | GlobalSection(ExtensibilityAddIns) = postSolution 44 | EndGlobalSection 45 | EndGlobal 46 | -------------------------------------------------------------------------------- /gtest-1.6.0/msvc/gtest.sln: -------------------------------------------------------------------------------- 1 | Microsoft Visual Studio Solution File, Format Version 8.00 2 | Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "gtest", "gtest.vcproj", "{C8F6C172-56F2-4E76-B5FA-C3B423B31BE7}" 3 | ProjectSection(ProjectDependencies) = postProject 4 | EndProjectSection 5 | EndProject 6 | Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "gtest_main", "gtest_main.vcproj", "{3AF54C8A-10BF-4332-9147-F68ED9862032}" 7 | ProjectSection(ProjectDependencies) = postProject 8 | EndProjectSection 9 | EndProject 10 | Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "gtest_unittest", "gtest_unittest.vcproj", "{4D9FDFB5-986A-4139-823C-F4EE0ED481A1}" 11 | ProjectSection(ProjectDependencies) = postProject 12 | EndProjectSection 13 | EndProject 14 | Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "gtest_prod_test", "gtest_prod_test.vcproj", "{24848551-EF4F-47E8-9A9D-EA4D49BC3ECA}" 15 | ProjectSection(ProjectDependencies) = postProject 16 | EndProjectSection 17 | EndProject 18 | Global 19 | GlobalSection(SolutionConfiguration) = preSolution 20 | Debug = Debug 21 | Release = Release 22 | EndGlobalSection 23 | GlobalSection(ProjectConfiguration) = postSolution 24 | {C8F6C172-56F2-4E76-B5FA-C3B423B31BE7}.Debug.ActiveCfg = Debug|Win32 25 | {C8F6C172-56F2-4E76-B5FA-C3B423B31BE7}.Debug.Build.0 = Debug|Win32 26 | {C8F6C172-56F2-4E76-B5FA-C3B423B31BE7}.Release.ActiveCfg = Release|Win32 27 | {C8F6C172-56F2-4E76-B5FA-C3B423B31BE7}.Release.Build.0 = Release|Win32 28 | {3AF54C8A-10BF-4332-9147-F68ED9862032}.Debug.ActiveCfg = Debug|Win32 29 | {3AF54C8A-10BF-4332-9147-F68ED9862032}.Debug.Build.0 = Debug|Win32 30 | {3AF54C8A-10BF-4332-9147-F68ED9862032}.Release.ActiveCfg = Release|Win32 31 | {3AF54C8A-10BF-4332-9147-F68ED9862032}.Release.Build.0 = Release|Win32 32 | {4D9FDFB5-986A-4139-823C-F4EE0ED481A1}.Debug.ActiveCfg = Debug|Win32 33 | {4D9FDFB5-986A-4139-823C-F4EE0ED481A1}.Debug.Build.0 = Debug|Win32 34 | {4D9FDFB5-986A-4139-823C-F4EE0ED481A1}.Release.ActiveCfg = Release|Win32 35 | {4D9FDFB5-986A-4139-823C-F4EE0ED481A1}.Release.Build.0 = Release|Win32 36 | {24848551-EF4F-47E8-9A9D-EA4D49BC3ECA}.Debug.ActiveCfg = Debug|Win32 37 | {24848551-EF4F-47E8-9A9D-EA4D49BC3ECA}.Debug.Build.0 = Debug|Win32 38 | {24848551-EF4F-47E8-9A9D-EA4D49BC3ECA}.Release.ActiveCfg = Release|Win32 39 | {24848551-EF4F-47E8-9A9D-EA4D49BC3ECA}.Release.Build.0 = Release|Win32 40 | EndGlobalSection 41 | GlobalSection(ExtensibilityGlobals) = postSolution 42 | EndGlobalSection 43 | GlobalSection(ExtensibilityAddIns) = postSolution 44 | EndGlobalSection 45 | EndGlobal 46 | -------------------------------------------------------------------------------- /gtest-1.6.0/samples/sample1.h: -------------------------------------------------------------------------------- 1 | // Copyright 2005, Google Inc. 2 | // All rights reserved. 3 | // 4 | // Redistribution and use in source and binary forms, with or without 5 | // modification, are permitted provided that the following conditions are 6 | // met: 7 | // 8 | // * Redistributions of source code must retain the above copyright 9 | // notice, this list of conditions and the following disclaimer. 10 | // * Redistributions in binary form must reproduce the above 11 | // copyright notice, this list of conditions and the following disclaimer 12 | // in the documentation and/or other materials provided with the 13 | // distribution. 14 | // * Neither the name of Google Inc. nor the names of its 15 | // contributors may be used to endorse or promote products derived from 16 | // this software without specific prior written permission. 17 | // 18 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 19 | // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 20 | // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 21 | // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 22 | // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 23 | // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 24 | // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 25 | // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 26 | // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 27 | // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 28 | // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 29 | 30 | // A sample program demonstrating using Google C++ testing framework. 31 | // 32 | // Author: wan@google.com (Zhanyong Wan) 33 | 34 | #ifndef GTEST_SAMPLES_SAMPLE1_H_ 35 | #define GTEST_SAMPLES_SAMPLE1_H_ 36 | 37 | // Returns n! (the factorial of n). For negative n, n! is defined to be 1. 38 | int Factorial(int n); 39 | 40 | // Returns true iff n is a prime number. 41 | bool IsPrime(int n); 42 | 43 | #endif // GTEST_SAMPLES_SAMPLE1_H_ 44 | -------------------------------------------------------------------------------- /gtest-1.6.0/samples/sample2.cc: -------------------------------------------------------------------------------- 1 | // Copyright 2005, Google Inc. 2 | // All rights reserved. 3 | // 4 | // Redistribution and use in source and binary forms, with or without 5 | // modification, are permitted provided that the following conditions are 6 | // met: 7 | // 8 | // * Redistributions of source code must retain the above copyright 9 | // notice, this list of conditions and the following disclaimer. 10 | // * Redistributions in binary form must reproduce the above 11 | // copyright notice, this list of conditions and the following disclaimer 12 | // in the documentation and/or other materials provided with the 13 | // distribution. 14 | // * Neither the name of Google Inc. nor the names of its 15 | // contributors may be used to endorse or promote products derived from 16 | // this software without specific prior written permission. 17 | // 18 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 19 | // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 20 | // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 21 | // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 22 | // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 23 | // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 24 | // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 25 | // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 26 | // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 27 | // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 28 | // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 29 | 30 | // A sample program demonstrating using Google C++ testing framework. 31 | // 32 | // Author: wan@google.com (Zhanyong Wan) 33 | 34 | #include "sample2.h" 35 | 36 | #include 37 | 38 | // Clones a 0-terminated C string, allocating memory using new. 39 | const char* MyString::CloneCString(const char* a_c_string) { 40 | if (a_c_string == NULL) return NULL; 41 | 42 | const size_t len = strlen(a_c_string); 43 | char* const clone = new char[ len + 1 ]; 44 | memcpy(clone, a_c_string, len + 1); 45 | 46 | return clone; 47 | } 48 | 49 | // Sets the 0-terminated C string this MyString object 50 | // represents. 51 | void MyString::Set(const char* a_c_string) { 52 | // Makes sure this works when c_string == c_string_ 53 | const char* const temp = MyString::CloneCString(a_c_string); 54 | delete[] c_string_; 55 | c_string_ = temp; 56 | } 57 | -------------------------------------------------------------------------------- /gtest-1.6.0/samples/sample4.cc: -------------------------------------------------------------------------------- 1 | // Copyright 2005, Google Inc. 2 | // All rights reserved. 3 | // 4 | // Redistribution and use in source and binary forms, with or without 5 | // modification, are permitted provided that the following conditions are 6 | // met: 7 | // 8 | // * Redistributions of source code must retain the above copyright 9 | // notice, this list of conditions and the following disclaimer. 10 | // * Redistributions in binary form must reproduce the above 11 | // copyright notice, this list of conditions and the following disclaimer 12 | // in the documentation and/or other materials provided with the 13 | // distribution. 14 | // * Neither the name of Google Inc. nor the names of its 15 | // contributors may be used to endorse or promote products derived from 16 | // this software without specific prior written permission. 17 | // 18 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 19 | // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 20 | // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 21 | // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 22 | // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 23 | // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 24 | // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 25 | // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 26 | // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 27 | // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 28 | // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 29 | 30 | // A sample program demonstrating using Google C++ testing framework. 31 | // 32 | // Author: wan@google.com (Zhanyong Wan) 33 | 34 | #include 35 | 36 | #include "sample4.h" 37 | 38 | // Returns the current counter value, and increments it. 39 | int Counter::Increment() { 40 | return counter_++; 41 | } 42 | 43 | // Prints the current counter value to STDOUT. 44 | void Counter::Print() const { 45 | printf("%d", counter_); 46 | } 47 | -------------------------------------------------------------------------------- /gtest-1.6.0/samples/sample4.h: -------------------------------------------------------------------------------- 1 | // Copyright 2005, Google Inc. 2 | // All rights reserved. 3 | // 4 | // Redistribution and use in source and binary forms, with or without 5 | // modification, are permitted provided that the following conditions are 6 | // met: 7 | // 8 | // * Redistributions of source code must retain the above copyright 9 | // notice, this list of conditions and the following disclaimer. 10 | // * Redistributions in binary form must reproduce the above 11 | // copyright notice, this list of conditions and the following disclaimer 12 | // in the documentation and/or other materials provided with the 13 | // distribution. 14 | // * Neither the name of Google Inc. nor the names of its 15 | // contributors may be used to endorse or promote products derived from 16 | // this software without specific prior written permission. 17 | // 18 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 19 | // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 20 | // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 21 | // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 22 | // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 23 | // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 24 | // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 25 | // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 26 | // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 27 | // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 28 | // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 29 | 30 | // A sample program demonstrating using Google C++ testing framework. 31 | // 32 | // Author: wan@google.com (Zhanyong Wan) 33 | 34 | #ifndef GTEST_SAMPLES_SAMPLE4_H_ 35 | #define GTEST_SAMPLES_SAMPLE4_H_ 36 | 37 | // A simple monotonic counter. 38 | class Counter { 39 | private: 40 | int counter_; 41 | 42 | public: 43 | // Creates a counter that starts at 0. 44 | Counter() : counter_(0) {} 45 | 46 | // Returns the current counter value, and increments it. 47 | int Increment(); 48 | 49 | // Prints the current counter value to STDOUT. 50 | void Print() const; 51 | }; 52 | 53 | #endif // GTEST_SAMPLES_SAMPLE4_H_ 54 | -------------------------------------------------------------------------------- /gtest-1.6.0/samples/sample4_unittest.cc: -------------------------------------------------------------------------------- 1 | // Copyright 2005, Google Inc. 2 | // All rights reserved. 3 | // 4 | // Redistribution and use in source and binary forms, with or without 5 | // modification, are permitted provided that the following conditions are 6 | // met: 7 | // 8 | // * Redistributions of source code must retain the above copyright 9 | // notice, this list of conditions and the following disclaimer. 10 | // * Redistributions in binary form must reproduce the above 11 | // copyright notice, this list of conditions and the following disclaimer 12 | // in the documentation and/or other materials provided with the 13 | // distribution. 14 | // * Neither the name of Google Inc. nor the names of its 15 | // contributors may be used to endorse or promote products derived from 16 | // this software without specific prior written permission. 17 | // 18 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 19 | // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 20 | // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 21 | // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 22 | // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 23 | // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 24 | // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 25 | // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 26 | // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 27 | // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 28 | // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 29 | // 30 | // Author: wan@google.com (Zhanyong Wan) 31 | 32 | #include "gtest/gtest.h" 33 | #include "sample4.h" 34 | 35 | // Tests the Increment() method. 36 | TEST(Counter, Increment) { 37 | Counter c; 38 | 39 | // EXPECT_EQ() evaluates its arguments exactly once, so they 40 | // can have side effects. 41 | 42 | EXPECT_EQ(0, c.Increment()); 43 | EXPECT_EQ(1, c.Increment()); 44 | EXPECT_EQ(2, c.Increment()); 45 | } 46 | -------------------------------------------------------------------------------- /gtest-1.6.0/scripts/test/Makefile: -------------------------------------------------------------------------------- 1 | # A Makefile for fusing Google Test and building a sample test against it. 2 | # 3 | # SYNOPSIS: 4 | # 5 | # make [all] - makes everything. 6 | # make TARGET - makes the given target. 7 | # make check - makes everything and runs the built sample test. 8 | # make clean - removes all files generated by make. 9 | 10 | # Points to the root of fused Google Test, relative to where this file is. 11 | FUSED_GTEST_DIR = output 12 | 13 | # Paths to the fused gtest files. 14 | FUSED_GTEST_H = $(FUSED_GTEST_DIR)/gtest/gtest.h 15 | FUSED_GTEST_ALL_CC = $(FUSED_GTEST_DIR)/gtest/gtest-all.cc 16 | 17 | # Where to find the sample test. 18 | SAMPLE_DIR = ../../samples 19 | 20 | # Where to find gtest_main.cc. 21 | GTEST_MAIN_CC = ../../src/gtest_main.cc 22 | 23 | # Flags passed to the preprocessor. 24 | # We have no idea here whether pthreads is available in the system, so 25 | # disable its use. 26 | CPPFLAGS += -I$(FUSED_GTEST_DIR) -DGTEST_HAS_PTHREAD=0 27 | 28 | # Flags passed to the C++ compiler. 29 | CXXFLAGS += -g 30 | 31 | all : sample1_unittest 32 | 33 | check : all 34 | ./sample1_unittest 35 | 36 | clean : 37 | rm -rf $(FUSED_GTEST_DIR) sample1_unittest *.o 38 | 39 | $(FUSED_GTEST_H) : 40 | ../fuse_gtest_files.py $(FUSED_GTEST_DIR) 41 | 42 | $(FUSED_GTEST_ALL_CC) : 43 | ../fuse_gtest_files.py $(FUSED_GTEST_DIR) 44 | 45 | gtest-all.o : $(FUSED_GTEST_H) $(FUSED_GTEST_ALL_CC) 46 | $(CXX) $(CPPFLAGS) $(CXXFLAGS) -c $(FUSED_GTEST_DIR)/gtest/gtest-all.cc 47 | 48 | gtest_main.o : $(FUSED_GTEST_H) $(GTEST_MAIN_CC) 49 | $(CXX) $(CPPFLAGS) $(CXXFLAGS) -c $(GTEST_MAIN_CC) 50 | 51 | sample1.o : $(SAMPLE_DIR)/sample1.cc $(SAMPLE_DIR)/sample1.h 52 | $(CXX) $(CPPFLAGS) $(CXXFLAGS) -c $(SAMPLE_DIR)/sample1.cc 53 | 54 | sample1_unittest.o : $(SAMPLE_DIR)/sample1_unittest.cc \ 55 | $(SAMPLE_DIR)/sample1.h $(FUSED_GTEST_H) 56 | $(CXX) $(CPPFLAGS) $(CXXFLAGS) -c $(SAMPLE_DIR)/sample1_unittest.cc 57 | 58 | sample1_unittest : sample1.o sample1_unittest.o gtest-all.o gtest_main.o 59 | $(CXX) $(CPPFLAGS) $(CXXFLAGS) $^ -o $@ 60 | -------------------------------------------------------------------------------- /gtest-1.6.0/src/gtest-all.cc: -------------------------------------------------------------------------------- 1 | // Copyright 2008, Google Inc. 2 | // All rights reserved. 3 | // 4 | // Redistribution and use in source and binary forms, with or without 5 | // modification, are permitted provided that the following conditions are 6 | // met: 7 | // 8 | // * Redistributions of source code must retain the above copyright 9 | // notice, this list of conditions and the following disclaimer. 10 | // * Redistributions in binary form must reproduce the above 11 | // copyright notice, this list of conditions and the following disclaimer 12 | // in the documentation and/or other materials provided with the 13 | // distribution. 14 | // * Neither the name of Google Inc. nor the names of its 15 | // contributors may be used to endorse or promote products derived from 16 | // this software without specific prior written permission. 17 | // 18 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 19 | // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 20 | // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 21 | // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 22 | // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 23 | // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 24 | // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 25 | // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 26 | // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 27 | // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 28 | // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 29 | // 30 | // Author: mheule@google.com (Markus Heule) 31 | // 32 | // Google C++ Testing Framework (Google Test) 33 | // 34 | // Sometimes it's desirable to build Google Test by compiling a single file. 35 | // This file serves this purpose. 36 | 37 | // This line ensures that gtest.h can be compiled on its own, even 38 | // when it's fused. 39 | #include "gtest/gtest.h" 40 | 41 | // The following lines pull in the real gtest *.cc files. 42 | #include "src/gtest.cc" 43 | #include "src/gtest-death-test.cc" 44 | #include "src/gtest-filepath.cc" 45 | #include "src/gtest-port.cc" 46 | #include "src/gtest-printers.cc" 47 | #include "src/gtest-test-part.cc" 48 | #include "src/gtest-typed-test.cc" 49 | -------------------------------------------------------------------------------- /gtest-1.6.0/src/gtest_main.cc: -------------------------------------------------------------------------------- 1 | // Copyright 2006, Google Inc. 2 | // All rights reserved. 3 | // 4 | // Redistribution and use in source and binary forms, with or without 5 | // modification, are permitted provided that the following conditions are 6 | // met: 7 | // 8 | // * Redistributions of source code must retain the above copyright 9 | // notice, this list of conditions and the following disclaimer. 10 | // * Redistributions in binary form must reproduce the above 11 | // copyright notice, this list of conditions and the following disclaimer 12 | // in the documentation and/or other materials provided with the 13 | // distribution. 14 | // * Neither the name of Google Inc. nor the names of its 15 | // contributors may be used to endorse or promote products derived from 16 | // this software without specific prior written permission. 17 | // 18 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 19 | // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 20 | // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 21 | // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 22 | // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 23 | // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 24 | // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 25 | // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 26 | // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 27 | // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 28 | // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 29 | 30 | #include 31 | 32 | #include "gtest/gtest.h" 33 | 34 | GTEST_API_ int main(int argc, char **argv) { 35 | std::cout << "Running main() from gtest_main.cc\n"; 36 | 37 | testing::InitGoogleTest(&argc, argv); 38 | return RUN_ALL_TESTS(); 39 | } 40 | -------------------------------------------------------------------------------- /gtest-1.6.0/test/gtest-param-test_test.h: -------------------------------------------------------------------------------- 1 | // Copyright 2008, Google Inc. 2 | // All rights reserved. 3 | // 4 | // Redistribution and use in source and binary forms, with or without 5 | // modification, are permitted provided that the following conditions are 6 | // met: 7 | // 8 | // * Redistributions of source code must retain the above copyright 9 | // notice, this list of conditions and the following disclaimer. 10 | // * Redistributions in binary form must reproduce the above 11 | // copyright notice, this list of conditions and the following disclaimer 12 | // in the documentation and/or other materials provided with the 13 | // distribution. 14 | // * Neither the name of Google Inc. nor the names of its 15 | // contributors may be used to endorse or promote products derived from 16 | // this software without specific prior written permission. 17 | // 18 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 19 | // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 20 | // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 21 | // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 22 | // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 23 | // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 24 | // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 25 | // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 26 | // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 27 | // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 28 | // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 29 | // 30 | // Authors: vladl@google.com (Vlad Losev) 31 | // 32 | // The Google C++ Testing Framework (Google Test) 33 | // 34 | // This header file provides classes and functions used internally 35 | // for testing Google Test itself. 36 | 37 | #ifndef GTEST_TEST_GTEST_PARAM_TEST_TEST_H_ 38 | #define GTEST_TEST_GTEST_PARAM_TEST_TEST_H_ 39 | 40 | #include "gtest/gtest.h" 41 | 42 | #if GTEST_HAS_PARAM_TEST 43 | 44 | // Test fixture for testing definition and instantiation of a test 45 | // in separate translation units. 46 | class ExternalInstantiationTest : public ::testing::TestWithParam {}; 47 | 48 | // Test fixture for testing instantiation of a test in multiple 49 | // translation units. 50 | class InstantiationInMultipleTranslaionUnitsTest 51 | : public ::testing::TestWithParam {}; 52 | 53 | #endif // GTEST_HAS_PARAM_TEST 54 | 55 | #endif // GTEST_TEST_GTEST_PARAM_TEST_TEST_H_ 56 | -------------------------------------------------------------------------------- /gtest-1.6.0/test/gtest-typed-test2_test.cc: -------------------------------------------------------------------------------- 1 | // Copyright 2008 Google Inc. 2 | // All Rights Reserved. 3 | // 4 | // Redistribution and use in source and binary forms, with or without 5 | // modification, are permitted provided that the following conditions are 6 | // met: 7 | // 8 | // * Redistributions of source code must retain the above copyright 9 | // notice, this list of conditions and the following disclaimer. 10 | // * Redistributions in binary form must reproduce the above 11 | // copyright notice, this list of conditions and the following disclaimer 12 | // in the documentation and/or other materials provided with the 13 | // distribution. 14 | // * Neither the name of Google Inc. nor the names of its 15 | // contributors may be used to endorse or promote products derived from 16 | // this software without specific prior written permission. 17 | // 18 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 19 | // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 20 | // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 21 | // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 22 | // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 23 | // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 24 | // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 25 | // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 26 | // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 27 | // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 28 | // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 29 | // 30 | // Author: wan@google.com (Zhanyong Wan) 31 | 32 | #include 33 | 34 | #include "test/gtest-typed-test_test.h" 35 | #include "gtest/gtest.h" 36 | 37 | #if GTEST_HAS_TYPED_TEST_P 38 | 39 | // Tests that the same type-parameterized test case can be 40 | // instantiated in different translation units linked together. 41 | // (ContainerTest is also instantiated in gtest-typed-test_test.cc.) 42 | INSTANTIATE_TYPED_TEST_CASE_P(Vector, ContainerTest, 43 | testing::Types >); 44 | 45 | #endif // GTEST_HAS_TYPED_TEST_P 46 | -------------------------------------------------------------------------------- /gtest-1.6.0/test/gtest_all_test.cc: -------------------------------------------------------------------------------- 1 | // Copyright 2009, Google Inc. 2 | // All rights reserved. 3 | // 4 | // Redistribution and use in source and binary forms, with or without 5 | // modification, are permitted provided that the following conditions are 6 | // met: 7 | // 8 | // * Redistributions of source code must retain the above copyright 9 | // notice, this list of conditions and the following disclaimer. 10 | // * Redistributions in binary form must reproduce the above 11 | // copyright notice, this list of conditions and the following disclaimer 12 | // in the documentation and/or other materials provided with the 13 | // distribution. 14 | // * Neither the name of Google Inc. nor the names of its 15 | // contributors may be used to endorse or promote products derived from 16 | // this software without specific prior written permission. 17 | // 18 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 19 | // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 20 | // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 21 | // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 22 | // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 23 | // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 24 | // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 25 | // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 26 | // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 27 | // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 28 | // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 29 | // 30 | // Author: wan@google.com (Zhanyong Wan) 31 | // 32 | // Tests for Google C++ Testing Framework (Google Test) 33 | // 34 | // Sometimes it's desirable to build most of Google Test's own tests 35 | // by compiling a single file. This file serves this purpose. 36 | #include "test/gtest-filepath_test.cc" 37 | #include "test/gtest-linked_ptr_test.cc" 38 | #include "test/gtest-message_test.cc" 39 | #include "test/gtest-options_test.cc" 40 | #include "test/gtest-port_test.cc" 41 | #include "test/gtest_pred_impl_unittest.cc" 42 | #include "test/gtest_prod_test.cc" 43 | #include "test/gtest-test-part_test.cc" 44 | #include "test/gtest-typed-test_test.cc" 45 | #include "test/gtest-typed-test2_test.cc" 46 | #include "test/gtest_unittest.cc" 47 | #include "test/production.cc" 48 | -------------------------------------------------------------------------------- /gtest-1.6.0/test/gtest_help_test_.cc: -------------------------------------------------------------------------------- 1 | // Copyright 2009, Google Inc. 2 | // All rights reserved. 3 | // 4 | // Redistribution and use in source and binary forms, with or without 5 | // modification, are permitted provided that the following conditions are 6 | // met: 7 | // 8 | // * Redistributions of source code must retain the above copyright 9 | // notice, this list of conditions and the following disclaimer. 10 | // * Redistributions in binary form must reproduce the above 11 | // copyright notice, this list of conditions and the following disclaimer 12 | // in the documentation and/or other materials provided with the 13 | // distribution. 14 | // * Neither the name of Google Inc. nor the names of its 15 | // contributors may be used to endorse or promote products derived from 16 | // this software without specific prior written permission. 17 | // 18 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 19 | // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 20 | // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 21 | // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 22 | // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 23 | // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 24 | // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 25 | // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 26 | // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 27 | // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 28 | // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 29 | // 30 | // Author: wan@google.com (Zhanyong Wan) 31 | 32 | // This program is meant to be run by gtest_help_test.py. Do not run 33 | // it directly. 34 | 35 | #include "gtest/gtest.h" 36 | 37 | // When a help flag is specified, this program should skip the tests 38 | // and exit with 0; otherwise the following test will be executed, 39 | // causing this program to exit with a non-zero code. 40 | TEST(HelpFlagTest, ShouldNotBeRun) { 41 | ASSERT_TRUE(false) << "Tests shouldn't be run when --help is specified."; 42 | } 43 | 44 | #if GTEST_HAS_DEATH_TEST 45 | TEST(DeathTest, UsedByPythonScriptToDetectSupportForDeathTestsInThisBinary) {} 46 | #endif 47 | -------------------------------------------------------------------------------- /gtest-1.6.0/test/gtest_main_unittest.cc: -------------------------------------------------------------------------------- 1 | // Copyright 2006, Google Inc. 2 | // All rights reserved. 3 | // 4 | // Redistribution and use in source and binary forms, with or without 5 | // modification, are permitted provided that the following conditions are 6 | // met: 7 | // 8 | // * Redistributions of source code must retain the above copyright 9 | // notice, this list of conditions and the following disclaimer. 10 | // * Redistributions in binary form must reproduce the above 11 | // copyright notice, this list of conditions and the following disclaimer 12 | // in the documentation and/or other materials provided with the 13 | // distribution. 14 | // * Neither the name of Google Inc. nor the names of its 15 | // contributors may be used to endorse or promote products derived from 16 | // this software without specific prior written permission. 17 | // 18 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 19 | // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 20 | // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 21 | // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 22 | // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 23 | // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 24 | // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 25 | // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 26 | // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 27 | // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 28 | // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 29 | // 30 | // Author: wan@google.com (Zhanyong Wan) 31 | 32 | #include "gtest/gtest.h" 33 | 34 | // Tests that we don't have to define main() when we link to 35 | // gtest_main instead of gtest. 36 | 37 | namespace { 38 | 39 | TEST(GTestMainTest, ShouldSucceed) { 40 | } 41 | 42 | } // namespace 43 | 44 | // We are using the main() function defined in src/gtest_main.cc, so 45 | // we don't define it here. 46 | -------------------------------------------------------------------------------- /gtest-1.6.0/test/gtest_no_test_unittest.cc: -------------------------------------------------------------------------------- 1 | // Copyright 2006, Google Inc. 2 | // All rights reserved. 3 | // 4 | // Redistribution and use in source and binary forms, with or without 5 | // modification, are permitted provided that the following conditions are 6 | // met: 7 | // 8 | // * Redistributions of source code must retain the above copyright 9 | // notice, this list of conditions and the following disclaimer. 10 | // * Redistributions in binary form must reproduce the above 11 | // copyright notice, this list of conditions and the following disclaimer 12 | // in the documentation and/or other materials provided with the 13 | // distribution. 14 | // * Neither the name of Google Inc. nor the names of its 15 | // contributors may be used to endorse or promote products derived from 16 | // this software without specific prior written permission. 17 | // 18 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 19 | // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 20 | // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 21 | // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 22 | // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 23 | // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 24 | // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 25 | // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 26 | // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 27 | // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 28 | // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 29 | 30 | // Tests that a Google Test program that has no test defined can run 31 | // successfully. 32 | // 33 | // Author: wan@google.com (Zhanyong Wan) 34 | 35 | #include "gtest/gtest.h" 36 | 37 | 38 | int main(int argc, char **argv) { 39 | testing::InitGoogleTest(&argc, argv); 40 | 41 | // An ad-hoc assertion outside of all tests. 42 | // 43 | // This serves three purposes: 44 | // 45 | // 1. It verifies that an ad-hoc assertion can be executed even if 46 | // no test is defined. 47 | // 2. It verifies that a failed ad-hoc assertion causes the test 48 | // program to fail. 49 | // 3. We had a bug where the XML output won't be generated if an 50 | // assertion is executed before RUN_ALL_TESTS() is called, even 51 | // though --gtest_output=xml is specified. This makes sure the 52 | // bug is fixed and doesn't regress. 53 | EXPECT_EQ(1, 2); 54 | 55 | // The above EXPECT_EQ() should cause RUN_ALL_TESTS() to return non-zero. 56 | return RUN_ALL_TESTS() ? 0 : 1; 57 | } 58 | -------------------------------------------------------------------------------- /gtest-1.6.0/test/gtest_prod_test.cc: -------------------------------------------------------------------------------- 1 | // Copyright 2006, Google Inc. 2 | // All rights reserved. 3 | // 4 | // Redistribution and use in source and binary forms, with or without 5 | // modification, are permitted provided that the following conditions are 6 | // met: 7 | // 8 | // * Redistributions of source code must retain the above copyright 9 | // notice, this list of conditions and the following disclaimer. 10 | // * Redistributions in binary form must reproduce the above 11 | // copyright notice, this list of conditions and the following disclaimer 12 | // in the documentation and/or other materials provided with the 13 | // distribution. 14 | // * Neither the name of Google Inc. nor the names of its 15 | // contributors may be used to endorse or promote products derived from 16 | // this software without specific prior written permission. 17 | // 18 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 19 | // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 20 | // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 21 | // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 22 | // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 23 | // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 24 | // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 25 | // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 26 | // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 27 | // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 28 | // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 29 | // 30 | // Author: wan@google.com (Zhanyong Wan) 31 | // 32 | // Unit test for include/gtest/gtest_prod.h. 33 | 34 | #include "gtest/gtest.h" 35 | #include "test/production.h" 36 | 37 | // Tests that private members can be accessed from a TEST declared as 38 | // a friend of the class. 39 | TEST(PrivateCodeTest, CanAccessPrivateMembers) { 40 | PrivateCode a; 41 | EXPECT_EQ(0, a.x_); 42 | 43 | a.set_x(1); 44 | EXPECT_EQ(1, a.x_); 45 | } 46 | 47 | typedef testing::Test PrivateCodeFixtureTest; 48 | 49 | // Tests that private members can be accessed from a TEST_F declared 50 | // as a friend of the class. 51 | TEST_F(PrivateCodeFixtureTest, CanAccessPrivateMembers) { 52 | PrivateCode a; 53 | EXPECT_EQ(0, a.x_); 54 | 55 | a.set_x(2); 56 | EXPECT_EQ(2, a.x_); 57 | } 58 | -------------------------------------------------------------------------------- /gtest-1.6.0/test/gtest_sole_header_test.cc: -------------------------------------------------------------------------------- 1 | // Copyright 2008, Google Inc. 2 | // All rights reserved. 3 | // 4 | // Redistribution and use in source and binary forms, with or without 5 | // modification, are permitted provided that the following conditions are 6 | // met: 7 | // 8 | // * Redistributions of source code must retain the above copyright 9 | // notice, this list of conditions and the following disclaimer. 10 | // * Redistributions in binary form must reproduce the above 11 | // copyright notice, this list of conditions and the following disclaimer 12 | // in the documentation and/or other materials provided with the 13 | // distribution. 14 | // * Neither the name of Google Inc. nor the names of its 15 | // contributors may be used to endorse or promote products derived from 16 | // this software without specific prior written permission. 17 | // 18 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 19 | // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 20 | // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 21 | // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 22 | // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 23 | // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 24 | // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 25 | // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 26 | // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 27 | // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 28 | // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 29 | // 30 | // Author: mheule@google.com (Markus Heule) 31 | // 32 | // This test verifies that it's possible to use Google Test by including 33 | // the gtest.h header file alone. 34 | 35 | #include "gtest/gtest.h" 36 | 37 | namespace { 38 | 39 | void Subroutine() { 40 | EXPECT_EQ(42, 42); 41 | } 42 | 43 | TEST(NoFatalFailureTest, ExpectNoFatalFailure) { 44 | EXPECT_NO_FATAL_FAILURE(;); 45 | EXPECT_NO_FATAL_FAILURE(SUCCEED()); 46 | EXPECT_NO_FATAL_FAILURE(Subroutine()); 47 | EXPECT_NO_FATAL_FAILURE({ SUCCEED(); }); 48 | } 49 | 50 | TEST(NoFatalFailureTest, AssertNoFatalFailure) { 51 | ASSERT_NO_FATAL_FAILURE(;); 52 | ASSERT_NO_FATAL_FAILURE(SUCCEED()); 53 | ASSERT_NO_FATAL_FAILURE(Subroutine()); 54 | ASSERT_NO_FATAL_FAILURE({ SUCCEED(); }); 55 | } 56 | 57 | } // namespace 58 | -------------------------------------------------------------------------------- /gtest-1.6.0/test/gtest_uninitialized_test_.cc: -------------------------------------------------------------------------------- 1 | // Copyright 2008, Google Inc. 2 | // All rights reserved. 3 | // 4 | // Redistribution and use in source and binary forms, with or without 5 | // modification, are permitted provided that the following conditions are 6 | // met: 7 | // 8 | // * Redistributions of source code must retain the above copyright 9 | // notice, this list of conditions and the following disclaimer. 10 | // * Redistributions in binary form must reproduce the above 11 | // copyright notice, this list of conditions and the following disclaimer 12 | // in the documentation and/or other materials provided with the 13 | // distribution. 14 | // * Neither the name of Google Inc. nor the names of its 15 | // contributors may be used to endorse or promote products derived from 16 | // this software without specific prior written permission. 17 | // 18 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 19 | // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 20 | // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 21 | // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 22 | // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 23 | // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 24 | // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 25 | // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 26 | // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 27 | // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 28 | // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 29 | // 30 | // Author: wan@google.com (Zhanyong Wan) 31 | 32 | #include "gtest/gtest.h" 33 | 34 | TEST(DummyTest, Dummy) { 35 | // This test doesn't verify anything. We just need it to create a 36 | // realistic stage for testing the behavior of Google Test when 37 | // RUN_ALL_TESTS() is called without testing::InitGoogleTest() being 38 | // called first. 39 | } 40 | 41 | int main() { 42 | return RUN_ALL_TESTS(); 43 | } 44 | -------------------------------------------------------------------------------- /gtest-1.6.0/test/gtest_xml_outfile1_test_.cc: -------------------------------------------------------------------------------- 1 | // Copyright 2008, Google Inc. 2 | // All rights reserved. 3 | // 4 | // Redistribution and use in source and binary forms, with or without 5 | // modification, are permitted provided that the following conditions are 6 | // met: 7 | // 8 | // * Redistributions of source code must retain the above copyright 9 | // notice, this list of conditions and the following disclaimer. 10 | // * Redistributions in binary form must reproduce the above 11 | // copyright notice, this list of conditions and the following disclaimer 12 | // in the documentation and/or other materials provided with the 13 | // distribution. 14 | // * Neither the name of Google Inc. nor the names of its 15 | // contributors may be used to endorse or promote products derived from 16 | // this software without specific prior written permission. 17 | // 18 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 19 | // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 20 | // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 21 | // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 22 | // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 23 | // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 24 | // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 25 | // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 26 | // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 27 | // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 28 | // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 29 | // 30 | // Author: keith.ray@gmail.com (Keith Ray) 31 | // 32 | // gtest_xml_outfile1_test_ writes some xml via TestProperty used by 33 | // gtest_xml_outfiles_test.py 34 | 35 | #include "gtest/gtest.h" 36 | 37 | class PropertyOne : public testing::Test { 38 | protected: 39 | virtual void SetUp() { 40 | RecordProperty("SetUpProp", 1); 41 | } 42 | virtual void TearDown() { 43 | RecordProperty("TearDownProp", 1); 44 | } 45 | }; 46 | 47 | TEST_F(PropertyOne, TestSomeProperties) { 48 | RecordProperty("TestSomeProperty", 1); 49 | } 50 | -------------------------------------------------------------------------------- /gtest-1.6.0/test/gtest_xml_outfile2_test_.cc: -------------------------------------------------------------------------------- 1 | // Copyright 2008, Google Inc. 2 | // All rights reserved. 3 | // 4 | // Redistribution and use in source and binary forms, with or without 5 | // modification, are permitted provided that the following conditions are 6 | // met: 7 | // 8 | // * Redistributions of source code must retain the above copyright 9 | // notice, this list of conditions and the following disclaimer. 10 | // * Redistributions in binary form must reproduce the above 11 | // copyright notice, this list of conditions and the following disclaimer 12 | // in the documentation and/or other materials provided with the 13 | // distribution. 14 | // * Neither the name of Google Inc. nor the names of its 15 | // contributors may be used to endorse or promote products derived from 16 | // this software without specific prior written permission. 17 | // 18 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 19 | // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 20 | // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 21 | // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 22 | // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 23 | // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 24 | // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 25 | // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 26 | // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 27 | // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 28 | // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 29 | // 30 | // Author: keith.ray@gmail.com (Keith Ray) 31 | // 32 | // gtest_xml_outfile2_test_ writes some xml via TestProperty used by 33 | // gtest_xml_outfiles_test.py 34 | 35 | #include "gtest/gtest.h" 36 | 37 | class PropertyTwo : public testing::Test { 38 | protected: 39 | virtual void SetUp() { 40 | RecordProperty("SetUpProp", 2); 41 | } 42 | virtual void TearDown() { 43 | RecordProperty("TearDownProp", 2); 44 | } 45 | }; 46 | 47 | TEST_F(PropertyTwo, TestSomeProperties) { 48 | RecordProperty("TestSomeProperty", 2); 49 | } 50 | -------------------------------------------------------------------------------- /gtest-1.6.0/test/production.cc: -------------------------------------------------------------------------------- 1 | // Copyright 2006, Google Inc. 2 | // All rights reserved. 3 | // 4 | // Redistribution and use in source and binary forms, with or without 5 | // modification, are permitted provided that the following conditions are 6 | // met: 7 | // 8 | // * Redistributions of source code must retain the above copyright 9 | // notice, this list of conditions and the following disclaimer. 10 | // * Redistributions in binary form must reproduce the above 11 | // copyright notice, this list of conditions and the following disclaimer 12 | // in the documentation and/or other materials provided with the 13 | // distribution. 14 | // * Neither the name of Google Inc. nor the names of its 15 | // contributors may be used to endorse or promote products derived from 16 | // this software without specific prior written permission. 17 | // 18 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 19 | // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 20 | // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 21 | // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 22 | // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 23 | // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 24 | // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 25 | // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 26 | // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 27 | // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 28 | // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 29 | // 30 | // Author: wan@google.com (Zhanyong Wan) 31 | // 32 | // This is part of the unit test for include/gtest/gtest_prod.h. 33 | 34 | #include "production.h" 35 | 36 | PrivateCode::PrivateCode() : x_(0) {} 37 | -------------------------------------------------------------------------------- /gtest-1.6.0/test/production.h: -------------------------------------------------------------------------------- 1 | // Copyright 2006, Google Inc. 2 | // All rights reserved. 3 | // 4 | // Redistribution and use in source and binary forms, with or without 5 | // modification, are permitted provided that the following conditions are 6 | // met: 7 | // 8 | // * Redistributions of source code must retain the above copyright 9 | // notice, this list of conditions and the following disclaimer. 10 | // * Redistributions in binary form must reproduce the above 11 | // copyright notice, this list of conditions and the following disclaimer 12 | // in the documentation and/or other materials provided with the 13 | // distribution. 14 | // * Neither the name of Google Inc. nor the names of its 15 | // contributors may be used to endorse or promote products derived from 16 | // this software without specific prior written permission. 17 | // 18 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 19 | // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 20 | // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 21 | // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 22 | // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 23 | // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 24 | // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 25 | // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 26 | // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 27 | // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 28 | // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 29 | // 30 | // Author: wan@google.com (Zhanyong Wan) 31 | // 32 | // This is part of the unit test for include/gtest/gtest_prod.h. 33 | 34 | #ifndef GTEST_TEST_PRODUCTION_H_ 35 | #define GTEST_TEST_PRODUCTION_H_ 36 | 37 | #include "gtest/gtest_prod.h" 38 | 39 | class PrivateCode { 40 | public: 41 | // Declares a friend test that does not use a fixture. 42 | FRIEND_TEST(PrivateCodeTest, CanAccessPrivateMembers); 43 | 44 | // Declares a friend test that uses a fixture. 45 | FRIEND_TEST(PrivateCodeFixtureTest, CanAccessPrivateMembers); 46 | 47 | PrivateCode(); 48 | 49 | int x() const { return x_; } 50 | private: 51 | void set_x(int an_x) { x_ = an_x; } 52 | int x_; 53 | }; 54 | 55 | #endif // GTEST_TEST_PRODUCTION_H_ 56 | -------------------------------------------------------------------------------- /gtest-1.6.0/xcode/Config/DebugProject.xcconfig: -------------------------------------------------------------------------------- 1 | // 2 | // DebugProject.xcconfig 3 | // 4 | // These are Debug Configuration project settings for the gtest framework and 5 | // examples. It is set in the "Based On:" dropdown in the "Project" info 6 | // dialog. 7 | // This file is based on the Xcode Configuration files in: 8 | // http://code.google.com/p/google-toolbox-for-mac/ 9 | // 10 | 11 | #include "General.xcconfig" 12 | 13 | // No optimization 14 | GCC_OPTIMIZATION_LEVEL = 0 15 | 16 | // Deployment postprocessing is what triggers Xcode to strip, turn it off 17 | DEPLOYMENT_POSTPROCESSING = NO 18 | 19 | // Dead code stripping off 20 | DEAD_CODE_STRIPPING = NO 21 | 22 | // Debug symbols should be on obviously 23 | GCC_GENERATE_DEBUGGING_SYMBOLS = YES 24 | 25 | // Define the DEBUG macro in all debug builds 26 | OTHER_CFLAGS = $(OTHER_CFLAGS) -DDEBUG=1 27 | 28 | // These are turned off to avoid STL incompatibilities with client code 29 | // // Turns on special C++ STL checks to "encourage" good STL use 30 | // GCC_PREPROCESSOR_DEFINITIONS = $(GCC_PREPROCESSOR_DEFINITIONS) _GLIBCXX_DEBUG_PEDANTIC _GLIBCXX_DEBUG _GLIBCPP_CONCEPT_CHECKS 31 | -------------------------------------------------------------------------------- /gtest-1.6.0/xcode/Config/FrameworkTarget.xcconfig: -------------------------------------------------------------------------------- 1 | // 2 | // FrameworkTarget.xcconfig 3 | // 4 | // These are Framework target settings for the gtest framework and examples. It 5 | // is set in the "Based On:" dropdown in the "Target" info dialog. 6 | // This file is based on the Xcode Configuration files in: 7 | // http://code.google.com/p/google-toolbox-for-mac/ 8 | // 9 | 10 | // Dynamic libs need to be position independent 11 | GCC_DYNAMIC_NO_PIC = NO 12 | 13 | // Dynamic libs should not have their external symbols stripped. 14 | STRIP_STYLE = non-global 15 | 16 | // Let the user install by specifying the $DSTROOT with xcodebuild 17 | SKIP_INSTALL = NO 18 | -------------------------------------------------------------------------------- /gtest-1.6.0/xcode/Config/General.xcconfig: -------------------------------------------------------------------------------- 1 | // 2 | // General.xcconfig 3 | // 4 | // These are General configuration settings for the gtest framework and 5 | // examples. 6 | // This file is based on the Xcode Configuration files in: 7 | // http://code.google.com/p/google-toolbox-for-mac/ 8 | // 9 | 10 | // Build for PPC and Intel, 32- and 64-bit 11 | ARCHS = i386 x86_64 ppc ppc64 12 | 13 | // Zerolink prevents link warnings so turn it off 14 | ZERO_LINK = NO 15 | 16 | // Prebinding considered unhelpful in 10.3 and later 17 | PREBINDING = NO 18 | 19 | // Strictest warning policy 20 | WARNING_CFLAGS = -Wall -Werror -Wendif-labels -Wnewline-eof -Wno-sign-compare -Wshadow 21 | 22 | // Work around Xcode bugs by using external strip. See: 23 | // http://lists.apple.com/archives/Xcode-users/2006/Feb/msg00050.html 24 | SEPARATE_STRIP = YES 25 | 26 | // Force C99 dialect 27 | GCC_C_LANGUAGE_STANDARD = c99 28 | 29 | // not sure why apple defaults this on, but it's pretty risky 30 | ALWAYS_SEARCH_USER_PATHS = NO 31 | 32 | // Turn on position dependent code for most cases (overridden where appropriate) 33 | GCC_DYNAMIC_NO_PIC = YES 34 | 35 | // Default SDK and minimum OS version is 10.4 36 | SDKROOT = $(DEVELOPER_SDK_DIR)/MacOSX10.4u.sdk 37 | MACOSX_DEPLOYMENT_TARGET = 10.4 38 | GCC_VERSION = 4.0 39 | 40 | // VERSIONING BUILD SETTINGS (used in Info.plist) 41 | GTEST_VERSIONINFO_ABOUT = © 2008 Google Inc. 42 | -------------------------------------------------------------------------------- /gtest-1.6.0/xcode/Config/ReleaseProject.xcconfig: -------------------------------------------------------------------------------- 1 | // 2 | // ReleaseProject.xcconfig 3 | // 4 | // These are Release Configuration project settings for the gtest framework 5 | // and examples. It is set in the "Based On:" dropdown in the "Project" info 6 | // dialog. 7 | // This file is based on the Xcode Configuration files in: 8 | // http://code.google.com/p/google-toolbox-for-mac/ 9 | // 10 | 11 | #include "General.xcconfig" 12 | 13 | // subconfig/Release.xcconfig 14 | 15 | // Optimize for space and size (Apple recommendation) 16 | GCC_OPTIMIZATION_LEVEL = s 17 | 18 | // Deploment postprocessing is what triggers Xcode to strip 19 | DEPLOYMENT_POSTPROCESSING = YES 20 | 21 | // No symbols 22 | GCC_GENERATE_DEBUGGING_SYMBOLS = NO 23 | 24 | // Dead code strip does not affect ObjC code but can help for C 25 | DEAD_CODE_STRIPPING = YES 26 | 27 | // NDEBUG is used by things like assert.h, so define it for general compat. 28 | // ASSERT going away in release tends to create unused vars. 29 | OTHER_CFLAGS = $(OTHER_CFLAGS) -DNDEBUG=1 -Wno-unused-variable 30 | 31 | // When we strip we want to strip all symbols in release, but save externals. 32 | STRIP_STYLE = all 33 | -------------------------------------------------------------------------------- /gtest-1.6.0/xcode/Config/StaticLibraryTarget.xcconfig: -------------------------------------------------------------------------------- 1 | // 2 | // StaticLibraryTarget.xcconfig 3 | // 4 | // These are static library target settings for libgtest.a. It 5 | // is set in the "Based On:" dropdown in the "Target" info dialog. 6 | // This file is based on the Xcode Configuration files in: 7 | // http://code.google.com/p/google-toolbox-for-mac/ 8 | // 9 | 10 | // Static libs can be included in bundles so make them position independent 11 | GCC_DYNAMIC_NO_PIC = NO 12 | 13 | // Static libs should not have their internal globals or external symbols 14 | // stripped. 15 | STRIP_STYLE = debugging 16 | 17 | // Let the user install by specifying the $DSTROOT with xcodebuild 18 | SKIP_INSTALL = NO 19 | -------------------------------------------------------------------------------- /gtest-1.6.0/xcode/Config/TestTarget.xcconfig: -------------------------------------------------------------------------------- 1 | // 2 | // TestTarget.xcconfig 3 | // 4 | // These are Test target settings for the gtest framework and examples. It 5 | // is set in the "Based On:" dropdown in the "Target" info dialog. 6 | 7 | PRODUCT_NAME = $(TARGET_NAME) 8 | HEADER_SEARCH_PATHS = ../include 9 | -------------------------------------------------------------------------------- /gtest-1.6.0/xcode/Resources/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | English 7 | CFBundleExecutable 8 | ${EXECUTABLE_NAME} 9 | CFBundleIconFile 10 | 11 | CFBundleIdentifier 12 | com.google.${PRODUCT_NAME} 13 | CFBundleInfoDictionaryVersion 14 | 6.0 15 | CFBundlePackageType 16 | FMWK 17 | CFBundleSignature 18 | ???? 19 | CFBundleVersion 20 | GTEST_VERSIONINFO_LONG 21 | CFBundleShortVersionString 22 | GTEST_VERSIONINFO_SHORT 23 | CFBundleGetInfoString 24 | ${PRODUCT_NAME} GTEST_VERSIONINFO_LONG, ${GTEST_VERSIONINFO_ABOUT} 25 | NSHumanReadableCopyright 26 | ${GTEST_VERSIONINFO_ABOUT} 27 | CSResourcesFileMapped 28 | 29 | 30 | 31 | -------------------------------------------------------------------------------- /gtest-1.6.0/xcode/Samples/FrameworkSample/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | English 7 | CFBundleExecutable 8 | ${EXECUTABLE_NAME} 9 | CFBundleIconFile 10 | 11 | CFBundleIdentifier 12 | com.google.gtest.${PRODUCT_NAME:identifier} 13 | CFBundleInfoDictionaryVersion 14 | 6.0 15 | CFBundleName 16 | ${PRODUCT_NAME} 17 | CFBundlePackageType 18 | FMWK 19 | CFBundleShortVersionString 20 | 1.0 21 | CFBundleSignature 22 | ???? 23 | CFBundleVersion 24 | 1.0 25 | CSResourcesFileMapped 26 | 27 | 28 | 29 | -------------------------------------------------------------------------------- /gtest-1.6.0/xcode/Samples/FrameworkSample/runtests.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # 3 | # Copyright 2008, Google Inc. 4 | # All rights reserved. 5 | # 6 | # Redistribution and use in source and binary forms, with or without 7 | # modification, are permitted provided that the following conditions are 8 | # met: 9 | # 10 | # * Redistributions of source code must retain the above copyright 11 | # notice, this list of conditions and the following disclaimer. 12 | # * Redistributions in binary form must reproduce the above 13 | # copyright notice, this list of conditions and the following disclaimer 14 | # in the documentation and/or other materials provided with the 15 | # distribution. 16 | # * Neither the name of Google Inc. nor the names of its 17 | # contributors may be used to endorse or promote products derived from 18 | # this software without specific prior written permission. 19 | # 20 | # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 21 | # "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 22 | # LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 23 | # A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 24 | # OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 25 | # SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 26 | # LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 27 | # DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 28 | # THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 29 | # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 30 | # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 31 | 32 | # Executes the samples and tests for the Google Test Framework. 33 | 34 | # Help the dynamic linker find the path to the libraries. 35 | export DYLD_FRAMEWORK_PATH=$BUILT_PRODUCTS_DIR 36 | export DYLD_LIBRARY_PATH=$BUILT_PRODUCTS_DIR 37 | 38 | # Create some executables. 39 | test_executables=$@ 40 | 41 | # Now execute each one in turn keeping track of how many succeeded and failed. 42 | succeeded=0 43 | failed=0 44 | failed_list=() 45 | for test in ${test_executables[*]}; do 46 | "$test" 47 | result=$? 48 | if [ $result -eq 0 ]; then 49 | succeeded=$(( $succeeded + 1 )) 50 | else 51 | failed=$(( failed + 1 )) 52 | failed_list="$failed_list $test" 53 | fi 54 | done 55 | 56 | # Report the successes and failures to the console. 57 | echo "Tests complete with $succeeded successes and $failed failures." 58 | if [ $failed -ne 0 ]; then 59 | echo "The following tests failed:" 60 | echo $failed_list 61 | fi 62 | exit $failed 63 | -------------------------------------------------------------------------------- /gtest-1.6.0/xcode/Samples/FrameworkSample/widget.cc: -------------------------------------------------------------------------------- 1 | // Copyright 2008, Google Inc. 2 | // All rights reserved. 3 | // 4 | // Redistribution and use in source and binary forms, with or without 5 | // modification, are permitted provided that the following conditions are 6 | // met: 7 | // 8 | // * Redistributions of source code must retain the above copyright 9 | // notice, this list of conditions and the following disclaimer. 10 | // * Redistributions in binary form must reproduce the above 11 | // copyright notice, this list of conditions and the following disclaimer 12 | // in the documentation and/or other materials provided with the 13 | // distribution. 14 | // * Neither the name of Google Inc. nor the names of its 15 | // contributors may be used to endorse or promote products derived from 16 | // this software without specific prior written permission. 17 | // 18 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 19 | // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 20 | // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 21 | // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 22 | // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 23 | // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 24 | // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 25 | // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 26 | // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 27 | // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 28 | // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 29 | // 30 | // Author: preston.a.jackson@gmail.com (Preston Jackson) 31 | // 32 | // Google Test - FrameworkSample 33 | // widget.cc 34 | // 35 | 36 | // Widget is a very simple class used for demonstrating the use of gtest 37 | 38 | #include "widget.h" 39 | 40 | Widget::Widget(int number, const std::string& name) 41 | : number_(number), 42 | name_(name) {} 43 | 44 | Widget::~Widget() {} 45 | 46 | float Widget::GetFloatValue() const { 47 | return number_; 48 | } 49 | 50 | int Widget::GetIntValue() const { 51 | return static_cast(number_); 52 | } 53 | 54 | std::string Widget::GetStringValue() const { 55 | return name_; 56 | } 57 | 58 | void Widget::GetCharPtrValue(char* buffer, size_t max_size) const { 59 | // Copy the char* representation of name_ into buffer, up to max_size. 60 | strncpy(buffer, name_.c_str(), max_size-1); 61 | buffer[max_size-1] = '\0'; 62 | return; 63 | } 64 | -------------------------------------------------------------------------------- /gtest-1.6.0/xcode/Samples/FrameworkSample/widget.h: -------------------------------------------------------------------------------- 1 | // Copyright 2008, Google Inc. 2 | // All rights reserved. 3 | // 4 | // Redistribution and use in source and binary forms, with or without 5 | // modification, are permitted provided that the following conditions are 6 | // met: 7 | // 8 | // * Redistributions of source code must retain the above copyright 9 | // notice, this list of conditions and the following disclaimer. 10 | // * Redistributions in binary form must reproduce the above 11 | // copyright notice, this list of conditions and the following disclaimer 12 | // in the documentation and/or other materials provided with the 13 | // distribution. 14 | // * Neither the name of Google Inc. nor the names of its 15 | // contributors may be used to endorse or promote products derived from 16 | // this software without specific prior written permission. 17 | // 18 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 19 | // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 20 | // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 21 | // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 22 | // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 23 | // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 24 | // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 25 | // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 26 | // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 27 | // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 28 | // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 29 | // 30 | // Author: preston.a.jackson@gmail.com (Preston Jackson) 31 | // 32 | // Google Test - FrameworkSample 33 | // widget.h 34 | // 35 | 36 | // Widget is a very simple class used for demonstrating the use of gtest. It 37 | // simply stores two values a string and an integer, which are returned via 38 | // public accessors in multiple forms. 39 | 40 | #import 41 | 42 | class Widget { 43 | public: 44 | Widget(int number, const std::string& name); 45 | ~Widget(); 46 | 47 | // Public accessors to number data 48 | float GetFloatValue() const; 49 | int GetIntValue() const; 50 | 51 | // Public accessors to the string data 52 | std::string GetStringValue() const; 53 | void GetCharPtrValue(char* buffer, size_t max_size) const; 54 | 55 | private: 56 | // Data members 57 | float number_; 58 | std::string name_; 59 | }; 60 | -------------------------------------------------------------------------------- /install_deps.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | if [[ $EUID -ne 0 ]]; then 4 | echo "This script must be run as root" 1>&2 5 | exit 1 6 | fi 7 | echo "Installing dependencies" 8 | 9 | sudo apt-get update -qq 10 | sudo apt-get install build-essential gcc g++ make cmake libboost-dev libprotobuf-dev protobuf-compiler libboost-thread-dev libboost-system-dev libboost-filesystem-dev libboost-program-options-dev libboost-date-time-dev libboost-regex-dev git 11 | 12 | ./install_vex.sh 13 | -------------------------------------------------------------------------------- /install_vex.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | git clone https://github.com/trailofbits/libvex.git 4 | #git clone git@github.com:trailofbits/libvex.git 5 | cd libvex 6 | CFLAGS=-g VEX_INSTALL_DIR=./build make install 7 | cd .. 8 | -------------------------------------------------------------------------------- /libs/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | add_subdirectory(IR) 2 | add_subdirectory(pe-parse) 3 | add_subdirectory(RopLib) 4 | add_subdirectory(VEE) 5 | IF(NOT WIN32) 6 | add_subdirectory(MachOLib) 7 | ENDIF(NOT WIN32) 8 | add_subdirectory(getExecSections) 9 | add_subdirectory(ExprParser) 10 | -------------------------------------------------------------------------------- /libs/ExprParser/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | include_directories(${codeReason_SOURCE_DIR}/libs/IR ) 2 | 3 | add_library(ExprParser ExprParser.cpp) 4 | -------------------------------------------------------------------------------- /libs/ExprParser/ExprAST.h: -------------------------------------------------------------------------------- 1 | //this is the AST for the expression stuff 2 | 3 | #include 4 | #include 5 | #include 6 | #include 7 | 8 | struct expression_call; 9 | 10 | typedef 11 | boost::variant< 12 | boost::recursive_wrapper, 13 | int, 14 | std::string 15 | > 16 | expression; 17 | 18 | struct expression_call 19 | { 20 | std::string symName; 21 | std::vector args; 22 | }; 23 | 24 | struct statement 25 | { 26 | expression assign; 27 | expression source; 28 | }; 29 | 30 | BOOST_FUSION_ADAPT_STRUCT( 31 | expression_call, 32 | (std::string, symName) 33 | (std::vector, args) 34 | ) 35 | 36 | BOOST_FUSION_ADAPT_STRUCT( 37 | statement, 38 | (expression, assign) 39 | (expression, source) 40 | ) 41 | 42 | typedef std::vector conditionFile; -------------------------------------------------------------------------------- /libs/ExprParser/ExprParser.h: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | 5 | class ParseFail { 6 | public: 7 | ParseFail(std::string failCause) : fc(failCause) { } 8 | 9 | std::string fc; 10 | }; 11 | 12 | class SemanticFail { 13 | public: 14 | SemanticFail(std::string failCause) : fc(failCause) { } 15 | 16 | std::string fc; 17 | }; 18 | 19 | std::vector getExprsForFile(std::string filePath); -------------------------------------------------------------------------------- /libs/IR/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | PROTOBUF_GENERATE_CPP(PROTO_SRCS PROTO_HDRS IR.proto) 2 | 3 | include_directories(${PROTOBUF_INCLUDE_DIR} ${CMAKE_CURRENT_BINARY_DIR} ${codeReason_SOURCE_DIR}/${LIBVEX_BUILD_DIR}/include) 4 | 5 | add_library(IR 6 | BasicIR.cpp 7 | Output.cpp 8 | printIR.cpp 9 | printOp.cpp 10 | Input.cpp 11 | decodeToIR.cpp 12 | VexIR.cpp 13 | Helpers.cpp 14 | IRMatcher.cpp 15 | Serial.cpp 16 | ${PROTO_SRCS} 17 | ${PROTO_HDRS}) 18 | -------------------------------------------------------------------------------- /libs/IR/Helpers.h: -------------------------------------------------------------------------------- 1 | bool transfersRegister(BlockPtr, Register); 2 | 3 | bool exprReadsRegister(ExpressionPtr, Register, BlockPtr); 4 | 5 | std::vector getGPRsForPlatform(TargetArch ); 6 | 7 | ConstantValue getValue(ExpressionPtr ); 8 | 9 | std::list simplifyTransfers(BlockPtr b); 10 | ExpressionPtr simplifyExpr(BlockPtr b, ExpressionPtr e); 11 | -------------------------------------------------------------------------------- /libs/IR/IRMatcher.h: -------------------------------------------------------------------------------- 1 | bool exprsMatch(ExpressionPtr, ExpressionPtr); 2 | -------------------------------------------------------------------------------- /libs/IR/Input.cpp: -------------------------------------------------------------------------------- 1 | #include "BasicIR.h" 2 | 3 | Input::Input(Block *b) { 4 | 5 | return; 6 | } 7 | -------------------------------------------------------------------------------- /libs/IR/Input.h: -------------------------------------------------------------------------------- 1 | class Input : public boost::enable_shared_from_this { 2 | private: 3 | public: 4 | Input(Block *b); 5 | }; 6 | 7 | typedef boost::shared_ptr InputPtr; 8 | -------------------------------------------------------------------------------- /libs/IR/Output.cpp: -------------------------------------------------------------------------------- 1 | #include "BasicIR.h" 2 | 3 | using namespace boost; 4 | using namespace std; 5 | 6 | list Block::getTransfers(void) { 7 | return this->transfer; 8 | } 9 | 10 | /*Transfer Block::getTransferForReg(Register r) { 11 | Transfer t; 12 | 13 | //lookup the register in our list 14 | list::iterator it = this->transfer.begin(); 15 | while( it != this->transfer.end() ) { 16 | Transfer k = *it; 17 | 18 | if( k.first == r ) { 19 | t = k; 20 | break; 21 | } 22 | ++it; 23 | } 24 | 25 | //return it 26 | 27 | return t; 28 | }*/ 29 | -------------------------------------------------------------------------------- /libs/IR/Output.h: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | /*class Output : public boost::enable_shared_from_this { 4 | private: 5 | Block *block; 6 | bool readMem; 7 | bool writeMem; 8 | bool ret; 9 | bool condBranch; 10 | bool anyCalls; 11 | std::list transfer; 12 | public: 13 | Output(Block *b); 14 | 15 | bool readsMem(void) { return this->readMem; } 16 | bool writesMem(void) { return this->writeMem; } 17 | bool returns(void) { return this->ret; } 18 | bool conditionalBranch(void) { return this->condBranch; } 19 | bool calls(void) { return this->anyCalls; } 20 | 21 | unsigned long getFollowingAddr(void); 22 | 23 | std::list getTransfers(void); 24 | 25 | Transfer getTransferForReg(Register r); 26 | }; 27 | 28 | typedef boost::shared_ptr OutputPtr;*/ 29 | -------------------------------------------------------------------------------- /libs/IR/Serial.h: -------------------------------------------------------------------------------- 1 | class ContextHandle; 2 | 3 | ContextHandle *openFile(std::string); 4 | bool appendToFile(ContextHandle *, BlockPtr); 5 | bool writeOutFile(ContextHandle *, std::string); 6 | 7 | bool writeToFile(std::string, std::string, std::list); 8 | bool readFromFile(std::string, std::string &, std::list &); 9 | -------------------------------------------------------------------------------- /libs/IR/decodeLib.h: -------------------------------------------------------------------------------- 1 | #ifndef _DECODE_LIB_H 2 | #define _DECODE_LIB_H 3 | 4 | #include "BasicIR.h" 5 | 6 | enum OptLevel { 7 | NoOpt, 8 | SomeOpt, 9 | FullOpt 10 | }; 11 | 12 | struct TargetInfo { 13 | OptLevel opLevel; 14 | unsigned long maxInstructions; 15 | unsigned long chaseThreshold;//default to 10 16 | unsigned long guestHWcaps; 17 | unsigned long hostHWcaps; 18 | TargetArch tarch; 19 | }; 20 | 21 | void * initDecodeLib(TargetInfo, bool do_throw, bool dbg_spew); 22 | 23 | void * initDecodeLib2(TargetArch, bool do_throw, bool dbg_spew); 24 | 25 | bool convertToOneBlock(void *ctx, 26 | unsigned char *buf, 27 | unsigned long bufLen, 28 | uint64_t baseAddr, 29 | TargetArch arch, 30 | unsigned int maxStatements, 31 | BlockPtr &blockOut); 32 | 33 | void finiDecodeLib(void *ctx); 34 | 35 | void initLibState(void); 36 | 37 | #endif 38 | -------------------------------------------------------------------------------- /libs/IR/decodeToIR.h: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | #include 6 | 7 | #include "BasicIR.h" 8 | #include "decodeLib.h" 9 | -------------------------------------------------------------------------------- /libs/IR/dumpIRToProto.cpp: -------------------------------------------------------------------------------- 1 | /*#include "BasicIR.h" 2 | 3 | #include "DisFmt.pb.h" 4 | 5 | std::string Block::dumpBlockToProto(void) { 6 | return ""; 7 | } 8 | 9 | DisFmt::Block 10 | convertBlockToProto(Block *b) { 11 | DisFmt::Block protoB = DisFmt::Block(); 12 | 13 | protoB.set_blockid(b->getBlockId()); 14 | protoB.set_blockstart(b->getBlockBase()); 15 | protoB.set_blockend(b->getBlockEnd()); 16 | 17 | return protoB; 18 | } 19 | 20 | std::string Flow::dumpFlowToProto(void) { 21 | DisFmt::Flow protoF = DisFmt::Flow(); 22 | //convert all the blocks to proto format 23 | std::set::iterator it = this->m_blocks.begin(); 24 | std::set::iterator e = this->m_blocks.end(); 25 | while( it != e ) { 26 | Block *b = *it; 27 | 28 | ++it; 29 | } 30 | 31 | return protoF.SerializeAsString(); 32 | }*/ 33 | #include "BasicIR.h" 34 | 35 | std::string Flow::dumpFlowToProto(void) { 36 | return ""; 37 | } -------------------------------------------------------------------------------- /libs/MachOLib/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | add_library(MachOLib mach-o.cc log.cc read_fat.cc dyld_decache.cpp DataFile.cpp) 2 | -------------------------------------------------------------------------------- /libs/MachOLib/log.cc: -------------------------------------------------------------------------------- 1 | // Copyright 2011 Shinichiro Hamaji. All rights reserved. 2 | // 3 | // Redistribution and use in source and binary forms, with or without 4 | // modification, are permitted provided that the following conditions 5 | // are met: 6 | // 7 | // 1. Redistributions of source code must retain the above copyright 8 | // notice, this list of conditions and the following disclaimer. 9 | // 10 | // 2. Redistributions in binary form must reproduce the above 11 | // copyright notice, this list of conditions and the following 12 | // disclaimer in the documentation and/or other materials 13 | // provided with the distribution. 14 | // 15 | // THIS SOFTWARE IS PROVIDED BY Shinichiro Hamaji ``AS IS'' AND ANY 16 | // EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 17 | // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 18 | // PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL Shinichiro Hamaji OR 19 | // CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 20 | // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 21 | // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF 22 | // USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 23 | // ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 24 | // OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT 25 | // OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 26 | // SUCH DAMAGE. 27 | 28 | #include "env_flags.h" 29 | 30 | DEFINE_bool(LOG, false, "Output bunch of logs"); 31 | -------------------------------------------------------------------------------- /libs/MachOLib/log.h: -------------------------------------------------------------------------------- 1 | // Copyright 2011 Shinichiro Hamaji. All rights reserved. 2 | // 3 | // Redistribution and use in source and binary forms, with or without 4 | // modification, are permitted provided that the following conditions 5 | // are met: 6 | // 7 | // 1. Redistributions of source code must retain the above copyright 8 | // notice, this list of conditions and the following disclaimer. 9 | // 10 | // 2. Redistributions in binary form must reproduce the above 11 | // copyright notice, this list of conditions and the following 12 | // disclaimer in the documentation and/or other materials 13 | // provided with the distribution. 14 | // 15 | // THIS SOFTWARE IS PROVIDED BY Shinichiro Hamaji ``AS IS'' AND ANY 16 | // EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 17 | // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 18 | // PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL Shinichiro Hamaji OR 19 | // CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 20 | // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 21 | // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF 22 | // USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 23 | // ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 24 | // OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT 25 | // OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 26 | // SUCH DAMAGE. 27 | 28 | #ifndef LOG_H_ 29 | #define LOG_H_ 30 | 31 | #include 32 | 33 | #include "env_flags.h" 34 | 35 | DECLARE_bool(LOG); 36 | 37 | #ifdef NOLOG 38 | # define LOG if (0) cout 39 | # define LOGF(...) if (0) fprintf(stderr, __VA_ARGS__) 40 | #else 41 | # define LOG if (FLAGS_LOG) cerr 42 | # define LOGF(...) if (FLAGS_LOG) fprintf(stderr, __VA_ARGS__) 43 | #endif 44 | 45 | #define ERR cerr 46 | 47 | #ifdef NDEBUG 48 | // Do an extra check to avoid warning around unused local variables. 49 | # define CHECK(r) do { if (!(r)) assert(r); } while (0) 50 | #else 51 | # define CHECK(r) assert(r); 52 | #endif 53 | 54 | #endif 55 | -------------------------------------------------------------------------------- /libs/MachOLib/read_fat.h: -------------------------------------------------------------------------------- 1 | // Copyright 2011 Shinichiro Hamaji. All rights reserved. 2 | // 3 | // Redistribution and use in source and binary forms, with or without 4 | // modification, are permitted provided that the following conditions 5 | // are met: 6 | // 7 | // 1. Redistributions of source code must retain the above copyright 8 | // notice, this list of conditions and the following disclaimer. 9 | // 10 | // 2. Redistributions in binary form must reproduce the above 11 | // copyright notice, this list of conditions and the following 12 | // disclaimer in the documentation and/or other materials 13 | // provided with the distribution. 14 | // 15 | // THIS SOFTWARE IS PROVIDED BY Shinichiro Hamaji ``AS IS'' AND ANY 16 | // EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 17 | // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 18 | // PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL Shinichiro Hamaji OR 19 | // CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 20 | // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 21 | // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF 22 | // USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 23 | // ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 24 | // OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT 25 | // OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 26 | // SUCH DAMAGE. 27 | 28 | #ifndef FAT_H_ 29 | #define FAT_H_ 30 | 31 | #include 32 | #include 33 | 34 | #include "fat.h" 35 | 36 | using namespace std; 37 | 38 | // Reads fd and fill fat info. Returns true if fd is a fat binary. 39 | bool readFatInfo(FILE *f, map* fat); 40 | 41 | #endif // FAT_H_ 42 | -------------------------------------------------------------------------------- /libs/RopLib/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | include_directories(${codeReason_SOURCE_DIR}/libs/IR ${codeReason_SOURCE_DIR}/lua-5.3.0/src ${codeReason_SOURCE_DIR}/libs/getExecSections ${codeReason_SOURCE_DIR}/${LIBVEX_BUILD_DIR}/include) 2 | 3 | add_library(RopLib 4 | RopLib.cpp) 5 | -------------------------------------------------------------------------------- /libs/RopLib/RopLib_internal.h: -------------------------------------------------------------------------------- 1 | #include "RopLib.h" 2 | #include 3 | #include 4 | 5 | /* these are some graph-theoretic definitions that only have meaning to the 6 | * state explorer. 7 | */ 8 | 9 | #include 10 | #include 11 | 12 | struct VP 13 | { 14 | /* block of code at this point */ 15 | BlockPtr block; 16 | /* current abstract state at this point */ 17 | CodeExplorationStatePtr state; 18 | }; 19 | 20 | typedef boost::adjacency_list< boost::vecS, 21 | boost::vecS, 22 | boost::bidirectionalS, 23 | VP> 24 | ROPGraph; 25 | 26 | extern "C" { 27 | #include 28 | #include 29 | #include 30 | #include 31 | } 32 | -------------------------------------------------------------------------------- /libs/VEE/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | include_directories(${codeReason_SOURCE_DIR}/libs/IR ${codeReason_SOURCE_DIR}/lua-5.3.0/src ${codeReason_SOURCE_DIR}/${LIBVEX_BUILD_DIR}/include) 2 | 3 | add_library(VEE 4 | VEE.cpp 5 | VEEOps.cpp 6 | VEEState.cpp 7 | VEECC.cpp 8 | VEEHelpers.cpp 9 | Conditions.cpp 10 | VEElua.cpp) 11 | -------------------------------------------------------------------------------- /libs/VEE/Conditions.cpp: -------------------------------------------------------------------------------- 1 | #include "VEE.h" 2 | #include 3 | 4 | using namespace std; 5 | using namespace boost; 6 | 7 | Condition::Condition(string s, TargetArch t) : cachedLoad(false) { 8 | //create a new LUA state 9 | this->state = initScript(s); 10 | this->veeState = VexExecutionStatePtr(new VexExecutionState(t)); 11 | return; 12 | } 13 | 14 | Condition::~Condition(void) { 15 | finiScript(this->state); 16 | return; 17 | } 18 | 19 | void Condition::runPreVee(VexExecutionStatePtr vss) { 20 | boost::mutex::scoped_lock l(this->stateLock); 21 | if( l ) { 22 | runPre(this->state, vss); 23 | } 24 | return; 25 | } 26 | bool Condition::runPostVee(VexExecutionStatePtr vss) { 27 | bool res = false; 28 | boost::mutex::scoped_lock l(this->stateLock); 29 | if( l ) { 30 | runPost(this->state, vss, res); 31 | } 32 | return res; 33 | } 34 | 35 | Condition *getConditionsFromFile(string fn, TargetArch t) { 36 | //simpler now! 37 | return new Condition(fn, t); 38 | } 39 | 40 | bool Condition::loaded(void) { 41 | if( this->state != NULL ) { 42 | return true; 43 | } 44 | return false; 45 | } 46 | -------------------------------------------------------------------------------- /libs/VEE/Conditions.h: -------------------------------------------------------------------------------- 1 | #ifndef VEE_COND_H 2 | #define VEE_COND_H 3 | #include 4 | 5 | class Condition { 6 | private: 7 | ScriptState *state; 8 | boost::mutex stateLock; 9 | bool cachedLoad; 10 | VexExecutionStatePtr veeState; 11 | public: 12 | Condition() { } 13 | Condition(std::string s, TargetArch t); 14 | ~Condition(void); 15 | 16 | void runPreVee(VexExecutionStatePtr vss); 17 | bool runPostVee(VexExecutionStatePtr vss); 18 | bool loaded(void); 19 | VexExecutionStatePtr getState(void) { return this->veeState; } 20 | }; 21 | 22 | Condition *getConditionsFromFile(std::string fn, TargetArch t); 23 | #endif 24 | -------------------------------------------------------------------------------- /libs/VEE/VEEHelpers.cpp: -------------------------------------------------------------------------------- 1 | #include "VEE.h" 2 | 3 | #include 4 | 5 | using namespace std; 6 | using namespace boost; 7 | 8 | uint16_t getArgLen(ExpressionPtr opArg) { 9 | uint16_t width = 0; 10 | 11 | do { 12 | if( ExConstPtr cst = dynamic_pointer_cast(opArg) ) { 13 | ConstantValue cv = cst->getVal(); 14 | 15 | assert(cv.width ==8 || cv.width == 16 || cv.width == 32 || cv.width == 64 || cv.width == 1 ); 16 | width = cv.width; 17 | break; 18 | } 19 | 20 | if( ExRdTmpPtr rdt = dynamic_pointer_cast(opArg) ) { 21 | TempValPtr tv = rdt->getTmp(); 22 | ConstantValue cv = tv->getVal(); 23 | 24 | assert(cv.width == 8 || cv.width == 16 || cv.width == 32 || cv.width == 64 || cv.width == 1 ); 25 | width = cv.width; 26 | break; 27 | } 28 | 29 | assert(!"BAD STATE"); 30 | } while( false ); 31 | 32 | return width; 33 | } 34 | 35 | void getConstArgs(vector args, vector &consts ) { 36 | 37 | for(vector::iterator it = args.begin(); 38 | it != args.end(); 39 | ++it) 40 | { 41 | ExpressionPtr exp = *it; 42 | if( ExConstPtr cst = dynamic_pointer_cast(exp) ) { 43 | ConstantValue cv = cst->getVal(); 44 | if( cv.valueIsKnown ) { 45 | consts.push_back(cv); 46 | } 47 | } 48 | 49 | if( ExRdTmpPtr rdt = dynamic_pointer_cast(exp) ) { 50 | TempValPtr tv = rdt->getTmp(); 51 | ConstantValue cv = tv->getVal(); 52 | if( cv.valueIsKnown ) { 53 | consts.push_back(cv); 54 | } 55 | } 56 | } 57 | 58 | return; 59 | } 60 | 61 | void applyPreConditions(VexExecutionStatePtr vss, Condition *c) { 62 | if( c ) { 63 | c->runPreVee(vss); 64 | } 65 | return; 66 | } 67 | 68 | bool checkPostConditions(VexExecutionStatePtr vss, Condition *c) { 69 | if( c ) { 70 | return c->runPostVee(vss); 71 | } else { 72 | return false; 73 | } 74 | } 75 | 76 | uint16_t getStrideFromWidth(uint16_t width) { 77 | switch(width) { 78 | case 8: 79 | return 1; 80 | break; 81 | case 16: 82 | return 2; 83 | break; 84 | case 32: 85 | return 4; 86 | break; 87 | case 64: 88 | return 8; 89 | break; 90 | } 91 | 92 | return 0; 93 | } 94 | -------------------------------------------------------------------------------- /libs/VEE/VEEHelpers.h: -------------------------------------------------------------------------------- 1 | void getConstArgs(std::vector args, std::vector &consts ); 2 | 3 | void applyPreConditions(VexExecutionStatePtr vss, Condition *c); 4 | bool checkPostConditions(VexExecutionStatePtr vss, Condition *c); 5 | boost::uint16_t getArgLen(ExpressionPtr opArg); 6 | boost::uint16_t getStrideFromWidth(boost::uint16_t width); 7 | -------------------------------------------------------------------------------- /libs/VEE/VEElua.h: -------------------------------------------------------------------------------- 1 | struct ScriptState { 2 | lua_State *S; 3 | int preCallbackIdx; 4 | int postCallbackIdx; 5 | }; 6 | 7 | void runPre(ScriptState *ss, VexExecutionStatePtr vss); 8 | void runPost(ScriptState *ss, VexExecutionStatePtr vss, bool &res); 9 | void runChase(ScriptState *ss, VexExecutionStatePtr vss, bool &res); 10 | void finiScript(ScriptState *ss); 11 | ScriptState *initScript(std::string scriptPath); 12 | ScriptState *initScriptFromString(std::string script); 13 | -------------------------------------------------------------------------------- /libs/getExecSections/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | include_directories(${codeReason_SOURCE_DIR}/libs ${codeReason_SOURCE_DIR}/libs/IR ${codeReason_SOURCE_DIR}/libs/pe-parse/parser-library ${codeReason_SOURCE_DIR}/libs/MachOLib ) 2 | 3 | add_library(getExecSections getExec.cpp) 4 | -------------------------------------------------------------------------------- /libs/getExecSections/getExec.h: -------------------------------------------------------------------------------- 1 | #ifndef _GET_EXEC_H 2 | #define _GET_EXEC_H 3 | 4 | #include 5 | #include 6 | 7 | /* Machine type definitions (windows) */ 8 | #define IMAGE_FILE_MACHINE_I386 0x014c 9 | #define IMAGE_FILE_MACHINE_ARM 0x01c0 10 | #define IMAGE_FILE_MACHINE_THUMB 0x01c2 11 | #define IMAGE_FILE_MACHINE_AMD64 0x8664 12 | 13 | 14 | /* File format definitions (i.e., Executable types) */ 15 | enum FileFormat { 16 | Invalid, 17 | PEFmt, 18 | ELFFmt, 19 | MachOFmt, 20 | RawFmt 21 | }; 22 | 23 | /* 24 | * Type Definitions 25 | */ 26 | 27 | /* (baseAddress, length) tuple */ 28 | typedef std::pair lenAddrT; 29 | 30 | /* (pointer to data, (baseAddress, length)) */ 31 | typedef std::pair secPT; 32 | typedef std::pair secAndArchT; 33 | 34 | /* vector of sections */ 35 | typedef std::vector secVT; 36 | 37 | 38 | /* 39 | * class ExecCodeProvider: 40 | * the new interface for getting executable sections from PE, ELF, Mach-o 41 | * and RAW file formats 42 | */ 43 | class ExecCodeProvider { 44 | private: 45 | bool err; 46 | FileFormat fmt; 47 | TargetArch arch; 48 | void *peCtx; 49 | void *elfCtx; 50 | void *machoCtx; 51 | uint8_t *buf; 52 | uint32_t bufLen; 53 | std::string fName; 54 | 55 | secVT getExecPESections(); 56 | secVT getExecELFSections(); 57 | secVT getExecMachSections(); 58 | secVT getExecMachSectionsFromBuff(uint8_t *, uint32_t, TargetArch); 59 | secVT getRaw(); 60 | 61 | public: 62 | ExecCodeProvider() : err(true) { return; } 63 | ExecCodeProvider(std::string, TargetArch, bool); 64 | 65 | TargetArch getArch(void) { return this->arch; } 66 | bool getError(void) { return this->err; } 67 | bool selectArchForFAT(TargetArch t); 68 | std::list filenames(void); 69 | secVT getExecSections(void); 70 | 71 | /* handy executable arch to TargetArch converters */ 72 | TargetArch convertPEArch(uint32_t machine_type); 73 | TargetArch convertELFArch(uint32_t machine_type); 74 | TargetArch convertMachArch(uint32_t machine_type); 75 | }; 76 | 77 | typedef boost::shared_ptr ExecCodeProviderPtr; 78 | 79 | #endif 80 | -------------------------------------------------------------------------------- /libs/pe-parse/CMakeFiles/3.2.2/CMakeCCompiler.cmake: -------------------------------------------------------------------------------- 1 | set(CMAKE_C_COMPILER "/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/cc") 2 | set(CMAKE_C_COMPILER_ARG1 "") 3 | set(CMAKE_C_COMPILER_ID "AppleClang") 4 | set(CMAKE_C_COMPILER_VERSION "6.1.0.6020049") 5 | set(CMAKE_C_COMPILE_FEATURES "c_function_prototypes;c_restrict;c_variadic_macros;c_static_assert") 6 | set(CMAKE_C90_COMPILE_FEATURES "c_function_prototypes") 7 | set(CMAKE_C99_COMPILE_FEATURES "c_restrict;c_variadic_macros") 8 | set(CMAKE_C11_COMPILE_FEATURES "c_static_assert") 9 | 10 | set(CMAKE_C_PLATFORM_ID "Darwin") 11 | set(CMAKE_C_SIMULATE_ID "") 12 | set(CMAKE_C_SIMULATE_VERSION "") 13 | 14 | set(CMAKE_AR "/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/ar") 15 | set(CMAKE_RANLIB "/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/ranlib") 16 | set(CMAKE_LINKER "/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/ld") 17 | set(CMAKE_COMPILER_IS_GNUCC ) 18 | set(CMAKE_C_COMPILER_LOADED 1) 19 | set(CMAKE_C_COMPILER_WORKS TRUE) 20 | set(CMAKE_C_ABI_COMPILED TRUE) 21 | set(CMAKE_COMPILER_IS_MINGW ) 22 | set(CMAKE_COMPILER_IS_CYGWIN ) 23 | if(CMAKE_COMPILER_IS_CYGWIN) 24 | set(CYGWIN 1) 25 | set(UNIX 1) 26 | endif() 27 | 28 | set(CMAKE_C_COMPILER_ENV_VAR "CC") 29 | 30 | if(CMAKE_COMPILER_IS_MINGW) 31 | set(MINGW 1) 32 | endif() 33 | set(CMAKE_C_COMPILER_ID_RUN 1) 34 | set(CMAKE_C_SOURCE_FILE_EXTENSIONS c;m) 35 | set(CMAKE_C_IGNORE_EXTENSIONS h;H;o;O;obj;OBJ;def;DEF;rc;RC) 36 | set(CMAKE_C_LINKER_PREFERENCE 10) 37 | 38 | # Save compiler ABI information. 39 | set(CMAKE_C_SIZEOF_DATA_PTR "8") 40 | set(CMAKE_C_COMPILER_ABI "") 41 | set(CMAKE_C_LIBRARY_ARCHITECTURE "") 42 | 43 | if(CMAKE_C_SIZEOF_DATA_PTR) 44 | set(CMAKE_SIZEOF_VOID_P "${CMAKE_C_SIZEOF_DATA_PTR}") 45 | endif() 46 | 47 | if(CMAKE_C_COMPILER_ABI) 48 | set(CMAKE_INTERNAL_PLATFORM_ABI "${CMAKE_C_COMPILER_ABI}") 49 | endif() 50 | 51 | if(CMAKE_C_LIBRARY_ARCHITECTURE) 52 | set(CMAKE_LIBRARY_ARCHITECTURE "") 53 | endif() 54 | 55 | 56 | 57 | 58 | set(CMAKE_C_IMPLICIT_LINK_LIBRARIES "/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/clang/6.1.0/lib/darwin/libclang_rt.osx.a") 59 | set(CMAKE_C_IMPLICIT_LINK_DIRECTORIES "/usr/lib;/usr/local/lib") 60 | set(CMAKE_C_IMPLICIT_LINK_FRAMEWORK_DIRECTORIES "/Library/Frameworks;/System/Library/Frameworks") 61 | 62 | 63 | 64 | -------------------------------------------------------------------------------- /libs/pe-parse/CMakeFiles/3.2.2/CMakeDetermineCompilerABI_C.bin: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lifting-bits/codereason/5c9d51fe61895ebe29cd9b6d8e60dc49d0162ea2/libs/pe-parse/CMakeFiles/3.2.2/CMakeDetermineCompilerABI_C.bin -------------------------------------------------------------------------------- /libs/pe-parse/CMakeFiles/3.2.2/CMakeDetermineCompilerABI_CXX.bin: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lifting-bits/codereason/5c9d51fe61895ebe29cd9b6d8e60dc49d0162ea2/libs/pe-parse/CMakeFiles/3.2.2/CMakeDetermineCompilerABI_CXX.bin -------------------------------------------------------------------------------- /libs/pe-parse/CMakeFiles/3.2.2/CMakeSystem.cmake: -------------------------------------------------------------------------------- 1 | set(CMAKE_HOST_SYSTEM "Darwin-14.3.0") 2 | set(CMAKE_HOST_SYSTEM_NAME "Darwin") 3 | set(CMAKE_HOST_SYSTEM_VERSION "14.3.0") 4 | set(CMAKE_HOST_SYSTEM_PROCESSOR "x86_64") 5 | 6 | 7 | 8 | set(CMAKE_SYSTEM "Darwin-14.3.0") 9 | set(CMAKE_SYSTEM_NAME "Darwin") 10 | set(CMAKE_SYSTEM_VERSION "14.3.0") 11 | set(CMAKE_SYSTEM_PROCESSOR "x86_64") 12 | 13 | set(CMAKE_CROSSCOMPILING "FALSE") 14 | 15 | set(CMAKE_SYSTEM_LOADED 1) 16 | -------------------------------------------------------------------------------- /libs/pe-parse/CMakeFiles/cmake.check_cache: -------------------------------------------------------------------------------- 1 | # This file is generated by cmake for dependency checking of the CMakeCache.txt file 2 | -------------------------------------------------------------------------------- /libs/pe-parse/CMakeFiles/feature_tests.bin: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lifting-bits/codereason/5c9d51fe61895ebe29cd9b6d8e60dc49d0162ea2/libs/pe-parse/CMakeFiles/feature_tests.bin -------------------------------------------------------------------------------- /libs/pe-parse/CMakeFiles/feature_tests.c: -------------------------------------------------------------------------------- 1 | 2 | const char features[] = {"" 3 | "C_FEATURE:" 4 | #if ((__clang_major__ * 100) + __clang_minor__) >= 400 5 | "1" 6 | #else 7 | "0" 8 | #endif 9 | "c_function_prototypes\n" 10 | "C_FEATURE:" 11 | #if ((__clang_major__ * 100) + __clang_minor__) >= 400 && defined(__STDC_VERSION__) && __STDC_VERSION__ >= 199901L 12 | "1" 13 | #else 14 | "0" 15 | #endif 16 | "c_restrict\n" 17 | "C_FEATURE:" 18 | #if ((__clang_major__ * 100) + __clang_minor__) >= 400 && defined(__STDC_VERSION__) && __STDC_VERSION__ >= 201112L 19 | "1" 20 | #else 21 | "0" 22 | #endif 23 | "c_static_assert\n" 24 | "C_FEATURE:" 25 | #if ((__clang_major__ * 100) + __clang_minor__) >= 400 && defined(__STDC_VERSION__) && __STDC_VERSION__ >= 199901L 26 | "1" 27 | #else 28 | "0" 29 | #endif 30 | "c_variadic_macros\n" 31 | 32 | }; 33 | 34 | int main(int argc, char** argv) { (void)argv; return features[argc]; } 35 | -------------------------------------------------------------------------------- /libs/pe-parse/CMakeFiles/progress.marks: -------------------------------------------------------------------------------- 1 | 2 2 | -------------------------------------------------------------------------------- /libs/pe-parse/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required (VERSION 2.8) 2 | 3 | project (pe-parse) 4 | 5 | #lets use boost for smart pointers 6 | set(BOOST_USE_MULTITHREADED ON) 7 | if(WIN32) 8 | set(Boost_USE_STATIC_LIBS ON) 9 | endif(WIN32) 10 | find_package(Boost COMPONENTS thread system filesystem program_options date_time regex REQUIRED) 11 | find_package(Threads REQUIRED) 12 | 13 | include_directories(${Boost_INCLUDE_DIRS}) 14 | 15 | add_subdirectory(parser-library) 16 | -------------------------------------------------------------------------------- /libs/pe-parse/LICENSE.txt: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2013 Andrew Ruef 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy of 6 | this software and associated documentation files (the "Software"), to deal in 7 | the Software without restriction, including without limitation the rights to 8 | use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of 9 | the Software, and to permit persons to whom the Software is furnished to do so, 10 | subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS 17 | FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR 18 | COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER 19 | IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 20 | CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 21 | -------------------------------------------------------------------------------- /libs/pe-parse/parser-library/CMakeFiles/pe-parser-library.dir/progress.make: -------------------------------------------------------------------------------- 1 | CMAKE_PROGRESS_1 = 1 2 | CMAKE_PROGRESS_2 = 2 3 | 4 | -------------------------------------------------------------------------------- /libs/pe-parse/parser-library/CMakeFiles/progress.marks: -------------------------------------------------------------------------------- 1 | 2 2 | -------------------------------------------------------------------------------- /libs/pe-parse/parser-library/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | add_library(pe-parser-library 2 | buffer.cpp 3 | parse.cpp) 4 | -------------------------------------------------------------------------------- /libs/pe-parse/parser-library/to_string.h: -------------------------------------------------------------------------------- 1 | #ifndef _TO_STRING_H 2 | #define _TO_STRING_H 3 | #include 4 | 5 | template 6 | static 7 | std::string to_string(T t, std::ios_base & (*f)(std::ios_base&)) { 8 | std::ostringstream oss; 9 | oss << f << t; 10 | return oss.str(); 11 | } 12 | #endif 13 | -------------------------------------------------------------------------------- /lua-5.3.0/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | add_subdirectory(src) 2 | -------------------------------------------------------------------------------- /lua-5.3.0/README: -------------------------------------------------------------------------------- 1 | 2 | This is Lua 5.3.0, released on 06 Jan 2015. 3 | 4 | For installation instructions, license details, and 5 | further information about Lua, see doc/readme.html. 6 | 7 | -------------------------------------------------------------------------------- /lua-5.3.0/doc/logo.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lifting-bits/codereason/5c9d51fe61895ebe29cd9b6d8e60dc49d0162ea2/lua-5.3.0/doc/logo.gif -------------------------------------------------------------------------------- /lua-5.3.0/doc/lua.css: -------------------------------------------------------------------------------- 1 | html { 2 | background-color: #F8F8F8 ; 3 | } 4 | 5 | body { 6 | border: solid #a0a0a0 1px ; 7 | border-radius: 20px ; 8 | padding: 26px ; 9 | margin: 16px ; 10 | color: #000000 ; 11 | background-color: #FFFFFF ; 12 | font-family: Helvetica, Arial, sans-serif ; 13 | text-align: justify ; 14 | } 15 | 16 | h1, h2, h3, h4 { 17 | font-family: Verdana, Geneva, sans-serif ; 18 | font-weight: normal ; 19 | font-style: normal ; 20 | } 21 | 22 | h2 { 23 | padding-top: 0.4em ; 24 | padding-bottom: 0.4em ; 25 | padding-left: 0.8em ; 26 | padding-right: 0.8em ; 27 | background-color: #D0D0FF ; 28 | border-radius: 8px ; 29 | border: solid #a0a0a0 1px ; 30 | } 31 | 32 | h3 { 33 | padding-left: 0.5em ; 34 | border-left: solid #D0D0FF 1em ; 35 | } 36 | 37 | table h3 { 38 | padding-left: 0px ; 39 | border-left: none ; 40 | } 41 | 42 | a:link { 43 | color: #000080 ; 44 | background-color: inherit ; 45 | text-decoration: none ; 46 | } 47 | 48 | a:visited { 49 | background-color: inherit ; 50 | text-decoration: none ; 51 | } 52 | 53 | a:link:hover, a:visited:hover { 54 | color: #000080 ; 55 | background-color: #D0D0FF ; 56 | border-radius: 4px; 57 | } 58 | 59 | a:link:active, a:visited:active { 60 | color: #FF0000 ; 61 | } 62 | 63 | h1 a img { 64 | vertical-align: text-bottom ; 65 | } 66 | 67 | hr { 68 | border: 0 ; 69 | height: 1px ; 70 | color: #a0a0a0 ; 71 | background-color: #a0a0a0 ; 72 | display: none ; 73 | } 74 | 75 | table hr { 76 | display: block ; 77 | } 78 | 79 | :target { 80 | background-color: #F8F8F8 ; 81 | padding: 8px ; 82 | border: solid #a0a0a0 2px ; 83 | border-radius: 8px ; 84 | } 85 | 86 | .footer { 87 | color: gray ; 88 | font-size: x-small ; 89 | } 90 | 91 | input[type=text] { 92 | border: solid #a0a0a0 2px ; 93 | border-radius: 2em ; 94 | background-image: url('images/search.png') ; 95 | background-repeat: no-repeat ; 96 | background-position: 4px center ; 97 | padding-left: 20px ; 98 | height: 2em ; 99 | } 100 | 101 | pre.session { 102 | background-color: #F8F8F8 ; 103 | padding: 1em ; 104 | border-radius: 8px ; 105 | } 106 | -------------------------------------------------------------------------------- /lua-5.3.0/doc/manual.css: -------------------------------------------------------------------------------- 1 | h3 code { 2 | font-family: inherit ; 3 | font-size: inherit ; 4 | } 5 | 6 | pre, code { 7 | font-size: 12pt ; 8 | } 9 | 10 | span.apii { 11 | float: right ; 12 | font-family: inherit ; 13 | font-style: normal ; 14 | font-size: small ; 15 | color: gray ; 16 | } 17 | 18 | p+h1, ul+h1 { 19 | font-style: normal ; 20 | padding-top: 0.4em ; 21 | padding-bottom: 0.4em ; 22 | padding-left: 16px ; 23 | margin-left: -16px ; 24 | background-color: #D0D0FF ; 25 | border-radius: 8px ; 26 | border: solid #000080 1px ; 27 | } 28 | -------------------------------------------------------------------------------- /lua-5.3.0/doc/osi-certified-72x60.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lifting-bits/codereason/5c9d51fe61895ebe29cd9b6d8e60dc49d0162ea2/lua-5.3.0/doc/osi-certified-72x60.png -------------------------------------------------------------------------------- /lua-5.3.0/src/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | add_library(lua 2 | lapi.c 3 | lauxlib.c 4 | lbaselib.c 5 | lbitlib.c 6 | lcode.c 7 | lcorolib.c 8 | lctype.c 9 | ldblib.c 10 | ldebug.c 11 | ldo.c 12 | ldump.c 13 | lfunc.c 14 | lgc.c 15 | linit.c 16 | liolib.c 17 | llex.c 18 | lmathlib.c 19 | lmem.c 20 | loadlib.c 21 | lobject.c 22 | lopcodes.c 23 | loslib.c 24 | lparser.c 25 | lstate.c 26 | lstring.c 27 | lstrlib.c 28 | ltable.c 29 | ltablib.c 30 | ltm.c 31 | lundump.c 32 | lutf8lib.c 33 | lvm.c 34 | lzio.c) 35 | 36 | -------------------------------------------------------------------------------- /lua-5.3.0/src/lapi.h: -------------------------------------------------------------------------------- 1 | /* 2 | ** $Id: lapi.h,v 2.8 2014/07/15 21:26:50 roberto Exp $ 3 | ** Auxiliary functions from Lua API 4 | ** See Copyright Notice in lua.h 5 | */ 6 | 7 | #ifndef lapi_h 8 | #define lapi_h 9 | 10 | 11 | #include "llimits.h" 12 | #include "lstate.h" 13 | 14 | #define api_incr_top(L) {L->top++; api_check(L->top <= L->ci->top, \ 15 | "stack overflow");} 16 | 17 | #define adjustresults(L,nres) \ 18 | { if ((nres) == LUA_MULTRET && L->ci->top < L->top) L->ci->top = L->top; } 19 | 20 | #define api_checknelems(L,n) api_check((n) < (L->top - L->ci->func), \ 21 | "not enough elements in the stack") 22 | 23 | 24 | #endif 25 | -------------------------------------------------------------------------------- /lua-5.3.0/src/lctype.c: -------------------------------------------------------------------------------- 1 | /* 2 | ** $Id: lctype.c,v 1.12 2014/11/02 19:19:04 roberto Exp $ 3 | ** 'ctype' functions for Lua 4 | ** See Copyright Notice in lua.h 5 | */ 6 | 7 | #define lctype_c 8 | #define LUA_CORE 9 | 10 | #include "lprefix.h" 11 | 12 | 13 | #include "lctype.h" 14 | 15 | #if !LUA_USE_CTYPE /* { */ 16 | 17 | #include 18 | 19 | LUAI_DDEF const lu_byte luai_ctype_[UCHAR_MAX + 2] = { 20 | 0x00, /* EOZ */ 21 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0. */ 22 | 0x00, 0x08, 0x08, 0x08, 0x08, 0x08, 0x00, 0x00, 23 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 1. */ 24 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 25 | 0x0c, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, /* 2. */ 26 | 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 27 | 0x16, 0x16, 0x16, 0x16, 0x16, 0x16, 0x16, 0x16, /* 3. */ 28 | 0x16, 0x16, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 29 | 0x04, 0x15, 0x15, 0x15, 0x15, 0x15, 0x15, 0x05, /* 4. */ 30 | 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 31 | 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, /* 5. */ 32 | 0x05, 0x05, 0x05, 0x04, 0x04, 0x04, 0x04, 0x05, 33 | 0x04, 0x15, 0x15, 0x15, 0x15, 0x15, 0x15, 0x05, /* 6. */ 34 | 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 35 | 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, /* 7. */ 36 | 0x05, 0x05, 0x05, 0x04, 0x04, 0x04, 0x04, 0x00, 37 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 8. */ 38 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 39 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 9. */ 40 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 41 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* a. */ 42 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 43 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* b. */ 44 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 45 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* c. */ 46 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 47 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* d. */ 48 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 49 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* e. */ 50 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 51 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* f. */ 52 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 53 | }; 54 | 55 | #endif /* } */ 56 | -------------------------------------------------------------------------------- /lua-5.3.0/src/lctype.h: -------------------------------------------------------------------------------- 1 | /* 2 | ** $Id: lctype.h,v 1.12 2011/07/15 12:50:29 roberto Exp $ 3 | ** 'ctype' functions for Lua 4 | ** See Copyright Notice in lua.h 5 | */ 6 | 7 | #ifndef lctype_h 8 | #define lctype_h 9 | 10 | #include "lua.h" 11 | 12 | 13 | /* 14 | ** WARNING: the functions defined here do not necessarily correspond 15 | ** to the similar functions in the standard C ctype.h. They are 16 | ** optimized for the specific needs of Lua 17 | */ 18 | 19 | #if !defined(LUA_USE_CTYPE) 20 | 21 | #if 'A' == 65 && '0' == 48 22 | /* ASCII case: can use its own tables; faster and fixed */ 23 | #define LUA_USE_CTYPE 0 24 | #else 25 | /* must use standard C ctype */ 26 | #define LUA_USE_CTYPE 1 27 | #endif 28 | 29 | #endif 30 | 31 | 32 | #if !LUA_USE_CTYPE /* { */ 33 | 34 | #include 35 | 36 | #include "llimits.h" 37 | 38 | 39 | #define ALPHABIT 0 40 | #define DIGITBIT 1 41 | #define PRINTBIT 2 42 | #define SPACEBIT 3 43 | #define XDIGITBIT 4 44 | 45 | 46 | #define MASK(B) (1 << (B)) 47 | 48 | 49 | /* 50 | ** add 1 to char to allow index -1 (EOZ) 51 | */ 52 | #define testprop(c,p) (luai_ctype_[(c)+1] & (p)) 53 | 54 | /* 55 | ** 'lalpha' (Lua alphabetic) and 'lalnum' (Lua alphanumeric) both include '_' 56 | */ 57 | #define lislalpha(c) testprop(c, MASK(ALPHABIT)) 58 | #define lislalnum(c) testprop(c, (MASK(ALPHABIT) | MASK(DIGITBIT))) 59 | #define lisdigit(c) testprop(c, MASK(DIGITBIT)) 60 | #define lisspace(c) testprop(c, MASK(SPACEBIT)) 61 | #define lisprint(c) testprop(c, MASK(PRINTBIT)) 62 | #define lisxdigit(c) testprop(c, MASK(XDIGITBIT)) 63 | 64 | /* 65 | ** this 'ltolower' only works for alphabetic characters 66 | */ 67 | #define ltolower(c) ((c) | ('A' ^ 'a')) 68 | 69 | 70 | /* two more entries for 0 and -1 (EOZ) */ 71 | LUAI_DDEC const lu_byte luai_ctype_[UCHAR_MAX + 2]; 72 | 73 | 74 | #else /* }{ */ 75 | 76 | /* 77 | ** use standard C ctypes 78 | */ 79 | 80 | #include 81 | 82 | 83 | #define lislalpha(c) (isalpha(c) || (c) == '_') 84 | #define lislalnum(c) (isalnum(c) || (c) == '_') 85 | #define lisdigit(c) (isdigit(c)) 86 | #define lisspace(c) (isspace(c)) 87 | #define lisprint(c) (isprint(c)) 88 | #define lisxdigit(c) (isxdigit(c)) 89 | 90 | #define ltolower(c) (tolower(c)) 91 | 92 | #endif /* } */ 93 | 94 | #endif 95 | 96 | -------------------------------------------------------------------------------- /lua-5.3.0/src/ldebug.h: -------------------------------------------------------------------------------- 1 | /* 2 | ** $Id: ldebug.h,v 2.12 2014/11/10 14:46:05 roberto Exp $ 3 | ** Auxiliary functions from Debug Interface module 4 | ** See Copyright Notice in lua.h 5 | */ 6 | 7 | #ifndef ldebug_h 8 | #define ldebug_h 9 | 10 | 11 | #include "lstate.h" 12 | 13 | 14 | #define pcRel(pc, p) (cast(int, (pc) - (p)->code) - 1) 15 | 16 | #define getfuncline(f,pc) (((f)->lineinfo) ? (f)->lineinfo[pc] : -1) 17 | 18 | #define resethookcount(L) (L->hookcount = L->basehookcount) 19 | 20 | /* Active Lua function (given call info) */ 21 | #define ci_func(ci) (clLvalue((ci)->func)) 22 | 23 | 24 | LUAI_FUNC l_noret luaG_typeerror (lua_State *L, const TValue *o, 25 | const char *opname); 26 | LUAI_FUNC l_noret luaG_concaterror (lua_State *L, const TValue *p1, 27 | const TValue *p2); 28 | LUAI_FUNC l_noret luaG_opinterror (lua_State *L, const TValue *p1, 29 | const TValue *p2, 30 | const char *msg); 31 | LUAI_FUNC l_noret luaG_tointerror (lua_State *L, const TValue *p1, 32 | const TValue *p2); 33 | LUAI_FUNC l_noret luaG_ordererror (lua_State *L, const TValue *p1, 34 | const TValue *p2); 35 | LUAI_FUNC l_noret luaG_runerror (lua_State *L, const char *fmt, ...); 36 | LUAI_FUNC l_noret luaG_errormsg (lua_State *L); 37 | LUAI_FUNC void luaG_traceexec (lua_State *L); 38 | 39 | 40 | #endif 41 | -------------------------------------------------------------------------------- /lua-5.3.0/src/ldo.h: -------------------------------------------------------------------------------- 1 | /* 2 | ** $Id: ldo.h,v 2.21 2014/10/25 11:50:46 roberto Exp $ 3 | ** Stack and Call structure of Lua 4 | ** See Copyright Notice in lua.h 5 | */ 6 | 7 | #ifndef ldo_h 8 | #define ldo_h 9 | 10 | 11 | #include "lobject.h" 12 | #include "lstate.h" 13 | #include "lzio.h" 14 | 15 | 16 | #define luaD_checkstack(L,n) if (L->stack_last - L->top <= (n)) \ 17 | luaD_growstack(L, n); else condmovestack(L); 18 | 19 | 20 | #define incr_top(L) {L->top++; luaD_checkstack(L,0);} 21 | 22 | #define savestack(L,p) ((char *)(p) - (char *)L->stack) 23 | #define restorestack(L,n) ((TValue *)((char *)L->stack + (n))) 24 | 25 | 26 | /* type of protected functions, to be ran by 'runprotected' */ 27 | typedef void (*Pfunc) (lua_State *L, void *ud); 28 | 29 | LUAI_FUNC int luaD_protectedparser (lua_State *L, ZIO *z, const char *name, 30 | const char *mode); 31 | LUAI_FUNC void luaD_hook (lua_State *L, int event, int line); 32 | LUAI_FUNC int luaD_precall (lua_State *L, StkId func, int nresults); 33 | LUAI_FUNC void luaD_call (lua_State *L, StkId func, int nResults, 34 | int allowyield); 35 | LUAI_FUNC int luaD_pcall (lua_State *L, Pfunc func, void *u, 36 | ptrdiff_t oldtop, ptrdiff_t ef); 37 | LUAI_FUNC int luaD_poscall (lua_State *L, StkId firstResult); 38 | LUAI_FUNC void luaD_reallocstack (lua_State *L, int newsize); 39 | LUAI_FUNC void luaD_growstack (lua_State *L, int n); 40 | LUAI_FUNC void luaD_shrinkstack (lua_State *L); 41 | 42 | LUAI_FUNC l_noret luaD_throw (lua_State *L, int errcode); 43 | LUAI_FUNC int luaD_rawrunprotected (lua_State *L, Pfunc f, void *ud); 44 | 45 | #endif 46 | 47 | -------------------------------------------------------------------------------- /lua-5.3.0/src/lfunc.h: -------------------------------------------------------------------------------- 1 | /* 2 | ** $Id: lfunc.h,v 2.14 2014/06/19 18:27:20 roberto Exp $ 3 | ** Auxiliary functions to manipulate prototypes and closures 4 | ** See Copyright Notice in lua.h 5 | */ 6 | 7 | #ifndef lfunc_h 8 | #define lfunc_h 9 | 10 | 11 | #include "lobject.h" 12 | 13 | 14 | #define sizeCclosure(n) (cast(int, sizeof(CClosure)) + \ 15 | cast(int, sizeof(TValue)*((n)-1))) 16 | 17 | #define sizeLclosure(n) (cast(int, sizeof(LClosure)) + \ 18 | cast(int, sizeof(TValue *)*((n)-1))) 19 | 20 | 21 | /* test whether thread is in 'twups' list */ 22 | #define isintwups(L) (L->twups != L) 23 | 24 | 25 | /* 26 | ** Upvalues for Lua closures 27 | */ 28 | struct UpVal { 29 | TValue *v; /* points to stack or to its own value */ 30 | lu_mem refcount; /* reference counter */ 31 | union { 32 | struct { /* (when open) */ 33 | UpVal *next; /* linked list */ 34 | int touched; /* mark to avoid cycles with dead threads */ 35 | } open; 36 | TValue value; /* the value (when closed) */ 37 | } u; 38 | }; 39 | 40 | #define upisopen(up) ((up)->v != &(up)->u.value) 41 | 42 | 43 | LUAI_FUNC Proto *luaF_newproto (lua_State *L); 44 | LUAI_FUNC CClosure *luaF_newCclosure (lua_State *L, int nelems); 45 | LUAI_FUNC LClosure *luaF_newLclosure (lua_State *L, int nelems); 46 | LUAI_FUNC void luaF_initupvals (lua_State *L, LClosure *cl); 47 | LUAI_FUNC UpVal *luaF_findupval (lua_State *L, StkId level); 48 | LUAI_FUNC void luaF_close (lua_State *L, StkId level); 49 | LUAI_FUNC void luaF_freeproto (lua_State *L, Proto *f); 50 | LUAI_FUNC const char *luaF_getlocalname (const Proto *func, int local_number, 51 | int pc); 52 | 53 | 54 | #endif 55 | -------------------------------------------------------------------------------- /lua-5.3.0/src/linit.c: -------------------------------------------------------------------------------- 1 | /* 2 | ** $Id: linit.c,v 1.38 2015/01/05 13:48:33 roberto Exp $ 3 | ** Initialization of libraries for lua.c and other clients 4 | ** See Copyright Notice in lua.h 5 | */ 6 | 7 | 8 | #define linit_c 9 | #define LUA_LIB 10 | 11 | /* 12 | ** If you embed Lua in your program and need to open the standard 13 | ** libraries, call luaL_openlibs in your program. If you need a 14 | ** different set of libraries, copy this file to your project and edit 15 | ** it to suit your needs. 16 | ** 17 | ** You can also *preload* libraries, so that a later 'require' can 18 | ** open the library, which is already linked to the application. 19 | ** For that, do the following code: 20 | ** 21 | ** luaL_getsubtable(L, LUA_REGISTRYINDEX, "_PRELOAD"); 22 | ** lua_pushcfunction(L, luaopen_modname); 23 | ** lua_setfield(L, -2, modname); 24 | ** lua_pop(L, 1); // remove _PRELOAD table 25 | */ 26 | 27 | #include "lprefix.h" 28 | 29 | 30 | #include 31 | 32 | #include "lua.h" 33 | 34 | #include "lualib.h" 35 | #include "lauxlib.h" 36 | 37 | 38 | /* 39 | ** these libs are loaded by lua.c and are readily available to any Lua 40 | ** program 41 | */ 42 | static const luaL_Reg loadedlibs[] = { 43 | {"_G", luaopen_base}, 44 | {LUA_LOADLIBNAME, luaopen_package}, 45 | {LUA_COLIBNAME, luaopen_coroutine}, 46 | {LUA_TABLIBNAME, luaopen_table}, 47 | {LUA_IOLIBNAME, luaopen_io}, 48 | {LUA_OSLIBNAME, luaopen_os}, 49 | {LUA_STRLIBNAME, luaopen_string}, 50 | {LUA_MATHLIBNAME, luaopen_math}, 51 | {LUA_UTF8LIBNAME, luaopen_utf8}, 52 | {LUA_DBLIBNAME, luaopen_debug}, 53 | #if defined(LUA_COMPAT_BITLIB) 54 | {LUA_BITLIBNAME, luaopen_bit32}, 55 | #endif 56 | {NULL, NULL} 57 | }; 58 | 59 | 60 | LUALIB_API void luaL_openlibs (lua_State *L) { 61 | const luaL_Reg *lib; 62 | /* "require" functions from 'loadedlibs' and set results to global table */ 63 | for (lib = loadedlibs; lib->func; lib++) { 64 | luaL_requiref(L, lib->name, lib->func, 1); 65 | lua_pop(L, 1); /* remove lib */ 66 | } 67 | } 68 | 69 | -------------------------------------------------------------------------------- /lua-5.3.0/src/llex.h: -------------------------------------------------------------------------------- 1 | /* 2 | ** $Id: llex.h,v 1.78 2014/10/29 15:38:24 roberto Exp $ 3 | ** Lexical Analyzer 4 | ** See Copyright Notice in lua.h 5 | */ 6 | 7 | #ifndef llex_h 8 | #define llex_h 9 | 10 | #include "lobject.h" 11 | #include "lzio.h" 12 | 13 | 14 | #define FIRST_RESERVED 257 15 | 16 | 17 | #if !defined(LUA_ENV) 18 | #define LUA_ENV "_ENV" 19 | #endif 20 | 21 | 22 | /* 23 | * WARNING: if you change the order of this enumeration, 24 | * grep "ORDER RESERVED" 25 | */ 26 | enum RESERVED { 27 | /* terminal symbols denoted by reserved words */ 28 | TK_AND = FIRST_RESERVED, TK_BREAK, 29 | TK_DO, TK_ELSE, TK_ELSEIF, TK_END, TK_FALSE, TK_FOR, TK_FUNCTION, 30 | TK_GOTO, TK_IF, TK_IN, TK_LOCAL, TK_NIL, TK_NOT, TK_OR, TK_REPEAT, 31 | TK_RETURN, TK_THEN, TK_TRUE, TK_UNTIL, TK_WHILE, 32 | /* other terminal symbols */ 33 | TK_IDIV, TK_CONCAT, TK_DOTS, TK_EQ, TK_GE, TK_LE, TK_NE, 34 | TK_SHL, TK_SHR, 35 | TK_DBCOLON, TK_EOS, 36 | TK_FLT, TK_INT, TK_NAME, TK_STRING 37 | }; 38 | 39 | /* number of reserved words */ 40 | #define NUM_RESERVED (cast(int, TK_WHILE-FIRST_RESERVED+1)) 41 | 42 | 43 | typedef union { 44 | lua_Number r; 45 | lua_Integer i; 46 | TString *ts; 47 | } SemInfo; /* semantics information */ 48 | 49 | 50 | typedef struct Token { 51 | int token; 52 | SemInfo seminfo; 53 | } Token; 54 | 55 | 56 | /* state of the lexer plus state of the parser when shared by all 57 | functions */ 58 | typedef struct LexState { 59 | int current; /* current character (charint) */ 60 | int linenumber; /* input line counter */ 61 | int lastline; /* line of last token 'consumed' */ 62 | Token t; /* current token */ 63 | Token lookahead; /* look ahead token */ 64 | struct FuncState *fs; /* current function (parser) */ 65 | struct lua_State *L; 66 | ZIO *z; /* input stream */ 67 | Mbuffer *buff; /* buffer for tokens */ 68 | Table *h; /* to avoid collection/reuse strings */ 69 | struct Dyndata *dyd; /* dynamic structures used by the parser */ 70 | TString *source; /* current source name */ 71 | TString *envn; /* environment variable name */ 72 | char decpoint; /* locale decimal point */ 73 | } LexState; 74 | 75 | 76 | LUAI_FUNC void luaX_init (lua_State *L); 77 | LUAI_FUNC void luaX_setinput (lua_State *L, LexState *ls, ZIO *z, 78 | TString *source, int firstchar); 79 | LUAI_FUNC TString *luaX_newstring (LexState *ls, const char *str, size_t l); 80 | LUAI_FUNC void luaX_next (LexState *ls); 81 | LUAI_FUNC int luaX_lookahead (LexState *ls); 82 | LUAI_FUNC l_noret luaX_syntaxerror (LexState *ls, const char *s); 83 | LUAI_FUNC const char *luaX_token2str (LexState *ls, int token); 84 | 85 | 86 | #endif 87 | -------------------------------------------------------------------------------- /lua-5.3.0/src/lmem.h: -------------------------------------------------------------------------------- 1 | /* 2 | ** $Id: lmem.h,v 1.43 2014/12/19 17:26:14 roberto Exp $ 3 | ** Interface to Memory Manager 4 | ** See Copyright Notice in lua.h 5 | */ 6 | 7 | #ifndef lmem_h 8 | #define lmem_h 9 | 10 | 11 | #include 12 | 13 | #include "llimits.h" 14 | #include "lua.h" 15 | 16 | 17 | /* 18 | ** This macro reallocs a vector 'b' from 'on' to 'n' elements, where 19 | ** each element has size 'e'. In case of arithmetic overflow of the 20 | ** product 'n'*'e', it raises an error (calling 'luaM_toobig'). Because 21 | ** 'e' is always constant, it avoids the runtime division MAX_SIZET/(e). 22 | ** 23 | ** (The macro is somewhat complex to avoid warnings: The 'sizeof' 24 | ** comparison avoids a runtime comparison when overflow cannot occur. 25 | ** The compiler should be able to optimize the real test by itself, but 26 | ** when it does it, it may give a warning about "comparison is always 27 | ** false due to limited range of data type"; the +1 tricks the compiler, 28 | ** avoiding this warning but also this optimization.) 29 | */ 30 | #define luaM_reallocv(L,b,on,n,e) \ 31 | (((sizeof(n) >= sizeof(size_t) && cast(size_t, (n)) + 1 > MAX_SIZET/(e)) \ 32 | ? luaM_toobig(L) : cast_void(0)) , \ 33 | luaM_realloc_(L, (b), (on)*(e), (n)*(e))) 34 | 35 | /* 36 | ** Arrays of chars do not need any test 37 | */ 38 | #define luaM_reallocvchar(L,b,on,n) \ 39 | cast(char *, luaM_realloc_(L, (b), (on)*sizeof(char), (n)*sizeof(char))) 40 | 41 | #define luaM_freemem(L, b, s) luaM_realloc_(L, (b), (s), 0) 42 | #define luaM_free(L, b) luaM_realloc_(L, (b), sizeof(*(b)), 0) 43 | #define luaM_freearray(L, b, n) luaM_realloc_(L, (b), (n)*sizeof(*(b)), 0) 44 | 45 | #define luaM_malloc(L,s) luaM_realloc_(L, NULL, 0, (s)) 46 | #define luaM_new(L,t) cast(t *, luaM_malloc(L, sizeof(t))) 47 | #define luaM_newvector(L,n,t) \ 48 | cast(t *, luaM_reallocv(L, NULL, 0, n, sizeof(t))) 49 | 50 | #define luaM_newobject(L,tag,s) luaM_realloc_(L, NULL, tag, (s)) 51 | 52 | #define luaM_growvector(L,v,nelems,size,t,limit,e) \ 53 | if ((nelems)+1 > (size)) \ 54 | ((v)=cast(t *, luaM_growaux_(L,v,&(size),sizeof(t),limit,e))) 55 | 56 | #define luaM_reallocvector(L, v,oldn,n,t) \ 57 | ((v)=cast(t *, luaM_reallocv(L, v, oldn, n, sizeof(t)))) 58 | 59 | LUAI_FUNC l_noret luaM_toobig (lua_State *L); 60 | 61 | /* not to be called directly */ 62 | LUAI_FUNC void *luaM_realloc_ (lua_State *L, void *block, size_t oldsize, 63 | size_t size); 64 | LUAI_FUNC void *luaM_growaux_ (lua_State *L, void *block, int *size, 65 | size_t size_elem, int limit, 66 | const char *what); 67 | 68 | #endif 69 | 70 | -------------------------------------------------------------------------------- /lua-5.3.0/src/lprefix.h: -------------------------------------------------------------------------------- 1 | /* 2 | ** $Id: lprefix.h,v 1.2 2014/12/29 16:54:13 roberto Exp $ 3 | ** Definitions for Lua code that must come before any other header file 4 | ** See Copyright Notice in lua.h 5 | */ 6 | 7 | #ifndef lprefix_h 8 | #define lprefix_h 9 | 10 | 11 | /* 12 | ** Allows POSIX/XSI stuff 13 | */ 14 | #if !defined(LUA_USE_C89) /* { */ 15 | 16 | #if !defined(_XOPEN_SOURCE) 17 | #define _XOPEN_SOURCE 600 18 | #elif _XOPEN_SOURCE == 0 19 | #undef _XOPEN_SOURCE /* use -D_XOPEN_SOURCE=0 to undefine it */ 20 | #endif 21 | 22 | /* 23 | ** Allows manipulation of large files in gcc and some other compilers 24 | */ 25 | #if !defined(LUA_32BITS) && !defined(_FILE_OFFSET_BITS) 26 | #define _LARGEFILE_SOURCE 1 27 | #define _FILE_OFFSET_BITS 64 28 | #endif 29 | 30 | #endif /* } */ 31 | 32 | 33 | /* 34 | ** Windows stuff 35 | */ 36 | #if defined(_WIN32) /* { */ 37 | 38 | #if !defined(_CRT_SECURE_NO_WARNINGS) 39 | #define _CRT_SECURE_NO_WARNINGS /* avoid warnings about ISO C functions */ 40 | #endif 41 | 42 | #endif /* } */ 43 | 44 | #endif 45 | 46 | -------------------------------------------------------------------------------- /lua-5.3.0/src/lstring.h: -------------------------------------------------------------------------------- 1 | /* 2 | ** $Id: lstring.h,v 1.56 2014/07/18 14:46:47 roberto Exp $ 3 | ** String table (keep all strings handled by Lua) 4 | ** See Copyright Notice in lua.h 5 | */ 6 | 7 | #ifndef lstring_h 8 | #define lstring_h 9 | 10 | #include "lgc.h" 11 | #include "lobject.h" 12 | #include "lstate.h" 13 | 14 | 15 | #define sizelstring(l) (sizeof(union UTString) + ((l) + 1) * sizeof(char)) 16 | #define sizestring(s) sizelstring((s)->len) 17 | 18 | #define sizeludata(l) (sizeof(union UUdata) + (l)) 19 | #define sizeudata(u) sizeludata((u)->len) 20 | 21 | #define luaS_newliteral(L, s) (luaS_newlstr(L, "" s, \ 22 | (sizeof(s)/sizeof(char))-1)) 23 | 24 | 25 | /* 26 | ** test whether a string is a reserved word 27 | */ 28 | #define isreserved(s) ((s)->tt == LUA_TSHRSTR && (s)->extra > 0) 29 | 30 | 31 | /* 32 | ** equality for short strings, which are always internalized 33 | */ 34 | #define eqshrstr(a,b) check_exp((a)->tt == LUA_TSHRSTR, (a) == (b)) 35 | 36 | 37 | LUAI_FUNC unsigned int luaS_hash (const char *str, size_t l, unsigned int seed); 38 | LUAI_FUNC int luaS_eqlngstr (TString *a, TString *b); 39 | LUAI_FUNC void luaS_resize (lua_State *L, int newsize); 40 | LUAI_FUNC void luaS_remove (lua_State *L, TString *ts); 41 | LUAI_FUNC Udata *luaS_newudata (lua_State *L, size_t s); 42 | LUAI_FUNC TString *luaS_newlstr (lua_State *L, const char *str, size_t l); 43 | LUAI_FUNC TString *luaS_new (lua_State *L, const char *str); 44 | 45 | 46 | #endif 47 | -------------------------------------------------------------------------------- /lua-5.3.0/src/ltable.h: -------------------------------------------------------------------------------- 1 | /* 2 | ** $Id: ltable.h,v 2.20 2014/09/04 18:15:29 roberto Exp $ 3 | ** Lua tables (hash) 4 | ** See Copyright Notice in lua.h 5 | */ 6 | 7 | #ifndef ltable_h 8 | #define ltable_h 9 | 10 | #include "lobject.h" 11 | 12 | 13 | #define gnode(t,i) (&(t)->node[i]) 14 | #define gval(n) (&(n)->i_val) 15 | #define gnext(n) ((n)->i_key.nk.next) 16 | 17 | 18 | /* 'const' to avoid wrong writings that can mess up field 'next' */ 19 | #define gkey(n) cast(const TValue*, (&(n)->i_key.tvk)) 20 | 21 | #define wgkey(n) (&(n)->i_key.nk) 22 | 23 | #define invalidateTMcache(t) ((t)->flags = 0) 24 | 25 | 26 | /* returns the key, given the value of a table entry */ 27 | #define keyfromval(v) \ 28 | (gkey(cast(Node *, cast(char *, (v)) - offsetof(Node, i_val)))) 29 | 30 | 31 | LUAI_FUNC const TValue *luaH_getint (Table *t, lua_Integer key); 32 | LUAI_FUNC void luaH_setint (lua_State *L, Table *t, lua_Integer key, 33 | TValue *value); 34 | LUAI_FUNC const TValue *luaH_getstr (Table *t, TString *key); 35 | LUAI_FUNC const TValue *luaH_get (Table *t, const TValue *key); 36 | LUAI_FUNC TValue *luaH_newkey (lua_State *L, Table *t, const TValue *key); 37 | LUAI_FUNC TValue *luaH_set (lua_State *L, Table *t, const TValue *key); 38 | LUAI_FUNC Table *luaH_new (lua_State *L); 39 | LUAI_FUNC void luaH_resize (lua_State *L, Table *t, unsigned int nasize, 40 | unsigned int nhsize); 41 | LUAI_FUNC void luaH_resizearray (lua_State *L, Table *t, unsigned int nasize); 42 | LUAI_FUNC void luaH_free (lua_State *L, Table *t); 43 | LUAI_FUNC int luaH_next (lua_State *L, Table *t, StkId key); 44 | LUAI_FUNC int luaH_getn (Table *t); 45 | 46 | 47 | #if defined(LUA_DEBUG) 48 | LUAI_FUNC Node *luaH_mainposition (const Table *t, const TValue *key); 49 | LUAI_FUNC int luaH_isdummy (Node *n); 50 | #endif 51 | 52 | 53 | #endif 54 | -------------------------------------------------------------------------------- /lua-5.3.0/src/ltm.h: -------------------------------------------------------------------------------- 1 | /* 2 | ** $Id: ltm.h,v 2.21 2014/10/25 11:50:46 roberto Exp $ 3 | ** Tag methods 4 | ** See Copyright Notice in lua.h 5 | */ 6 | 7 | #ifndef ltm_h 8 | #define ltm_h 9 | 10 | 11 | #include "lobject.h" 12 | 13 | 14 | /* 15 | * WARNING: if you change the order of this enumeration, 16 | * grep "ORDER TM" and "ORDER OP" 17 | */ 18 | typedef enum { 19 | TM_INDEX, 20 | TM_NEWINDEX, 21 | TM_GC, 22 | TM_MODE, 23 | TM_LEN, 24 | TM_EQ, /* last tag method with fast access */ 25 | TM_ADD, 26 | TM_SUB, 27 | TM_MUL, 28 | TM_MOD, 29 | TM_POW, 30 | TM_DIV, 31 | TM_IDIV, 32 | TM_BAND, 33 | TM_BOR, 34 | TM_BXOR, 35 | TM_SHL, 36 | TM_SHR, 37 | TM_UNM, 38 | TM_BNOT, 39 | TM_LT, 40 | TM_LE, 41 | TM_CONCAT, 42 | TM_CALL, 43 | TM_N /* number of elements in the enum */ 44 | } TMS; 45 | 46 | 47 | 48 | #define gfasttm(g,et,e) ((et) == NULL ? NULL : \ 49 | ((et)->flags & (1u<<(e))) ? NULL : luaT_gettm(et, e, (g)->tmname[e])) 50 | 51 | #define fasttm(l,et,e) gfasttm(G(l), et, e) 52 | 53 | #define ttypename(x) luaT_typenames_[(x) + 1] 54 | #define objtypename(x) ttypename(ttnov(x)) 55 | 56 | LUAI_DDEC const char *const luaT_typenames_[LUA_TOTALTAGS]; 57 | 58 | 59 | LUAI_FUNC const TValue *luaT_gettm (Table *events, TMS event, TString *ename); 60 | LUAI_FUNC const TValue *luaT_gettmbyobj (lua_State *L, const TValue *o, 61 | TMS event); 62 | LUAI_FUNC void luaT_init (lua_State *L); 63 | 64 | LUAI_FUNC void luaT_callTM (lua_State *L, const TValue *f, const TValue *p1, 65 | const TValue *p2, TValue *p3, int hasres); 66 | LUAI_FUNC int luaT_callbinTM (lua_State *L, const TValue *p1, const TValue *p2, 67 | StkId res, TMS event); 68 | LUAI_FUNC void luaT_trybinTM (lua_State *L, const TValue *p1, const TValue *p2, 69 | StkId res, TMS event); 70 | LUAI_FUNC int luaT_callorderTM (lua_State *L, const TValue *p1, 71 | const TValue *p2, TMS event); 72 | 73 | 74 | 75 | #endif 76 | -------------------------------------------------------------------------------- /lua-5.3.0/src/lua.hpp: -------------------------------------------------------------------------------- 1 | // lua.hpp 2 | // Lua header files for C++ 3 | // <> not supplied automatically because Lua also compiles as C++ 4 | 5 | extern "C" { 6 | #include "lua.h" 7 | #include "lualib.h" 8 | #include "lauxlib.h" 9 | } 10 | -------------------------------------------------------------------------------- /lua-5.3.0/src/lualib.h: -------------------------------------------------------------------------------- 1 | /* 2 | ** $Id: lualib.h,v 1.44 2014/02/06 17:32:33 roberto Exp $ 3 | ** Lua standard libraries 4 | ** See Copyright Notice in lua.h 5 | */ 6 | 7 | 8 | #ifndef lualib_h 9 | #define lualib_h 10 | 11 | #include "lua.h" 12 | 13 | 14 | 15 | LUAMOD_API int (luaopen_base) (lua_State *L); 16 | 17 | #define LUA_COLIBNAME "coroutine" 18 | LUAMOD_API int (luaopen_coroutine) (lua_State *L); 19 | 20 | #define LUA_TABLIBNAME "table" 21 | LUAMOD_API int (luaopen_table) (lua_State *L); 22 | 23 | #define LUA_IOLIBNAME "io" 24 | LUAMOD_API int (luaopen_io) (lua_State *L); 25 | 26 | #define LUA_OSLIBNAME "os" 27 | LUAMOD_API int (luaopen_os) (lua_State *L); 28 | 29 | #define LUA_STRLIBNAME "string" 30 | LUAMOD_API int (luaopen_string) (lua_State *L); 31 | 32 | #define LUA_UTF8LIBNAME "utf8" 33 | LUAMOD_API int (luaopen_utf8) (lua_State *L); 34 | 35 | #define LUA_BITLIBNAME "bit32" 36 | LUAMOD_API int (luaopen_bit32) (lua_State *L); 37 | 38 | #define LUA_MATHLIBNAME "math" 39 | LUAMOD_API int (luaopen_math) (lua_State *L); 40 | 41 | #define LUA_DBLIBNAME "debug" 42 | LUAMOD_API int (luaopen_debug) (lua_State *L); 43 | 44 | #define LUA_LOADLIBNAME "package" 45 | LUAMOD_API int (luaopen_package) (lua_State *L); 46 | 47 | 48 | /* open all previous libraries */ 49 | LUALIB_API void (luaL_openlibs) (lua_State *L); 50 | 51 | 52 | 53 | #if !defined(lua_assert) 54 | #define lua_assert(x) ((void)0) 55 | #endif 56 | 57 | 58 | #endif 59 | -------------------------------------------------------------------------------- /lua-5.3.0/src/lundump.h: -------------------------------------------------------------------------------- 1 | /* 2 | ** $Id: lundump.h,v 1.44 2014/06/19 18:27:20 roberto Exp $ 3 | ** load precompiled Lua chunks 4 | ** See Copyright Notice in lua.h 5 | */ 6 | 7 | #ifndef lundump_h 8 | #define lundump_h 9 | 10 | #include "llimits.h" 11 | #include "lobject.h" 12 | #include "lzio.h" 13 | 14 | 15 | /* data to catch conversion errors */ 16 | #define LUAC_DATA "\x19\x93\r\n\x1a\n" 17 | 18 | #define LUAC_INT 0x5678 19 | #define LUAC_NUM cast_num(370.5) 20 | 21 | #define MYINT(s) (s[0]-'0') 22 | #define LUAC_VERSION (MYINT(LUA_VERSION_MAJOR)*16+MYINT(LUA_VERSION_MINOR)) 23 | #define LUAC_FORMAT 0 /* this is the official format */ 24 | 25 | /* load one chunk; from lundump.c */ 26 | LUAI_FUNC LClosure* luaU_undump (lua_State* L, ZIO* Z, Mbuffer* buff, 27 | const char* name); 28 | 29 | /* dump one chunk; from ldump.c */ 30 | LUAI_FUNC int luaU_dump (lua_State* L, const Proto* f, lua_Writer w, 31 | void* data, int strip); 32 | 33 | #endif 34 | -------------------------------------------------------------------------------- /lua-5.3.0/src/lvm.h: -------------------------------------------------------------------------------- 1 | /* 2 | ** $Id: lvm.h,v 2.34 2014/08/01 17:24:02 roberto Exp $ 3 | ** Lua virtual machine 4 | ** See Copyright Notice in lua.h 5 | */ 6 | 7 | #ifndef lvm_h 8 | #define lvm_h 9 | 10 | 11 | #include "ldo.h" 12 | #include "lobject.h" 13 | #include "ltm.h" 14 | 15 | 16 | #if !defined(LUA_NOCVTN2S) 17 | #define cvt2str(o) ttisnumber(o) 18 | #else 19 | #define cvt2str(o) 0 /* no conversion from numbers to strings */ 20 | #endif 21 | 22 | 23 | #if !defined(LUA_NOCVTS2N) 24 | #define cvt2num(o) ttisstring(o) 25 | #else 26 | #define cvt2num(o) 0 /* no conversion from strings to numbers */ 27 | #endif 28 | 29 | 30 | #define tonumber(o,n) \ 31 | (ttisfloat(o) ? (*(n) = fltvalue(o), 1) : luaV_tonumber_(o,n)) 32 | 33 | #define tointeger(o,i) \ 34 | (ttisinteger(o) ? (*(i) = ivalue(o), 1) : luaV_tointeger_(o,i)) 35 | 36 | #define intop(op,v1,v2) l_castU2S(l_castS2U(v1) op l_castS2U(v2)) 37 | 38 | #define luaV_rawequalobj(t1,t2) luaV_equalobj(NULL,t1,t2) 39 | 40 | 41 | LUAI_FUNC int luaV_equalobj (lua_State *L, const TValue *t1, const TValue *t2); 42 | LUAI_FUNC int luaV_lessthan (lua_State *L, const TValue *l, const TValue *r); 43 | LUAI_FUNC int luaV_lessequal (lua_State *L, const TValue *l, const TValue *r); 44 | LUAI_FUNC int luaV_tonumber_ (const TValue *obj, lua_Number *n); 45 | LUAI_FUNC int luaV_tointeger_ (const TValue *obj, lua_Integer *p); 46 | LUAI_FUNC void luaV_gettable (lua_State *L, const TValue *t, TValue *key, 47 | StkId val); 48 | LUAI_FUNC void luaV_settable (lua_State *L, const TValue *t, TValue *key, 49 | StkId val); 50 | LUAI_FUNC void luaV_finishOp (lua_State *L); 51 | LUAI_FUNC void luaV_execute (lua_State *L); 52 | LUAI_FUNC void luaV_concat (lua_State *L, int total); 53 | LUAI_FUNC lua_Integer luaV_div (lua_State *L, lua_Integer x, lua_Integer y); 54 | LUAI_FUNC lua_Integer luaV_mod (lua_State *L, lua_Integer x, lua_Integer y); 55 | LUAI_FUNC lua_Integer luaV_shiftl (lua_Integer x, lua_Integer y); 56 | LUAI_FUNC void luaV_objlen (lua_State *L, StkId ra, const TValue *rb); 57 | 58 | #endif 59 | -------------------------------------------------------------------------------- /lua-5.3.0/src/lzio.c: -------------------------------------------------------------------------------- 1 | /* 2 | ** $Id: lzio.c,v 1.36 2014/11/02 19:19:04 roberto Exp $ 3 | ** Buffered streams 4 | ** See Copyright Notice in lua.h 5 | */ 6 | 7 | #define lzio_c 8 | #define LUA_CORE 9 | 10 | #include "lprefix.h" 11 | 12 | 13 | #include 14 | 15 | #include "lua.h" 16 | 17 | #include "llimits.h" 18 | #include "lmem.h" 19 | #include "lstate.h" 20 | #include "lzio.h" 21 | 22 | 23 | int luaZ_fill (ZIO *z) { 24 | size_t size; 25 | lua_State *L = z->L; 26 | const char *buff; 27 | lua_unlock(L); 28 | buff = z->reader(L, z->data, &size); 29 | lua_lock(L); 30 | if (buff == NULL || size == 0) 31 | return EOZ; 32 | z->n = size - 1; /* discount char being returned */ 33 | z->p = buff; 34 | return cast_uchar(*(z->p++)); 35 | } 36 | 37 | 38 | void luaZ_init (lua_State *L, ZIO *z, lua_Reader reader, void *data) { 39 | z->L = L; 40 | z->reader = reader; 41 | z->data = data; 42 | z->n = 0; 43 | z->p = NULL; 44 | } 45 | 46 | 47 | /* --------------------------------------------------------------- read --- */ 48 | size_t luaZ_read (ZIO *z, void *b, size_t n) { 49 | while (n) { 50 | size_t m; 51 | if (z->n == 0) { /* no bytes in buffer? */ 52 | if (luaZ_fill(z) == EOZ) /* try to read more */ 53 | return n; /* no more input; return number of missing bytes */ 54 | else { 55 | z->n++; /* luaZ_fill consumed first byte; put it back */ 56 | z->p--; 57 | } 58 | } 59 | m = (n <= z->n) ? n : z->n; /* min. between n and z->n */ 60 | memcpy(b, z->p, m); 61 | z->n -= m; 62 | z->p += m; 63 | b = (char *)b + m; 64 | n -= m; 65 | } 66 | return 0; 67 | } 68 | 69 | /* ------------------------------------------------------------------------ */ 70 | char *luaZ_openspace (lua_State *L, Mbuffer *buff, size_t n) { 71 | if (n > buff->buffsize) { 72 | if (n < LUA_MINBUFFER) n = LUA_MINBUFFER; 73 | luaZ_resizebuffer(L, buff, n); 74 | } 75 | return buff->buffer; 76 | } 77 | 78 | 79 | -------------------------------------------------------------------------------- /lua-5.3.0/src/lzio.h: -------------------------------------------------------------------------------- 1 | /* 2 | ** $Id: lzio.h,v 1.30 2014/12/19 17:26:14 roberto Exp $ 3 | ** Buffered streams 4 | ** See Copyright Notice in lua.h 5 | */ 6 | 7 | 8 | #ifndef lzio_h 9 | #define lzio_h 10 | 11 | #include "lua.h" 12 | 13 | #include "lmem.h" 14 | 15 | 16 | #define EOZ (-1) /* end of stream */ 17 | 18 | typedef struct Zio ZIO; 19 | 20 | #define zgetc(z) (((z)->n--)>0 ? cast_uchar(*(z)->p++) : luaZ_fill(z)) 21 | 22 | 23 | typedef struct Mbuffer { 24 | char *buffer; 25 | size_t n; 26 | size_t buffsize; 27 | } Mbuffer; 28 | 29 | #define luaZ_initbuffer(L, buff) ((buff)->buffer = NULL, (buff)->buffsize = 0) 30 | 31 | #define luaZ_buffer(buff) ((buff)->buffer) 32 | #define luaZ_sizebuffer(buff) ((buff)->buffsize) 33 | #define luaZ_bufflen(buff) ((buff)->n) 34 | 35 | #define luaZ_buffremove(buff,i) ((buff)->n -= (i)) 36 | #define luaZ_resetbuffer(buff) ((buff)->n = 0) 37 | 38 | 39 | #define luaZ_resizebuffer(L, buff, size) \ 40 | ((buff)->buffer = luaM_reallocvchar(L, (buff)->buffer, \ 41 | (buff)->buffsize, size), \ 42 | (buff)->buffsize = size) 43 | 44 | #define luaZ_freebuffer(L, buff) luaZ_resizebuffer(L, buff, 0) 45 | 46 | 47 | LUAI_FUNC char *luaZ_openspace (lua_State *L, Mbuffer *buff, size_t n); 48 | LUAI_FUNC void luaZ_init (lua_State *L, ZIO *z, lua_Reader reader, 49 | void *data); 50 | LUAI_FUNC size_t luaZ_read (ZIO* z, void *b, size_t n); /* read next n bytes */ 51 | 52 | 53 | 54 | /* --------- Private Part ------------------ */ 55 | 56 | struct Zio { 57 | size_t n; /* bytes still unread */ 58 | const char *p; /* current position in buffer */ 59 | lua_Reader reader; /* reader function */ 60 | void *data; /* additional data */ 61 | lua_State *L; /* Lua state (for reader) */ 62 | }; 63 | 64 | 65 | LUAI_FUNC int luaZ_fill (ZIO *z); 66 | 67 | #endif 68 | -------------------------------------------------------------------------------- /make.sh: -------------------------------------------------------------------------------- 1 | #/bin/bash 2 | 3 | # make Capstone 4 | cd capstone-3.0.3 5 | ./setup_capstone.sh 6 | cd .. 7 | 8 | # make pe-parse 9 | cd libs/pe-parse 10 | cmake . 11 | make 12 | cd ../../ 13 | 14 | 15 | # make CodeReason 16 | mkdir build 17 | cd build 18 | cmake .. 19 | make -j8 20 | -------------------------------------------------------------------------------- /package.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | echo "This script packages mcsema into a .deb package" 4 | echo "Cleaning old diretories" 5 | rm -rf ./deb-build 6 | 7 | GIT_DATE=$(git log -n 1 --format="%ai") 8 | DATE=$(date --utc --date="${GIT_DATE}" +%Y%m%d%H%M) 9 | VERSION=0.1-${DATE} 10 | 11 | 12 | echo "CodeReason Version is: ${VERSION}" 13 | 14 | mkdir -p ./deb-build/codereason_${VERSION}/opt/codereason/bin/ 15 | 16 | cp -R ./debian ./deb-build/codereason_${VERSION}/DEBIAN 17 | echo "Version: ${VERSION}" | cat - ./debian/control > ./deb-build/codereason_${VERSION}/DEBIAN/control 18 | 19 | CR_BINS=$(find ./build/bin -executable -type f) 20 | 21 | if [ "${CR_BINS}" == "" ] 22 | then 23 | echo "Could not find mcsema binaries. Did you build CodeReason?" 24 | exit -1 25 | fi 26 | 27 | for BINFILE in ${CR_BINS} 28 | do 29 | echo "Packaging ${BINFILE}..." 30 | cp ${BINFILE} ./deb-build/codereason_${VERSION}/opt/codereason/bin/ 31 | done 32 | 33 | 34 | LLVM_BINS=$(find ./build/llvm-3.2.src/build/bin -executable -type f ! -name '*.so') 35 | if [ "${LLVM_BINS}" == "" ] 36 | then 37 | echo "Could not find LLVM binaries. Did you build CodeReason?" 38 | exit -1 39 | fi 40 | 41 | for BINFILE in ${LLVM_BINS} 42 | do 43 | echo "Packaging ${BINFILE}..." 44 | cp ${BINFILE} ./deb-build/codereason_${VERSION}/opt/codereason/bin/ 45 | done 46 | 47 | strip -s ./deb-build/codereason_${VERSION}/opt/codereason/bin/* 48 | 49 | echo "Building .deb file..." 50 | dpkg-deb -v --build ./deb-build/codereason_${VERSION} 51 | -------------------------------------------------------------------------------- /recompile.sh: -------------------------------------------------------------------------------- 1 | #/bin/bash 2 | 3 | # make CodeReason 4 | mkdir build 5 | cd build 6 | cmake .. 7 | make -j8 8 | 9 | 10 | -------------------------------------------------------------------------------- /scripts/arm/call_reg.lua: -------------------------------------------------------------------------------- 1 | function onPre(v) 2 | vee.putreg(v, R1, 32, 80808080) 3 | vee.putreg(v, R2, 32, 80808080) 4 | vee.putreg(v, R3, 32, 80808080) 5 | vee.putreg(v, R4, 32, 80808080) 6 | vee.putreg(v, R5, 32, 80808080) 7 | vee.putreg(v, R6, 32, 80808080) 8 | vee.putreg(v, R7, 32, 80808080) 9 | vee.putreg(v, R8, 32, 80808080) 10 | vee.putreg(v, R9, 32, 80808080) 11 | vee.putreg(v, R10, 32, 80808080) 12 | end 13 | 14 | function onPost(v) 15 | eip = vee.getreg(v, R15, 32) 16 | 17 | if eip ~= nil and eip > 80808080-16 and eip < 80808080+16 then 18 | return true 19 | end 20 | 21 | return false 22 | end 23 | 24 | vee.register(onPre, onPost) 25 | -------------------------------------------------------------------------------- /scripts/lang/from_msf/adobe_mp4/deref_pop_ret: -------------------------------------------------------------------------------- 1 | EAX = MEMREAD[EAX] 2 | EBP = MEMREAD[ESP] 3 | EIP = MEMREAD[Add[ESP, 4]] 4 | -------------------------------------------------------------------------------- /scripts/lang/from_msf/general_rwrite: -------------------------------------------------------------------------------- 1 | _ = MEMREAD[ESP] 2 | EIP = MEMREAD[Add[ESP, 4]] 3 | -------------------------------------------------------------------------------- /scripts/lang/from_msf/general_vwrite: -------------------------------------------------------------------------------- 1 | x1 = _ 2 | x0 = MEMREAD[ESP] 3 | EIP = MEMREAD[Add[ESP, 4]] 4 | -------------------------------------------------------------------------------- /scripts/lang/from_msf/ibm_tivoli/pop_many_ret: -------------------------------------------------------------------------------- 1 | EAX = MEMREAD[ESP] 2 | EDI = MEMREAD[Add[ESP, 4]] 3 | ESI = MEMREAD[Add[ESP, 8]] 4 | EBX = MEMREAD[Add[ESP, 12]] 5 | EBP = MEMREAD[Add[ESP, 16]] 6 | EIP = MEMREAD[Add[ESP, 20]] 7 | -------------------------------------------------------------------------------- /scripts/lang/from_msf/java_docbase_bof/add_eax_ret: -------------------------------------------------------------------------------- 1 | EAX = Add[ EAX, 88 ] 2 | EIP = MEMREAD[ESP] 3 | -------------------------------------------------------------------------------- /scripts/lang/from_msf/java_docbase_bof/deref_eax: -------------------------------------------------------------------------------- 1 | EAX = MEMREAD[EAX] 2 | EIP = MEMREAD[ESP] 3 | -------------------------------------------------------------------------------- /scripts/lang/from_msf/java_docbase_bof/deref_eax4: -------------------------------------------------------------------------------- 1 | EAX = MEMREAD[Add[EAX, 4]] 2 | EIP = MEMREAD[ESP] 3 | -------------------------------------------------------------------------------- /scripts/lang/from_msf/ms10_002_ie_object/jmp_eax: -------------------------------------------------------------------------------- 1 | EIP = MEMREAD[EAX] 2 | -------------------------------------------------------------------------------- /scripts/lang/from_msf/ms10_002_ie_object/pop_eax_ret: -------------------------------------------------------------------------------- 1 | EAX = MEMREAD[ESP] 2 | EIP = MEMREAD[Add[ESP, 4]] 3 | -------------------------------------------------------------------------------- /scripts/lang/from_msf/ms10_002_ie_object/pop_ebp_ret: -------------------------------------------------------------------------------- 1 | EBP = MEMREAD[ESP] 2 | EIP = MEMREAD[Add[ESP, 4]] 3 | -------------------------------------------------------------------------------- /scripts/lang/from_msf/ms10_002_ie_object/pop_edi_ret: -------------------------------------------------------------------------------- 1 | EDI = MEMREAD[ESP] 2 | EIP = MEMREAD[Add[ESP, 4]] 3 | -------------------------------------------------------------------------------- /scripts/lang/from_msf/ms10_002_ie_object/pushad_ret: -------------------------------------------------------------------------------- 1 | MEMWRITE[ Add[ESP, 28 ]] = EAX 2 | MEMWRITE[ Add[ESP, 24 ]] = ECX 3 | MEMWRITE[ Add[ESP, 20 ]] = EDX 4 | MEMWRITE[ Add[ESP, 16 ]] = EBX 5 | MEMWRITE[ Add[ESP, 12 ]] = ESP 6 | MEMWRITE[ Add[ESP, 8 ]] = EBP 7 | MEMWRITE[ Add[ESP, 4 ]] = ESI 8 | MEMWRITE[ESP] = EDI 9 | EIP = MEMREAD[ Add[ESP, 32] ] 10 | -------------------------------------------------------------------------------- /scripts/lang/from_msf/vlc_amv/add_xor_inc_ret: -------------------------------------------------------------------------------- 1 | EAX = 1 2 | EAX = Add[EAX, EBX] 3 | EIP = MEMREAD[ESP] 4 | -------------------------------------------------------------------------------- /scripts/lang/mem_equiv: -------------------------------------------------------------------------------- 1 | MEMWRITE[ECX] = MEMREAD[EBX] 2 | -------------------------------------------------------------------------------- /scripts/lang/mem_equiv_eps: -------------------------------------------------------------------------------- 1 | MEMWRITE[EAX] = MEMREAD[ Add[EBX, RANGE[0, 10] ] ] 2 | -------------------------------------------------------------------------------- /scripts/lang/pvtfinder: -------------------------------------------------------------------------------- 1 | EIP = MEMREAD[ Add[ EAX , $32 ] ] 2 | -------------------------------------------------------------------------------- /scripts/lang/reg_equiv: -------------------------------------------------------------------------------- 1 | EAX = EBX 2 | ECX = EDX 3 | -------------------------------------------------------------------------------- /scripts/lang/reg_equiv_eps: -------------------------------------------------------------------------------- 1 | EAX = Add[ EBX, RANGE[0, 48] ] 2 | -------------------------------------------------------------------------------- /scripts/lang/wild_binary_ops: -------------------------------------------------------------------------------- 1 | ? = Add[ EBX, _ ] 2 | -------------------------------------------------------------------------------- /scripts/lang/wild_reg_assign: -------------------------------------------------------------------------------- 1 | ? = MEMREAD[ _ ] 2 | -------------------------------------------------------------------------------- /scripts/valu/add.lua: -------------------------------------------------------------------------------- 1 | function onPre(v) 2 | --say that we could have a 32-bit value in any general purpose register 3 | regClass = {} 4 | regClass[CLASS] = GenericRegister 5 | regClass[VALUE] = 21 6 | regClass[WIDTH] = 32 7 | 8 | vee.setregclass(v, regClass) 9 | 10 | --and then say that we have some other 32-bit value in any general purpose 11 | --register 12 | regClass = {} 13 | regClass[CLASS] = GenericRegister 14 | regClass[VALUE] = 18 15 | regClass[WIDTH] = 32 16 | 17 | vee.setregclass(v, regClass) 18 | end 19 | 20 | function checkReg(v, reg, width, val) 21 | tmp = vee.getreg(v, reg, width) 22 | if tmp ~= nil then 23 | if tmp == val then 24 | return true 25 | end 26 | end 27 | 28 | return false 29 | end 30 | 31 | function onPost(v) 32 | --check and see if we branched to the value we wanted to branch to 33 | eip = vee.getreg(v, EIP, 32) 34 | if eip == nil then 35 | return false 36 | end 37 | 38 | if vee.getexit(v) == Return then 39 | --if we branched where we wanted to, then check and see if any GPR 40 | --contains the result of 0x1 + 0x2 41 | if checkReg(v, EAX, 32, 39) or 42 | checkReg(v, EBX, 32, 39) or 43 | checkReg(v, ECX, 32, 39) or 44 | checkReg(v, EDX, 32, 39) or 45 | checkReg(v, ESI, 32, 39) or 46 | checkReg(v, EDI, 32, 39) or 47 | checkReg(v, EBP, 32, 39) then 48 | return true 49 | end 50 | end 51 | 52 | return false 53 | end 54 | 55 | vee.register(onPre, onPost) 56 | -------------------------------------------------------------------------------- /scripts/valu/and.lua: -------------------------------------------------------------------------------- 1 | function onPre(v) 2 | --say that we could have a 32-bit value in any general purpose register 3 | regClass = {} 4 | regClass[CLASS] = GenericRegister 5 | regClass[VALUE] = 21 6 | regClass[WIDTH] = 32 7 | 8 | vee.setregclass(v, regClass) 9 | 10 | --and then say that we have some other 32-bit value in any general purpose 11 | --register 12 | regClass = {} 13 | regClass[CLASS] = GenericRegister 14 | regClass[VALUE] = 18 15 | regClass[WIDTH] = 32 16 | 17 | vee.setregclass(v, regClass) 18 | end 19 | 20 | function checkReg(v, reg, width, val) 21 | tmp = vee.getreg(v, reg, width) 22 | if tmp ~= nil then 23 | if tmp == val then 24 | return true 25 | end 26 | end 27 | 28 | return false 29 | end 30 | 31 | function onPost(v) 32 | --check and see if we branched to the value we wanted to branch to 33 | eip = vee.getreg(v, EIP, 32) 34 | if eip == nil then 35 | return false 36 | end 37 | 38 | if vee.getexit(v) == Return then 39 | --if we branched where we wanted to, then check and see if any GPR 40 | --contains the result of 0x1 + 0x2 41 | if checkReg(v, EAX, 32, 16) or 42 | checkReg(v, EBX, 32, 16) or 43 | checkReg(v, ECX, 32, 16) or 44 | checkReg(v, EDX, 32, 16) or 45 | checkReg(v, ESI, 32, 16) or 46 | checkReg(v, EDI, 32, 16) or 47 | checkReg(v, EBP, 32, 16) then 48 | return true 49 | end 50 | end 51 | 52 | return false 53 | end 54 | 55 | vee.register(onPre, onPost) 56 | -------------------------------------------------------------------------------- /scripts/valu/div.lua: -------------------------------------------------------------------------------- 1 | function onPre(v) 2 | --say that we could have a 32-bit value in any general purpose register 3 | regClass = {} 4 | regClass[CLASS] = GenericRegister 5 | regClass[VALUE] = 20 6 | regClass[WIDTH] = 32 7 | 8 | vee.setregclass(v, regClass) 9 | 10 | --and then say that we have some other 32-bit value in any general purpose 11 | --register 12 | regClass = {} 13 | regClass[CLASS] = GenericRegister 14 | regClass[VALUE] = 4 15 | regClass[WIDTH] = 32 16 | 17 | vee.setregclass(v, regClass) 18 | end 19 | 20 | function checkReg(v, reg, width, val) 21 | tmp = vee.getreg(v, reg, width) 22 | if tmp ~= nil then 23 | if tmp == val then 24 | return true 25 | end 26 | end 27 | 28 | return false 29 | end 30 | 31 | function onPost(v) 32 | --check and see if we branched to the value we wanted to branch to 33 | eip = vee.getreg(v, EIP, 32) 34 | if eip == nil then 35 | return false 36 | end 37 | 38 | if vee.getexit(v) == Return then 39 | --if we branched where we wanted to, then check and see if any GPR 40 | --contains the result of 0x1 + 0x2 41 | if checkReg(v, EAX, 32, 5) or 42 | checkReg(v, EBX, 32, 5) or 43 | checkReg(v, ECX, 32, 5) or 44 | checkReg(v, EDX, 32, 5) or 45 | checkReg(v, ESI, 32, 5) or 46 | checkReg(v, EDI, 32, 5) or 47 | checkReg(v, EBP, 32, 5) then 48 | return true 49 | end 50 | end 51 | 52 | return false 53 | end 54 | 55 | vee.register(onPre, onPost) 56 | -------------------------------------------------------------------------------- /scripts/valu/mul.lua: -------------------------------------------------------------------------------- 1 | function onPre(v) 2 | --say that we could have a 32-bit value in any general purpose register 3 | regClass = {} 4 | regClass[CLASS] = GenericRegister 5 | regClass[VALUE] = 21 6 | regClass[WIDTH] = 32 7 | 8 | vee.setregclass(v, regClass) 9 | 10 | --and then say that we have some other 32-bit value in any general purpose 11 | --register 12 | regClass = {} 13 | regClass[CLASS] = GenericRegister 14 | regClass[VALUE] = 18 15 | regClass[WIDTH] = 32 16 | 17 | vee.setregclass(v, regClass) 18 | end 19 | 20 | function checkReg(v, reg, width, val) 21 | tmp = vee.getreg(v, reg, width) 22 | if tmp ~= nil then 23 | if tmp == val then 24 | return true 25 | end 26 | end 27 | 28 | return false 29 | end 30 | 31 | function onPost(v) 32 | --check and see if we branched to the value we wanted to branch to 33 | eip = vee.getreg(v, EIP, 32) 34 | if eip == nil then 35 | return false 36 | end 37 | 38 | if vee.getexit(v) == Return then 39 | --if we branched where we wanted to, then check and see if any GPR 40 | --contains the result of 0x1 + 0x2 41 | if checkReg(v, EAX, 32, 378) or 42 | checkReg(v, EBX, 32, 378) or 43 | checkReg(v, ECX, 32, 378) or 44 | checkReg(v, EDX, 32, 378) or 45 | checkReg(v, ESI, 32, 378) or 46 | checkReg(v, EDI, 32, 378) or 47 | checkReg(v, EBP, 32, 378) then 48 | return true 49 | end 50 | end 51 | 52 | return false 53 | end 54 | 55 | vee.register(onPre, onPost) 56 | -------------------------------------------------------------------------------- /scripts/valu/or.lua: -------------------------------------------------------------------------------- 1 | function onPre(v) 2 | --say that we could have a 32-bit value in any general purpose register 3 | regClass = {} 4 | regClass[CLASS] = GenericRegister 5 | regClass[VALUE] = 21 6 | regClass[WIDTH] = 32 7 | 8 | vee.setregclass(v, regClass) 9 | 10 | --and then say that we have some other 32-bit value in any general purpose 11 | --register 12 | regClass = {} 13 | regClass[CLASS] = GenericRegister 14 | regClass[VALUE] = 18 15 | regClass[WIDTH] = 32 16 | 17 | vee.setregclass(v, regClass) 18 | end 19 | 20 | function checkReg(v, reg, width, val) 21 | tmp = vee.getreg(v, reg, width) 22 | if tmp ~= nil then 23 | if tmp == val then 24 | return true 25 | end 26 | end 27 | 28 | return false 29 | end 30 | 31 | function onPost(v) 32 | --check and see if we branched to the value we wanted to branch to 33 | eip = vee.getreg(v, EIP, 32) 34 | if eip == nil then 35 | return false 36 | end 37 | 38 | if vee.getexit(v) == Return then 39 | --if we branched where we wanted to, then check and see if any GPR 40 | --contains the result of 0x1 + 0x2 41 | if checkReg(v, EAX, 32, 23) or 42 | checkReg(v, EBX, 32, 23) or 43 | checkReg(v, ECX, 32, 23) or 44 | checkReg(v, EDX, 32, 23) or 45 | checkReg(v, ESI, 32, 23) or 46 | checkReg(v, EDI, 32, 23) or 47 | checkReg(v, EBP, 32, 23) then 48 | return true 49 | end 50 | end 51 | 52 | return false 53 | end 54 | 55 | vee.register(onPre, onPost) 56 | -------------------------------------------------------------------------------- /scripts/valu/shl.lua: -------------------------------------------------------------------------------- 1 | function onPre(v) 2 | --say that we could have a 32-bit value in any general purpose register 3 | regClass = {} 4 | regClass[CLASS] = GenericRegister 5 | regClass[VALUE] = 21 6 | regClass[WIDTH] = 32 7 | 8 | vee.setregclass(v, regClass) 9 | end 10 | 11 | function checkReg(v, reg, width, val) 12 | tmp = vee.getreg(v, reg, width) 13 | if tmp ~= nil then 14 | if tmp == val then 15 | return true 16 | end 17 | end 18 | 19 | return false 20 | end 21 | 22 | function onPost(v) 23 | --check and see if we branched to the value we wanted to branch to 24 | eip = vee.getreg(v, EIP, 32) 25 | if eip == nil then 26 | return false 27 | end 28 | 29 | if vee.getexit(v) == Return then 30 | --if we branched where we wanted to, then check and see if any GPR 31 | --contains the result of 0x1 + 0x2 32 | if checkReg(v, EAX, 32, 42) or 33 | checkReg(v, EBX, 32, 42) or 34 | checkReg(v, ECX, 32, 42) or 35 | checkReg(v, EDX, 32, 42) or 36 | checkReg(v, ESI, 32, 42) or 37 | checkReg(v, EDI, 32, 42) or 38 | checkReg(v, EBP, 32, 42) then 39 | return true 40 | end 41 | end 42 | 43 | return false 44 | end 45 | 46 | vee.register(onPre, onPost) 47 | -------------------------------------------------------------------------------- /scripts/valu/shr.lua: -------------------------------------------------------------------------------- 1 | function onPre(v) 2 | --say that we could have a 32-bit value in any general purpose register 3 | regClass = {} 4 | regClass[CLASS] = GenericRegister 5 | regClass[VALUE] = 21 6 | regClass[WIDTH] = 32 7 | 8 | vee.setregclass(v, regClass) 9 | 10 | end 11 | 12 | function checkReg(v, reg, width, val) 13 | tmp = vee.getreg(v, reg, width) 14 | if tmp ~= nil then 15 | if tmp == val then 16 | return true 17 | end 18 | end 19 | 20 | return false 21 | end 22 | 23 | function onPost(v) 24 | --check and see if we branched to the value we wanted to branch to 25 | eip = vee.getreg(v, EIP, 32) 26 | if eip == nil then 27 | return false 28 | end 29 | 30 | if vee.getexit(v) == Return then 31 | --if we branched where we wanted to, then check and see if any GPR 32 | --contains the result of 0x1 + 0x2 33 | if checkReg(v, EAX, 32, 10) or 34 | checkReg(v, EBX, 32, 10) or 35 | checkReg(v, ECX, 32, 10) or 36 | checkReg(v, EDX, 32, 10) or 37 | checkReg(v, ESI, 32, 10) or 38 | checkReg(v, EDI, 32, 10) or 39 | checkReg(v, EBP, 32, 10) then 40 | return true 41 | end 42 | end 43 | 44 | return false 45 | end 46 | 47 | vee.register(onPre, onPost) 48 | -------------------------------------------------------------------------------- /scripts/valu/sub.lua: -------------------------------------------------------------------------------- 1 | function onPre(v) 2 | --say that we could have a 32-bit value in any general purpose register 3 | regClass = {} 4 | regClass[CLASS] = GenericRegister 5 | regClass[VALUE] = 49 6 | regClass[WIDTH] = 32 7 | 8 | vee.setregclass(v, regClass) 9 | 10 | --and then say that we have some other 32-bit value in any general purpose 11 | --register 12 | regClass = {} 13 | regClass[CLASS] = GenericRegister 14 | regClass[VALUE] = 10 15 | regClass[WIDTH] = 32 16 | 17 | vee.setregclass(v, regClass) 18 | end 19 | 20 | function checkReg(v, reg, width, val) 21 | tmp = vee.getreg(v, reg, width) 22 | if tmp ~= nil then 23 | if tmp == val then 24 | return true 25 | end 26 | end 27 | 28 | return false 29 | end 30 | 31 | function onPost(v) 32 | --check and see if we branched to the value we wanted to branch to 33 | eip = vee.getreg(v, EIP, 32) 34 | if eip == nil then 35 | return false 36 | end 37 | 38 | if vee.getexit(v) == Return then 39 | --if we branched where we wanted to, then check and see if any GPR 40 | --contains the result of 0x1 + 0x2 41 | if checkReg(v, EAX, 32, 39) or 42 | checkReg(v, EBX, 32, 39) or 43 | checkReg(v, ECX, 32, 39) or 44 | checkReg(v, EDX, 32, 39) or 45 | checkReg(v, ESI, 32, 39) or 46 | checkReg(v, EDI, 32, 39) or 47 | checkReg(v, EBP, 32, 39) then 48 | return true 49 | end 50 | end 51 | 52 | return false 53 | end 54 | 55 | vee.register(onPre, onPost) 56 | -------------------------------------------------------------------------------- /scripts/valu/xor.lua: -------------------------------------------------------------------------------- 1 | function onPre(v) 2 | --say that we could have a 32-bit value in any general purpose register 3 | regClass = {} 4 | regClass[CLASS] = GenericRegister 5 | regClass[VALUE] = 21 6 | regClass[WIDTH] = 32 7 | 8 | vee.setregclass(v, regClass) 9 | 10 | --and then say that we have some other 32-bit value in any general purpose 11 | --register 12 | regClass = {} 13 | regClass[CLASS] = GenericRegister 14 | regClass[VALUE] = 18 15 | regClass[WIDTH] = 32 16 | 17 | vee.setregclass(v, regClass) 18 | end 19 | 20 | function checkReg(v, reg, width, val) 21 | tmp = vee.getreg(v, reg, width) 22 | if tmp ~= nil then 23 | if tmp == val then 24 | return true 25 | end 26 | end 27 | 28 | return false 29 | end 30 | 31 | function onPost(v) 32 | --check and see if we branched to the value we wanted to branch to 33 | eip = vee.getreg(v, EIP, 32) 34 | if eip == nil then 35 | return false 36 | end 37 | 38 | if vee.getexit(v) == Return then 39 | --if we branched where we wanted to, then check and see if any GPR 40 | --contains the result of 0x1 + 0x2 41 | if checkReg(v, EAX, 32, 7) or 42 | checkReg(v, EBX, 32, 7) or 43 | checkReg(v, ECX, 32, 7) or 44 | checkReg(v, EDX, 32, 7) or 45 | checkReg(v, ESI, 32, 7) or 46 | checkReg(v, EDI, 32, 7) or 47 | checkReg(v, EBP, 32, 7) then 48 | return true 49 | end 50 | end 51 | 52 | return false 53 | end 54 | 55 | vee.register(onPre, onPost) 56 | -------------------------------------------------------------------------------- /scripts/x64/call_reg.lua: -------------------------------------------------------------------------------- 1 | function onPre(v) 2 | vee.putreg(v, RAX, 64, 50505050) 3 | vee.putreg(v, RBX, 64, 50505050) 4 | vee.putreg(v, RCX, 64, 50505050) 5 | vee.putreg(v, RDX, 64, 50505050) 6 | vee.putreg(v, RBP, 64, 50505050) 7 | vee.putreg(v, RSI, 64, 50505050) 8 | vee.putreg(v, RDI, 64, 50505050) 9 | vee.putreg(v, R8, 64, 50505050) 10 | vee.putreg(v, R9, 64, 50505050) 11 | vee.putreg(v, R10, 64, 50505050) 12 | vee.putreg(v, R11, 64, 50505050) 13 | vee.putreg(v, R12, 64, 50505050) 14 | vee.putreg(v, R13, 64, 50505050) 15 | vee.putreg(v, R14, 64, 50505050) 16 | vee.putreg(v, R15, 64, 50505050) 17 | end 18 | 19 | function onPost(v) 20 | rip = vee.getreg(v, RIP, 64) 21 | 22 | if rip == nil then 23 | return false 24 | end 25 | 26 | if rip == 50505050 and vee.getexit(v) == Call then 27 | return true 28 | end 29 | 30 | return false 31 | end 32 | 33 | vee.register(onPre, onPost) 34 | -------------------------------------------------------------------------------- /scripts/x86/call_reg.lua: -------------------------------------------------------------------------------- 1 | function onPre(v) 2 | vee.putreg(v, EAX, 32, 80808080) 3 | vee.putreg(v, EBX, 32, 80808080) 4 | vee.putreg(v, ECX, 32, 80808080) 5 | vee.putreg(v, EDX, 32, 80808080) 6 | vee.putreg(v, ESI, 32, 80808080) 7 | vee.putreg(v, EDI, 32, 80808080) 8 | vee.putreg(v, EBP, 32, 80808080) 9 | vee.putreg(v, ESP, 32, 40404040) 10 | end 11 | 12 | function onPost(v) 13 | eip = vee.getreg(v, EIP, 32) 14 | 15 | if eip == nil then 16 | return false 17 | end 18 | 19 | if eip == 80808080 and vee.getexit(v) == Call then 20 | return true 21 | end 22 | 23 | return false 24 | end 25 | 26 | vee.register(onPre, onPost) 27 | -------------------------------------------------------------------------------- /scripts/x86/pop_ecx.lua: -------------------------------------------------------------------------------- 1 | function onPre(v) 2 | vee.putreg(v, ESP, 32, 40404040) 3 | 4 | for i = 0,0x100,4 do 5 | vee.putmem(v, 40404040-0x80+i, 32, 80808080) 6 | end 7 | 8 | end 9 | 10 | function onPost(v) 11 | ecx = vee.getreg(v, ECX, 32) 12 | if ecx == nil then 13 | return false 14 | end 15 | 16 | if ecx == 80808080 and vee.getexit(v) == Return then 17 | return true 18 | end 19 | 20 | return false 21 | end 22 | 23 | vee.register(onPre, onPost) 24 | -------------------------------------------------------------------------------- /scripts/x86/pvtdown.lua: -------------------------------------------------------------------------------- 1 | function onPre(v) 2 | vee.putreg(v, ESP, 32, 0x40404040) 3 | end 4 | 5 | function onPost(v) 6 | esp = vee.getreg(v, ESP, 32) 7 | 8 | if esp == nil then 9 | return false 10 | end 11 | 12 | if ((esp & 0xffff0000) == 0x40400000) and (esp > 0x40404040+16) then 13 | if vee.hascalls(v) == false and vee.getexit(v) == Return then 14 | return true 15 | end 16 | return false 17 | end 18 | 19 | return false 20 | end 21 | 22 | vee.register(onPre, onPost) 23 | -------------------------------------------------------------------------------- /scripts/x86/pvtfinder.lua: -------------------------------------------------------------------------------- 1 | function onPre(v) 2 | vee.putreg(v, ESP, 32, 40000000) 3 | vee.putreg(v, EAX, 32, 80808080) 4 | end 5 | 6 | function onPost(v) 7 | esp = vee.getreg(v, ESP, 32) 8 | 9 | if esp == nil then 10 | return false 11 | end 12 | 13 | if esp > 80808080-16 and esp < 80808080+16 then 14 | if vee.hascalls(v) == false and vee.getexit(v) == Return then 15 | return true 16 | end 17 | return false 18 | end 19 | 20 | return false 21 | end 22 | 23 | vee.register(onPre, onPost) 24 | -------------------------------------------------------------------------------- /scripts/x86/pvtfinder2.lua: -------------------------------------------------------------------------------- 1 | function onPre(v) 2 | vee.putreg(v, ESP, 32, 40000000) 3 | vee.putreg(v, EAX, 32, 80808080) 4 | 5 | for i=0,4096 do 6 | vee.putmem(v, 80808080+i, 8, 20) 7 | end 8 | end 9 | 10 | function onPost(v) 11 | esp = vee.getreg(v, ESP, 32) 12 | 13 | if esp ~= nil and esp > 80808080-16 and esp < 80808080+16 then 14 | if vee.getexit(v) == Return then 15 | return true 16 | end 17 | return false 18 | end 19 | 20 | eip = vee.getreg(v, EIP, 32) 21 | 22 | if eip ~= nil and eip == 20202020 then 23 | return true 24 | end 25 | 26 | return false 27 | end 28 | 29 | vee.register(onPre, onPost) 30 | -------------------------------------------------------------------------------- /scripts/x86/transfer_arith_with_branch.lua: -------------------------------------------------------------------------------- 1 | function onPre(v) 2 | --say that we could have a 32-bit value in any general purpose register 3 | regClass = {} 4 | regClass[CLASS] = GenericRegister 5 | regClass[VALUE] = 0x1 6 | regClass[WIDTH] = 32 7 | 8 | vee.setregclass(v, regClass) 9 | 10 | --and then say that we have some other 32-bit value in any general purpose 11 | --register 12 | regClass = {} 13 | regClass[CLASS] = GenericRegister 14 | regClass[VALUE] = 0x2 15 | regClass[WIDTH] = 32 16 | 17 | vee.setregclass(v, regClass) 18 | 19 | --and then, in a THIRD register, we have the next place that we want to go 20 | 21 | regClass = {} 22 | regClass[CLASS] = GenericRegister 23 | regClass[VALUE] = 0x12345678 24 | regClass[WIDTH] = 32 25 | 26 | vee.setregclass(v, regClass) 27 | end 28 | 29 | function checkReg(v, reg, width, val) 30 | tmp = vee.getreg(v, reg, width) 31 | if tmp ~= nil then 32 | if tmp == val then 33 | return true 34 | end 35 | end 36 | 37 | return false 38 | end 39 | 40 | function onPost(v) 41 | --check and see if we branched to the value we wanted to branch to 42 | eip = vee.getreg(v, EIP, 32) 43 | if eip == nil then 44 | return false 45 | end 46 | 47 | if eip > 0x12345670 and eip < 0x12345686 then 48 | --if we branched where we wanted to, then check and see if any GPR 49 | --contains the result of 0x1 + 0x2 50 | if checkReg(v, EAX, 32, 0x3) or 51 | checkReg(v, EBX, 32, 0x3) or 52 | checkReg(v, ECX, 32, 0x3) or 53 | checkReg(v, EDX, 32, 0x3) or 54 | checkReg(v, ESI, 32, 0x3) or 55 | checkReg(v, EDI, 32, 0x3) or 56 | checkReg(v, EBP, 32, 0x3) then 57 | return true 58 | end 59 | end 60 | 61 | return false 62 | end 63 | 64 | vee.register(onPre, onPost) 65 | -------------------------------------------------------------------------------- /scripts/x86/vcall.lua: -------------------------------------------------------------------------------- 1 | function onPre(v) 2 | vee.putreg(v, EAX, 32, 0x40000000) 3 | vee.putmem(v, 0x40000000, 32, 0x20202020) 4 | end 5 | 6 | function onPost(v) 7 | eip = vee.getreg(v, EIP, 32) 8 | 9 | if eip == nil then 10 | return false 11 | end 12 | 13 | if eip == 0x20202020 then 14 | return true 15 | end 16 | 17 | return false 18 | end 19 | 20 | vee.register(onPre, onPost) 21 | -------------------------------------------------------------------------------- /scripts/x86/vcall2.lua: -------------------------------------------------------------------------------- 1 | function onPre(v) 2 | vee.putreg(v, ECX, 32, 40000000) 3 | for i=0,3 do 4 | vee.putmem(v, 40000000 + (i*4), 32, 80808080) 5 | end 6 | end 7 | 8 | function onPost(v) 9 | eip = vee.getreg(v, EIP, 32) 10 | 11 | if eip == nil then 12 | return false 13 | end 14 | 15 | if eip == 80808080 then 16 | return true 17 | end 18 | 19 | return false 20 | end 21 | 22 | vee.register(onPre, onPost) 23 | -------------------------------------------------------------------------------- /tests/ELF/ls_ARM: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lifting-bits/codereason/5c9d51fe61895ebe29cd9b6d8e60dc49d0162ea2/tests/ELF/ls_ARM -------------------------------------------------------------------------------- /tests/ELF/ls_x64: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lifting-bits/codereason/5c9d51fe61895ebe29cd9b6d8e60dc49d0162ea2/tests/ELF/ls_x64 -------------------------------------------------------------------------------- /tests/ELF/ls_x86: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lifting-bits/codereason/5c9d51fe61895ebe29cd9b6d8e60dc49d0162ea2/tests/ELF/ls_x86 -------------------------------------------------------------------------------- /tests/MachO/ls_FAT_x86_x64: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lifting-bits/codereason/5c9d51fe61895ebe29cd9b6d8e60dc49d0162ea2/tests/MachO/ls_FAT_x86_x64 -------------------------------------------------------------------------------- /tests/Makefile: -------------------------------------------------------------------------------- 1 | all: testAdd.bin testSub.bin testOr.bin testMul.bin testDiv.bin testMul8.bin testWat.bin testAnd.bin testJ1.bin testLAdd.bin bigOne.bin testAdd64.bin testMem.bin 2 | 3 | clean: 4 | rm *.bin 5 | 6 | testMem.bin: 7 | nasm -f bin -o testMem.bin testMem.asm 8 | 9 | testAdd64.bin: 10 | nasm -f bin -o testAdd64.bin testAdd64.asm 11 | 12 | bigOne.bin: 13 | nasm -f bin -o bigOne.bin bigOne.asm 14 | 15 | testAdd.bin: 16 | nasm -f bin -o testAdd.bin testAdd.asm 17 | 18 | testSub.bin: 19 | nasm -f bin -o testSub.bin testSub.asm 20 | 21 | testOr.bin: 22 | nasm -f bin -o testOr.bin testOr.asm 23 | 24 | testMul.bin: 25 | nasm -f bin -o testMul.bin testMul.asm 26 | 27 | testMul8.bin: 28 | nasm -f bin -o testMul8.bin testMul8.asm 29 | 30 | testDiv.bin: 31 | nasm -f bin -o testDiv.bin testDiv.asm 32 | 33 | testWat.bin: 34 | nasm -f bin -o testWat.bin testWat.asm 35 | 36 | testAnd.bin: 37 | nasm -f bin -o testAnd.bin testAnd.asm 38 | 39 | testJ1.bin: 40 | nasm -f bin -o testJ1.bin testJ1.asm 41 | 42 | testLAdd.bin: 43 | nasm -f bin -o testLAdd.bin testLAdd.asm 44 | -------------------------------------------------------------------------------- /tests/bigOne.asm: -------------------------------------------------------------------------------- 1 | BITS 32 2 | SEGMENT .text 3 | 4 | _s: 5 | xchg ebp, eax 6 | inc eax 7 | push edx 8 | add [eax], dl 9 | mov edi, edi 10 | push eax 11 | push edx 12 | add [eax], dl 13 | pop eax 14 | push edx 15 | add [eax], dl 16 | push dword 0x7c100052 17 | push edx 18 | add [eax], dl 19 | mov eax, [ebp+0x8] 20 | pop esi 21 | pop edi 22 | leave 23 | ret 24 | -------------------------------------------------------------------------------- /tests/bigOne.bin: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lifting-bits/codereason/5c9d51fe61895ebe29cd9b6d8e60dc49d0162ea2/tests/bigOne.bin -------------------------------------------------------------------------------- /tests/testAdd.asm: -------------------------------------------------------------------------------- 1 | BITS 32 2 | 3 | _s: 4 | mov eax, ecx 5 | add eax, 1 6 | ret 7 | -------------------------------------------------------------------------------- /tests/testAdd.bin: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lifting-bits/codereason/5c9d51fe61895ebe29cd9b6d8e60dc49d0162ea2/tests/testAdd.bin -------------------------------------------------------------------------------- /tests/testAdd.lua: -------------------------------------------------------------------------------- 1 | function onPre(v) 2 | vee.putreg(v, ECX, 32, 0) 3 | end 4 | 5 | function onPost(v) 6 | eax = vee.getreg(v, EAX, 32) 7 | 8 | if eax == 1 then 9 | return true 10 | end 11 | 12 | return false 13 | end 14 | -------------------------------------------------------------------------------- /tests/testAdd64.asm: -------------------------------------------------------------------------------- 1 | BITS 64 2 | 3 | _s: 4 | mov rax, rcx 5 | add rax, 1 6 | ret 7 | -------------------------------------------------------------------------------- /tests/testAnd.asm: -------------------------------------------------------------------------------- 1 | BITS 32 2 | SEGMENT .text 3 | 4 | _s: 5 | mov eax, ecx 6 | and eax, 8 7 | ret 8 | -------------------------------------------------------------------------------- /tests/testAnd.bin: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lifting-bits/codereason/5c9d51fe61895ebe29cd9b6d8e60dc49d0162ea2/tests/testAnd.bin -------------------------------------------------------------------------------- /tests/testArm.bin: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lifting-bits/codereason/5c9d51fe61895ebe29cd9b6d8e60dc49d0162ea2/tests/testArm.bin -------------------------------------------------------------------------------- /tests/testConds.lua: -------------------------------------------------------------------------------- 1 | function onPre(v) 2 | vee.putreg(v, ESP, 32, 40000000) 3 | vee.putreg(v, EAX, 32, 80808080) 4 | end 5 | 6 | function onPost(v) 7 | esp = vee.getreg(v, ESP, 32) 8 | 9 | if esp == nil then 10 | return false 11 | end 12 | 13 | if esp > 80808080-16 and esp < 80808080+16 then 14 | return true 15 | end 16 | 17 | return false 18 | end 19 | 20 | vee.register(onPre, onPost) 21 | -------------------------------------------------------------------------------- /tests/testDiv.asm: -------------------------------------------------------------------------------- 1 | BITS 32 2 | SEGMENT .text 3 | 4 | _s: 5 | mov eax, ecx 6 | mov ebx, 4 7 | div ebx 8 | ret 9 | -------------------------------------------------------------------------------- /tests/testDiv.bin: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lifting-bits/codereason/5c9d51fe61895ebe29cd9b6d8e60dc49d0162ea2/tests/testDiv.bin -------------------------------------------------------------------------------- /tests/testJ1.asm: -------------------------------------------------------------------------------- 1 | BITS 32 2 | SEGMENT .text 3 | 4 | _s: 5 | mov eax, ecx 6 | add eax, 1 7 | jmp eax 8 | -------------------------------------------------------------------------------- /tests/testJ1.bin: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lifting-bits/codereason/5c9d51fe61895ebe29cd9b6d8e60dc49d0162ea2/tests/testJ1.bin -------------------------------------------------------------------------------- /tests/testLAdd.asm: -------------------------------------------------------------------------------- 1 | BITS 32 2 | SEGMENT .text 3 | 4 | _s: 5 | mov eax, 5 6 | mov edx, 1 7 | lock xadd [EAX], EDX 8 | ret 9 | -------------------------------------------------------------------------------- /tests/testLAdd.bin: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lifting-bits/codereason/5c9d51fe61895ebe29cd9b6d8e60dc49d0162ea2/tests/testLAdd.bin -------------------------------------------------------------------------------- /tests/testMem.asm: -------------------------------------------------------------------------------- 1 | BITS 32 2 | SEGMENT .text 3 | 4 | _s: 5 | mov eax, DWORD [ ecx ] 6 | ret 7 | -------------------------------------------------------------------------------- /tests/testMul.asm: -------------------------------------------------------------------------------- 1 | BITS 32 2 | SEGMENT .text 3 | 4 | _s: 5 | mov eax, ecx 6 | mov ebx, 2 7 | mul ebx 8 | imul ebx 9 | ret 10 | -------------------------------------------------------------------------------- /tests/testMul.bin: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lifting-bits/codereason/5c9d51fe61895ebe29cd9b6d8e60dc49d0162ea2/tests/testMul.bin -------------------------------------------------------------------------------- /tests/testMul8.asm: -------------------------------------------------------------------------------- 1 | BITS 32 2 | SEGMENT .text 3 | 4 | _s: 5 | mov eax, ecx 6 | mov ebx, 2 7 | mul bh 8 | ret 9 | -------------------------------------------------------------------------------- /tests/testMul8.bin: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lifting-bits/codereason/5c9d51fe61895ebe29cd9b6d8e60dc49d0162ea2/tests/testMul8.bin -------------------------------------------------------------------------------- /tests/testOr.asm: -------------------------------------------------------------------------------- 1 | BITS 32 2 | SEGMENT .text 3 | 4 | _s: 5 | mov eax, ecx 6 | or eax, 8 7 | ret 8 | -------------------------------------------------------------------------------- /tests/testOr.bin: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lifting-bits/codereason/5c9d51fe61895ebe29cd9b6d8e60dc49d0162ea2/tests/testOr.bin -------------------------------------------------------------------------------- /tests/testSkyWipe.asm: -------------------------------------------------------------------------------- 1 | BITS 32 2 | SEGMENT .text 3 | 4 | _s: 5 | lea ecx, [eax+11h] 6 | add eax, 0Bh 7 | imul ecx, eax 8 | mov edx, ecx 9 | shr edx, 8 10 | mov eax, edx 11 | xor eax, ecx 12 | shr eax, 10h 13 | xor eax, edx 14 | xor eax, ecx 15 | ret 16 | -------------------------------------------------------------------------------- /tests/testSub.asm: -------------------------------------------------------------------------------- 1 | BITS 32 2 | SEGMENT .text 3 | 4 | _s: 5 | mov eax, ecx 6 | sub eax, 1 7 | ret 8 | -------------------------------------------------------------------------------- /tests/testSub.bin: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lifting-bits/codereason/5c9d51fe61895ebe29cd9b6d8e60dc49d0162ea2/tests/testSub.bin -------------------------------------------------------------------------------- /tests/testWat.asm: -------------------------------------------------------------------------------- 1 | BITS 32 2 | 3 | segment .text 4 | 5 | _test: 6 | xor eax, eax 7 | push eax 8 | sub eax, 93939BD2h 9 | push eax 10 | sub eax, 3A02EEC0h 11 | push eax 12 | sub eax, 0D0FD0100h 13 | push eax 14 | mov eax, esp 15 | push eax 16 | ret 17 | -------------------------------------------------------------------------------- /tests/testWat.bin: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lifting-bits/codereason/5c9d51fe61895ebe29cd9b6d8e60dc49d0162ea2/tests/testWat.bin -------------------------------------------------------------------------------- /tests/testXor.asm: -------------------------------------------------------------------------------- 1 | BITS 32 2 | SEGMENT .text 3 | 4 | _s: 5 | mov eax, ecx 6 | mov ebx, edx 7 | xor eax, ebx 8 | ret 9 | -------------------------------------------------------------------------------- /tools/BlockExtract/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | PROTOBUF_GENERATE_CPP(IR_PROTO_SRCS IR_PROTO_HDRS ${codeReason_SOURCE_DIR}/libs/IR/IR.proto) 2 | 3 | include_directories(${codeReason_SOURCE_DIR}/libs/IR ${codeReason_SOURCE_DIR}/libs/IR ${codeReason_SOURCE_DIR}/libs/VEE ${codeReason_SOURCE_DIR}/libs/getExecSections ${codeReason_SOURCE_DIR}/lua-5.3.0/src ${codeReason_SOURCE_DIR}/libs/RopLib ${CMAKE_CURRENT_BINARY_DIR} ) 4 | 5 | link_directories(${Boost_LIBRARY_DIRS}) 6 | add_definitions(-D__STDC_LIMIT_MACROS) 7 | 8 | add_executable( BlockExtract 9 | BlockExtract.cpp 10 | ${IR_PROTO_SRCS} 11 | ${IR_PROTO_HDRS}) 12 | 13 | IF(WIN32) 14 | target_link_libraries( BlockExtract 15 | ${PROTOBUF_LIBRARIES} 16 | VEE 17 | RopLib 18 | IR 19 | getExecSections 20 | lua 21 | ${PE-PARSE_LIB} 22 | ${VEX_LIB} 23 | ${CMAKE_THREAD_LIBS_INIT} 24 | ${Boost_LIBRARIES} ) 25 | ELSE(WIN32) 26 | target_link_libraries( BlockExtract 27 | ${PROTOBUF_LIBRARIES} 28 | VEE 29 | RopLib 30 | IR 31 | getExecSections 32 | MachOLib 33 | lua 34 | ${PE-PARSE_LIB} 35 | ${VEX_LIB} 36 | ${CMAKE_THREAD_LIBS_INIT} 37 | ${Boost_LIBRARIES} 38 | dl) 39 | ENDIF(WIN32) 40 | -------------------------------------------------------------------------------- /tools/BlockReader/BlockReader.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | 6 | #include 7 | #include 8 | #include 9 | #include 10 | #include 11 | 12 | #include 13 | 14 | using namespace std; 15 | using namespace boost; 16 | 17 | //print progress 18 | static 19 | void print_progress(unsigned int Total, unsigned int Done) { 20 | const int tdot = 40; 21 | 22 | double pctDone = ((double)Done)/((double)Total); 23 | 24 | unsigned int print = floor(pctDone * tdot); 25 | 26 | unsigned int i = 0; 27 | std::cout << std::setprecision(5) << std::fixed << pctDone*100 << "["; 28 | for( ; i < print; i++ ) { 29 | std::cout << "="; 30 | } 31 | for( ; i < tdot; i++ ) { 32 | std::cout << " "; 33 | } 34 | 35 | std::cout << "]\r"; 36 | std::cout.flush(); 37 | 38 | return; 39 | } 40 | 41 | int main(int argc, char *argv[]) { 42 | program_options::options_description d("options"); 43 | program_options::variables_map vm; 44 | string inputFile; 45 | 46 | d.add_options() 47 | ("database,db", program_options::value(), "input block database"); 48 | 49 | program_options::store( 50 | program_options::parse_command_line(argc, argv, d), vm); 51 | 52 | /* try and read the input */ 53 | if( vm.count("database") ) { 54 | inputFile = vm["database"].as(); 55 | } 56 | 57 | if( inputFile.size() == 0 ) { 58 | cout << d << endl; 59 | return 1; 60 | } 61 | 62 | list blocks; 63 | string modName; 64 | if( !readFromFile(inputFile, modName, blocks) ) { 65 | cout << "Failure to read input file " << inputFile << endl; 66 | return 1; 67 | } 68 | 69 | cout << "read module " << modName << endl; 70 | cout << "read in blocks " << to_string(blocks.size(), dec); 71 | for(list::iterator it = blocks.begin(); it != blocks.end(); ++it){ 72 | cout << (*it)->printBlock(); 73 | } 74 | cout << endl; 75 | 76 | return 0; 77 | } 78 | -------------------------------------------------------------------------------- /tools/BlockReader/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | PROTOBUF_GENERATE_CPP(IR_PROTO_SRCS IR_PROTO_HDRS ${codeReason_SOURCE_DIR}/libs/IR/IR.proto) 2 | 3 | include_directories(${codeReason_SOURCE_DIR}/libs/IR ${codeReason_SOURCE_DIR}/libs/IR ${codeReason_SOURCE_DIR}/libs/VEE ${codeReason_SOURCE_DIR}/libs/getExecSections ${codeReason_SOURCE_DIR}/lua-5.3.0/src ${codeReason_SOURCE_DIR}/libs/RopLib ${CMAKE_CURRENT_BINARY_DIR} ) 4 | 5 | link_directories(${Boost_LIBRARY_DIRS}) 6 | 7 | add_executable( BlockReader 8 | BlockReader.cpp 9 | ${IR_PROTO_SRCS} 10 | ${IR_PROTO_HDRS}) 11 | 12 | IF(WIN32) 13 | target_link_libraries( BlockReader 14 | ${PROTOBUF_LIBRARIES} 15 | VEE 16 | RopLib 17 | IR 18 | getExecSections 19 | lua 20 | ${PE-PARSE_LIB} 21 | ${VEX_LIB} 22 | ${CMAKE_THREAD_LIBS_INIT} 23 | ${Boost_LIBRARIES} ) 24 | ELSE(WIN32) 25 | target_link_libraries( BlockReader 26 | ${PROTOBUF_LIBRARIES} 27 | VEE 28 | RopLib 29 | IR 30 | getExecSections 31 | MachOLib 32 | lua 33 | ${PE-PARSE_LIB} 34 | ${VEX_LIB} 35 | ${CMAKE_THREAD_LIBS_INIT} 36 | ${Boost_LIBRARIES} 37 | dl) 38 | ENDIF(WIN32) 39 | -------------------------------------------------------------------------------- /tools/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | add_subdirectory(BlockExtract) 2 | add_subdirectory(BlockReader) 3 | add_subdirectory(ImgTool) 4 | add_subdirectory(RopTool) 5 | #add_subdirectory(RopScore) 6 | #add_subdirectory(TestLua) 7 | #add_subdirectory(TestParse) 8 | #add_subdirectory(VEEShell) 9 | #add_subdirectory(VEXBlobEater) 10 | -------------------------------------------------------------------------------- /tools/ImgTool/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | include_directories(${codeReason_SOURCE_DIR}/libs/IR ${codeReason_SOURCE_DIR}/libs/getExecSections) 2 | 3 | add_executable(ImgTool ImgTool.cpp ) 4 | IF(WIN32) 5 | target_link_libraries(ImgTool getExecSections PELib ${CMAKE_THREAD_LIBS_INIT} ${Boost_LIBRARIES}) 6 | ELSE(WIN32) 7 | target_link_libraries(ImgTool getExecSections MachOLib ${PE-PARSE_LIB} ${CMAKE_THREAD_LIBS_INIT} ${Boost_LIBRARIES}) 8 | ENDIF(WIN32) 9 | -------------------------------------------------------------------------------- /tools/RopScore/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | PROTOBUF_GENERATE_CPP(IR_PROTO_SRCS IR_PROTO_HDRS ${codeReason_SOURCE_DIR}/libs/IR/IR.proto) 2 | 3 | include_directories(${codeReason_SOURCE_DIR}/libs/IR ${codeReason_SOURCE_DIR}/libs/IR ${codeReason_SOURCE_DIR}/libs/VEE ${codeReason_SOURCE_DIR}/libs/getExecSections ${codeReason_SOURCE_DIR}/lua-5.3.0/src ${codeReason_SOURCE_DIR}/libs/RopLib ${CMAKE_CURRENT_BINARY_DIR} ${codeReason_SOURCE_DIR}/libs/ExprParser ) 4 | 5 | link_directories(${LLVM_LIBDIR_RAW} ${Boost_LIBRARY_DIRS}) 6 | add_definitions(-D__STDC_LIMIT_MACROS) 7 | 8 | add_executable( RopScore 9 | RopScore.cpp 10 | ${IR_PROTO_SRCS} 11 | ${IR_PROTO_HDRS}) 12 | 13 | IF(WIN32) 14 | target_link_libraries( RopScore 15 | ${PROTOBUF_LIBRARIES} 16 | ExprParser 17 | VEE 18 | RopLib 19 | IR 20 | getExecSections 21 | PELib 22 | lua 23 | ${VEX_LIB} 24 | ${CMAKE_THREAD_LIBS_INIT} 25 | ${Boost_LIBRARIES} 26 | ${LLVM_LIBS_RAW} ) 27 | ELSE(WIN32) 28 | target_link_libraries( RopScore 29 | ${PROTOBUF_LIBRARIES} 30 | ExprParser 31 | VEE 32 | RopLib 33 | IR 34 | getExecSections 35 | MachOLib 36 | PELib 37 | lua 38 | ${VEX_LIB} 39 | ${CMAKE_THREAD_LIBS_INIT} 40 | ${Boost_LIBRARIES} 41 | ${LLVM_LIBS_RAW} 42 | dl) 43 | ENDIF(WIN32) 44 | -------------------------------------------------------------------------------- /tools/RopTool/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | PROTOBUF_GENERATE_CPP(IR_PROTO_SRCS IR_PROTO_HDRS ${codeReason_SOURCE_DIR}/libs/IR/IR.proto) 2 | 3 | include_directories(${codeReason_SOURCE_DIR}/libs/IR ${codeReason_SOURCE_DIR}/capstone-3.0.3/capstone-3.0.3/include ${codeReason_SOURCE_DIR}/libs/VEE ${codeReason_SOURCE_DIR}/libs/getExecSections ${codeReason_SOURCE_DIR}/lua-5.3.0/src ${codeReason_SOURCE_DIR}/libs/RopLib ${CMAKE_CURRENT_BINARY_DIR} ) 4 | 5 | link_directories(${Boost_LIBRARY_DIRS}) 6 | add_definitions(-D__STDC_LIMIT_MACROS) 7 | 8 | add_executable( RopTool 9 | RopTool.cpp 10 | ${IR_PROTO_SRCS} 11 | ${IR_PROTO_HDRS}) 12 | 13 | IF(WIN32) 14 | target_link_libraries( RopTool 15 | ${PROTOBUF_LIBRARIES} 16 | VEE 17 | RopLib 18 | IR 19 | getExecSections 20 | lua 21 | ${PE-PARSE_LIB} 22 | ${VEX_LIB} 23 | ${CMAKE_THREAD_LIBS_INIT} 24 | ${Boost_LIBRARIES} ) 25 | ELSE(WIN32) 26 | target_link_libraries( RopTool 27 | ${PROTOBUF_LIBRARIES} 28 | VEE 29 | RopLib 30 | IR 31 | getExecSections 32 | MachOLib 33 | lua 34 | ${PE-PARSE_LIB} 35 | ${CAPSTONE_LIB} 36 | ${VEX_LIB} 37 | ${CMAKE_THREAD_LIBS_INIT} 38 | ${Boost_LIBRARIES} 39 | dl) 40 | ENDIF(WIN32) 41 | -------------------------------------------------------------------------------- /tools/TestLua/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | include_directories(${codeReason_SOURCE_DIR}/lua-5.3.0/src) 2 | 3 | add_executable(TestLua TestLua.cpp ) 4 | target_link_libraries(TestLua lua) 5 | -------------------------------------------------------------------------------- /tools/TestLua/test.lua: -------------------------------------------------------------------------------- 1 | function onPre(v) 2 | print "onPre" 3 | vee.getreg(v, 0x20202020, 0x80808080) 4 | end 5 | 6 | function onPost(vee) 7 | print "onPost" 8 | return true 9 | end 10 | 11 | vee.register(onPre, onPost) 12 | -------------------------------------------------------------------------------- /tools/TestParse/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | include_directories(${codeReason_SOURCE_DIR}/libs/ExprParser ${codeReason_SOURCE_DIR}/libs/IR) 2 | 3 | add_executable(TestParse TestParse.cpp ) 4 | add_dependencies(TestParse ExprParser) 5 | target_link_libraries(TestParse ExprParser IR ${Boost_LIBRARIES}) 6 | -------------------------------------------------------------------------------- /tools/TestParse/TestParse.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | #include 5 | #include 6 | #include 7 | #include 8 | #include 9 | 10 | int main(int argc, char *argv[]) { 11 | boost::program_options::options_description d("options"); 12 | boost::program_options::variables_map vm; 13 | //parse command line 14 | d.add_options() 15 | ("input,i", boost::program_options::value(),"input file") 16 | ("help,h", "print help"); 17 | 18 | boost::program_options::store( 19 | boost::program_options::parse_command_line(argc, argv, d), vm); 20 | 21 | if( vm.count("help") || !vm.count("input") ) { 22 | std::cout << d << std::endl; 23 | return 0; 24 | } 25 | 26 | std::string inFile = vm["input"].as(); 27 | 28 | if( inFile.size() > 0 ) { 29 | std::vector stmts; 30 | 31 | try { 32 | stmts = getExprsForFile(inFile); 33 | } 34 | catch ( SemanticFail s ) { 35 | std::cout << "semantic fail: " << s.fc << std::endl; 36 | } 37 | catch (ParseFail p ) { 38 | std::cout << "parser fail: " << p.fc << std::endl; 39 | } 40 | 41 | for(std::vector::iterator it = stmts.begin(); 42 | it != stmts.end(); 43 | ++it) 44 | { 45 | StatementPtr s = *it; 46 | 47 | std::cout << s->printStmt(); 48 | } 49 | } 50 | 51 | return 0; 52 | } 53 | -------------------------------------------------------------------------------- /tools/VEEShell/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | include_directories(${codeReason_SOURCE_DIR}/libs/IR ${codeReason_SOURCE_DIR}/libs/VEE ${codeReason_SOURCE_DIR}/libs/PELib ${codeReason_SOURCE_DIR}/lua-5.3.0/src) 2 | 3 | #link_directories(${codeReason_BINARY_DIR}/IR ${codeReason_BINARY_DIR}/VEE ${codeReason_BINARY_DIR}/PELib) 4 | link_directories(${Boost_LIBRARY_DIRS}) 5 | 6 | add_executable(VEEShell shell.cpp ) 7 | target_link_libraries(VEEShell VEE IR PELib ${VEX_LIB} lua ${CMAKE_THREAD_LIBS_INIT} ${Boost_LIBRARIES}) 8 | -------------------------------------------------------------------------------- /tools/VEXBlobEater/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | include_directories(${codeReason_SOURCE_DIR}/libs/IR) 2 | 3 | #link_directories(${codeREason_BINARY_DIR}/libs/IR) 4 | 5 | add_executable(VEXBlobEater blobEater.cpp getopt.c) 6 | target_link_libraries(VEXBlobEater IR ${VEX_LIB} ${CMAKE_THREAD_LIBS_INIT}) 7 | #set_target_properties(VEXBlobEater PROPERTIES COMPILE_FLAGS "-m32" LINK_FLAGS "-m32") 8 | -------------------------------------------------------------------------------- /tools/VEXBlobEater/blobeater.h: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | #include 6 | 7 | #include "getopt.h" 8 | #include "decodeLib.h" 9 | --------------------------------------------------------------------------------