Read Windows DLL import dumps through a temporary file
This commit is contained in:
1 parent
6e4b1ae9c4
commit
be9a953136
1 file changed
+13
-4
+13
-4
@@ -74,6 +74,14 @@ COPIED=0
|
||||
SCAN_STARTED=$SECONDS
|
||||
log " Scanner: $OBJDUMP; initial files=${#todo[@]}"
|
||||
log " Search directories: $FFMPEG_BIN; /ucrt64/bin; $SRC_DIR/rlottie_build"
|
||||
# Большой вывод objdump передаём через файл, чтобы не зависеть от here-string и pipe в MSYS2.
|
||||
if IMPORT_DUMP=$(mktemp); then
|
||||
log " Temporary import dump: $IMPORT_DUMP"
|
||||
else
|
||||
log " ERROR: cannot create temporary file for DLL inspection"
|
||||
exit 1
|
||||
fi
|
||||
trap 'rm -f -- "$IMPORT_DUMP" || log " WARN: cannot remove temporary import dump: $IMPORT_DUMP"' EXIT
|
||||
for ((i = 0; i < ${#todo[@]}; i++)); do
|
||||
src="${todo[i]}"
|
||||
key="${src,,}"
|
||||
@@ -82,11 +90,12 @@ for ((i = 0; i < ${#todo[@]}; i++)); do
|
||||
CHECKED=$((CHECKED + 1))
|
||||
CHECK_STARTED=$SECONDS
|
||||
log " Checking [$((i + 1))/${#todo[@]}]: $src (objdump starting)"
|
||||
if imports=$("$OBJDUMP" -p "$src" 2>&1); then
|
||||
log " Imports read: $src (objdump=$((SECONDS - CHECK_STARTED))s, output=${#imports} chars; resolving dependencies)"
|
||||
if "$OBJDUMP" -p "$src" > "$IMPORT_DUMP" 2>&1; then
|
||||
IMPORT_BYTES=$(wc -c < "$IMPORT_DUMP")
|
||||
log " Imports read: $src (objdump=$((SECONDS - CHECK_STARTED))s, output=$IMPORT_BYTES bytes; resolving dependencies)"
|
||||
else
|
||||
RC=$?
|
||||
log " ERROR: cannot inspect $src (exit=$RC, elapsed=$((SECONDS - CHECK_STARTED))s): $imports"
|
||||
log " ERROR: cannot inspect $src (exit=$RC, elapsed=$((SECONDS - CHECK_STARTED))s): $(cat "$IMPORT_DUMP")"
|
||||
MISSING=$((MISSING + 1))
|
||||
continue
|
||||
fi
|
||||
@@ -96,7 +105,7 @@ for ((i = 0; i < ${#todo[@]}; i++)); do
|
||||
FILE_MISSING=0
|
||||
PARSE_STARTED=$SECONDS
|
||||
log " Parsing import table: $src (awk starting)"
|
||||
if import_list=$(awk '/DLL Name:/ {print $3}' <<< "$imports" 2>&1); then
|
||||
if import_list=$(awk '/DLL Name:/ {print $3}' "$IMPORT_DUMP" 2>&1); then
|
||||
log " Import table parsed: $src (elapsed=$((SECONDS - PARSE_STARTED))s, names=${#import_list} chars)"
|
||||
else
|
||||
RC=$?
|
||||
|
||||
Reference in new issue
Block a user