Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 1 addition & 3 deletions GNUmakefile
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ toolchain_64 := x86_64-w64-mingw32-

gitrev := $(shell git rev-parse HEAD)
cppflags := -I src -I src/main -I src/test -DGITREV=$(gitrev)
cflags := -O2 -pipe -ffunction-sections -fdata-sections \
cflags := -g -O2 -pipe -ffunction-sections -fdata-sections \
-Wall -std=c99 -DPSAPI_VERSION=1
cflags_release := -Werror
ldflags := -Wl,--gc-sections -static-libgcc
Expand Down Expand Up @@ -240,7 +240,6 @@ $$(dll_$1_$2_$3) $$(implib_$1_$2_$3): $$(obj_$1_$2_$3) $$(abslib_$1_$2_$3) \
$(V)$$(toolchain_$1)gcc -shared \
-o $$(dll_$1_$2_$3) -Wl,--out-implib,$$(implib_$1_$2_$3) \
-Wl,--start-group $$^ -Wl,--end-group $$(ldflags_$3)
$(V)$$(toolchain_$1)strip $$(dll_$1_$2_$3)
$(V)$$(toolchain_$1)ranlib $$(implib_$1_$2_$3)

endef
Expand All @@ -257,7 +256,6 @@ $$(exe_$1_$2_$3): $$(obj_$1_$2_$3) $$(abslib_$1_$2_$3) $$(absdpl_$1_$2_$3) \
| $$(bindir_$1_$2)
$(V)echo ... $$@
$(V)$$(toolchain_$1)gcc -o $$@ $$^ $$(ldflags_$3)
$(V)$$(toolchain_$1)strip $$@

endef

