//============================================================================
// Name        : ProcAddress.cpp
// Author      : SaEeD
// Description : Return Hex Value of Process Address in DLLs
//============================================================================

#include <iostream>
#include <windows.h>
using namespace std;

int main(int argc, char *argv[])
{
	HINSTANCE hInstance = NULL;
	int addr=0;
	if(argc !=3)
	{
		cerr << "Usage: " << argv[0] << " <DLL Name>  <Function Name> " << endl;
		exit(-1);
	}
	hInstance = LoadLibraryA(argv[1]);
	if(hInstance != NULL)
	{
		addr = (int)GetProcAddress(hInstance,argv[2]);
		if(addr ==0)
		{
			cerr<< "[-]Address NOT Found :-(" << endl;
			exit(-1);
		}
		cout<< "[+]Process Address is : 0x" << hex << addr <<endl;;
		FreeLibrary(hInstance);
	}else{
		cerr<< "[-]Cannot load the Library. :-(" << endl;
		exit(-1);
	}
	return 0;
}