Add module offset

This commit is contained in:
Jupeyy 2022-02-23 21:10:45 +01:00
parent 501364cffe
commit 8bed1c7267
2 changed files with 40 additions and 2 deletions

29
scripts/parse_drmingw.sh Executable file
View file

@ -0,0 +1,29 @@
#!/bin/bash
if [ -z ${1+x} ]; then
printf "\e[31m%s\e[30m\n" "Did not pass executable file (full path)"
printf "\e[31m%s\e[30m\n" "Usage: ./parse_drmingw.sh <executable> <crash_log>"
exit 1
fi
if [ -z ${2+x} ]; then
printf "\e[31m%s\e[30m\n" "Did not pass crash log file (full path)"
printf "\e[31m%s\e[30m\n" "Usage: ./parse_drmingw.sh <executable> <crash_log>"
exit 1
fi
TMP_OFFSET=$(cat "$2" | grep -E -o "\(with offset [0-9A-F]*\)" | grep -E -o "[A-F0-9]*")
ADDR_PC_REGEX='[0-9A-F]+ [0-9A-F]+ [0-9A-F]+ [0-9A-F]+'
while read -r line
do
if [[ $line =~ $ADDR_PC_REGEX ]]
then
TMP_ADDR=$(echo "$line" | grep -E -o -m 1 "[A-F0-9]+ " | head -1)
ADDR_BASE=$(winedump -f "$1" | grep -E -o "image base[ ]*0x[0-9A-Fa-f]*" | grep -E -o "[0-9A-Fa-f]+" | tail -1)
REAL_ADDR=$(printf '%X\n' "$(((0x$TMP_ADDR-0x$TMP_OFFSET)+0x$ADDR_BASE))")
echo "Parsing address: $REAL_ADDR (img base: $ADDR_BASE)"
addr2line -e "$1" "$REAL_ADDR"
fi
done < "$2"

View file

@ -4072,8 +4072,17 @@ void init_exception_handler()
gs_ExceptionHandlingModule = LoadLibraryA("exchndl.dll");
if(gs_ExceptionHandlingModule != nullptr)
{
auto pfnExcHndlInit = (void APIENTRY (*)())GetProcAddress(gs_ExceptionHandlingModule, "ExcHndlInit");
pfnExcHndlInit();
// Intentional
#ifdef __MINGW32__
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wcast-function-type"
#endif
auto pfnExcHndlInit = (void APIENTRY (*)(void *))GetProcAddress(gs_ExceptionHandlingModule, "ExcHndlInit");
#ifdef __MINGW32__
#pragma clang diagnostic pop
#endif
void *pExceptionHandlingOffset = (void *)GetModuleHandle(NULL);
pfnExcHndlInit(pExceptionHandlingOffset);
}
#else
#error exception handling not implemented