Since I have to write a small library in Assembler that accesses a Sqlite3 Database, I have started a search on how to use the sqlite3.dll. I have found a way to do that in fasm (I have to use masm32 for numerous reasons that do not contribute to solving the problem, it simply is a necessity) via cinvoke
and referencing the library which is not available as it seems.
What I would basically like to know is whether it is possible for me to do a similar thing in masm or if I have to get the Addresses of every function I need to call individually via GetProcAddress
.
Why wouldn't it? It is simple, as simple as the following:
.486
.model flat, stdcall
option casemap:none
include \masm32\include\masm32.inc
include \masm32\include\kernel32.inc
include \masm32\include\user32.inc
include sqlite3.inc
.data
szSQLDB db "MyDB.db3", 0
szRandQuery db "SELECT * FROM Quit ORDER BY RANDOM() LIMIT 1;", 0
.data?
hDBase dd ?
.code
START:
invoke sqlite3_open, offset szSQLDB, offset hDBase
call GetQuitMsg
invoke sqlite3_close, hDBase
invoke ExitProcess, 0
GetQuitMsg proc
local ppStmt
invoke sqlite3_prepare_v2, hDBase, offset szRandQuery, -1, addr ppStmt, 0
invoke sqlite3_step, ppStmt
invoke sqlite3_data_count, ppStmt
.if eax !=0
invoke sqlite3_column_text, ppStmt, 0
invoke MessageBoxA, 0, eax, 0,0
.endif
ret
GetQuitMsg endp
end START
I use a makefile, and Geany as my editor. The zip includes the test db, sqlite3.inc, but not the sqlite3.dll just unzip files, plop the sqlite3.dll into project directory and you will be good to go. I also do not use the MS link, instead I use GoLink as it does not need import libs, but if you have to use the MS Link, I have a SQLite import library around here somewhere.