如果我有exampleA.exe
過程,我用FindEntryPointAddress()
函數來獲取exampleB.exe
過程我怎樣才能在PE函數入口點文件
FindEntryPointAddress()
的main()
切入點是exampleA.exe
DWORD FindEntryPointAddress(TCHAR *exeFile)
{
BY_HANDLE_FILE_INFORMATION bhfi;
HANDLE hMapping;
char *lpBase;
HANDLE hFile = CreateFile(exeFile, GENERIC_READ, FILE_SHARE_READ, NULL,OPEN_EXISTING, 0, NULL);
if (hFile == INVALID_HANDLE_VALUE)
;
if (!GetFileInformationByHandle(hFile, &bhfi))
;
hMapping = CreateFileMapping(hFile, NULL, PAGE_READONLY, bhfi.nFileSizeHigh, bhfi.nFileSizeLow, NULL);
if (!hMapping)
;
lpBase = (char *)MapViewOfFile(hMapping, FILE_MAP_READ, 0, 0, bhfi.nFileSizeLow);
if (!lpBase)
;
PIMAGE_DOS_HEADER dosHeader = (PIMAGE_DOS_HEADER)lpBase;
if (dosHeader->e_magic != IMAGE_DOS_SIGNATURE) // 0x00004550(IMAGE_NT_SIGNATURE)
;
PIMAGE_NT_HEADERS32 ntHeader = (PIMAGE_NT_HEADERS32)(lpBase + dosHeader->e_lfanew);
if (ntHeader->Signature != IMAGE_NT_SIGNATURE)
;
DWORD pEntryPoint = ntHeader->OptionalHeader.ImageBase + ntHeader->OptionalHeader.AddressOfEntryPoint;
UnmapViewOfFile((LPCVOID)lpBase);
CloseHandle(hMapping);
CloseHandle(hFile);
printf("test.exe entry point: %p\n", pEntryPoint);
return pEntryPoint;
} // FindEntryPointAddress()
功能
知道我有一個問題是我如何編輯FindEntryPointAddress()
以獲得func()
入口點exampleB.exe
exampleB.exe
void func()
{
char str[10];
strcpy(str, "iambuffer\n");
printf("%s", str);
} // func()
int main()
{
func();
return 0;
} // main()
感謝除非功能大量出口