Hi again.
I've written some code to interface C with our assembly network library procedures and it feels good to see C being able to load libraries at run time. Binary for Kolibri is also attached to post.
dllhttp.asm:
Код:
__DEBUG__ = 1
__DEBUG_LEVEL__ = 1
format coff
use32 ; Tell compiler to use 32 bit instructions
include 'struct.inc'
include 'proc32.inc'
include 'macros.inc'
purge section,mov,add,sub
include 'debug-fdo.inc'
include 'network.inc'
include 'http.inc'
include 'dll.inc'
virtual at 0
http_msg http_msg
end virtual
public init_network as '_init_network'
public open_site as '_open_site'
public dll.Load as '_dll_load'
public dll.Link as '_dll_link'
public dll.Init as '_dll_init'
public mem.Alloc as '_mem_alloc'
public mem.ReAlloc as '_mem_realloc'
section '.flat' code
proc init_network
mcall 68,11
stdcall dll.Load, @IMPORT
;; stdcall new_dll_load, @IMPORT
test eax, eax
jnz error
mov eax, 0xAABBCCDD
ret
error:
mov eax, 0xEEFF8899
mcall -1
endp
proc open_site
mov eax, identifier
invoke HTTP_get, sz_url, 0, 0, 0
test eax, eax
jz error2
mov [identifier], eax
.again:
invoke HTTP_receive, [identifier]
test eax, eax
jnz .again
mov eax, [identifier]
add eax, 32
mov ebx, [eax]
int3
DEBUGF 1, "The content is : %s", ebx
ret
error2:
mcall -1
endp
@IMPORT:
library lib_http, 'http.obj'
import lib_http, \
HTTP_get, 'get', \
HTTP_post, 'post', \
HTTP_receive, 'receive', \
HTTP_find_header_field, 'find_header_field', \
HTTP_free, 'free', \
HTTP_escape, 'escape'
public HTTP_get as '_http_get'
public HTTP_post as '_http_post'
public HTTP_receive as '_http_receive'
public HTTP_find_header_field as '_http_find_header_field'
public HTTP_free as '_http_free'
public HTTP_escape as '_http_escape'
sz_url db 'http://www.ashmew2.me'
identifier dd 0
include_debug_strings
dllhttp.c:
Код:
extern void init_network(void);
extern void open_site(void);
#define NULL 0
int main()
{
__asm__ volatile("int3"::);
init_network();
open_site();
return 0;
}
Compile/Link as usual and run the binary.
To get your hands dirty without compiling, this is how you should run the binary in MTDBG:
Код:
load dllhttpbin
g
bp c463
g
r eip=c479
g
d eax
<Now keep pressing d to see the site's content>
g
_________________
---
Check out the
Netsurf Web Browser for KolibriOS.
Read the wiki and happy hacking with KolibriOS!