我有一份合同A和一份合同B。
合约A声明了这个函数:
function getIntValue() constant returns (uint);
Run Code Online (Sandbox Code Playgroud)
delegatecall从 B承包 A 的功能的适当汇编代码是什么getIntValue?我对组装还不太有经验,所以到目前为止我只有这个不起作用:
function getContractAIntValue() constant returns (uint c) {
address addr = address(contractA); // contract A is stored in B.
bytes4 sig = bytes4(sha3("getIntValue()")); // function signature
assembly {
let x := mload(0x40) // find empty storage location using "free memory pointer"
mstore(x,sig) // attach function signature
let status := delegatecall(sub(gas, 10000), addr, add(x, 0x04), 0, x, 0x20)
jumpi(invalidJumpLabel, iszero(status)) // error out if unsuccessful delegatecall
c := …Run Code Online (Sandbox Code Playgroud) 我正在尝试使用跳转表在程序集(MASM64,Windows,x64)中实现算法。基本思想是:我需要对数据进行3种不同类型的操作。这些操作取决于一些变量,但是我发现实现许多切换和许多长的实现很乏味。
PUBLIC superFunc@@40 ;__vectorcall decoration
.DATA
ALIGN 16
jumpTable1 qword func_11, func_12, func_13, func_14
jumpTable2 qword func_21, func_22, func_23, func_24
jumpTable3 qword func_31, func_32, func_33, func_34
.CODE
superFunc@@40 PROC
;no stack actions, as we should do our stuff as a leaf function
;assume the first parameter (rcx) is our jumpTable index, and it's
;the same index for all functions
mov rax, qword ptr [rcx*8 + offset jumpTable1]
mov r10, qword ptr [rcx*8 + offset jumpTable2]
mov r11, qword ptr [rcx*8 …Run Code Online (Sandbox Code Playgroud) 我目前正在对软件进行逆向工程,该软件可以为给定的数据缓冲区计算2字节宽的校验和。该代码来自16位DLL(NE格式),并使用Borland C ++进行了编译。我怀疑校验和为CRC-16,且多边形为0x8408,但是我没有机会计算相同的CRC,所以我想知道实现是否为“ CRC16标准”。
这是程序集的实现:
crc_cal proc far
var_4= word ptr -4
arg_0= word ptr 6
arg_2= dword ptr 8
mov ax, seg dseg37
inc bp
push bp
mov bp, sp
push ds
mov ds, ax
sub sp, 2
push si
push di
xor cx, cx
mov dx, 0FFFFh
mov [bp+var_4], 8408h
loc_42646:
les bx, [bp+arg_2]
add bx, cx
mov al, es:[bx]
xor al, dl
mov dl, al
inc cx
xor di, di
jmp short loc_42672
loc_42657:
mov si, dx …Run Code Online (Sandbox Code Playgroud) 我正在编写一个 bootsector 游戏,它试图复制没有互联网时可以玩的 chrome 恐龙游戏。
为此,我必须从左向右跑,直到玩家击中仙人掌。
我如何实现这一目标?(如何使终端从右向左滚动,使其看起来像是在移动?)因此,我需要从右向左和从左向右滚动,而不是向上和向下滚动。我在 16 位实模式 (BIOS),我使用 nasm/intel 语法。
我正在调试一个带有修改过的boringssl 的chrome。它总是有一个SegmentFault。我发现问题是
EC_GROUP_get_curve_name(EC_KEY_get0_group(ec));
Run Code Online (Sandbox Code Playgroud)
反汇编代码:
callq EC_KEY_get0_group
mov %eax,%edi
callq EC_GROUP_get_curve_name
Run Code Online (Sandbox Code Playgroud)
的返回类型EC_KEY_get0_group是一个EC_GROUP*指针,但它是EC_GROUP_get_curve_name由一个 32 位寄存器传递给的。
指针被截断并导致 SegmentFault。为什么编译器会生成这样的代码?是否有任何编译器选项可以避免这种情况?
我使用以下命令通过命令提示符打开和编辑文件.但在我的系统中不允许编辑该文件并返回错误.但在我的笔记本电脑编辑器窗口中打开以编辑此文件.
'edit' is not recognized as an internal or external command,
operable program or batch file.
Run Code Online (Sandbox Code Playgroud) 我有以下装配线:
...
MOV ECX, 0x36EE80
MOV EDX, 0x95217CB1
MUL EDX
SHR EDX, 0x15
MOV DWORD PTR SS:[EBP-0x3C8], EDX
....
....
Run Code Online (Sandbox Code Playgroud)
因此,在http://en.wikibooks.org/wiki/X86_Assembly/Arithmetic中我已经读过MUL的操作数(在这种情况下是EDX)的值乘以EAX中的值.因此,在EAX中,我的值为0330FD3B(十进制:53542203).在EDX中,我的值为95217CB1(十进制:2501999793).但在MUL操作之后,我在EDX中的值为01DBEE41(十进制:31190593).但这一定是错的,因为53542203*2501999793不是31190593 ......
有人可以解释一下吗?
ROM或RAM中的中断向量表是?如果它在RAM中,它从哪里加载?此外,该表是否依赖于操作系统?例如,在MS-DOS中,"int 0x80"用于播放音乐和内容,但在Linux中它是一个系统调用.那么,在MS-DOS中,操作系统或ROM是否处理中断0x80?如果它在ROM中,Linux是否会覆盖表项?
我目前正在遵循启用GDT细分的指南.我正在使用GNU Assembler和Bochs进行仿真.
我知道我需要使用GDT描述符加载GDT寄存器.我已经完成了,接下来的步骤是将所有具有相对于GDT的偏移的段寄存器加载到代码/数据段描述符的各个位置.这样做的代码如下:
reloadSegments:
; Reload CS register containing code selector:
JMP 0x08:reload_CS ; 0x08 points at the new code selector
.reload_CS:
; Reload data segment registers:
MOV AX, 0x10 ; 0x10 points at the new data selector
MOV DS, AX
MOV ES, AX
MOV FS, AX
MOV GS, AX
MOV SS, AX
RET
Run Code Online (Sandbox Code Playgroud)
但是,我无法理解如何可以隐式加载具有偏移量的CS寄存器,而不会显着跳跃到CS:IP对指向的任何内存位置 - 即,如果代码段描述符位于GDT_start + 0x10,我尝试将0x10加载到CS寄存器,虚拟机跳转到0x10:IP,我从不输入.reload_CS标签.
我的例程版本(at&t语法):
_start:
// Disable interrupts
cli
// Load GDT register with location of GDT
lgdt 0x3c
// Load location of Code …Run Code Online (Sandbox Code Playgroud) 如何仅使用英特尔 64 位汇编和 nasm 汇编器创建/处理用一种颜色填充的简单 bmp 文件?