Как бы я установить значение «0xA5» в качестве первых 5 байтов моей строки «Теперь сообщение:»? - PullRequest
0 голосов
/ 17 апреля 2020

В настоящее время мой вывод выглядит следующим образом:

enter image description here

Но я бы хотел заменить первые 5 байтов строки "Конец близок !» с 'A5' в конце моей функции x_memset после оператора "Теперь сообщение:".

#include <stdio.h>
#include <string.h>
#include <Windows.h>


void printBytes(char *data, int length)
{
    int x;
    for (x = 0; x < length; x++)
    {
        if ((x & 0xF) == 0) printf("\n");
        printf("%02X ", (unsigned char)data[x]);
    }
    printf("\n\n");
    return;
} // printBytes

void x_memset(void *destination, unsigned char value, int nCount,char *str) {

    __asm {
            mov eax, 16; push the length
            push eax
            mov eax, 0x41; push the value
            push eax
            lea eax, str; push the address of string
            push eax
            call inline_memset
            add esp, 12
            jmp EXIT
        inline_memset :
            mov ecx, [nCount]
            mov edi, [destination]
            mov al, [value]
            mov ebx, ecx
    //      shr ecx, 2
    //      and ebx, 3
    //      rep stosd
    //      mov ecx, ebx
    //      rep stosb
        EXIT:

    }
    printf("\nNow the message is : %s\n", str);
    printBytes(str, strlen(str));

    return;

} // end function

int main()
{
    char string[] = "The end is near!"; // this is 16 bytes + null
    printf("The message is : %s\n", string);
    printBytes(string,strlen(string));

    x_memset(0x1000,0xA5,5,string);
    //puts(string);
    //fflush(stdin);
    getchar();
    return 0;
}

Я очень ценю любую помощь, которую вы можете предложить!

...