Index: /trunk/Module/mod_cgi.c
===================================================================
--- /trunk/Module/mod_cgi.c	(revision 312)
+++ /trunk/Module/mod_cgi.c	(revision 313)
@@ -5,5 +5,5 @@
 #include <cm_string.h>
 
-int mod_init(struct tw_config* config, struct tw_tool* tools) {
+int MODULE_DECL mod_init(struct tw_config* config, struct tw_tool* tools) {
 	tools->log("CGI", "Initializing CGI module");
 	tools->add_version("CGI/1.1");
@@ -11,5 +11,5 @@
 }
 
-int mod_config(struct tw_tool* tools, char** argv, int argc) {
+int MODULE_DECL mod_config(struct tw_tool* tools, char** argv, int argc) {
 	if(cm_strcaseequ(argv[0], "AllowCGI")) {
 		return TW_CONFIG_PARSED;
@@ -18,5 +18,5 @@
 }
 
-int mod_request(struct tw_tool* tools, struct tw_http_request* req, struct tw_http_response* res) {
+int MODULE_DECL mod_request(struct tw_tool* tools, struct tw_http_request* req, struct tw_http_response* res) {
 	res->status = 403;
 	return TW_MODULE_STOP;
Index: /trunk/Module/mod_example.c
===================================================================
--- /trunk/Module/mod_example.c	(revision 312)
+++ /trunk/Module/mod_example.c	(revision 313)
@@ -4,5 +4,5 @@
 #include <tw_module.h>
 
-int mod_init(struct tw_config* config, struct tw_tool* tools) {
+int MODULE_DECL mod_init(struct tw_config* config, struct tw_tool* tools) {
 	tools->log("Example", "This is an example module");
 	tools->add_version("Example/0.0");
@@ -10,5 +10,5 @@
 }
 
-int mod_config(struct tw_tool* tools, char** argv, int argc) { return TW_CONFIG_PARSED; }
+int MODULE_DECL mod_config(struct tw_tool* tools, char** argv, int argc) { return TW_CONFIG_PARSED; }
 
-int mod_request(struct tw_tool* tools, struct tw_http_request* req, struct tw_http_response* res) { return TW_MODULE_ERROR(403); }
+int MODULE_DECL mod_request(struct tw_tool* tools, struct tw_http_request* req, struct tw_http_response* res) { return TW_MODULE_ERROR(403); }
Index: /trunk/Module/mod_proxy.c
===================================================================
--- /trunk/Module/mod_proxy.c	(revision 312)
+++ /trunk/Module/mod_proxy.c	(revision 313)
@@ -5,5 +5,5 @@
 #include <cm_string.h>
 
-int mod_init(struct tw_config* config, struct tw_tool* tools) {
+int MODULE_DECL mod_init(struct tw_config* config, struct tw_tool* tools) {
 	tools->log("CGI", "Initializing Proxy module");
 	tools->add_version("Proxy/1.0");
@@ -11,5 +11,5 @@
 }
 
-int mod_config(struct tw_tool* tools, char** argv, int argc) { return TW_CONFIG_NOTME; }
+int MODULE_DECL mod_config(struct tw_tool* tools, char** argv, int argc) { return TW_CONFIG_NOTME; }
 
-int mod_request(struct tw_tool* tools, struct tw_http_request* req, struct tw_http_response* res) { return TW_MODULE_PASS; }
+int MODULE_DECL mod_request(struct tw_tool* tools, struct tw_http_request* req, struct tw_http_response* res) { return TW_MODULE_PASS; }
Index: /trunk/README
===================================================================
--- /trunk/README	(revision 312)
+++ /trunk/README	(revision 313)
@@ -45,4 +45,5 @@
 Minix                    Working
 UnixWare                 Working on 7.1.1
+OS/2                     Mostly working, module is broken. Help required!
 PlayStation Portable     Working, missing module support
                          TODO: Get multi-threading working (maybe)
Index: /trunk/README.tmpl
===================================================================
--- /trunk/README.tmpl	(revision 312)
+++ /trunk/README.tmpl	(revision 313)
@@ -45,4 +45,5 @@
 Minix                    Working
 UnixWare                 Working on 7.1.1
+OS/2                     Mostly working, module is broken. Help required!
 PlayStation Portable     Working, missing module support
                          TODO: Get multi-threading working (maybe)
Index: /trunk/Server/module.c
===================================================================
--- /trunk/Server/module.c	(revision 312)
+++ /trunk/Server/module.c	(revision 313)
@@ -30,4 +30,5 @@
 #ifdef __OS2__
 #define INCL_DOSMODULEMGR
+#define INCL_DOSERRORS
 #include <os2.h>
 #else
@@ -43,11 +44,14 @@
 	void* lib;
 	char tmp[512];
-	unsigned long l;
+#ifdef __OS2__
+	HMODULE mod;
+#endif
 	chdir(config.server_root);
 #if defined(__MINGW32__) || defined(_MSC_VER) || defined(__BORLANDC__) || defined(__WATCOMC__)
 #ifdef __OS2__
-	lib = NULL;
-	l = (unsigned long)lib;
-	DosLoadModule(tmp, 512, path, &l);
+	if(DosLoadModule(tmp, 512, path, &mod) != NO_ERROR){
+		return NULL;
+	}
+	lib = (void*)mod;
 #else
 	lib = LoadLibraryA(path);
@@ -68,5 +72,9 @@
 #ifdef __OS2__
 	void* ret;
-	DosQueryProcAddr((unsigned long)mod, 0, sym, (PFN*)&ret);
+	APIRET rc;
+	if((rc = DosQueryProcAddr((HMODULE)mod, 0, sym, (PFN*)&ret)) != NO_ERROR){
+		cm_log("Module", "OS/2 error %d", (int)rc);
+		return NULL;
+	}
 	return ret;
 #else
@@ -81,5 +89,5 @@
 	tw_mod_init_t mod_init = (tw_mod_init_t)tw_module_symbol(mod, "mod_init");
 	if(mod_init == NULL) {
-		cm_log("Module", "Could not init a module");
+		cm_log("Module", "Could not find a init call");
 		return 1;
 	} else {
Index: /trunk/Server/tw_module.h
===================================================================
--- /trunk/Server/tw_module.h	(revision 312)
+++ /trunk/Server/tw_module.h	(revision 313)
@@ -10,4 +10,13 @@
 #include "tw_config.h"
 #include "tw_http.h"
+
+#if defined(__OS2__)
+#define INCL_DOSMODULEMGR
+#define INCL_DOSERRORS
+#include <os2.h>
+#define MODULE_DECL APIENTRY
+#else
+#define MODULE_DECL
+#endif
 
 struct tw_tool {
@@ -38,7 +47,7 @@
 #define TW_CONFIG_ERROR _TW_CONFIG_ERROR
 
-typedef int (*tw_mod_init_t)(struct tw_config* config, struct tw_tool* tools);
-typedef int (*tw_mod_request_t)(struct tw_tool* tools, struct tw_http_request* req, struct tw_http_response* res);
-typedef int (*tw_mod_config_t)(struct tw_tool* tools, char** argv, int argc);
+typedef int (MODULE_DECL *tw_mod_init_t)(struct tw_config* config, struct tw_tool* tools);
+typedef int (MODULE_DECL *tw_mod_request_t)(struct tw_tool* tools, struct tw_http_request* req, struct tw_http_response* res);
+typedef int (MODULE_DECL *tw_mod_config_t)(struct tw_tool* tools, char** argv, int argc);
 
 #ifdef SOURCE
