flat assembler
Message board for the users of flat assembler.
![]() |
Author |
|
narada
Hi!
Anybody know how to use sqlite.so in linux-asm programs??? For Win it's not a problem, but for linux... i can't find any example on the web... ((( HELP, PLEASE!!! |
|||
![]() |
|
pelaillo
Here is a very simple example that uses the fasm's new features for ELF
Code: ;Use fasm 1.69 or later (for extended ELF support) SQLITE_OK =0 SQLITE_ROW =100 format ELF executable entry start include 'import32.inc' include 'proc32.inc' interpreter '/lib/ld-linux.so.2' needed 'libc.so.6','libsqlite3.so.0' import printf,exit,\ sqlite3_open,sqlite3_prepare_v2,sqlite3_step,\ sqlite3_column_text,sqlite3_finalize,sqlite3_close segment readable executable start: cinvoke sqlite3_open,database,ppDB cmp eax,SQLITE_OK jne .error_opening cinvoke printf,msg1,database cinvoke sqlite3_prepare_v2,[ppDB],SQL1,SQL1_len,ppStmt,0 cmp eax,SQLITE_OK jne .error_compiling cinvoke sqlite3_step,[ppStmt] ; Creating a table cinvoke sqlite3_finalize,[ppStmt] cinvoke sqlite3_prepare_v2,[ppDB],SQL2,SQL2_len,ppStmt,0 cmp eax,SQLITE_OK jne .error_compiling cinvoke sqlite3_step,[ppStmt] ; inserting some records cinvoke sqlite3_finalize,[ppStmt] cinvoke sqlite3_prepare_v2,[ppDB],SQL3,SQL3_len,ppStmt,0 cmp eax,SQLITE_OK jne .error_compiling .get_row: cinvoke sqlite3_step,[ppStmt] cmp eax,SQLITE_ROW jne .rows_done cinvoke sqlite3_column_text,[ppStmt],0 cinvoke printf,text,eax cinvoke sqlite3_column_text,[ppStmt],1 cinvoke printf,text,eax jmp .get_row .rows_done: cinvoke sqlite3_finalize,[ppStmt] .closing: cinvoke sqlite3_prepare_v2,[ppDB],SQL4,SQL4_len,ppStmt,0 cmp eax,SQLITE_OK jne .error_compiling cinvoke sqlite3_step,[ppStmt] ; dropping the table cinvoke sqlite3_finalize,[ppStmt] cinvoke sqlite3_close,[ppDB] .the_end: cinvoke exit .error_compiling: cinvoke printf,msg2 jmp .closing .error_opening: cinvoke printf,msg3 jmp .the_end segment readable writeable ppDB dd 0 ppStmt dd 0 database db "tes.sqlite",0 SQL1 db "CREATE TABLE functions (name,description)",0 SQL1_len = $ - SQL1 SQL2 db "INSERT INTO functions VALUES ('hello', 'world')",0 SQL2_len = $ - SQL2 SQL3 db "SELECT * FROM functions",0 SQL3_len = $ - SQL3 SQL4 db "DROP TABLE functions",0 SQL4_len = $ - SQL4 text db "%s",0xA,0 msg1 db 'Sqlite3 test program. Reading "%s" database file.',0xA,0 msg2 db "Error compiling the SQL statement.",0xA,0 msg3 db "Error opening the database file.",0xA,0 Last edited by pelaillo on 08 Apr 2010, 13:59; edited 1 time in total |
|||
![]() |
|
narada
+1) thanks.
+ some another question: for linux i am programming just few month, so i don't know some info. So, can i convert .so to .o ? |
|||
![]() |
|
pelaillo
narada,
One .so file is a shared object (executable library) already linked and could be composed of several object files. The answer to your question is yes, but the method depends on what you really want to accomplish. |
|||
![]() |
|
kohlrak
Odds are, if you're using linux and you have a .so file, there is a .o file in another folder or available for download.
I just did a little research on it and it's obviously open source, so by all means, dig in. Just make an object file instead and use a linker. |
|||
![]() |
|
codesz
It works fine.
SQLITE_OK =0 SQLITE_ROW =100 |
|||
![]() |
|
< Last Thread | Next Thread > |
Forum Rules:
|
Copyright © 1999-2020, Tomasz Grysztar. Also on GitHub, YouTube, Twitter.
Website powered by rwasa.