Commit 66d31e1f048e8d90d614c19fbcdabc028c431bc7
1 parent
20f4c5d0
Exists in
master
and in
1 other branch
Fixing load of delayed library.
Showing
3 changed files
with
34 additions
and
39 deletions
Show diff stats
client/src/session/local/session.cc
| @@ -69,6 +69,8 @@ | @@ -69,6 +69,8 @@ | ||
| 69 | 69 | ||
| 70 | HANDLE hEventLog = RegisterEventSource(NULL, PACKAGE_NAME); | 70 | HANDLE hEventLog = RegisterEventSource(NULL, PACKAGE_NAME); |
| 71 | 71 | ||
| 72 | + debug(msg," rc=",rc); | ||
| 73 | + | ||
| 72 | if(hEventLog) { | 74 | if(hEventLog) { |
| 73 | 75 | ||
| 74 | char username[UNLEN + 1]; | 76 | char username[UNLEN + 1]; |
| @@ -142,8 +144,7 @@ | @@ -142,8 +144,7 @@ | ||
| 142 | if(!initialized) { | 144 | if(!initialized) { |
| 143 | 145 | ||
| 144 | // Get application DATADIR | 146 | // Get application DATADIR |
| 145 | - | ||
| 146 | - // https://github.com/curl/curl/blob/master/lib/system_win32.c | 147 | + LSTATUS rc; |
| 147 | 148 | ||
| 148 | char datadir[4096]; | 149 | char datadir[4096]; |
| 149 | HKEY hKey = openKey(); | 150 | HKEY hKey = openKey(); |
| @@ -155,55 +156,48 @@ | @@ -155,55 +156,48 @@ | ||
| 155 | 156 | ||
| 156 | unsigned long datatype; // #defined in winnt.h (predefined types 0-11) | 157 | unsigned long datatype; // #defined in winnt.h (predefined types 0-11) |
| 157 | 158 | ||
| 158 | - if(RegQueryValueExA(hKey,"InstallLocation",NULL,&datatype,(LPBYTE) datadir,&datalen) != ERROR_SUCCESS) { | 159 | + rc = RegQueryValueExA(hKey,"InstallLocation",NULL,&datatype,(LPBYTE) datadir,&datalen); |
| 160 | + if(rc != ERROR_SUCCESS) { | ||
| 159 | 161 | ||
| 160 | // Can't get DATADIR | 162 | // Can't get DATADIR |
| 163 | + write_log("Can't get Install Location", (int) rc); | ||
| 161 | 164 | ||
| 162 | *datadir = 0; | 165 | *datadir = 0; |
| 163 | } | 166 | } |
| 164 | - | ||
| 165 | RegCloseKey(hKey); | 167 | RegCloseKey(hKey); |
| 166 | 168 | ||
| 167 | } | 169 | } |
| 168 | 170 | ||
| 169 | - if(*datadir) { | ||
| 170 | - | ||
| 171 | - HMODULE kernel = | ||
| 172 | - LoadLibrary("kernel32.dll"); | ||
| 173 | - | ||
| 174 | - if(kernel) { | ||
| 175 | - | ||
| 176 | - HANDLE WINAPI (*AddDllDirectory)(PCWSTR) = | ||
| 177 | - (HANDLE WINAPI (*)(PCWSTR)) GetProcAddress(kernel,"AddDllDirectory"); | ||
| 178 | - | ||
| 179 | - //BOOL WINAPI (*RemoveDllDirectory)(HANDLE) = | ||
| 180 | - // (BOOL WINAPI (*)(HANDLE)) GetProcAddress(kernel,"RemoveDllDirectory"); | ||
| 181 | - | ||
| 182 | - if(AddDllDirectory) { | ||
| 183 | - | ||
| 184 | - wchar_t *path = (wchar_t *) malloc(sizeof(datadir)*sizeof(wchar_t)); | ||
| 185 | - mbstowcs(path, datadir, 4095); | ||
| 186 | - | ||
| 187 | - if(!AddDllDirectory(path)) { | ||
| 188 | - write_log("AddDllDirectory has failed"); | ||
| 189 | - } | ||
| 190 | - | ||
| 191 | - free(path); | ||
| 192 | - | ||
| 193 | - } else { | ||
| 194 | - | ||
| 195 | - write_log("Can't find AddDllDirectory@kernel32.dll"); | ||
| 196 | - | ||
| 197 | - } | ||
| 198 | - | ||
| 199 | - FreeLibrary(kernel); | 171 | +#ifdef DEBUG |
| 172 | + debug("Datadir=\"",datadir,"\""); | ||
| 173 | +#endif // DEBUG | ||
| 200 | 174 | ||
| 175 | + if(*datadir) { | ||
| 201 | 176 | ||
| 202 | - } else { | 177 | + wchar_t *path = (wchar_t *) malloc(sizeof(datadir)*sizeof(wchar_t)); |
| 178 | + mbstowcs(path, datadir, 4095); | ||
| 203 | 179 | ||
| 204 | - write_log("Can't load kernel32.dll"); | 180 | + if(!SetDefaultDllDirectories(LOAD_LIBRARY_SEARCH_USER_DIRS)) { |
| 181 | + write_log("SetDefaultDllDirectories has failed"); | ||
| 182 | + } | ||
| 183 | +#ifdef DEBUG | ||
| 184 | + else { | ||
| 185 | + debug("SetDefaultDllDirectories has suceeded"); | ||
| 186 | + } | ||
| 187 | +#endif | ||
| 205 | 188 | ||
| 189 | + if(!AddDllDirectory(path)) { | ||
| 190 | + string msg = "Can't add "; | ||
| 191 | + msg += datadir; | ||
| 192 | + msg += " to directory path"; | ||
| 193 | + write_log(msg.c_str()); | ||
| 206 | } | 194 | } |
| 195 | +#ifdef DEBUG | ||
| 196 | + else { | ||
| 197 | + debug("AddDllDirectory has suceeded"); | ||
| 198 | + } | ||
| 199 | +#endif | ||
| 200 | + free(path); | ||
| 207 | 201 | ||
| 208 | } | 202 | } |
| 209 | 203 | ||
| @@ -215,6 +209,7 @@ | @@ -215,6 +209,7 @@ | ||
| 215 | #endif // _WIN32 | 209 | #endif // _WIN32 |
| 216 | 210 | ||
| 217 | this->hSession = lib3270_session_new(""); | 211 | this->hSession = lib3270_session_new(""); |
| 212 | + | ||
| 218 | lib3270_set_user_data(this->hSession,(void *) this); | 213 | lib3270_set_user_data(this->hSession,(void *) this); |
| 219 | setCharSet(lib3270_get_display_charset(this->hSession)); | 214 | setCharSet(lib3270_get_display_charset(this->hSession)); |
| 220 | 215 |
client/src/testprogram/testprogram.cc
| @@ -46,7 +46,7 @@ | @@ -46,7 +46,7 @@ | ||
| 46 | 46 | ||
| 47 | int main(int argc, char **argv) { | 47 | int main(int argc, char **argv) { |
| 48 | 48 | ||
| 49 | - const char * session = "pw3270:a"; | 49 | + const char * session = ""; // "pw3270:a"; |
| 50 | 50 | ||
| 51 | #pragma GCC diagnostic push | 51 | #pragma GCC diagnostic push |
| 52 | #pragma GCC diagnostic ignored "-Wzero-as-null-pointer-constant" | 52 | #pragma GCC diagnostic ignored "-Wzero-as-null-pointer-constant" |
configure.ac
| @@ -80,7 +80,7 @@ case "$host" in | @@ -80,7 +80,7 @@ case "$host" in | ||
| 80 | *-mingw32|*-pc-msys) | 80 | *-mingw32|*-pc-msys) |
| 81 | app_cv_osname="windows" | 81 | app_cv_osname="windows" |
| 82 | CFLAGS="$CFLAGS -D_WIN32_WINNT=0x0600" | 82 | CFLAGS="$CFLAGS -D_WIN32_WINNT=0x0600" |
| 83 | - LIBS="$LIBS -lws2_32 -lwtsapi32 -lcomdlg32" | 83 | + LIBS="$LIBS -lws2_32 -lwtsapi32 -lcomdlg32 -lkernel32" |
| 84 | LDFLAGS="$LDFLAGS" | 84 | LDFLAGS="$LDFLAGS" |
| 85 | STATIC_LDFLAGS="-static -static-libgcc -static-libstdc++" | 85 | STATIC_LDFLAGS="-static -static-libgcc -static-libstdc++" |
| 86 | DLLEXT=".dll" | 86 | DLLEXT=".dll" |