diff options
-rw-r--r-- | src/compat/win32.cpp | 22 | ||||
-rw-r--r-- | src/compat/win32.h | 2 | ||||
-rw-r--r-- | src/plugger.h | 18 |
3 files changed, 34 insertions, 8 deletions
diff --git a/src/compat/win32.cpp b/src/compat/win32.cpp index 6fcac15..052644a 100644 --- a/src/compat/win32.cpp +++ b/src/compat/win32.cpp | |||
@@ -162,5 +162,27 @@ int Bu::Winsock2::__WSAFDIsSet( SOCKET s, fd_set *set ) { | |||
162 | return (*Bu::Winsock2::_fnptr___WSAFDIsSet)( s, set ); | 162 | return (*Bu::Winsock2::_fnptr___WSAFDIsSet)( s, set ); |
163 | } | 163 | } |
164 | 164 | ||
165 | Bu::FString Bu::getLastWinError() | ||
166 | { | ||
167 | LPVOID lpMsgBuf; | ||
168 | DWORD dw = GetLastError(); | ||
169 | |||
170 | FormatMessageA( | ||
171 | FORMAT_MESSAGE_ALLOCATE_BUFFER | | ||
172 | FORMAT_MESSAGE_FROM_SYSTEM | | ||
173 | FORMAT_MESSAGE_IGNORE_INSERTS, | ||
174 | NULL, | ||
175 | dw, | ||
176 | MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), | ||
177 | (LPSTR) &lpMsgBuf, | ||
178 | 0, NULL ); | ||
179 | |||
180 | Bu::FString sRet( (char *)lpMsgBuf ); | ||
181 | |||
182 | LocalFree(lpMsgBuf); | ||
183 | |||
184 | return sRet; | ||
185 | } | ||
186 | |||
165 | #endif | 187 | #endif |
166 | 188 | ||
diff --git a/src/compat/win32.h b/src/compat/win32.h index 6304d4c..ea0ae53 100644 --- a/src/compat/win32.h +++ b/src/compat/win32.h | |||
@@ -89,6 +89,8 @@ namespace Bu | |||
89 | static char scode[15]; | 89 | static char scode[15]; |
90 | static char *gai_strerror( int iCode ); | 90 | static char *gai_strerror( int iCode ); |
91 | }; | 91 | }; |
92 | |||
93 | Bu::FString getLastWinError(); | ||
92 | }; | 94 | }; |
93 | 95 | ||
94 | #ifdef FD_ISSET | 96 | #ifdef FD_ISSET |
diff --git a/src/plugger.h b/src/plugger.h index 37d6f19..2780356 100644 --- a/src/plugger.h +++ b/src/plugger.h | |||
@@ -14,6 +14,8 @@ | |||
14 | #include "bu/fstring.h" | 14 | #include "bu/fstring.h" |
15 | #include <stddef.h> | 15 | #include <stddef.h> |
16 | 16 | ||
17 | #include "bu/config.h" | ||
18 | |||
17 | #ifdef WIN32 | 19 | #ifdef WIN32 |
18 | # include <windows.h> | 20 | # include <windows.h> |
19 | #else | 21 | #else |
@@ -197,29 +199,29 @@ namespace Bu | |||
197 | pReg->dlHandle = LoadLibrary( sFName.getStr() ); | 199 | pReg->dlHandle = LoadLibrary( sFName.getStr() ); |
198 | if( pReg->dlHandle == NULL ) | 200 | if( pReg->dlHandle == NULL ) |
199 | { | 201 | { |
200 | throw PluginException( 1, "Error opening %s: %s", sFName.getStr(), | 202 | throw PluginException( 1, "Error opening %s: %s", |
201 | "unknown error, fix this for windows" ); | 203 | sFName.getStr(), Bu::getLastWinError().getStr() ); |
202 | } | 204 | } |
203 | pReg->pInfo = (PluginInfo *)GetProcAddress( pReg->dlHandle, | 205 | pReg->pInfo = (PluginInfo *)GetProcAddress( pReg->dlHandle, |
204 | sPluginName.getStr() ); | 206 | sPluginName.getStr() ); |
205 | if( pReg->pInfo == NULL ) | 207 | if( pReg->pInfo == NULL ) |
206 | { | 208 | { |
207 | throw PluginException( 2, "Error mapping %s: %s", sFName.getStr(), | 209 | throw PluginException( 2, "Error mapping %s: %s", |
208 | "unknown error, fix this for windows" ); | 210 | sFName.getStr(), Bu::getLastWinError().getStr() ); |
209 | } | 211 | } |
210 | #else | 212 | #else |
211 | pReg->dlHandle = dlopen( sFName.getStr(), RTLD_NOW ); | 213 | pReg->dlHandle = dlopen( sFName.getStr(), RTLD_NOW ); |
212 | if( pReg->dlHandle == NULL ) | 214 | if( pReg->dlHandle == NULL ) |
213 | { | 215 | { |
214 | throw PluginException( 1, "Error opening %s: %s", sFName.getStr(), | 216 | throw PluginException( 1, "Error opening %s: %s", |
215 | dlerror() ); | 217 | sFName.getStr(), dlerror() ); |
216 | } | 218 | } |
217 | pReg->pInfo = (PluginInfo *)dlsym( pReg->dlHandle, | 219 | pReg->pInfo = (PluginInfo *)dlsym( pReg->dlHandle, |
218 | sPluginName.getStr() ); | 220 | sPluginName.getStr() ); |
219 | if( pReg->pInfo == NULL ) | 221 | if( pReg->pInfo == NULL ) |
220 | { | 222 | { |
221 | throw PluginException( 2, "Error mapping %s: %s", sFName.getStr(), | 223 | throw PluginException( 2, "Error mapping %s: %s", |
222 | dlerror() ); | 224 | sFName.getStr(), dlerror() ); |
223 | } | 225 | } |
224 | #endif | 226 | #endif |
225 | hPlugin.insert( pReg->pInfo->sID, pReg ); | 227 | hPlugin.insert( pReg->pInfo->sID, pReg ); |