Skip to content

Instantly share code, notes, and snippets.

@DingWeizhe
Last active November 28, 2015 06:15
Show Gist options
  • Save DingWeizhe/afb3d44548dd54dcf7c2 to your computer and use it in GitHub Desktop.
Save DingWeizhe/afb3d44548dd54dcf7c2 to your computer and use it in GitHub Desktop.
/* Replace "dll.h" with the name of your header */
#include "dll.h"
#include <windows.h>
#include <tchar.h>
typedef long (__cdecl * CompressType)(unsigned char *, int *, unsigned char *, int);
typedef long (__cdecl * UncompressType)(unsigned char *, int *, unsigned char *, int);
CompressType Bcompress = NULL;
UncompressType Buncompress = NULL;
DLLIMPORT long compress(unsigned char *a, int *b, unsigned char *c, int d)
{
return Bcompress(a,b,c,d);
}
DLLIMPORT long uncompress(unsigned char *a, int *b, unsigned char *c, int d)
{
//沒有報錯, 但預期a會是解密過後的資料, 但結果a是NULL
return Buncompress(a,b,c,d);
}
BOOL WINAPI DllMain(HINSTANCE hModule,DWORD fdwReason,LPVOID lpvReserved)
{
switch(fdwReason)
{
case DLL_PROCESS_ATTACH:
HINSTANCE cps = LoadLibrary(_T("B.dll"));
Bcompress = (CompressType) GetProcAddress(cps, "compress");
Buncompress = (UncompressType) GetProcAddress(cps, "uncompress");
break;
}
return TRUE;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment