From aacab6a6adc4feeab003a6bc4325a81af1dd042d Mon Sep 17 00:00:00 2001
From: WookiesRpeople2
Date: Sun, 20 Oct 2024 16:19:33 +0000
Subject: [PATCH 1/4] changed data.asm to contain a pointer array with the
values HEAD and GET, enhanced the http.asm file to loop through the array and
set the request type when found
---
data.asm | 10 ++++++++++
http.asm | 41 ++++++++++++++++++++++++-----------------
2 files changed, 34 insertions(+), 17 deletions(-)
diff --git a/data.asm b/data.asm
index 9a649ba..7809aee 100644
--- a/data.asm
+++ b/data.asm
@@ -171,3 +171,13 @@
http_dir_entry_open_a_tag_pre db '',0x00
http_dir_entry_close_a_tag db '
',0x00
+
+ ; Request type
+ req_types db 'GET', 0
+ req_get_length equ $ - req_types - 1
+
+ req_head db 'HEAD', 0
+ req_head_length equ $ - req_head - 1
+
+ req_type_ptrs dq req_types, req_head ; array of request types
+ req_type_lengths dq req_get_length, req_head_length
diff --git a/http.asm b/http.asm
index 3864097..f1a998c 100644
--- a/http.asm
+++ b/http.asm
@@ -413,26 +413,33 @@ get_request_type: ;rdi - pointer to buffer, ret = rax: request type
mov rax, REQ_UNK
- check_get:
- cmp byte[rdi+0], 0x47
- jne check_head
- cmp byte[rdi+1], 0x45
- jne check_head
- cmp byte[rdi+2], 0x54
- jne check_head
+ check_request:
+ ; add to array in data in order check to the request type
+
+ mov rsi, [req_type_ptrs + rbx * 8]
+ mov rcx, [req_type_lengths + rbx * 8]
+
+ repe cmpsb
+ jne next_request
+
+ cmp rbx, 0
+ je set_req_get
+ cmp rbx, 1
+ je set_req_head
+
+ set_req_get:
mov rax, REQ_GET
+ jmp request_type_return
- check_head:
- cmp byte[rdi+0], 0x48
- jne request_type_return
- cmp byte[rdi+1], 0x45
- jne request_type_return
- cmp byte[rdi+2], 0x41
- jne request_type_return
- cmp byte[rdi+3], 0x44
- jne request_type_return
+ set_req_head:
mov rax, REQ_HEAD
+ jmp request_type_return
+
+ next_request:
+ inc rbx
+ cmp rbx, rdx
+ jl check_request
- request_type_return:
+ request_type_return:
stackpop
ret
From 9312df7ffce8ccd30a64380d83c88b49f01cce20 Mon Sep 17 00:00:00 2001
From: WookiesRpeople2
Date: Sun, 20 Oct 2024 18:22:02 +0000
Subject: [PATCH 2/4] changed req_types to req_get
---
data.asm | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/data.asm b/data.asm
index 7809aee..4f77499 100644
--- a/data.asm
+++ b/data.asm
@@ -173,11 +173,11 @@
http_dir_entry_close_a_tag db '
',0x00
; Request type
- req_types db 'GET', 0
- req_get_length equ $ - req_types - 1
+ req_get db 'GET', 0
+ req_get_length equ $ - req_get - 1
req_head db 'HEAD', 0
req_head_length equ $ - req_head - 1
- req_type_ptrs dq req_types, req_head ; array of request types
+ req_type_ptrs dq req_get, req_head ; array of request types
req_type_lengths dq req_get_length, req_head_length
From 39a94841f15a8bdf6289a31e207bf776f70e0b28 Mon Sep 17 00:00:00 2001
From: WookiesRpeople2
Date: Tue, 22 Oct 2024 22:05:45 +0000
Subject: [PATCH 3/4] FIXED: segfault on head request
---
data.asm | 6 +++---
http.asm | 26 ++++++++++++--------------
2 files changed, 15 insertions(+), 17 deletions(-)
diff --git a/data.asm b/data.asm
index 4f77499..2ab3b9a 100644
--- a/data.asm
+++ b/data.asm
@@ -174,10 +174,10 @@
; Request type
req_get db 'GET', 0
- req_get_length equ $ - req_get - 1
+ req_get_offset equ $ - req_get
req_head db 'HEAD', 0
- req_head_length equ $ - req_head - 1
+ req_head_offset equ $ - req_head
req_type_ptrs dq req_get, req_head ; array of request types
- req_type_lengths dq req_get_length, req_head_length
+ req_type_count equ ($ - req_type_ptrs) / 8
diff --git a/http.asm b/http.asm
index f1a998c..efe0bb6 100644
--- a/http.asm
+++ b/http.asm
@@ -410,36 +410,34 @@ get_request_type: ;rdi - pointer to buffer, ret = rax: request type
mov rax, r10
add rax, 0x03
mov [request_offset], rax
+ xor rbx, rbx
mov rax, REQ_UNK
check_request:
; add to array in data in order check to the request type
-
- mov rsi, [req_type_ptrs + rbx * 8]
- mov rcx, [req_type_lengths + rbx * 8]
+ mov rsi, [req_type_ptrs + rbx * 8]
+ mov rcx, -1
+ mov rdx, rdi
repe cmpsb
jne next_request
- cmp rbx, 0
- je set_req_get
- cmp rbx, 1
- je set_req_head
+ jmp [req_type_ptrs + rbx * 8] ; automatically jmp to the correct method
+
+ next_request:
+ inc rbx
+ cmp rbx, req_type_count
+ jne check_request
set_req_get:
mov rax, REQ_GET
- jmp request_type_return
+ jmp request_type_return
set_req_head:
mov rax, REQ_HEAD
jmp request_type_return
-
- next_request:
- inc rbx
- cmp rbx, rdx
- jl check_request
-
+
request_type_return:
stackpop
ret
From 3ac36a112f54e15ba685f602e70ccf0f5c955dcc Mon Sep 17 00:00:00 2001
From: WookiesRpeople2
Date: Fri, 8 Nov 2024 01:12:51 +0100
Subject: [PATCH 4/4] Changed the way the requested is matched
---
data.asm | 13 ++++---------
http.asm | 39 ++++++++++++++-------------------------
2 files changed, 18 insertions(+), 34 deletions(-)
diff --git a/data.asm b/data.asm
index 2ab3b9a..6de55c8 100644
--- a/data.asm
+++ b/data.asm
@@ -172,12 +172,7 @@
http_dir_entry_open_a_tag_post db '">',0x00
http_dir_entry_close_a_tag db '',0x00
- ; Request type
- req_get db 'GET', 0
- req_get_offset equ $ - req_get
-
- req_head db 'HEAD', 0
- req_head_offset equ $ - req_head
-
- req_type_ptrs dq req_get, req_head ; array of request types
- req_type_count equ ($ - req_type_ptrs) / 8
+ ; Request type
+ request_types db "GET ", "HEAD " ; space after each request type
+ request_values db REQ_GET, REQ_HEAD
+ num_requests equ ($ - request_types) / 4
diff --git a/http.asm b/http.asm
index efe0bb6..30eff48 100644
--- a/http.asm
+++ b/http.asm
@@ -410,34 +410,23 @@ get_request_type: ;rdi - pointer to buffer, ret = rax: request type
mov rax, r10
add rax, 0x03
mov [request_offset], rax
- xor rbx, rbx
-
+
mov rax, REQ_UNK
+
+ check_request_loop:
+ mov edx, [rdi]
+ lea rsi, [request_types + rbx * 4]
+ cmp edx, [rsi]
+ jne next_request
- check_request:
- ; add to array in data in order check to the request type
- mov rsi, [req_type_ptrs + rbx * 8]
- mov rcx, -1
- mov rdx, rdi
-
- repe cmpsb
- jne next_request
-
- jmp [req_type_ptrs + rbx * 8] ; automatically jmp to the correct method
-
- next_request:
- inc rbx
- cmp rbx, req_type_count
- jne check_request
+ movzx rax, byte [request_values + rbx]
+ jmp request_type_return
- set_req_get:
- mov rax, REQ_GET
- jmp request_type_return
+ next_request:
+ inc rbx
+ cmp rbx, num_requests
+ jl check_request_loop
- set_req_head:
- mov rax, REQ_HEAD
- jmp request_type_return
-
- request_type_return:
+ request_type_return:
stackpop
ret