Skip to content

Instantly share code, notes, and snippets.

@blaquee
Created February 10, 2015 02:49
Show Gist options
  • Save blaquee/76bf99746e5b0ac6ad9a to your computer and use it in GitHub Desktop.
Save blaquee/76bf99746e5b0ac6ad9a to your computer and use it in GitHub Desktop.
crackme1
#include <Windows.h>
#include <strsafe.h>
#include <Shlobj.h>
#include <string.h>
//the exported function
typedef void(__cdecl* display_message)(void);
//this can change
#define DLL_NAME L"\\display.dll"
int main(int argc, char** argv){
HINSTANCE hdll = NULL;
display_message display_func = NULL;
PWSTR appdata_path = NULL;
appdata_path = (PWSTR)malloc(MAX_PATH*2);
memset(appdata_path, 0, MAX_PATH * 2);
//get %appdata% roaming dir
HRESULT ok = SHGetKnownFolderPath((REFKNOWNFOLDERID)FOLDERID_RoamingAppData, 0,
NULL, &appdata_path);
if (ok == S_OK){
StringCchCat(appdata_path, MAX_PATH * 2, DLL_NAME);
//wprintf(L"%ws\n", &appdata_path);
hdll = LoadLibrary(appdata_path);
}
else{
wprintf(L"dll path fail\n");
return 0;
}
if (hdll != NULL){
display_func = (display_message)GetProcAddress(hdll, "DisplayMessage");
if (display_func != NULL){
//call the function
display_func();
return 0;
}
}
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment