Support unicode compilation

This commit is contained in:
Joachim Bauch
2013-03-12 01:02:10 +01:00
parent 390efc33a1
commit a064d0e636
3 changed files with 22 additions and 14 deletions
+14 -14
View File
@@ -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);
+4
View File
@@ -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)
+4
View File
@@ -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)