upload sources

This commit is contained in:
rgimad
2024-03-19 20:02:55 +03:00
commit 929f757016
6 changed files with 81 additions and 0 deletions

4
.gitignore vendored Normal file
View File

@@ -0,0 +1,4 @@
*.code-workspace
*.exe
*.zip
*.img

18
Makefile Normal file
View File

@@ -0,0 +1,18 @@
KTCC_DIR = ../KOS_SVN/programs/develop/ktcc/trunk
KLIBC = ../KOS_SVN/programs/develop/ktcc/trunk/libc.obj
NAME = kexview
KTCC = $(KTCC_DIR)/bin/kos32-tcc
# KPACK = kpack
SRC = $(wildcard *.c)
FLAGS= -B$(KTCC_DIR)/bin -I $(KLIBC)/include
LIBS = -limg
all: $(SRC)
$(KTCC) $(FLAGS) $(SRC) $(LIBS) -o $(NAME)
# $(KPACK) $(NAME)
clean:
rm $(NAME)

2
README.md Normal file
View File

@@ -0,0 +1,2 @@
# KEXview
Program for viewing information about executable files for KolibriOS

BIN
kexview Normal file

Binary file not shown.

56
kexview.c Normal file
View File

@@ -0,0 +1,56 @@
#include <stdio.h>
#include <string.h>
#include <stdint.h>
#include <sys/ksys.h>
#define SIGNATURE_SIZE 8
typedef struct {
char signature[SIGNATURE_SIZE];
uint32_t startAddress;
uint32_t fileSize;
uint32_t memRequired;
uint32_t espValue;
uint32_t paramAddress;
uint32_t filePathAddress;
uint32_t tlsDataAddress; // Only for MENUET02 signature
} ExecutableHeader;
int main(int argc, char *argv[]) {
if (argc < 2) {
printf("Error: Path to executable file not provided.\n");
return 1;
}
ksys_ufile_t file = _ksys_load_file(argv[1]);
if (file.data == NULL) {
printf("Error: Unable to open file.\n");
return 1;
}
ExecutableHeader header;
if (file.size < sizeof(ExecutableHeader)) {
printf("Error: Unable to read header information.\n");
return 1;
} else {
memcpy(&header, file.data, sizeof(ExecutableHeader));
}
if (strncmp(header.signature, "MENUET01", SIGNATURE_SIZE) != 0 && strncmp(header.signature, "MENUET02", SIGNATURE_SIZE) != 0) {
printf("Error: Invalid signature.\n");
return 1;
}
printf("Version: %.*s\n", SIGNATURE_SIZE, header.signature);
printf("Start Address: 0x%x\n", header.startAddress);
printf("File Size: %u bytes\n", header.fileSize);
printf("Memory Required: %u bytes\n", header.memRequired);
printf("ESP Value: 0x%x\n", header.espValue);
printf("Parameter Address: 0x%x\n", header.paramAddress);
printf("File Path Address: 0x%x\n", header.filePathAddress);
if (strncmp(header.signature, "MENUET02", SIGNATURE_SIZE) == 0) {
printf("TLS Data Address: 0x%x\n", header.tlsDataAddress);
}
return 0;
}

1
run.bat Normal file
View File

@@ -0,0 +1 @@
qemu-system-i386 -fda kolibri.img -boot a -m 512 -usbdevice tablet -drive file=fat:rw:.