diff --git a/example/DllLoader/DllLoader.cpp b/example/DllLoader/DllLoader.cpp index f65bb80..944ac98 100644 --- a/example/DllLoader/DllLoader.cpp +++ b/example/DllLoader/DllLoader.cpp @@ -9,7 +9,7 @@ typedef int (*addNumberProc)(int, int); -#define DLL_FILE "..\\SampleDLL\\SampleDLL.dll" +#define DLL_FILE _T("..\\SampleDLL\\SampleDLL.dll") void LoadFromFile(void) { @@ -24,20 +24,20 @@ void LoadFromFile(void) return; addNumber = (addNumberProc)GetProcAddress(handle, "addNumbers"); - printf("From file: %d\n", addNumber(1, 2)); + _tprintf(_T("From file: %d\n"), addNumber(1, 2)); resourceInfo = FindResource(handle, MAKEINTRESOURCE(VS_VERSION_INFO), RT_VERSION); - printf("FindResource returned 0x%p\n", resourceInfo); + _tprintf(_T("FindResource returned 0x%p\n"), resourceInfo); resourceSize = SizeofResource(handle, resourceInfo); resourceData = LoadResource(handle, resourceInfo); - printf("Resource data: %ld bytes at 0x%p\n", resourceSize, resourceData); + _tprintf(_T("Resource data: %ld bytes at 0x%p\n"), resourceSize, resourceData); LoadString(handle, 1, buffer, sizeof(buffer)); - printf("String1: %s\n", buffer); + _tprintf(_T("String1: %s\n"), buffer); LoadString(handle, 20, buffer, sizeof(buffer)); - printf("String2: %s\n", buffer); + _tprintf(_T("String2: %s\n"), buffer); FreeLibrary(handle); } @@ -54,10 +54,10 @@ void LoadFromMemory(void) LPVOID resourceData; _TCHAR buffer[100]; - fp = fopen(DLL_FILE, "rb"); + fp = _tfopen(DLL_FILE, _T("rb")); if (fp == NULL) { - printf("Can't open DLL file \"%s\".", DLL_FILE); + _tprintf(_T("Can't open DLL file \"%s\"."), DLL_FILE); goto exit; } @@ -71,25 +71,25 @@ void LoadFromMemory(void) handle = MemoryLoadLibrary(data); if (handle == NULL) { - printf("Can't load library from memory.\n"); + _tprintf(_T("Can't load library from memory.\n")); goto exit; } addNumber = (addNumberProc)MemoryGetProcAddress(handle, "addNumbers"); - printf("From memory: %d\n", addNumber(1, 2)); + _tprintf(_T("From memory: %d\n"), addNumber(1, 2)); resourceInfo = MemoryFindResource(handle, MAKEINTRESOURCE(VS_VERSION_INFO), RT_VERSION); - printf("MemoryFindResource returned 0x%p\n", resourceInfo); + _tprintf(_T("MemoryFindResource returned 0x%p\n"), resourceInfo); resourceSize = MemorySizeofResource(handle, resourceInfo); resourceData = MemoryLoadResource(handle, resourceInfo); - printf("Memory resource data: %ld bytes at 0x%p\n", resourceSize, resourceData); + _tprintf(_T("Memory resource data: %ld bytes at 0x%p\n"), resourceSize, resourceData); MemoryLoadString(handle, 1, buffer, sizeof(buffer)); - printf("String1: %s\n", buffer); + _tprintf(_T("String1: %s\n"), buffer); MemoryLoadString(handle, 20, buffer, sizeof(buffer)); - printf("String2: %s\n", buffer); + _tprintf(_T("String2: %s\n"), buffer); MemoryFreeLibrary(handle); diff --git a/example/DllLoader/Makefile b/example/DllLoader/Makefile index 35c3d8f..92fbd0a 100644 --- a/example/DllLoader/Makefile +++ b/example/DllLoader/Makefile @@ -17,6 +17,10 @@ RM = rm CFLAGS = -Wall -g LDFLAGS = +ifdef UNICODE +CFLAGS += -DUNICODE -D_UNICODE +endif + OBJ = DllLoader.o ../../MemoryModule.o DllLoader.exe: $(OBJ) diff --git a/example/SampleDLL/Makefile b/example/SampleDLL/Makefile index 78c5e1e..6ab5629 100644 --- a/example/SampleDLL/Makefile +++ b/example/SampleDLL/Makefile @@ -20,6 +20,10 @@ CFLAGS = -Wall -g -DSAMPLEDLL_EXPORTS LDFLAGS = -shared RCFLAGS = -O coff +ifdef UNICODE +CFLAGS += -DUNICODE -D_UNICODE +endif + OBJ = SampleDLL.o SampleDLL.res SampleDLL.dll: $(OBJ)