SkiиArtDlg.cpp
资源名称:Skinload.rar [点击查看]
上传用户:tjjuxin
上传日期:2021-06-01
资源大小:3552k
文件大小:36k
源码类别:
Shell编程
开发平台:
Visual C++
- // SkiиArtDlg.cpp : implementation file
- //
- #include "stdafx.h"
- #include "SkiиArt.h"
- #include "SkiиArtDlg.h"
- #include "SkinPPWTL.h"
- #include "DlgSections.h"
- #include "DlgStruct.h"
- #ifdef _DEBUG
- #define new DEBUG_NEW
- #undef THIS_FILE
- static char THIS_FILE[] = __FILE__;
- #endif
- #define ADD_SECTION_SIZE 0x1000
- BYTE *g_pPEBuffer = NULL;
- BYTE *g_pShellCodeStart = NULL;
- BYTE *g_pShellCodeEnd = NULL;
- DWORD g_dwSectionBase = 0;
- BOOL g_bShellCode = TRUE;
- void ShellCode();
- typedef struct _SKIN_ART
- {
- _SKIN_ART()
- {
- memset(&dwSign, 0, sizeof(_SKIN_ART));
- // dwSign = 0x7e69ac4e;
- }
- DWORD dwSign;
- DWORD dwDllFileSize;
- DWORD dwSkinFileSize;
- char szDllName[50];
- char szSkinName[50];
- }SKIN_ART, * PSKIN_ART;
- /////////////////////////////////////////////////////////////////////////////
- // CSkiArtDlg dialog
- CSkiArtDlg::CSkiArtDlg(CWnd* pParent /*=NULL*/)
- : CDialog(CSkiArtDlg::IDD, pParent)
- {
- //{{AFX_DATA_INIT(CSkiArtDlg)
- // NOTE: the ClassWizard will add member initialization here
- //}}AFX_DATA_INIT
- // Note that LoadIcon does not require a subsequent DestroyIcon in Win32
- m_hIcon = AfxGetApp()->LoadIcon(IDR_MAINFRAME);
- }
- CSkiArtDlg::~CSkiArtDlg()
- {
- if (g_pPEBuffer)
- {
- delete [] g_pPEBuffer;
- g_pPEBuffer = NULL;
- }
- }
- void CSkiArtDlg::DoDataExchange(CDataExchange* pDX)
- {
- CDialog::DoDataExchange(pDX);
- //{{AFX_DATA_MAP(CSkiArtDlg)
- DDX_Control(pDX, IDC_LIST_SKIN, m_SkinList);
- //}}AFX_DATA_MAP
- }
- BEGIN_MESSAGE_MAP(CSkiArtDlg, CDialog)
- //{{AFX_MSG_MAP(CSkiArtDlg)
- ON_WM_SYSCOMMAND()
- ON_WM_PAINT()
- ON_WM_QUERYDRAGICON()
- ON_BN_CLICKED(IDC_CHECK_TOP, OnCheckTop)
- ON_BN_CLICKED(IDC_BTN_ABOUT, OnBtnAbout)
- ON_BN_CLICKED(IDC_BTN_EXIT, OnBtnExit)
- ON_BN_CLICKED(IDC_BTN_SELECT, OnBtnSelect)
- ON_WM_DROPFILES()
- ON_BN_CLICKED(IDC_BTN_ADDSKIN, OnBtnAddskin)
- ON_BN_CLICKED(IDC_BTN_SECTIONS, OnBtnSections)
- ON_BN_CLICKED(IDC_BTN_LOOK, OnBtnLook)
- ON_LBN_SELCHANGE(IDC_LIST_SKIN, OnSelchangeListSkin)
- //}}AFX_MSG_MAP
- END_MESSAGE_MAP()
- void CSkiArtDlg::OnBtnLook()
- {
- if (!g_pPEBuffer)
- {
- return ;
- }
- char *szbigbuff = new char[50*100];
- if (szbigbuff == NULL)
- {
- ::MessageBox(m_hWnd, "申请内存失败", "错误", NULL);
- return ;
- }
- PIMAGE_DOS_HEADER pDosHead=NULL;
- PIMAGE_NT_HEADERS pNtHead=NULL;
- pDosHead=(PIMAGE_DOS_HEADER)g_pPEBuffer;
- pNtHead=(PIMAGE_NT_HEADERS)((unsigned char *)pDosHead+pDosHead->e_lfanew);
- memset(szbigbuff, 0, 50*100);
- char szTemp100[100] = {0};
- //1. Dos Header
- sprintf(szTemp100, "->IMAGE_DOS_HEADER 结构体:rn");
- strcpy(szbigbuff, szTemp100);
- sprintf(szTemp100, " e_magic: 0x%.4X //Dos 头标志,为0x5A4D,ASCII码值"MZ".rn", pDosHead->e_magic);
- strcat(szbigbuff, szTemp100);
- sprintf(szTemp100, " e_cblp: 0x%.4X //Bytes on last page of file.rn", pDosHead->e_cblp);
- strcat(szbigbuff, szTemp100);
- sprintf(szTemp100, " e_cp: 0x%.4X //Pages in file.rn", pDosHead->e_cp);
- strcat(szbigbuff, szTemp100);
- sprintf(szTemp100, " e_crlc: 0x%.4X //Relocations.rn", pDosHead->e_crlc);
- strcat(szbigbuff, szTemp100);
- sprintf(szTemp100, " e_cparhdr: 0x%.4X //Size of header in paragraphs.rn", pDosHead->e_cparhdr);
- strcat(szbigbuff, szTemp100);
- sprintf(szTemp100, " e_minalloc: 0x%.4X //Minimum extra paragraphs needed.rn", pDosHead->e_minalloc);
- strcat(szbigbuff, szTemp100);
- sprintf(szTemp100, " e_maxalloc: 0x%.4X //Maximum extra paragraphs needed.rn", pDosHead->e_maxalloc);
- strcat(szbigbuff, szTemp100);
- sprintf(szTemp100, " e_ss: 0x%.4X //Initial (relative) SS value.rn", pDosHead->e_ss);
- strcat(szbigbuff, szTemp100);
- sprintf(szTemp100, " e_csum: 0x%.4X //Checksum.rn", pDosHead->e_csum);
- strcat(szbigbuff, szTemp100);
- sprintf(szTemp100, " e_ip: 0x%.4X //Initial IP value.rn", pDosHead->e_ip);
- strcat(szbigbuff, szTemp100);
- sprintf(szTemp100, " e_cs: 0x%.4X //Initial (relative) CS value.rn", pDosHead->e_cs);
- strcat(szbigbuff, szTemp100);
- sprintf(szTemp100, " e_lfarlc: 0x%.4X //File address of relocation table.rn", pDosHead->e_lfarlc);
- strcat(szbigbuff, szTemp100);
- sprintf(szTemp100, " e_ovno: 0x%.4X //Overlay number.rn", pDosHead->e_ovno);
- strcat(szbigbuff, szTemp100);
- sprintf(szTemp100, " e_res[4]: 0x%.2X%.2X%.2X%.2X //File address of relocation table.rn", pDosHead->e_res[0], pDosHead->e_res[1], pDosHead->e_res[2], pDosHead->e_res[3]);
- strcat(szbigbuff, szTemp100);
- sprintf(szTemp100, " e_oemid: 0x%.4X //File address of relocation table.rn", pDosHead->e_oemid);
- strcat(szbigbuff, szTemp100);
- sprintf(szTemp100, " e_oeminfo: 0x%.4X //File address of relocation table.rn", pDosHead->e_oeminfo);
- strcat(szbigbuff, szTemp100);
- sprintf(szTemp100, " e_res2[10]: 0x%.2X%.2X%.2X%.2X%.2X%.2X%.2X%.2X%.2X%.2X //File address of relocation table.rn", pDosHead->e_res2[0], pDosHead->e_res2[1], pDosHead->e_res2[2], pDosHead->e_res2[3], pDosHead->e_res2[4], pDosHead->e_res2[5], pDosHead->e_res2[6], pDosHead->e_res2[7], pDosHead->e_res2[8], pDosHead->e_res2[9]);
- strcat(szbigbuff, szTemp100);
- sprintf(szTemp100, " e_lfanew: 0x%.8X //File address of new exe header.rn", pDosHead->e_lfanew);
- strcat(szbigbuff, szTemp100);
- //2. Image NT Headers
- sprintf(szTemp100, "rn->IMAGE_NT_HEADERS 结构体:rn");
- strcat(szbigbuff, szTemp100);
- sprintf(szTemp100, " Signature: 0x%.8X //此字段设置为0x00004550, ASCII码值"PE00".rn", pNtHead->Signature);
- strcat(szbigbuff, szTemp100);
- sprintf(szTemp100, " 一个IMAGE_FILE_HEADER结构体,在下面介绍.rn");
- strcat(szbigbuff, szTemp100);
- sprintf(szTemp100, " 一个IMAGE_OPTIONAL_HEADER结构体,下面介绍.rn");
- strcat(szbigbuff, szTemp100);
- //3. Image File Header
- sprintf(szTemp100, "rn->IMAGE_FILE_HEADER 结构体:rn");
- strcat(szbigbuff, szTemp100);
- sprintf(szTemp100, " Machine: 0x%.4X //(I386)rn", pNtHead->FileHeader.Machine);
- strcat(szbigbuff, szTemp100);
- sprintf(szTemp100, " NumberOfSections: 0x%.4X //区块的数量.rn", pNtHead->FileHeader.NumberOfSections);
- strcat(szbigbuff, szTemp100);
- sprintf(szTemp100, " TimeDateStamp: 0x%.8X //文件时间信息.rn", pNtHead->FileHeader.TimeDateStamp);
- strcat(szbigbuff, szTemp100);
- sprintf(szTemp100, " PointerToSymbolTable: 0x%.8X //调试信息.rn", pNtHead->FileHeader.PointerToSymbolTable);
- strcat(szbigbuff, szTemp100);
- sprintf(szTemp100, " NumberOfSymbols: 0x%.8X //调试信息.rn", pNtHead->FileHeader.NumberOfSymbols);
- strcat(szbigbuff, szTemp100);
- sprintf(szTemp100, " SizeOfOptionalHeader: 0x%.4X //结构体IMAGE_OPTIONAL_HEADER 的大小.rn", pNtHead->FileHeader.SizeOfOptionalHeader);
- strcat(szbigbuff, szTemp100);
- sprintf(szTemp100, " Characteristics: 0x%.4X //特征值.rn", pNtHead->FileHeader.Characteristics);
- strcat(szbigbuff, szTemp100);
- //4. Image Optional Header
- sprintf(szTemp100, "rn->IMAGE_OPTIONAL_HEADER 结构体:rn");
- strcat(szbigbuff, szTemp100);
- sprintf(szTemp100, " Magic: 0x%.4X //标识字.rn", pNtHead->OptionalHeader.Magic);
- strcat(szbigbuff, szTemp100);
- sprintf(szTemp100, " MajorLinkerVersion: 0x%.2X //rn", pNtHead->OptionalHeader.MajorLinkerVersion);
- strcat(szbigbuff, szTemp100);
- sprintf(szTemp100, " MinorLinkerVersion: 0x%.2X //rn", pNtHead->OptionalHeader.MinorLinkerVersion);
- strcat(szbigbuff, szTemp100);
- sprintf(szTemp100, " SizeOfCode: 0x%.8X //rn", pNtHead->OptionalHeader.SizeOfCode);
- strcat(szbigbuff, szTemp100);
- sprintf(szTemp100, " SizeOfInitializedData: 0x%.8X //rn", pNtHead->OptionalHeader.SizeOfInitializedData);
- strcat(szbigbuff, szTemp100);
- sprintf(szTemp100, " SizeOfUninitializedData: 0x%.8X //rn", pNtHead->OptionalHeader.SizeOfUninitializedData);
- strcat(szbigbuff, szTemp100);
- sprintf(szTemp100, " AddressOfEntryPoint: 0x%.8X //rn", pNtHead->OptionalHeader.AddressOfEntryPoint);
- strcat(szbigbuff, szTemp100);
- sprintf(szTemp100, " BaseOfCode: 0x%.8X //rn", pNtHead->OptionalHeader.BaseOfCode);
- strcat(szbigbuff, szTemp100);
- sprintf(szTemp100, " BaseOfData: 0x%.8X //rn", pNtHead->OptionalHeader.BaseOfData);
- strcat(szbigbuff, szTemp100);
- sprintf(szTemp100, " ImageBase: 0x%.4X //rn", pNtHead->OptionalHeader.ImageBase);
- strcat(szbigbuff, szTemp100);
- sprintf(szTemp100, " SectionAlignment: 0x%.4X //段对齐rn", pNtHead->OptionalHeader.SectionAlignment);
- strcat(szbigbuff, szTemp100);
- sprintf(szTemp100, " FileAlignment: 0x%.4X //文件对齐rn", pNtHead->OptionalHeader.FileAlignment);
- strcat(szbigbuff, szTemp100);
- sprintf(szTemp100, " MajorOperatingSystemVersion: 0x%.4X //rn", pNtHead->OptionalHeader.MajorOperatingSystemVersion);
- strcat(szbigbuff, szTemp100);
- sprintf(szTemp100, " MinorOperatingSystemVersion: 0x%.4X //rn", pNtHead->OptionalHeader.MinorOperatingSystemVersion);
- strcat(szbigbuff, szTemp100);
- sprintf(szTemp100, " MajorImageVersion: 0x%.4X //rn", pNtHead->OptionalHeader.MajorImageVersion);
- strcat(szbigbuff, szTemp100);
- sprintf(szTemp100, " MinorImageVersion: 0x%.4X //rn", pNtHead->OptionalHeader.MinorImageVersion);
- strcat(szbigbuff, szTemp100);
- sprintf(szTemp100, " MajorSubsystemVersion: 0x%.8X //rn", pNtHead->OptionalHeader.MajorSubsystemVersion);
- strcat(szbigbuff, szTemp100);
- sprintf(szTemp100, " MinorSubsystemVersion: 0x%.8X //rn", pNtHead->OptionalHeader.MinorSubsystemVersion);
- strcat(szbigbuff, szTemp100);
- sprintf(szTemp100, " Win32VersionValue: 0x%.8X //rn", pNtHead->OptionalHeader.Win32VersionValue);
- strcat(szbigbuff, szTemp100);
- sprintf(szTemp100, " SizeOfImage: 0x%.8X //rn", pNtHead->OptionalHeader.SizeOfImage);
- strcat(szbigbuff, szTemp100);
- sprintf(szTemp100, " SizeOfHeaders: 0x%.8X //rn", pNtHead->OptionalHeader.SizeOfHeaders);
- strcat(szbigbuff, szTemp100);
- sprintf(szTemp100, " CheckSum: 0x%.8X //rn", pNtHead->OptionalHeader.CheckSum);
- strcat(szbigbuff, szTemp100);
- sprintf(szTemp100, " Subsystem: 0x%.4X //rn", pNtHead->OptionalHeader.Subsystem);
- strcat(szbigbuff, szTemp100);
- sprintf(szTemp100, " DllCharacteristics: 0x%.4X //rn", pNtHead->OptionalHeader.DllCharacteristics);
- strcat(szbigbuff, szTemp100);
- sprintf(szTemp100, " SizeOfStackReserve: 0x%.8X //rn", pNtHead->OptionalHeader.SizeOfStackReserve);
- strcat(szbigbuff, szTemp100);
- sprintf(szTemp100, " SizeOfStackCommit: 0x%.8X //rn", pNtHead->OptionalHeader.SizeOfStackCommit);
- strcat(szbigbuff, szTemp100);
- sprintf(szTemp100, " SizeOfHeapReserve: 0x%.8X //rn", pNtHead->OptionalHeader.SizeOfHeapReserve);
- strcat(szbigbuff, szTemp100);
- sprintf(szTemp100, " SizeOfHeapCommit: 0x%.8X //rn", pNtHead->OptionalHeader.SizeOfHeapCommit);
- strcat(szbigbuff, szTemp100);
- sprintf(szTemp100, " LoaderFlags: 0x%.8X //rn", pNtHead->OptionalHeader.LoaderFlags);
- strcat(szbigbuff, szTemp100);
- sprintf(szTemp100, " NumberOfRvaAndSizes: 0x%.8X //下一项的数组元素个数rn", pNtHead->OptionalHeader.NumberOfRvaAndSizes);
- strcat(szbigbuff, szTemp100);
- sprintf(szTemp100, " DataDirectory [%d] 数据目录表rn", pNtHead->OptionalHeader.NumberOfRvaAndSizes);
- strcat(szbigbuff, szTemp100);
- CDlgStruct dlg(this, szbigbuff, 0);
- dlg.DoModal();
- delete [] szbigbuff;
- }
- /////////////////////////////////////////////////////////////////////////////
- // CSkiArtDlg message handlers
- BOOL CSkiArtDlg::OnInitDialog()
- {
- CDialog::OnInitDialog();
- // Add "About..." menu item to system menu.
- // IDM_ABOUTBOX must be in the system command range.
- ASSERT((IDM_ABOUTBOX & 0xFFF0) == IDM_ABOUTBOX);
- ASSERT(IDM_ABOUTBOX < 0xF000);
- CMenu* pSysMenu = GetSystemMenu(FALSE);
- if (pSysMenu != NULL)
- {
- CString strAboutMenu;
- strAboutMenu.LoadString(IDS_ABOUTBOX);
- if (!strAboutMenu.IsEmpty())
- {
- pSysMenu->AppendMenu(MF_SEPARATOR);
- pSysMenu->AppendMenu(MF_STRING, IDM_ABOUTBOX, strAboutMenu);
- }
- }
- // Set the icon for this dialog. The framework does this automatically
- // when the application's main window is not a dialog
- SetIcon(m_hIcon, TRUE); // Set big icon
- SetIcon(m_hIcon, FALSE); // Set small icon
- srand(unsigned int (time(NULL)));
- ::SetDlgItemTextA(m_hWnd, IDC_EDIT_FILE, "可拖放文件");
- //init skin list
- char szMoudleName[MAX_PATH] = {0};
- GetCurrentDirectoryA(MAX_PATH, szMoudleName);
- if (szMoudleName[strlen(szMoudleName)-1] == '/' || szMoudleName[strlen(szMoudleName)-1] == '\')
- {
- szMoudleName[strlen(szMoudleName)-1] = 0;
- }
- char szFind[MAX_PATH];
- sprintf(szFind, "%s/Skin/*.*", szMoudleName);
- WIN32_FIND_DATA FindFileData;
- HANDLE hFind=::FindFirstFile(szFind,&FindFileData);
- if(INVALID_HANDLE_VALUE == hFind)
- {
- AfxMessageBox("没有找到皮肤文件,请检查同目录下的Skin文件夹中的文件!");
- ExitProcess(0);
- }
- BOOL bFind = FALSE;
- while(TRUE)
- {
- if(!(FindFileData.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY))
- {
- bFind = TRUE;
- m_SkinList.AddString(FindFileData.cFileName);
- }
- if(!FindNextFile(hFind,&FindFileData))
- break;
- }
- FindClose(hFind);
- if (!bFind)
- {
- AfxMessageBox("没有找到皮肤文件,请检查同目录下的Skin文件夹中的文件!");
- ExitProcess(0);
- }
- int iSkinCount = m_SkinList.GetCount();
- m_SkinList.SetCurSel(rand()%iSkinCount);
- OnSelchangeListSkin();
- return TRUE; // return TRUE unless you set the focus to a control
- }
- void CSkiArtDlg::OnSysCommand(UINT nID, LPARAM lParam)
- {
- if ((nID & 0xFFF0) == IDM_ABOUTBOX)
- {
- // CAboutDlg dlgAbout;
- // dlgAbout.DoModal();
- }
- else
- {
- CDialog::OnSysCommand(nID, lParam);
- }
- }
- // If you add a minimize button to your dialog, you will need the code below
- // to draw the icon. For MFC applications using the document/view model,
- // this is automatically done for you by the framework.
- void CSkiArtDlg::OnPaint()
- {
- if (IsIconic())
- {
- CPaintDC dc(this); // device context for painting
- SendMessage(WM_ICONERASEBKGND, (WPARAM) dc.GetSafeHdc(), 0);
- // Center icon in client rectangle
- int cxIcon = GetSystemMetrics(SM_CXICON);
- int cyIcon = GetSystemMetrics(SM_CYICON);
- CRect rect;
- GetClientRect(&rect);
- int x = (rect.Width() - cxIcon + 1) / 2;
- int y = (rect.Height() - cyIcon + 1) / 2;
- // Draw the icon
- dc.DrawIcon(x, y, m_hIcon);
- }
- else
- {
- CDialog::OnPaint();
- }
- }
- // The system calls this to obtain the cursor to display while the user drags
- // the minimized window.
- HCURSOR CSkiArtDlg::OnQueryDragIcon()
- {
- return (HCURSOR) m_hIcon;
- }
- void CSkiArtDlg::OnCheckTop()
- {
- CButton *pCheckBtn = (CButton *)GetDlgItem(IDC_CHECK_TOP);
- //be checked
- if (pCheckBtn->GetCheck())
- {
- ::SetWindowPos(m_hWnd,HWND_TOPMOST,0,0,0,0,SWP_NOMOVE|SWP_NOSIZE);
- }
- //not be checked
- else
- {
- ::SetWindowPos(m_hWnd,HWND_NOTOPMOST,0,0,0,0,SWP_NOMOVE|SWP_NOSIZE);
- }
- }
- void CSkiArtDlg::OnBtnAbout()
- {
- char szText[200] = {"编程是一门艺术 rn作者:blueapplezrnQQ:124272113rnEmail:blueapple1987@163.comrn说明:谢谢您的使用,欢迎提出宝贵建议!"};
- ::MessageBoxA(m_hWnd, szText, "SkiиArt 1.0-By blueapplez", MB_OK);
- }
- void CSkiArtDlg::OnBtnExit()
- {
- CDialog::OnCancel();
- }
- BOOL IsPEvalid(LPBYTE pImage)
- {
- PIMAGE_DOS_HEADER pDosHead=NULL;
- PIMAGE_NT_HEADERS pNtHead=NULL;
- PIMAGE_SECTION_HEADER pSectionHead=NULL;
- pDosHead=(PIMAGE_DOS_HEADER)pImage;
- pNtHead=(PIMAGE_NT_HEADERS)((unsigned char *)pDosHead+pDosHead->e_lfanew);
- WORD wMZ = 0;
- memcpy(&wMZ, pImage, 2);
- if (wMZ != 0x5a4d)
- {
- return FALSE;
- }
- if (pNtHead == 0)
- {
- return FALSE;
- }
- WORD wPE = 0;
- memcpy(&wPE, pNtHead, 2);
- if (wPE != 0x4550)
- {
- return FALSE;
- }
- return TRUE;
- }
- BOOL CSkiArtDlg::GetPEInfo()
- {
- char szExeFile[MAX_PATH] = {0};
- GetDlgItemText(IDC_EDIT_FILE, szExeFile, MAX_PATH);
- HANDLE hFile = ::CreateFile(szExeFile, GENERIC_READ|GENERIC_WRITE, 0, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL | FILE_FLAG_SEQUENTIAL_SCAN, NULL);
- if (hFile == INVALID_HANDLE_VALUE)
- {
- AfxMessageBox("文件打开失败!");
- return FALSE;
- }
- DWORD dwFileSize = GetFileSize(hFile, NULL);
- if (dwFileSize == 0)
- {
- CloseHandle(hFile);
- AfxMessageBox("文件大小为零!");
- return FALSE;
- }
- if (!g_pPEBuffer)
- {
- delete [] g_pPEBuffer;
- g_pPEBuffer = NULL;
- }
- g_pPEBuffer = new BYTE [dwFileSize];
- if (!g_pPEBuffer)
- {
- CloseHandle(hFile);
- AfxMessageBox("申请内存失败!");
- return FALSE;
- }
- memset (g_pPEBuffer, 0, dwFileSize);
- DWORD dwRead = 0;
- ReadFile(hFile, g_pPEBuffer, dwFileSize, &dwRead, NULL);
- if (dwRead != dwFileSize)
- {
- CloseHandle(hFile);
- AfxMessageBox("读文件失败!");
- return FALSE;
- }
- CloseHandle(hFile);
- if (!IsPEvalid(g_pPEBuffer))
- {
- AfxMessageBox("无效的PE文件!");
- return FALSE;
- }
- DWORD dwNumOfSection = 0;
- DWORD dwImageBase=0;
- DWORD dwImageSize=0;
- DWORD dwEntryPointOffset = 0;
- DWORD dwEntryPoint=0;
- PIMAGE_DOS_HEADER pDosHead=NULL;
- PIMAGE_NT_HEADERS pNtHead=NULL;
- PIMAGE_SECTION_HEADER pSectionHead=NULL;
- pDosHead = (PIMAGE_DOS_HEADER)g_pPEBuffer;
- pNtHead = (PIMAGE_NT_HEADERS)((DWORD)pDosHead+pDosHead->e_lfanew);
- //Record the old PE EnterPoint
- dwEntryPoint = pNtHead->OptionalHeader.AddressOfEntryPoint;
- dwImageBase = pNtHead->OptionalHeader.ImageBase;
- dwImageSize = pNtHead->OptionalHeader.SizeOfImage;
- dwNumOfSection = pNtHead->FileHeader.NumberOfSections;
- pSectionHead = (PIMAGE_SECTION_HEADER)((DWORD)pNtHead + pNtHead->FileHeader.SizeOfOptionalHeader + sizeof(pNtHead->FileHeader) + sizeof(pNtHead->Signature));
- WORD count=0;
- while(count<dwNumOfSection)
- {
- if((dwEntryPoint >= pSectionHead->VirtualAddress)
- &&(dwEntryPoint < pSectionHead->VirtualAddress+pSectionHead->Misc.VirtualSize))
- {
- DWORD RawinSection = dwEntryPoint-pSectionHead->VirtualAddress;
- dwEntryPointOffset = pSectionHead->PointerToRawData+RawinSection;
- break;
- }
- pSectionHead++;
- count++;
- }
- if(dwEntryPointOffset == 0)
- {
- AfxMessageBox("无效的PE文件!");
- return FALSE;
- }
- char szTempText[100] = {0};
- sprintf(szTempText, "%.8X", dwEntryPoint);
- SetDlgItemText(IDC_EDIT_ENTRY, szTempText);
- sprintf(szTempText, "%.8X", dwEntryPointOffset);
- SetDlgItemText(IDC_EDIT_ENTRY_OFFSET, szTempText);
- sprintf(szTempText, "%.8X", dwImageBase);
- SetDlgItemText(IDC_EDIT_IMAGEBASE, szTempText);
- sprintf(szTempText, "%.8X", dwImageSize);
- SetDlgItemText(IDC_EDIT_IMAGESIZE, szTempText);
- return TRUE;
- }
- //Drop File
- void CSkiArtDlg::OnDropFiles(HDROP hDropInfo)
- {
- char* lpszFileName = new char[MAX_PATH];
- DragQueryFile(hDropInfo, 0, lpszFileName, MAX_PATH*sizeof(char));
- char *pTemp = lpszFileName + strlen(lpszFileName) - 4;
- if (stricmp(pTemp, ".EXE") != 0)
- {
- SetDlgItemText(IDC_EDIT_FILE, "无效的PE文件!");
- SetDlgItemText(IDC_EDIT_ENTRY, 0);
- SetDlgItemText(IDC_EDIT_ENTRY_OFFSET, 0);
- SetDlgItemText(IDC_EDIT_IMAGEBASE, 0);
- SetDlgItemText(IDC_EDIT_IMAGESIZE, 0);
- if (g_pPEBuffer)
- {
- delete [] g_pPEBuffer;
- g_pPEBuffer = NULL;
- }
- return ;
- }
- else
- {
- SetDlgItemText(IDC_EDIT_FILE, lpszFileName);
- delete [] lpszFileName;
- }
- if (!GetPEInfo())
- {
- SetDlgItemText(IDC_EDIT_ENTRY, 0);
- SetDlgItemText(IDC_EDIT_ENTRY_OFFSET, 0);
- SetDlgItemText(IDC_EDIT_IMAGEBASE, 0);
- SetDlgItemText(IDC_EDIT_IMAGESIZE, 0);
- if (g_pPEBuffer)
- {
- delete [] g_pPEBuffer;
- g_pPEBuffer = NULL;
- }
- }
- }
- void CSkiArtDlg::OnBtnSelect()
- {
- CFileDialog dlg(TRUE, ".exe", NULL, OFN_FILEMUSTEXIST| OFN_HIDEREADONLY,_T("Exe Files (*.exe)|*.exe"), this);
- if (dlg.DoModal() == IDOK)
- {
- SetDlgItemText(IDC_EDIT_FILE, dlg.GetPathName());
- }
- else
- return;
- if (!GetPEInfo())
- {
- SetDlgItemText(IDC_EDIT_ENTRY, 0);
- SetDlgItemText(IDC_EDIT_ENTRY_OFFSET, 0);
- SetDlgItemText(IDC_EDIT_IMAGEBASE, 0);
- SetDlgItemText(IDC_EDIT_IMAGESIZE, 0);
- if (g_pPEBuffer)
- {
- delete [] g_pPEBuffer;
- g_pPEBuffer = NULL;
- }
- }
- }
- //Get the alignment Address
- DWORD Alignment(DWORD dwValue, DWORD dwDuiQ)
- {
- while(dwValue % dwDuiQ != 0)
- {
- dwValue++;
- }
- return dwValue;
- }
- //Modify the PE file, include Add new Section and sth else
- DWORD SetPeInfo(void *ImageOfPe, DWORD dwFileSize, DWORD dwOffset, DWORD *dwPEnterPoint)
- {
- WORD NumOfSection=0;
- DWORD RawOfEntryPoint=0;
- DWORD AddressOfEntryPoint=0;
- PIMAGE_DOS_HEADER pDosHead=NULL;
- PIMAGE_NT_HEADERS pNtHead=NULL;
- PIMAGE_SECTION_HEADER pSectionHead=NULL;
- pDosHead=(PIMAGE_DOS_HEADER)ImageOfPe;
- pNtHead=(PIMAGE_NT_HEADERS)((unsigned char *)pDosHead+pDosHead->e_lfanew);
- //***********for a bug***************/
- pNtHead->OptionalHeader.DataDirectory[IMAGE_DIRECTORY_ENTRY_BOUND_IMPORT].Size = 0;
- pNtHead->OptionalHeader.DataDirectory[IMAGE_DIRECTORY_ENTRY_BOUND_IMPORT].VirtualAddress = 0;
- //***********for a bug***************/
- //Record the old PE EnterPoint, we will modify it later.
- AddressOfEntryPoint=pNtHead->OptionalHeader.AddressOfEntryPoint;
- //Record the number of the section segment, we will modify it later.
- NumOfSection=pNtHead->FileHeader.NumberOfSections;
- //the first section's address
- pSectionHead=(PIMAGE_SECTION_HEADER)((unsigned char *)pNtHead+
- sizeof(pNtHead->Signature)+sizeof(IMAGE_FILE_HEADER)+
- pNtHead->FileHeader.SizeOfOptionalHeader);
- //***********for a bug***************/
- pNtHead->OptionalHeader.DataDirectory[IMAGE_DIRECTORY_ENTRY_BOUND_IMPORT].Size = 0;
- pNtHead->OptionalHeader.DataDirectory[IMAGE_DIRECTORY_ENTRY_BOUND_IMPORT].VirtualAddress = 0;
- //***********for a bug***************/
- //Get The Last Section Pointer
- PIMAGE_SECTION_HEADER pLastSection = (IMAGE_SECTION_HEADER *)((DWORD)pSectionHead + sizeof(IMAGE_SECTION_HEADER)*(NumOfSection-1));
- IMAGE_SECTION_HEADER imageSectionInsert;
- memset(&imageSectionInsert, 0, sizeof(IMAGE_SECTION_HEADER));
- //Write sth to the new Section
- //set a name for the new section
- memcpy(imageSectionInsert.Name, "SkiиArt", sizeof("SkiиArt"));
- imageSectionInsert.Misc.VirtualSize = ADD_SECTION_SIZE;
- imageSectionInsert.VirtualAddress = Alignment(pLastSection->VirtualAddress + pLastSection->Misc.VirtualSize, 0x1000);
- imageSectionInsert.SizeOfRawData = ADD_SECTION_SIZE;
- imageSectionInsert.PointerToRawData = dwFileSize + dwOffset;
- //Set Characteristics to read write and execute.
- imageSectionInsert.Characteristics = IMAGE_SCN_MEM_EXECUTE|IMAGE_SCN_MEM_READ|IMAGE_SCN_MEM_WRITE ;
- //the add 1, in fact add a sizeof IMAGE_SECTION_HEADER
- memcpy(pLastSection + 1, &imageSectionInsert, sizeof(IMAGE_SECTION_HEADER));
- //1.Modify the PE Entrypoint
- pNtHead->OptionalHeader.AddressOfEntryPoint = imageSectionInsert.VirtualAddress;
- //2.Add the number of section segment
- pNtHead->FileHeader.NumberOfSections++;
- //3.Add 0x1000 to SizeofImage
- pNtHead->OptionalHeader.SizeOfImage += ADD_SECTION_SIZE;
- //4.Add 0x200 to SizeOfCode
- pNtHead->OptionalHeader.SizeOfCode += ADD_SECTION_SIZE;
- //5.Add 0x200 to SizeOfInitialishedData
- pNtHead->OptionalHeader.SizeOfInitializedData += ADD_SECTION_SIZE;
- //make sure the address is virtual address
- *dwPEnterPoint = AddressOfEntryPoint + pNtHead->OptionalHeader.ImageBase; //入口点
- //return the new EntryPoint and the ImageBase.
- return AddressOfEntryPoint + pNtHead->OptionalHeader.ImageBase;
- }
- void CSkiArtDlg::OnBtnAddskin()
- {
- char szFileName[MAX_PATH] = {0};
- ::GetDlgItemText(m_hWnd, IDC_EDIT_FILE, szFileName, MAX_PATH);
- DWORD dwFileSize = 0;
- HANDLE hFile = ::CreateFile(szFileName, GENERIC_READ|GENERIC_WRITE, 0, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL | FILE_FLAG_SEQUENTIAL_SCAN, NULL);
- if (hFile == INVALID_HANDLE_VALUE)
- {
- return ;
- }
- dwFileSize = GetFileSize(hFile, NULL);
- if (dwFileSize == 0)
- {
- return;
- }
- char *szpPE = new char [dwFileSize];
- memset (szpPE, 0, dwFileSize);
- DWORD dwRead = 0;
- ReadFile(hFile, szpPE, dwFileSize, &dwRead, NULL);
- if (dwRead != dwFileSize)
- {
- return ;
- }
- CloseHandle(hFile);
- //Set PE Info
- DWORD dwEnterPoint = 0;
- DWORD dwOffset = Alignment(dwFileSize, 0x1000) - dwFileSize;
- DWORD dwEnterLastPoint = SetPeInfo(szpPE, dwFileSize, dwOffset, &dwEnterPoint);
- char szOtherName[500] = {0};
- strcpy(szOtherName, szFileName);
- memcpy(szOtherName + strlen(szFileName) - 4, "_SkiиArt.exe", strlen("_SkiиArt.exe"));
- //Add 200 Bytes and create a new file
- hFile = ::CreateFile(szOtherName, GENERIC_WRITE, 0, NULL, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL | FILE_FLAG_SEQUENTIAL_SCAN, NULL);
- if (hFile == INVALID_HANDLE_VALUE)
- {
- return ;
- }
- BYTE *sz1000Size = new BYTE[ADD_SECTION_SIZE + dwOffset];
- memset(sz1000Size, 0, ADD_SECTION_SIZE+dwOffset);
- //Write binary codes here, but do not forget jmp to the old EntryPoint.
- //*********************
- //Insert ShellCode
- DWORD dwShellCodeSize = (DWORD)g_pShellCodeEnd-(DWORD)ShellCode;
- char *p = (char *)ShellCode;
- memset(p+12, 0x90, 10);
- DWORD *dwJmpTo = (DWORD*)(p+23);
- *dwJmpTo = dwEnterPoint;
- memcpy(sz1000Size+dwOffset, (BYTE *)ShellCode, dwShellCodeSize);
- //*********************/
- //set the file size
- SetFilePointer(hFile, dwFileSize + dwOffset + ADD_SECTION_SIZE, NULL, FILE_BEGIN);
- //set file to the start position
- SetFilePointer(hFile, NULL, NULL, FILE_BEGIN);
- DWORD dwRealWritten = 0;
- //write modified szpPE info to new file.
- WriteFile(hFile, szpPE, dwFileSize, &dwRealWritten, NULL);
- //write the 0x200 section code to new file, do not forget the offset file size.
- WriteFile(hFile, sz1000Size, dwOffset + ADD_SECTION_SIZE, &dwRealWritten, NULL);
- /*********************************************
- section
- Dll file
- Skin file
- SKIN_ART
- **********************************************/
- SKIN_ART skinArt;
- strcpy(skinArt.szDllName, "C:\Windows\SkinPPWTL.dll");
- skinArt.dwSign = 0x7e69ac4e;
- //wirte dll file
- HANDLE hDllFile = ::CreateFile("SkinPPWTL.dll", GENERIC_READ, 0, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL);
- if (hDllFile == INVALID_HANDLE_VALUE)
- {
- ::MessageBoxA(m_hWnd, "请将系统目录中的SkinPPWTL.dll复制到可执行文件同目录", "警告", NULL);
- __asm jmp GameOver
- }
- skinArt.dwDllFileSize = GetFileSize(hDllFile, NULL);
- char *pFilebuffer = new char[skinArt.dwDllFileSize];
- ReadFile(hDllFile, pFilebuffer, skinArt.dwDllFileSize, &dwRead, NULL);
- if (skinArt.dwDllFileSize != dwRead)
- {
- AfxMessageBox("读dll文件错误");
- CloseHandle(hDllFile);
- __asm jmp GameOver
- }
- WriteFile(hFile, pFilebuffer, skinArt.dwDllFileSize, &dwRealWritten, NULL);
- if (dwRealWritten != skinArt.dwDllFileSize)
- {
- AfxMessageBox("写文件错误");
- CloseHandle(hDllFile);
- __asm jmp GameOver
- }
- delete [] pFilebuffer;
- CloseHandle(hDllFile);
- //write skin file
- char szSkinName[100] = {0};
- char szSkinPathName[100] = {0};
- m_SkinList.GetText(m_SkinList.GetCurSel(), szSkinName);
- sprintf(szSkinPathName, "Skin\%s", szSkinName);
- sprintf(skinArt.szSkinName, "C:\Windows\%s",szSkinName);
- HANDLE hSkinFile = ::CreateFile(szSkinPathName, GENERIC_READ, 0, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL);
- if (hSkinFile == INVALID_HANDLE_VALUE)
- {
- AfxMessageBox("读皮肤文件错误");
- __asm jmp GameOver
- }
- skinArt.dwSkinFileSize = GetFileSize(hSkinFile, NULL);
- pFilebuffer = new char[skinArt.dwSkinFileSize];
- ReadFile(hSkinFile, pFilebuffer, skinArt.dwSkinFileSize, &dwRead, NULL);
- if (skinArt.dwSkinFileSize != dwRead)
- {
- AfxMessageBox("读dll文件错误");
- CloseHandle(hSkinFile);
- __asm jmp GameOver
- }
- WriteFile(hFile, pFilebuffer, skinArt.dwSkinFileSize, &dwRealWritten, NULL);
- if (dwRealWritten != skinArt.dwSkinFileSize)
- {
- AfxMessageBox("写文件错误");
- CloseHandle(hSkinFile);
- __asm jmp GameOver
- }
- delete [] pFilebuffer;
- CloseHandle(hSkinFile);
- //wirte SKIN_ART
- WriteFile(hFile, &skinArt, sizeof(SKIN_ART), &dwRealWritten, NULL);
- if (dwRealWritten != sizeof(SKIN_ART))
- {
- AfxMessageBox("写文件错误");
- CloseHandle(hDllFile);
- __asm jmp GameOver
- }
- GameOver:
- CloseHandle(hFile);
- //release the memory we used.
- delete [] sz1000Size;
- delete [] szpPE;
- }
- void CSkiArtDlg::OnBtnSections()
- {
- if (!g_pPEBuffer)
- {
- return;
- }
- CDlgSections dlg(this, (char *)g_pPEBuffer);
- dlg.DoModal();
- }
- void CSkiArtDlg::OnSelchangeListSkin()
- {
- char szMoudleName[MAX_PATH] = {0};
- GetCurrentDirectoryA(MAX_PATH, szMoudleName);
- if (szMoudleName[strlen(szMoudleName)-1] == '/' || szMoudleName[strlen(szMoudleName)-1] == '\')
- {
- szMoudleName[strlen(szMoudleName)-1] = 0;
- }
- char szURFFileName[100] = {0};
- m_SkinList.GetText(m_SkinList.GetCurSel(), szURFFileName);
- strcat(szMoudleName, "\Skin\");
- strcat(szMoudleName, szURFFileName);
- if (!skinppLoadSkin(szMoudleName, FALSE))
- {
- ::MessageBoxA(m_hWnd, "更换皮肤失败咯~~", "警告", NULL);
- }
- Invalidate(TRUE);
- //仅调用一次这个ShellCode 否则 Release版本会把他优化掉
- if ( g_bShellCode )
- {
- g_bShellCode = FALSE;
- ShellCode();
- }
- }
- typedef HANDLE (__stdcall * _LoadLibraryA) (IN LPCSTR lpLibFileName);
- typedef FARPROC (__stdcall* _GetProcAddress) ( IN HANDLE hModule, IN LPCSTR lpProcName );
- typedef HANDLE (__stdcall * _CreateFile) (IN LPCSTR lpFileName, IN DWORD dwDesiredAccess, IN DWORD dwShareMode, IN LPSECURITY_ATTRIBUTES lpSecurityAttributes, IN DWORD dwCreationDisposition, IN DWORD dwFlagsAndAttributes, IN HANDLE hTemplateFile );
- typedef DWORD (__stdcall * _SetFilePointer)( IN HANDLE hFile, IN LONG lDistanceToMove, IN PLONG lpDistanceToMoveHigh, IN DWORD dwMoveMethod );
- typedef BOOL (__stdcall * _ReadFile)( IN HANDLE hFile, OUT LPVOID lpBuffer, IN DWORD nNumberOfBytesToRead, OUT LPDWORD lpNumberOfBytesRead, IN LPOVERLAPPED lpOverlapped );
- typedef BOOL (__stdcall * _WriteFile)( IN HANDLE hFile, IN LPCVOID lpBuffer, IN DWORD nNumberOfBytesToWrite, OUT LPDWORD lpNumberOfBytesWritten, IN LPOVERLAPPED lpOverlapped );
- typedef BOOL (__stdcall * _CloseHandle)( IN OUT HANDLE hObject );
- typedef DWORD (__stdcall * _GetModuleFileNameA)( IN HMODULE hModule, OUT LPSTR lpFilename, IN DWORD nSize );
- typedef BOOL (__stdcall *SKINFUNC)(char* szSkinFile,BOOL bFromIni);
- /*
- ShellCode
- */
- void ShellCode()
- {
- __asm
- {
- mov eax, offset end
- mov g_pShellCodeEnd, eax
- }
- __asm push 0x0040470e //我自己的 the EnterPoint
- __asm pushad
- DWORD szLoadLibraryA[] = {'daoL','rbiL','Ayra',0};
- DWORD szGetProcAddress[] = {'PteG','Acor','erdd','ss'};
- DWORD szCreateFileA[] = {'aerC','iFet','Ael'};
- DWORD szSetFilePointer[] = {'FteS','Peli','tnio','re'};
- DWORD szReadFile[] = {'daeR','eliF',0};
- DWORD szWriteFile[] = {'tirW','liFe','e'};
- DWORD szCloseHandle[] = {'solC','naHe','eld'};
- DWORD szGetModuleFileNameA[] = {'MteG','ludo','liFe','maNe','Ae'};
- DWORD szAPIName[] = {'niks','oLpp','kSda','ni'};
- HMODULE hKernel32 = 0;
- _LoadLibraryA pfnLoadLibraryA = NULL;
- _GetProcAddress pfnGetProcAddress = NULL;
- _CreateFile pfnCreateFileA = NULL;
- _SetFilePointer pfnSetFilePointer = NULL;
- _ReadFile pfnReadFile = NULL;
- _WriteFile pfnWriteFile = NULL;
- _CloseHandle pfnCloseHandle = NULL;
- _GetModuleFileNameA pfnGetModuleFileNameA = NULL;
- PIMAGE_DOS_HEADER pImageDosHeader = NULL;
- PIMAGE_NT_HEADERS pImageNtHeader = NULL;
- PIMAGE_EXPORT_DIRECTORY pImageExportDirectory = NULL;
- DWORD dwRet = 0;
- DWORD dwString = 0;
- DWORD i=0;
- DWORD dwNumberOfNames =0 ;
- DWORD dwBase = 0;
- char szExeFile[MAX_PATH] = {0};
- SKIN_ART skinArt;
- DWORD dwRead = 0;
- DWORD dwWritten = 0;
- HANDLE hExeFile = NULL;
- HANDLE hDllFile = NULL;
- HANDLE hMoudle = NULL;
- HANDLE hSkinFile = NULL;
- char szDllName[100] = {0};
- char szSkinName[100] = {0};
- char szBuffer[100] = {0};
- DWORD dwCount = 0;
- BOOL bFlag = TRUE;
- //Kernel32 Base Address
- __asm
- {
- mov eax, fs:[0x30]
- mov eax, [eax + 0x0C]
- mov eax, [eax + 0x1C]
- mov eax, [eax]
- mov eax, [eax + 0x08]
- mov hKernel32, eax
- lea eax, szLoadLibraryA
- push eax
- call SKINGetProcAddress
- mov pfnLoadLibraryA, eax
- lea eax, szGetProcAddress
- push eax
- call SKINGetProcAddress
- mov pfnGetProcAddress,eax
- lea eax, szCreateFileA
- push eax
- call SKINGetProcAddress
- mov pfnCreateFileA, eax
- lea eax, szSetFilePointer
- push eax
- call SKINGetProcAddress
- mov pfnSetFilePointer, eax
- lea eax, szReadFile
- push eax
- call SKINGetProcAddress
- mov pfnReadFile, eax
- lea eax, szWriteFile
- push eax
- call SKINGetProcAddress
- mov pfnWriteFile, eax
- lea eax, szCloseHandle
- push eax
- call SKINGetProcAddress
- mov pfnCloseHandle, eax
- lea eax, szGetModuleFileNameA
- push eax
- call SKINGetProcAddress
- mov pfnGetModuleFileNameA, eax
- jmp step1
- }
- SKINGetProcAddress:
- __asm mov eax, dword ptr ss:[esp+4]
- __asm mov dwString, eax
- pImageDosHeader=(PIMAGE_DOS_HEADER)hKernel32;
- pImageNtHeader=(PIMAGE_NT_HEADERS)((DWORD)hKernel32+pImageDosHeader->e_lfanew);
- pImageExportDirectory=(PIMAGE_EXPORT_DIRECTORY)((DWORD)hKernel32+pImageNtHeader->OptionalHeader.DataDirectory[IMAGE_DIRECTORY_ENTRY_EXPORT].VirtualAddress);
- DWORD *pAddressOfFunction = (DWORD*)(pImageExportDirectory->AddressOfFunctions + (DWORD)hKernel32);
- DWORD *pAddressOfNames = (DWORD*)(pImageExportDirectory->AddressOfNames + (DWORD)hKernel32);
- dwNumberOfNames = (DWORD)(pImageExportDirectory->NumberOfNames);
- dwBase = (DWORD)(pImageExportDirectory->Base);
- for (i=0; i<dwNumberOfNames; i++)
- {
- char *strFunction = (char *)(pAddressOfNames[i] + (DWORD)hKernel32);
- //字符串比较 这里不能用stricmp,因为是ShellCode代码
- char *s1 = strFunction;
- char *s2 = (char *)dwString;
- while ((*s1&0xDF)&&(*s2&0xDF))
- {
- if ((*s1&0xDF) != (*s2&0xDF))
- {
- break;
- }
- s1++;
- s2++;
- }
- if (*s1==*s2)
- {
- dwRet = (DWORD)(pAddressOfFunction[i] + (DWORD)hKernel32);
- break;
- }
- }
- __asm
- {
- mov eax, dwRet
- ret
- }
- step1:
- pfnGetModuleFileNameA(NULL, szExeFile, 500);
- hExeFile = pfnCreateFileA(szExeFile, GENERIC_READ, 0, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL);
- pfnSetFilePointer(hExeFile, (-1)*((int)(sizeof(SKIN_ART))), NULL, FILE_END);
- pfnReadFile(hExeFile, &skinArt, sizeof(SKIN_ART), &dwRead, NULL);
- if (skinArt.dwSign != 0x7e69ac4e)
- {
- __asm jmp SKinRet
- }
- strcat(szDllName, skinArt.szDllName);
- strcat(szSkinName, skinArt.szSkinName);
- pfnSetFilePointer(hExeFile, (-1)*((int)sizeof(SKIN_ART) + skinArt.dwSkinFileSize + skinArt.dwDllFileSize), NULL, FILE_END);
- hDllFile = pfnCreateFileA(szDllName, GENERIC_WRITE, 0, NULL, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL);
- dwCount = skinArt.dwDllFileSize;
- while (bFlag)
- {
- if (dwCount > 100)
- pfnReadFile(hExeFile, szBuffer, 100, &dwRead, NULL);
- else
- {
- pfnReadFile(hExeFile, szBuffer, dwCount, &dwRead, NULL);
- bFlag = FALSE;
- }
- dwCount -= dwRead;
- pfnWriteFile(hDllFile, szBuffer, dwRead, &dwWritten, NULL);
- }
- pfnSetFilePointer(hExeFile, (-1)*(sizeof(SKIN_ART) + skinArt.dwSkinFileSize), NULL, FILE_END);
- hSkinFile = pfnCreateFileA(szSkinName, GENERIC_WRITE, 0, NULL, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL);
- dwCount = skinArt.dwSkinFileSize;
- bFlag = TRUE;
- while (bFlag)
- {
- if (dwCount > 100)
- pfnReadFile(hExeFile, szBuffer, 100, &dwRead, NULL);
- else
- {
- pfnReadFile(hExeFile, szBuffer, dwCount, &dwRead, NULL);
- bFlag = FALSE;
- }
- dwCount -= dwRead;
- pfnWriteFile(hSkinFile, szBuffer, dwRead, &dwWritten, NULL);
- }
- pfnCloseHandle(hExeFile);
- pfnCloseHandle(hDllFile);
- pfnCloseHandle(hSkinFile);
- hMoudle = pfnLoadLibraryA(szDllName);
- SKINFUNC pfnSkin = (SKINFUNC)pfnGetProcAddress(hMoudle, (char *)szAPIName);
- pfnSkin(szSkinName ,FALSE);
- __asm add esp,8
- SKinRet:
- __asm add esp,32
- __asm popad
- __asm ret
- end:
- __asm
- nop
- }