Skip to content

Commit 905ad75

Browse files
committed
Expose default callback functions.
This was suggested in #33.
1 parent 2e193f1 commit 905ad75

File tree

2 files changed

+28
-4
lines changed

2 files changed

+28
-4
lines changed

MemoryModule.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -423,7 +423,7 @@ BuildImportTable(PMEMORYMODULE module)
423423
return result;
424424
}
425425

426-
static HCUSTOMMODULE _LoadLibrary(LPCSTR filename, void *userdata)
426+
HCUSTOMMODULE MemoryDefaultLoadLibrary(LPCSTR filename, void *userdata)
427427
{
428428
HMODULE result;
429429
UNREFERENCED_PARAMETER(userdata);
@@ -435,21 +435,21 @@ static HCUSTOMMODULE _LoadLibrary(LPCSTR filename, void *userdata)
435435
return (HCUSTOMMODULE) result;
436436
}
437437

438-
static FARPROC _GetProcAddress(HCUSTOMMODULE module, LPCSTR name, void *userdata)
438+
FARPROC MemoryDefaultGetProcAddress(HCUSTOMMODULE module, LPCSTR name, void *userdata)
439439
{
440440
UNREFERENCED_PARAMETER(userdata);
441441
return (FARPROC) GetProcAddress((HMODULE) module, name);
442442
}
443443

444-
static void _FreeLibrary(HCUSTOMMODULE module, void *userdata)
444+
void MemoryDefaultFreeLibrary(HCUSTOMMODULE module, void *userdata)
445445
{
446446
UNREFERENCED_PARAMETER(userdata);
447447
FreeLibrary((HMODULE) module);
448448
}
449449

450450
HMEMORYMODULE MemoryLoadLibrary(const void *data, size_t size)
451451
{
452-
return MemoryLoadLibraryEx(data, size, _LoadLibrary, _GetProcAddress, _FreeLibrary, NULL);
452+
return MemoryLoadLibraryEx(data, size, MemoryDefaultLoadLibrary, MemoryDefaultGetProcAddress, MemoryDefaultFreeLibrary, NULL);
453453
}
454454

455455
HMEMORYMODULE MemoryLoadLibraryEx(const void *data, size_t size,

MemoryModule.h

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -117,6 +117,30 @@ int MemoryLoadString(HMEMORYMODULE, UINT, LPTSTR, int);
117117
*/
118118
int MemoryLoadStringEx(HMEMORYMODULE, UINT, LPTSTR, int, WORD);
119119

120+
/**
121+
* Default implementation of CustomLoadLibraryFunc that calls LoadLibraryA
122+
* internally to load an additional libary.
123+
*
124+
* This is the default as used by MemoryLoadLibrary.
125+
*/
126+
HCUSTOMMODULE MemoryDefaultLoadLibrary(LPCSTR, void *);
127+
128+
/**
129+
* Default implementation of CustomGetProcAddressFunc that calls GetProcAddress
130+
* internally to get the address of an exported function.
131+
*
132+
* This is the default as used by MemoryLoadLibrary.
133+
*/
134+
FARPROC MemoryDefaultGetProcAddress(HCUSTOMMODULE, LPCSTR, void *);
135+
136+
/**
137+
* Default implementation of CustomFreeLibraryFunc that calls FreeLibrary
138+
* internally to release an additional libary.
139+
*
140+
* This is the default as used by MemoryLoadLibrary.
141+
*/
142+
void MemoryDefaultFreeLibrary(HCUSTOMMODULE, void *);
143+
120144
#ifdef __cplusplus
121145
}
122146
#endif

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy