// 增加区段.cpp : Defines the entry point for the console application.
//
#include <windows.h>
#include <stdio.h>
#include <winbase.h>
bool OpenMyFile(char fileName[]);
LPVOID AddSection(LPVOID ImageBase,char sectionName[],DWORD SectionNumber);
DWORD ToAlign(DWORD SectionNumber,DWORD AlignSize); //取整 第二个参数表示以多少进行取整
DWORD addNumber; //新区段的字节数
DWORD VAValue; //保存原入口VA值
char chao[MAX_PATH]="MessageBoxA GetProAddress LoadLibraryA user32.dll kernel32.dll";
DWORD addRess; //保存GETMODULEHANDL地址
int main(int argc, char* argv[])
{
addRess =(DWORD)GetProcAddress(GetModuleHandle("kernel32.dll"),"GetModuleHandleA");
addNumber = 100;
char fileName[] = "text.exe"; //欲测试的程序
if(!OpenMyFile(fileName))
printf("failed!!!/n");
return 0;
}
bool OpenMyFile(char fileName[])
{
HANDLE hFile;
hFile = CreateFile(fileName, //打开文件
GENERIC_READ|GENERIC_WRITE,
FILE_SHARE_READ|FILE_SHARE_WRITE,
NULL,OPEN_EXISTING,
FILE_ATTRIBUTE_NORMAL,
NULL);
if(!hFile)
return false;
DWORD fileSize = GetFileSize(hFile,NULL); //得到文件大小
HANDLE hMap;
增加区段的VC嵌汇编代码
最新推荐文章于 2024-12-09 12:34:13 发布