static char *win32_merger(DSO *dso, const char *filespec1,
const char *filespec2);
static int win32_pathbyaddr(void *addr,char *path,int sz);
+static void *win32_globallookup(const char *name);
static const char *openssl_strnchr(const char *string, int c, size_t len);
win32_merger,
NULL, /* init */
NULL, /* finish */
- win32_pathbyaddr
+ win32_pathbyaddr,
+ win32_globallookup
};
DSO_METHOD *DSO_METHOD_win32(void)
goto err;
}
*p = h;
- if(!sk_push(dso->meth_data, (char *)p))
+ if(!sk_void_push(dso->meth_data, p))
{
DSOerr(DSO_F_WIN32_LOAD,DSO_R_STACK_ERROR);
goto err;
DSOerr(DSO_F_WIN32_UNLOAD,ERR_R_PASSED_NULL_PARAMETER);
return(0);
}
- if(sk_num(dso->meth_data) < 1)
+ if(sk_void_num(dso->meth_data) < 1)
return(1);
- p = (HINSTANCE *)sk_pop(dso->meth_data);
+ p = sk_void_pop(dso->meth_data);
if(p == NULL)
{
DSOerr(DSO_F_WIN32_UNLOAD,DSO_R_NULL_HANDLE);
DSOerr(DSO_F_WIN32_UNLOAD,DSO_R_UNLOAD_FAILED);
/* We should push the value back onto the stack in
* case of a retry. */
- sk_push(dso->meth_data, (char *)p);
+ sk_void_push(dso->meth_data, p);
return(0);
}
/* Cleanup */
DSOerr(DSO_F_WIN32_BIND_VAR,ERR_R_PASSED_NULL_PARAMETER);
return(NULL);
}
- if(sk_num(dso->meth_data) < 1)
+ if(sk_void_num(dso->meth_data) < 1)
{
DSOerr(DSO_F_WIN32_BIND_VAR,DSO_R_STACK_ERROR);
return(NULL);
}
- ptr = (HINSTANCE *)sk_value(dso->meth_data, sk_num(dso->meth_data) - 1);
+ ptr = sk_void_value(dso->meth_data, sk_void_num(dso->meth_data) - 1);
if(ptr == NULL)
{
DSOerr(DSO_F_WIN32_BIND_VAR,DSO_R_NULL_HANDLE);
DSOerr(DSO_F_WIN32_BIND_FUNC,ERR_R_PASSED_NULL_PARAMETER);
return(NULL);
}
- if(sk_num(dso->meth_data) < 1)
+ if(sk_void_num(dso->meth_data) < 1)
{
DSOerr(DSO_F_WIN32_BIND_FUNC,DSO_R_STACK_ERROR);
return(NULL);
}
- ptr = (HINSTANCE *)sk_value(dso->meth_data, sk_num(dso->meth_data) - 1);
+ ptr = sk_void_value(dso->meth_data, sk_void_num(dso->meth_data) - 1);
if(ptr == NULL)
{
DSOerr(DSO_F_WIN32_BIND_FUNC,DSO_R_NULL_HANDLE);
DSOerr(DSO_F_WIN32_SPLITTER,
DSO_R_INCORRECT_FILE_SYNTAX);
/*goto err;*/
+ OPENSSL_free(result);
return(NULL);
}
result->device = start;
- result->devicelen = filename - start;
+ result->devicelen = (int)(filename - start);
position = IN_FILE;
start = ++filename;
result->dir = start;
case '/':
if(position == IN_NODE)
{
- result->nodelen = filename - start;
+ result->nodelen = (int)(filename - start);
position = IN_FILE;
start = ++filename;
result->dir = start;
position = IN_FILE;
filename++;
result->dir = start;
- result->dirlen = filename - start;
+ result->dirlen = (int)(filename - start);
start = filename;
}
else
{
filename++;
- result->dirlen += filename - start;
+ result->dirlen += (int)(filename - start);
start = filename;
}
break;
case '\0':
if(position == IN_NODE)
{
- result->nodelen = filename - start;
+ result->nodelen = (int)(filename - start);
}
else
{
result->dirlen = 0;
}
result->dirlen +=
- filename - start;
+ (int)(filename - start);
}
else
{
result->file = start;
result->filelen =
- filename - start;
+ (int)(filename - start);
}
}
}
+ file_split->predirlen
- (start - file_split->predir);
strncpy(&result[offset], start,
- end - start); offset += end - start;
+ end - start); offset += (int)(end - start);
result[offset] = '\\'; offset++;
start = end + 1;
}
+ file_split->dirlen
- (start - file_split->dir);
strncpy(&result[offset], start,
- end - start); offset += end - start;
+ end - start); offset += (int)(end - start);
result[offset] = '\\'; offset++;
start = end + 1;
}
}
else
{
- filespec1_split = win32_splitter(dso, filespec1, 1);
+ filespec1_split = win32_splitter(dso, filespec1, 0);
if (!filespec1_split)
{
DSOerr(DSO_F_WIN32_MERGER,
ERR_R_MALLOC_FAILURE);
return(NULL);
}
- filespec2_split = win32_splitter(dso, filespec2, 0);
+ filespec2_split = win32_splitter(dso, filespec2, 1);
if (!filespec2_split)
{
DSOerr(DSO_F_WIN32_MERGER,
merged = win32_joiner(dso, filespec1_split);
}
+ OPENSSL_free(filespec1_split);
+ OPENSSL_free(filespec2_split);
return(merged);
}
CREATETOOLHELP32SNAPSHOT create_snap;
CLOSETOOLHELP32SNAPSHOT close_snap;
MODULE32 module_first, module_next;
- int len;
if (addr == NULL)
{
dll = LoadLibrary(TEXT(DLLNAME));
if (dll == NULL)
{
- DSOerr(DSO_F_PATHBYADDR,DSO_R_UNSUPPORTED);
+ DSOerr(DSO_F_WIN32_PATHBYADDR,DSO_R_UNSUPPORTED);
return -1;
}
if (create_snap == NULL)
{
FreeLibrary(dll);
- DSOerr(DSO_F_PATHBYADDR,DSO_R_UNSUPPORTED);
+ DSOerr(DSO_F_WIN32_PATHBYADDR,DSO_R_UNSUPPORTED);
return -1;
}
/* We take the rest for granted... */
if( hModuleSnap == INVALID_HANDLE_VALUE )
{
FreeLibrary(dll);
- DSOerr(DSO_F_PATHBYADDR,DSO_R_UNSUPPORTED);
+ DSOerr(DSO_F_WIN32_PATHBYADDR,DSO_R_UNSUPPORTED);
return -1;
}
{
(*close_snap)(hModuleSnap);
FreeLibrary(dll);
- DSOerr(DSO_F_PATHBYADDR,DSO_R_FAILURE);
+ DSOerr(DSO_F_WIN32_PATHBYADDR,DSO_R_FAILURE);
return -1;
}
return WideCharToMultiByte(CP_ACP,0,me32.szExePath,-1,
path,sz,NULL,NULL);
# else
- len = (int)wcslen(me32.szExePath);
+ {
+ int i,len = (int)wcslen(me32.szExePath);
if (sz <= 0) return len+1;
if (len >= sz) len=sz-1;
for(i=0;i<len;i++)
path[i] = (char)me32.szExePath[i];
path[len++] = 0;
return len;
+ }
# endif
#else
- len = (int)strlen(me32.szExePath);
+ {
+ int len = (int)strlen(me32.szExePath);
if (sz <= 0) return len+1;
if (len >= sz) len=sz-1;
memcpy(path,me32.szExePath,len);
path[len++] = 0;
return len;
+ }
#endif
}
} while((*module_next)(hModuleSnap, &me32));
FreeLibrary(dll);
return 0;
}
+
+static void *win32_globallookup(const char *name)
+ {
+ HMODULE dll;
+ HANDLE hModuleSnap = INVALID_HANDLE_VALUE;
+ MODULEENTRY32 me32;
+ CREATETOOLHELP32SNAPSHOT create_snap;
+ CLOSETOOLHELP32SNAPSHOT close_snap;
+ MODULE32 module_first, module_next;
+ FARPROC ret=NULL;
+
+ dll = LoadLibrary(TEXT(DLLNAME));
+ if (dll == NULL)
+ {
+ DSOerr(DSO_F_WIN32_GLOBALLOOKUP,DSO_R_UNSUPPORTED);
+ return NULL;
+ }
+
+ create_snap = (CREATETOOLHELP32SNAPSHOT)
+ GetProcAddress(dll,"CreateToolhelp32Snapshot");
+ if (create_snap == NULL)
+ {
+ FreeLibrary(dll);
+ DSOerr(DSO_F_WIN32_GLOBALLOOKUP,DSO_R_UNSUPPORTED);
+ return NULL;
+ }
+ /* We take the rest for granted... */
+#ifdef _WIN32_WCE
+ close_snap = (CLOSETOOLHELP32SNAPSHOT)
+ GetProcAddress(dll,"CloseToolhelp32Snapshot");
+#else
+ close_snap = (CLOSETOOLHELP32SNAPSHOT)CloseHandle;
+#endif
+ module_first = (MODULE32)GetProcAddress(dll,"Module32First");
+ module_next = (MODULE32)GetProcAddress(dll,"Module32Next");
+
+ hModuleSnap = (*create_snap)(TH32CS_SNAPMODULE,0);
+ if( hModuleSnap == INVALID_HANDLE_VALUE )
+ {
+ FreeLibrary(dll);
+ DSOerr(DSO_F_WIN32_GLOBALLOOKUP,DSO_R_UNSUPPORTED);
+ return NULL;
+ }
+
+ me32.dwSize = sizeof(me32);
+
+ if (!(*module_first)(hModuleSnap,&me32))
+ {
+ (*close_snap)(hModuleSnap);
+ FreeLibrary(dll);
+ return NULL;
+ }
+
+ do {
+ if ((ret = GetProcAddress(me32.hModule,name)))
+ {
+ (*close_snap)(hModuleSnap);
+ FreeLibrary(dll);
+ return ret;
+ }
+ } while((*module_next)(hModuleSnap,&me32));
+
+ (*close_snap)(hModuleSnap);
+ FreeLibrary(dll);
+ return NULL;
+ }
#endif /* DSO_WIN32 */