SQLite Forum

Using sqlite3_load_extension on windows
I found that if the entry point was declared with __stdcall the function name had no leading underscore in dependency walker. Thought that was that but alas no. Using the code below, line // 1 doesn't return SQLITE_OK and line // 2 gives an exception with message "privileged instruction at 0x004f158a" in console.exe. I've googled the error but I can't see anything that would cause a memory overwrite.

lite32c.dll file
#include <sqlite3ext.h>


#ifdef _WIN32
__stdcall __declspec(dllexport)

int sqlite3_lite32c_init(
  sqlite3 *db,
  char **pzErrMsg,
  const sqlite3_api_routines *pApi
  int rc = SQLITE_OK;

  return rc;
console.exe file
#ifdef _WIN32
#include <tchar.h>
  typedef char _TCHAR;
  #define _tmain main

#include "sqlite3.c"
int _tmain(int argc, _TCHAR* argv[])
  sqlite3 *db;
  int rc;
  rc=sqlite3_load_extension(db,"c:/temp/Win32/Debug/lite32c.dll",0,0); // 1
  rc=sqlite3_load_extension(db,"c:/temp/Win32/Debug/lite32c.dll",      // 2
  return 0;