Click here to Skip to main content
15,896,727 members
Articles / Programming Languages / ASM

Grafting Compiled Code: Unlimited Code Reuse

Rate me:
Please Sign up or sign in to vote.
4.83/5 (30 votes)
7 Mar 2008CPOL17 min read 95.4K   2.2K   83  
Add functionality to a project using existing compiled machine code.
// PEChecksum.h : header file
//

#pragma once


// CPEChecksum dialog
class CPEChecksum: public CDialog
{
    // Construction
public:
    CPEChecksum(CWnd* pParent = NULL); // standard constructor

    // Dialog Data
    enum{ IDD = IDD_PECHECKSUM_DIALOG };

protected:
    virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support


    // Implementation
protected:
    HICON m_hIcon;

    // Generated message map functions
    virtual BOOL OnInitDialog();
    afx_msg void OnPaint();
    afx_msg HCURSOR OnQueryDragIcon();
    DECLARE_MESSAGE_MAP()
public:
    afx_msg void OnBnClickedRetrieveChecksum();
    afx_msg void OnBnClickedBrowse();

protected:
    BOOL SelectFile( CString& );
    BOOL RetrieveFilename( CString& );
    BOOL RetrieveAndCalculateChecksum( const CString&, DWORD32&, DWORD32& );
    BOOL RetrieveNewChecksum( DWORD32& );
    BOOL CalculateChecksum( const CString&, DWORD32&, DWORD32& );
    BOOL WriteChecksum( DWORD32& );

    BOOL MapFile( const CString& szFilename );
    BOOL UnmapFile( );

    VOID DisplayError( DWORD dwError );
    VOID DisplayWarning( DWORD dwError );

protected:
    HANDLE hFile;
    HANDLE hFileMapping;
    PVOID pBaseAddress;

public:
    afx_msg void OnBnClickedBtnWriteChecksum();
};

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


Written By
Systems / Hardware Administrator
United States United States
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.

Comments and Discussions