Expand Down
8 changes: 8 additions & 0 deletions Module.mk
Original file line number Diff line number Diff line change
Expand Up @@ -257,6 +257,7 @@ $(zipdir)/iidx-09-to-12.zip: \
build/bin/indep-32/iidxio.dll \
build/bin/indep-32/vefxio.dll \
build/bin/indep-32/inject.exe \
dist/dwarfstack/32/dwarfstack.dll \
dist/iidx/config.bat \
dist/iidx/gamestart-09.bat \
dist/iidx/gamestart-10.bat \
Expand All @@ -282,6 +283,7 @@ $(zipdir)/iidx-13.zip: \
build/bin/indep-32/iidxio.dll \
build/bin/indep-32/vefxio.dll \
build/bin/indep-32/inject.exe \
dist/dwarfstack/32/dwarfstack.dll \
dist/iidx/config.bat \
dist/iidx/gamestart-13.bat \
dist/iidx/iidxhook-13.conf \
Expand All @@ -298,6 +300,7 @@ $(zipdir)/iidx-14-to-17.zip: \
build/bin/indep-32/iidxio.dll \
build/bin/indep-32/vefxio.dll \
build/bin/indep-32/inject.exe \
dist/dwarfstack/32/dwarfstack.dll \
dist/iidx/config.bat \
dist/iidx/gamestart-14.bat \
dist/iidx/gamestart-15.bat \
Expand Down Expand Up @@ -485,6 +488,7 @@ $(zipdir)/jb-01.zip: \
build/bin/indep-32/eamio.dll \
build/bin/indep-32/geninput.dll \
build/bin/indep-32/jbio.dll \
dist/dwarfstack/32/dwarfstack.dll \
dist/jb/config.bat \
dist/jb/gamestart-01.bat \
dist/jb/jbhook-01.conf \
Expand All @@ -499,6 +503,7 @@ $(zipdir)/jb-02.zip: \
build/bin/indep-32/eamio.dll \
build/bin/indep-32/geninput.dll \
build/bin/indep-32/jbio.dll \
dist/dwarfstack/32/dwarfstack.dll \
dist/jb/config.bat \
dist/jb/gamestart-02.bat \
dist/jb/jbhook-02.conf \
Expand Down Expand Up @@ -659,6 +664,7 @@ $(zipdir)/ddr-12-us.zip: \
build/bin/indep-32/ddrio-smx.dll \
build/bin/indep-32/eamio.dll \
build/bin/indep-32/geninput.dll \
dist/dwarfstack/32/dwarfstack.dll \
dist/ddr/config.bat \
dist/ddr/gamestart-12-us.bat \
dist/ddr/gamestart-12-eu.bat \
Expand Down Expand Up @@ -776,6 +782,7 @@ $(zipdir)/popn-15-to-18.zip: \
build/bin/indep-32/eamio.dll \
build/bin/indep-32/popnio.dll \
build/bin/indep-32/ezusb2-popn-shim.dll \
dist/dwarfstack/32/dwarfstack.dll \
dist/popn/config.bat \
dist/popn/gamestart-15.bat \
dist/popn/gamestart-16.bat \
Expand Down Expand Up @@ -807,6 +814,7 @@ $(BUILDDIR)/tests.zip: \
build/bin/indep-32/iidxhook-util-config-gfx-test.exe \
build/bin/indep-32/iidxhook-util-config-misc-test.exe \
build/bin/indep-32/iidxhook-util-config-sec-test.exe \
dist/dwarfstack/32/dwarfstack.dll \
build/bin/indep-32/inject.exe \
build/bin/indep-32/security-id-test.exe \
build/bin/indep-32/security-mcode-test.exe \
Expand Down
Binary file added dist/dwarfstack/32/dwarfstack.dll
Binary file not shown.
Binary file added dist/dwarfstack/64/dwarfstack.dll
Binary file not shown.
1 change: 1 addition & 0 deletions dist/dwarfstack/readme.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Version/release: https://github.com/ssbssa/dwarfstack/releases/tag/2.2
162 changes: 162 additions & 0 deletions src/imports/dwarfstack.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,162 @@
/*
* Copyright (C) 2013-2019 Hannes Domani
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/


#ifndef __DWARFSTACK_H__
#define __DWARFSTACK_H__

#include <stdint.h>


#if defined(DWST_STATIC)
#define EXPORT
#elif defined(DWST_SHARED)
#define EXPORT __declspec(dllexport)
#else
#define EXPORT __declspec(dllimport)
#endif


#ifdef __cplusplus
extern "C" {
#endif


// dwstCallback(): callback function
// addr: stack address
// filename: source file location
// lineno: line number
// funcname: function name
// context: user-provided pointer (callbackContext)
// columnno: column number
typedef void dwstCallback(
uint64_t addr,const char *filename,int lineno,const char *funcname,
void *context,int columnno );

typedef void dwstCallbackW(
uint64_t addr,const wchar_t *filename,int lineno,const char *funcname,
void *context,int columnno );

// special values for lineno:

// DWST_BASE_ADDR: inform about the used image base address
// (important in case it's not the same as the preferred image base address)
// addr: used image base address
// filename: executable location
#define DWST_BASE_ADDR 0

// DWST_NO_DBG_SYM: no debug information available
// addr: stack address
// filename: executable location
#define DWST_NO_DBG_SYM -1

// DWST_NO_SRC_FILE: no source file information available
// addr: stack address
// filename: executable location
#define DWST_NO_SRC_FILE -2

// DWST_NOT_FOUND: no information available (invalid address?)
// addr: stack address
// filename: executable location
#define DWST_NOT_FOUND -3


// dwstOfFile(): stack information of file
// name: executable location
// imageBase: used image base address
// addr: stack addresses
// count: number of addresses
// callbackFunc: callback function
// callbackContext: user-provided pointer (context)
// (for example see examples/addr2line/)
EXPORT int dwstOfFile(
const char *name,uint64_t imageBase,
uint64_t *addr,int count,
dwstCallback *callbackFunc,void *callbackContext );

EXPORT int dwstOfFileW(
const wchar_t *name,uint64_t imageBase,
uint64_t *addr,int count,
dwstCallbackW *callbackFunc,void *callbackContext );


// dwstOfProcess(): stack information of current process
// addr: stack addresses
// count: number of addresses
// callbackFunc: callback function
// callbackContext: user-provided pointer (context)
EXPORT int dwstOfProcess(
uintptr_t *addr,int count,
dwstCallback *callbackFunc,void *callbackContext );

EXPORT int dwstOfProcessW(
uintptr_t *addr,int count,
dwstCallbackW *callbackFunc,void *callbackContext );


// dwstOfLocation(): stack information of current location
// callbackFunc: callback function
// callbackContext: user-provided pointer (context)
// (for example see examples/location/)
EXPORT int dwstOfLocation(
dwstCallback *callbackFunc,void *callbackContext );

EXPORT int dwstOfLocationW(
dwstCallbackW *callbackFunc,void *callbackContext );


// dwstOfException(): stack information of exception
// context: ContextRecord of exception
// callbackFunc: callback function
// callbackContext: user-provided pointer (context)
// (for example see examples/exception/)
EXPORT int dwstOfException(
void *context,
dwstCallback *callbackFunc,void *callbackContext );

EXPORT int dwstOfExceptionW(
void *context,
dwstCallbackW *callbackFunc,void *callbackContext );


// dwstExceptionDialog(): show dialog on unhandled exception
// extraInfo: extra information shown in dialog
// (for example see examples/exception-dialog/)
EXPORT void dwstExceptionDialog(
const char *extraInfo );

EXPORT void dwstExceptionDialogW(
const wchar_t *extraInfo );


#ifndef DWST_STATIC
// dwstDemangle(): demangle gcc style c++ symbols
// mangled: mangled name
// demangled: demangled name
// length: size of demangled buffer
EXPORT size_t dwstDemangle(
const char *mangled,
char *demangled,size_t length );
#endif


#ifdef __cplusplus
}
#endif

#endif
13 changes: 13 additions & 0 deletions src/imports/import_32_indep_dwarfstack.def
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
LIBRARY dwarfstack

EXPORTS
dwstOfFile @ 441
dwstOfFileW @ 443
dwstOfProcess @ 446
dwstOfProcessW @ 448
dwstOfLocation @ 444
dwstOfLocationW @ 445
dwstOfException @ 438
dwstOfExceptionW @ 440
dwstExceptionDialog @ 436
dwstExceptionDialogW @ 437
13 changes: 13 additions & 0 deletions src/imports/import_64_indep_dwarfstack.def
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
LIBRARY dwarfstack

EXPORTS
dwstOfFile @ 441
dwstOfFileW @ 443
dwstOfProcess @ 446
dwstOfProcessW @ 448
dwstOfLocation @ 444
dwstOfLocationW @ 445
dwstOfException @ 438
dwstOfExceptionW @ 440
dwstExceptionDialog @ 436
dwstExceptionDialogW @ 437
3 changes: 3 additions & 0 deletions src/main/inject/Module.mk
Original file line number Diff line number Diff line change
@@ -1,11 +1,14 @@
exes += inject
imps += dwarfstack

ldflags_inject := \
-mconsole \
-lpsapi \
-ldbghelp \

libs_inject := \
util \
dwarfstack \

src_inject := \
main.c \
Expand Down
4 changes: 2 additions & 2 deletions src/main/inject/debugger.c
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,10 @@
#include "inject/debugger.h"
#include "inject/logger.h"

#include "util/debug.h"
#include "util/log.h"
#include "util/mem.h"
#include "util/proc.h"
#include "util/signal.h"
#include "util/str.h"

#define MM_ALLOCATION_GRANULARITY 0x10000
Expand Down Expand Up @@ -271,7 +271,7 @@ static uint32_t debugger_loop()
"EXCEPTION_DEBUG_EVENT(pid %ld, tid %ld): x%s 0x%p",
de.dwProcessId,
de.dwThreadId,
signal_exception_code_to_str(
debug_exception_code_to_str(
de.u.Exception.ExceptionRecord.ExceptionCode),
de.u.Exception.ExceptionRecord.ExceptionAddress);

Expand Down
2 changes: 2 additions & 0 deletions src/main/inject/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
#include "inject/version.h"

#include "util/cmdline.h"
#include "util/debug.h"
#include "util/log.h"
#include "util/mem.h"
#include "util/os.h"
Expand Down Expand Up @@ -166,6 +167,7 @@ int main(int argc, char **argv)

os_version_log();

debug_init();
signal_exception_handler_init();
// Cleanup remote process on CTRL+C
signal_register_shutdown_handler(signal_shutdown_handler);
Expand Down
1 change: 1 addition & 0 deletions src/main/util/Module.mk
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ src_util := \
cmdline.c \
crc.c \
crypto.c \
debug.c \
fs.c \
hex.c \
iobuf.c \
Expand Down
Loading