Call an unnamed function in a DLL based on the function address

Hits: 0

#include <iostream>
#include <windows.h>
#include <string>
#include <shlwapi.h>
#pragma comment(lib, "shlwapi.lib")
#include <fstream>
using namespace std;


typedef  char (*pDecrypt) (LPVOID a, int ** b) ;             // function pointer 
pDecrypt Decrypt = NULL ;                            // just call Decrypt later


int main()
{

    WCHAR pszPath;
    pszPath = 0 ;
     bool ret = PathAppendW(&pszPath, L"1.dat" );    // Parameter 1: the file to be decrypted 
    if (ret == 1 ) {
         cout << &pszPath << "The file was read successfully!" < < endl ;
    }

    FILE * fp1 = fopen("1.dat", "rb");
    //cout << &fp1.seek() << endl;

    int *v8;                                             // parameter two 
    v8 = 0 ;

    HMODULE hDLL;
    hDLL = LoadLibrary("1.dll");

    if (hDLL) { 

        cout << typeid (hDLL).name() << endl ;
         int offset = 0xEB0 ;                            // 3AC0h / 4 = EB0h 
        hDLL = hDLL + offset;                        // hDLL now saves the offset address of the "function" 
        cout << " function address" << hDLL << endl ;

        Decrypt = (pDecrypt)hDLL;

        if (Decrypt) {

            Decrypt(&fp1, &v8);
            cout << "The following is the v8 data." << endl ;
             cout << &v8 << endl ;
             cout << v8 << endl ;

        }
    }

    system("pause");
    FreeLibrary(hDLL);
    return 0;
}

You may also like...

Leave a Reply

Your email address will not be published.