#include "Common/NSimple.h"
#include <list>
#include <string>
#include "DllProxyLink.h"
using std::list;
using std::string;
#define DLL_Name "winmm.dll"
#define DLL_API_LIST() \
DLL_API_USE(CloseDriver) \
DLL_API_USE(DefDriverProc) \
DLL_API_USE(DriverCallback) \
DLL_API_USE(DrvGetModuleHandle) \
DLL_API_USE(GetDriverModuleHandle) \
DLL_API_USE(NotifyCallbackData) \
DLL_API_USE(OpenDriver) \
DLL_API_USE(PlaySound) \
DLL_API_USE(PlaySoundA) \
DLL_API_USE(PlaySoundW) \
DLL_API_USE(SendDriverMessage) \
DLL_API_USE(WOW32DriverCallback) \
DLL_API_USE(WOW32ResolveMultiMediaHandle) \
DLL_API_USE(WOWAppExit) \
DLL_API_USE(aux32Message) \
DLL_API_USE(auxGetDevCapsA) \
DLL_API_USE(auxGetDevCapsW) \
DLL_API_USE(auxGetNumDevs) \
DLL_API_USE(auxGetVolume) \
DLL_API_USE(auxOutMessage) \
DLL_API_USE(auxSetVolume) \
DLL_API_USE(joy32Message) \
DLL_API_USE(joyConfigChanged) \
DLL_API_USE(joyGetDevCapsA) \
DLL_API_USE(joyGetDevCapsW) \
DLL_API_USE(joyGetNumDevs) \
DLL_API_USE(joyGetPos) \
DLL_API_USE(joyGetPosEx) \
DLL_API_USE(joyGetThreshold) \
DLL_API_USE(joyReleaseCapture) \
DLL_API_USE(joySetCapture) \
DLL_API_USE(joySetThreshold) \
DLL_API_USE(mci32Message) \
DLL_API_USE(mciDriverNotify) \
DLL_API_USE(mciDriverYield) \
DLL_API_USE(mciExecute) \
DLL_API_USE(mciFreeCommandResource) \
DLL_API_USE(mciGetCreatorTask) \
DLL_API_USE(mciGetDeviceIDA) \
DLL_API_USE(mciGetDeviceIDFromElementIDA) \
DLL_API_USE(mciGetDeviceIDFromElementIDW) \
DLL_API_USE(mciGetDeviceIDW) \
DLL_API_USE(mciGetDriverData) \
DLL_API_USE(mciGetErrorStringA) \
DLL_API_USE(mciGetErrorStringW) \
DLL_API_USE(mciGetYieldProc) \
DLL_API_USE(mciLoadCommandResource) \
DLL_API_USE(mciSendCommandA) \
DLL_API_USE(mciSendCommandW) \
DLL_API_USE(mciSendStringA) \
DLL_API_USE(mciSendStringW) \
DLL_API_USE(mciSetDriverData) \
DLL_API_USE(mciSetYieldProc) \
DLL_API_USE(mid32Message) \
DLL_API_USE(midiConnect) \
DLL_API_USE(midiDisconnect) \
DLL_API_USE(midiInAddBuffer) \
DLL_API_USE(midiInClose) \
DLL_API_USE(midiInGetDevCapsA) \
DLL_API_USE(midiInGetDevCapsW) \
DLL_API_USE(midiInGetErrorTextA) \
DLL_API_USE(midiInGetErrorTextW) \
DLL_API_USE(midiInGetID) \
DLL_API_USE(midiInGetNumDevs) \
DLL_API_USE(midiInMessage) \
DLL_API_USE(midiInOpen) \
DLL_API_USE(midiInPrepareHeader) \
DLL_API_USE(midiInReset) \
DLL_API_USE(midiInStart) \
DLL_API_USE(midiInStop) \
DLL_API_USE(midiInUnprepareHeader) \
DLL_API_USE(midiOutCacheDrumPatches) \
DLL_API_USE(midiOutCachePatches) \
DLL_API_USE(midiOutClose) \
DLL_API_USE(midiOutGetDevCapsA) \
DLL_API_USE(midiOutGetDevCapsW) \
DLL_API_USE(midiOutGetErrorTextA) \
DLL_API_USE(midiOutGetErrorTextW) \
DLL_API_USE(midiOutGetID) \
DLL_API_USE(midiOutGetNumDevs) \
DLL_API_USE(midiOutGetVolume) \
DLL_API_USE(midiOutLongMsg) \
DLL_API_USE(midiOutMessage) \
DLL_API_USE(midiOutOpen) \
DLL_API_USE(midiOutPrepareHeader) \
DLL_API_USE(midiOutReset) \
DLL_API_USE(midiOutSetVolume) \
DLL_API_USE(midiOutShortMsg) \
DLL_API_USE(midiOutUnprepareHeader) \
DLL_API_USE(midiStreamClose) \
DLL_API_USE(midiStreamOpen) \
DLL_API_USE(midiStreamOut) \
DLL_API_USE(midiStreamPause) \
DLL_API_USE(midiStreamPosition) \
DLL_API_USE(midiStreamProperty) \
DLL_API_USE(midiStreamRestart) \
DLL_API_USE(midiStreamStop) \
DLL_API_USE(mixerClose) \
DLL_API_USE(mixerGetControlDetailsA) \
DLL_API_USE(mixerGetControlDetailsW) \
DLL_API_USE(mixerGetDevCapsA) \
DLL_API_USE(mixerGetDevCapsW) \
DLL_API_USE(mixerGetID) \
DLL_API_USE(mixerGetLineControlsA) \
DLL_API_USE(mixerGetLineControlsW) \
DLL_API_USE(mixerGetLineInfoA) \
DLL_API_USE(mixerGetLineInfoW) \
DLL_API_USE(mixerGetNumDevs) \
DLL_API_USE(mixerMessage) \
DLL_API_USE(mixerOpen) \
DLL_API_USE(mixerSetControlDetails) \
DLL_API_USE(mmDrvInstall) \
DLL_API_USE(mmGetCurrentTask) \
DLL_API_USE(mmTaskBlock) \
DLL_API_USE(mmTaskCreate) \
DLL_API_USE(mmTaskSignal) \
DLL_API_USE(mmTaskYield) \
DLL_API_USE(mmioAdvance) \
DLL_API_USE(mmioAscend) \
DLL_API_USE(mmioClose) \
DLL_API_USE(mmioCreateChunk) \
DLL_API_USE(mmioDescend) \
DLL_API_USE(mmioFlush) \
DLL_API_USE(mmioGetInfo) \
DLL_API_USE(mmioInstallIOProcA) \
DLL_API_USE(mmioInstallIOProcW) \
DLL_API_USE(mmioOpenA) \
DLL_API_USE(mmioOpenW) \
DLL_API_USE(mmioRead) \
DLL_API_USE(mmioRenameA) \
DLL_API_USE(mmioRenameW) \
DLL_API_USE(mmioSeek) \
DLL_API_USE(mmioSendMessage) \
DLL_API_USE(mmioSetBuffer) \
DLL_API_USE(mmioSetInfo) \
DLL_API_USE(mmioStringToFOURCCA) \
DLL_API_USE(mmioStringToFOURCCW) \
DLL_API_USE(mmioWrite) \
DLL_API_USE(mmsystemGetVersion) \
DLL_API_USE(mod32Message) \
DLL_API_USE(mxd32Message) \
DLL_API_USE(sndPlaySoundA) \
DLL_API_USE(sndPlaySoundW) \
DLL_API_USE(tid32Message) \
DLL_API_USE(timeBeginPeriod) \
DLL_API_USE(timeEndPeriod) \
DLL_API_USE(timeGetDevCaps) \
DLL_API_USE(timeGetSystemTime) \
DLL_API_USE(timeGetTime) \
DLL_API_USE(timeKillEvent) \
DLL_API_USE(timeSetEvent) \
DLL_API_USE(waveInAddBuffer) \
DLL_API_USE(waveInClose) \
DLL_API_USE(waveInGetDevCapsA) \
DLL_API_USE(waveInGetDevCapsW) \
DLL_API_USE(waveInGetErrorTextA) \
DLL_API_USE(waveInGetErrorTextW) \
DLL_API_USE(waveInGetID) \
DLL_API_USE(waveInGetNumDevs) \
DLL_API_USE(waveInGetPosition) \
DLL_API_USE(waveInMessage) \
DLL_API_USE(waveInOpen) \
DLL_API_USE(waveInPrepareHeader) \
DLL_API_USE(waveInReset) \
DLL_API_USE(waveInStart) \
DLL_API_USE(waveInStop) \
DLL_API_USE(waveInUnprepareHeader) \
DLL_API_USE(waveOutBreakLoop) \
DLL_API_USE(waveOutClose) \
DLL_API_USE(waveOutGetDevCapsA) \
DLL_API_USE(waveOutGetDevCapsW) \
DLL_API_USE(waveOutGetErrorTextA) \
DLL_API_USE(waveOutGetErrorTextW) \
DLL_API_USE(waveOutGetID) \
DLL_API_USE(waveOutGetNumDevs) \
DLL_API_USE(waveOutGetPitch) \
DLL_API_USE(waveOutGetPlaybackRate) \
DLL_API_USE(waveOutGetPosition) \
DLL_API_USE(waveOutGetVolume) \
DLL_API_USE(waveOutMessage) \
DLL_API_USE(waveOutOpen) \
DLL_API_USE(waveOutPause) \
DLL_API_USE(waveOutPrepareHeader) \
DLL_API_USE(waveOutReset) \
DLL_API_USE(waveOutRestart) \
DLL_API_USE(waveOutSetPitch) \
DLL_API_USE(waveOutSetPlaybackRate) \
DLL_API_USE(waveOutSetVolume) \
DLL_API_USE(waveOutUnprepareHeader) \
DLL_API_USE(waveOutWrite) \
DLL_API_USE(wid32Message) \
DLL_API_USE(wod32Message) \
#define DLL_API extern "C"
#define DLL_API_Def(fun) static void * __##fun = NULL;
#define DLL_API_Fun(fun) DLL_API __declspec(naked) void * _##fun() \
{ \
__asm jmp __##fun \
}
#define DLL_API_Get(fun) __##fun = (void *)GetProcAddress(hSysMod, #fun);
#define DLL_API_Export(fun) AddLinkHead(funList, #fun);
#undef DLL_API_USE
#define DLL_API_USE DLL_API_Def
DLL_API_LIST()
#undef DLL_API_USE
#define DLL_API_USE DLL_API_Fun
DLL_API_LIST()
BOOL CreateLinkHead();
static HMODULE hSysMod = NULL;
BOOL DllProxyInit()
{
CHAR szSysDll[520];
GetSystemDirectoryA(szSysDll, sizeof(szSysDll));
strcat_s(szSysDll, sizeof(szSysDll), "\\");
strcat_s(szSysDll, sizeof(szSysDll), DLL_Name);
hSysMod = LoadLibraryA(szSysDll);
#undef DLL_API_USE
#define DLL_API_USE DLL_API_Get
DLL_API_LIST()
CreateLinkHead();
return TRUE;
}
BOOL AddLinkHead(list<string> &funList, CHAR *pName)
{
funList.push_back(pName);
return TRUE;
}
BOOL CreateLinkHead()
{
list<string>::iterator Iter;
list<string> funList;
string sFullText;
CHAR szItem[1024], szDir[MAXPATH], szPath[MAXPATH];
CHAR *pName;
#ifndef _DEBUG
return TRUE;
#endif
#undef DLL_API_USE
#define DLL_API_USE DLL_API_Export
DLL_API_LIST()
sFullText = "";
for(Iter = funList.begin();
Iter != funList.end();
Iter ++)
{
pName = (CHAR *)Iter->data();
sprintf_s(szItem, sizeof(szItem),
"#pragma comment(linker, \"/EXPORT:%s=__%s,PRIVATE\")",
pName, pName);
sFullText += szItem;
sFullText += "\r\n";
}
NFile::SpliteFilePath(__FILE__, szDir, NULL);
sprintf_s(szPath, sizeof(szPath), "%s\\%s", szDir, "DllProxyLink.h");
if(NFile::FileExist(szPath) == FALSE)
return FALSE;
NFile::DumpToFileCheck(szPath, sFullText.data(), sFullText.size());
return TRUE;
}
DLL_API BOOL TestExport()
{
return TRUE;
}
标签:USE,代理,DLL,API,fun,Dll,szSysDll,define
From: https://www.cnblogs.com/zzz3265/p/17807363.html