• B правой части каждого сообщения есть стрелки и . Не стесняйтесь оценивать ответы. Чтобы автору вопроса закрыть свой тикет, надо выбрать лучший ответ. Просто нажмите значок в правой части сообщения.

  • 15 апреля стартует «Курс «SQL-injection Master» ©» от команды The Codeby

    За 3 месяца вы пройдете путь от начальных навыков работы с SQL-запросами к базам данных до продвинутых техник. Научитесь находить уязвимости связанные с базами данных, и внедрять произвольный SQL-код в уязвимые приложения.

    На последнюю неделю приходится экзамен, где нужно будет показать свои навыки, взломав ряд уязвимых учебных сайтов, и добыть флаги. Успешно сдавшие экзамен получат сертификат.

    Запись на курс до 25 апреля. Получить промодоступ ...

Как Же Использует Ассемблер Владислав Пирогов В Главе Совместное Испол

  • Автор темы Dimkawshm
  • Дата начала
D

Dimkawshm

Книгу Владислав Пирогова Юрьевича я скачал висьма недавно, я открыл ее и раньше и прочитал 5 листов.

Читаю сегодня




Простой пример использования ассемблера
с языками высокого уровня
В данном разделе рассматривается простой модуль на языке ассемблера, со-
держащий процедуру, копирующую одну строку в другую. Мы подсоединяем
этот модуль к программам, написанным на языках С и Паскаль, с использо-
ванием трансляторов: Visual C++ 2005 и Delphi 8.0.
Остановимся вначале на языке C++. Функцию, вызываемую из модуля, напи-
санного на языке ассемблера, мы объявляем при помощи модификаторов
Глава 3.7. Совместное использование ассемблера с языками высокого уровня 585
extern "C" и С (в ассемблерном модуле). Соглашение C предполагает, что
стек освобождается в вызывающем модуле (см. табл. 3.7.1). В ассемблерном
модуле вызываемая процедура должна быть дополнительно объявлена при
помощи директивы PUBLIC. Модули на языке ассемблера и языке C++ пред-
ставлены в листинге 3.7.1.
Листинг 3.7.1. Пример подключения объектного модуля к программе на языке
C++ (тип согласования вызовов C)
//файл copyc.cpp
#include <stdio.h>
#include <windows.h>
extern "C" char * COPYSTR(char *, char *);
void main()
{
char s1[100];
char *s2="Privet!";
printf("%s\n",COPYSTR(s1,s2));
printf("%s\n",s1);
ExitProcess(0);
}
;файл copy.asm
.586P
;плоская модель памяти
.MODEL FLAT, C
PUBLIC COPYSTR
_TEXT SEGMENT
;процедура копирования одной строки в другую
;строка, куда копировать [EBP+08H]
;строка, что копировать [EBP+0СH]
;не учитывает длину строки, куда производится копирование
COPYSTR PROC
PUSH EBP
MOV EBP,ESP
MOV ESI,DWORD PTR [EBP+0CH]
MOV EDI,DWORD PTR [EBP+08H]
L1:
MOV AL,BYTE PTR [ESI]
MOV BYTE PTR [EDI],AL
CMP AL,0
JE L2
INC ESI
INC EDI
586 Часть III. Сложные примеры программирования в Windows
JMP L1
L2:
MOV EAX,DWORD PTR [EBP+08H]
LEAVE
RET
COPYSTR ENDP
_TEXT ENDS
END
Трансляция программы из листинга 3.7.1:
ml /c /coff copy.asm
Далее транслируется программа на языке C++.
Комментарий к модулям в листинге 3.7.1.
 Для того чтобы скомпоновать объектный модуль в проект на языке Visual
C++, следует обратиться к окну свойств проекта. На вкладке Linker |
Command Line указать полное имя объектного модуля. В нашем случае
я указал ..\..\..\copy.obj.
 Обратите внимание, как мы согласовали параметры. Выбрав тип согласо-
вания C, мы тем самым избавили себя от суффикса @, а во-вторых, нам не
надо заботиться об очистке стека в ассемблерном модуле, потому что очи-
стку осуществляет вызывающая сторона.
Зададимся теперь следующим вопросом. Как следует изменить ассемблерный
модуль, если в нем установлено соглашение о вызовах stdcall? Порядок сле-
дования параметров не изменился, но MASM будет добавлять в конце имени
суффикс @. В данном случае в модуле на языке C++ следует указать при объ-
явлении функции COPYSTR тип вызова __stdcall (листинг 3.7.2).



Так вот. Я же знаю что тут что то не то. Как то не так Владислав Юрьевич пишет. В С++ принято вставлять ассемблерный код с помощю __asm{ юююю }

Как это его с ключами ассемблировать? ..Читаю и перечитываю. Если в студии то как с ключами, а если батником и с помощю masm32 или побного и заранее то тагда что, я же получу экзешник и что?

Что же имел Пирогов Владислав Юрьевич?
 
D

Dimkawshm

Имел он следующее. MSDN subscriptions
Get tools


Например
Только все равно непонятно. Вроде все написано, но точно понять пока не могу. Не то что я все слова совсем не понимаю, вроде почти понятно написано.


Setting the Path and Environment Variables for Command-Line Builds
Visual Studio 2013 Other Versions Visual Studio 2012 Visual Studio 2010 Visual Studio 2008 Visual Studio 2005 Visual Studio .NET 2003 2 out of 6 rated this helpful - Rate this topic The Visual C++ command-line build tools require several environment variables that are customized for your installation. When Visual Studio is installed, it creates command files that set the required environment variables, and then creates shortcuts that start a Command Prompt window that already has these variables set. When you want to use the command-line tools, you can run one of these shortcuts, or you can open a plain Command Prompt window and then run the vcvarsall.bat command file.

