Use spaces instead of tabs - sorry for the noise.

This commit is contained in:
Joachim Bauch
2013-03-09 00:42:29 +01:00
parent f210f67771
commit a199afce7c
3 changed files with 370 additions and 370 deletions
+40 -40
View File
@@ -12,59 +12,59 @@ typedef int (*addNumberProc)(int, int);
void LoadFromFile(void)
{
addNumberProc addNumber;
HINSTANCE handle = LoadLibrary(DLL_FILE);
if (handle == NULL)
return;
addNumberProc addNumber;
HINSTANCE handle = LoadLibrary(DLL_FILE);
if (handle == NULL)
return;
addNumber = (addNumberProc)GetProcAddress(handle, "addNumbers");
printf("From file: %d\n", addNumber(1, 2));
FreeLibrary(handle);
addNumber = (addNumberProc)GetProcAddress(handle, "addNumbers");
printf("From file: %d\n", addNumber(1, 2));
FreeLibrary(handle);
}
void LoadFromMemory(void)
{
FILE *fp;
unsigned char *data=NULL;
size_t size;
HMEMORYMODULE module;
addNumberProc addNumber;
fp = fopen(DLL_FILE, "rb");
if (fp == NULL)
{
printf("Can't open DLL file \"%s\".", DLL_FILE);
goto exit;
}
FILE *fp;
unsigned char *data=NULL;
size_t size;
HMEMORYMODULE module;
addNumberProc addNumber;
fp = fopen(DLL_FILE, "rb");
if (fp == NULL)
{
printf("Can't open DLL file \"%s\".", DLL_FILE);
goto exit;
}
fseek(fp, 0, SEEK_END);
size = ftell(fp);
data = (unsigned char *)malloc(size);
fseek(fp, 0, SEEK_SET);
fread(data, 1, size, fp);
fclose(fp);
fseek(fp, 0, SEEK_END);
size = ftell(fp);
data = (unsigned char *)malloc(size);
fseek(fp, 0, SEEK_SET);
fread(data, 1, size, fp);
fclose(fp);
module = MemoryLoadLibrary(data);
if (module == NULL)
{
printf("Can't load library from memory.\n");
goto exit;
}
module = MemoryLoadLibrary(data);
if (module == NULL)
{
printf("Can't load library from memory.\n");
goto exit;
}
addNumber = (addNumberProc)MemoryGetProcAddress(module, "addNumbers");
printf("From memory: %d\n", addNumber(1, 2));
MemoryFreeLibrary(module);
addNumber = (addNumberProc)MemoryGetProcAddress(module, "addNumbers");
printf("From memory: %d\n", addNumber(1, 2));
MemoryFreeLibrary(module);
exit:
if (data)
free(data);
if (data)
free(data);
}
int main(int argc, char* argv[])
{
LoadFromFile();
printf("\n\n");
LoadFromMemory();
return 0;
LoadFromFile();
printf("\n\n");
LoadFromMemory();
return 0;
}
+1 -1
View File
@@ -4,7 +4,7 @@ extern "C" {
SAMPLEDLL_API int addNumbers(int a, int b)
{
return a + b;
return a + b;
}
}