PE-Filebuffer-ImageBuffer-NewBuffer-已经修正-可正常执行

博客详细介绍了如何在C语言中修复PE文件的filebuffer、imagebuffer和newbuffer问题,确保文件能正常执行。通过分析globle.h文件头和具体代码段globle.cpp,博主展示了在petools.cpp中的最终执行解决方案。
摘要由CSDN通过智能技术生成

globle.h文件头

// globle.h: interface for the globle class.
//
//

#if !defined(AFX_GLOBLE_H__3D77A66B_EE77_4B6B_997F_15924F62332B__INCLUDED_)
#define AFX_GLOBLE_H__3D77A66B_EE77_4B6B_997F_15924F62332B__INCLUDED_

#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000

class globle  
{
   
public:
	globle();
	virtual ~globle();

};


#include <windows.h>
#include <stdio.h>

//#define FILEPATH_IN         "C:\\WINDOWS\\system32\\kernel32.dll"
//#define FilePath_In         "C:\\cntfpe\\notepad.exe"
#define FilePath_In         "C:\\cntfpe\\ipmsg.exe"
//#define FilePath_Out        "C:\\cntfpe\\notepadnewpes.exe"
#define FilePath_Out        "C:\\cntfpe\\ipmsgnewpes.exe"
#define MessageBoxAddr      0x77E5425F
#define ShellCodeLength     0x12

extern BYTE ShellCode[];

DWORD ReadPEFile(IN LPSTR lpszFile,OUT LPVOID* pFileBuffer);

DWORD CopyFileBufferToImageBuffer(IN LPVOID pFileBuffer,OUT LPVOID* pImageBuffer);

DWORD CopyImageBufferToNewBuffer(IN LPVOID pImageBuffer,OUT LPVOID* pNewBuffer);

BOOL MemeryTOFile(IN LPVOID pMemBuffer,IN size_t size,OUT LPSTR lpszFile);

//DWORD RvaToFileOffset(IN LPVOID pFileBuffer,IN DWORD dwRva);


void Fun();


#endif // !defined(AFX_GLOBLE_H__3D77A66B_EE77_4B6B_997F_15924F62332B__INCLUDED_)

##具体代码部分globle.cpp

// globle.cpp: implementation of the globle class.
//
//

#include "stdafx.h"
#include "globle.h"
#include <string.h>
#include <windows.h>
#include <stdlib.h>
/*#include <tchar.h>
#include <iostream>
#include <stdio.h>
*/

//
// Construction/Destruction
//

 // globle.cpp: implementation of the globle class.
//
//

// Globle Varible  
BYTE ShellCode[] =
{
   
    0x6A,00,0x6A,00,0x6A,00,0x6A,00,
    0xE8,00,00,00,00,
    0xE9,00,00,00,00
};

//
// Construction/Destruction
//
//ExeFile->FileBuffer  返回值为计算所得文件大小

DWORD ReadPEFile(IN LPSTR lpszFile, OUT LPVOID* pFileBuffer)
{
   
    FILE* pFile = NULL;
    DWORD fileSize = 0;
    LPVOID pTempFileBuffer = NULL;
    
    //Open The Files
    pFile = fopen(lpszFile,"rb");
    if (!pFile)
在微信小程序中,选择文件并上传至云存储通常涉及以下几个步骤: **小程序端(前端)代码示例**(使用WXML、WXSS和JS编写): ```wxml <!-- index.wxml --> <view> <button bindtap="chooseFile">选择文件</button> <view wx:if="{{fileList.length > 0}}"> <text>{{fileList[0].name}}</text> <button bindtap="uploadFile">上传文件</button> </view> </view> <!-- index.js --> Page({ data: { fileList: [], }, chooseFile: function() { wx.chooseFile({ success: res => { this.setData({ fileList: res.tempFiles, }); } }); }, uploadFile: async function() { const file = this.fileList[0]; await cloud.uploadFile({ filePath: file.path, // 文件路径 fileName: file.name, // 新的文件名(如果需要) 雲存儲地址: 'your-cloud-storage-url', // 替换为实际的云存储URL header: { 'content-type': 'application/octet-stream', }, }).then(res => { console.log('上传成功', res); this.uploadToCloudFunction(file.url); // 调用云函数处理上传文件 }); }, uploadToCloudFunction:云.request({ url: 'https://your-function-url', // 云函数的URL method: 'POST', data: { url: file.url, // 上传文件的链接 }, }), }); ``` **云函数(Node.js + node-xlsx)代码示例**: ```javascript // cloud_function.js (假设已安装了express和axios依赖) const express = require('express'); const axios = require('axios'); const xlsx = require('node-xlsx'); const app = express(); app.post('/processExcel', async (req, res) => { try { const uploadedUrl = req.body.url; // 微信云存储的文件URL const response = await axios.get(uploadedUrl, { responseType: 'stream' }); const fileBuffer = []; response.data.on('data', chunk => fileBuffer.push(chunk)); response.data.on('end', () => { const workbook = xlsx.parse(Buffer.concat(fileBuffer)); // 进行解析操作,例如获取数据或分析工作簿 const parsedData = processWorkbook(workbook); res.json({ result: parsedData }); }); } catch (error) { console.error(error); res.status(500).json({ error: 'Error processing Excel file' }); } }); const PORT = process.env.PORT || 3000; app.listen(PORT, () => { console.log(`Cloud Function listening on port ${PORT}`); }); ``` 以上代码展示了基本流程,但在实际应用中,你需要替换`your-cloud-storage-url`和`your-function-url`为实际的云存储地址和云函数地址,并处理`processWorkbook`函数以适应你的需求。 **相关问题--:** 1. 小程序如何处理文件上传失败的情况? 2. 云函数如何保证文件安全地保存和访问? 3. 在处理Excel文件时,如何避免node-xlsx的内存消耗过大?
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值