upload sources
This commit is contained in:
4
.gitignore
vendored
Normal file
4
.gitignore
vendored
Normal file
@@ -0,0 +1,4 @@
|
|||||||
|
*.code-workspace
|
||||||
|
*.exe
|
||||||
|
*.zip
|
||||||
|
*.img
|
18
Makefile
Normal file
18
Makefile
Normal 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
2
README.md
Normal file
@@ -0,0 +1,2 @@
|
|||||||
|
# KEXview
|
||||||
|
Program for viewing information about executable files for KolibriOS
|
56
kexview.c
Normal file
56
kexview.c
Normal 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;
|
||||||
|
}
|
Reference in New Issue
Block a user