主程序
#include <stdio.h>
#include <stdlib.h>
#include "func.h"
typedef int(*lpPlus)(int, int);
int main(int argc ,char* argv[])
{
PVOID pFileBuffer;
if (!ReadPEFile(FILEPATH, &pFileBuffer))
{
printf("文件读取失败\n");
return;
}
LPCSTR lpProcName = "Div";
DWORD func=GetFunctionAddrByName(pFileBuffer ,lpProcName);
printf("通过函数名Div称获取的函数地址:%x\n", func);
lpProcName = "Sub";
func = GetFunctionAddrByName(pFileBuffer, lpProcName);
printf("通过函数名Sub称获取的函数地址:%x\n", func);
lpProcName = "Mul";
func = GetFunctionAddrByName(pFileBuffer, lpProcName);
printf("通过函数名Mul称获取的函数地址:%x\n", func);
lpProcName = "Plus";
func = GetFunctionAddrByName(pFileBuffer, lpProcName);
printf("通过函数名Plus称获取的函数地址:%x\n", func);
printf("++++++++++++++++++++++++++++++++++++++++++++++\n");
func = GetFunctionAddrByOrdinals(pFileBuffer,6);
printf("通过函数序号6获取的函数地址:%x\n", func);
func = GetFunctionAddrByOrdinals(pFileBuffer, 4);
printf("通过函数序号4获取的函数地址:%x\n", func);
func = GetFunctionAddrByOrdinals(pFileBuffer, 5);
printf("通过函数序号5获取的函数地址:%x\n", func);
func = GetFunctionAddrByOrdinals(pFileBuffer,