├── DerokoOEP ├── driver │ ├── MAKEFILE │ ├── SOURCES │ ├── make32.bat │ ├── make64.bat │ └── tracer.c ├── finder.cpp ├── finder.rc ├── resource.h ├── split.def ├── split.sln ├── split.vcproj └── tracer.h ├── Disasm ├── dump.c ├── help.ru.htm ├── make32.bat ├── make64.bat ├── mediana.c ├── mediana.h ├── mediana_ctrl.h ├── pstdint.h ├── sample.c ├── tables.h ├── tables.inc ├── utils.c └── utils.h ├── DlgAbout.cpp ├── DlgAbout.h ├── DlgAttach.cpp ├── DlgAttach.h ├── DlgDisasm.cpp ├── DlgDisasm.h ├── DlgDump.cpp ├── DlgDump.h ├── DlgEditImport.cpp ├── DlgEditImport.h ├── DlgFinders.cpp ├── DlgFinders.h ├── DlgImport.cpp ├── DlgImport.h ├── DlgInput.cpp ├── DlgInput.h ├── DlgLicense.cpp ├── DlgLicense.h ├── DlgLua.cpp ├── DlgLua.h ├── DlgMain.cpp ├── DlgMain.h ├── DlgPref.cpp ├── DlgPref.h ├── Engine ├── MAKEFILE ├── SOURCES ├── amd64 │ ├── QUnpack.sys │ ├── engine64.asm │ └── interface64.inc ├── engine.c ├── i386 │ ├── QUnpack.sys │ ├── engine32.asm │ └── interface32.inc ├── make32.bat └── make64.bat ├── EngineHandler.cpp ├── EngineHandler.h ├── EngineSVM ├── MAKEFILE ├── SOURCES ├── amd64 │ ├── QUnpack.sys │ ├── engine64.asm │ └── interface64.inc ├── engine.c ├── i386 │ ├── QUnpack.sys │ ├── engine32.asm │ └── interface32.inc ├── make32.bat ├── make64.bat └── svm.h ├── EngineVMX ├── MAKEFILE ├── SOURCES ├── amd64 │ ├── QUnpack.sys │ ├── engine64.asm │ └── interface64.inc ├── engine.c ├── i386 │ ├── QUnpack.sys │ ├── engine32.asm │ └── interface32.inc ├── make32.bat ├── make64.bat └── vmx.h ├── Force ├── force.cpp ├── force.def ├── make32.bat ├── make32U.bat ├── make64.bat └── make64U.bat ├── GetLoadDll ├── GetLoadDll.cpp ├── GetLoadDll.def ├── make32.bat └── make64.bat ├── HumanOEP ├── Human.def ├── Human.sln ├── Human.vcproj ├── finder.cpp ├── finder.rc └── resource.h ├── Init.cpp ├── Init.h ├── LoadDll ├── LoadDll.cpp ├── make32.bat ├── make32U.bat ├── make64.bat └── make64U.bat ├── Loader ├── loader.cpp ├── make32.bat ├── make32U.bat ├── make64.bat └── make64U.bat ├── Lua ├── make32.bat ├── make64.bat └── src │ ├── 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 ├── Main.cpp ├── Main.h ├── MiniFMOD ├── lib │ ├── Fmusic.c │ ├── Fsound.c │ ├── Mixer.h │ ├── Music.h │ ├── Sound.h │ ├── Winmm.lib │ ├── minifmod.h │ ├── mixer_clipcopy.c │ ├── mixer_clipcopy.h │ ├── mixer_fpu_ramp.h │ ├── music_formatxm.c │ ├── music_formatxm.h │ ├── system_file.c │ ├── system_file.h │ ├── system_memory.h │ └── xmeffects.h ├── minifmod.h ├── minifmod.sln ├── minifmod.vcproj └── mixer │ ├── include32.inc │ ├── include64.inc │ ├── make32.bat │ ├── make64.bat │ ├── mixer32.asm │ └── mixer64.asm ├── Modules.cpp ├── Modules.h ├── PEFile.cpp ├── PEFile.h ├── QUnpack.def ├── QUnpack.rc ├── QUnpack.sln ├── QUnpack.vcproj ├── RegistryKey.cpp ├── RegistryKey.h ├── SeException.cpp ├── SeException.h ├── Tracer.cpp ├── Tracer.h ├── UsarOEP ├── UsAr.c ├── UsAr.def ├── UsAr.sln ├── UsAr.vcproj ├── UsArdll.d11.cpp ├── UsArdll.d11.def ├── UsArdll.d11.vcproj ├── resource.h └── rsrc.rc ├── VersionHelpers.h ├── effects ├── MARQUEE.H ├── Marquee.cpp ├── Picture.cpp └── Picture.h ├── interface.h ├── res ├── 32.manifest ├── 64.manifest ├── icon.ico ├── logo.jpg └── music.xm ├── resource.h ├── stdafx.cpp └── stdafx.h /DerokoOEP/driver/MAKEFILE: -------------------------------------------------------------------------------- 1 | 2 | ############################################################################# 3 | # 4 | # Copyright (C) Microsoft Corporation 1998, 1999 5 | # All Rights Reserved. 6 | # 7 | ############################################################################# 8 | 9 | # 10 | # DO NOT EDIT THIS FILE!!! Edit .\sources. if you want to add a new source 11 | # file to this component. This file merely indirects to the real make file 12 | # that is shared by all the driver components of Windows NT 13 | # 14 | 15 | !IF "$(DDKBUILDENV)"=="fre" 16 | LINKER_FORCE_NO_DBG_SECTION=1 17 | !ENDIF 18 | !INCLUDE $(NTMAKEENV)\makefile.def -------------------------------------------------------------------------------- /DerokoOEP/driver/SOURCES: -------------------------------------------------------------------------------- 1 | TARGETNAME=split 2 | TARGETPATH=. 3 | TARGETTYPE=DRIVER 4 | I386_SOURCES=tracer32.asm 5 | AMD64_SOURCES=tracer64.asm 6 | SOURCES=tracer.c -------------------------------------------------------------------------------- /DerokoOEP/driver/make32.bat: -------------------------------------------------------------------------------- 1 | build -cwZ 2 | del build* -------------------------------------------------------------------------------- /DerokoOEP/driver/make64.bat: -------------------------------------------------------------------------------- 1 | build -cwZ 2 | del build* -------------------------------------------------------------------------------- /DerokoOEP/finder.rc: -------------------------------------------------------------------------------- 1 | // Microsoft Visual C++ generated resource script. 2 | // 3 | #include "resource.h" 4 | 5 | #define APSTUDIO_READONLY_SYMBOLS 6 | ///////////////////////////////////////////////////////////////////////////// 7 | // 8 | // Generated from the TEXTINCLUDE 2 resource. 9 | // 10 | #include "afxres.h" 11 | 12 | ///////////////////////////////////////////////////////////////////////////// 13 | #undef APSTUDIO_READONLY_SYMBOLS 14 | 15 | ///////////////////////////////////////////////////////////////////////////// 16 | // Neutral resources 17 | 18 | #if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_NEU) 19 | #ifdef _WIN32 20 | LANGUAGE LANG_NEUTRAL, SUBLANG_NEUTRAL 21 | #pragma code_page(1251) 22 | #endif //_WIN32 23 | 24 | ///////////////////////////////////////////////////////////////////////////// 25 | // 26 | // Dialog 27 | // 28 | 29 | IDD_MAINDLG DIALOGEX 0, 0, 280, 136 30 | STYLE DS_SETFONT | DS_SETFOREGROUND | DS_CENTER | WS_MINIMIZEBOX | WS_POPUP | WS_VISIBLE | WS_CAPTION | WS_SYSMENU 31 | CAPTION "SplitTLB by Archer & deroko" 32 | FONT 8, "MS SANS SERIF", 0, 0, 0x0 33 | BEGIN 34 | LTEXT "File:",IDC_STATICFILE,8,10,36,8 35 | EDITTEXT IDC_FILENAME,48,8,184,12,ES_READONLY | NOT WS_TABSTOP 36 | LTEXT "Command:",IDC_STATICCOMMAND,8,24,36,8 37 | EDITTEXT IDC_COMMAND,48,22,184,12 38 | LISTBOX IDC_SECTIONS,48,39,184,64,NOT LBS_NOTIFY | WS_VSCROLL | WS_TABSTOP 39 | AUTOCHECKBOX "Use Custom &Range",IDC_USERANGE,8,104,76,9 40 | EDITTEXT IDC_RANGESTART,88,102,44,12,ES_RIGHT | ES_UPPERCASE | ES_READONLY 41 | LTEXT "Size:",IDC_STATICRANGESIZE,140,104,20,9 42 | EDITTEXT IDC_RANGESIZE,164,102,44,12,ES_RIGHT | ES_UPPERCASE | ES_READONLY 43 | LTEXT "Memory Start:",IDC_STATICMEMSTART,18,120,48,9 44 | EDITTEXT IDC_MEMSTART,88,118,44,12,ES_RIGHT | ES_UPPERCASE 45 | LTEXT "End:",IDC_STATICMEMEND,140,120,16,9 46 | EDITTEXT IDC_MEMEND,164,118,44,12,ES_RIGHT | ES_UPPERCASE 47 | PUSHBUTTON "&Oep",IDC_OEP,236,8,36,12 48 | PUSHBUTTON "&Detach",IDC_DETACH,236,27,36,12 49 | PUSHBUTTON "D&ump",IDC_DUMP,236,45,36,12 50 | PUSHBUTTON "E&xit",IDC_EXIT,236,63,36,12 51 | GROUPBOX "",IDC_STATICFRAME,3,0,273,134 52 | END 53 | 54 | #endif // Neutral resources 55 | ///////////////////////////////////////////////////////////////////////////// 56 | -------------------------------------------------------------------------------- /DerokoOEP/resource.h: -------------------------------------------------------------------------------- 1 | //{{NO_DEPENDENCIES}} 2 | // Microsoft Visual C++ generated include file. 3 | // Used by finder.rc 4 | // 5 | #define IDD_MAINDLG 101 6 | 7 | #define IDC_STATICFILE 1001 8 | #define IDC_FILENAME 1002 9 | #define IDC_STATICCOMMAND 1003 10 | #define IDC_COMMAND 1004 11 | #define IDC_SECTIONS 1005 12 | #define IDC_USERANGE 1006 13 | #define IDC_RANGESTART 1007 14 | #define IDC_STATICRANGESIZE 1008 15 | #define IDC_RANGESIZE 1009 16 | #define IDC_STATICMEMSTART 1010 17 | #define IDC_MEMSTART 1011 18 | #define IDC_STATICMEMEND 1012 19 | #define IDC_MEMEND 1013 20 | #define IDC_OEP 1014 21 | #define IDC_DETACH 1015 22 | #define IDC_DUMP 1016 23 | #define IDC_EXIT 1017 24 | #define IDC_STATICFRAME 1018 25 | 26 | // Next default values for new objects 27 | // 28 | #ifdef APSTUDIO_INVOKED 29 | #ifndef APSTUDIO_READONLY_SYMBOLS 30 | #define _APS_NEXT_RESOURCE_VALUE 1 31 | #define _APS_NEXT_SYMED_VALUE 102 32 | #define _APS_NEXT_CONTROL_VALUE 1019 33 | #define _APS_NEXT_COMMAND_VALUE 32768 34 | #endif 35 | #endif 36 | -------------------------------------------------------------------------------- /DerokoOEP/split.def: -------------------------------------------------------------------------------- 1 | LIBRARY split 2 | EXPORTS 3 | 4 | ShortFinderName 5 | GetOEPNow 6 | GetDllOEPNow -------------------------------------------------------------------------------- /DerokoOEP/split.sln: -------------------------------------------------------------------------------- 1 |  2 | Microsoft Visual Studio Solution File, Format Version 10.00 3 | # Visual Studio 2008 4 | Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "split", "split.vcproj", "{DEF9ED69-47E7-4A24-993A-B3E4D3914D7A}" 5 | EndProject 6 | Global 7 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 8 | Release Unicode|Win32 = Release Unicode|Win32 9 | Release Unicode|x64 = Release Unicode|x64 10 | Release|Win32 = Release|Win32 11 | Release|x64 = Release|x64 12 | EndGlobalSection 13 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 14 | {DEF9ED69-47E7-4A24-993A-B3E4D3914D7A}.Release Unicode|Win32.ActiveCfg = Release Unicode|Win32 15 | {DEF9ED69-47E7-4A24-993A-B3E4D3914D7A}.Release Unicode|Win32.Build.0 = Release Unicode|Win32 16 | {DEF9ED69-47E7-4A24-993A-B3E4D3914D7A}.Release Unicode|x64.ActiveCfg = Release Unicode|x64 17 | {DEF9ED69-47E7-4A24-993A-B3E4D3914D7A}.Release Unicode|x64.Build.0 = Release Unicode|x64 18 | {DEF9ED69-47E7-4A24-993A-B3E4D3914D7A}.Release|Win32.ActiveCfg = Release|Win32 19 | {DEF9ED69-47E7-4A24-993A-B3E4D3914D7A}.Release|Win32.Build.0 = Release|Win32 20 | {DEF9ED69-47E7-4A24-993A-B3E4D3914D7A}.Release|x64.ActiveCfg = Release|x64 21 | {DEF9ED69-47E7-4A24-993A-B3E4D3914D7A}.Release|x64.Build.0 = Release|x64 22 | EndGlobalSection 23 | GlobalSection(SolutionProperties) = preSolution 24 | HideSolutionNode = FALSE 25 | EndGlobalSection 26 | EndGlobal 27 | -------------------------------------------------------------------------------- /DerokoOEP/tracer.h: -------------------------------------------------------------------------------- 1 | #ifndef INTERFACE_H 2 | #define INTERFACE_H 3 | 4 | #define CURRENT_VERSION 0x040000 5 | 6 | #define GET_VERSION CTL_CODE(FILE_DEVICE_UNKNOWN,0x800,METHOD_BUFFERED,FILE_ANY_ACCESS) 7 | #define INIT_TRACER CTL_CODE(FILE_DEVICE_UNKNOWN,0x801,METHOD_BUFFERED,FILE_ANY_ACCESS) 8 | #define SET_RANGE CTL_CODE(FILE_DEVICE_UNKNOWN,0x802,METHOD_BUFFERED,FILE_ANY_ACCESS) 9 | #define STOP_TRACER CTL_CODE(FILE_DEVICE_UNKNOWN,0x803,METHOD_BUFFERED,FILE_ANY_ACCESS) 10 | 11 | #define STATE_WAIT 0x0 12 | #define STATE_READY 0x1 13 | 14 | #define STATE_BUSY 0x10 15 | 16 | #pragma pack(push,1) 17 | 18 | typedef struct 19 | { 20 | HANDLE Pid; 21 | ULONG_PTR StartRange; 22 | ULONG_PTR Size; 23 | } PROCESS_INFO; 24 | 25 | typedef struct 26 | { 27 | ULONG_PTR CurrentIp; 28 | ULONG State; 29 | } TRACER_STRUCT; 30 | 31 | typedef struct 32 | { 33 | ULONG_PTR MyCr3; 34 | ULONG_PTR StartRange; 35 | ULONG_PTR BpSize; 36 | } BREAKPOINT; 37 | 38 | #pragma pack(pop) 39 | 40 | #if defined _M_AMD64 41 | #define PAE_PDE_BASE 0xFFFFF6FB40000000 42 | #define PAE_PTE_BASE 0xFFFFF68000000000 43 | #elif defined _M_IX86 44 | #define PAE_PDE_BASE 0xC0600000 45 | #define PAE_PTE_BASE 0xC0000000 46 | #else 47 | !!! 48 | #endif 49 | 50 | #define NON_PAE_PDE_BASE 0xC0300000 51 | #define NON_PAE_PTE_BASE 0xC0000000 52 | 53 | #endif //INTERFACE_H -------------------------------------------------------------------------------- /Disasm/help.ru.htm: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fatrolls/Quick-Unpack/48070723aa80c1f2b6d1c43c345e51c37c1ea5b2/Disasm/help.ru.htm -------------------------------------------------------------------------------- /Disasm/make32.bat: -------------------------------------------------------------------------------- 1 | cl.exe /D_CRT_SECURE_NO_WARNINGS /c mediana.c dump.c utils.c /W4 /O2 /Ob2 /Oi /Ot /Oy /GT /GL /GF /GS- /Gy /arch:SSE2 /fp:fast /GR- 2 | lib.exe /NODEFAULTLIB mediana.obj dump.obj utils.obj 3 | del *.obj 4 | move mediana.lib disasm32.lib 5 | 6 | cl.exe /D_CRT_SECURE_NO_WARNINGS /D "UNICODE" /D "_UNICODE" /c mediana.c dump.c utils.c /W4 /O2 /Ob2 /Oi /Ot /Oy /GT /GL /GF /GS- /Gy /arch:SSE2 /fp:fast /GR- 7 | lib.exe /NODEFAULTLIB mediana.obj dump.obj utils.obj 8 | del *.obj 9 | move mediana.lib disasm32U.lib -------------------------------------------------------------------------------- /Disasm/make64.bat: -------------------------------------------------------------------------------- 1 | cl.exe /D_CRT_SECURE_NO_WARNINGS /c mediana.c dump.c utils.c /W4 /O2 /Ob2 /Oi /Ot /Oy /GT /GL /GF /GS- /Gy /fp:fast /GR- 2 | lib.exe /NODEFAULTLIB mediana.obj dump.obj utils.obj 3 | del *.obj 4 | move mediana.lib disasm64.lib 5 | 6 | cl.exe /D_CRT_SECURE_NO_WARNINGS /D "UNICODE" /D "_UNICODE" /c mediana.c dump.c utils.c /W4 /O2 /Ob2 /Oi /Ot /Oy /GT /GL /GF /GS- /Gy /fp:fast /GR- 7 | lib.exe /NODEFAULTLIB mediana.obj dump.obj utils.obj 8 | del *.obj 9 | move mediana.lib disasm64U.lib -------------------------------------------------------------------------------- /Disasm/mediana_ctrl.h: -------------------------------------------------------------------------------- 1 | /****************************************************************************** 2 | * Copyright (c) 2010, Mikae 3 | * All rights reserved. 4 | * 5 | * Redistribution and use in source and binary forms, with or without 6 | * modification, are permitted provided that the following conditions are met: 7 | * 1. Redistributions of source code must retain the above copyright 8 | * notice, this list of conditions and the following disclaimer. 9 | * 2. Redistributions in binary form must reproduce the above copyright 10 | * notice, this list of conditions and the following disclaimer in the 11 | * documentation and/or other materials provided with the distribution. 12 | * 3. All advertising materials mentioning features or use of this software 13 | * must display the following acknowledgement: 14 | * This product includes software developed by Mikae. 15 | * 4. Neither the name of Mikae nor the 16 | * names of its contributors may be used to endorse or promote products 17 | * derived from this software without specific prior written permission. 18 | * 19 | * THIS SOFTWARE IS PROVIDED BY Mikae ''AS IS'' AND ANY 20 | * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 21 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 22 | * DISCLAIMED. IN NO EVENT SHALL Mikae BE LIABLE FOR ANY 23 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 24 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 25 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 26 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 27 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 28 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 29 | ******************************************************************************* 30 | */ 31 | 32 | //Include/exclude dumping functions. 33 | #define MEDIANA_CTRL_DUMP 34 | 35 | //Alignment control. 36 | #define MEDIANA_CTRL_OPERAND_PACK 0x4 37 | #define MEDIANA_CTRL_DISP_PACK 0x4 38 | #define MEDIANA_CTRL_INSTRUCTION_PACK 0x4 39 | #define MEDIANA_CTRL_OPCODE_DESCR_PACK 0x4 40 | #define MEDIANA_CTRL_PARAMS_PACK 0x4 -------------------------------------------------------------------------------- /Disasm/utils.c: -------------------------------------------------------------------------------- 1 | /****************************************************************************** 2 | * Copyright (c) 2010, Mikae 3 | * All rights reserved. 4 | * 5 | * Redistribution and use in source and binary forms, with or without 6 | * modification, are permitted provided that the following conditions are met: 7 | * 1. Redistributions of source code must retain the above copyright 8 | * notice, this list of conditions and the following disclaimer. 9 | * 2. Redistributions in binary form must reproduce the above copyright 10 | * notice, this list of conditions and the following disclaimer in the 11 | * documentation and/or other materials provided with the distribution. 12 | * 3. All advertising materials mentioning features or use of this software 13 | * must display the following acknowledgement: 14 | * This product includes software developed by the Mikae. 15 | * 4. Neither the name of Mikae nor the 16 | * names of its contributors may be used to endorse or promote products 17 | * derived from this software without specific prior written permission. 18 | * 19 | * THIS SOFTWARE IS PROVIDED BY Mikae ''AS IS'' AND ANY 20 | * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 21 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 22 | * DISCLAIMED. IN NO EVENT SHALL Mikae BE LIABLE FOR ANY 23 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 24 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 25 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 26 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 27 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 28 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 29 | ******************************************************************************* 30 | */ 31 | 32 | #include "utils.h" 33 | 34 | uint8_t pref_opcodes[] = 35 | { 36 | 0x2E, //CS 37 | 0x3E, //DS 38 | 0x26, //ES 39 | 0x36, //SS 40 | 0x64, //FS 41 | 0x65, //GS 42 | 0x66, //OPSIZE 43 | 0x67, //ADDRSIZE 44 | 0xF2, //REPZ 45 | 0xF3, //REPNZ 46 | 0xF0 //LOCK 47 | }; 48 | 49 | uint8_t bsf(uint32_t src) 50 | { 51 | uint8_t res; 52 | 53 | for(res = 0; src; src >>= 0x1) 54 | { 55 | if (src & 0x1) 56 | break; 57 | res++; 58 | } 59 | 60 | return res; 61 | } -------------------------------------------------------------------------------- /Disasm/utils.h: -------------------------------------------------------------------------------- 1 | /****************************************************************************** 2 | * Copyright (c) 2010, Mikae 3 | * All rights reserved. 4 | * 5 | * Redistribution and use in source and binary forms, with or without 6 | * modification, are permitted provided that the following conditions are met: 7 | * 1. Redistributions of source code must retain the above copyright 8 | * notice, this list of conditions and the following disclaimer. 9 | * 2. Redistributions in binary form must reproduce the above copyright 10 | * notice, this list of conditions and the following disclaimer in the 11 | * documentation and/or other materials provided with the distribution. 12 | * 3. All advertising materials mentioning features or use of this software 13 | * must display the following acknowledgement: 14 | * This product includes software developed by the Mikae. 15 | * 4. Neither the name of Mikae nor the 16 | * names of its contributors may be used to endorse or promote products 17 | * derived from this software without specific prior written permission. 18 | * 19 | * THIS SOFTWARE IS PROVIDED BY Mikae ''AS IS'' AND ANY 20 | * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 21 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 22 | * DISCLAIMED. IN NO EVENT SHALL Mikae BE LIABLE FOR ANY 23 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 24 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 25 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 26 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 27 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 28 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 29 | ******************************************************************************* 30 | */ 31 | 32 | //Common routines, defines, prototypes and structs. 33 | #include "pstdint.h" 34 | 35 | struct RWBUFF 36 | { 37 | uint8_t *origin_offset; 38 | uint8_t *offset; 39 | size_t length; 40 | uint8_t err; 41 | }; 42 | 43 | uint8_t bsf(uint32_t src); 44 | 45 | extern uint8_t pref_opcodes[]; -------------------------------------------------------------------------------- /DlgAbout.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "afxwin.h" 4 | #include ".\\effects\\Picture.h" 5 | 6 | class CDlgAbout:public CDialog 7 | { 8 | DECLARE_DYNAMIC(CDlgAbout) 9 | 10 | public: 11 | CDlgAbout(); 12 | CPicture Picture; 13 | virtual ~CDlgAbout(); 14 | BOOL fSecret; 15 | 16 | enum {IDD=IDD_DLG_ABOUT}; 17 | 18 | protected: 19 | virtual void DoDataExchange(CDataExchange *pDX); 20 | 21 | DECLARE_MESSAGE_MAP() 22 | public: 23 | BOOL OnInitDialog(); 24 | afx_msg void OnDestroy(); 25 | afx_msg void OnBnClickedOk(); 26 | afx_msg void OnPaint(); 27 | void ConvertStaticToHyperlink(HWND hWndCtl); 28 | }; -------------------------------------------------------------------------------- /DlgAttach.cpp: -------------------------------------------------------------------------------- 1 | #include "stdafx.h" 2 | #include "Init.h" 3 | #include "DlgMain.h" 4 | #include "DlgAttach.h" 5 | #include "PEFile.h" 6 | #include "Modules.h" 7 | #include "psapi.h" 8 | 9 | IMPLEMENT_DYNAMIC(CDlgAttach,CDialog) 10 | CDlgAttach::CDlgAttach(CModules *n_pAttModules,DWORD *n_pPID,DWORD_PTR *n_pImageBase,DWORD *n_pTID):CDialog(CDlgAttach::IDD,NULL), 11 | pAttModules(n_pAttModules), 12 | pPID(n_pPID), 13 | pImageBase(n_pImageBase), 14 | pTID(n_pTID) 15 | { 16 | } 17 | 18 | CDlgAttach::~CDlgAttach() 19 | { 20 | } 21 | 22 | void CDlgAttach::DoDataExchange(CDataExchange *pDX) 23 | { 24 | CDialog::DoDataExchange(pDX); 25 | DDX_Control(pDX,IDC_PROCESSES,ProcessName); 26 | DDX_Control(pDX,IDC_MODULES,Modules); 27 | } 28 | 29 | BEGIN_MESSAGE_MAP(CDlgAttach,CDialog) 30 | ON_LBN_DBLCLK(IDC_MODULES,&CDlgAttach::OnLbnDblclkListModules) 31 | ON_LBN_SELCHANGE(IDC_PROCESSES,&CDlgAttach::OnLbnSelchangeListProcesses) 32 | END_MESSAGE_MAP() 33 | 34 | BOOL CDlgAttach::OnInitDialog() 35 | { 36 | CDialog::OnInitDialog(); 37 | 38 | CString sTemp; 39 | GetWindowText(sTemp); sTemp=pDlgMain->LocalizeString(sTemp,true); SetWindowText(sTemp); 40 | 41 | RefreshProcesses(); 42 | 43 | if(pDlgMain->Option.fAlwaysOnTop) 44 | SetWindowPos(&wndTopMost,0,0,0,0,SWP_NOMOVE | SWP_NOSIZE); 45 | return TRUE; 46 | } 47 | 48 | void CDlgAttach::OnLbnDblclkListModules() 49 | { 50 | CString sTemp; 51 | Modules.GetText(Modules.GetCurSel(),sTemp); 52 | if(sTemp==_T("-----")) 53 | return; 54 | *pImageBase=(DWORD_PTR)_tcstoi64(sTemp.Left(sizeof(DWORD_PTR)*2),NULL,16); 55 | ProcessName.GetText(ProcessName.GetCurSel(),sTemp); 56 | *pPID=_tcstoul(sTemp.Left(8),NULL,16); 57 | 58 | HANDLE hThreadSnap; 59 | hThreadSnap=CreateToolhelp32Snapshot(TH32CS_SNAPTHREAD,*pPID); 60 | THREADENTRY32 te32; 61 | te32.dwSize=sizeof(te32); 62 | if(!Thread32First(hThreadSnap,&te32)) 63 | { 64 | CloseHandle(hThreadSnap); 65 | return; 66 | } 67 | 68 | *pTID=0; 69 | HANDLE hThread; 70 | do 71 | { 72 | if(te32.th32OwnerProcessID==*pPID) 73 | { 74 | if(*pTID==0) 75 | *pTID=te32.th32ThreadID; 76 | hThread=OpenThread(THREAD_ALL_ACCESS,FALSE,te32.th32ThreadID); 77 | SuspendThread(hThread); 78 | CloseHandle(hThread); 79 | } 80 | } 81 | while(Thread32Next(hThreadSnap,&te32)); 82 | 83 | CloseHandle(hThreadSnap); 84 | OnOK(); 85 | } 86 | 87 | void CDlgAttach::RefreshProcesses() 88 | { 89 | TCHAR cTmpBuf[0x400]; 90 | TCHAR szTmpName[MAX_PATH]; 91 | HANDLE hProcess; 92 | 93 | ProcessName.ResetContent(); 94 | 95 | HANDLE hProcessSnap; 96 | hProcessSnap=CreateToolhelp32Snapshot(TH32CS_SNAPPROCESS,0); 97 | PROCESSENTRY32 pe32; 98 | pe32.dwSize=sizeof(pe32); 99 | if(!Process32First(hProcessSnap,&pe32)) 100 | { 101 | CloseHandle(hProcessSnap); 102 | return; 103 | } 104 | do 105 | { 106 | hProcess=OpenProcess(PROCESS_ALL_ACCESS,FALSE,pe32.th32ProcessID); 107 | if(IsWOW64(GetCurrentProcess())!=IsWOW64(hProcess)) 108 | { 109 | CloseHandle(hProcess); 110 | continue; 111 | } 112 | memset(cTmpBuf,0,sizeof(cTmpBuf)); 113 | memset(szTmpName,0,sizeof(szTmpName)); 114 | if(IsProcessDying(hProcess)) 115 | _tcscat_s(szTmpName,pe32.szExeFile); 116 | else 117 | GetModuleFileNameEx(hProcess,NULL,szTmpName,_countof(szTmpName)); 118 | CloseHandle(hProcess); 119 | _stprintf_s(cTmpBuf,_T("%08X - %s"),pe32.th32ProcessID,szTmpName); 120 | ProcessName.AddString(cTmpBuf); 121 | } 122 | while(Process32Next(hProcessSnap,&pe32)); 123 | 124 | CloseHandle(hProcessSnap); 125 | ProcessName.SetCurSel(0); 126 | OnLbnSelchangeListProcesses(); 127 | } 128 | 129 | void CDlgAttach::OnLbnSelchangeListProcesses() 130 | { 131 | CString sTemp; 132 | 133 | pAttModules->Clear(); 134 | Modules.ResetContent(); 135 | ProcessName.GetText(ProcessName.GetCurSel(),sTemp); 136 | HANDLE hVictim=OpenProcess(PROCESS_ALL_ACCESS,FALSE,_tcstoul(sTemp.Left(8),NULL,16)); 137 | pAttModules->Reload(MAX_NUM,NULL,hVictim); 138 | CloseHandle(hVictim); 139 | 140 | if(pAttModules->Modules.empty()) 141 | Modules.AddString(_T("-----")); 142 | 143 | for(size_t i=0;i!=pAttModules->Modules.size();++i) 144 | Modules.AddString(IntToStr(pAttModules->Modules[i]->ModuleBase,16,sizeof(pAttModules->Modules[0]->ModuleBase)*2)+_T(" - ")+pAttModules->Modules[i]->sFullName.c_str()); 145 | } -------------------------------------------------------------------------------- /DlgAttach.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "afxcmn.h" 4 | #include "PEFile.h" 5 | #include "DlgDisasm.h" 6 | #include "afxwin.h" 7 | 8 | class CDlgAttach:public CDialog 9 | { 10 | friend class CDlgMain; 11 | 12 | DECLARE_DYNAMIC(CDlgAttach) 13 | 14 | public: 15 | CDlgAttach(CModules *n_pAttModules,DWORD *n_pPID,DWORD_PTR *n_pImageBase,DWORD *n_pTID); 16 | virtual ~CDlgAttach(); 17 | 18 | enum {IDD=IDD_DLG_ATTACH}; 19 | 20 | protected: 21 | virtual void DoDataExchange(CDataExchange *pDX); 22 | 23 | DECLARE_MESSAGE_MAP() 24 | public: 25 | CListCtrl ImportList; 26 | virtual BOOL OnInitDialog(); 27 | void RefreshProcesses(); 28 | private: 29 | CModules *pAttModules; 30 | DWORD_PTR *pImageBase; 31 | DWORD *pPID,*pTID; 32 | public: 33 | CListBox ProcessName; 34 | CListBox Modules; 35 | afx_msg void OnLbnDblclkListModules(); 36 | afx_msg void OnLbnSelchangeListProcesses(); 37 | }; 38 | -------------------------------------------------------------------------------- /DlgDisasm.cpp: -------------------------------------------------------------------------------- 1 | #include "stdafx.h" 2 | #include "Init.h" 3 | #include "DlgMain.h" 4 | #include "DlgDisasm.h" 5 | 6 | #include ".\\Disasm\\mediana.h" 7 | 8 | IMPLEMENT_DYNAMIC(CDlgDisasm,CDialog) 9 | CDlgDisasm::CDlgDisasm():CDialog(CDlgDisasm::IDD,NULL) 10 | { 11 | } 12 | 13 | CDlgDisasm::~CDlgDisasm() 14 | { 15 | } 16 | 17 | void CDlgDisasm::DoDataExchange(CDataExchange *pDX) 18 | { 19 | CDialog::DoDataExchange(pDX); 20 | DDX_Control(pDX,IDC_DISLIST,DisasmList); 21 | } 22 | 23 | void CDlgDisasm::Disasm() 24 | { 25 | TCHAR cBuff[0x400]; 26 | void *cPtr; 27 | INSTRUCTION Instr; 28 | DISASM_PARAMS Params; 29 | int nInstrNum=0; 30 | 31 | cPtr=pAddr; 32 | DisasmList.ResetContent(); 33 | Params.arch=ARCH_ALL; 34 | Params.base=AltAddress; 35 | Params.options=DISASM_OPTION_APPLY_REL | DISASM_OPTION_OPTIMIZE_DISP | DISASM_OPTION_COMPUTE_RIP; 36 | Params.sf_prefixes=NULL; 37 | #if defined _M_AMD64 38 | Params.mode=DISASSEMBLE_MODE_64; 39 | #elif defined _M_IX86 40 | Params.mode=DISASSEMBLE_MODE_32; 41 | #else 42 | !!! 43 | #endif 44 | do 45 | { 46 | if(medi_disassemble((uint8_t*)cPtr,BUFSIZ_INFINITY,&Instr,&Params)!=DASM_ERR_OK) 47 | break; 48 | _stprintf_s(cBuff,_T("%I64X:"),Params.base); 49 | size_t nTempLen=_tcslen(cBuff); 50 | cBuff[nTempLen++]=_T(' '); 51 | cBuff[nTempLen++]=_T(' '); 52 | cBuff[nTempLen++]=_T(' '); 53 | nTempLen+=medi_dump(&Instr,cBuff+nTempLen,_countof(cBuff)-nTempLen,NULL); 54 | cBuff[nTempLen]=_T('\0'); 55 | 56 | DisasmList.AddString(cBuff); 57 | cPtr=(BYTE*)cPtr+Instr.length; 58 | Params.base+=Instr.length; 59 | ++nInstrNum; 60 | } 61 | while(nInstrNum!=INSTRS_TO_DISASM); 62 | } 63 | 64 | BOOL CDlgDisasm::OnInitDialog() 65 | { 66 | CDialog::OnInitDialog(); 67 | CString sTemp; 68 | GetWindowText(sTemp); sTemp=pDlgMain->LocalizeString(sTemp,true); SetWindowText(sTemp); 69 | 70 | UpdateData(FALSE); 71 | Disasm(); 72 | 73 | if(pDlgMain->Option.fAlwaysOnTop) 74 | SetWindowPos(&wndTopMost,0,0,0,0,SWP_NOMOVE | SWP_NOSIZE); 75 | return TRUE; 76 | } -------------------------------------------------------------------------------- /DlgDisasm.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "afxwin.h" 4 | 5 | class CDlgDisasm:public CDialog 6 | { 7 | DECLARE_DYNAMIC(CDlgDisasm) 8 | 9 | public: 10 | CDlgDisasm(); 11 | virtual ~CDlgDisasm(); 12 | BOOL OnInitDialog(); 13 | void Disasm(); 14 | void *pAddr; 15 | DWORD_PTR AltAddress; 16 | 17 | enum {IDD=IDD_DLG_DISASM}; 18 | 19 | protected: 20 | virtual void DoDataExchange(CDataExchange *pDX); 21 | 22 | public: 23 | CListBox DisasmList; 24 | }; -------------------------------------------------------------------------------- /DlgDump.cpp: -------------------------------------------------------------------------------- 1 | #include "stdafx.h" 2 | #include "Init.h" 3 | #include "DlgDump.h" 4 | 5 | IMPLEMENT_DYNAMIC(CDlgDump,CDialog) 6 | CDlgDump::CDlgDump():CDialog(CDlgDump::IDD,NULL), 7 | sData(_T("")) 8 | { 9 | } 10 | 11 | CDlgDump::~CDlgDump() 12 | { 13 | } 14 | 15 | void CDlgDump::DoDataExchange(CDataExchange *pDX) 16 | { 17 | CDialog::DoDataExchange(pDX); 18 | DDX_Text(pDX,IDC_DUMPDATA,sData); 19 | } 20 | 21 | BEGIN_MESSAGE_MAP(CDlgDump,CDialog) 22 | ON_WM_CTLCOLOR() 23 | ON_BN_CLICKED(IDC_COPYTOCLIPBOARD,OnBnClickedButtonCopyToClipboard) 24 | END_MESSAGE_MAP() 25 | 26 | BOOL CDlgDump::OnInitDialog() 27 | { 28 | CDialog::OnInitDialog(); 29 | 30 | SetWindowPos(&wndTopMost,0,0,0,0,SWP_NOMOVE | SWP_NOSIZE); 31 | return TRUE; 32 | } 33 | 34 | HBRUSH CDlgDump::OnCtlColor(CDC *pDC,CWnd *pWnd,UINT nCtlColor) 35 | { 36 | HBRUSH hbr=CDialog::OnCtlColor(pDC,pWnd,nCtlColor); 37 | 38 | if(pWnd->GetDlgCtrlID()==IDC_CRASHTEXT) 39 | { 40 | pDC->SetTextColor(RGB(0,0,0)); 41 | pDC->SetBkColor(RGB(255,255,255)); 42 | } 43 | return hbr; 44 | } 45 | 46 | void CDlgDump::OnBnClickedButtonCopyToClipboard() 47 | { 48 | OpenClipboard(); 49 | EmptyClipboard(); 50 | HGLOBAL gl=GlobalAlloc(GMEM_MOVEABLE,(sData.GetLength()+1)*sizeof(sData.GetString()[0])); 51 | _tcscpy_s((TCHAR*)GlobalLock(gl),sData.GetLength()+1,sData.GetString()); 52 | GlobalUnlock(gl); 53 | SetClipboardData(CF_TEXT,gl); 54 | CloseClipboard(); 55 | } -------------------------------------------------------------------------------- /DlgDump.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | class CDlgDump:public CDialog 4 | { 5 | DECLARE_DYNAMIC(CDlgDump) 6 | 7 | public: 8 | CDlgDump(); 9 | virtual BOOL OnInitDialog(); 10 | virtual ~CDlgDump(); 11 | 12 | enum {IDD=IDD_DLG_DUMP}; 13 | 14 | protected: 15 | virtual void DoDataExchange(CDataExchange *pDX); 16 | 17 | DECLARE_MESSAGE_MAP() 18 | public: 19 | afx_msg HBRUSH OnCtlColor(CDC *pDC,CWnd *pWnd,UINT nCtlColor); 20 | afx_msg void OnBnClickedButtonCopyToClipboard(); 21 | CString sData; 22 | }; 23 | -------------------------------------------------------------------------------- /DlgEditImport.cpp: -------------------------------------------------------------------------------- 1 | #include "stdafx.h" 2 | #include "Init.h" 3 | #include "DlgMain.h" 4 | #include "DlgEditImport.h" 5 | #include "PEFile.h" 6 | #include "Modules.h" 7 | 8 | IMPLEMENT_DYNAMIC(CDlgEditImport,CDialog) 9 | 10 | CDlgEditImport::CDlgEditImport(CModules *n_pModules,CImportRecord *n_pImportRecord):CDialog(CDlgEditImport::IDD,NULL), 11 | pModules(n_pModules), 12 | pImportRecord(n_pImportRecord) 13 | { 14 | } 15 | 16 | CDlgEditImport::~CDlgEditImport() 17 | { 18 | } 19 | 20 | void CDlgEditImport::DoDataExchange(CDataExchange *pDX) 21 | { 22 | CDialog::DoDataExchange(pDX); 23 | DDX_Control(pDX,IDC_MODULE,ModuleName); 24 | DDX_Control(pDX,IDC_FUNCTIONS,Functions); 25 | } 26 | 27 | BEGIN_MESSAGE_MAP(CDlgEditImport,CDialog) 28 | ON_BN_CLICKED(IDOK,&CDlgEditImport::OnBnClickedOK) 29 | ON_BN_CLICKED(IDCANCEL,&CDlgEditImport::OnBnClickedCancel) 30 | ON_CBN_SELCHANGE(IDC_MODULE,&CDlgEditImport::OnCbnSelchangeCombo1) 31 | END_MESSAGE_MAP() 32 | 33 | BOOL CDlgEditImport::OnInitDialog() 34 | { 35 | CDialog::OnInitDialog(); 36 | 37 | CString sTemp; 38 | GetWindowText(sTemp); sTemp=pDlgMain->LocalizeString(sTemp,true); SetWindowText(sTemp); 39 | GetDlgItemText(IDCANCEL,sTemp); sTemp=pDlgMain->LocalizeString(sTemp,true); SetDlgItemText(IDCANCEL,sTemp); 40 | 41 | for(size_t i=0;i!=pModules->Modules.size();++i) 42 | { 43 | if(!pModules->Modules[i]->Exports.empty()) 44 | ModuleName.AddString(pModules->Modules[i]->sImportName.c_str()); 45 | } 46 | if(!pImportRecord->Exist()) 47 | ModuleName.SelectString(-1,_T("kernel32.dll")); 48 | else 49 | ModuleName.SelectString(-1,pImportRecord->sLibName.c_str()); 50 | OnCbnSelchangeCombo1(); 51 | Functions.SelectString(-1,ord2+IntToStr(pImportRecord->wOrdinal,16,4)); 52 | 53 | if(pDlgMain->Option.fAlwaysOnTop) 54 | SetWindowPos(&wndTopMost,0,0,0,0,SWP_NOMOVE | SWP_NOSIZE); 55 | return TRUE; 56 | } 57 | 58 | void CDlgEditImport::OnBnClickedOK() 59 | { 60 | CString sTemp; 61 | if(ModuleName.GetCurSel()!=CB_ERR && Functions.GetCurSel()!=CB_ERR) 62 | { 63 | ModuleName.GetLBText(ModuleName.GetCurSel(),sTemp); 64 | pImportRecord->sLibName=sTemp; 65 | Functions.GetText(Functions.GetCurSel(),sTemp); 66 | sTemp.Delete(0,ord2.GetLength()); 67 | pImportRecord->wOrdinal=(WORD)_tcstoul(sTemp.Left(4),NULL,16); 68 | sTemp.Delete(0,4+name.GetLength()); 69 | #ifdef UNICODE 70 | int nWideLength=sTemp.GetLength()+1; 71 | char *pMultiArray=new char[nWideLength]; 72 | WideCharToMultiByte(CP_ACP,0,sTemp.GetBuffer(),nWideLength,pMultiArray,nWideLength,NULL,NULL); 73 | pImportRecord->sApiName=pMultiArray; 74 | delete[] pMultiArray; 75 | #else 76 | pImportRecord->sApiName=sTemp; 77 | #endif 78 | } 79 | OnOK(); 80 | } 81 | void CDlgEditImport::OnBnClickedCancel() 82 | { 83 | OnCancel(); 84 | } 85 | 86 | void CDlgEditImport::OnCbnSelchangeCombo1() 87 | { 88 | if(ModuleName.GetCurSel()==CB_ERR) 89 | return; 90 | 91 | CString sTemp; 92 | ModuleName.GetLBText(ModuleName.GetCurSel(),sTemp); 93 | for(size_t i=0;i!=pModules->Modules.size();++i) 94 | { 95 | if(sTemp!=pModules->Modules[i]->sImportName.c_str()) 96 | continue; 97 | 98 | Functions.ResetContent(); 99 | for(size_t j=0;j!=pModules->Modules[i]->Exports.size();++j) 100 | { 101 | if(pModules->Modules[i]->Exports[j].dwFuncAddress==0) 102 | continue; 103 | #ifdef UNICODE 104 | int nMultiLength=(int)pModules->Modules[i]->Exports[j].sFuncName.length()+1; 105 | WCHAR *pWideArray=new WCHAR[nMultiLength]; 106 | MultiByteToWideChar(CP_ACP,0,pModules->Modules[i]->Exports[j].sFuncName.c_str(),nMultiLength, 107 | pWideArray,nMultiLength); 108 | Functions.AddString(ord2+IntToStr(pModules->Modules[i]->Exports[j].wFuncOrdinal,16,4)+ 109 | name+pWideArray); 110 | delete[] pWideArray; 111 | #else 112 | Functions.AddString(ord2+IntToStr(pModules->Modules[i]->Exports[j].wFuncOrdinal,16,4)+ 113 | name+pModules->Modules[i]->Exports[j].sFuncName.c_str()); 114 | #endif 115 | } 116 | break; 117 | } 118 | Functions.SetFocus(); 119 | } 120 | 121 | BOOL CDlgEditImport::PreTranslateMessage(MSG *pMsg) 122 | { 123 | if(pMsg->message==WM_CHAR) 124 | { 125 | CString sHeader,sFunction; 126 | 127 | GetWindowText(sHeader); 128 | if(sHeader==editfunction) 129 | sHeader=_T(""); 130 | if(pMsg->wParam==VK_BACK) 131 | sHeader.Delete(sHeader.GetLength()-1); 132 | else 133 | sHeader.AppendChar((TCHAR)pMsg->wParam); 134 | for(int i=0;i!=Functions.GetCount();++i) 135 | { 136 | Functions.GetText(i,sFunction); 137 | sFunction.Delete(0,ord2.GetLength()+4+name.GetLength()); 138 | if(sHeader.MakeLower()==sFunction.Left(sHeader.GetLength()).MakeLower()) 139 | { 140 | Functions.SetCurSel(i); 141 | break; 142 | } 143 | } 144 | SetWindowText(sHeader.GetString()); 145 | } 146 | else if(pMsg->message==WM_LBUTTONDOWN) 147 | SetWindowText(editfunction); 148 | return CDialog::PreTranslateMessage(pMsg); 149 | } -------------------------------------------------------------------------------- /DlgEditImport.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "afxcmn.h" 4 | #include "afxwin.h" 5 | #include "DlgDisasm.h" 6 | #include "PEFile.h" 7 | 8 | class CDlgEditImport:public CDialog 9 | { 10 | DECLARE_DYNAMIC(CDlgEditImport) 11 | 12 | public: 13 | CDlgEditImport(CModules *n_pModules,CImportRecord *n_pImportRecord); 14 | virtual ~CDlgEditImport(); 15 | 16 | enum {IDD=IDD_DLG_EDITIMPORT}; 17 | 18 | protected: 19 | virtual void DoDataExchange(CDataExchange *pDX); 20 | 21 | DECLARE_MESSAGE_MAP() 22 | public: 23 | CListCtrl ImportList; 24 | afx_msg void OnBnClickedOK(); 25 | afx_msg void OnBnClickedCancel(); 26 | afx_msg void OnCbnSelchangeCombo1(); 27 | virtual BOOL OnInitDialog(); 28 | 29 | protected: 30 | CModules *pModules; 31 | CImportRecord *pImportRecord; 32 | public: 33 | CComboBox ModuleName; 34 | CListBox Functions; 35 | BOOL PreTranslateMessage(MSG *pMsg); 36 | }; -------------------------------------------------------------------------------- /DlgFinders.cpp: -------------------------------------------------------------------------------- 1 | #include "stdafx.h" 2 | #include "Init.h" 3 | #include "DlgFinders.h" 4 | #include "DlgMain.h" 5 | 6 | bool fIsDll; 7 | CListBox FindersBox; 8 | DWORD dwOEPFinderResult; 9 | 10 | IMPLEMENT_DYNAMIC(CDlgFinders,CDialog) 11 | 12 | CDlgFinders::CDlgFinders(bool n_fIsDll):CDialog(CDlgFinders::IDD,NULL) 13 | { 14 | fIsDll=n_fIsDll; 15 | } 16 | 17 | CDlgFinders::~CDlgFinders() 18 | { 19 | UnloadOEPFinders(); 20 | } 21 | 22 | void CDlgFinders::DoDataExchange(CDataExchange *pDX) 23 | { 24 | CDialog::DoDataExchange(pDX); 25 | DDX_Control(pDX,IDC_OEPFINDERSBOX,FindersBox); 26 | } 27 | 28 | BEGIN_MESSAGE_MAP(CDlgFinders,CDialog) 29 | ON_LBN_DBLCLK(IDC_OEPFINDERSBOX,OnLbnDblclkOepfindersbox) 30 | END_MESSAGE_MAP() 31 | 32 | const TCHAR szOEPPluginSearch[]=_T("\\OEPFinders\\*.dll"); 33 | const TCHAR szOEPPluginDir[]=_T("\\OEPFinders\\"); 34 | const char szGetOEP[]="GetOEPNow"; 35 | const char szGetDllOEP[]="GetDllOEPNow"; 36 | const char szOEPGetNamePluginFn[]="ShortFinderName"; 37 | 38 | typedef DWORD (__stdcall *StartFinder)(const BYTE*); 39 | typedef const BYTE *(__stdcall *GetFinderName)(); 40 | 41 | struct FINDER_INFO 42 | { 43 | HMODULE hModule; 44 | StartFinder StartFunc; 45 | bool fUnicode; 46 | }; 47 | 48 | std::vector OEPFinders; 49 | 50 | void LoadOEPFinders(HWND hWnd) 51 | { 52 | TCHAR cBuff[MAX_PATH]={_T('\0')}; 53 | WIN32_FIND_DATA Find={0}; 54 | HANDLE hFind; 55 | 56 | GetModuleFileName(NULL,cBuff,_countof(cBuff)); 57 | PathToDir(cBuff); 58 | _tcscat_s(cBuff,szOEPPluginSearch); 59 | 60 | hFind=FindFirstFile(cBuff,&Find); 61 | if(hFind!=INVALID_HANDLE_VALUE) 62 | { 63 | do ProcessOEPFinder(Find.cFileName); 64 | while(FindNextFile(hFind,&Find)); 65 | 66 | FindClose(hFind); 67 | } 68 | 69 | EnableWindow(hWnd,OEPFinders.empty() ? FALSE : TRUE); 70 | } 71 | 72 | void ProcessOEPFinder(TCHAR *szDllName) 73 | { 74 | StartFinder pFn; 75 | GetFinderName pFnGetName; 76 | HMODULE hModule; 77 | TCHAR cBuff[MAX_PATH]={_T('\0')}; 78 | 79 | GetModuleFileName(NULL,cBuff,_countof(cBuff)); 80 | PathToDir(cBuff); 81 | _tcscat_s(cBuff,szOEPPluginDir); 82 | _tcscat_s(cBuff,szDllName); 83 | 84 | hModule=LoadLibrary(cBuff); 85 | if(hModule==NULL) 86 | return; 87 | 88 | if(fIsDll) 89 | pFn=(StartFinder)GetProcAddress(hModule,szGetDllOEP); 90 | else 91 | pFn=(StartFinder)GetProcAddress(hModule,szGetOEP); 92 | pFnGetName=(GetFinderName)GetProcAddress(hModule,szOEPGetNamePluginFn); 93 | 94 | if(pFn!=NULL && pFnGetName!=NULL) 95 | { 96 | FINDER_INFO FinderInfo; 97 | FinderInfo.hModule=hModule; 98 | FinderInfo.StartFunc=pFn; 99 | FinderInfo.fUnicode=pFnGetName()[1]==0; 100 | OEPFinders.push_back(FinderInfo); 101 | 102 | TCHAR *szName; 103 | if(FinderInfo.fUnicode) 104 | { 105 | size_t nLength=wcslen((WCHAR*)pFnGetName())+2; 106 | szName=new TCHAR[nLength]; 107 | #ifdef UNICODE 108 | _stprintf_s(szName,nLength,_T("%ls"),pFnGetName()); 109 | #else 110 | _stprintf_s(szName,nLength,_T("%ls*"),pFnGetName()); 111 | #endif 112 | } 113 | else 114 | { 115 | size_t nLength=strlen((char*)pFnGetName())+2; 116 | szName=new TCHAR[nLength]; 117 | #ifdef UNICODE 118 | _stprintf_s(szName,nLength,_T("%hs*"),pFnGetName()); 119 | #else 120 | _stprintf_s(szName,nLength,_T("%hs"),pFnGetName()); 121 | #endif 122 | } 123 | FindersBox.AddString(szName); 124 | delete[] szName; 125 | } 126 | } 127 | 128 | void UnloadOEPFinders() 129 | { 130 | for(size_t i=0;i!=OEPFinders.size();++i) 131 | FreeLibrary(OEPFinders[i].hModule); 132 | OEPFinders.clear(); 133 | } 134 | 135 | BOOL CDlgFinders::OnInitDialog() 136 | { 137 | CDialog::OnInitDialog(); 138 | 139 | CString sTemp; 140 | GetWindowText(sTemp); sTemp=pDlgMain->LocalizeString(sTemp,true); SetWindowText(sTemp); 141 | 142 | LoadOEPFinders(GetSafeHwnd()); 143 | FindersBox.SetCurSel(0); 144 | FindersBox.SelectString(-1,_T("ForceOEP")); 145 | 146 | if(pDlgMain->Option.fAlwaysOnTop) 147 | SetWindowPos(&wndTopMost,0,0,0,0,SWP_NOMOVE | SWP_NOSIZE); 148 | return TRUE; 149 | } 150 | 151 | void CDlgFinders::OnLbnDblclkOepfindersbox() 152 | { 153 | size_t nLength=pDlgMain->InitData.sVictimFile.length()+1; 154 | BYTE *szName; 155 | if(OEPFinders[FindersBox.GetCurSel()].fUnicode) 156 | { 157 | szName=(BYTE*)new WCHAR[nLength]; 158 | #ifdef UNICODE 159 | swprintf_s((WCHAR*)szName,nLength,L"%ls",pDlgMain->InitData.sVictimFile.c_str()); 160 | #else 161 | swprintf_s((WCHAR*)szName,nLength,L"%hs",pDlgMain->InitData.sVictimFile.c_str()); 162 | #endif 163 | } 164 | else 165 | { 166 | szName=(BYTE*)new char[nLength]; 167 | #ifdef UNICODE 168 | sprintf_s((char*)szName,nLength,"%ls",pDlgMain->InitData.sVictimFile.c_str()); 169 | #else 170 | sprintf_s((char*)szName,nLength,"%hs",pDlgMain->InitData.sVictimFile.c_str()); 171 | #endif 172 | } 173 | dwOEPFinderResult=OEPFinders[FindersBox.GetCurSel()].StartFunc(szName); 174 | delete[] szName; 175 | 176 | pDlgMain->UpdateData(TRUE); 177 | pDlgMain->sOEPbox.Format(_T("%08X"),dwOEPFinderResult); 178 | pDlgMain->UpdateData(FALSE); 179 | 180 | OnOK(); 181 | } -------------------------------------------------------------------------------- /DlgFinders.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "afxwin.h" 4 | 5 | class CDlgFinders:public CDialog 6 | { 7 | DECLARE_DYNAMIC(CDlgFinders) 8 | 9 | public: 10 | CDlgFinders(bool n_fIsDll); 11 | ~CDlgFinders(); 12 | 13 | enum {IDD=IDD_DLG_FINDERS}; 14 | 15 | protected: 16 | virtual BOOL OnInitDialog(); 17 | virtual void DoDataExchange(CDataExchange *pDX); 18 | DECLARE_MESSAGE_MAP() 19 | public: 20 | afx_msg void OnLbnDblclkOepfindersbox(); 21 | }; 22 | 23 | void LoadOEPFinders(HWND hWnd); 24 | void UnloadOEPFinders(); 25 | void ProcessOEPFinder(TCHAR *szDllName); -------------------------------------------------------------------------------- /DlgImport.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "PEFile.h" 4 | 5 | class CDlgImport:public CDialog 6 | { 7 | DECLARE_DYNAMIC(CDlgImport) 8 | 9 | public: 10 | CDlgImport(CImport *n_pImport,CPEFile *n_pPEMain,CModules *n_pModules,const TCHAR *n_szPEFileName,CMain *n_pMain); 11 | virtual ~CDlgImport(); 12 | 13 | enum {IDD=IDD_DLG_IMPORT}; 14 | 15 | protected: 16 | virtual void DoDataExchange(CDataExchange *pDX); 17 | 18 | DECLARE_MESSAGE_MAP() 19 | public: 20 | CListCtrl ImportList; 21 | virtual BOOL OnInitDialog(); 22 | 23 | private: 24 | void ChangeWndHeader(); 25 | void FillImport(); 26 | void FillRecord(int i); 27 | void FillTable(); 28 | 29 | ESortImportType ImportSortType; 30 | CImport *pImport; 31 | CPEFile *pPEMain; 32 | CModules *pModules; 33 | const TCHAR *szPEFileName; 34 | CMain *pMain; 35 | CString sImpRVAbox; 36 | public: 37 | afx_msg void DoUpdateData(); 38 | afx_msg void OnBnClickedUseOldIAT(); 39 | afx_msg void OnBnClickedSaveOriginal(); 40 | afx_msg void OnBnClickedDeleteSelected(); 41 | afx_msg void OnBnClickedDeleteInvalid(); 42 | afx_msg void OnBnClickedExport(); 43 | afx_msg void OnBnClickedImpEdit(); 44 | afx_msg void OnBnClickedImpLoadLib(); 45 | afx_msg void OnBnClickedImport(); 46 | afx_msg void OnBnClickedImpDisasm(); 47 | afx_msg void OnNMCustomdrawImportlist(NMHDR *pNMHDR,LRESULT *pResult); 48 | afx_msg void OnItemChangedImportlist(NMHDR *pNMHDR,LRESULT *pResult); 49 | afx_msg void OnBnClickedChangeSort(); 50 | afx_msg void OnBnClickedPrevForw(); 51 | afx_msg void OnBnClickedNextForw(); 52 | afx_msg void OnBnClickedPrevFunc(); 53 | afx_msg void OnBnClickedNextFunc(); 54 | }; 55 | -------------------------------------------------------------------------------- /DlgInput.cpp: -------------------------------------------------------------------------------- 1 | #include "stdafx.h" 2 | #include "Init.h" 3 | #include "DlgInput.h" 4 | #include "DlgMain.h" 5 | 6 | IMPLEMENT_DYNAMIC(CDlgInput,CDialog) 7 | 8 | CDlgInput::CDlgInput(TSTRING *n_pName,const TCHAR *szCaption,const TCHAR *szDefault) 9 | :CDialog(CDlgInput::IDD,NULL), 10 | pName(n_pName), 11 | sCaption(szCaption), 12 | sDefault(szDefault) 13 | { 14 | } 15 | 16 | void CDlgInput::DoDataExchange(CDataExchange *pDX) 17 | { 18 | CDialog::DoDataExchange(pDX); 19 | DDX_Text(pDX,IDC_INPUTEDIT,sValue); 20 | } 21 | 22 | BEGIN_MESSAGE_MAP(CDlgInput,CDialog) 23 | ON_EN_CHANGE(IDC_INPUTEDIT,DoUpdateData) 24 | END_MESSAGE_MAP() 25 | 26 | void CDlgInput::DoUpdateData() 27 | { 28 | UpdateData(TRUE); 29 | } 30 | 31 | BOOL CDlgInput::OnInitDialog() 32 | { 33 | CDialog::OnInitDialog(); 34 | 35 | CString sTemp; 36 | GetWindowText(sTemp); sTemp=pDlgMain->LocalizeString(sTemp,true); SetWindowText(sTemp); 37 | GetDlgItemText(IDCANCEL,sTemp); sTemp=pDlgMain->LocalizeString(sTemp,true); SetDlgItemText(IDCANCEL,sTemp); 38 | 39 | SetWindowText(sCaption.c_str()); 40 | sValue=sDefault.c_str(); 41 | GetDlgItem(IDC_INPUTEDIT)->SetFocus(); 42 | if(pDlgMain->Option.fAlwaysOnTop) 43 | SetWindowPos(&wndTopMost,0,0,0,0,SWP_NOMOVE | SWP_NOSIZE); 44 | return FALSE; 45 | } 46 | 47 | void CDlgInput::OnOK() 48 | { 49 | *pName=sValue; 50 | CDialog::OnOK(); 51 | } -------------------------------------------------------------------------------- /DlgInput.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "afxwin.h" 4 | 5 | class CDlgInput:public CDialog 6 | { 7 | DECLARE_DYNAMIC(CDlgInput) 8 | 9 | public: 10 | CDlgInput(TSTRING *n_pName,const TCHAR *szCaption,const TCHAR *szDefault); 11 | afx_msg void DoUpdateData(); 12 | BOOL OnInitDialog(); 13 | void OnOK(); 14 | 15 | enum {IDD=IDD_DLG_INPUT}; 16 | protected: 17 | DECLARE_MESSAGE_MAP() 18 | virtual void DoDataExchange(CDataExchange *pDX); 19 | TSTRING *pName,sCaption,sDefault; 20 | CString sValue; 21 | }; -------------------------------------------------------------------------------- /DlgLicense.cpp: -------------------------------------------------------------------------------- 1 | #include "stdafx.h" 2 | #include "Init.h" 3 | #include "DlgLicense.h" 4 | #include "DlgMain.h" 5 | 6 | const int nHotKeyID=50; 7 | const int nTimerID=2; 8 | 9 | IMPLEMENT_DYNAMIC(CDlgLicense,CDialog) 10 | CDlgLicense::CDlgLicense(bool n_fEnableButton):CDialog(CDlgLicense::IDD,NULL), 11 | sLicense(_T("")), 12 | fEnableButton(n_fEnableButton) 13 | { 14 | } 15 | 16 | CDlgLicense::~CDlgLicense() 17 | { 18 | } 19 | 20 | void CDlgLicense::DoDataExchange(CDataExchange *pDX) 21 | { 22 | CDialog::DoDataExchange(pDX); 23 | DDX_Text(pDX,IDC_LICENSETEXT,sLicense); 24 | } 25 | 26 | BEGIN_MESSAGE_MAP(CDlgLicense,CDialog) 27 | ON_BN_CLICKED(IDCANCEL,OnBnClickedCancel) 28 | ON_BN_CLICKED(IDOK,OnBnClickedOK) 29 | ON_WM_TIMER() 30 | END_MESSAGE_MAP() 31 | 32 | BOOL CDlgLicense::OnInitDialog() 33 | { 34 | CDialog::OnInitDialog(); 35 | 36 | sLicense="QuickUnpack is Copyright (c) 2007 Archer & FEUERRADER [AHTeam]\r\nAll rights reserved.\r\n\r\nTHIS PROGRAM IS PROTECTED BY COPYRIGHT LAW AND INTERNATIONAL TREATIES.\r\nBREAKING THE FOLLOWING AGREEMENT WILL RESULT IN SEVERE CIVIL AND CRIMINAL\r\nPENALTIES AND WILL BE PROSECUTED TO THE MAXIMUM EXTENT POSSIBLE UNDER LAW.\r\n\r\nTHIS AGREEMENT IS A LEGAL DOCUMENT. READ IT CAREFULLY BEFORE USING THE\r\nSOFTWARE. IT PROVIDES A LICENSE TO USE THE SOFTWARE.\r\n\r\n\"Software\" means the program supplied by FEUERRADER herewith.\r\n\r\nPermission is hereby granted to any individual, organization or agency to\r\nuse the Software for any legal NON-COMMERCIAL purpose, without any\r\nobligation to the author. You may distribute the Software freely,\r\nprovided that the original distribution package (binaries and any other\r\nfiles included in it) is left intact. You may also disassemble, reverse\r\nengineer or modify the Software, but you MAY NOT distribute it in modified\r\nform.\r\n\r\nAny COMMERCIAL use of the Software without prior written permission from\r\nthe author is strictly prohibited.\r\n\r\nDISCLAIMER OF LIABILITY\r\n\r\nTHIS SOFTWARE IS PROVIDED BY FEUERRADER \"AS IS\" AND ANY EXPRESS OR\r\nIMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED\r\nWARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE\r\nARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY\r\nDIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL\r\nDAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS\r\nOR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)\r\nHOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN\r\nCONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)\r\nARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF\r\nTHE POSSIBILITY OF SUCH DAMAGE."; 37 | GetDlgItem(IDC_LICENSETEXT)->SendMessage(EM_SETBKGNDCOLOR,FALSE,::GetSysColor(COLOR_BTNFACE)); 38 | if(fEnableButton) 39 | GetDlgItem(IDOK)->EnableWindow(TRUE); 40 | else 41 | { 42 | RegisterHotKey(GetSafeHwnd(),nHotKeyID,MOD_ALT,VK_F4); 43 | SetTimer(nTimerID,4000,NULL); 44 | } 45 | UpdateData(FALSE); 46 | 47 | GetDlgItem(IDCANCEL)->SetFocus(); 48 | if(pDlgMain->Option.fAlwaysOnTop) 49 | SetWindowPos(&wndTopMost,0,0,0,0,SWP_NOMOVE | SWP_NOSIZE); 50 | return FALSE; 51 | } 52 | 53 | void CDlgLicense::OnBnClickedCancel() 54 | { 55 | ExitProcess(666); 56 | } 57 | 58 | void CDlgLicense::OnBnClickedOK() 59 | { 60 | OnOK(); 61 | } 62 | 63 | void CDlgLicense::OnTimer(UINT_PTR nIDEvent) 64 | { 65 | if(nIDEvent==nTimerID) 66 | { 67 | UnregisterHotKey(GetSafeHwnd(),nHotKeyID); 68 | KillTimer(nTimerID); 69 | GetDlgItem(IDOK)->EnableWindow(TRUE); 70 | } 71 | else 72 | CDialog::OnTimer(nIDEvent); 73 | } -------------------------------------------------------------------------------- /DlgLicense.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "afxcmn.h" 4 | 5 | class CDlgLicense:public CDialog 6 | { 7 | DECLARE_DYNAMIC(CDlgLicense) 8 | 9 | public: 10 | CString sLicense; 11 | CDlgLicense(bool n_fEnableButton); 12 | virtual ~CDlgLicense(); 13 | virtual BOOL OnInitDialog(); 14 | afx_msg void OnBnClickedCancel(); 15 | afx_msg void OnBnClickedOK(); 16 | afx_msg void OnTimer(UINT_PTR nIDEvent); 17 | 18 | enum {IDD=IDD_DLG_LICENSE}; 19 | 20 | protected: 21 | virtual void DoDataExchange(CDataExchange *pDX); 22 | 23 | bool fEnableButton; 24 | DECLARE_MESSAGE_MAP() 25 | }; -------------------------------------------------------------------------------- /DlgLua.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "afxcmn.h" 4 | #include "Main.h" 5 | 6 | unsigned int __stdcall ScriptThread(void *pInitData); 7 | 8 | class CDlgLua:public CDialog 9 | { 10 | DECLARE_DYNAMIC(CDlgLua) 11 | 12 | public: 13 | HANDLE hTimerThread,hInitialEvent,hTimerEvent; 14 | DWORD dwTimerTimeout; 15 | 16 | CDlgLua(CInitData *pInitData); 17 | virtual ~CDlgLua(); 18 | virtual BOOL OnInitDialog(); 19 | virtual void DoDataExchange(CDataExchange *pDX); 20 | afx_msg void OnBnClickedLoad(); 21 | afx_msg void OnBnClickedSave(); 22 | afx_msg void OnBnClickedRun(); 23 | afx_msg void OnBnClickedClose(); 24 | afx_msg void OnBnClickedSaveAs(); 25 | afx_msg void OnClose(); 26 | 27 | enum {IDD=IDD_DLG_LUA}; 28 | protected: 29 | CString sScript; 30 | HWND hWndTemp; 31 | DECLARE_MESSAGE_MAP() 32 | void UpdateScript(); 33 | }; -------------------------------------------------------------------------------- /DlgMain.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "afxcmn.h" 4 | #include "afxwin.h" 5 | #include "Init.h" 6 | #include "EngineHandler.h" 7 | #include "Main.h" 8 | #include "DlgDisasm.h" 9 | 10 | struct OPTIONS 11 | { 12 | bool fAlwaysOnTop; 13 | bool fShowLicense; 14 | TCHAR szCurrDir[MAX_PATH]; 15 | TCHAR szLang[MAX_PATH]; 16 | TCHAR szDrvName[17]; 17 | TCHAR szSymbLinkName[17]; 18 | }; 19 | 20 | class CDlgMain:public CDialog 21 | { 22 | public: 23 | #ifdef DLLFILE 24 | HMODULE hForce; 25 | CDlgMain(TCHAR *szPath); 26 | ~CDlgMain(); 27 | #else 28 | CDlgMain(); 29 | #endif 30 | 31 | enum {IDD=IDD_DLG_MAIN}; 32 | 33 | HICON hIcon; 34 | CRichEditCtrl RichEdit; 35 | CFont Font; 36 | 37 | OPTIONS Option; 38 | CString sCutModuleBox,sModEndBox,sOEPbox,sParamBox,sTimeDeltabox; 39 | BOOL fAppendOverlay,fAutosaveLog,fDelphiInit,fDirectRefs,fExecuteFunc,fForce,fLeaveDirectRefs,fLongImport,fPathToLibs,fProtectDr,fRelocs,fRemoveSect,fSuspectFunc,fUseTf; 40 | 41 | bool fExit; 42 | HANDLE hMainThread; 43 | CInitData InitData; 44 | std::vector Localization; 45 | BOOL fSecret; 46 | 47 | void ClearLog(); 48 | void SaveLogToFile(const TCHAR *szFileName,bool fAnnounceSize); 49 | void SaveLog(); 50 | void WriteEx(CString sLine,BOOL fDoBreak,BOOL fBold,COLORREF Color); 51 | void Write(const CString &sLine); 52 | void WriteLn(const CString &sLine); 53 | void WriteTime(); 54 | void WriteLog(const CString &sLine); 55 | void ProcessString(std::vector &StrArray,CString sString); 56 | CString LocalizeString(CString sName,bool fForward); 57 | void Localize(bool fForward); 58 | void LoadLocalization(); 59 | 60 | afx_msg void OnBnClickedOpen(); 61 | afx_msg void OnBnClickedAttach(); 62 | afx_msg void OnBnClickedUnpack(); 63 | afx_msg void OnBnClickedKill(); 64 | afx_msg void OnBnClickedFindOEP(); 65 | #ifndef DLLFILE 66 | DECLARE_MESSAGE_MAP() 67 | virtual void DoDataExchange(CDataExchange *pDX); 68 | afx_msg void DoUpdateData(); 69 | afx_msg void OnClose(); 70 | afx_msg void OnDropFiles(HDROP hDropInfo); 71 | afx_msg void OnPaint(); 72 | afx_msg HCURSOR OnQueryDragIcon(); 73 | afx_msg void OnTimer(UINT_PTR nIDEvent); 74 | virtual LRESULT WindowProc(UINT message,WPARAM wParam,LPARAM lParam); 75 | virtual BOOL OnInitDialog(); 76 | afx_msg void OnBnClickedChangeEngine(); 77 | afx_msg void OnBnClickedScript(); 78 | afx_msg void OnBnClickedTest(); 79 | afx_msg void OnBnClickedFindObject(); 80 | afx_msg void OnBnClickedUnpDel(); 81 | afx_msg void OnBnClickedExit(); 82 | afx_msg void OnBnClickedDisasm(); 83 | afx_msg void OnBnClickedFindDelta(); 84 | afx_msg void OnOptionsPreferences(); 85 | afx_msg void OnAboutLicenseAgreement(); 86 | afx_msg void OnAboutAbout(); 87 | void BlockButtonsAndMenus(BOOL fEnable); 88 | void SetDLLUnpackingMode(BOOL fIsDll); 89 | #endif 90 | }; 91 | extern CDlgMain *pDlgMain; 92 | 93 | extern OPTIONS *pOptions; 94 | void ClearLog(); 95 | void WriteEx(CString sLine,BOOL fDoBreak,BOOL fBold,COLORREF Color); 96 | void Write(const CString &sLine); 97 | void WriteLn(const CString &sLine); 98 | void WriteTime(); 99 | void WriteLog(const CString &sLine); -------------------------------------------------------------------------------- /DlgPref.cpp: -------------------------------------------------------------------------------- 1 | #include "stdafx.h" 2 | #include "Init.h" 3 | #include "DlgMain.h" 4 | #include "DlgPref.h" 5 | #include "RegistryKey.h" 6 | #include ".\DlgPref.h" 7 | 8 | IMPLEMENT_DYNAMIC(CDlgPref,CDialog) 9 | CDlgPref::CDlgPref():CDialog(CDlgPref::IDD,NULL) 10 | { 11 | } 12 | 13 | CDlgPref::~CDlgPref() 14 | { 15 | } 16 | 17 | void CDlgPref::DoDataExchange(CDataExchange *pDX) 18 | { 19 | CDialog::DoDataExchange(pDX); 20 | DDX_Control(pDX,IDC_LANGS,Lang); 21 | } 22 | 23 | BEGIN_MESSAGE_MAP(CDlgPref,CDialog) 24 | ON_BN_CLICKED(IDC_SAVEPREF,OnBnClickedSavePref) 25 | END_MESSAGE_MAP() 26 | 27 | void CDlgPref::OnBnClickedSavePref() 28 | { 29 | bool fNeedLocalize=true; 30 | CString sTemp; 31 | Lang.GetLBText(Lang.GetCurSel(),sTemp); 32 | if(_tcscmp(pDlgMain->Option.szLang,sTemp.GetBuffer())==0) 33 | fNeedLocalize=false; 34 | else 35 | _tcscpy_s(pDlgMain->Option.szLang,sTemp.GetBuffer()); 36 | 37 | if(IsDlgButtonChecked(IDC_ALWAYSONTOP)==BST_CHECKED) 38 | pDlgMain->Option.fAlwaysOnTop=true; 39 | else 40 | pDlgMain->Option.fAlwaysOnTop=false; 41 | 42 | CRegistryKey RegKey; 43 | RegKey.RegistryWriteStruct(REG_KEY_NAME,REG_VALUE_NAME,(void*)&pDlgMain->Option,sizeof(pDlgMain->Option)); 44 | if(fNeedLocalize) 45 | { 46 | pDlgMain->Localize(false); 47 | pDlgMain->LoadLocalization(); 48 | pDlgMain->Localize(true); 49 | } 50 | 51 | if(IsDlgButtonChecked(IDC_REGSHELLEXT)==BST_CHECKED) 52 | RegKey.RegisterShellExt(); 53 | else 54 | RegKey.UnRegisterShellExt(); 55 | 56 | AnimateWindow(300,AW_BLEND | AW_HIDE); 57 | OnOK(); 58 | } 59 | 60 | BOOL CDlgPref::OnInitDialog() 61 | { 62 | TCHAR cBuff[MAX_PATH]={_T('\0')}; 63 | WIN32_FIND_DATA Find={0}; 64 | HANDLE hFind; 65 | 66 | CDialog::OnInitDialog(); 67 | 68 | CString sTemp; 69 | GetWindowText(sTemp); sTemp=pDlgMain->LocalizeString(sTemp,true); SetWindowText(sTemp); 70 | GetDlgItemText(IDC_SAVEPREF,sTemp); sTemp=pDlgMain->LocalizeString(sTemp,true); SetDlgItemText(IDC_SAVEPREF,sTemp); 71 | GetDlgItemText(IDC_REGSHELLEXT,sTemp); sTemp=pDlgMain->LocalizeString(sTemp,true); SetDlgItemText(IDC_REGSHELLEXT,sTemp); 72 | GetDlgItemText(IDCANCEL,sTemp); sTemp=pDlgMain->LocalizeString(sTemp,true); SetDlgItemText(IDCANCEL,sTemp); 73 | GetDlgItemText(IDC_ALWAYSONTOP,sTemp); sTemp=pDlgMain->LocalizeString(sTemp,true); SetDlgItemText(IDC_ALWAYSONTOP,sTemp); 74 | 75 | CRegistryKey RegKey; 76 | GetDlgItem(IDC_REGSHELLEXT)->SendMessage(BM_SETCHECK,RegKey.IsShellRegisterExt(),0); 77 | GetDlgItem(IDC_ALWAYSONTOP)->SendMessage(BM_SETCHECK,pDlgMain->Option.fAlwaysOnTop,0); 78 | 79 | GetModuleFileName(NULL,cBuff,_countof(cBuff)); 80 | PathToDir(cBuff); 81 | _tcscat_s(cBuff,_T("\\*.lng")); 82 | 83 | Lang.ResetContent(); 84 | Lang.AddString(_T("english.lng")); 85 | hFind=FindFirstFile(cBuff,&Find); 86 | if(hFind!=INVALID_HANDLE_VALUE) 87 | { 88 | do Lang.AddString(Find.cFileName); 89 | while(FindNextFile(hFind,&Find)); 90 | FindClose(hFind); 91 | } 92 | Lang.SelectString(-1,pDlgMain->Option.szLang); 93 | if(pDlgMain->Option.fAlwaysOnTop) 94 | SetWindowPos(&wndTopMost,0,0,0,0,SWP_NOMOVE | SWP_NOSIZE); 95 | return TRUE; 96 | } -------------------------------------------------------------------------------- /DlgPref.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "afxwin.h" 4 | 5 | class CDlgPref:public CDialog 6 | { 7 | DECLARE_DYNAMIC(CDlgPref) 8 | 9 | public: 10 | CDlgPref(); 11 | virtual ~CDlgPref(); 12 | 13 | enum {IDD=IDD_DLG_PREF}; 14 | 15 | protected: 16 | virtual void DoDataExchange(CDataExchange *pDX); 17 | virtual BOOL OnInitDialog(); 18 | 19 | DECLARE_MESSAGE_MAP() 20 | public: 21 | afx_msg void OnBnClickedSavePref(); 22 | CComboBox Lang; 23 | }; -------------------------------------------------------------------------------- /Engine/MAKEFILE: -------------------------------------------------------------------------------- 1 | # DO NOT EDIT THIS FILE!!! Edit .\sources. if you want to add a new source 2 | # file to this component. This file merely indirects to the real make file 3 | # that is shared by all the driver components of the Windows NT DDK 4 | # 5 | 6 | !IF "$(DDKBUILDENV)"=="fre" 7 | LINKER_FORCE_NO_DBG_SECTION=1 8 | !ENDIF 9 | !INCLUDE $(NTMAKEENV)\makefile.def -------------------------------------------------------------------------------- /Engine/SOURCES: -------------------------------------------------------------------------------- 1 | TARGETNAME=QUnpack 2 | TARGETPATH=. 3 | TARGETTYPE=DRIVER 4 | I386_SOURCES=engine32.asm 5 | AMD64_SOURCES=engine64.asm 6 | SOURCES=engine.c -------------------------------------------------------------------------------- /Engine/amd64/QUnpack.sys: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fatrolls/Quick-Unpack/48070723aa80c1f2b6d1c43c345e51c37c1ea5b2/Engine/amd64/QUnpack.sys -------------------------------------------------------------------------------- /Engine/amd64/interface64.inc: -------------------------------------------------------------------------------- 1 | STATE_READY EQU 00h 2 | STATE_SINGLESTEP EQU 01h 3 | STATE_BREAK EQU 02h 4 | STATE_BREAKALT EQU 03h 5 | STATE_BREAKMEM EQU 04h 6 | 7 | STATE_HANDLED EQU 10h 8 | STATE_UNHANDLED EQU 11h 9 | 10 | STATE_BUSY EQU 20h 11 | 12 | KTRAP_SIZE EQU 168h 13 | 14 | DATA_STATE STRUCT 1 15 | State DD ? 16 | ThreadID DD ? 17 | 18 | RegCr2 DQ ? 19 | RegDr0 DQ ? 20 | RegDr1 DQ ? 21 | RegDr2 DQ ? 22 | RegDr3 DQ ? 23 | RegDr6 DQ ? 24 | RegDr7 DQ ? 25 | 26 | RegIp DQ ? 27 | RegCS DQ ? 28 | RegFlags DQ ? 29 | RegSp DQ ? 30 | 31 | RegDi DQ ? 32 | RegSi DQ ? 33 | RegBp DQ ? 34 | RegBx DQ ? 35 | RegDx DQ ? 36 | RegCx DQ ? 37 | RegAx DQ ? 38 | 39 | Reg8 DQ ? 40 | Reg9 DQ ? 41 | Reg10 DQ ? 42 | Reg11 DQ ? 43 | Reg12 DQ ? 44 | Reg13 DQ ? 45 | Reg14 DQ ? 46 | Reg15 DQ ? 47 | DATA_STATE ENDS -------------------------------------------------------------------------------- /Engine/i386/QUnpack.sys: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fatrolls/Quick-Unpack/48070723aa80c1f2b6d1c43c345e51c37c1ea5b2/Engine/i386/QUnpack.sys -------------------------------------------------------------------------------- /Engine/i386/interface32.inc: -------------------------------------------------------------------------------- 1 | STATE_READY EQU 00h 2 | STATE_SINGLESTEP EQU 01h 3 | STATE_BREAK EQU 02h 4 | STATE_BREAKALT EQU 03h 5 | STATE_BREAKMEM EQU 04h 6 | 7 | STATE_HANDLED EQU 10h 8 | STATE_UNHANDLED EQU 11h 9 | 10 | STATE_BUSY EQU 20h 11 | 12 | KTRAP_SIZE EQU 29ch 13 | 14 | DATA_STATE STRUCT 1 15 | State DD ? 16 | ThreadID DD ? 17 | 18 | RegCr2 DD ? 19 | RegDr0 DD ? 20 | RegDr1 DD ? 21 | RegDr2 DD ? 22 | RegDr3 DD ? 23 | RegDr6 DD ? 24 | RegDr7 DD ? 25 | 26 | RegIp DD ? 27 | RegCS DD ? 28 | RegFlags DD ? 29 | RegSp DD ? 30 | 31 | RegDi DD ? 32 | RegSi DD ? 33 | RegBp DD ? 34 | RegSp0 DD ? 35 | RegBx DD ? 36 | RegDx DD ? 37 | RegCx DD ? 38 | RegAx DD ? 39 | DATA_STATE ENDS -------------------------------------------------------------------------------- /Engine/make32.bat: -------------------------------------------------------------------------------- 1 | build -cwZ 2 | del build* -------------------------------------------------------------------------------- /Engine/make64.bat: -------------------------------------------------------------------------------- 1 | build -cwZ 2 | del build* -------------------------------------------------------------------------------- /EngineHandler.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "interface.h" 4 | #include 5 | #include 6 | 7 | class CEngine 8 | { 9 | static HANDLE hEngine; 10 | DATA_STATE *pContext; 11 | bool fStartedByThisProgram; 12 | bool fStartedByThisCopy; 13 | 14 | void GetEngineHandle(bool fShowError); 15 | 16 | void Create(HMODULE hDllHandle); 17 | void Delete(); 18 | 19 | void Control(DWORD dwCode,void *pInData,DWORD dwInSize,void *pOutData,DWORD dwOutSize) const; 20 | 21 | public: 22 | CEngine(HMODULE hDllHandle); 23 | ~CEngine(); 24 | 25 | void Hook(DWORD dwPID,DWORD dwInt1,DWORD dwInt0d,DWORD dwInt0e) const; 26 | void GetState(DATA_STATE *pData) const; 27 | void SetState(DATA_STATE *pData); 28 | DWORD_PTR GetModHandle(DWORD dwPID,const TCHAR *szModuleName) const; 29 | 30 | void EmulateRDTSC(DWORD dwHook,DWORD dwShift) const; 31 | void EmulateCPUID(DWORD dwHook) const; 32 | }; -------------------------------------------------------------------------------- /EngineSVM/MAKEFILE: -------------------------------------------------------------------------------- 1 | # DO NOT EDIT THIS FILE!!! Edit .\sources. if you want to add a new source 2 | # file to this component. This file merely indirects to the real make file 3 | # that is shared by all the driver components of the Windows NT DDK 4 | # 5 | 6 | !IF "$(DDKBUILDENV)"=="fre" 7 | LINKER_FORCE_NO_DBG_SECTION=1 8 | !ENDIF 9 | !INCLUDE $(NTMAKEENV)\makefile.def -------------------------------------------------------------------------------- /EngineSVM/SOURCES: -------------------------------------------------------------------------------- 1 | TARGETNAME=QUnpack 2 | TARGETPATH=. 3 | TARGETTYPE=DRIVER 4 | I386_SOURCES=engine32.asm 5 | AMD64_SOURCES=engine64.asm 6 | SOURCES=engine.c -------------------------------------------------------------------------------- /EngineSVM/amd64/QUnpack.sys: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fatrolls/Quick-Unpack/48070723aa80c1f2b6d1c43c345e51c37c1ea5b2/EngineSVM/amd64/QUnpack.sys -------------------------------------------------------------------------------- /EngineSVM/amd64/interface64.inc: -------------------------------------------------------------------------------- 1 | STATE_READY EQU 00h 2 | STATE_SINGLESTEP EQU 01h 3 | STATE_BREAK EQU 02h 4 | STATE_BREAKMEM EQU 03h 5 | STATE_BREAKCPUID EQU 04h 6 | 7 | STATE_HANDLED EQU 10h 8 | STATE_UNHANDLED EQU 11h 9 | 10 | STATE_BUSY EQU 20h 11 | 12 | KTRAP_SIZE EQU 168h 13 | 14 | VMCB_RSP_OFFSET EQU 400h+1d8h 15 | VMCB_RIP_OFFSET EQU 400h+178h 16 | 17 | DATA_STATE STRUCT 1 18 | State DD ? 19 | ThreadID DD ? 20 | 21 | RegCr2 DQ ? 22 | RegDr0 DQ ? 23 | RegDr1 DQ ? 24 | RegDr2 DQ ? 25 | RegDr3 DQ ? 26 | RegDr6 DQ ? 27 | RegDr7 DQ ? 28 | 29 | RegIp DQ ? 30 | RegCS DQ ? 31 | RegFlags DQ ? 32 | RegSp DQ ? 33 | 34 | RegDi DQ ? 35 | RegSi DQ ? 36 | RegBp DQ ? 37 | RegBx DQ ? 38 | RegDx DQ ? 39 | RegCx DQ ? 40 | RegAx DQ ? 41 | 42 | Reg8 DQ ? 43 | Reg9 DQ ? 44 | Reg10 DQ ? 45 | Reg11 DQ ? 46 | Reg12 DQ ? 47 | Reg13 DQ ? 48 | Reg14 DQ ? 49 | Reg15 DQ ? 50 | DATA_STATE ENDS -------------------------------------------------------------------------------- /EngineSVM/i386/QUnpack.sys: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fatrolls/Quick-Unpack/48070723aa80c1f2b6d1c43c345e51c37c1ea5b2/EngineSVM/i386/QUnpack.sys -------------------------------------------------------------------------------- /EngineSVM/i386/interface32.inc: -------------------------------------------------------------------------------- 1 | STATE_READY EQU 00h 2 | STATE_SINGLESTEP EQU 01h 3 | STATE_BREAK EQU 02h 4 | STATE_BREAKMEM EQU 03h 5 | STATE_BREAKCPUID EQU 04h 6 | 7 | STATE_HANDLED EQU 10h 8 | STATE_UNHANDLED EQU 11h 9 | 10 | STATE_BUSY EQU 20h 11 | 12 | KTRAP_SIZE EQU 29ch 13 | 14 | VMCB_RSP_OFFSET EQU 400h+1d8h 15 | VMCB_RIP_OFFSET EQU 400h+178h 16 | 17 | DATA_STATE STRUCT 1 18 | State DD ? 19 | ThreadID DD ? 20 | 21 | RegCr2 DD ? 22 | RegDr0 DD ? 23 | RegDr1 DD ? 24 | RegDr2 DD ? 25 | RegDr3 DD ? 26 | RegDr6 DD ? 27 | RegDr7 DD ? 28 | 29 | RegIp DD ? 30 | RegCS DD ? 31 | RegFlags DD ? 32 | RegSp DD ? 33 | 34 | RegDi DD ? 35 | RegSi DD ? 36 | RegBp DD ? 37 | RegSp0 DD ? 38 | RegBx DD ? 39 | RegDx DD ? 40 | RegCx DD ? 41 | RegAx DD ? 42 | DATA_STATE ENDS -------------------------------------------------------------------------------- /EngineSVM/make32.bat: -------------------------------------------------------------------------------- 1 | build -cwZ 2 | del build* -------------------------------------------------------------------------------- /EngineSVM/make64.bat: -------------------------------------------------------------------------------- 1 | build -cwZ 2 | del build* -------------------------------------------------------------------------------- /EngineVMX/MAKEFILE: -------------------------------------------------------------------------------- 1 | # DO NOT EDIT THIS FILE!!! Edit .\sources. if you want to add a new source 2 | # file to this component. This file merely indirects to the real make file 3 | # that is shared by all the driver components of the Windows NT DDK 4 | # 5 | 6 | !IF "$(DDKBUILDENV)"=="fre" 7 | LINKER_FORCE_NO_DBG_SECTION=1 8 | !ENDIF 9 | !INCLUDE $(NTMAKEENV)\makefile.def -------------------------------------------------------------------------------- /EngineVMX/SOURCES: -------------------------------------------------------------------------------- 1 | TARGETNAME=QUnpack 2 | TARGETPATH=. 3 | TARGETTYPE=DRIVER 4 | I386_SOURCES=engine32.asm 5 | AMD64_SOURCES=engine64.asm 6 | SOURCES=engine.c -------------------------------------------------------------------------------- /EngineVMX/amd64/QUnpack.sys: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fatrolls/Quick-Unpack/48070723aa80c1f2b6d1c43c345e51c37c1ea5b2/EngineVMX/amd64/QUnpack.sys -------------------------------------------------------------------------------- /EngineVMX/amd64/interface64.inc: -------------------------------------------------------------------------------- 1 | STATE_READY EQU 00h 2 | STATE_SINGLESTEP EQU 01h 3 | STATE_BREAK EQU 02h 4 | STATE_BREAKMEM EQU 03h 5 | STATE_BREAKCPUID EQU 04h 6 | 7 | STATE_HANDLED EQU 10h 8 | STATE_UNHANDLED EQU 11h 9 | 10 | STATE_BUSY EQU 20h 11 | 12 | KTRAP_SIZE EQU 168h 13 | 14 | VMX_GUEST_GDTLIMIT EQU 4810h 15 | VMX_GUEST_IDTLIMIT EQU 4812h 16 | VMX_GUEST_RSP EQU 681ch 17 | VMX_GUEST_RIP EQU 681eh 18 | 19 | DATA_STATE STRUCT 1 20 | State DD ? 21 | ThreadID DD ? 22 | 23 | RegCr2 DQ ? 24 | RegDr0 DQ ? 25 | RegDr1 DQ ? 26 | RegDr2 DQ ? 27 | RegDr3 DQ ? 28 | RegDr6 DQ ? 29 | RegDr7 DQ ? 30 | 31 | RegIp DQ ? 32 | RegCS DQ ? 33 | RegFlags DQ ? 34 | RegSp DQ ? 35 | 36 | RegDi DQ ? 37 | RegSi DQ ? 38 | RegBp DQ ? 39 | RegBx DQ ? 40 | RegDx DQ ? 41 | RegCx DQ ? 42 | RegAx DQ ? 43 | 44 | Reg8 DQ ? 45 | Reg9 DQ ? 46 | Reg10 DQ ? 47 | Reg11 DQ ? 48 | Reg12 DQ ? 49 | Reg13 DQ ? 50 | Reg14 DQ ? 51 | Reg15 DQ ? 52 | DATA_STATE ENDS -------------------------------------------------------------------------------- /EngineVMX/i386/QUnpack.sys: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fatrolls/Quick-Unpack/48070723aa80c1f2b6d1c43c345e51c37c1ea5b2/EngineVMX/i386/QUnpack.sys -------------------------------------------------------------------------------- /EngineVMX/i386/interface32.inc: -------------------------------------------------------------------------------- 1 | STATE_READY EQU 00h 2 | STATE_SINGLESTEP EQU 01h 3 | STATE_BREAK EQU 02h 4 | STATE_BREAKMEM EQU 03h 5 | STATE_BREAKCPUID EQU 04h 6 | 7 | STATE_HANDLED EQU 10h 8 | STATE_UNHANDLED EQU 11h 9 | 10 | STATE_BUSY EQU 20h 11 | 12 | KTRAP_SIZE EQU 29ch 13 | 14 | VMX_GUEST_GDTLIMIT EQU 4810h 15 | VMX_GUEST_IDTLIMIT EQU 4812h 16 | VMX_GUEST_RSP EQU 681ch 17 | VMX_GUEST_RIP EQU 681eh 18 | 19 | DATA_STATE STRUCT 1 20 | State DD ? 21 | ThreadID DD ? 22 | 23 | RegCr2 DD ? 24 | RegDr0 DD ? 25 | RegDr1 DD ? 26 | RegDr2 DD ? 27 | RegDr3 DD ? 28 | RegDr6 DD ? 29 | RegDr7 DD ? 30 | 31 | RegIp DD ? 32 | RegCS DD ? 33 | RegFlags DD ? 34 | RegSp DD ? 35 | 36 | RegDi DD ? 37 | RegSi DD ? 38 | RegBp DD ? 39 | RegSp0 DD ? 40 | RegBx DD ? 41 | RegDx DD ? 42 | RegCx DD ? 43 | RegAx DD ? 44 | DATA_STATE ENDS -------------------------------------------------------------------------------- /EngineVMX/make32.bat: -------------------------------------------------------------------------------- 1 | build -cwZ 2 | del build* -------------------------------------------------------------------------------- /EngineVMX/make64.bat: -------------------------------------------------------------------------------- 1 | build -cwZ 2 | del build* -------------------------------------------------------------------------------- /Force/force.def: -------------------------------------------------------------------------------- 1 | LIBRARY force 2 | 3 | EXPORTS 4 | GetOEPNow 5 | ShortFinderName 6 | GetDllOEPNow -------------------------------------------------------------------------------- /Force/make32.bat: -------------------------------------------------------------------------------- 1 | cl.exe force.cpp /W4 /O2 /Ob2 /Oi /Ot /Oy /GT /GL /GF /GS- /Gy /arch:SSE2 /fp:fast /GR- /LD /link /LARGEADDRESSAWARE /OPT:REF /OPT:ICF /LTCG /def:force.def /NODEFAULTLIB /entry:DllMain kernel32.lib user32.lib 2 | del *.obj 3 | del *.exp 4 | del *.lib 5 | move Force.dll Force32.dll -------------------------------------------------------------------------------- /Force/make32U.bat: -------------------------------------------------------------------------------- 1 | cl.exe /D "UNICODE" /D "_UNICODE" force.cpp /W4 /O2 /Ob2 /Oi /Ot /Oy /GT /GL /GF /GS- /Gy /arch:SSE2 /fp:fast /GR- /LD /link /LARGEADDRESSAWARE /OPT:REF /OPT:ICF /LTCG /def:force.def /NODEFAULTLIB /entry:DllMain kernel32.lib user32.lib 2 | del *.obj 3 | del *.exp 4 | del *.lib 5 | move Force.dll Force32.dll -------------------------------------------------------------------------------- /Force/make64.bat: -------------------------------------------------------------------------------- 1 | cl.exe force.cpp /W4 /O2 /Ob2 /Oi /Ot /Oy /GT /GL /GF /GS- /Gy /fp:fast /GR- /LD /link /LARGEADDRESSAWARE /OPT:REF /OPT:ICF /LTCG /def:force.def /NODEFAULTLIB /entry:DllMain kernel32.lib user32.lib 2 | del *.obj 3 | del *.exp 4 | del *.lib 5 | move Force.dll Force64.dll -------------------------------------------------------------------------------- /Force/make64U.bat: -------------------------------------------------------------------------------- 1 | cl.exe /D "UNICODE" /D "_UNICODE" force.cpp /W4 /O2 /Ob2 /Oi /Ot /Oy /GT /GL /GF /GS- /Gy /fp:fast /GR- /LD /link /LARGEADDRESSAWARE /OPT:REF /OPT:ICF /LTCG /def:force.def /NODEFAULTLIB /entry:DllMain kernel32.lib user32.lib 2 | del *.obj 3 | del *.exp 4 | del *.lib 5 | move Force.dll Force64.dll -------------------------------------------------------------------------------- /GetLoadDll/GetLoadDll.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | DWORD_PTR RetAddr=0; 5 | 6 | __declspec(dllexport) DWORD_PTR __stdcall GetLoadDllAddress() 7 | { 8 | return RetAddr; 9 | } 10 | 11 | BOOL __stdcall DllMain(HANDLE,DWORD,void*) 12 | { 13 | RetAddr=(DWORD_PTR)_ReturnAddress(); 14 | return TRUE; 15 | } -------------------------------------------------------------------------------- /GetLoadDll/GetLoadDll.def: -------------------------------------------------------------------------------- 1 | LIBRARY "GetLoadDll" 2 | 3 | EXPORTS 4 | GetLoadDllAddress -------------------------------------------------------------------------------- /GetLoadDll/make32.bat: -------------------------------------------------------------------------------- 1 | cl.exe GetLoadDll.cpp /W4 /O2 /Ob2 /Oi /Ot /Oy /GT /GL /GF /GS- /Gy /fp:fast /GR- /LD /link /LARGEADDRESSAWARE /OPT:REF /OPT:ICF /LTCG /def:GetLoadDll.def /NODEFAULTLIB /entry:DllMain /subsystem:windows 2 | del *.exp 3 | del *.obj 4 | del *.lib 5 | move GetLoadDll.dll GetLoadDll32.dll -------------------------------------------------------------------------------- /GetLoadDll/make64.bat: -------------------------------------------------------------------------------- 1 | cl.exe GetLoadDll.cpp /W4 /O2 /Ob2 /Oi /Ot /Oy /GT /GL /GF /GS- /Gy /fp:fast /GR- /LD /link /LARGEADDRESSAWARE /OPT:REF /OPT:ICF /LTCG /def:GetLoadDll.def /NODEFAULTLIB /entry:DllMain /subsystem:windows 2 | del *.exp 3 | del *.obj 4 | del *.lib 5 | move GetLoadDll.dll GetLoadDll64.dll -------------------------------------------------------------------------------- /HumanOEP/Human.def: -------------------------------------------------------------------------------- 1 | LIBRARY HUMAN 2 | EXPORTS 3 | 4 | ShortFinderName 5 | GetOEPNow 6 | GetDllOEPNow -------------------------------------------------------------------------------- /HumanOEP/Human.sln: -------------------------------------------------------------------------------- 1 |  2 | Microsoft Visual Studio Solution File, Format Version 10.00 3 | # Visual Studio 2008 4 | Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Human", "Human.vcproj", "{DEF9ED69-47E7-4A24-993A-B3E4D3914D7A}" 5 | EndProject 6 | Global 7 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 8 | Release Unicode|Win32 = Release Unicode|Win32 9 | Release Unicode|x64 = Release Unicode|x64 10 | Release|Win32 = Release|Win32 11 | Release|x64 = Release|x64 12 | EndGlobalSection 13 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 14 | {DEF9ED69-47E7-4A24-993A-B3E4D3914D7A}.Release Unicode|Win32.ActiveCfg = Release Unicode|Win32 15 | {DEF9ED69-47E7-4A24-993A-B3E4D3914D7A}.Release Unicode|Win32.Build.0 = Release Unicode|Win32 16 | {DEF9ED69-47E7-4A24-993A-B3E4D3914D7A}.Release Unicode|x64.ActiveCfg = Release Unicode|x64 17 | {DEF9ED69-47E7-4A24-993A-B3E4D3914D7A}.Release Unicode|x64.Build.0 = Release Unicode|x64 18 | {DEF9ED69-47E7-4A24-993A-B3E4D3914D7A}.Release|Win32.ActiveCfg = Release|Win32 19 | {DEF9ED69-47E7-4A24-993A-B3E4D3914D7A}.Release|Win32.Build.0 = Release|Win32 20 | {DEF9ED69-47E7-4A24-993A-B3E4D3914D7A}.Release|x64.ActiveCfg = Release|x64 21 | {DEF9ED69-47E7-4A24-993A-B3E4D3914D7A}.Release|x64.Build.0 = Release|x64 22 | EndGlobalSection 23 | GlobalSection(SolutionProperties) = preSolution 24 | HideSolutionNode = FALSE 25 | EndGlobalSection 26 | EndGlobal 27 | -------------------------------------------------------------------------------- /HumanOEP/finder.rc: -------------------------------------------------------------------------------- 1 | // Microsoft Visual C++ generated resource script. 2 | // 3 | #include "resource.h" 4 | 5 | #define APSTUDIO_READONLY_SYMBOLS 6 | ///////////////////////////////////////////////////////////////////////////// 7 | // 8 | // Generated from the TEXTINCLUDE 2 resource. 9 | // 10 | #include "afxres.h" 11 | 12 | ///////////////////////////////////////////////////////////////////////////// 13 | #undef APSTUDIO_READONLY_SYMBOLS 14 | 15 | ///////////////////////////////////////////////////////////////////////////// 16 | // Neutral resources 17 | 18 | #if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_NEU) 19 | #ifdef _WIN32 20 | LANGUAGE LANG_NEUTRAL, SUBLANG_NEUTRAL 21 | #pragma code_page(1251) 22 | #endif //_WIN32 23 | 24 | ///////////////////////////////////////////////////////////////////////////// 25 | // 26 | // Dialog 27 | // 28 | 29 | IDD_MAINDLG DIALOGEX 0, 0, 280, 136 30 | STYLE DS_SETFONT | DS_SETFOREGROUND | DS_CENTER | WS_MINIMIZEBOX | WS_POPUP | WS_VISIBLE | WS_CAPTION | WS_SYSMENU 31 | CAPTION "OEP Finder by Archer & Human" 32 | FONT 8, "MS SANS SERIF", 0, 0, 0x0 33 | BEGIN 34 | LTEXT "File:",IDC_STATICFILE,8,10,36,8 35 | EDITTEXT IDC_FILENAME,48,8,184,12,ES_READONLY | NOT WS_TABSTOP 36 | LTEXT "Command:",IDC_STATICCOMMAND,8,24,36,8 37 | EDITTEXT IDC_COMMAND,48,22,184,12 38 | AUTOCHECKBOX "Use &Int 3",IDC_USEINT3,8,36,76,9 39 | AUTOCHECKBOX "&Kill Low Alloc",IDC_KILLLOWALLOCK,8,46,76,9 40 | AUTOCHECKBOX "Hook Virtual&Alloc",IDC_HOOKALLOCK,8,56,76,9 41 | AUTOCHECKBOX "Hook Virtual&Protect",IDC_HOOKPROTECT,8,66,76,9 42 | COMBOBOX IDC_NUMOFTHREADS,8,88,24,24,CBS_DROPDOWNLIST | WS_BORDER | WS_TABSTOP 43 | CTEXT "CreateThread Allowed",IDC_STATICCREATETHREAD,36,86,44,16 44 | LISTBOX IDC_SECTIONS,88,39,144,70,NOT LBS_NOTIFY | WS_VSCROLL | WS_TABSTOP 45 | AUTOCHECKBOX "Use Custom &Range",IDC_USERANGE,8,104,76,9 46 | EDITTEXT IDC_RANGESTART,88,102,44,12,ES_RIGHT | ES_UPPERCASE | ES_READONLY 47 | LTEXT "Size:",IDC_STATICRANGESIZE,140,104,20,9 48 | EDITTEXT IDC_RANGESIZE,164,102,44,12,ES_RIGHT | ES_UPPERCASE | ES_READONLY 49 | LTEXT "Memory Start:",IDC_STATICMEMSTART,18,120,48,9 50 | EDITTEXT IDC_MEMSTART,88,118,44,12,ES_RIGHT | ES_UPPERCASE 51 | LTEXT "End:",IDC_STATICMEMEND,140,120,16,9 52 | EDITTEXT IDC_MEMEND,164,118,44,12,ES_RIGHT | ES_UPPERCASE 53 | PUSHBUTTON "&Oep",IDC_OEP,236,8,36,12 54 | PUSHBUTTON "&Detach",IDC_DETACH,236,27,36,12 55 | PUSHBUTTON "D&ump",IDC_DUMP,236,45,36,12 56 | PUSHBUTTON "E&xit",IDC_EXIT,236,63,36,12 57 | GROUPBOX "",IDC_STATICFRAME,3,0,273,134 58 | END 59 | 60 | #endif // Neutral resources 61 | ///////////////////////////////////////////////////////////////////////////// 62 | -------------------------------------------------------------------------------- /HumanOEP/resource.h: -------------------------------------------------------------------------------- 1 | //{{NO_DEPENDENCIES}} 2 | // Microsoft Visual C++ generated include file. 3 | // Used by finder.rc 4 | // 5 | #define IDD_MAINDLG 101 6 | 7 | #define IDC_STATICFILE 1001 8 | #define IDC_FILENAME 1002 9 | #define IDC_STATICCOMMAND 1003 10 | #define IDC_COMMAND 1004 11 | #define IDC_USEINT3 1005 12 | #define IDC_KILLLOWALLOCK 1006 13 | #define IDC_HOOKALLOCK 1007 14 | #define IDC_HOOKPROTECT 1008 15 | #define IDC_NUMOFTHREADS 1009 16 | #define IDC_STATICCREATETHREAD 1010 17 | #define IDC_SECTIONS 1011 18 | #define IDC_USERANGE 1012 19 | #define IDC_RANGESTART 1013 20 | #define IDC_STATICRANGESIZE 1014 21 | #define IDC_RANGESIZE 1015 22 | #define IDC_STATICMEMSTART 1016 23 | #define IDC_MEMSTART 1017 24 | #define IDC_STATICMEMEND 1018 25 | #define IDC_MEMEND 1019 26 | #define IDC_OEP 1020 27 | #define IDC_DETACH 1021 28 | #define IDC_DUMP 1022 29 | #define IDC_EXIT 1023 30 | #define IDC_STATICFRAME 1024 31 | 32 | // Next default values for new objects 33 | // 34 | #ifdef APSTUDIO_INVOKED 35 | #ifndef APSTUDIO_READONLY_SYMBOLS 36 | #define _APS_NEXT_RESOURCE_VALUE 1 37 | #define _APS_NEXT_SYMED_VALUE 102 38 | #define _APS_NEXT_CONTROL_VALUE 1025 39 | #define _APS_NEXT_COMMAND_VALUE 32768 40 | #endif 41 | #endif 42 | -------------------------------------------------------------------------------- /Init.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #ifndef __AFXWIN_H__ 4 | #error include 'stdafx.h' before including this file for PCH 5 | #endif 6 | 7 | #include "resource.h" 8 | #include "SeException.h" 9 | 10 | class CApp:public CWinApp 11 | { 12 | protected: 13 | 14 | public: 15 | CApp(); 16 | TSTRING sFileName,sTime,sOSName,sOSBuild; 17 | void CApp::HandleException(CSeException *e) const; 18 | BOOL CApp::PumpMessage(); 19 | 20 | public: 21 | virtual BOOL InitInstance(); 22 | 23 | DECLARE_MESSAGE_MAP() 24 | }; 25 | 26 | extern CApp theApp; -------------------------------------------------------------------------------- /LoadDll/LoadDll.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | 5 | LONG_PTR(WINAPI *GetOEPDLL) 6 | ( 7 | HMODULE hModuleBase 8 | ); 9 | 10 | volatile HMODULE hExtra; 11 | 12 | void main() 13 | { 14 | TCHAR *pTmpBuff=GetCommandLine(); 15 | TCHAR bIsNew=pTmpBuff[_tcslen(pTmpBuff)-1]; 16 | pTmpBuff[_tcslen(pTmpBuff)-1]=_T('\0'); 17 | 18 | HMODULE hDllBase=LoadLibrary(pTmpBuff); 19 | if(hDllBase==NULL) 20 | return; 21 | 22 | switch(bIsNew) 23 | { 24 | case _T('0'): 25 | { 26 | TCHAR szLibUsArDLLdl1[MAX_PATH]; 27 | GetModuleFileName(GetModuleHandle(NULL),szLibUsArDLLdl1,_countof(szLibUsArDLLdl1)); 28 | for(int i=(int)_tcslen(szLibUsArDLLdl1)-1;i>0;--i) 29 | { 30 | if(szLibUsArDLLdl1[i]==_T('\\')) 31 | { 32 | szLibUsArDLLdl1[i]=_T('\0'); 33 | break; 34 | } 35 | } 36 | _tcscat(szLibUsArDLLdl1,_T("\\UsArdll.d11")); 37 | 38 | *(LPVOID*)&GetOEPDLL=GetProcAddress(LoadLibrary(szLibUsArDLLdl1),"GetOEPDLL"); 39 | GetOEPDLL(hDllBase); 40 | 41 | break; 42 | } 43 | case _T('1'): 44 | hExtra=hDllBase; 45 | __debugbreak(); 46 | break; 47 | case _T('2'): 48 | hExtra=hDllBase; 49 | while(hExtra!=0) 50 | { 51 | } 52 | break; 53 | default: 54 | return; 55 | } 56 | 57 | FreeLibrary(hDllBase); 58 | } -------------------------------------------------------------------------------- /LoadDll/make32.bat: -------------------------------------------------------------------------------- 1 | cl.exe /D_CRT_SECURE_NO_WARNINGS LoadDll.cpp /W4 /O2 /Ob2 /Oi /Ot /Oy /GT /GL /GF /GS- /Gy /arch:SSE2 /fp:fast /GR- /link /LARGEADDRESSAWARE /OPT:REF /OPT:ICF /LTCG /NODEFAULTLIB /entry:main /subsystem:windows kernel32.lib 2 | del *.obj 3 | move LoadDll.exe LoadDll32.exe -------------------------------------------------------------------------------- /LoadDll/make32U.bat: -------------------------------------------------------------------------------- 1 | cl.exe /D_CRT_SECURE_NO_WARNINGS /D "UNICODE" /D "_UNICODE" LoadDll.cpp /W4 /O2 /Ob2 /Oi /Ot /Oy /GT /GL /GF /GS- /Gy /arch:SSE2 /fp:fast /GR- /link /LARGEADDRESSAWARE /OPT:REF /OPT:ICF /LTCG /NODEFAULTLIB /entry:main /subsystem:windows kernel32.lib 2 | del *.obj 3 | move LoadDll.exe LoadDll32.exe -------------------------------------------------------------------------------- /LoadDll/make64.bat: -------------------------------------------------------------------------------- 1 | cl.exe /D_CRT_SECURE_NO_WARNINGS LoadDll.cpp /W4 /O2 /Ob2 /Oi /Ot /Oy /GT /GL /GF /GS- /Gy /fp:fast /GR- /link /LARGEADDRESSAWARE /OPT:REF /OPT:ICF /LTCG /NODEFAULTLIB /entry:main /subsystem:windows kernel32.lib 2 | del *.obj 3 | move LoadDll.exe LoadDll64.exe -------------------------------------------------------------------------------- /LoadDll/make64U.bat: -------------------------------------------------------------------------------- 1 | cl.exe /D_CRT_SECURE_NO_WARNINGS /D "UNICODE" /D "_UNICODE" LoadDll.cpp /W4 /O2 /Ob2 /Oi /Ot /Oy /GT /GL /GF /GS- /Gy /fp:fast /GR- /link /LARGEADDRESSAWARE /OPT:REF /OPT:ICF /LTCG /NODEFAULTLIB /entry:main /subsystem:windows kernel32.lib 2 | del *.obj 3 | move LoadDll.exe LoadDll64.exe -------------------------------------------------------------------------------- /Loader/loader.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | 5 | typedef DWORD (__stdcall *_Unpack)(const TCHAR *szFileName,DWORD dwTimeout); 6 | _Unpack Unpack; 7 | 8 | int _tmain() 9 | { 10 | HMODULE hModule; 11 | DWORD dwTemp; 12 | TCHAR szDllFile[MAX_PATH],szFileToUnpack[MAX_PATH]; 13 | 14 | GetCurrentDirectory(_countof(szDllFile),szDllFile); 15 | _tcscat(szDllFile,_T("\\QUnpack.dll")); 16 | 17 | _tprintf(_T("Enter filename: ")); 18 | _getts(szFileToUnpack); 19 | 20 | hModule=LoadLibrary(szDllFile); 21 | if(hModule==NULL) 22 | { 23 | _tprintf(_T("Couldn't load QUnpack.dll")); 24 | _getts(szFileToUnpack); 25 | return -1; 26 | } 27 | Unpack=(_Unpack)GetProcAddress(hModule,"UnPack"); 28 | if(Unpack==0) 29 | { 30 | _tprintf(_T("Couldn't get address of Unpack procedure")); 31 | _getts(szFileToUnpack); 32 | return -1; 33 | } 34 | dwTemp=Unpack(szFileToUnpack,15000); 35 | if(dwTemp==0) 36 | _tprintf(_T("File successfully unpacked")); 37 | else if(dwTemp==1) 38 | _tprintf(_T("Couldn't find OEP")); 39 | else if(dwTemp==2) 40 | _tprintf(_T("Timeout reached")); 41 | else if(dwTemp==3) 42 | _tprintf(_T("Something went wrong")); 43 | Sleep(1000); //needed for the unpacking thread to stop 44 | FreeLibrary(hModule); 45 | _getts(szFileToUnpack); 46 | 47 | return 1; 48 | } -------------------------------------------------------------------------------- /Loader/make32.bat: -------------------------------------------------------------------------------- 1 | cl.exe /D_CRT_SECURE_NO_WARNINGS loader.cpp /W4 /O2 /Ob2 /Oi /Ot /Oy /GT /GL /GF /GS- /Gy /arch:SSE2 /fp:fast /GR- /link /LARGEADDRESSAWARE /OPT:REF /OPT:ICF /LTCG 2 | del *.obj 3 | move loader.exe loader32.exe -------------------------------------------------------------------------------- /Loader/make32U.bat: -------------------------------------------------------------------------------- 1 | cl.exe /D_CRT_SECURE_NO_WARNINGS /D "UNICODE" /D "_UNICODE" loader.cpp /W4 /O2 /Ob2 /Oi /Ot /Oy /GT /GL /GF /GS- /Gy /arch:SSE2 /fp:fast /GR- /link /LARGEADDRESSAWARE /OPT:REF /OPT:ICF /LTCG 2 | del *.obj 3 | move loader.exe loader32.exe -------------------------------------------------------------------------------- /Loader/make64.bat: -------------------------------------------------------------------------------- 1 | cl.exe /D_CRT_SECURE_NO_WARNINGS loader.cpp /W4 /O2 /Ob2 /Oi /Ot /Oy /GT /GL /GF /GS- /Gy /fp:fast /GR- /link /LARGEADDRESSAWARE /OPT:REF /OPT:ICF /LTCG 2 | del *.obj 3 | move loader.exe loader64.exe -------------------------------------------------------------------------------- /Loader/make64U.bat: -------------------------------------------------------------------------------- 1 | cl.exe /D_CRT_SECURE_NO_WARNINGS /D "UNICODE" /D "_UNICODE" loader.cpp /W4 /O2 /Ob2 /Oi /Ot /Oy /GT /GL /GF /GS- /Gy /fp:fast /GR- /link /LARGEADDRESSAWARE /OPT:REF /OPT:ICF /LTCG 2 | del *.obj 3 | move loader.exe loader64.exe -------------------------------------------------------------------------------- /Lua/make32.bat: -------------------------------------------------------------------------------- 1 | @rem Script to build Lua under "Visual Studio Command Prompt". 2 | 3 | @setlocal 4 | @set MYCOMPILE=cl.exe /nologo /MT /W4 /O2 /Ob2 /Oi /Ot /Oy /GT /GF /GS- /Gy /arch:SSE2 /fp:fast /GR- /c /D_CRT_SECURE_NO_DEPRECATE 5 | @set MYLINK=link.exe /nologo /LARGEADDRESSAWARE /OPT:REF /OPT:ICF /LTCG 6 | @set MYLIB=lib.exe /nologo 7 | 8 | cd src 9 | %MYCOMPILE% l*.c 10 | del lua.obj luac.obj 11 | %MYLIB% /out:..\lua32.lib l*.obj 12 | del *.obj *.manifest 13 | cd .. -------------------------------------------------------------------------------- /Lua/make64.bat: -------------------------------------------------------------------------------- 1 | @rem Script to build Lua under "Visual Studio Command Prompt". 2 | 3 | @setlocal 4 | @set MYCOMPILE=cl.exe /nologo /MT /W4 /O2 /Ob2 /Oi /Ot /Oy /GT /GF /GS- /Gy /fp:fast /GR- /c /D_CRT_SECURE_NO_DEPRECATE 5 | @set MYLINK=link.exe /nologo /LARGEADDRESSAWARE /OPT:REF /OPT:ICF /LTCG 6 | @set MYLIB=lib.exe /nologo 7 | 8 | cd src 9 | %MYCOMPILE% l*.c 10 | del lua.obj luac.obj 11 | %MYLIB% /out:..\lua64.lib l*.obj 12 | del *.obj *.manifest 13 | cd .. -------------------------------------------------------------------------------- /Lua/src/lapi.h: -------------------------------------------------------------------------------- 1 | /* 2 | ** $Id: lapi.h,v 2.9 2015/03/06 19:49: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, 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(L, (n) < (L->top - L->ci->func), \ 21 | "not enough elements in the stack") 22 | 23 | 24 | #endif 25 | -------------------------------------------------------------------------------- /Lua/src/lcode.h: -------------------------------------------------------------------------------- 1 | /* 2 | ** $Id: lcode.h,v 1.64 2016/01/05 16:22:37 roberto Exp $ 3 | ** Code generator for Lua 4 | ** See Copyright Notice in lua.h 5 | */ 6 | 7 | #ifndef lcode_h 8 | #define lcode_h 9 | 10 | #include "llex.h" 11 | #include "lobject.h" 12 | #include "lopcodes.h" 13 | #include "lparser.h" 14 | 15 | 16 | /* 17 | ** Marks the end of a patch list. It is an invalid value both as an absolute 18 | ** address, and as a list link (would link an element to itself). 19 | */ 20 | #define NO_JUMP (-1) 21 | 22 | 23 | /* 24 | ** grep "ORDER OPR" if you change these enums (ORDER OP) 25 | */ 26 | typedef enum BinOpr { 27 | OPR_ADD, OPR_SUB, OPR_MUL, OPR_MOD, OPR_POW, 28 | OPR_DIV, 29 | OPR_IDIV, 30 | OPR_BAND, OPR_BOR, OPR_BXOR, 31 | OPR_SHL, OPR_SHR, 32 | OPR_CONCAT, 33 | OPR_EQ, OPR_LT, OPR_LE, 34 | OPR_NE, OPR_GT, OPR_GE, 35 | OPR_AND, OPR_OR, 36 | OPR_NOBINOPR 37 | } BinOpr; 38 | 39 | 40 | typedef enum UnOpr { OPR_MINUS, OPR_BNOT, OPR_NOT, OPR_LEN, OPR_NOUNOPR } UnOpr; 41 | 42 | 43 | /* get (pointer to) instruction of given 'expdesc' */ 44 | #define getinstruction(fs,e) ((fs)->f->code[(e)->u.info]) 45 | 46 | #define luaK_codeAsBx(fs,o,A,sBx) luaK_codeABx(fs,o,A,(sBx)+MAXARG_sBx) 47 | 48 | #define luaK_setmultret(fs,e) luaK_setreturns(fs, e, LUA_MULTRET) 49 | 50 | #define luaK_jumpto(fs,t) luaK_patchlist(fs, luaK_jump(fs), t) 51 | 52 | LUAI_FUNC int luaK_codeABx (FuncState *fs, OpCode o, int A, unsigned int Bx); 53 | LUAI_FUNC int luaK_codeABC (FuncState *fs, OpCode o, int A, int B, int C); 54 | LUAI_FUNC int luaK_codek (FuncState *fs, int reg, int k); 55 | LUAI_FUNC void luaK_fixline (FuncState *fs, int line); 56 | LUAI_FUNC void luaK_nil (FuncState *fs, int from, int n); 57 | LUAI_FUNC void luaK_reserveregs (FuncState *fs, int n); 58 | LUAI_FUNC void luaK_checkstack (FuncState *fs, int n); 59 | LUAI_FUNC int luaK_stringK (FuncState *fs, TString *s); 60 | LUAI_FUNC int luaK_intK (FuncState *fs, lua_Integer n); 61 | LUAI_FUNC void luaK_dischargevars (FuncState *fs, expdesc *e); 62 | LUAI_FUNC int luaK_exp2anyreg (FuncState *fs, expdesc *e); 63 | LUAI_FUNC void luaK_exp2anyregup (FuncState *fs, expdesc *e); 64 | LUAI_FUNC void luaK_exp2nextreg (FuncState *fs, expdesc *e); 65 | LUAI_FUNC void luaK_exp2val (FuncState *fs, expdesc *e); 66 | LUAI_FUNC int luaK_exp2RK (FuncState *fs, expdesc *e); 67 | LUAI_FUNC void luaK_self (FuncState *fs, expdesc *e, expdesc *key); 68 | LUAI_FUNC void luaK_indexed (FuncState *fs, expdesc *t, expdesc *k); 69 | LUAI_FUNC void luaK_goiftrue (FuncState *fs, expdesc *e); 70 | LUAI_FUNC void luaK_goiffalse (FuncState *fs, expdesc *e); 71 | LUAI_FUNC void luaK_storevar (FuncState *fs, expdesc *var, expdesc *e); 72 | LUAI_FUNC void luaK_setreturns (FuncState *fs, expdesc *e, int nresults); 73 | LUAI_FUNC void luaK_setoneret (FuncState *fs, expdesc *e); 74 | LUAI_FUNC int luaK_jump (FuncState *fs); 75 | LUAI_FUNC void luaK_ret (FuncState *fs, int first, int nret); 76 | LUAI_FUNC void luaK_patchlist (FuncState *fs, int list, int target); 77 | LUAI_FUNC void luaK_patchtohere (FuncState *fs, int list); 78 | LUAI_FUNC void luaK_patchclose (FuncState *fs, int list, int level); 79 | LUAI_FUNC void luaK_concat (FuncState *fs, int *l1, int l2); 80 | LUAI_FUNC int luaK_getlabel (FuncState *fs); 81 | LUAI_FUNC void luaK_prefix (FuncState *fs, UnOpr op, expdesc *v, int line); 82 | LUAI_FUNC void luaK_infix (FuncState *fs, BinOpr op, expdesc *v); 83 | LUAI_FUNC void luaK_posfix (FuncState *fs, BinOpr op, expdesc *v1, 84 | expdesc *v2, int line); 85 | LUAI_FUNC void luaK_setlist (FuncState *fs, int base, int nelems, int tostore); 86 | 87 | 88 | #endif 89 | -------------------------------------------------------------------------------- /Lua/src/lcorolib.c: -------------------------------------------------------------------------------- 1 | /* 2 | ** $Id: lcorolib.c,v 1.10 2016/04/11 19:19:55 roberto Exp $ 3 | ** Coroutine Library 4 | ** See Copyright Notice in lua.h 5 | */ 6 | 7 | #define lcorolib_c 8 | #define LUA_LIB 9 | 10 | #include "lprefix.h" 11 | 12 | 13 | #include 14 | 15 | #include "lua.h" 16 | 17 | #include "lauxlib.h" 18 | #include "lualib.h" 19 | 20 | 21 | static lua_State *getco (lua_State *L) { 22 | lua_State *co = lua_tothread(L, 1); 23 | luaL_argcheck(L, co, 1, "thread expected"); 24 | return co; 25 | } 26 | 27 | 28 | static int auxresume (lua_State *L, lua_State *co, int narg) { 29 | int status; 30 | if (!lua_checkstack(co, narg)) { 31 | lua_pushliteral(L, "too many arguments to resume"); 32 | return -1; /* error flag */ 33 | } 34 | if (lua_status(co) == LUA_OK && lua_gettop(co) == 0) { 35 | lua_pushliteral(L, "cannot resume dead coroutine"); 36 | return -1; /* error flag */ 37 | } 38 | lua_xmove(L, co, narg); 39 | status = lua_resume(co, L, narg); 40 | if (status == LUA_OK || status == LUA_YIELD) { 41 | int nres = lua_gettop(co); 42 | if (!lua_checkstack(L, nres + 1)) { 43 | lua_pop(co, nres); /* remove results anyway */ 44 | lua_pushliteral(L, "too many results to resume"); 45 | return -1; /* error flag */ 46 | } 47 | lua_xmove(co, L, nres); /* move yielded values */ 48 | return nres; 49 | } 50 | else { 51 | lua_xmove(co, L, 1); /* move error message */ 52 | return -1; /* error flag */ 53 | } 54 | } 55 | 56 | 57 | static int luaB_coresume (lua_State *L) { 58 | lua_State *co = getco(L); 59 | int r; 60 | r = auxresume(L, co, lua_gettop(L) - 1); 61 | if (r < 0) { 62 | lua_pushboolean(L, 0); 63 | lua_insert(L, -2); 64 | return 2; /* return false + error message */ 65 | } 66 | else { 67 | lua_pushboolean(L, 1); 68 | lua_insert(L, -(r + 1)); 69 | return r + 1; /* return true + 'resume' returns */ 70 | } 71 | } 72 | 73 | 74 | static int luaB_auxwrap (lua_State *L) { 75 | lua_State *co = lua_tothread(L, lua_upvalueindex(1)); 76 | int r = auxresume(L, co, lua_gettop(L)); 77 | if (r < 0) { 78 | if (lua_type(L, -1) == LUA_TSTRING) { /* error object is a string? */ 79 | luaL_where(L, 1); /* add extra info */ 80 | lua_insert(L, -2); 81 | lua_concat(L, 2); 82 | } 83 | return lua_error(L); /* propagate error */ 84 | } 85 | return r; 86 | } 87 | 88 | 89 | static int luaB_cocreate (lua_State *L) { 90 | lua_State *NL; 91 | luaL_checktype(L, 1, LUA_TFUNCTION); 92 | NL = lua_newthread(L); 93 | lua_pushvalue(L, 1); /* move function to top */ 94 | lua_xmove(L, NL, 1); /* move function from L to NL */ 95 | return 1; 96 | } 97 | 98 | 99 | static int luaB_cowrap (lua_State *L) { 100 | luaB_cocreate(L); 101 | lua_pushcclosure(L, luaB_auxwrap, 1); 102 | return 1; 103 | } 104 | 105 | 106 | static int luaB_yield (lua_State *L) { 107 | return lua_yield(L, lua_gettop(L)); 108 | } 109 | 110 | 111 | static int luaB_costatus (lua_State *L) { 112 | lua_State *co = getco(L); 113 | if (L == co) lua_pushliteral(L, "running"); 114 | else { 115 | switch (lua_status(co)) { 116 | case LUA_YIELD: 117 | lua_pushliteral(L, "suspended"); 118 | break; 119 | case LUA_OK: { 120 | lua_Debug ar; 121 | if (lua_getstack(co, 0, &ar) > 0) /* does it have frames? */ 122 | lua_pushliteral(L, "normal"); /* it is running */ 123 | else if (lua_gettop(co) == 0) 124 | lua_pushliteral(L, "dead"); 125 | else 126 | lua_pushliteral(L, "suspended"); /* initial state */ 127 | break; 128 | } 129 | default: /* some error occurred */ 130 | lua_pushliteral(L, "dead"); 131 | break; 132 | } 133 | } 134 | return 1; 135 | } 136 | 137 | 138 | static int luaB_yieldable (lua_State *L) { 139 | lua_pushboolean(L, lua_isyieldable(L)); 140 | return 1; 141 | } 142 | 143 | 144 | static int luaB_corunning (lua_State *L) { 145 | int ismain = lua_pushthread(L); 146 | lua_pushboolean(L, ismain); 147 | return 2; 148 | } 149 | 150 | 151 | static const luaL_Reg co_funcs[] = { 152 | {"create", luaB_cocreate}, 153 | {"resume", luaB_coresume}, 154 | {"running", luaB_corunning}, 155 | {"status", luaB_costatus}, 156 | {"wrap", luaB_cowrap}, 157 | {"yield", luaB_yield}, 158 | {"isyieldable", luaB_yieldable}, 159 | {NULL, NULL} 160 | }; 161 | 162 | 163 | 164 | LUAMOD_API int luaopen_coroutine (lua_State *L) { 165 | luaL_newlib(L, co_funcs); 166 | return 1; 167 | } 168 | 169 | -------------------------------------------------------------------------------- /Lua/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/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/src/ldebug.h: -------------------------------------------------------------------------------- 1 | /* 2 | ** $Id: ldebug.h,v 2.14 2015/05/22 17:45:56 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 | 21 | LUAI_FUNC l_noret luaG_typeerror (lua_State *L, const TValue *o, 22 | const char *opname); 23 | LUAI_FUNC l_noret luaG_concaterror (lua_State *L, const TValue *p1, 24 | const TValue *p2); 25 | LUAI_FUNC l_noret luaG_opinterror (lua_State *L, const TValue *p1, 26 | const TValue *p2, 27 | const char *msg); 28 | LUAI_FUNC l_noret luaG_tointerror (lua_State *L, const TValue *p1, 29 | const TValue *p2); 30 | LUAI_FUNC l_noret luaG_ordererror (lua_State *L, const TValue *p1, 31 | const TValue *p2); 32 | LUAI_FUNC l_noret luaG_runerror (lua_State *L, const char *fmt, ...); 33 | LUAI_FUNC const char *luaG_addinfo (lua_State *L, const char *msg, 34 | TString *src, int line); 35 | LUAI_FUNC l_noret luaG_errormsg (lua_State *L); 36 | LUAI_FUNC void luaG_traceexec (lua_State *L); 37 | 38 | 39 | #endif 40 | -------------------------------------------------------------------------------- /Lua/src/ldo.h: -------------------------------------------------------------------------------- 1 | /* 2 | ** $Id: ldo.h,v 2.29 2015/12/21 13:02:14 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 | /* 17 | ** Macro to check stack size and grow stack if needed. Parameters 18 | ** 'pre'/'pos' allow the macro to preserve a pointer into the 19 | ** stack across reallocations, doing the work only when needed. 20 | ** 'condmovestack' is used in heavy tests to force a stack reallocation 21 | ** at every check. 22 | */ 23 | #define luaD_checkstackaux(L,n,pre,pos) \ 24 | if (L->stack_last - L->top <= (n)) \ 25 | { pre; luaD_growstack(L, n); pos; } else { condmovestack(L,pre,pos); } 26 | 27 | /* In general, 'pre'/'pos' are empty (nothing to save) */ 28 | #define luaD_checkstack(L,n) luaD_checkstackaux(L,n,(void)0,(void)0) 29 | 30 | 31 | 32 | #define savestack(L,p) ((char *)(p) - (char *)L->stack) 33 | #define restorestack(L,n) ((TValue *)((char *)L->stack + (n))) 34 | 35 | 36 | /* type of protected functions, to be ran by 'runprotected' */ 37 | typedef void (*Pfunc) (lua_State *L, void *ud); 38 | 39 | LUAI_FUNC int luaD_protectedparser (lua_State *L, ZIO *z, const char *name, 40 | const char *mode); 41 | LUAI_FUNC void luaD_hook (lua_State *L, int event, int line); 42 | LUAI_FUNC int luaD_precall (lua_State *L, StkId func, int nresults); 43 | LUAI_FUNC void luaD_call (lua_State *L, StkId func, int nResults); 44 | LUAI_FUNC void luaD_callnoyield (lua_State *L, StkId func, int nResults); 45 | LUAI_FUNC int luaD_pcall (lua_State *L, Pfunc func, void *u, 46 | ptrdiff_t oldtop, ptrdiff_t ef); 47 | LUAI_FUNC int luaD_poscall (lua_State *L, CallInfo *ci, StkId firstResult, 48 | int nres); 49 | LUAI_FUNC void luaD_reallocstack (lua_State *L, int newsize); 50 | LUAI_FUNC void luaD_growstack (lua_State *L, int n); 51 | LUAI_FUNC void luaD_shrinkstack (lua_State *L); 52 | LUAI_FUNC void luaD_inctop (lua_State *L); 53 | 54 | LUAI_FUNC l_noret luaD_throw (lua_State *L, int errcode); 55 | LUAI_FUNC int luaD_rawrunprotected (lua_State *L, Pfunc f, void *ud); 56 | 57 | #endif 58 | 59 | -------------------------------------------------------------------------------- /Lua/src/lfunc.c: -------------------------------------------------------------------------------- 1 | /* 2 | ** $Id: lfunc.c,v 2.45 2014/11/02 19:19:04 roberto Exp $ 3 | ** Auxiliary functions to manipulate prototypes and closures 4 | ** See Copyright Notice in lua.h 5 | */ 6 | 7 | #define lfunc_c 8 | #define LUA_CORE 9 | 10 | #include "lprefix.h" 11 | 12 | 13 | #include 14 | 15 | #include "lua.h" 16 | 17 | #include "lfunc.h" 18 | #include "lgc.h" 19 | #include "lmem.h" 20 | #include "lobject.h" 21 | #include "lstate.h" 22 | 23 | 24 | 25 | CClosure *luaF_newCclosure (lua_State *L, int n) { 26 | GCObject *o = luaC_newobj(L, LUA_TCCL, sizeCclosure(n)); 27 | CClosure *c = gco2ccl(o); 28 | c->nupvalues = cast_byte(n); 29 | return c; 30 | } 31 | 32 | 33 | LClosure *luaF_newLclosure (lua_State *L, int n) { 34 | GCObject *o = luaC_newobj(L, LUA_TLCL, sizeLclosure(n)); 35 | LClosure *c = gco2lcl(o); 36 | c->p = NULL; 37 | c->nupvalues = cast_byte(n); 38 | while (n--) c->upvals[n] = NULL; 39 | return c; 40 | } 41 | 42 | /* 43 | ** fill a closure with new closed upvalues 44 | */ 45 | void luaF_initupvals (lua_State *L, LClosure *cl) { 46 | int i; 47 | for (i = 0; i < cl->nupvalues; i++) { 48 | UpVal *uv = luaM_new(L, UpVal); 49 | uv->refcount = 1; 50 | uv->v = &uv->u.value; /* make it closed */ 51 | setnilvalue(uv->v); 52 | cl->upvals[i] = uv; 53 | } 54 | } 55 | 56 | 57 | UpVal *luaF_findupval (lua_State *L, StkId level) { 58 | UpVal **pp = &L->openupval; 59 | UpVal *p; 60 | UpVal *uv; 61 | lua_assert(isintwups(L) || L->openupval == NULL); 62 | while (*pp != NULL && (p = *pp)->v >= level) { 63 | lua_assert(upisopen(p)); 64 | if (p->v == level) /* found a corresponding upvalue? */ 65 | return p; /* return it */ 66 | pp = &p->u.open.next; 67 | } 68 | /* not found: create a new upvalue */ 69 | uv = luaM_new(L, UpVal); 70 | uv->refcount = 0; 71 | uv->u.open.next = *pp; /* link it to list of open upvalues */ 72 | uv->u.open.touched = 1; 73 | *pp = uv; 74 | uv->v = level; /* current value lives in the stack */ 75 | if (!isintwups(L)) { /* thread not in list of threads with upvalues? */ 76 | L->twups = G(L)->twups; /* link it to the list */ 77 | G(L)->twups = L; 78 | } 79 | return uv; 80 | } 81 | 82 | 83 | void luaF_close (lua_State *L, StkId level) { 84 | UpVal *uv; 85 | while (L->openupval != NULL && (uv = L->openupval)->v >= level) { 86 | lua_assert(upisopen(uv)); 87 | L->openupval = uv->u.open.next; /* remove from 'open' list */ 88 | if (uv->refcount == 0) /* no references? */ 89 | luaM_free(L, uv); /* free upvalue */ 90 | else { 91 | setobj(L, &uv->u.value, uv->v); /* move value to upvalue slot */ 92 | uv->v = &uv->u.value; /* now current value lives here */ 93 | luaC_upvalbarrier(L, uv); 94 | } 95 | } 96 | } 97 | 98 | 99 | Proto *luaF_newproto (lua_State *L) { 100 | GCObject *o = luaC_newobj(L, LUA_TPROTO, sizeof(Proto)); 101 | Proto *f = gco2p(o); 102 | f->k = NULL; 103 | f->sizek = 0; 104 | f->p = NULL; 105 | f->sizep = 0; 106 | f->code = NULL; 107 | f->cache = NULL; 108 | f->sizecode = 0; 109 | f->lineinfo = NULL; 110 | f->sizelineinfo = 0; 111 | f->upvalues = NULL; 112 | f->sizeupvalues = 0; 113 | f->numparams = 0; 114 | f->is_vararg = 0; 115 | f->maxstacksize = 0; 116 | f->locvars = NULL; 117 | f->sizelocvars = 0; 118 | f->linedefined = 0; 119 | f->lastlinedefined = 0; 120 | f->source = NULL; 121 | return f; 122 | } 123 | 124 | 125 | void luaF_freeproto (lua_State *L, Proto *f) { 126 | luaM_freearray(L, f->code, f->sizecode); 127 | luaM_freearray(L, f->p, f->sizep); 128 | luaM_freearray(L, f->k, f->sizek); 129 | luaM_freearray(L, f->lineinfo, f->sizelineinfo); 130 | luaM_freearray(L, f->locvars, f->sizelocvars); 131 | luaM_freearray(L, f->upvalues, f->sizeupvalues); 132 | luaM_free(L, f); 133 | } 134 | 135 | 136 | /* 137 | ** Look for n-th local variable at line 'line' in function 'func'. 138 | ** Returns NULL if not found. 139 | */ 140 | const char *luaF_getlocalname (const Proto *f, int local_number, int pc) { 141 | int i; 142 | for (i = 0; isizelocvars && f->locvars[i].startpc <= pc; i++) { 143 | if (pc < f->locvars[i].endpc) { /* is variable active? */ 144 | local_number--; 145 | if (local_number == 0) 146 | return getstr(f->locvars[i].varname); 147 | } 148 | } 149 | return NULL; /* not found */ 150 | } 151 | 152 | -------------------------------------------------------------------------------- /Lua/src/lfunc.h: -------------------------------------------------------------------------------- 1 | /* 2 | ** $Id: lfunc.h,v 2.15 2015/01/13 15:49:11 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 | ** maximum number of upvalues in a closure (both C and Lua). (Value 27 | ** must fit in a VM register.) 28 | */ 29 | #define MAXUPVAL 255 30 | 31 | 32 | /* 33 | ** Upvalues for Lua closures 34 | */ 35 | struct UpVal { 36 | TValue *v; /* points to stack or to its own value */ 37 | lu_mem refcount; /* reference counter */ 38 | union { 39 | struct { /* (when open) */ 40 | UpVal *next; /* linked list */ 41 | int touched; /* mark to avoid cycles with dead threads */ 42 | } open; 43 | TValue value; /* the value (when closed) */ 44 | } u; 45 | }; 46 | 47 | #define upisopen(up) ((up)->v != &(up)->u.value) 48 | 49 | 50 | LUAI_FUNC Proto *luaF_newproto (lua_State *L); 51 | LUAI_FUNC CClosure *luaF_newCclosure (lua_State *L, int nelems); 52 | LUAI_FUNC LClosure *luaF_newLclosure (lua_State *L, int nelems); 53 | LUAI_FUNC void luaF_initupvals (lua_State *L, LClosure *cl); 54 | LUAI_FUNC UpVal *luaF_findupval (lua_State *L, StkId level); 55 | LUAI_FUNC void luaF_close (lua_State *L, StkId level); 56 | LUAI_FUNC void luaF_freeproto (lua_State *L, Proto *f); 57 | LUAI_FUNC const char *luaF_getlocalname (const Proto *func, int local_number, 58 | int pc); 59 | 60 | 61 | #endif 62 | -------------------------------------------------------------------------------- /Lua/src/lgc.h: -------------------------------------------------------------------------------- 1 | /* 2 | ** $Id: lgc.h,v 2.91 2015/12/21 13:02:14 roberto Exp $ 3 | ** Garbage Collector 4 | ** See Copyright Notice in lua.h 5 | */ 6 | 7 | #ifndef lgc_h 8 | #define lgc_h 9 | 10 | 11 | #include "lobject.h" 12 | #include "lstate.h" 13 | 14 | /* 15 | ** Collectable objects may have one of three colors: white, which 16 | ** means the object is not marked; gray, which means the 17 | ** object is marked, but its references may be not marked; and 18 | ** black, which means that the object and all its references are marked. 19 | ** The main invariant of the garbage collector, while marking objects, 20 | ** is that a black object can never point to a white one. Moreover, 21 | ** any gray object must be in a "gray list" (gray, grayagain, weak, 22 | ** allweak, ephemeron) so that it can be visited again before finishing 23 | ** the collection cycle. These lists have no meaning when the invariant 24 | ** is not being enforced (e.g., sweep phase). 25 | */ 26 | 27 | 28 | 29 | /* how much to allocate before next GC step */ 30 | #if !defined(GCSTEPSIZE) 31 | /* ~100 small strings */ 32 | #define GCSTEPSIZE (cast_int(100 * sizeof(TString))) 33 | #endif 34 | 35 | 36 | /* 37 | ** Possible states of the Garbage Collector 38 | */ 39 | #define GCSpropagate 0 40 | #define GCSatomic 1 41 | #define GCSswpallgc 2 42 | #define GCSswpfinobj 3 43 | #define GCSswptobefnz 4 44 | #define GCSswpend 5 45 | #define GCScallfin 6 46 | #define GCSpause 7 47 | 48 | 49 | #define issweepphase(g) \ 50 | (GCSswpallgc <= (g)->gcstate && (g)->gcstate <= GCSswpend) 51 | 52 | 53 | /* 54 | ** macro to tell when main invariant (white objects cannot point to black 55 | ** ones) must be kept. During a collection, the sweep 56 | ** phase may break the invariant, as objects turned white may point to 57 | ** still-black objects. The invariant is restored when sweep ends and 58 | ** all objects are white again. 59 | */ 60 | 61 | #define keepinvariant(g) ((g)->gcstate <= GCSatomic) 62 | 63 | 64 | /* 65 | ** some useful bit tricks 66 | */ 67 | #define resetbits(x,m) ((x) &= cast(lu_byte, ~(m))) 68 | #define setbits(x,m) ((x) |= (m)) 69 | #define testbits(x,m) ((x) & (m)) 70 | #define bitmask(b) (1<<(b)) 71 | #define bit2mask(b1,b2) (bitmask(b1) | bitmask(b2)) 72 | #define l_setbit(x,b) setbits(x, bitmask(b)) 73 | #define resetbit(x,b) resetbits(x, bitmask(b)) 74 | #define testbit(x,b) testbits(x, bitmask(b)) 75 | 76 | 77 | /* Layout for bit use in 'marked' field: */ 78 | #define WHITE0BIT 0 /* object is white (type 0) */ 79 | #define WHITE1BIT 1 /* object is white (type 1) */ 80 | #define BLACKBIT 2 /* object is black */ 81 | #define FINALIZEDBIT 3 /* object has been marked for finalization */ 82 | /* bit 7 is currently used by tests (luaL_checkmemory) */ 83 | 84 | #define WHITEBITS bit2mask(WHITE0BIT, WHITE1BIT) 85 | 86 | 87 | #define iswhite(x) testbits((x)->marked, WHITEBITS) 88 | #define isblack(x) testbit((x)->marked, BLACKBIT) 89 | #define isgray(x) /* neither white nor black */ \ 90 | (!testbits((x)->marked, WHITEBITS | bitmask(BLACKBIT))) 91 | 92 | #define tofinalize(x) testbit((x)->marked, FINALIZEDBIT) 93 | 94 | #define otherwhite(g) ((g)->currentwhite ^ WHITEBITS) 95 | #define isdeadm(ow,m) (!(((m) ^ WHITEBITS) & (ow))) 96 | #define isdead(g,v) isdeadm(otherwhite(g), (v)->marked) 97 | 98 | #define changewhite(x) ((x)->marked ^= WHITEBITS) 99 | #define gray2black(x) l_setbit((x)->marked, BLACKBIT) 100 | 101 | #define luaC_white(g) cast(lu_byte, (g)->currentwhite & WHITEBITS) 102 | 103 | 104 | /* 105 | ** Does one step of collection when debt becomes positive. 'pre'/'pos' 106 | ** allows some adjustments to be done only when needed. macro 107 | ** 'condchangemem' is used only for heavy tests (forcing a full 108 | ** GC cycle on every opportunity) 109 | */ 110 | #define luaC_condGC(L,pre,pos) \ 111 | { if (G(L)->GCdebt > 0) { pre; luaC_step(L); pos;}; \ 112 | condchangemem(L,pre,pos); } 113 | 114 | /* more often than not, 'pre'/'pos' are empty */ 115 | #define luaC_checkGC(L) luaC_condGC(L,(void)0,(void)0) 116 | 117 | 118 | #define luaC_barrier(L,p,v) ( \ 119 | (iscollectable(v) && isblack(p) && iswhite(gcvalue(v))) ? \ 120 | luaC_barrier_(L,obj2gco(p),gcvalue(v)) : cast_void(0)) 121 | 122 | #define luaC_barrierback(L,p,v) ( \ 123 | (iscollectable(v) && isblack(p) && iswhite(gcvalue(v))) ? \ 124 | luaC_barrierback_(L,p) : cast_void(0)) 125 | 126 | #define luaC_objbarrier(L,p,o) ( \ 127 | (isblack(p) && iswhite(o)) ? \ 128 | luaC_barrier_(L,obj2gco(p),obj2gco(o)) : cast_void(0)) 129 | 130 | #define luaC_upvalbarrier(L,uv) ( \ 131 | (iscollectable((uv)->v) && !upisopen(uv)) ? \ 132 | luaC_upvalbarrier_(L,uv) : cast_void(0)) 133 | 134 | LUAI_FUNC void luaC_fix (lua_State *L, GCObject *o); 135 | LUAI_FUNC void luaC_freeallobjects (lua_State *L); 136 | LUAI_FUNC void luaC_step (lua_State *L); 137 | LUAI_FUNC void luaC_runtilstate (lua_State *L, int statesmask); 138 | LUAI_FUNC void luaC_fullgc (lua_State *L, int isemergency); 139 | LUAI_FUNC GCObject *luaC_newobj (lua_State *L, int tt, size_t sz); 140 | LUAI_FUNC void luaC_barrier_ (lua_State *L, GCObject *o, GCObject *v); 141 | LUAI_FUNC void luaC_barrierback_ (lua_State *L, Table *o); 142 | LUAI_FUNC void luaC_upvalbarrier_ (lua_State *L, UpVal *uv); 143 | LUAI_FUNC void luaC_checkfinalizer (lua_State *L, GCObject *o, Table *mt); 144 | LUAI_FUNC void luaC_upvdeccount (lua_State *L, UpVal *uv); 145 | 146 | 147 | #endif 148 | -------------------------------------------------------------------------------- /Lua/src/linit.c: -------------------------------------------------------------------------------- 1 | /* 2 | ** $Id: linit.c,v 1.39 2016/12/04 20:17:24 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, LUA_PRELOAD_TABLE); 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/src/llex.h: -------------------------------------------------------------------------------- 1 | /* 2 | ** $Id: llex.h,v 1.79 2016/05/02 14:02:12 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 | } LexState; 73 | 74 | 75 | LUAI_FUNC void luaX_init (lua_State *L); 76 | LUAI_FUNC void luaX_setinput (lua_State *L, LexState *ls, ZIO *z, 77 | TString *source, int firstchar); 78 | LUAI_FUNC TString *luaX_newstring (LexState *ls, const char *str, size_t l); 79 | LUAI_FUNC void luaX_next (LexState *ls); 80 | LUAI_FUNC int luaX_lookahead (LexState *ls); 81 | LUAI_FUNC l_noret luaX_syntaxerror (LexState *ls, const char *s); 82 | LUAI_FUNC const char *luaX_token2str (LexState *ls, int token); 83 | 84 | 85 | #endif 86 | -------------------------------------------------------------------------------- /Lua/src/lmem.c: -------------------------------------------------------------------------------- 1 | /* 2 | ** $Id: lmem.c,v 1.91 2015/03/06 19:45:54 roberto Exp $ 3 | ** Interface to Memory Manager 4 | ** See Copyright Notice in lua.h 5 | */ 6 | 7 | #define lmem_c 8 | #define LUA_CORE 9 | 10 | #include "lprefix.h" 11 | 12 | 13 | #include 14 | 15 | #include "lua.h" 16 | 17 | #include "ldebug.h" 18 | #include "ldo.h" 19 | #include "lgc.h" 20 | #include "lmem.h" 21 | #include "lobject.h" 22 | #include "lstate.h" 23 | 24 | 25 | 26 | /* 27 | ** About the realloc function: 28 | ** void * frealloc (void *ud, void *ptr, size_t osize, size_t nsize); 29 | ** ('osize' is the old size, 'nsize' is the new size) 30 | ** 31 | ** * frealloc(ud, NULL, x, s) creates a new block of size 's' (no 32 | ** matter 'x'). 33 | ** 34 | ** * frealloc(ud, p, x, 0) frees the block 'p' 35 | ** (in this specific case, frealloc must return NULL); 36 | ** particularly, frealloc(ud, NULL, 0, 0) does nothing 37 | ** (which is equivalent to free(NULL) in ISO C) 38 | ** 39 | ** frealloc returns NULL if it cannot create or reallocate the area 40 | ** (any reallocation to an equal or smaller size cannot fail!) 41 | */ 42 | 43 | 44 | 45 | #define MINSIZEARRAY 4 46 | 47 | 48 | void *luaM_growaux_ (lua_State *L, void *block, int *size, size_t size_elems, 49 | int limit, const char *what) { 50 | void *newblock; 51 | int newsize; 52 | if (*size >= limit/2) { /* cannot double it? */ 53 | if (*size >= limit) /* cannot grow even a little? */ 54 | luaG_runerror(L, "too many %s (limit is %d)", what, limit); 55 | newsize = limit; /* still have at least one free place */ 56 | } 57 | else { 58 | newsize = (*size)*2; 59 | if (newsize < MINSIZEARRAY) 60 | newsize = MINSIZEARRAY; /* minimum size */ 61 | } 62 | newblock = luaM_reallocv(L, block, *size, newsize, size_elems); 63 | *size = newsize; /* update only when everything else is OK */ 64 | return newblock; 65 | } 66 | 67 | 68 | l_noret luaM_toobig (lua_State *L) { 69 | luaG_runerror(L, "memory allocation error: block too big"); 70 | } 71 | 72 | 73 | 74 | /* 75 | ** generic allocation routine. 76 | */ 77 | void *luaM_realloc_ (lua_State *L, void *block, size_t osize, size_t nsize) { 78 | void *newblock; 79 | global_State *g = G(L); 80 | size_t realosize = (block) ? osize : 0; 81 | lua_assert((realosize == 0) == (block == NULL)); 82 | #if defined(HARDMEMTESTS) 83 | if (nsize > realosize && g->gcrunning) 84 | luaC_fullgc(L, 1); /* force a GC whenever possible */ 85 | #endif 86 | newblock = (*g->frealloc)(g->ud, block, osize, nsize); 87 | if (newblock == NULL && nsize > 0) { 88 | lua_assert(nsize > realosize); /* cannot fail when shrinking a block */ 89 | if (g->version) { /* is state fully built? */ 90 | luaC_fullgc(L, 1); /* try to free some memory... */ 91 | newblock = (*g->frealloc)(g->ud, block, osize, nsize); /* try again */ 92 | } 93 | if (newblock == NULL) 94 | luaD_throw(L, LUA_ERRMEM); 95 | } 96 | lua_assert((nsize == 0) == (newblock == NULL)); 97 | g->GCdebt = (g->GCdebt + nsize) - realosize; 98 | return newblock; 99 | } 100 | 101 | -------------------------------------------------------------------------------- /Lua/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/src/lopcodes.c: -------------------------------------------------------------------------------- 1 | /* 2 | ** $Id: lopcodes.c,v 1.55 2015/01/05 13:48:33 roberto Exp $ 3 | ** Opcodes for Lua virtual machine 4 | ** See Copyright Notice in lua.h 5 | */ 6 | 7 | #define lopcodes_c 8 | #define LUA_CORE 9 | 10 | #include "lprefix.h" 11 | 12 | 13 | #include 14 | 15 | #include "lopcodes.h" 16 | 17 | 18 | /* ORDER OP */ 19 | 20 | LUAI_DDEF const char *const luaP_opnames[NUM_OPCODES+1] = { 21 | "MOVE", 22 | "LOADK", 23 | "LOADKX", 24 | "LOADBOOL", 25 | "LOADNIL", 26 | "GETUPVAL", 27 | "GETTABUP", 28 | "GETTABLE", 29 | "SETTABUP", 30 | "SETUPVAL", 31 | "SETTABLE", 32 | "NEWTABLE", 33 | "SELF", 34 | "ADD", 35 | "SUB", 36 | "MUL", 37 | "MOD", 38 | "POW", 39 | "DIV", 40 | "IDIV", 41 | "BAND", 42 | "BOR", 43 | "BXOR", 44 | "SHL", 45 | "SHR", 46 | "UNM", 47 | "BNOT", 48 | "NOT", 49 | "LEN", 50 | "CONCAT", 51 | "JMP", 52 | "EQ", 53 | "LT", 54 | "LE", 55 | "TEST", 56 | "TESTSET", 57 | "CALL", 58 | "TAILCALL", 59 | "RETURN", 60 | "FORLOOP", 61 | "FORPREP", 62 | "TFORCALL", 63 | "TFORLOOP", 64 | "SETLIST", 65 | "CLOSURE", 66 | "VARARG", 67 | "EXTRAARG", 68 | NULL 69 | }; 70 | 71 | 72 | #define opmode(t,a,b,c,m) (((t)<<7) | ((a)<<6) | ((b)<<4) | ((c)<<2) | (m)) 73 | 74 | LUAI_DDEF const lu_byte luaP_opmodes[NUM_OPCODES] = { 75 | /* T A B C mode opcode */ 76 | opmode(0, 1, OpArgR, OpArgN, iABC) /* OP_MOVE */ 77 | ,opmode(0, 1, OpArgK, OpArgN, iABx) /* OP_LOADK */ 78 | ,opmode(0, 1, OpArgN, OpArgN, iABx) /* OP_LOADKX */ 79 | ,opmode(0, 1, OpArgU, OpArgU, iABC) /* OP_LOADBOOL */ 80 | ,opmode(0, 1, OpArgU, OpArgN, iABC) /* OP_LOADNIL */ 81 | ,opmode(0, 1, OpArgU, OpArgN, iABC) /* OP_GETUPVAL */ 82 | ,opmode(0, 1, OpArgU, OpArgK, iABC) /* OP_GETTABUP */ 83 | ,opmode(0, 1, OpArgR, OpArgK, iABC) /* OP_GETTABLE */ 84 | ,opmode(0, 0, OpArgK, OpArgK, iABC) /* OP_SETTABUP */ 85 | ,opmode(0, 0, OpArgU, OpArgN, iABC) /* OP_SETUPVAL */ 86 | ,opmode(0, 0, OpArgK, OpArgK, iABC) /* OP_SETTABLE */ 87 | ,opmode(0, 1, OpArgU, OpArgU, iABC) /* OP_NEWTABLE */ 88 | ,opmode(0, 1, OpArgR, OpArgK, iABC) /* OP_SELF */ 89 | ,opmode(0, 1, OpArgK, OpArgK, iABC) /* OP_ADD */ 90 | ,opmode(0, 1, OpArgK, OpArgK, iABC) /* OP_SUB */ 91 | ,opmode(0, 1, OpArgK, OpArgK, iABC) /* OP_MUL */ 92 | ,opmode(0, 1, OpArgK, OpArgK, iABC) /* OP_MOD */ 93 | ,opmode(0, 1, OpArgK, OpArgK, iABC) /* OP_POW */ 94 | ,opmode(0, 1, OpArgK, OpArgK, iABC) /* OP_DIV */ 95 | ,opmode(0, 1, OpArgK, OpArgK, iABC) /* OP_IDIV */ 96 | ,opmode(0, 1, OpArgK, OpArgK, iABC) /* OP_BAND */ 97 | ,opmode(0, 1, OpArgK, OpArgK, iABC) /* OP_BOR */ 98 | ,opmode(0, 1, OpArgK, OpArgK, iABC) /* OP_BXOR */ 99 | ,opmode(0, 1, OpArgK, OpArgK, iABC) /* OP_SHL */ 100 | ,opmode(0, 1, OpArgK, OpArgK, iABC) /* OP_SHR */ 101 | ,opmode(0, 1, OpArgR, OpArgN, iABC) /* OP_UNM */ 102 | ,opmode(0, 1, OpArgR, OpArgN, iABC) /* OP_BNOT */ 103 | ,opmode(0, 1, OpArgR, OpArgN, iABC) /* OP_NOT */ 104 | ,opmode(0, 1, OpArgR, OpArgN, iABC) /* OP_LEN */ 105 | ,opmode(0, 1, OpArgR, OpArgR, iABC) /* OP_CONCAT */ 106 | ,opmode(0, 0, OpArgR, OpArgN, iAsBx) /* OP_JMP */ 107 | ,opmode(1, 0, OpArgK, OpArgK, iABC) /* OP_EQ */ 108 | ,opmode(1, 0, OpArgK, OpArgK, iABC) /* OP_LT */ 109 | ,opmode(1, 0, OpArgK, OpArgK, iABC) /* OP_LE */ 110 | ,opmode(1, 0, OpArgN, OpArgU, iABC) /* OP_TEST */ 111 | ,opmode(1, 1, OpArgR, OpArgU, iABC) /* OP_TESTSET */ 112 | ,opmode(0, 1, OpArgU, OpArgU, iABC) /* OP_CALL */ 113 | ,opmode(0, 1, OpArgU, OpArgU, iABC) /* OP_TAILCALL */ 114 | ,opmode(0, 0, OpArgU, OpArgN, iABC) /* OP_RETURN */ 115 | ,opmode(0, 1, OpArgR, OpArgN, iAsBx) /* OP_FORLOOP */ 116 | ,opmode(0, 1, OpArgR, OpArgN, iAsBx) /* OP_FORPREP */ 117 | ,opmode(0, 0, OpArgN, OpArgU, iABC) /* OP_TFORCALL */ 118 | ,opmode(0, 1, OpArgR, OpArgN, iAsBx) /* OP_TFORLOOP */ 119 | ,opmode(0, 0, OpArgU, OpArgU, iABC) /* OP_SETLIST */ 120 | ,opmode(0, 1, OpArgU, OpArgN, iABx) /* OP_CLOSURE */ 121 | ,opmode(0, 1, OpArgU, OpArgN, iABC) /* OP_VARARG */ 122 | ,opmode(0, 0, OpArgU, OpArgU, iAx) /* OP_EXTRAARG */ 123 | }; 124 | 125 | -------------------------------------------------------------------------------- /Lua/src/lparser.h: -------------------------------------------------------------------------------- 1 | /* 2 | ** $Id: lparser.h,v 1.76 2015/12/30 18:16:13 roberto Exp $ 3 | ** Lua Parser 4 | ** See Copyright Notice in lua.h 5 | */ 6 | 7 | #ifndef lparser_h 8 | #define lparser_h 9 | 10 | #include "llimits.h" 11 | #include "lobject.h" 12 | #include "lzio.h" 13 | 14 | 15 | /* 16 | ** Expression and variable descriptor. 17 | ** Code generation for variables and expressions can be delayed to allow 18 | ** optimizations; An 'expdesc' structure describes a potentially-delayed 19 | ** variable/expression. It has a description of its "main" value plus a 20 | ** list of conditional jumps that can also produce its value (generated 21 | ** by short-circuit operators 'and'/'or'). 22 | */ 23 | 24 | /* kinds of variables/expressions */ 25 | typedef enum { 26 | VVOID, /* when 'expdesc' describes the last expression a list, 27 | this kind means an empty list (so, no expression) */ 28 | VNIL, /* constant nil */ 29 | VTRUE, /* constant true */ 30 | VFALSE, /* constant false */ 31 | VK, /* constant in 'k'; info = index of constant in 'k' */ 32 | VKFLT, /* floating constant; nval = numerical float value */ 33 | VKINT, /* integer constant; nval = numerical integer value */ 34 | VNONRELOC, /* expression has its value in a fixed register; 35 | info = result register */ 36 | VLOCAL, /* local variable; info = local register */ 37 | VUPVAL, /* upvalue variable; info = index of upvalue in 'upvalues' */ 38 | VINDEXED, /* indexed variable; 39 | ind.vt = whether 't' is register or upvalue; 40 | ind.t = table register or upvalue; 41 | ind.idx = key's R/K index */ 42 | VJMP, /* expression is a test/comparison; 43 | info = pc of corresponding jump instruction */ 44 | VRELOCABLE, /* expression can put result in any register; 45 | info = instruction pc */ 46 | VCALL, /* expression is a function call; info = instruction pc */ 47 | VVARARG /* vararg expression; info = instruction pc */ 48 | } expkind; 49 | 50 | 51 | #define vkisvar(k) (VLOCAL <= (k) && (k) <= VINDEXED) 52 | #define vkisinreg(k) ((k) == VNONRELOC || (k) == VLOCAL) 53 | 54 | typedef struct expdesc { 55 | expkind k; 56 | union { 57 | lua_Integer ival; /* for VKINT */ 58 | lua_Number nval; /* for VKFLT */ 59 | int info; /* for generic use */ 60 | struct { /* for indexed variables (VINDEXED) */ 61 | short idx; /* index (R/K) */ 62 | lu_byte t; /* table (register or upvalue) */ 63 | lu_byte vt; /* whether 't' is register (VLOCAL) or upvalue (VUPVAL) */ 64 | } ind; 65 | } u; 66 | int t; /* patch list of 'exit when true' */ 67 | int f; /* patch list of 'exit when false' */ 68 | } expdesc; 69 | 70 | 71 | /* description of active local variable */ 72 | typedef struct Vardesc { 73 | short idx; /* variable index in stack */ 74 | } Vardesc; 75 | 76 | 77 | /* description of pending goto statements and label statements */ 78 | typedef struct Labeldesc { 79 | TString *name; /* label identifier */ 80 | int pc; /* position in code */ 81 | int line; /* line where it appeared */ 82 | lu_byte nactvar; /* local level where it appears in current block */ 83 | } Labeldesc; 84 | 85 | 86 | /* list of labels or gotos */ 87 | typedef struct Labellist { 88 | Labeldesc *arr; /* array */ 89 | int n; /* number of entries in use */ 90 | int size; /* array size */ 91 | } Labellist; 92 | 93 | 94 | /* dynamic structures used by the parser */ 95 | typedef struct Dyndata { 96 | struct { /* list of active local variables */ 97 | Vardesc *arr; 98 | int n; 99 | int size; 100 | } actvar; 101 | Labellist gt; /* list of pending gotos */ 102 | Labellist label; /* list of active labels */ 103 | } Dyndata; 104 | 105 | 106 | /* control of blocks */ 107 | struct BlockCnt; /* defined in lparser.c */ 108 | 109 | 110 | /* state needed to generate code for a given function */ 111 | typedef struct FuncState { 112 | Proto *f; /* current function header */ 113 | struct FuncState *prev; /* enclosing function */ 114 | struct LexState *ls; /* lexical state */ 115 | struct BlockCnt *bl; /* chain of current blocks */ 116 | int pc; /* next position to code (equivalent to 'ncode') */ 117 | int lasttarget; /* 'label' of last 'jump label' */ 118 | int jpc; /* list of pending jumps to 'pc' */ 119 | int nk; /* number of elements in 'k' */ 120 | int np; /* number of elements in 'p' */ 121 | int firstlocal; /* index of first local var (in Dyndata array) */ 122 | short nlocvars; /* number of elements in 'f->locvars' */ 123 | lu_byte nactvar; /* number of active local variables */ 124 | lu_byte nups; /* number of upvalues */ 125 | lu_byte freereg; /* first free register */ 126 | } FuncState; 127 | 128 | 129 | LUAI_FUNC LClosure *luaY_parser (lua_State *L, ZIO *z, Mbuffer *buff, 130 | Dyndata *dyd, const char *name, int firstchar); 131 | 132 | 133 | #endif 134 | -------------------------------------------------------------------------------- /Lua/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/src/lstring.h: -------------------------------------------------------------------------------- 1 | /* 2 | ** $Id: lstring.h,v 1.61 2015/11/03 15:36:01 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 | 17 | #define sizeludata(l) (sizeof(union UUdata) + (l)) 18 | #define sizeudata(u) sizeludata((u)->len) 19 | 20 | #define luaS_newliteral(L, s) (luaS_newlstr(L, "" s, \ 21 | (sizeof(s)/sizeof(char))-1)) 22 | 23 | 24 | /* 25 | ** test whether a string is a reserved word 26 | */ 27 | #define isreserved(s) ((s)->tt == LUA_TSHRSTR && (s)->extra > 0) 28 | 29 | 30 | /* 31 | ** equality for short strings, which are always internalized 32 | */ 33 | #define eqshrstr(a,b) check_exp((a)->tt == LUA_TSHRSTR, (a) == (b)) 34 | 35 | 36 | LUAI_FUNC unsigned int luaS_hash (const char *str, size_t l, unsigned int seed); 37 | LUAI_FUNC unsigned int luaS_hashlongstr (TString *ts); 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_clearcache (global_State *g); 41 | LUAI_FUNC void luaS_init (lua_State *L); 42 | LUAI_FUNC void luaS_remove (lua_State *L, TString *ts); 43 | LUAI_FUNC Udata *luaS_newudata (lua_State *L, size_t s); 44 | LUAI_FUNC TString *luaS_newlstr (lua_State *L, const char *str, size_t l); 45 | LUAI_FUNC TString *luaS_new (lua_State *L, const char *str); 46 | LUAI_FUNC TString *luaS_createlngstrobj (lua_State *L, size_t l); 47 | 48 | 49 | #endif 50 | -------------------------------------------------------------------------------- /Lua/src/ltable.h: -------------------------------------------------------------------------------- 1 | /* 2 | ** $Id: ltable.h,v 2.23 2016/12/22 13:08:50 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 | /* 22 | ** writable version of 'gkey'; allows updates to individual fields, 23 | ** but not to the whole (which has incompatible type) 24 | */ 25 | #define wgkey(n) (&(n)->i_key.nk) 26 | 27 | #define invalidateTMcache(t) ((t)->flags = 0) 28 | 29 | 30 | /* true when 't' is using 'dummynode' as its hash part */ 31 | #define isdummy(t) ((t)->lastfree == NULL) 32 | 33 | 34 | /* allocated size for hash nodes */ 35 | #define allocsizenode(t) (isdummy(t) ? 0 : sizenode(t)) 36 | 37 | 38 | /* returns the key, given the value of a table entry */ 39 | #define keyfromval(v) \ 40 | (gkey(cast(Node *, cast(char *, (v)) - offsetof(Node, i_val)))) 41 | 42 | 43 | LUAI_FUNC const TValue *luaH_getint (Table *t, lua_Integer key); 44 | LUAI_FUNC void luaH_setint (lua_State *L, Table *t, lua_Integer key, 45 | TValue *value); 46 | LUAI_FUNC const TValue *luaH_getshortstr (Table *t, TString *key); 47 | LUAI_FUNC const TValue *luaH_getstr (Table *t, TString *key); 48 | LUAI_FUNC const TValue *luaH_get (Table *t, const TValue *key); 49 | LUAI_FUNC TValue *luaH_newkey (lua_State *L, Table *t, const TValue *key); 50 | LUAI_FUNC TValue *luaH_set (lua_State *L, Table *t, const TValue *key); 51 | LUAI_FUNC Table *luaH_new (lua_State *L); 52 | LUAI_FUNC void luaH_resize (lua_State *L, Table *t, unsigned int nasize, 53 | unsigned int nhsize); 54 | LUAI_FUNC void luaH_resizearray (lua_State *L, Table *t, unsigned int nasize); 55 | LUAI_FUNC void luaH_free (lua_State *L, Table *t); 56 | LUAI_FUNC int luaH_next (lua_State *L, Table *t, StkId key); 57 | LUAI_FUNC int luaH_getn (Table *t); 58 | 59 | 60 | #if defined(LUA_DEBUG) 61 | LUAI_FUNC Node *luaH_mainposition (const Table *t, const TValue *key); 62 | LUAI_FUNC int luaH_isdummy (const Table *t); 63 | #endif 64 | 65 | 66 | #endif 67 | -------------------------------------------------------------------------------- /Lua/src/ltm.h: -------------------------------------------------------------------------------- 1 | /* 2 | ** $Id: ltm.h,v 2.22 2016/02/26 19:20:15 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 | 55 | LUAI_DDEC const char *const luaT_typenames_[LUA_TOTALTAGS]; 56 | 57 | 58 | LUAI_FUNC const char *luaT_objtypename (lua_State *L, const TValue *o); 59 | 60 | LUAI_FUNC const TValue *luaT_gettm (Table *events, TMS event, TString *ename); 61 | LUAI_FUNC const TValue *luaT_gettmbyobj (lua_State *L, const TValue *o, 62 | TMS event); 63 | LUAI_FUNC void luaT_init (lua_State *L); 64 | 65 | LUAI_FUNC void luaT_callTM (lua_State *L, const TValue *f, const TValue *p1, 66 | const TValue *p2, TValue *p3, int hasres); 67 | LUAI_FUNC int luaT_callbinTM (lua_State *L, const TValue *p1, const TValue *p2, 68 | StkId res, TMS event); 69 | LUAI_FUNC void luaT_trybinTM (lua_State *L, const TValue *p1, const TValue *p2, 70 | StkId res, TMS event); 71 | LUAI_FUNC int luaT_callorderTM (lua_State *L, const TValue *p1, 72 | const TValue *p2, TMS event); 73 | 74 | 75 | 76 | #endif 77 | -------------------------------------------------------------------------------- /Lua/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/src/lualib.h: -------------------------------------------------------------------------------- 1 | /* 2 | ** $Id: lualib.h,v 1.45 2017/01/12 17:14:26 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 | /* version suffix for environment variable names */ 15 | #define LUA_VERSUFFIX "_" LUA_VERSION_MAJOR "_" LUA_VERSION_MINOR 16 | 17 | 18 | LUAMOD_API int (luaopen_base) (lua_State *L); 19 | 20 | #define LUA_COLIBNAME "coroutine" 21 | LUAMOD_API int (luaopen_coroutine) (lua_State *L); 22 | 23 | #define LUA_TABLIBNAME "table" 24 | LUAMOD_API int (luaopen_table) (lua_State *L); 25 | 26 | #define LUA_IOLIBNAME "io" 27 | LUAMOD_API int (luaopen_io) (lua_State *L); 28 | 29 | #define LUA_OSLIBNAME "os" 30 | LUAMOD_API int (luaopen_os) (lua_State *L); 31 | 32 | #define LUA_STRLIBNAME "string" 33 | LUAMOD_API int (luaopen_string) (lua_State *L); 34 | 35 | #define LUA_UTF8LIBNAME "utf8" 36 | LUAMOD_API int (luaopen_utf8) (lua_State *L); 37 | 38 | #define LUA_BITLIBNAME "bit32" 39 | LUAMOD_API int (luaopen_bit32) (lua_State *L); 40 | 41 | #define LUA_MATHLIBNAME "math" 42 | LUAMOD_API int (luaopen_math) (lua_State *L); 43 | 44 | #define LUA_DBLIBNAME "debug" 45 | LUAMOD_API int (luaopen_debug) (lua_State *L); 46 | 47 | #define LUA_LOADLIBNAME "package" 48 | LUAMOD_API int (luaopen_package) (lua_State *L); 49 | 50 | 51 | /* open all previous libraries */ 52 | LUALIB_API void (luaL_openlibs) (lua_State *L); 53 | 54 | 55 | 56 | #if !defined(lua_assert) 57 | #define lua_assert(x) ((void)0) 58 | #endif 59 | 60 | 61 | #endif 62 | -------------------------------------------------------------------------------- /Lua/src/lundump.h: -------------------------------------------------------------------------------- 1 | /* 2 | ** $Id: lundump.h,v 1.45 2015/09/08 15:41:05 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, const char* name); 27 | 28 | /* dump one chunk; from ldump.c */ 29 | LUAI_FUNC int luaU_dump (lua_State* L, const Proto* f, lua_Writer w, 30 | void* data, int strip); 31 | 32 | #endif 33 | -------------------------------------------------------------------------------- /Lua/src/lvm.h: -------------------------------------------------------------------------------- 1 | /* 2 | ** $Id: lvm.h,v 2.41 2016/12/22 13:08:50 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 | /* 31 | ** You can define LUA_FLOORN2I if you want to convert floats to integers 32 | ** by flooring them (instead of raising an error if they are not 33 | ** integral values) 34 | */ 35 | #if !defined(LUA_FLOORN2I) 36 | #define LUA_FLOORN2I 0 37 | #endif 38 | 39 | 40 | #define tonumber(o,n) \ 41 | (ttisfloat(o) ? (*(n) = fltvalue(o), 1) : luaV_tonumber_(o,n)) 42 | 43 | #define tointeger(o,i) \ 44 | (ttisinteger(o) ? (*(i) = ivalue(o), 1) : luaV_tointeger(o,i,LUA_FLOORN2I)) 45 | 46 | #define intop(op,v1,v2) l_castU2S(l_castS2U(v1) op l_castS2U(v2)) 47 | 48 | #define luaV_rawequalobj(t1,t2) luaV_equalobj(NULL,t1,t2) 49 | 50 | 51 | /* 52 | ** fast track for 'gettable': if 't' is a table and 't[k]' is not nil, 53 | ** return 1 with 'slot' pointing to 't[k]' (final result). Otherwise, 54 | ** return 0 (meaning it will have to check metamethod) with 'slot' 55 | ** pointing to a nil 't[k]' (if 't' is a table) or NULL (otherwise). 56 | ** 'f' is the raw get function to use. 57 | */ 58 | #define luaV_fastget(L,t,k,slot,f) \ 59 | (!ttistable(t) \ 60 | ? (slot = NULL, 0) /* not a table; 'slot' is NULL and result is 0 */ \ 61 | : (slot = f(hvalue(t), k), /* else, do raw access */ \ 62 | !ttisnil(slot))) /* result not nil? */ 63 | 64 | /* 65 | ** standard implementation for 'gettable' 66 | */ 67 | #define luaV_gettable(L,t,k,v) { const TValue *slot; \ 68 | if (luaV_fastget(L,t,k,slot,luaH_get)) { setobj2s(L, v, slot); } \ 69 | else luaV_finishget(L,t,k,v,slot); } 70 | 71 | 72 | /* 73 | ** Fast track for set table. If 't' is a table and 't[k]' is not nil, 74 | ** call GC barrier, do a raw 't[k]=v', and return true; otherwise, 75 | ** return false with 'slot' equal to NULL (if 't' is not a table) or 76 | ** 'nil'. (This is needed by 'luaV_finishget'.) Note that, if the macro 77 | ** returns true, there is no need to 'invalidateTMcache', because the 78 | ** call is not creating a new entry. 79 | */ 80 | #define luaV_fastset(L,t,k,slot,f,v) \ 81 | (!ttistable(t) \ 82 | ? (slot = NULL, 0) \ 83 | : (slot = f(hvalue(t), k), \ 84 | ttisnil(slot) ? 0 \ 85 | : (luaC_barrierback(L, hvalue(t), v), \ 86 | setobj2t(L, cast(TValue *,slot), v), \ 87 | 1))) 88 | 89 | 90 | #define luaV_settable(L,t,k,v) { const TValue *slot; \ 91 | if (!luaV_fastset(L,t,k,slot,luaH_get,v)) \ 92 | luaV_finishset(L,t,k,v,slot); } 93 | 94 | 95 | 96 | LUAI_FUNC int luaV_equalobj (lua_State *L, const TValue *t1, const TValue *t2); 97 | LUAI_FUNC int luaV_lessthan (lua_State *L, const TValue *l, const TValue *r); 98 | LUAI_FUNC int luaV_lessequal (lua_State *L, const TValue *l, const TValue *r); 99 | LUAI_FUNC int luaV_tonumber_ (const TValue *obj, lua_Number *n); 100 | LUAI_FUNC int luaV_tointeger (const TValue *obj, lua_Integer *p, int mode); 101 | LUAI_FUNC void luaV_finishget (lua_State *L, const TValue *t, TValue *key, 102 | StkId val, const TValue *slot); 103 | LUAI_FUNC void luaV_finishset (lua_State *L, const TValue *t, TValue *key, 104 | StkId val, const TValue *slot); 105 | LUAI_FUNC void luaV_finishOp (lua_State *L); 106 | LUAI_FUNC void luaV_execute (lua_State *L); 107 | LUAI_FUNC void luaV_concat (lua_State *L, int total); 108 | LUAI_FUNC lua_Integer luaV_div (lua_State *L, lua_Integer x, lua_Integer y); 109 | LUAI_FUNC lua_Integer luaV_mod (lua_State *L, lua_Integer x, lua_Integer y); 110 | LUAI_FUNC lua_Integer luaV_shiftl (lua_Integer x, lua_Integer y); 111 | LUAI_FUNC void luaV_objlen (lua_State *L, StkId ra, const TValue *rb); 112 | 113 | #endif 114 | -------------------------------------------------------------------------------- /Lua/src/lzio.c: -------------------------------------------------------------------------------- 1 | /* 2 | ** $Id: lzio.c,v 1.37 2015/09/08 15:41:05 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 | -------------------------------------------------------------------------------- /Lua/src/lzio.h: -------------------------------------------------------------------------------- 1 | /* 2 | ** $Id: lzio.h,v 1.31 2015/09/08 15:41:05 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 void luaZ_init (lua_State *L, ZIO *z, lua_Reader reader, 48 | void *data); 49 | LUAI_FUNC size_t luaZ_read (ZIO* z, void *b, size_t n); /* read next n bytes */ 50 | 51 | 52 | 53 | /* --------- Private Part ------------------ */ 54 | 55 | struct Zio { 56 | size_t n; /* bytes still unread */ 57 | const char *p; /* current position in buffer */ 58 | lua_Reader reader; /* reader function */ 59 | void *data; /* additional data */ 60 | lua_State *L; /* Lua state (for reader) */ 61 | }; 62 | 63 | 64 | LUAI_FUNC int luaZ_fill (ZIO *z); 65 | 66 | #endif 67 | -------------------------------------------------------------------------------- /Main.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "Tracer.h" 4 | #include "PEFile.h" 5 | #include "Modules.h" 6 | 7 | enum EImpRecType {irNone,irSmart,irSmartTracer,irLoadLibs}; 8 | enum EUnpackModeType {umFull,umSkipOEP,umScript}; 9 | 10 | struct CInitData 11 | { 12 | TSTRING sParameters,sScriptFile,sUnpackedLong,sUnpackedShort,sUnpackedFile,sVictimFile,sVictimName; 13 | DWORD dwCutModule,dwImportRVA,dwOEP,dwModuleEnd,dwPID,dwTimeDelta,dwTID; 14 | DWORD_PTR ImageBase; 15 | EImpRecType ImportRec; 16 | EUnpackModeType UnpackMode; 17 | BOOL fAppendOverlay,fAutosaveLog,fDelphiInit,fDirectRefs,fExecuteFunc,fForce,fIsDll,fLeaveDirectRefs,fLongImport,fMemoryManager,fPathToLibs,fProtectDr,fRelocs,fRemoveSect,fSuspectFunc,fUseTf; 18 | HWND hMain; 19 | HMODULE hDllHandle; 20 | }; 21 | 22 | unsigned int __stdcall MainThread(void *pInitData); 23 | void StopMainThread(); 24 | 25 | class CMain:public CTracer 26 | { 27 | friend CDlgImport; 28 | friend CTracer; 29 | 30 | void IntersecLibsArray(std::map &sLibs,const CImportRecord &ImportRecord); 31 | void FillLibsArray(std::map &sLibs,CImportRecord ImportRecord); 32 | DWORD GetNeededThreadId(HANDLE hThread); 33 | bool IsNeededProcess(HANDLE hProcess); 34 | public: 35 | CInitData *pInitData; 36 | bool fTerminate; 37 | CPEFile UnpackedFile; 38 | CModules Modules; 39 | CImport Import; 40 | CFixUp FixUp; 41 | CPEFile VirginVictim; 42 | DWORD_PTR TickCountAX,TickCountDX; 43 | int nBreakNumber; 44 | 45 | CMain(CInitData *n_pInitData); 46 | ~CMain(); 47 | 48 | int PreLoad(); 49 | int PreLoadDLL(); 50 | void FullUnpack(); 51 | void RestoreDelphiInit(bool fIsStatic); 52 | void ChangeForwardedImport(); 53 | void RestoreImportRelocs(); 54 | void Run(); 55 | void RunScript(); 56 | void Stop(); 57 | void UnpackSkipOEP(); 58 | 59 | bool IsAddressInModule(DWORD_PTR Address); 60 | DWORD_PTR SetLastSEH(); 61 | void RemoveLastSEH(DWORD_PTR SehAddr); 62 | void ProcessRelocation(); 63 | void ProcessImport(); 64 | void ProcessImportOnlyLibs(); 65 | int FindTrace(DWORD dwRefRVA,DWORD_PTR RecordAddr,EImportRecordType Type); 66 | int FindTraceSkipOEP(DWORD dwRefRVA,DWORD_PTR RecordAddr,EImportRecordType Type); 67 | void ProcessImportWTrace(); 68 | void IdentifyFunction(CImportRecord &ImportRecord,DWORD_PTR FuncAddress) const; 69 | 70 | void SetMainBreaks(); 71 | DWORD_PTR LoadExtraLibrary(const TCHAR *szPath); 72 | DWORD_PTR ExecuteFunction(const TCHAR *szPath,const char *szFunc,DWORD_PTR Arg1,DWORD_PTR Arg2,DWORD_PTR Arg3,DWORD_PTR Arg4,DWORD_PTR Arg5); 73 | DWORD_PTR Find(const BYTE *bBuf,int nLength,DWORD_PTR StartAddr,DWORD_PTR EndAddr); 74 | DWORD_PTR FindByMask(const BYTE *bBuf,int nLength,DWORD_PTR StartAddr,DWORD_PTR EndAddr); 75 | bool BreakHandler(); 76 | }; 77 | 78 | extern CMain *pMain; -------------------------------------------------------------------------------- /MiniFMOD/lib/Mixer.h: -------------------------------------------------------------------------------- 1 | /******************************************************************************/ 2 | /* MIXER.H */ 3 | /* ---------------- */ 4 | /* MiniFMOD public source code release. */ 5 | /* This source is provided as-is. Firelight Technologies will not support */ 6 | /* or answer questions about the source provided. */ 7 | /* MiniFMOD Sourcecode is copyright (c) Firelight Technologies, 2000-2004. */ 8 | /* MiniFMOD Sourcecode is in no way representative of FMOD 3 source. */ 9 | /* Firelight Technologies is a registered company. */ 10 | /* This source must not be redistributed without this notice. */ 11 | /******************************************************************************/ 12 | 13 | #ifndef _MIXER_H_ 14 | #define _MIXER_H_ 15 | 16 | #define FSOUND_MIXDIR_FORWARDS 1 17 | #define FSOUND_MIXDIR_BACKWARDS 2 18 | 19 | #define FSOUND_OUTPUTBUFF_END 0 20 | #define FSOUND_SAMPLEBUFF_END 1 21 | #define FSOUND_VOLUMERAMP_END 2 22 | 23 | #endif -------------------------------------------------------------------------------- /MiniFMOD/lib/Winmm.lib: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fatrolls/Quick-Unpack/48070723aa80c1f2b6d1c43c345e51c37c1ea5b2/MiniFMOD/lib/Winmm.lib -------------------------------------------------------------------------------- /MiniFMOD/lib/minifmod.h: -------------------------------------------------------------------------------- 1 | /******************************************************************************/ 2 | /* MINIFMOD.H */ 3 | /* ---------------- */ 4 | /* MiniFMOD public source code release. */ 5 | /* This source is provided as-is. Firelight Technologies will not support */ 6 | /* or answer questions about the source provided. */ 7 | /* MiniFMOD Sourcecode is copyright (c) Firelight Technologies, 2000-2004. */ 8 | /* MiniFMOD Sourcecode is in no way representative of FMOD 3 source. */ 9 | /* Firelight Technologies is a registered company name. */ 10 | /* This source must not be redistributed without this notice. */ 11 | /******************************************************************************/ 12 | 13 | //========================================================================================== 14 | // MINIFMOD Main header file. Copyright (c), Firelight Technologies, 2000-2004. 15 | // Based on FMOD, copyright (c), Firelight Technologies, 2000-2004. 16 | //========================================================================================== 17 | 18 | #ifndef _MINIFMOD_H_ 19 | #define _MINIFMOD_H_ 20 | 21 | //=============================================================================================== 22 | //= DEFINITIONS 23 | //=============================================================================================== 24 | 25 | // fmod defined types 26 | typedef struct FMUSIC_MODULE FMUSIC_MODULE; 27 | 28 | //=============================================================================================== 29 | //= FUNCTION PROTOTYPES 30 | //=============================================================================================== 31 | 32 | #ifdef __cplusplus 33 | extern "C" { 34 | #endif 35 | 36 | // ================================== 37 | // Initialization / Global functions. 38 | // ================================== 39 | typedef void (*SAMPLELOADCALLBACK)(void *buff,int lenbytes,int numbits,int instno,int sampno); 40 | typedef void (*FMUSIC_CALLBACK)(FMUSIC_MODULE *mod,unsigned char param); 41 | 42 | // this must be called before FSOUND_Init! 43 | void FSOUND_File_SetCallbacks(void *(*OpenCallback)(char *name), 44 | void (*CloseCallback)(void *handle), 45 | int (*ReadCallback)(void *buffer,int size,void *handle), 46 | void (*SeekCallback)(void *handle,int pos,signed char mode), 47 | int (*TellCallback)(void *handle)); 48 | 49 | // ============================================================================================= 50 | // FMUSIC API 51 | // ============================================================================================= 52 | 53 | // Song management / playback functions. 54 | // ===================================== 55 | 56 | FMUSIC_MODULE *FMUSIC_LoadSong(char *data,SAMPLELOADCALLBACK sampleloadcallback); 57 | signed char FMUSIC_FreeSong(FMUSIC_MODULE *mod); 58 | signed char FMUSIC_PlaySong(FMUSIC_MODULE *mod); 59 | signed char FMUSIC_StopSong(FMUSIC_MODULE *mod); 60 | 61 | // Runtime song information 62 | // ======================== 63 | 64 | int FMUSIC_GetOrder(FMUSIC_MODULE *mod); 65 | int FMUSIC_GetRow(FMUSIC_MODULE *mod); 66 | unsigned int FMUSIC_GetTime(FMUSIC_MODULE *mod); 67 | 68 | #ifdef __cplusplus 69 | } 70 | #endif 71 | 72 | #endif -------------------------------------------------------------------------------- /MiniFMOD/lib/mixer_clipcopy.h: -------------------------------------------------------------------------------- 1 | /******************************************************************************/ 2 | /* MIXER_CLIPCOPY.H */ 3 | /* ---------------- */ 4 | /* MiniFMOD public source code release. */ 5 | /* This source is provided as-is. Firelight Technologies will not support */ 6 | /* or answer questions about the source provided. */ 7 | /* MiniFMOD Sourcecode is copyright (c) Firelight Technologies, 2000-2004. */ 8 | /* MiniFMOD Sourcecode is in no way representative of FMOD 3 source. */ 9 | /* Firelight Technologies is a registered company. */ 10 | /* This source must not be redistributed without this notice. */ 11 | /******************************************************************************/ 12 | 13 | #ifndef _MIXER_CLIPCOPY_H 14 | #define _MIXER_CLIPCOPY_H 15 | 16 | void FSOUND_MixerClipCopy_Float32(void *dest,void *src,int len); 17 | 18 | #endif -------------------------------------------------------------------------------- /MiniFMOD/lib/mixer_fpu_ramp.h: -------------------------------------------------------------------------------- 1 | /******************************************************************************/ 2 | /* MIXER_FPU_RAMP.H */ 3 | /* ---------------- */ 4 | /* MiniFMOD public source code release. */ 5 | /* This source is provided as-is. Firelight Technologies will not support */ 6 | /* or answer questions about the source provided. */ 7 | /* MiniFMOD Sourcecode is copyright (c) Firelight Technologies, 2000-2004. */ 8 | /* MiniFMOD Sourcecode is in no way representative of FMOD 3 source. */ 9 | /* Firelight Technologies is a registered company. */ 10 | /* This source must not be redistributed without this notice. */ 11 | /******************************************************************************/ 12 | 13 | #ifndef _MIXER_FPU_RAMP_H 14 | #define _MIXER_FPU_RAMP_H 15 | 16 | #define FSOUND_VOLUMERAMP_STEPS 128 // at 44.1khz 17 | 18 | void FSOUND_Mixer_FPU_Ramp(void *mixptr,int len); 19 | 20 | extern unsigned int mix_volumerampsteps; 21 | extern float mix_1overvolumerampsteps; 22 | 23 | #endif -------------------------------------------------------------------------------- /MiniFMOD/lib/music_formatxm.h: -------------------------------------------------------------------------------- 1 | /******************************************************************************/ 2 | /* FORMATXM.H */ 3 | /* ---------------- */ 4 | /* MiniFMOD public source code release. */ 5 | /* This source is provided as-is. Firelight Technologies will not support */ 6 | /* or answer questions about the source provided. */ 7 | /* MiniFMOD Sourcecode is copyright (c) Firelight Technologies, 2000-2004. */ 8 | /* MiniFMOD Sourcecode is in no way representative of FMOD 3 source. */ 9 | /* Firelight Technologies is a registered company. */ 10 | /* This source must not be redistributed without this notice. */ 11 | /******************************************************************************/ 12 | 13 | #ifndef _FMUSIC_FORMATXM 14 | #define _FMUSIC_FORMATXM 15 | 16 | #include "music.h" 17 | #include "system_file.h" 18 | 19 | 20 | enum FMUSIC_XMCOMMANDS 21 | { 22 | FMUSIC_XM_ARPEGGIO, 23 | FMUSIC_XM_PORTAUP, 24 | FMUSIC_XM_PORTADOWN, 25 | FMUSIC_XM_PORTATO, 26 | FMUSIC_XM_VIBRATO, 27 | FMUSIC_XM_PORTATOVOLSLIDE, 28 | FMUSIC_XM_VIBRATOVOLSLIDE, 29 | FMUSIC_XM_TREMOLO, 30 | FMUSIC_XM_SETPANPOSITION, 31 | FMUSIC_XM_SETSAMPLEOFFSET, 32 | FMUSIC_XM_VOLUMESLIDE, 33 | FMUSIC_XM_PATTERNJUMP, 34 | FMUSIC_XM_SETVOLUME, 35 | FMUSIC_XM_PATTERNBREAK, 36 | FMUSIC_XM_SPECIAL, 37 | FMUSIC_XM_SETSPEED, 38 | FMUSIC_XM_SETGLOBALVOLUME, 39 | FMUSIC_XM_GLOBALVOLSLIDE, 40 | FMUSIC_XM_I, 41 | FMUSIC_XM_J, 42 | FMUSIC_XM_KEYOFF, 43 | FMUSIC_XM_SETENVELOPEPOS, 44 | FMUSIC_XM_M, 45 | FMUSIC_XM_N, 46 | FMUSIC_XM_O, 47 | FMUSIC_XM_PANSLIDE, 48 | FMUSIC_XM_Q, 49 | FMUSIC_XM_MULTIRETRIG, 50 | FMUSIC_XM_S, 51 | FMUSIC_XM_TREMOR, 52 | FMUSIC_XM_U, 53 | FMUSIC_XM_V, 54 | FMUSIC_XM_W, 55 | FMUSIC_XM_EXTRAFINEPORTA, 56 | FMUSIC_XM_Y, 57 | FMUSIC_XM_Z, 58 | }; 59 | 60 | 61 | enum FMUSIC_XMCOMMANDSSPECIAL 62 | { 63 | FMUSIC_XM_SETFILTER, 64 | FMUSIC_XM_FINEPORTAUP, 65 | FMUSIC_XM_FINEPORTADOWN, 66 | FMUSIC_XM_SETGLISSANDO, 67 | FMUSIC_XM_SETVIBRATOWAVE, 68 | FMUSIC_XM_SETFINETUNE, 69 | FMUSIC_XM_PATTERNLOOP, 70 | FMUSIC_XM_SETTREMOLOWAVE, 71 | FMUSIC_XM_SETPANPOSITION16, 72 | FMUSIC_XM_RETRIG, 73 | FMUSIC_XM_FINEVOLUMESLIDEUP, 74 | FMUSIC_XM_FINEVOLUMESLIDEDOWN, 75 | FMUSIC_XM_NOTECUT, 76 | FMUSIC_XM_NOTEDELAY, 77 | FMUSIC_XM_PATTERNDELAY, 78 | FMUSIC_XM_FUNKREPEAT, 79 | }; 80 | 81 | #define FMUSIC_XMFLAGS_LINEARFREQUENCY 1 82 | 83 | typedef struct 84 | { 85 | unsigned long instSize; // instrument size 86 | signed char instName[22]; // instrument filename 87 | unsigned char instType; // instrument type (now 0) 88 | unsigned short numSamples; // number of samples in instrument 89 | } FMUSIC_XM_INSTHEADER; 90 | 91 | typedef struct 92 | { 93 | unsigned long headerSize; // sample header size 94 | unsigned char noteSmpNums[96]; // sample numbers for notes 95 | unsigned short volEnvelope[2*12]; // volume envelope points 96 | unsigned short panEnvelope[2*12]; // panning envelope points 97 | unsigned char numVolPoints; // number of volume envelope points 98 | unsigned char numPanPoints; // number of panning env. points 99 | unsigned char volSustain; // volume sustain point 100 | unsigned char volLoopStart; // volume loop start point 101 | unsigned char volLoopEnd; // volume loop end point 102 | unsigned char panSustain; // panning sustain point 103 | unsigned char panLoopStart; // panning loop start point 104 | unsigned char panLoopEnd; // panning loop end point 105 | unsigned char volEnvFlags; // volume envelope flags 106 | unsigned char panEnvFlags; // panning envelope flags 107 | 108 | unsigned char vibType; // vibrato type 109 | unsigned char vibSweep; // vibrato sweep 110 | unsigned char vibDepth; // vibrato depth 111 | unsigned char vibRate; // vibrato rate 112 | unsigned short volFadeout; // volume fadeout 113 | unsigned short reserved; 114 | } FMUSIC_XM_INSTSAMPLEHEADER; 115 | 116 | 117 | signed char FMUSIC_LoadXM(FMUSIC_MODULE *mod,FSOUND_FILE_HANDLE *fp); 118 | 119 | #endif -------------------------------------------------------------------------------- /MiniFMOD/lib/system_file.h: -------------------------------------------------------------------------------- 1 | /******************************************************************************/ 2 | /* SYSTEM_FILE.H */ 3 | /* ---------------- */ 4 | /* MiniFMOD public source code release. */ 5 | /* This source is provided as-is. Firelight Technologies will not support */ 6 | /* or answer questions about the source provided. */ 7 | /* MiniFMOD Sourcecode is copyright (c) Firelight Technologies, 2000-2004. */ 8 | /* MiniFMOD Sourcecode is in no way representative of FMOD 3 source. */ 9 | /* Firelight Technologies is a registered company. */ 10 | /* This source must not be redistributed without this notice. */ 11 | /******************************************************************************/ 12 | 13 | #ifndef _SYSTEM_FILE_H_ 14 | #define _SYSTEM_FILE_H_ 15 | 16 | typedef struct tag_FSOUND_FILE_HANDLE 17 | { 18 | signed char type; 19 | void *fp; 20 | signed char *mem; 21 | int basepos; 22 | void *userhandle; 23 | int length; 24 | } FSOUND_FILE_HANDLE; 25 | 26 | FSOUND_FILE_HANDLE *FSOUND_File_Open(void *data,signed char type,int length); 27 | void FSOUND_File_Close(FSOUND_FILE_HANDLE *handle); 28 | int FSOUND_File_Read(void *buffer,int size,FSOUND_FILE_HANDLE *handle); 29 | void FSOUND_File_Seek(FSOUND_FILE_HANDLE *handle,int pos,signed char mode); 30 | int FSOUND_File_Tell(FSOUND_FILE_HANDLE *handle); 31 | 32 | extern void *(*FSOUND_File_OpenCallback)(char *name); 33 | extern void (*FSOUND_File_CloseCallback)(void *handle); 34 | extern int (*FSOUND_File_ReadCallback)(void *buffer,int size,void *handle); 35 | extern void (*FSOUND_File_SeekCallback)(void *handle,int pos,signed char mode); 36 | extern int (*FSOUND_File_TellCallback)(void *handle); 37 | 38 | #endif -------------------------------------------------------------------------------- /MiniFMOD/lib/system_memory.h: -------------------------------------------------------------------------------- 1 | /******************************************************************************/ 2 | /* SYSTEM_MEMORY.H */ 3 | /* ---------------- */ 4 | /* MiniFMOD public source code release. */ 5 | /* This source is provided as-is. Firelight Technologies will not support */ 6 | /* or answer questions about the source provided. */ 7 | /* MiniFMOD Sourcecode is copyright (c) Firelight Technologies, 2000-2004. */ 8 | /* MiniFMOD Sourcecode is in no way representative of FMOD 3 source. */ 9 | /* Firelight Technologies is a registered company. */ 10 | /* This source must not be redistributed without this notice. */ 11 | /******************************************************************************/ 12 | 13 | #ifndef _SYSTEM_MEMORY_H_ 14 | #define _SYSTEM_MEMORY_H_ 15 | 16 | // include your system's header here 17 | #include 18 | 19 | // redefine here 20 | #define FSOUND_Memory_Free(_ptr) free(_ptr) 21 | #define FSOUND_Memory_Alloc(_len) calloc(_len,1) 22 | #define FSOUND_Memory_Calloc(_len) calloc(_len,1) 23 | #define FSOUND_Memory_Realloc(_ptr,_len) realloc(_ptr,_len) 24 | 25 | #endif 26 | -------------------------------------------------------------------------------- /MiniFMOD/lib/xmeffects.h: -------------------------------------------------------------------------------- 1 | // ============================================================================= 2 | // XM Effect header generated by FEXP.EXE, Copyright (c) Firelight Technologies, 2000-2004. 3 | // ============================================================================= 4 | 5 | // Generated for urk7.xm 6 | 7 | #ifndef _XMEFFECTS_H 8 | #define _XMEFFECTS_H 9 | 10 | #ifdef FMUSIC_ALL_ACTIVE 11 | 12 | #define FMUSIC_XM_INSTRUMENTVIBRATO_ACTIVE 13 | #define FMUSIC_XM_VOLUMEENVELOPE_ACTIVE 14 | #define FMUSIC_XM_PANENVELOPE_ACTIVE 15 | #define FMUSIC_XM_VOLUMEBYTE_ACTIVE 16 | #define FMUSIC_XM_AMIGAPERIODS_ACTIVE 17 | #define FMUSIC_XM_TREMOLO_ACTIVE 18 | #define FMUSIC_XM_TREMOR_ACTIVE 19 | #define FMUSIC_XM_ARPEGGIO_ACTIVE 20 | #define FMUSIC_XM_PORTATO_ACTIVE 21 | #define FMUSIC_XM_PORTAUP_ACTIVE 22 | #define FMUSIC_XM_PORTADOWN_ACTIVE 23 | #define FMUSIC_XM_PORTATOVOLSLIDE_ACTIVE 24 | #define FMUSIC_XM_VIBRATO_ACTIVE 25 | #define FMUSIC_XM_VIBRATOVOLSLIDE_ACTIVE 26 | #define FMUSIC_XM_SETPANPOSITION_ACTIVE 27 | #define FMUSIC_XM_SETSAMPLEOFFSET_ACTIVE 28 | #define FMUSIC_XM_VOLUMESLIDE_ACTIVE 29 | #define FMUSIC_XM_PATTERNJUMP_ACTIVE 30 | #define FMUSIC_XM_SETVOLUME_ACTIVE 31 | #define FMUSIC_XM_PATTERNBREAK_ACTIVE 32 | #define FMUSIC_XM_FINEPORTAUP_ACTIVE 33 | #define FMUSIC_XM_FINEPORTADOWN_ACTIVE 34 | #define FMUSIC_XM_SETVIBRATOWAVE_ACTIVE 35 | #define FMUSIC_XM_SETFINETUNE_ACTIVE 36 | #define FMUSIC_XM_PATTERNLOOP_ACTIVE 37 | #define FMUSIC_XM_SETTREMOLOWAVE_ACTIVE 38 | #define FMUSIC_XM_SETPANPOSITION16_ACTIVE 39 | #define FMUSIC_XM_RETRIG_ACTIVE 40 | #define FMUSIC_XM_FINEVOLUMESLIDEUP_ACTIVE 41 | #define FMUSIC_XM_FINEVOLUMESLIDEDOWN_ACTIVE 42 | #define FMUSIC_XM_NOTECUT_ACTIVE 43 | #define FMUSIC_XM_NOTEDELAY_ACTIVE 44 | #define FMUSIC_XM_PATTERNDELAY_ACTIVE 45 | #define FMUSIC_XM_SETSPEED_ACTIVE 46 | #define FMUSIC_XM_SETGLOBALVOLUME_ACTIVE 47 | #define FMUSIC_XM_GLOBALVOLSLIDE_ACTIVE 48 | #define FMUSIC_XM_KEYOFF_ACTIVE 49 | #define FMUSIC_XM_SETENVELOPEPOS_ACTIVE 50 | #define FMUSIC_XM_PANSLIDE_ACTIVE 51 | #define FMUSIC_XM_MULTIRETRIG_ACTIVE 52 | #define FMUSIC_XM_EXTRAFINEPORTA_ACTIVE 53 | 54 | #else // FMUSIC_ALL_ACTIVE 55 | 56 | #define FMUSIC_XM_INSTRUMENTVIBRATO_ACTIVE 57 | #define FMUSIC_XM_VOLUMEENVELOPE_ACTIVE 58 | #define FMUSIC_XM_PANENVELOPE_ACTIVE 59 | #define FMUSIC_XM_VOLUMEBYTE_ACTIVE 60 | #define FMUSIC_XM_AMIGAPERIODS_ACTIVE 61 | #define FMUSIC_XM_TREMOLO_ACTIVE 62 | #define FMUSIC_XM_TREMOR_ACTIVE 63 | #define FMUSIC_XM_ARPEGGIO_ACTIVE 64 | #define FMUSIC_XM_PORTATO_ACTIVE 65 | #define FMUSIC_XM_PORTAUP_ACTIVE 66 | #define FMUSIC_XM_PORTADOWN_ACTIVE 67 | #define FMUSIC_XM_PORTATOVOLSLIDE_ACTIVE 68 | #define FMUSIC_XM_VIBRATO_ACTIVE 69 | #define FMUSIC_XM_VIBRATOVOLSLIDE_ACTIVE 70 | #define FMUSIC_XM_SETPANPOSITION_ACTIVE 71 | #define FMUSIC_XM_SETSAMPLEOFFSET_ACTIVE 72 | #define FMUSIC_XM_VOLUMESLIDE_ACTIVE 73 | #define FMUSIC_XM_PATTERNJUMP_ACTIVE 74 | #define FMUSIC_XM_SETVOLUME_ACTIVE 75 | #define FMUSIC_XM_PATTERNBREAK_ACTIVE 76 | #define FMUSIC_XM_FINEPORTAUP_ACTIVE 77 | #define FMUSIC_XM_FINEPORTADOWN_ACTIVE 78 | #define FMUSIC_XM_SETVIBRATOWAVE_ACTIVE 79 | #define FMUSIC_XM_SETFINETUNE_ACTIVE 80 | #define FMUSIC_XM_PATTERNLOOP_ACTIVE 81 | #define FMUSIC_XM_SETTREMOLOWAVE_ACTIVE 82 | #define FMUSIC_XM_SETPANPOSITION16_ACTIVE 83 | #define FMUSIC_XM_RETRIG_ACTIVE 84 | #define FMUSIC_XM_FINEVOLUMESLIDEUP_ACTIVE 85 | #define FMUSIC_XM_FINEVOLUMESLIDEDOWN_ACTIVE 86 | #define FMUSIC_XM_NOTECUT_ACTIVE 87 | #define FMUSIC_XM_NOTEDELAY_ACTIVE 88 | #define FMUSIC_XM_PATTERNDELAY_ACTIVE 89 | #define FMUSIC_XM_SETSPEED_ACTIVE 90 | #define FMUSIC_XM_SETGLOBALVOLUME_ACTIVE 91 | #define FMUSIC_XM_GLOBALVOLSLIDE_ACTIVE 92 | #define FMUSIC_XM_KEYOFF_ACTIVE 93 | #define FMUSIC_XM_SETENVELOPEPOS_ACTIVE 94 | #define FMUSIC_XM_PANSLIDE_ACTIVE 95 | #define FMUSIC_XM_MULTIRETRIG_ACTIVE 96 | #define FMUSIC_XM_EXTRAFINEPORTA_ACTIVE 97 | 98 | #endif // FMUSIC_ALL_ACTIVE 99 | 100 | #endif -------------------------------------------------------------------------------- /MiniFMOD/minifmod.h: -------------------------------------------------------------------------------- 1 | /******************************************************************************/ 2 | /* MINIFMOD.H */ 3 | /* ---------------- */ 4 | /* MiniFMOD public source code release. */ 5 | /* This source is provided as-is. Firelight Technologies will not support */ 6 | /* or answer questions about the source provided. */ 7 | /* MiniFMOD Sourcecode is copyright (c) Firelight Technologies, 2000-2004. */ 8 | /* MiniFMOD Sourcecode is in no way representative of FMOD 3 source. */ 9 | /* Firelight Technologies is a registered company name. */ 10 | /* This source must not be redistributed without this notice. */ 11 | /******************************************************************************/ 12 | 13 | //========================================================================================== 14 | // MINIFMOD Main header file. Copyright (c), Firelight Technologies, 2000-2004. 15 | // Based on FMOD, copyright (c), Firelight Technologies, 2000-2004. 16 | //========================================================================================== 17 | 18 | #ifndef _MINIFMOD_H_ 19 | #define _MINIFMOD_H_ 20 | 21 | //=============================================================================================== 22 | //= DEFINITIONS 23 | //=============================================================================================== 24 | 25 | // fmod defined types 26 | typedef struct FMUSIC_MODULE FMUSIC_MODULE; 27 | 28 | //=============================================================================================== 29 | //= FUNCTION PROTOTYPES 30 | //=============================================================================================== 31 | 32 | #ifdef __cplusplus 33 | extern "C" { 34 | #endif 35 | 36 | // ================================== 37 | // Initialization / Global functions. 38 | // ================================== 39 | typedef void (*SAMPLELOADCALLBACK)(void *buff, int lenbytes, int numbits, int instno, int sampno); 40 | typedef void (*FMUSIC_CALLBACK)(FMUSIC_MODULE *mod, unsigned char param); 41 | 42 | // this must be called before FSOUND_Init! 43 | void FSOUND_File_SetCallbacks(void *(*OpenCallback)(char *name), 44 | void (*CloseCallback)(void *handle), 45 | int (*ReadCallback)(void *buffer, int size, void *handle), 46 | void (*SeekCallback)(void *handle, int pos, signed char mode), 47 | int (*TellCallback)(void *handle)); 48 | 49 | // ============================================================================================= 50 | // FMUSIC API 51 | // ============================================================================================= 52 | 53 | // Song management / playback functions. 54 | // ===================================== 55 | 56 | FMUSIC_MODULE * FMUSIC_LoadSong(char *data, SAMPLELOADCALLBACK sampleloadcallback); 57 | signed char FMUSIC_FreeSong(FMUSIC_MODULE *mod); 58 | signed char FMUSIC_PlaySong(FMUSIC_MODULE *mod); 59 | signed char FMUSIC_StopSong(FMUSIC_MODULE *mod); 60 | 61 | // Runtime song information. 62 | // ========================= 63 | 64 | int FMUSIC_GetOrder(FMUSIC_MODULE *mod); 65 | int FMUSIC_GetRow(FMUSIC_MODULE *mod); 66 | unsigned int FMUSIC_GetTime(FMUSIC_MODULE *mod); 67 | 68 | #ifdef __cplusplus 69 | } 70 | #endif 71 | 72 | #endif 73 | -------------------------------------------------------------------------------- /MiniFMOD/minifmod.sln: -------------------------------------------------------------------------------- 1 |  2 | Microsoft Visual Studio Solution File, Format Version 10.00 3 | # Visual Studio 2008 4 | Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "minifmod", "minifmod.vcproj", "{8C82D9EC-C857-4C7B-AC25-63C6A6251382}" 5 | EndProject 6 | Global 7 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 8 | Release|Win32 = Release|Win32 9 | Release|x64 = Release|x64 10 | EndGlobalSection 11 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 12 | {8C82D9EC-C857-4C7B-AC25-63C6A6251382}.Release|Win32.ActiveCfg = Release|Win32 13 | {8C82D9EC-C857-4C7B-AC25-63C6A6251382}.Release|Win32.Build.0 = Release|Win32 14 | {8C82D9EC-C857-4C7B-AC25-63C6A6251382}.Release|x64.ActiveCfg = Release|x64 15 | {8C82D9EC-C857-4C7B-AC25-63C6A6251382}.Release|x64.Build.0 = Release|x64 16 | EndGlobalSection 17 | GlobalSection(SolutionProperties) = preSolution 18 | HideSolutionNode = FALSE 19 | EndGlobalSection 20 | EndGlobal 21 | -------------------------------------------------------------------------------- /MiniFMOD/mixer/include32.inc: -------------------------------------------------------------------------------- 1 | FSOUND_OUTPUTBUFF_END EQU 0 2 | FSOUND_MIXDIR_FORWARDS EQU 1 3 | FSOUND_SAMPLEBUFF_END EQU 1 4 | FSOUND_MIXDIR_BACKWARDS EQU 2 5 | FSOUND_LOOP_NORMAL EQU 2 6 | FSOUND_LOOP_BIDI EQU 4 7 | 8 | FSOUND_SAMPLE STRUCT 4 9 | buff DD ? 10 | 11 | blength DD ? 12 | loopstart DD ? 13 | looplen DD ? 14 | defvol DB ? 15 | finetune DB ? 16 | 17 | deffreq DD ? 18 | defpan DD ? 19 | 20 | bits DB ? 21 | loopmode DB ? 22 | 23 | globalvol DB ? 24 | relative DB ? 25 | middlec DD ? 26 | susloopbegin DD ? 27 | susloopend DD ? 28 | vibspeed DB ? 29 | vibdepth DB ? 30 | vibtype DB ? 31 | vibrate DB ? 32 | FSOUND_SAMPLE ENDS 33 | 34 | FSOUND_CHANNEL STRUCT 4 35 | index DD ? 36 | volume DD ? 37 | frequency DD ? 38 | pan DD ? 39 | actualvolume DD ? 40 | actualpan DD ? 41 | sampleoffset DD ? 42 | 43 | sptr DD ? 44 | 45 | leftvolume DD ? 46 | rightvolume DD ? 47 | mixpos DD ? 48 | mixposlo DD ? 49 | speedlo DD ? 50 | speedhi DD ? 51 | speeddir DD ? 52 | 53 | ramp_lefttarget DD ? 54 | ramp_righttarget DD ? 55 | ramp_leftvolume DD ? 56 | ramp_rightvolume DD ? 57 | ramp_leftspeed DD ? 58 | ramp_rightspeed DD ? 59 | ramp_count DD ? 60 | FSOUND_CHANNEL ENDS -------------------------------------------------------------------------------- /MiniFMOD/mixer/include64.inc: -------------------------------------------------------------------------------- 1 | FSOUND_OUTPUTBUFF_END EQU 0 2 | FSOUND_MIXDIR_FORWARDS EQU 1 3 | FSOUND_SAMPLEBUFF_END EQU 1 4 | FSOUND_MIXDIR_BACKWARDS EQU 2 5 | FSOUND_LOOP_NORMAL EQU 2 6 | FSOUND_LOOP_BIDI EQU 4 7 | 8 | FSOUND_SAMPLE STRUCT 8 9 | buff DQ ? 10 | 11 | blength DD ? 12 | loopstart DD ? 13 | looplen DD ? 14 | defvol DB ? 15 | finetune DB ? 16 | 17 | deffreq DD ? 18 | defpan DD ? 19 | 20 | bits DB ? 21 | loopmode DB ? 22 | 23 | globalvol DB ? 24 | relative DB ? 25 | middlec DD ? 26 | susloopbegin DD ? 27 | susloopend DD ? 28 | vibspeed DB ? 29 | vibdepth DB ? 30 | vibtype DB ? 31 | vibrate DB ? 32 | FSOUND_SAMPLE ENDS 33 | 34 | FSOUND_CHANNEL STRUCT 8 35 | index DD ? 36 | volume DD ? 37 | frequency DD ? 38 | pan DD ? 39 | actualvolume DD ? 40 | actualpan DD ? 41 | sampleoffset DD ? 42 | 43 | sptr DQ ? 44 | 45 | leftvolume DD ? 46 | rightvolume DD ? 47 | mixpos DD ? 48 | mixposlo DD ? 49 | speedlo DD ? 50 | speedhi DD ? 51 | speeddir DD ? 52 | 53 | ramp_lefttarget DD ? 54 | ramp_righttarget DD ? 55 | ramp_leftvolume DD ? 56 | ramp_rightvolume DD ? 57 | ramp_leftspeed DD ? 58 | ramp_rightspeed DD ? 59 | ramp_count DD ? 60 | FSOUND_CHANNEL ENDS -------------------------------------------------------------------------------- /MiniFMOD/mixer/make32.bat: -------------------------------------------------------------------------------- 1 | ml.exe /c /coff /Foasm32.obj mixer32.asm -------------------------------------------------------------------------------- /MiniFMOD/mixer/make64.bat: -------------------------------------------------------------------------------- 1 | ml64.exe /c /Foasm64.obj mixer64.asm -------------------------------------------------------------------------------- /Modules.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include"PEFile.h" 3 | 4 | class CExportFunction 5 | { 6 | public: 7 | std::string sFuncName; 8 | WORD wFuncOrdinal; 9 | DWORD dwFuncAddress; 10 | DWORD dwFuncAddressHook; 11 | 12 | CExportFunction():sFuncName(""),wFuncOrdinal(0),dwFuncAddress(0),dwFuncAddressHook(MAXDWORD) {} 13 | }; 14 | 15 | struct SCHEMA_LIBRARY 16 | { 17 | TSTRING sSchemaName; 18 | TSTRING sRealName; 19 | }; 20 | 21 | struct FORWARDED_FUNC 22 | { 23 | TSTRING sToLib; 24 | std::string sToName; 25 | WORD wToOrdinal; 26 | 27 | TSTRING sFromLib; 28 | std::string sFromName; 29 | WORD wFromOrdinal; 30 | }; 31 | 32 | class CModule 33 | { 34 | friend class CModules; 35 | friend class CTracer; 36 | friend class CMain; 37 | friend class CDlgEditImport; 38 | friend class CDlgAttach; 39 | friend class CDlgMain; 40 | 41 | HANDLE hVictim; 42 | 43 | DWORD dwOffsetToPe; 44 | 45 | std::vector Exports; 46 | public: 47 | TSTRING sModuleName,sFullName,sImportName; 48 | CPEFile ModuleFile; 49 | 50 | CModule(HANDLE n_hVictim,DWORD_PTR n_ModuleBase,const TCHAR *szModuleName, 51 | const TCHAR *szFullName,const TCHAR *szImportName); 52 | CModule &operator=(const CModule &other); 53 | void AddForwarded(); 54 | 55 | DWORD_PTR ModuleBase; 56 | DWORD dwModuleSize; 57 | DWORD_PTR HookBase; 58 | DWORD dwHookSize; 59 | 60 | void HookExport(); 61 | void UnHookExport(); 62 | void FreeMemory(); 63 | bool TestVictim(); 64 | }; 65 | 66 | class CModules 67 | { 68 | public: 69 | CModules(); 70 | ~CModules(); 71 | 72 | std::vector Modules; 73 | std::vector UnhookModules; 74 | std::vector UnhookedBreaks; 75 | DWORD_PTR VictimBase; 76 | DWORD_PTR TrampolineBase; 77 | CPEFile *pVictimFile; 78 | HANDLE hVictim; 79 | bool fHookedImport; 80 | BOOL fUnhookInAction; 81 | 82 | void Clear(); 83 | void AddModule(DWORD_PTR ModuleBase,bool fAddForwarded); 84 | void Reload(DWORD_PTR n_VictimBase,CPEFile *n_pVictimFile,HANDLE n_hVictim); 85 | 86 | void HookExport(); 87 | void UnHookExport(); 88 | void HookImport(); 89 | void SetUnhookedBreaksBack(); 90 | 91 | DWORD_PTR GetModHandle(const TCHAR *szModuleName) const; 92 | DWORD_PTR GetProcedureAddr(const TCHAR *szModuleName,const char *szFuncName,WORD wFuncOrdinal,bool fAddressHook) const; 93 | 94 | void IdentifyFunction(CImportRecord &ImportRecord,DWORD_PTR FuncAddress) const; 95 | bool IdentifyFunctionPrev(CImportRecord &ImportRecord) const; 96 | bool IdentifyFunctionNext(CImportRecord &ImportRecord) const; 97 | bool ForwardedPrev(CImportRecord &ImportRecord,DWORD dwCount) const; 98 | bool ForwardedNext(CImportRecord &ImportRecord,DWORD dwCount) const; 99 | }; -------------------------------------------------------------------------------- /PEFile.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | enum EImportRecordType {itNone,itIndirectJmp,itIndirectCall,itIndirectOther,itDirectJmp,itDirectCall,itDirectOther,itIndirectAx}; 4 | enum ESortImportType {siByName,siByRecord,siByReference}; 5 | enum ECutSectionsType {csNone,csSimple,csMemoryManager}; 6 | 7 | class CImportRecord 8 | { 9 | public: 10 | TSTRING sLibName; 11 | std::string sApiName; 12 | WORD wOrdinal; 13 | 14 | DWORD dwReferenceRVA; 15 | DWORD dwRecordRVA; 16 | DWORD_PTR NameRVA; 17 | 18 | EImportRecordType Type; 19 | 20 | int nLib,nApi,nTrampoline; 21 | 22 | CImportRecord(); 23 | CImportRecord(const TCHAR *szLibName,const char *szApiName,DWORD n_dwReferenceRVA,DWORD n_dwRecordRVA,EImportRecordType n_Type); 24 | CImportRecord(const TCHAR *szLibName,WORD n_wOrdinal,DWORD n_dwReferenceRVA,DWORD n_dwRecordRVA,EImportRecordType n_Type); 25 | 26 | void Clear(); 27 | 28 | bool Exist() const {return !sLibName.empty();}; 29 | bool IsDirectRef() const {return Type==itDirectJmp || Type==itDirectCall || Type==itDirectOther;}; 30 | }; 31 | 32 | class CImport 33 | { 34 | friend class CDlgImport; 35 | friend class CPEFile; 36 | friend class CTracer; 37 | friend class CMain; 38 | 39 | ESortImportType CurrentSort; 40 | std::vector Records; 41 | 42 | bool CheckOldIAT(const CPEFile &File,DWORD *pLibsNumber); 43 | void SaveToIAT(CPEFile &File,DWORD dwImportRVA); 44 | public: 45 | void Clear(); 46 | void AddRecord(const CImportRecord &ImportRecord); 47 | void ReadFromFile(const CPEFile &File); 48 | void SortRecords(ESortImportType SortType); 49 | void RedirectToOldIAT(bool fRedirectToEmpty,DWORD *pLibsNumber,DWORD *pDirectRefs); 50 | void SaveToFile(CPEFile &File,DWORD dwImportRVA); 51 | }; 52 | 53 | class CFixUp 54 | { 55 | public: 56 | struct RELOCATION 57 | { 58 | DWORD dwRVA; 59 | DWORD dwType; 60 | }; 61 | std::vector Items; 62 | 63 | void Clear(); 64 | 65 | void AddItem(DWORD dwRVA,DWORD dwType); 66 | int Compare(DWORD dwRVA) const; 67 | 68 | void ReadFromFile(const CPEFile &File); 69 | void SaveToFile(CPEFile &File); 70 | 71 | void ProcessToFile(CPEFile &File,DWORD dwDelta) const; 72 | }; 73 | 74 | class CTLS 75 | { 76 | friend CPEFile; 77 | 78 | std::vector bTLSSection; 79 | public: 80 | void Clear(); 81 | 82 | void ReadFromFile(const CPEFile &File); 83 | void SaveToFile(CPEFile &File,bool fSaveCallbacks) const; 84 | DWORD_PTR GetFirstCallback() const; 85 | }; 86 | 87 | class CExport 88 | { 89 | public: 90 | class CExportFunc 91 | { 92 | public: 93 | std::string sFuncName; 94 | WORD wFuncOrdinal; 95 | DWORD dwFuncAddress; 96 | std::string sForwardedName; 97 | 98 | CExportFunc():sFuncName(""),wFuncOrdinal(0),dwFuncAddress(0),sForwardedName("") {} 99 | }; 100 | private: 101 | IMAGE_EXPORT_DIRECTORY ExpHeader; 102 | std::string sExportName; 103 | std::vector Exports; 104 | public: 105 | void Clear(); 106 | 107 | void ReadFromFile(const CPEFile &File); 108 | void SaveToFile(CPEFile &File); 109 | }; 110 | 111 | class CPEFile 112 | { 113 | public: 114 | IMAGE_DOS_HEADER *pMZHeader; 115 | IMAGE_NT_HEADERS *pPEHeader; 116 | IMAGE_SECTION_HEADER *pSectionHeader; 117 | 118 | std::vector bOverlay; 119 | 120 | DWORD dwSectionsBegin; 121 | DWORD dwSectionsSize; 122 | private: 123 | std::vector bHeader; 124 | BYTE *bSections[MAX_SECTIONS]; 125 | 126 | void AddResourceDelta(DWORD dwDirRVA,DWORD dwResourceBase,DWORD dwResHeadersSize); 127 | void AlignRes(std::vector &bRes,DWORD dwAlignment); 128 | bool AddRes(std::vector &bRes,DWORD dwRVA,DWORD dwSize); 129 | DWORD AddResource(std::vector &bRes,DWORD dwRVA,DWORD dwSize); 130 | DWORD RipResources(DWORD dwDirRVA,DWORD dwResourceBase,std::vector &bResHeaders,std::vector &bResources); 131 | 132 | public: 133 | CPEFile(); 134 | ~CPEFile(); 135 | 136 | void Clear(); 137 | void Read(const TCHAR *szFileName); 138 | void Save(const TCHAR *szFileName); 139 | 140 | void Dump(HANDLE hProcess,DWORD_PTR ModuleBase,const CPEFile *pFileOnDisk,ECutSectionsType TruncateSections); 141 | bool IsEmpty() const; 142 | 143 | void CreateEmpty(); 144 | void CreateSection(const char *szName,const BYTE *bBody,DWORD dwSize,DWORD dwchars); 145 | 146 | void SetSectionWritable(DWORD dwRvaInSection); 147 | 148 | void DeleteLastSection(); 149 | void ClearSection(int i); 150 | 151 | int GetSectionNumber(DWORD dwRVA) const; 152 | std::string GetSectionName(DWORD dwRVA) const; 153 | void RenameSection(DWORD dwRVA,const char *szName); 154 | 155 | void ReBuild(); 156 | void ProcessExport(); 157 | void ProcessTLS(); 158 | void ProcessResources(); 159 | void CutSections(); 160 | 161 | void PreserveOverlay(const CPEFile &Source); 162 | void ClearOverlay(); 163 | 164 | BYTE *RVA(DWORD dwRVA) const; 165 | }; 166 | 167 | DWORD_PTR WriteMem(HANDLE hProcess,DWORD_PTR Addr,const void *pBuff,DWORD_PTR Size); 168 | DWORD_PTR ReadMem(HANDLE hProcess,DWORD_PTR Addr,void *pBuff,DWORD_PTR Size); -------------------------------------------------------------------------------- /QUnpack.def: -------------------------------------------------------------------------------- 1 | LIBRARY QUnpack 2 | 3 | EXPORTS UnPack -------------------------------------------------------------------------------- /QUnpack.sln: -------------------------------------------------------------------------------- 1 | Microsoft Visual Studio Solution File, Format Version 10.00 2 | # Visual Studio 2008 3 | Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "QUnpack", "QUnpack.vcproj", "{DC2164DC-4E1C-4EAE-8F42-5BA0FC60F6CB}" 4 | EndProject 5 | Global 6 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 7 | Release DLL Unicode|Win32 = Release DLL Unicode|Win32 8 | Release DLL Unicode|x64 = Release DLL Unicode|x64 9 | Release DLL|Win32 = Release DLL|Win32 10 | Release DLL|x64 = Release DLL|x64 11 | Release EXE Unicode|Win32 = Release EXE Unicode|Win32 12 | Release EXE Unicode|x64 = Release EXE Unicode|x64 13 | Release EXE|Win32 = Release EXE|Win32 14 | Release EXE|x64 = Release EXE|x64 15 | EndGlobalSection 16 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 17 | {DC2164DC-4E1C-4EAE-8F42-5BA0FC60F6CB}.Release DLL Unicode|Win32.ActiveCfg = Release DLL Unicode|Win32 18 | {DC2164DC-4E1C-4EAE-8F42-5BA0FC60F6CB}.Release DLL Unicode|Win32.Build.0 = Release DLL Unicode|Win32 19 | {DC2164DC-4E1C-4EAE-8F42-5BA0FC60F6CB}.Release DLL Unicode|x64.ActiveCfg = Release DLL Unicode|x64 20 | {DC2164DC-4E1C-4EAE-8F42-5BA0FC60F6CB}.Release DLL Unicode|x64.Build.0 = Release DLL Unicode|x64 21 | {DC2164DC-4E1C-4EAE-8F42-5BA0FC60F6CB}.Release DLL|Win32.ActiveCfg = Release DLL|Win32 22 | {DC2164DC-4E1C-4EAE-8F42-5BA0FC60F6CB}.Release DLL|Win32.Build.0 = Release DLL|Win32 23 | {DC2164DC-4E1C-4EAE-8F42-5BA0FC60F6CB}.Release DLL|x64.ActiveCfg = Release DLL|x64 24 | {DC2164DC-4E1C-4EAE-8F42-5BA0FC60F6CB}.Release DLL|x64.Build.0 = Release DLL|x64 25 | {DC2164DC-4E1C-4EAE-8F42-5BA0FC60F6CB}.Release EXE Unicode|Win32.ActiveCfg = Release EXE Unicode|Win32 26 | {DC2164DC-4E1C-4EAE-8F42-5BA0FC60F6CB}.Release EXE Unicode|Win32.Build.0 = Release EXE Unicode|Win32 27 | {DC2164DC-4E1C-4EAE-8F42-5BA0FC60F6CB}.Release EXE Unicode|x64.ActiveCfg = Release EXE Unicode|x64 28 | {DC2164DC-4E1C-4EAE-8F42-5BA0FC60F6CB}.Release EXE Unicode|x64.Build.0 = Release EXE Unicode|x64 29 | {DC2164DC-4E1C-4EAE-8F42-5BA0FC60F6CB}.Release EXE|Win32.ActiveCfg = Release EXE|Win32 30 | {DC2164DC-4E1C-4EAE-8F42-5BA0FC60F6CB}.Release EXE|Win32.Build.0 = Release EXE|Win32 31 | {DC2164DC-4E1C-4EAE-8F42-5BA0FC60F6CB}.Release EXE|x64.ActiveCfg = Release EXE|x64 32 | {DC2164DC-4E1C-4EAE-8F42-5BA0FC60F6CB}.Release EXE|x64.Build.0 = Release EXE|x64 33 | EndGlobalSection 34 | GlobalSection(SolutionProperties) = preSolution 35 | HideSolutionNode = FALSE 36 | EndGlobalSection 37 | EndGlobal 38 | -------------------------------------------------------------------------------- /RegistryKey.cpp: -------------------------------------------------------------------------------- 1 | #include "stdafx.h" 2 | #include "RegistryKey.h" 3 | 4 | const TCHAR CMD_LINE_QU_ARG[]=_T(" \"%1\""); 5 | const TCHAR *const szShellRegisterExt[]= 6 | { 7 | _T("dllfile"), 8 | _T("exefile"), 9 | _T("ocxfile"), 10 | _T("scrfile"), 11 | }; 12 | 13 | void CRegistryKey::RegisterShellExt() const 14 | { 15 | LONG lRes; 16 | HKEY hKey[_countof(szShellRegisterExt)]; 17 | 18 | for(int i=0;i!=_countof(szShellRegisterExt);++i) 19 | { 20 | CString sName=szShellRegisterExt[i]; 21 | sName=sName+_T("\\shell\\")+_T("Unpack with QuickUnpack")+_T("\\command"); 22 | lRes=RegCreateKey(HKEY_CLASSES_ROOT,sName.GetBuffer(),&hKey[i]); 23 | if(lRes==ERROR_SUCCESS) 24 | { 25 | TCHAR szPath[MAX_PATH]; 26 | GetModuleFileName(NULL,szPath,_countof(szPath)); 27 | _tcscat_s(szPath,CMD_LINE_QU_ARG); 28 | RegSetValue(hKey[i],NULL,REG_SZ,szPath,(DWORD)_tcslen(szPath)+1); 29 | } 30 | else 31 | return; 32 | } 33 | } 34 | 35 | void CRegistryKey::UnRegisterShellExt() const 36 | { 37 | LONG lRes1,lRes2; 38 | for(int i=0;i!=_countof(szShellRegisterExt);++i) 39 | { 40 | CString sName=szShellRegisterExt[i]; 41 | sName=sName+_T("\\shell\\")+_T("Unpack with QuickUnpack")+_T("\\command"); 42 | lRes1=RegDeleteKey(HKEY_CLASSES_ROOT,sName.GetBuffer()); 43 | sName=szShellRegisterExt[i]; 44 | sName=sName+_T("\\shell\\")+_T("Unpack with QuickUnpack"); 45 | lRes2=RegDeleteKey(HKEY_CLASSES_ROOT,sName.GetBuffer()); 46 | if(lRes1!=ERROR_SUCCESS || lRes2!=ERROR_SUCCESS) 47 | return; 48 | } 49 | } 50 | 51 | bool CRegistryKey::IsShellRegisterExt() const 52 | { 53 | LONG lRes; 54 | HKEY hKey[_countof(szShellRegisterExt)]; 55 | for(int i=0;i!=_countof(szShellRegisterExt);++i) 56 | { 57 | CString name=szShellRegisterExt[i]; 58 | name=name+_T("\\shell\\")+_T("Unpack with QuickUnpack"); 59 | lRes=RegOpenKeyEx(HKEY_CLASSES_ROOT,name.GetBuffer(),0,KEY_ALL_ACCESS,&hKey[i]); 60 | if(lRes==ERROR_SUCCESS) 61 | RegCloseKey(hKey[i]); 62 | else 63 | return false; 64 | } 65 | return true; 66 | } 67 | 68 | void CRegistryKey::RegistryWriteStruct(const TCHAR *szKeyName,const TCHAR *szValueName,void *pStruct,DWORD dwSizeStruct) const 69 | { 70 | TCHAR szIniFile[MAX_PATH]={_T('\0')}; 71 | GetModuleFileName(NULL,szIniFile,_countof(szIniFile)); 72 | PathToDir(szIniFile); 73 | _tcscat_s(szIniFile,FILE_LOCATION); 74 | 75 | WritePrivateProfileStruct(szKeyName,szValueName,pStruct,dwSizeStruct,szIniFile); 76 | } 77 | 78 | void CRegistryKey::RegistryReadStruct(const TCHAR *szKeyName,const TCHAR *szValueName,void *pStruct,DWORD dwSizeStruct) const 79 | { 80 | TCHAR szIniFile[MAX_PATH]={_T('\0')}; 81 | GetModuleFileName(NULL,szIniFile,_countof(szIniFile)); 82 | PathToDir(szIniFile); 83 | _tcscat_s(szIniFile,FILE_LOCATION); 84 | 85 | GetPrivateProfileStruct(szKeyName,szValueName,pStruct,dwSizeStruct,szIniFile); 86 | } -------------------------------------------------------------------------------- /RegistryKey.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | class CRegistryKey 4 | { 5 | public: 6 | virtual void RegistryReadStruct(const TCHAR *szKeyName,const TCHAR *szValueName,void *pStruct,DWORD dwSizeStruct) const; 7 | virtual void RegistryWriteStruct(const TCHAR *szKeyName,const TCHAR *szValueName,void *pStruct,DWORD dwSizeStruct) const; 8 | bool IsShellRegisterExt() const; 9 | void UnRegisterShellExt() const; 10 | void RegisterShellExt() const; 11 | }; -------------------------------------------------------------------------------- /SeException.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | class CSeException:public CException 4 | { 5 | DECLARE_DYNAMIC(CSeException) 6 | public: 7 | CSeException(DWORD n_dwSeCode,EXCEPTION_POINTERS *n_pExcPointers); 8 | CSeException(CSeException &CSeExc); 9 | 10 | DWORD GetSeCode() const; 11 | EXCEPTION_POINTERS *GetSePointers() const; 12 | void *GetExceptionAddress() const; 13 | 14 | void Delete(); 15 | void ReportError(DWORD dwType,DWORD dwIDHelp) const; 16 | void GetErrorMessage(CString &sErrDescr,DWORD *pHelpContext) const; 17 | void GetErrorMessage(TCHAR *szError,DWORD dwMaxError,DWORD *pHelpContext) const; 18 | private: 19 | DWORD dwSeCode; 20 | EXCEPTION_POINTERS *pExcPointers; 21 | public: 22 | void FormatStack(CString &sDump) const; 23 | void FormatRegs(CString &sDump) const; 24 | void FormatDump(CString &sDump) const; 25 | DWORD_PTR m_StackTrace[32]; 26 | }; 27 | 28 | void SeTranslator(UINT dwSeCode,EXCEPTION_POINTERS *pExcPointers); -------------------------------------------------------------------------------- /Tracer.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "EngineHandler.h" 4 | #include "PEFile.h" 5 | #include "Modules.h" 6 | 7 | enum EBreakType1 {btOpcode=1,btCC=2,btDr0=3,btDr1=4,btDr2=5,btDr3=6}; 8 | enum EBreakType2 {bt2Execute=0,bt2MemoryWrite=1,bt2MemoryAll=3}; 9 | 10 | class CBreak 11 | { 12 | friend class CTracer; 13 | 14 | EBreakType1 BreakType1; 15 | EBreakType2 BreakType2; 16 | int nEnabled,nExists; 17 | DWORD_PTR Where; 18 | int nSize; 19 | std::vector bOldBytes; 20 | 21 | public: 22 | CBreak(); 23 | }; 24 | 25 | class CDrReg 26 | { 27 | public: 28 | DWORD_PTR Dr[8]; 29 | DWORD_PTR OrigDr[8]; 30 | DWORD dwTID; 31 | bool fTraceFlag; 32 | 33 | CDrReg() {Clear();} 34 | void Clear() { Dr[0]=0; Dr[1]=0; Dr[2]=0; Dr[3]=0; Dr[4]=0; Dr[5]=0; Dr[6]=0; Dr[7]=0; 35 | OrigDr[0]=0; OrigDr[1]=0; OrigDr[2]=0; OrigDr[3]=0; OrigDr[4]=0; OrigDr[5]=0; 36 | OrigDr[6]=0; OrigDr[7]=0; dwTID=0; fTraceFlag=false;} 37 | }; 38 | 39 | class CTracer:public CEngine 40 | { 41 | friend class CDlgImport; 42 | public: 43 | DWORD_PTR bProcessCreated,bOEP,bLoadLibrary,bExceptionDispatcher,bContinue,bGetContextThread, 44 | bSetContextThread,bCreateThread,bCreateThreadEx,bVirtualAlloc,bVirtualFree,bVirtualProtect, 45 | bOpenProcess,bOpenThread,bGetTickCount,bGetTickCount64,bLastSEH; 46 | 47 | TSTRING sVictimName; 48 | CPEFile VictimFile; 49 | 50 | DWORD dwVictimPID; 51 | DWORD_PTR PageLastUsed,PagesAllocked,VictimBase; 52 | PAGE_ENTRY *pPageDir; 53 | HANDLE hVictim; 54 | std::map MemBreaks; 55 | 56 | TSTRING sWorkDir,sOldDir; 57 | 58 | DATA_STATE State,BakState; 59 | 60 | CTracer(const TCHAR *szVictimName,HMODULE hDllHandle); 61 | ~CTracer(); 62 | 63 | DWORD_PTR BreakWhere,FirstVictimBase; 64 | TSTRING sVictimGhostName,sVictimLoaderName; 65 | 66 | DWORD Suspend(); 67 | DWORD Resume(); 68 | void SuspendAllOther(); 69 | void ResumeAllOther(); 70 | 71 | void Attach(); 72 | void Detach(); 73 | void Start(bool fUseGhost,BOOL fStopSystem); 74 | void Terminate(); 75 | 76 | void Continue(); 77 | void Trace(); 78 | void Wait(); 79 | 80 | std::vector Breaks; 81 | bool AddBreak(DWORD_PTR Where,EBreakType1 BreakType1=btOpcode,EBreakType2 BreakType2=bt2Execute); 82 | bool DeleteBreak(DWORD_PTR Where); 83 | void DeleteBreakAll(); 84 | bool EnableBreak(DWORD_PTR Where); 85 | bool DisableBreak(DWORD_PTR Where); 86 | void DisableBreakAll(); 87 | int IsEnabled(DWORD_PTR Where) const; 88 | int IsExist(DWORD_PTR Where) const; 89 | 90 | std::vector DrRegs; 91 | int AddDrReg(DWORD dwTID); 92 | void DeleteDrRegs(); 93 | 94 | bool AddMemoryBreak(DWORD_PTR StartAddr,DWORD Size); 95 | void DeleteMemoryBreaks(); 96 | 97 | DWORD_PTR NextInstr(DWORD_PTR Address); 98 | bool IsThreadDying() const; 99 | 100 | void TraceAndReplace(DWORD_PTR Where); 101 | 102 | DWORD_PTR ReadMem(DWORD_PTR Addr,void *pBuff,DWORD_PTR Size); 103 | DWORD_PTR WriteMem(DWORD_PTR Addr,const void *pBuff,DWORD_PTR Size); 104 | DWORD_PTR GetOrdinalAddress(const TCHAR *szLibName,WORD wOrdinal); 105 | DWORD_PTR GetProcedureAddress(const TCHAR *szLibName,const char *szApiName); 106 | }; -------------------------------------------------------------------------------- /UsarOEP/UsAr.def: -------------------------------------------------------------------------------- 1 | LIBRARY "UsAr" 2 | 3 | EXPORTS 4 | ShortFinderName 5 | GetOEPNow 6 | GetDllOEPNow -------------------------------------------------------------------------------- /UsarOEP/UsAr.sln: -------------------------------------------------------------------------------- 1 |  2 | Microsoft Visual Studio Solution File, Format Version 10.00 3 | # Visual Studio 2008 4 | Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "UsAr", "UsAr.vcproj", "{A1A0748B-B86D-4320-BFD8-E9907AECA847}" 5 | ProjectSection(ProjectDependencies) = postProject 6 | {0028F86E-2E50-42A6-98C3-5E81CE96A90F} = {0028F86E-2E50-42A6-98C3-5E81CE96A90F} 7 | EndProjectSection 8 | EndProject 9 | Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "UsArdll.d11", "UsArdll.d11.vcproj", "{0028F86E-2E50-42A6-98C3-5E81CE96A90F}" 10 | EndProject 11 | Global 12 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 13 | Release Unicode|Win32 = Release Unicode|Win32 14 | Release Unicode|x64 = Release Unicode|x64 15 | Release|Win32 = Release|Win32 16 | Release|x64 = Release|x64 17 | EndGlobalSection 18 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 19 | {A1A0748B-B86D-4320-BFD8-E9907AECA847}.Release Unicode|Win32.ActiveCfg = Release Unicode|Win32 20 | {A1A0748B-B86D-4320-BFD8-E9907AECA847}.Release Unicode|Win32.Build.0 = Release Unicode|Win32 21 | {A1A0748B-B86D-4320-BFD8-E9907AECA847}.Release Unicode|x64.ActiveCfg = Release Unicode|x64 22 | {A1A0748B-B86D-4320-BFD8-E9907AECA847}.Release Unicode|x64.Build.0 = Release Unicode|x64 23 | {A1A0748B-B86D-4320-BFD8-E9907AECA847}.Release|Win32.ActiveCfg = Release|Win32 24 | {A1A0748B-B86D-4320-BFD8-E9907AECA847}.Release|Win32.Build.0 = Release|Win32 25 | {A1A0748B-B86D-4320-BFD8-E9907AECA847}.Release|x64.ActiveCfg = Release|x64 26 | {A1A0748B-B86D-4320-BFD8-E9907AECA847}.Release|x64.Build.0 = Release|x64 27 | {0028F86E-2E50-42A6-98C3-5E81CE96A90F}.Release Unicode|Win32.ActiveCfg = Release Unicode|Win32 28 | {0028F86E-2E50-42A6-98C3-5E81CE96A90F}.Release Unicode|Win32.Build.0 = Release Unicode|Win32 29 | {0028F86E-2E50-42A6-98C3-5E81CE96A90F}.Release Unicode|x64.ActiveCfg = Release Unicode|x64 30 | {0028F86E-2E50-42A6-98C3-5E81CE96A90F}.Release Unicode|x64.Build.0 = Release Unicode|x64 31 | {0028F86E-2E50-42A6-98C3-5E81CE96A90F}.Release|Win32.ActiveCfg = Release|Win32 32 | {0028F86E-2E50-42A6-98C3-5E81CE96A90F}.Release|Win32.Build.0 = Release|Win32 33 | {0028F86E-2E50-42A6-98C3-5E81CE96A90F}.Release|x64.ActiveCfg = Release|x64 34 | {0028F86E-2E50-42A6-98C3-5E81CE96A90F}.Release|x64.Build.0 = Release|x64 35 | EndGlobalSection 36 | GlobalSection(SolutionProperties) = preSolution 37 | HideSolutionNode = FALSE 38 | EndGlobalSection 39 | EndGlobal 40 | -------------------------------------------------------------------------------- /UsarOEP/UsArdll.d11.def: -------------------------------------------------------------------------------- 1 | LIBRARY 2 | 3 | EXPORTS 4 | GetOEPEXE 5 | GetOEPDLL -------------------------------------------------------------------------------- /UsarOEP/resource.h: -------------------------------------------------------------------------------- 1 | //{{NO_DEPENDENCIES}} 2 | // Microsoft Visual C++ generated include file. 3 | // Used by rsrc.rc 4 | // 5 | #define IDD_MAINDLG 101 6 | 7 | #define IDC_STATICCAPTION 1001 8 | #define IDC_OUTPUT 1002 9 | #define IDC_STATICTEXT1 1003 10 | #define IDC_STATICTEXT2 1004 11 | #define IDC_STATICTEXT3 1005 12 | #define IDC_YES 1006 13 | #define IDC_NEXT 1007 14 | #define IDC_ABOUT 1008 15 | #define IDC_OK 1009 16 | #define IDC_STATICABOUT 1010 17 | 18 | // Next default values for new objects 19 | // 20 | #ifdef APSTUDIO_INVOKED 21 | #ifndef APSTUDIO_READONLY_SYMBOLS 22 | #define _APS_NEXT_RESOURCE_VALUE 1 23 | #define _APS_NEXT_SYMED_VALUE 102 24 | #define _APS_NEXT_CONTROL_VALUE 1011 25 | #define _APS_NEXT_COMMAND_VALUE 32768 26 | #endif 27 | #endif 28 | -------------------------------------------------------------------------------- /UsarOEP/rsrc.rc: -------------------------------------------------------------------------------- 1 | // Microsoft Visual C++ generated resource script. 2 | // 3 | #include "resource.h" 4 | 5 | #define APSTUDIO_READONLY_SYMBOLS 6 | ///////////////////////////////////////////////////////////////////////////// 7 | // 8 | // Generated from the TEXTINCLUDE 2 resource. 9 | // 10 | #include "afxres.h" 11 | 12 | ///////////////////////////////////////////////////////////////////////////// 13 | #undef APSTUDIO_READONLY_SYMBOLS 14 | 15 | ///////////////////////////////////////////////////////////////////////////// 16 | // Neutral resources 17 | 18 | #if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_NEU) 19 | #ifdef _WIN32 20 | LANGUAGE LANG_NEUTRAL, SUBLANG_NEUTRAL 21 | #pragma code_page(1251) 22 | #endif //_WIN32 23 | 24 | ///////////////////////////////////////////////////////////////////////////// 25 | // 26 | // Dialog 27 | // 28 | 29 | IDD_MAINDLG DIALOGEX 30, 10, 310, 100 30 | STYLE DS_SETFONT | DS_CENTER | WS_POPUP | WS_VISIBLE | WS_MAXIMIZE 31 | FONT 8, "fixedsys", 700, 0, 0x1 32 | BEGIN 33 | LTEXT " [00] Generic OEP Finder by Archer and UsAr",IDC_STATICCAPTION,0,0,310,8 34 | EDITTEXT IDC_OUTPUT,9,17,292,65,ES_MULTILINE | ES_AUTOVSCROLL | ES_AUTOHSCROLL | ES_READONLY | NOT WS_BORDER | NOT WS_TABSTOP 35 | LTEXT "1",IDC_STATICTEXT1,30,91,5,10 36 | LTEXT "2",IDC_STATICTEXT2,111,91,5,10 37 | LTEXT "3",IDC_STATICTEXT3,192,91,5,10 38 | CONTROL "Yes",IDC_YES,"Button",BS_OWNERDRAW,35,90,74,10 39 | CONTROL "",IDC_NEXT,"Button",BS_OWNERDRAW,116,90,74,10 40 | CONTROL "About",IDC_ABOUT,"Button",BS_OWNERDRAW,197,90,74,10 41 | CONTROL "",IDC_OK,"Button",BS_OWNERDRAW,116,90,74,10 42 | LTEXT "Generic OEP Finder by Archer and UsAr\nBased on Code Injection (no Debug API used)\nCoded in assembly by: UsAr\nPorted to C++ by Archer and LaZzy\n",IDC_STATICABOUT,10,20,290,60 43 | END 44 | 45 | #endif // Neutral resources 46 | ///////////////////////////////////////////////////////////////////////////// 47 | -------------------------------------------------------------------------------- /VersionHelpers.h: -------------------------------------------------------------------------------- 1 | 2 | /****************************************************************** 3 | * * 4 | * VersionHelpers.h -- This module defines helper functions to * 5 | * promote version check with proper * 6 | * comparisons. * 7 | * * 8 | * Copyright (c) Microsoft Corp. All rights reserved. * 9 | * * 10 | ******************************************************************/ 11 | #ifndef _versionhelpers_H_INCLUDED_ 12 | #define _versionhelpers_H_INCLUDED_ 13 | 14 | #pragma once 15 | 16 | #if !defined(__midl) && !defined(SORTPP_PASS) 17 | 18 | #if (NTDDI_VERSION >= NTDDI_WINXP) 19 | 20 | #ifdef __cplusplus 21 | 22 | #define VERSIONHELPERAPI inline bool 23 | 24 | #else // __cplusplus 25 | 26 | #define VERSIONHELPERAPI FORCEINLINE BOOL 27 | 28 | #endif // __cplusplus 29 | 30 | #define _WIN32_WINNT_WINXP 0x0501 31 | #define _WIN32_WINNT_WS03 0x0502 32 | #define _WIN32_WINNT_WIN6 0x0600 33 | #define _WIN32_WINNT_VISTA 0x0600 34 | #define _WIN32_WINNT_WS08 0x0600 35 | #define _WIN32_WINNT_LONGHORN 0x0600 36 | #define _WIN32_WINNT_WIN7 0x0601 37 | #define _WIN32_WINNT_WIN8 0x0602 38 | #define _WIN32_WINNT_WINBLUE 0x0603 39 | #define _WIN32_WINNT_WINTHRESHOLD 0x0A00 /* ABRACADABRA_THRESHOLD*/ 40 | #define _WIN32_WINNT_WIN10 0x0A00 /* ABRACADABRA_THRESHOLD*/ 41 | 42 | VERSIONHELPERAPI 43 | IsWindowsVersionOrGreater(WORD wMajorVersion, WORD wMinorVersion, WORD wServicePackMajor) 44 | { 45 | OSVERSIONINFOEXW osvi = { sizeof(osvi), 0, 0, 0, 0, {0}, 0, 0 }; 46 | DWORDLONG const dwlConditionMask = VerSetConditionMask( 47 | VerSetConditionMask( 48 | VerSetConditionMask( 49 | 0, VER_MAJORVERSION, VER_GREATER_EQUAL), 50 | VER_MINORVERSION, VER_GREATER_EQUAL), 51 | VER_SERVICEPACKMAJOR, VER_GREATER_EQUAL); 52 | 53 | osvi.dwMajorVersion = wMajorVersion; 54 | osvi.dwMinorVersion = wMinorVersion; 55 | osvi.wServicePackMajor = wServicePackMajor; 56 | 57 | return VerifyVersionInfoW(&osvi, VER_MAJORVERSION | VER_MINORVERSION | VER_SERVICEPACKMAJOR, dwlConditionMask) != FALSE; 58 | } 59 | 60 | VERSIONHELPERAPI 61 | IsWindowsXPOrGreater() 62 | { 63 | return IsWindowsVersionOrGreater(HIBYTE(_WIN32_WINNT_WINXP), LOBYTE(_WIN32_WINNT_WINXP), 0); 64 | } 65 | 66 | VERSIONHELPERAPI 67 | IsWindowsXPSP1OrGreater() 68 | { 69 | return IsWindowsVersionOrGreater(HIBYTE(_WIN32_WINNT_WINXP), LOBYTE(_WIN32_WINNT_WINXP), 1); 70 | } 71 | 72 | VERSIONHELPERAPI 73 | IsWindowsXPSP2OrGreater() 74 | { 75 | return IsWindowsVersionOrGreater(HIBYTE(_WIN32_WINNT_WINXP), LOBYTE(_WIN32_WINNT_WINXP), 2); 76 | } 77 | 78 | VERSIONHELPERAPI 79 | IsWindowsXPSP3OrGreater() 80 | { 81 | return IsWindowsVersionOrGreater(HIBYTE(_WIN32_WINNT_WINXP), LOBYTE(_WIN32_WINNT_WINXP), 3); 82 | } 83 | 84 | VERSIONHELPERAPI 85 | IsWindowsVistaOrGreater() 86 | { 87 | return IsWindowsVersionOrGreater(HIBYTE(_WIN32_WINNT_VISTA), LOBYTE(_WIN32_WINNT_VISTA), 0); 88 | } 89 | 90 | VERSIONHELPERAPI 91 | IsWindowsVistaSP1OrGreater() 92 | { 93 | return IsWindowsVersionOrGreater(HIBYTE(_WIN32_WINNT_VISTA), LOBYTE(_WIN32_WINNT_VISTA), 1); 94 | } 95 | 96 | VERSIONHELPERAPI 97 | IsWindowsVistaSP2OrGreater() 98 | { 99 | return IsWindowsVersionOrGreater(HIBYTE(_WIN32_WINNT_VISTA), LOBYTE(_WIN32_WINNT_VISTA), 2); 100 | } 101 | 102 | VERSIONHELPERAPI 103 | IsWindows7OrGreater() 104 | { 105 | return IsWindowsVersionOrGreater(HIBYTE(_WIN32_WINNT_WIN7), LOBYTE(_WIN32_WINNT_WIN7), 0); 106 | } 107 | 108 | VERSIONHELPERAPI 109 | IsWindows7SP1OrGreater() 110 | { 111 | return IsWindowsVersionOrGreater(HIBYTE(_WIN32_WINNT_WIN7), LOBYTE(_WIN32_WINNT_WIN7), 1); 112 | } 113 | 114 | VERSIONHELPERAPI 115 | IsWindows8OrGreater() 116 | { 117 | return IsWindowsVersionOrGreater(HIBYTE(_WIN32_WINNT_WIN8), LOBYTE(_WIN32_WINNT_WIN8), 0); 118 | } 119 | 120 | VERSIONHELPERAPI 121 | IsWindows8Point1OrGreater() 122 | { 123 | return IsWindowsVersionOrGreater(HIBYTE(_WIN32_WINNT_WINBLUE), LOBYTE(_WIN32_WINNT_WINBLUE), 0); 124 | } 125 | 126 | VERSIONHELPERAPI 127 | IsWindowsThresholdOrGreater() 128 | { 129 | return IsWindowsVersionOrGreater(HIBYTE(_WIN32_WINNT_WINTHRESHOLD), LOBYTE(_WIN32_WINNT_WINTHRESHOLD), 0); 130 | } 131 | 132 | VERSIONHELPERAPI 133 | IsWindows10OrGreater() 134 | { 135 | return IsWindowsVersionOrGreater(HIBYTE(_WIN32_WINNT_WINTHRESHOLD), LOBYTE(_WIN32_WINNT_WINTHRESHOLD), 0); 136 | } 137 | 138 | VERSIONHELPERAPI 139 | IsWindowsServer() 140 | { 141 | OSVERSIONINFOEXW osvi = { sizeof(osvi), 0, 0, 0, 0, {0}, 0, 0, 0, VER_NT_WORKSTATION }; 142 | DWORDLONG const dwlConditionMask = VerSetConditionMask( 0, VER_PRODUCT_TYPE, VER_EQUAL ); 143 | 144 | return !VerifyVersionInfoW(&osvi, VER_PRODUCT_TYPE, dwlConditionMask); 145 | } 146 | 147 | 148 | #endif // NTDDI_VERSION 149 | 150 | #endif // defined(__midl) 151 | 152 | #endif // _VERSIONHELPERS_H_INCLUDED_ 153 | -------------------------------------------------------------------------------- /effects/MARQUEE.H: -------------------------------------------------------------------------------- 1 | #define WIN32_LEAN_AND_MEAN // Exclude rarely-used stuff from Windows headers 2 | #include 3 | 4 | void MakeGradient(HDC hdcOn,DWORD gradWidth,DWORD gradHeight,DWORD leftEdge,DWORD rightEdge,DWORD textColor,DWORD toColor); 5 | 6 | DWORD __stdcall MarqueeThread(void*); 7 | void InstallMarquee(); 8 | void KillMarquee(); 9 | void SetParams(HWND sethw,TCHAR *szMText,COLORREF BackCl,COLORREF TextCl,DWORD pTop,DWORD pLeft,DWORD pWid,DWORD pHei); -------------------------------------------------------------------------------- /effects/Marquee.cpp: -------------------------------------------------------------------------------- 1 | // Marquee asm-code by Funbit/TSRh 2 | // C++ conversion by Funbit & FEUERRADER 3 | 4 | #include "stdafx.h" 5 | #include "marquee.h" 6 | 7 | TCHAR *szMarqText; 8 | COLORREF clBackGr; 9 | COLORREF clTextGr; 10 | 11 | HWND mar_hWnd; 12 | HANDLE hThreadMarquee; 13 | 14 | HDC marqmemHDC; 15 | HBITMAP hBitmapMemMarquee; 16 | LOGFONT LogFontMarquee; 17 | HFONT hFontMarquee; 18 | DWORD marqL,marqT,marqW,marqH; 19 | 20 | void MakeGradient(HDC hdcOn,DWORD gradWidth,DWORD gradHeight,DWORD leftEdge,DWORD rightEdge,DWORD textColor,DWORD toColor) 21 | { 22 | BYTE rfactor,gfactor,bfactor,r0,g0,b0,r1,g1,b1; 23 | DWORD xPix,yPix; 24 | BYTE wSide; 25 | DWORD temp1,temp2; 26 | 27 | r0=LOBYTE(toColor); 28 | g0=HIBYTE(toColor); 29 | b0=LOBYTE(toColor>>16); 30 | 31 | r1=LOBYTE(textColor); 32 | g1=HIBYTE(textColor); 33 | b1=LOBYTE(textColor>>16); 34 | 35 | rfactor=(max(r0,r1)-min(r0,r1)) % LOBYTE(gradWidth); 36 | gfactor=(max(g0,g1)-min(g0,g1)) % LOBYTE(gradWidth); 37 | bfactor=(max(b0,b1)-min(b0,b1)) % LOBYTE(gradWidth); 38 | 39 | xPix=0; 40 | yPix=0; 41 | wSide=0; 42 | 43 | for(;;) 44 | { 45 | if(wSide!=0) 46 | temp1=rightEdge+xPix; 47 | else 48 | temp1=leftEdge+xPix; 49 | temp2=GetPixel(hdcOn,temp1,yPix); 50 | if(temp2==textColor) 51 | { 52 | if(LOBYTE(temp2)!=b0) 53 | { 54 | if(wSide==0) 55 | b1=LOBYTE(gradWidth-xPix); 56 | else 57 | b1=LOBYTE(xPix); 58 | b1=b1*bfactor; 59 | if(LOBYTE(temp2)b0) 63 | b1=LOBYTE(temp2)-b1; 64 | temp1=b1; 65 | temp2=temp2>>8; 66 | } 67 | if(LOBYTE(temp2)!=g0) 68 | { 69 | if(wSide==0) 70 | g1=LOBYTE(gradWidth-xPix); 71 | else 72 | g1=LOBYTE(xPix); 73 | g1=g1*gfactor; 74 | if(LOBYTE(temp2)g0) 78 | g1=LOBYTE(temp2)-g1; 79 | temp1=(temp1<<8) | g1; 80 | temp2=temp2>>8; 81 | } 82 | if(LOBYTE(temp2)!=r0) 83 | { 84 | if(wSide==0) 85 | r1=LOBYTE(gradWidth-xPix); 86 | else 87 | r1=LOBYTE(xPix); 88 | r1=r1*rfactor; 89 | if(LOBYTE(temp2)r0) 93 | r1=LOBYTE(temp2)-r1; 94 | temp1=(temp1<<8) | r1; 95 | temp2=temp2>>8; 96 | } 97 | temp2=temp1; 98 | if(wSide==0) 99 | temp1=leftEdge+xPix; 100 | else 101 | temp1=rightEdge+xPix; 102 | SetPixel(hdcOn,temp1,yPix,temp2); 103 | } 104 | wSide^=1; 105 | if(wSide==1) 106 | continue; 107 | ++xPix; 108 | if(xPix!=gradWidth) 109 | continue; 110 | xPix=0; 111 | ++yPix; 112 | if(yPix==gradHeight) 113 | break; 114 | } 115 | } 116 | 117 | DWORD __stdcall MarqueeThread(void*) 118 | { 119 | HDC marqHDC; 120 | HBRUSH hBrushColor; 121 | DWORD x0,x,xMin; 122 | SIZE textSIZE; 123 | RECT tRect; 124 | 125 | x0=250; 126 | 127 | marqHDC=GetDC(mar_hWnd); 128 | 129 | marqmemHDC=CreateCompatibleDC(marqHDC); 130 | hBitmapMemMarquee=CreateCompatibleBitmap(marqHDC,marqW,marqH+10); 131 | SelectObject(marqmemHDC,hBitmapMemMarquee); 132 | LogFontMarquee.lfHeight=-9; 133 | LogFontMarquee.lfQuality=DEFAULT_PITCH; 134 | _tcscpy_s(LogFontMarquee.lfFaceName,_T("Tahoma")); 135 | hFontMarquee=CreateFontIndirect(&LogFontMarquee); 136 | 137 | SelectObject(marqmemHDC,hFontMarquee); 138 | SetTextColor(marqmemHDC,clTextGr); 139 | SetBkColor(marqmemHDC,clBackGr); 140 | SetBkMode(marqmemHDC,OPAQUE); 141 | SetBkMode(marqHDC,OPAQUE); 142 | 143 | GetTextExtentPoint32(marqmemHDC,szMarqText,(int)_tcslen(szMarqText),&textSIZE); 144 | xMin=-textSIZE.cx-100; 145 | x=x0; 146 | 147 | hBrushColor=CreateSolidBrush(clBackGr); 148 | tRect.left=0; 149 | tRect.top=0; 150 | tRect.right=marqW+20; 151 | tRect.bottom=marqH+20; 152 | 153 | for(;;) 154 | { 155 | FillRect(marqmemHDC,&tRect,hBrushColor); 156 | TextOut(marqmemHDC,x,1,szMarqText,(int)_tcslen(szMarqText)); 157 | MakeGradient(marqmemHDC,15,15,0,marqW-15,clTextGr,clBackGr); 158 | BitBlt(marqHDC,marqL,marqT,marqW,marqH,marqmemHDC,0,0,SRCCOPY); 159 | Sleep(20); 160 | 161 | --x; 162 | if(x==xMin) 163 | x=x0; 164 | } 165 | return 0; 166 | } 167 | 168 | void InstallMarquee() 169 | { 170 | hThreadMarquee=CreateThread(NULL,0,MarqueeThread,NULL,0,NULL); 171 | SetThreadPriority(hThreadMarquee,THREAD_PRIORITY_NORMAL); 172 | } 173 | 174 | void KillMarquee() 175 | { 176 | TerminateThread(hThreadMarquee,0); 177 | DeleteDC(marqmemHDC); 178 | DeleteObject(hBitmapMemMarquee); 179 | DeleteObject(hFontMarquee); 180 | } 181 | 182 | void SetParams(HWND sethw,TCHAR *szMText,COLORREF BackCl,COLORREF TextCl,DWORD pTop,DWORD pLeft,DWORD pWid,DWORD pHei) 183 | { 184 | mar_hWnd=sethw; 185 | szMarqText=szMText; 186 | clBackGr=BackCl; 187 | clTextGr=TextCl; 188 | marqL=pLeft; 189 | marqT=pTop; 190 | marqW=pWid; 191 | marqH=pHei; 192 | } -------------------------------------------------------------------------------- /effects/Picture.h: -------------------------------------------------------------------------------- 1 | //----------------------------------------------------------------------------- 2 | // Picture (Prototypes) Version 1.00 3 | // 4 | // Routins 4 Showing Picture Files... (.BMP .DIB .EMF .GIF .ICO .JPG .WMF) 5 | // 6 | // Author: Dr. Yovav Gad, EMail: Sources@SuperMain.com, Web: www.SuperMain.com 7 | //============================================================================= 8 | 9 | #if !defined(AFX_PICTURE_H__COPYFREE_BY_YOVAV_GAD__SOURCES_AT_SUPERMAIN_DOT_COM__INCLUDED_) 10 | #define AFX_PICTURE_H__COPYFREE_BY_YOVAV_GAD__SOURCES_AT_SUPERMAIN_DOT_COM__INCLUDED_ 11 | 12 | #if _MSC_VER > 1000 13 | #pragma once 14 | #endif // _MSC_VER > 1000 15 | 16 | class CPicture 17 | { 18 | public: 19 | void FreePictureData(); 20 | BOOL Load(CString sFilePathName); 21 | BOOL Load(UINT ResourceName,LPCTSTR ResourceType); 22 | BOOL LoadPictureData(BYTE *pBuffer,int nSize); 23 | BOOL SaveAsBitmap(CString sFilePathName); 24 | BOOL Show(CDC *pDC,CPoint LeftTop,CPoint WidthHeight,int MagnifyX,int MagnifyY); 25 | BOOL Show(CDC *pDC,CRect DrawRect); 26 | BOOL ShowBitmapResource(CDC *pDC,const int BMPResource,CPoint LeftTop); 27 | BOOL UpdateSizeOnDC(CDC *pDC); 28 | 29 | CPicture(); 30 | virtual ~CPicture(); 31 | 32 | IPicture *m_IPicture; // Same As LPPICTURE (typedef IPicture __RPC_FAR *LPPICTURE) 33 | 34 | LONG m_Height; // Height (In Pixels Ignor What Current Device Context Uses) 35 | LONG m_Weight; // Size Of The Image Object In Bytes (File OR Resource) 36 | LONG m_Width; // Width (In Pixels Ignor What Current Device Context Uses) 37 | }; 38 | 39 | #endif // !defined(AFX_PICTURE_H__COPYFREE_BY_YOVAV_GAD__SOURCES_AT_SUPERMAIN_DOT_COM__INCLUDED_) 40 | -------------------------------------------------------------------------------- /interface.h: -------------------------------------------------------------------------------- 1 | #ifndef INTERFACE_H 2 | #define INTERFACE_H 3 | 4 | #define ENGINE_VERSION 0x040300 5 | 6 | #define ENGINE_GETVERSION CTL_CODE(FILE_DEVICE_UNKNOWN,0x800,METHOD_BUFFERED,FILE_ANY_ACCESS) 7 | #define ENGINE_INIT CTL_CODE(FILE_DEVICE_UNKNOWN,0x801,METHOD_BUFFERED,FILE_ANY_ACCESS) 8 | #define ENGINE_HOOK CTL_CODE(FILE_DEVICE_UNKNOWN,0x802,METHOD_BUFFERED,FILE_ANY_ACCESS) 9 | #define ENGINE_EMULATE_RDTSC CTL_CODE(FILE_DEVICE_UNKNOWN,0x803,METHOD_BUFFERED,FILE_ANY_ACCESS) 10 | #define ENGINE_EMULATE_CPUID CTL_CODE(FILE_DEVICE_UNKNOWN,0x804,METHOD_BUFFERED,FILE_ANY_ACCESS) 11 | 12 | #define HOOK_NONE 0x00 13 | #define HOOK_HOOK 0x01 14 | #define HOOK_UNHOOK 0x02 15 | 16 | #define STATE_READY 0x00 17 | #define STATE_SINGLESTEP 0x01 18 | #define STATE_BREAK 0x02 19 | #define STATE_BREAKMEM 0x03 20 | #define STATE_BREAKCPUID 0x04 21 | 22 | #define STATE_HANDLED 0x10 23 | #define STATE_UNHANDLED 0x11 24 | 25 | #define STATE_BUSY 0x20 26 | 27 | #pragma pack(push,1) 28 | 29 | typedef struct 30 | { 31 | ULONG Hook; 32 | ULONG Shift; 33 | } RDTSC_HOOK; 34 | 35 | typedef struct 36 | { 37 | ULONG Hook; 38 | } CPUID_HOOK; 39 | 40 | typedef struct 41 | { 42 | ULONG ProcessID; 43 | ULONG Int1; 44 | ULONG Int0d; 45 | ULONG Int0e; 46 | } DATA_HOOK; 47 | 48 | typedef struct 49 | { 50 | ULONG State; 51 | ULONG ThreadID; 52 | 53 | ULONG_PTR RegCr2; 54 | ULONG_PTR RegDr0; 55 | ULONG_PTR RegDr1; 56 | ULONG_PTR RegDr2; 57 | ULONG_PTR RegDr3; 58 | ULONG_PTR RegDr6; 59 | ULONG_PTR RegDr7; 60 | 61 | ULONG_PTR RegIp; 62 | ULONG_PTR RegCS; 63 | ULONG_PTR RegFlags; 64 | ULONG_PTR RegSp; 65 | 66 | ULONG_PTR RegDi; 67 | ULONG_PTR RegSi; 68 | ULONG_PTR RegBp; 69 | #if defined _M_IX86 70 | ULONG_PTR RegSp0; 71 | #endif 72 | ULONG_PTR RegBx; 73 | ULONG_PTR RegDx; 74 | ULONG_PTR RegCx; 75 | ULONG_PTR RegAx; 76 | #if defined _M_AMD64 77 | ULONG_PTR Reg8; 78 | ULONG_PTR Reg9; 79 | ULONG_PTR Reg10; 80 | ULONG_PTR Reg11; 81 | ULONG_PTR Reg12; 82 | ULONG_PTR Reg13; 83 | ULONG_PTR Reg14; 84 | ULONG_PTR Reg15; 85 | #endif 86 | } DATA_STATE; 87 | 88 | #pragma pack(pop) 89 | 90 | #endif //INTERFACE_H -------------------------------------------------------------------------------- /res/32.manifest: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 21 | 22 | 23 | 24 | 25 | 26 | 29 | 30 | 31 | 32 | -------------------------------------------------------------------------------- /res/64.manifest: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 21 | 22 | 23 | 24 | 25 | 26 | 29 | 30 | 31 | 32 | -------------------------------------------------------------------------------- /res/icon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fatrolls/Quick-Unpack/48070723aa80c1f2b6d1c43c345e51c37c1ea5b2/res/icon.ico -------------------------------------------------------------------------------- /res/logo.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fatrolls/Quick-Unpack/48070723aa80c1f2b6d1c43c345e51c37c1ea5b2/res/logo.jpg -------------------------------------------------------------------------------- /res/music.xm: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fatrolls/Quick-Unpack/48070723aa80c1f2b6d1c43c345e51c37c1ea5b2/res/music.xm --------------------------------------------------------------------------------