summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorQuentin Ladevie <qladevie@virtuos.com.cn>2024-08-16 18:05:11 +0200
committerQuentin Ladevie <qladevie@virtuos.com.cn>2024-08-16 18:05:11 +0200
commitfa57140c3e3a56f23a37351a66d51f2cf3464561 (patch)
treeb01ff6f7b8e429521b1531ee5e9063198116581e
parentd4abaa7a7d89430fb8159ff0ce8c501c36a7ba82 (diff)
Add support for visual studio pro
Initial code for command parsing
-rw-r--r--build.bat24
-rw-r--r--src/main.c32
2 files changed, 52 insertions, 4 deletions
diff --git a/build.bat b/build.bat
index aa3cc2a..074c361 100644
--- a/build.bat
+++ b/build.bat
@@ -1,6 +1,7 @@
@ECHO OFF
:: Unpack Arguments
+set release=0
for %%a in (%*) do set "%%a=1"
set BUILD_DIR=build
@@ -10,12 +11,27 @@ IF EXIST %BUILD_DIR% rmdir %BUILD_DIR%\ /S /Q
mkdir build
-call "C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Auxiliary\Build\vcvars64.bat"
+set VS2022_COM="C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Auxiliary\Build\vcvars64.bat"
+set VS2022_PRO="C:\Program Files\Microsoft Visual Studio\2022\Professional\VC\Auxiliary\Build\vcvars64.bat"
+if EXIST %VS2022_COM% (
+ call %VS2022_COM%
+ goto compilation
+)
+if EXIST %VS2022_PRO% (
+ call %VS2022_PRO%
+ goto compilation
+)
+
+
+:compilation
set C_FLAGS=/nologo /W4 /WX /Zi /GS- /GR- /Gs1000000000 /Fo:%BUILD_DIR%\ /std:c17 /c /Tc
-set L_FLAGS=/WX /SUBSYSTEM:CONSOLE /NODEFAULTLIB /stack:0x100000,100000 /DEBUG
+set L_FLAGS=/WX /SUBSYSTEM:CONSOLE /NODEFAULTLIB /stack:0x100000,100000
-if "%release%"=="0" set C_FLAGS=%C_FLAGS% /Od
+if "%release%"=="0" (
+ set C_FLAGS=/Od %C_FLAGS%
+ set L_FLAGS=/DEBUG %L_FLAGS%
+)
set SRC_FILE=
@@ -30,7 +46,7 @@ link %L_FLAGS% %BUILD_DIR%\%SRC_FILE%.obj /OUT:%BUILD_DIR%\%SRC_FILE%.exe kernel
:: Test program
set SRC_FILE=test
:: Compile
-cl /Fd:%BUILD_DIR%\test.pdb %C_FLAGS% src/test.c
+cl /Fd:%BUILD_DIR%\%SRC_FILE%.pdb %C_FLAGS% src/%SRC_FILE%.c
:: Link
link %L_FLAGS% %BUILD_DIR%\%SRC_FILE%.obj /OUT:%BUILD_DIR%\%SRC_FILE%.exe kernel32.lib
diff --git a/src/main.c b/src/main.c
index e7278c8..3e9ee07 100644
--- a/src/main.c
+++ b/src/main.c
@@ -13,6 +13,37 @@ typedef int16_t i16;
typedef int32_t i32;
typedef int64_t i64;
+
+enum CMD_TYPE {
+ CMD_CONTINUE,
+ CMD_MAX,
+};
+
+struct token {
+ const char* start;
+ u8 size;
+};
+
+struct command {
+ enum CMD_TYPE cmd_type;
+};
+
+void tokenize(const char* cmd, struct token* tokens) {
+ const char* start = cmd;
+ const char* cur = cmd;
+ struct token* cur_token = tokens[0];
+ while(*cur != '\0') {
+
+ }
+}
+
+enum CMD_TYPE command_parser(const char* cmd) {
+ struct token* tokens = (struct token*)VirtualAlloc(NULL, sizeof(struct token) * 32, MEM_RESERVE | MEM_COMMIT, PAGE_READWRITE);
+ tokenize(cmd, tokens);
+
+ return CMD_MAX;
+}
+
void print(const char* format, ...) {
va_list args;
va_start(args, format);
@@ -129,6 +160,7 @@ int mainCRTStartup() {
ReadConsole(h_input, input_buffer, sizeof(input_buffer), &input_size, NULL);
// print("%s%s", "ReadConsole :", input_buffer);
+ command_parser(input_buffer);
if (input_buffer[0] == 'g') {
ContinueDebugEvent(
dbg_event.dwProcessId,