mirror of
https://github.com/Doczom/simple-httpd.git
synced 2025-09-21 02:50:09 +02:00
Added basic files: - httpd.asm - main loop server, include other files; - httpd_lib - file for data(constants, response string, headers etc.); - parser.inc - function for generation structure of HTTP request; - settings.inc - description request structure and function for read config file; - sys_func.inc - list function, for worked with sockets, filesystem and other functions system; NOTE: The server does not work in this version, but the main loop and the parser work.
90 lines
2.6 KiB
PHP
90 lines
2.6 KiB
PHP
; ABSTRACT SYSTEM FUNCTIONS
|
|
|
|
; stdcall socket(uint32_t domain, type, proto)
|
|
netfunc_socket:
|
|
push ebx esi
|
|
mcall 75, 0, [esp + 2*4 + 4], [esp + 2*4 + 8], [esp + 2*4 + 12]
|
|
;mov [fs:0], ebx ;errno
|
|
pop esi ebx
|
|
ret 12
|
|
|
|
;stdcall close(uint32_t sock_number);
|
|
netfunc_close:
|
|
push ebx
|
|
call 75, 1, [esp + 4 + 4]
|
|
pop ebx
|
|
ret 4
|
|
|
|
;stdcall bind(uint32_t sock_num, sockaddr* _sockaddr_struct, uint32_t sockaddr_size)
|
|
netfunc_bind:
|
|
push esi ebx
|
|
mcall 75, 2, [esp + 2*4 + 4], [esp + 2*4 + 8], [esp + 2*4 + 12]
|
|
pop ebx esi
|
|
ret 12
|
|
|
|
;stdcall listen(uint32_t socket, uint32_t backlog)
|
|
netfunc_listen:
|
|
push ebx
|
|
mcall 75, 3, [esp + 4 + 4], [esp + 4 + 8]
|
|
pop ebx
|
|
ret 8
|
|
;stdcall accept(uint32_t socket, sockaddr* new_sockaddr_struct, uint32_t sockaddr_size)
|
|
netfunc_accept:
|
|
push esi ebx
|
|
mcall 75, 5, [esp + 2*4 + 4], [esp + 2*4 + 8], [esp + 2*4 + 12]
|
|
pop ebx esi
|
|
ret 12
|
|
;stdcall send(uint32_t socket, void* buff, uint32_t len_buff, uint32_t flags)
|
|
netfunc_send:
|
|
push esi edi ebx
|
|
mcall 75, 6, [esp + 3*4 + 4], [esp + 3*4 + 8],\
|
|
[esp + 3*4 + 12], [esp + 3*4 + 16]
|
|
pop ebx edi esi
|
|
ret 16
|
|
;stdcall recv(uint32_t socket, void* buff, uint32_t len_buff, uint32_t flags)
|
|
netfunc_recv:
|
|
push esi edi ebx
|
|
mcall 75, 7, [esp + 3*4 + 4], [esp + 3*4 + 8],\
|
|
[esp + 3*4 + 12], [esp + 3*4 + 16]
|
|
pop ebx edi esi
|
|
ret 16
|
|
|
|
; stdcall CreatThread(void* entry_thread);
|
|
CreateThread:
|
|
push ebx edi
|
|
mcall 68, 12, 0x4000 ;alloc memory 16 kib for stack
|
|
test eax, eax
|
|
jz .err
|
|
|
|
mov ecx, 0x4000/4
|
|
mov edi, eax
|
|
;start thread for new connection
|
|
mov edx, eax
|
|
xor eax, eax
|
|
rep stosd
|
|
add edx, 0x4000
|
|
mcall 51, 1, [esp + 2*4 + 4] ;<- thread entry
|
|
.err:
|
|
pop ebx edi
|
|
ret 4
|
|
; stdcall Alloc(uint32_t size)
|
|
Alloc:
|
|
push ebx
|
|
mcall 68, 12, [esp + 4 + 4]
|
|
pop ebx
|
|
ret 4
|
|
; stdcall Free(void* ptr)
|
|
Free:
|
|
push ebx
|
|
mcall 68, 13, [esp + 4 + 4]
|
|
pop ebx
|
|
ret 4
|
|
|
|
;NTSTATUS stdcall FileInfo(const char* path, void* buff)
|
|
FileInfo:
|
|
|
|
ret 8
|
|
;NTSATTUS stdcall FileRead(const char* path, void* buff, uint32_t size)
|
|
FileRead:
|
|
|
|
ret 12 |