Skip to content

Commit 4fe4339

Browse files
committed
Add premake and prepare main executable
1 parent a4d2fb1 commit 4fe4339

26 files changed

Lines changed: 1686 additions & 498 deletions

File tree

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
name: win-artifact-build
2+
3+
on:
4+
push:
5+
branches: [ build ]
6+
7+
jobs:
8+
build-win64:
9+
10+
runs-on: windows-latest
11+
12+
steps:
13+
14+
- name: Install Cygwin
15+
# You may pin to the exact commit or the version.
16+
# uses: egor-tensin/setup-cygwin@4f96f9fecb8c952fa32ff791b0a77d93d5191bb4
17+
uses: egor-tensin/setup-cygwin@v3
18+
with:
19+
platform: x64 # optional, default is x64
20+
install-dir: c:\tools\cygwin # optional, default is C:\tools\cygwin
21+
packages: gcc-core binutils make zip libssl-devel # optional
22+
23+
- name: Checkout with submodules
24+
uses: actions/checkout@v3
25+
with:
26+
submodules: 'true'
27+
28+
- name: Compile
29+
run: make
30+
31+
- name: Compile Windows-only tools and create a ZIP package
32+
run: make zip
33+
34+
- name: Upload Artifact
35+
uses: actions/upload-artifact@v3
36+
with:
37+
name: win-build
38+
path: ./*.zip
39+
retention-days: 1

Makefile

Lines changed: 68 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,68 @@
1-
LIBPE_DIR = lib/libpe
2-
PEV_DIR = src
3-
VERSION = 0.82
4-
ZIPDIR = pev-$(VERSION)-win
5-
ZIPFILE = $(ZIPDIR).zip
6-
7-
all:
8-
%:
9-
cd $(LIBPE_DIR) && $(MAKE) $@
10-
cd $(PEV_DIR) && $(MAKE) $@
11-
12-
# Cygwin only
13-
zip:
14-
cd $(PEV_DIR)/windows && $(MAKE)
15-
mkdir -p $(ZIPDIR)/plugins
16-
cp src/build/plugins/*.dll $(ZIPDIR)/plugins/
17-
echo -ne "plugins_dir=plugins\r\n" > $(ZIPDIR)/pev.conf
18-
cp $(PEV_DIR)/userdb.txt $(ZIPDIR)
19-
cp lib/libpe/libpe.dll $(ZIPDIR)/
20-
cp /usr/bin/cygwin1.dll $(ZIPDIR)/
21-
cp /usr/bin/cygcrypto-1*.dll $(ZIPDIR)/
22-
cp /usr/bin/cygz.dll $(ZIPDIR)/
23-
cp README.md $(ZIPDIR)/
24-
cp $(PEV_DIR)/build/*.exe $(ZIPDIR)/
25-
cp $(PEV_DIR)/windows/run.bat $(ZIPDIR)/
26-
zip -r $(ZIPFILE) $(ZIPDIR)/*
27-
rm -rf $(ZIPDIR)
1+
# Alternative GNU Make workspace makefile autogenerated by Premake
2+
3+
ifndef config
4+
config=debug
5+
endif
6+
7+
ifndef verbose
8+
SILENT = @
9+
endif
10+
11+
ifeq ($(config),debug)
12+
pe_config = debug
13+
udis86_config = debug
14+
readpe_config = debug
15+
16+
else ifeq ($(config),release)
17+
pe_config = release
18+
udis86_config = release
19+
readpe_config = release
20+
21+
else
22+
$(error "invalid configuration $(config)")
23+
endif
24+
25+
PROJECTS := pe udis86 readpe
26+
27+
.PHONY: all clean help $(PROJECTS)
28+
29+
all: $(PROJECTS)
30+
31+
pe:
32+
ifneq (,$(pe_config))
33+
@echo "==== Building pe ($(pe_config)) ===="
34+
@${MAKE} --no-print-directory -C lib/libpe -f Makefile config=$(pe_config)
35+
endif
36+
37+
udis86:
38+
ifneq (,$(udis86_config))
39+
@echo "==== Building udis86 ($(udis86_config)) ===="
40+
@${MAKE} --no-print-directory -C lib/libudis86/libudis86 -f Makefile config=$(udis86_config)
41+
endif
42+
43+
readpe: pe udis86
44+
ifneq (,$(readpe_config))
45+
@echo "==== Building readpe ($(readpe_config)) ===="
46+
@${MAKE} --no-print-directory -C src -f Makefile config=$(readpe_config)
47+
endif
48+
49+
clean:
50+
@${MAKE} --no-print-directory -C lib/libpe -f Makefile clean
51+
@${MAKE} --no-print-directory -C lib/libudis86/libudis86 -f Makefile clean
52+
@${MAKE} --no-print-directory -C src -f Makefile clean
53+
54+
help:
55+
@echo "Usage: make [config=name] [target]"
56+
@echo ""
57+
@echo "CONFIGURATIONS:"
58+
@echo " debug"
59+
@echo " release"
60+
@echo ""
61+
@echo "TARGETS:"
62+
@echo " all (default)"
63+
@echo " clean"
64+
@echo " pe"
65+
@echo " udis86"
66+
@echo " readpe"
67+
@echo ""
68+
@echo "For more information, see https://github.com/premake/premake-core/wiki"

completion/bash/readpe

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,15 @@
11
#!/usr/bin/env bash
2-
complete -F _longopt readpe
2+
3+
function _complete_readpe () {
4+
echo $COMP_LINE
5+
# local _comp=$COMP_LINE
6+
# local _comp=$("${COMP_LINE[@]::${#COMP_LINE[@]}-1} --complete")
7+
local _comp=$($COMP_LINE "--complete")
8+
# printf "headers directories exports"
9+
COMPREPLY=($_comp)
10+
}
11+
12+
complete -F _complete_readpe readpe
313
complete -F _longopt pedis
414
complete -F _longopt pehash
515
complete -F _longopt peldd
@@ -9,3 +19,4 @@ complete -F _longopt pescan
919
complete -F _longopt pesec
1020
complete -F _longopt pestr
1121

22+

include/common.h

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,11 @@
5959

6060
#define MAX_MSG 81
6161
#define MAX_PATH 256
62-
#define VERSION "0.82"
62+
63+
#ifndef VERSION
64+
#define VERSION "1.0"
65+
#endif
66+
6367
#define TOOLKIT "from pev " VERSION " <https://github.com/mentebinaria/readpe/> toolkit"
6468
#define COPY \
6569
"License GPLv2+: GNU GPL version 2 or later <https://www.gnu.org/licenses/gpl-2.0.txt>.\n" \

include/peldd.h

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
/* vim: set ts=4 sw=4 noet: */
2+
/*
3+
readpe - the PE file analyzer toolkit
4+
5+
Copyright (C) 2023 readpe authors
6+
7+
This program is free software: you can redistribute it and/or modify
8+
it under the terms of the GNU General Public License as published by
9+
the Free Software Foundation, either version 2 of the License, or
10+
(at your option) any later version.
11+
12+
This program is distributed in the hope that it will be useful,
13+
but WITHOUT ANY WARRANTY; without even the implied warranty of
14+
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15+
GNU General Public License for more details.
16+
17+
You should have received a copy of the GNU General Public License
18+
along with this program. If not, see <http://www.gnu.org/licenses/>.
19+
20+
In addition, as a special exception, the copyright holders give
21+
permission to link the code of portions of this program with the
22+
OpenSSL library under certain conditions as described in each
23+
individual source file, and distribute linked combinations
24+
including the two.
25+
26+
You must obey the GNU General Public License in all respects
27+
for all of the code used other than OpenSSL. If you modify
28+
file(s) with this exception, you may extend this exception to your
29+
version of the file(s), but you are not obligated to do so. If you
30+
do not wish to do so, delete this exception statement from your
31+
version. If you delete this exception statement from all source
32+
files in the program, then also delete it here.
33+
*/
34+
35+
#pragma once
36+
37+
#include <libpe/pe.h>
38+
39+
void print_dependencies(pe_ctx_t *ctx);
40+