The Visual C++ command-line tools use the PATH, TMP, INCLUDE, LIB, and LIBPATH environment variables, and may also use tool-specific environment variables. Because the values of these environment variables are specific to your installation, and can be changed by product updates or upgrades, we recommend that you use vcvarsall.bat or a Developer Command Prompt shortcut instead of setting them yourself. For information about the specific environment variables used by the compiler and linker, see CL Environment Variables and LINK Environment Variables.

Note
Several command-line tools or tool options require Administrator permission. To use them, we recommend that you open a Command Prompt window by using the Run as Administrator option (on the shortcut menu for the Command Prompt window you want to open).


Using the Command Prompt shortcuts


--------------------------------------------------------------------------------

The Developer Command Prompt shortcut that's included in every edition of Visual Studio opens a Command Prompt window and sets the environment to use the 32-bit x86-native toolset to target x86 processors. Command Prompts for 32-bit cross-compilers that target x64 and ARM platforms are also available. Depending on your system and the edition of Visual Studio installed, a Command Prompt shortcut for a 64-bit x64-native toolset that targets x64 processors, and one for a 64-bit cross-compiler that targets x86 processors, may also be available. These versions of the command-line toolset are available in all editions of Visual Studio:

x86 on x86
Use this toolset to create output files for x86 machines. It runs as a 32-bit process, native on an x86 machine and under WOW64 on a 64-bit Windows operating system.

x64 on x86 (x64 cross-compiler)
Use this toolset to create output files for x64. It runs as a 32-bit process, native on an x86 machine and under WOW64 on a 64-bit Windows operating system.

ARM on x86 (ARM cross compiler)
Use this toolset to create output files for ARM machines. It runs as a 32-bit process, native on an x86 machine and under WOW64 on a 64-bit Windows operating system.

These versions of the command-line toolset are available on 64-bit platforms:

x86 on x64
Use this toolset to create output files for x86 machines. It runs as a native process on a 64-bit Windows operating system.

x64 on x64
Use this toolset to create output files for x64 machines. It runs as a native process on a 64-bit Windows operating system.

ARM on x64 (ARM cross compiler)
Use this toolset to create output files for ARM machines. It runs as a native 64-bit process on a 64-bit Windows operating system.

To open a Developer Command Prompt window
1.With the Windows 8 Start screen showing, type Visual Studio Tools. Notice that the search results change as you type; when Visual Studio Tools appears, choose it.

On earlier versions of Windows, choose Start, and then in the search box, type Visual Studio Tools. When Visual Studio Tools appears in the search results, choose it.

2.In the Visual Studio Tools folder, open the Developer Command Prompt for your version of Visual Studio. (To run as administrator, open the shortcut menu for the Developer Command Prompt and choose Run as Administrator.)

The Developer Command Prompt sets the environment to use the 32-bit native toolset to target x86 processors. Choose the x64 Cross Tools Command Prompt to use the 32-bit native toolset to target x64 processors. Choose the ARM Cross Tools Command Prompt to use the 32-bit native toolset to target ARM processors. Choose the x64 Native Tools Command Prompt to use the 64-bit native toolset to target x64 processors.

Using vcvarsall.bat in a Command Prompt window


--------------------------------------------------------------------------------

By running vcvarsall.bat in a plain Command Prompt window, you can set environment variables to configure the command line for native 32-bit or 64-bit compilation, or for cross-compilation to x86, x64, or ARM processors. If no arguments are provided, vcvarsall.bat configures the environment variables for using the 32-bit native compiler for x86 targets. However, you can use it to configure any of the compilers. If you specify a compiler configuration that is not installed or is not available on your build computer architecture, a message is displayed. The following table shows the supported arguments.

Vcvarsall.bat argument
Compiler
Build-computer architecture
Build output architecture

x86
x86 32-bit native
x86, x64
x86

x86_amd64
x64 on x86 cross
x86, x64
x64

x86_arm
ARM on x86 cross
x86, x64
ARM

amd64
x64 64-bit native
x64
x64

amd64_x86
x86 on x64 cross
x64
x86

amd64_arm
ARM on x64 cross
x64
ARM


The following steps show how to configure a Command Prompt to use the 32-bit native toolset to target x86 platforms.

To run vcvarsall.bat
1.At the command prompt, change to the Visual C++ installation directory. (The location depends on the system and the Visual Studio installation, but a typical location is C:\Program Files (x86)\Microsoft Visual Studio version\VC\.) For example, enter:

cd "\Program Files (x86)\Microsoft Visual Studio 12.0\VC"

2.To configure this Command Prompt window for 32-bit x86 command-line builds, at the command prompt, enter:

vcvarsall x86

Visual Studio also provides vcvars32.bat to set up a command-line environment. The vcvars32.bat file is limited to setting the appropriate environment variables to enable 32-bit x86 command-line builds. It's the equivalent of the vcvarsall x86 command.

If you are using DEVENV for command-line builds, the environment set by vcvarsall.bat or vcvars32.bat does not affect your builds, unless you also specify the /useenv option.
 
D

Dimkawshm

Поиск в компьютере Developer Command Prompt результатов не дал. В общем если кому не в лом, опишите пожалуста по русски про эту самую ситуацию, т.к в целом малопонятно с чем его едят и чтоже делать.
 
Мы в соцсетях:

Обучение наступательной кибербезопасности в игровой форме. Начать игру!