mirror of
https://github.com/dobin/SuperMega
synced 2026-06-02 17:27:10 +00:00
refactor: move stuff to working/
This commit is contained in:
+2
-2
@@ -90,12 +90,12 @@ def project():
|
||||
id = 0
|
||||
asm_a = "" # for diff
|
||||
asm_b = ""
|
||||
for file in os.listdir("logs"):
|
||||
for file in os.listdir(f"{logs_dir}/"):
|
||||
if file.startswith("."):
|
||||
continue
|
||||
print("Handle: ", file)
|
||||
|
||||
with open(os.path.join("logs", file), "r") as f:
|
||||
with open(os.path.join(f"{logs_dir}/", file), "r") as f:
|
||||
if file.endswith(".bin"):
|
||||
continue
|
||||
data = f.read()
|
||||
|
||||
@@ -49,7 +49,7 @@ def run_process_checkret(args, check=True):
|
||||
logger.warn(f"An error occurred: {e}")
|
||||
# Handle other exceptions
|
||||
|
||||
with open("logs/cmdoutput.log", "ab") as f:
|
||||
with open(f"{logs_dir}/cmdoutput.log", "ab") as f:
|
||||
cmd = "------------------------------------\n"
|
||||
cmd += "--- " + " ".join(args) + "\n"
|
||||
f.write(cmd.encode('utf-8'))
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
import logging
|
||||
|
||||
from model.defs import *
|
||||
|
||||
log_messages = []
|
||||
|
||||
|
||||
@@ -46,7 +48,7 @@ class ListHandler(logging.Handler):
|
||||
|
||||
def writelog():
|
||||
# write log to file
|
||||
with open("logs/supermega.log", "w") as f:
|
||||
with open(f"{logs_dir}/supermega.log", "w") as f:
|
||||
for line in log_messages:
|
||||
f.write(line + "\n")
|
||||
|
||||
|
||||
+3
-1
@@ -37,7 +37,9 @@ class SourceStyle(Enum):
|
||||
iat_reuse = "iat_reuse"
|
||||
|
||||
|
||||
build_dir = "build"
|
||||
# no slash at end
|
||||
build_dir = "working/build"
|
||||
logs_dir = "working/logs"
|
||||
|
||||
main_c_file = os.path.join(build_dir, "main.c")
|
||||
main_asm_file = os.path.join(build_dir, "main.asm")
|
||||
|
||||
+4
-3
@@ -5,6 +5,7 @@ from capstone import Cs, CS_ARCH_X86, CS_MODE_64
|
||||
from model import *
|
||||
from peparser.r2helper import r2_disas
|
||||
from helper import delete_all_files_in_directory
|
||||
from model.defs import *
|
||||
|
||||
|
||||
class Observer():
|
||||
@@ -32,16 +33,16 @@ class Observer():
|
||||
def write_to_file(self, filename, data):
|
||||
if not self.active:
|
||||
return
|
||||
with open("logs/{}-{}".format(self.idx, filename), "w") as f:
|
||||
with open("{}/{}-{}".format(logs_dir, self.idx, filename), "w") as f:
|
||||
f.write(data)
|
||||
def write_to_file_bin(self, filename, data):
|
||||
if not self.active:
|
||||
return
|
||||
with open("logs/{}-{}".format(self.idx, filename), "wb") as f:
|
||||
with open("{}/{}-{}".format(logs_dir, self.idx, filename), "wb") as f:
|
||||
f.write(data)
|
||||
|
||||
def clean_files(self):
|
||||
delete_all_files_in_directory("logs/")
|
||||
delete_all_files_in_directory(f"{logs_dir}/")
|
||||
self.idx = 0
|
||||
self.logs = []
|
||||
|
||||
|
||||
Binary file not shown.
+2
-2
@@ -74,12 +74,12 @@ def create_c_from_template(
|
||||
observer.add_text("main_c_rendered", rendered_template)
|
||||
|
||||
# TODO PEB
|
||||
shutil.copy("data/source/peb_walk/peb_lookup.h", "build/peb_lookup.h")
|
||||
shutil.copy("data/source/peb_walk/peb_lookup.h", f"{build_dir}/peb_lookup.h")
|
||||
else:
|
||||
observer.add_text("main_c", file_readall_text("data/source/peb_walk/main.c"))
|
||||
shutil.copy("data/source/peb_walk/main.c", main_c_file)
|
||||
# TODO PEB
|
||||
shutil.copy("data/source/peb_walk/peb_lookup.h", "build/peb_lookup.h")
|
||||
shutil.copy("data/source/peb_walk/peb_lookup.h", f"{build_dir}/peb_lookup.h")
|
||||
|
||||
elif source_style == SourceStyle.iat_reuse:
|
||||
if use_templates:
|
||||
|
||||
+1
-1
@@ -137,7 +137,7 @@ def start(settings: Settings):
|
||||
# Delete: all old files
|
||||
if settings.cleanup_files_on_start:
|
||||
clean_files()
|
||||
delete_all_files_in_directory("logs/")
|
||||
delete_all_files_in_directory(f"{logs_dir}/")
|
||||
exit_code = 0 # 0 = success
|
||||
|
||||
# Load our input
|
||||
|
||||
Reference in New Issue
Block a user