include/peres.h

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
/* vim: set ts=4 sw=4 noet: */
2+
/*
3+
readpe - the PE file analyzer toolkit
4+
5+
Copyright (C) 2023 readpe authors
6+
7+
This program is free software: you can redistribute it and/or modify
8+
it under the terms of the GNU General Public License as published by
9+
the Free Software Foundation, either version 2 of the License, or
10+
(at your option) any later version.
11+
12+
This program is distributed in the hope that it will be useful,
13+
but WITHOUT ANY WARRANTY; without even the implied warranty of
14+
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15+
GNU General Public License for more details.
16+
17+
You should have received a copy of the GNU General Public License
18+
along with this program. If not, see <http://www.gnu.org/licenses/>.
19+
20+
In addition, as a special exception, the copyright holders give
21+
permission to link the code of portions of this program with the
22+
OpenSSL library under certain conditions as described in each
23+
individual source file, and distribute linked combinations
24+
including the two.
25+
26+
You must obey the GNU General Public License in all respects
27+
for all of the code used other than OpenSSL. If you modify
28+
file(s) with this exception, you may extend this exception to your
29+
version of the file(s), but you are not obligated to do so. If you
30+
do not wish to do so, delete this exception statement from your
31+
version. If you delete this exception statement from all source
32+
files in the program, then also delete it here.
33+
*/
34+
35+
#pragma once
36+
37+
#include <libpe/context.h>
38+
#include <libpe/pe.h>
39+
#include <libpe/resources.h>
40+
#include <libpe/types_resources.h>
41+
#include <libpe/utlist.h>
42+
43+
void peres_show_nodes(pe_ctx_t *ctx, const pe_resource_node_t *node);
44+
void peres_show_stats(const pe_resource_node_t *node);
45+
void peres_show_list(pe_ctx_t *ctx, const pe_resource_node_t *node);
46+
void peres_save_all_resources(pe_ctx_t *ctx, const pe_resource_node_t *node, bool namedExtract);
47+
void peres_show_version(pe_ctx_t *ctx, const pe_resource_node_t *node);
48+

