Форум программистов
 

Восстановите пароль или Зарегистрируйтесь на форуме, о проблемах и с заказом рекламы пишите сюда - alarforum@yandex.ru, проверяйте папку спам!

Вернуться   Форум программистов > Низкоуровневое программирование > Assembler - Ассемблер (FASM, MASM, WASM, NASM, GoASM, Gas, RosAsm, HLA) и не рекомендуем TASM
Регистрация

Восстановить пароль
Повторная активизация e-mail

Купить рекламу на форуме - 42 тыс руб за месяц

Ответ
 
Опции темы Поиск в этой теме
Старый 26.11.2013, 22:45   #1
Ecosasha
Форумчанин
 
Регистрация: 22.05.2009
Сообщений: 248
По умолчанию Delphi XE2 x64 asm написанная под x32 преобразование к x64

Есть такая функция procedure EnCipher(var Source: AnsiString),
источник http://delphiworld.narod.ru/base/encode_s_coder.html

Для приложения в Delphi XE2 x64, попробовал преобразовать, чтобы работало в нем:

Код:
procedure EnCipher(var Source: AnsiString);

{Low order, 7-bit ASCII (char. 32-127) encryption designed for database use.
 Control and high order (8 bit) characters are passed through unchanged.

 Uses a hybrid method...random table substitution with bit-mangled output.
 No passwords to worry with (the built-in table is the password). Not industrial
 strength but enough to deter the casual hacker or snoop. Even repeating char.
 sequences have little discernable pattern once encrypted.

 NOTE: When displaying encrypted strings, remember that some characters
       within the output range are interpreted by VCL components; for
       example, '&'.}

asm
    Push RSI //Save the good stuff
    Push RDI

    Or RAX,RAX
    Jz @Done
    Push RAX
    Call UniqueString
    Pop RAX

    Mov RSI,[RAX] //String address into ESI
    Or RSI,RSI
    Jz @Done
    Mov RCX,[RSI-4] //String Length into ECX
    Jrcxz @Done //Abort on null string
    Mov RDX,RCX //initialize EDX with length
    Lea RDI,@ECTbl //Table address into EDI
    Cld //make sure we go forward
  @L1:
    Xor RAX,RAX
    Lodsb //Load a byte from string
    Sub AX,32 //Adjust to zero base
    Js @Next //Ignore if control char.
    Cmp AX,95
    Jg @Next //Ignore if high order char.
    Mov AL,[RDI+RAX] //get the table value
    Test CX,3 //screw it up some
    Jz @L2
    Rol RDX,3
@L2:
    And DL,31
    Xor AL,DL
    Add RDX,RCX
    Add RDX,RAX
    Add AL,32 //adjust to output range
    Mov [RSI-1],AL //write it back into string
@Next:
    Dec RCX
    Jnz @L1
// Loop @L1 //do it again if necessary

@Done:
    Pop RDI
    Pop RSI

    Jmp @Exit
// Ret //this does not work with Delphi 3 - EFD 971022

@ECTbl: //The encipher table
    DB 75,85,86,92,93,95,74,76,84,87,91,94
    DB 63,73,77,83,88,90,62,64,72,78,82,89
    DB 51,61,65,71,79,81,50,52,60,66,70,80
    DB 39,49,53,59,67,69,38,40,48,54,58,68
    DB 27,37,41,47,55,57,26,28,36,42,46,56
    DB 15,25,29,35,43,45,14,16,24,30,34,44
    DB 06,13,17,23,31,33,05,07,12,18,22,32
    DB 01,04,08,11,19,21,00,02,03,09,10,20
@Exit:

end;
P.S. Плохо знаю ассемблер, что требуется учесть в преобразовании к x64 еще, чтобы работало? То есть заменил EDI - RDI, ESI -RSI, ECX - RCX и так далее.
Ecosasha вне форума Ответить с цитированием
Ответ


Купить рекламу на форуме - 42 тыс руб за месяц

Опции темы Поиск в этой теме
Поиск в этой теме:

Расширенный поиск


Похожие темы
Тема Автор Раздел Ответов Последнее сообщение
JVCL на XE2, ос x64 RPGer C++ Builder 1 31.03.2013 17:42
ListView рабочего стола (x32 и x64 системы) IvanNovator Win Api 2 22.01.2013 12:33
Delphi 6 под Windows x64 RuVarez Общие вопросы Delphi 9 01.09.2011 02:19
C++ Bilder or Delphi под x64 SunKnight Свободное общение 5 10.02.2010 11:18
Компилятор C под XP x64 .ghost Общие вопросы C/C++ 1 28.01.2010 20:46