このプログラムには、もともと標準化されていない規則を使用していた cdecl 呼び出し規則を実装する必要がありました。私が知る限り、それは正しいように見えますが、「アクセス違反の書き込み場所0x00000066。プログラムが「バイトptr [eax]ではありません」という行に到達したときにヒットするようです」という未処理の例外エラーが発生します。矢印はプログラムを中断した後のポイントです。
私のプログラムの何が問題なのか、どうすれば修正できるのか、誰か教えてもらえますか? ありがとうございました。
void encrypt_chars (int length, char EKey)
{ char temp_char;
for (int i = 0; i < length; i++)
{
temp_char = OChars [i];
__asm {
push eax
movzx eax, temp_char
push eax
lea eax, EKey
push eax
call encrypt
mov temp_char, al
pop eax
}
EChars[i] = temp_char;
return;
// Inputs: register EAX = 32-bit address of Ekey,
// ECX = the character to be encrypted (in the low 8-bit field, CL).
// Output: register EAX = the encrypted value of the source character (in the low 8-bit field, AL).
__asm {
encrypt:
push ebp
mov ebp, esp
mov ecx, 8[ebp]
mov eax, 12[ebp]
push edi
push ecx
not byte ptr[eax]
add byte ptr[eax], 0x04
movzx edi, byte ptr[eax]
pop eax
xor eax, edi
pop edi
rol al, 1
rol al, 1
add al, 0x04
mov esp, ebp
pop ebp
ret
}