include/pesec.h

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
/* vim: set ts=4 sw=4 noet: */
2+
/*
3+
readpe - the PE file analyzer toolkit
4+
5+
Copyright (C) 2023 readpe authors
6+
7+
This program is free software: you can redistribute it and/or modify
8+
it under the terms of the GNU General Public License as published by
9+
the Free Software Foundation, either version 2 of the License, or
10+
(at your option) any later version.
11+
12+
This program is distributed in the hope that it will be useful,
13+
but WITHOUT ANY WARRANTY; without even the implied warranty of
14+
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15+
GNU General Public License for more details.
16+
17+
You should have received a copy of the GNU General Public License
18+
along with this program. If not, see <http://www.gnu.org/licenses/>.
19+
20+
In addition, as a special exception, the copyright holders give
21+
permission to link the code of portions of this program with the
22+
OpenSSL library under certain conditions as described in each
23+
individual source file, and distribute linked combinations
24+
including the two.
25+
26+
You must obey the GNU General Public License in all respects
27+
for all of the code used other than OpenSSL. If you modify
28+
file(s) with this exception, you may extend this exception to your
29+
version of the file(s), but you are not obligated to do so. If you
30+
do not wish to do so, delete this exception statement from your
31+
version. If you delete this exception statement from all source
32+
files in the program, then also delete it here.
33+
*/
34+
35+
#pragma once
36+
37+
#include "common.h"
38+
#include <libpe/pe.h>
39+
#include <openssl/pem.h>
40+
41+
typedef enum {
42+
CERT_FORMAT_TEXT = 1,
43+
CERT_FORMAT_PEM = 2,
44+
CERT_FORMAT_DER = 3
45+
} cert_format_e;
46+
47+
typedef struct {
48+
cert_format_e certoutform;
49+
BIO *certout;
50+
} certificate_settings;
51+
52+
bool stack_cookies(pe_ctx_t *ctx);
53+
void print_securities(pe_ctx_t *ctx);
54+
void parse_certificates(const certificate_settings *options, pe_ctx_t *ctx);
55+

include/pestr.h

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
/* vim: set ts=4 sw=4 noet: */
2+
/*
3+
readpe - the PE file analyzer toolkit
4+
5+
Copyright (C) 2023 readpe authors
6+
7+
This program is free software: you can redistribute it and/or modify
8+
it under the terms of the GNU General Public License as published by
9+
the Free Software Foundation, either version 2 of the License, or
10+
(at your option) any later version.
11+
12+
This program is distributed in the hope that it will be useful,
13+
but WITHOUT ANY WARRANTY; without even the implied warranty of
14+
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15+
GNU General Public License for more details.
16+
17+
You should have received a copy of the GNU General Public License
18+
along with this program. If not, see <http://www.gnu.org/licenses/>.
19+
20+
In addition, as a special exception, the copyright holders give
21+
permission to link the code of portions of this program with the
22+
OpenSSL library under certain conditions as described in each
23+
individual source file, and distribute linked combinations
24+
including the two.
25+
26+
You must obey the GNU General Public License in all respects
27+
for all of the code used other than OpenSSL. If you modify
28+
file(s) with this exception, you may extend this exception to your
29+
version of the file(s), but you are not obligated to do so. If you
30+
do not wish to do so, delete this exception statement from your
31+
version. If you delete this exception statement from all source
32+
files in the program, then also delete it here.
33+
*/
34+
35+
#pragma once
36+
37+
#include <libpe/pe.h>
38+
39+
typedef struct {
40+
unsigned short strsize;
41+
bool offset;
42+
bool section;
43+
} string_settings;
44+
45+
void print_strings( pe_ctx_t *ctx, const string_settings *options);
46+

0 commit comments

Comments
 (0)