summaryrefslogtreecommitdiffstats
path: root/winpr/libwinpr/library/test/TestLibraryLoadLibrary.c
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-05-04 01:24:41 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-05-04 01:24:41 +0000
commita9bcc81f821d7c66f623779fa5147e728eb3c388 (patch)
tree98676963bcdd537ae5908a067a8eb110b93486a6 /winpr/libwinpr/library/test/TestLibraryLoadLibrary.c
parentInitial commit. (diff)
downloadfreerdp3-a9bcc81f821d7c66f623779fa5147e728eb3c388.tar.xz
freerdp3-a9bcc81f821d7c66f623779fa5147e728eb3c388.zip
Adding upstream version 3.3.0+dfsg1.upstream/3.3.0+dfsg1
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to '')
-rw-r--r--winpr/libwinpr/library/test/TestLibraryLoadLibrary.c51
1 files changed, 51 insertions, 0 deletions
diff --git a/winpr/libwinpr/library/test/TestLibraryLoadLibrary.c b/winpr/libwinpr/library/test/TestLibraryLoadLibrary.c
new file mode 100644
index 0000000..4bd6e7c
--- /dev/null
+++ b/winpr/libwinpr/library/test/TestLibraryLoadLibrary.c
@@ -0,0 +1,51 @@
+
+#include <stdio.h>
+#include <winpr/crt.h>
+#include <winpr/path.h>
+#include <winpr/tchar.h>
+#include <winpr/windows.h>
+#include <winpr/library.h>
+
+int TestLibraryLoadLibrary(int argc, char* argv[])
+{
+ HINSTANCE library = NULL;
+ LPCSTR SharedLibraryExtension = NULL;
+ CHAR LibraryPath[PATHCCH_MAX_CCH];
+ PCHAR p = NULL;
+ WINPR_UNUSED(argc);
+ WINPR_UNUSED(argv);
+ if (!GetModuleFileNameA(NULL, LibraryPath, PATHCCH_MAX_CCH))
+ {
+ printf("%s: GetModuleFilenameA failed: 0x%08" PRIX32 "\n", __func__, GetLastError());
+ return -1;
+ }
+
+ /* PathCchRemoveFileSpec is not implemented in WinPR */
+
+ if (!(p = strrchr(LibraryPath, PathGetSeparatorA(PATH_STYLE_NATIVE))))
+ {
+ printf("%s: Error identifying module directory path\n", __func__);
+ return -1;
+ }
+ *p = 0;
+
+ NativePathCchAppendA(LibraryPath, PATHCCH_MAX_CCH, "TestLibraryA");
+ SharedLibraryExtension = PathGetSharedLibraryExtensionA(PATH_SHARED_LIB_EXT_WITH_DOT);
+ NativePathCchAddExtensionA(LibraryPath, PATHCCH_MAX_CCH, SharedLibraryExtension);
+
+ printf("%s: Loading Library: '%s'\n", __func__, LibraryPath);
+
+ if (!(library = LoadLibraryA(LibraryPath)))
+ {
+ printf("%s: LoadLibraryA failure: 0x%08" PRIX32 "\n", __func__, GetLastError());
+ return -1;
+ }
+
+ if (!FreeLibrary(library))
+ {
+ printf("%s: FreeLibrary failure: 0x%08" PRIX32 "\n", __func__, GetLastError());
+ return -1;
+ }
+
+ return 0;
+}