Download Pelles C here: http://www.pellesc.se
.386
.model flat,stdcall
option casemap:none
include SMCtest.inc
.data
str1 db '80 + 20 = %u',0
.code
start:
call main
invoke ExitProcess,0
main PROC USES esi edi ebx
LOCAL pMem:DWORD
invoke VirtualAlloc,0,4096,\
MEM_COMMIT or MEM_RESERVE,\
PAGE_EXECUTE_READWRITE
mov pMem,eax
mov edi,eax
mov esi,OFFSET Calculate
mov ecx,ProcLen
rep movsb ; Copy the procedure Calculate
; to virtual address space
lea ecx,[eax+4]
; Modify the procedure
mov BYTE PTR [ecx],_ADD
push 80
push 20
call eax
invoke printf,ADDR str1,eax
invoke VirtualFree,pMem,0,MEM_RELEASE
ret
main ENDP
OPTION PROLOGUE:NONE
OPTION EPILOGUE:NONE
Calculate PROC a:DWORD,b:DWORD
mov eax,DWORD PTR [esp+8]
sub eax,DWORD PTR [esp+4]
retn 2*4
Calculate ENDP
OPTION PROLOGUE:PrologueDef
OPTION EPILOGUE:EpilogueDef
END start
.386
.model flat,stdcall
option casemap:none
.code
call main
ret
main PROC
mov eax,OFFSET sample
ret
main ENDP
sample:
db 'This is a test.',0
END
\PellesC\bin\poasm.exe /AIA32 sample.asm
sample.asm(12): error: Symbol 'sample' is undefined.
sample.asm(12): error: Symbol 'main.sample' is undefined.
Quote from: ander_cc on May 02, 2026, 06:03:06 AMThere are two header files in folder "Include/win/winsqlite/": winsqlite3.h and winsqlite3ext.h.
But no related .lib files are included in folder "Lib".
Is this a deprecated feature?
#include <stdio.h>
#include <stdlib.h>
//#include "sqlite3.h"
#include <winsqlite/winsqlite3.h>
#pragma comment(lib, "WinSQLite3.lib")
int __cdecl main(int argc, char **argv)
{
sqlite3 *db;
int rc;
char *szSQL =
"DROP TABLE IF EXISTS test;"
"CREATE TABLE IF NOT EXISTS test (id INTEGER NOT NULL PRIMARY KEY, text VARCHAR(100));"
"INSERT INTO test VALUES (1, 'text1');"
"SELECT * FROM test;";
char *pSQL1, *pSQL2;
printf("lib version: %u\n", sqlite3_libversion_number());
rc = sqlite3_open("test.db3", &db);
if (rc == SQLITE_OK)
{
sqlite3_stmt *stmt;
pSQL1 = szSQL; // at start
do
{
rc = sqlite3_prepare_v2(db, pSQL1, -1, &stmt, (const char**)&pSQL2);
if (rc == SQLITE_OK)
{
int nCols = sqlite3_column_count(stmt);
if (nCols)
{
int nCol;
for (nCol = 0; nCol < nCols; nCol++)
printf("%s\t", sqlite3_column_name(stmt, nCol));
printf("\n");
while ((rc = sqlite3_step(stmt)) == SQLITE_ROW)
for (nCol = 0; nCol < nCols; nCol++)
printf("%s\t", sqlite3_column_text(stmt, nCol));
printf("\n");
}
sqlite3_finalize(stmt);
} else {
fprintf(stderr, "Error: %s\n", sqlite3_errmsg(db));
break;
}
pSQL1 = pSQL2; // next statement
} while (*pSQL2);
sqlite3_close(db);
} else {
fprintf(stderr, "Can't open database: %s\n", sqlite3_errmsg(db));
sqlite3_close(db);
return 1;
}
return 0;
}
after that just use polib.exe to create import library.library winsqlite3.dll
exports
_sqlite3_libversion_number@0
_sqlite3_open@8
_sqlite3_prepare_v2@20
_sqlite3_column_count@4
_sqlite3_column_name@8
_sqlite3_column_text@8
_sqlite3_step@4
_sqlite3_finalize@4
_sqlite3_errmsg@4
_sqlite3_close@4
Quote from: John Z on May 02, 2026, 04:48:07 PMWell I'm far from an expert but I have used a dll in a program.Many thanks for your detailed explanation. I will try.
basically the use follows this:
1)LoadLibrary: Loads the DLL into memory.
2)repeat GetProcAddress: Get a pointers to the exported functions.
3)use the functions:
4)FreeLibrary: Unloads the DLL when done.
A quick web example where the dll contains 1 function:
__declspec(dllexport) int Add(int a, int b) {return a + b};
some code excerpts from one of my actual programs
Hopefully helpful, at least a start -
John Z
Page created in 0.048 seconds with 15 queries.