addressing

Simpletron machine and indirect addressing

霸气de小男生 提交于 2019-12-06 09:28:46
I recently made the Simpletron assignment from the Deitel and Deitel textbook. The Simpletron machine language has only one addressing mode which is direct addressing. (That is, you have to specify the address you want to access in the operand part of the instruction.) So I think there is no way of computing an address at run time and access it. So doing something like this: [pseudo-c] int a[10]; ... int i = 0; while(a[i] > 100) { i++; } .. would require some self modifying code or expanding the loop, am I correct? So my question is: The textbook presents Simpletron as very similar to early

Absolute addressing for runtime code replacement in x86_64

有些话、适合烂在心里 提交于 2019-12-05 03:41:45
I'm currently using some code replace scheme in 32 bit where the code which is moved to another position, reads variables and a class pointer. Since x86_64 does not support absolute addressing I have trouble getting the correct addresses for the variables at the new position of the code. The problem in detail is, that because of rip relative addressing the instruction pointer address is different than at compile time. So is there a way to use absolute addressing in x86_64 or another way to get addresses of variables not instruction pointer relative? Something like: leaq variable(%%rax), %%rbx

MATLAB: extract submatrix with logical indexing

别等时光非礼了梦想. 提交于 2019-12-05 03:23:59
I'm looking for an elegant solution to this very simple problem in MATLAB. Suppose I have a matrix >> M = magic(5) M = 17 24 1 8 15 23 5 7 14 16 4 6 13 20 22 10 12 19 21 3 11 18 25 2 9 and a logical variable of the form I = 0 0 0 0 0 0 1 1 0 0 0 1 1 0 0 0 0 0 0 0 0 0 0 0 0 If I try to retrieve the elements of M associated to 1 values in I , I get a column vector >> M(I) ans = 5 6 7 13 What would be the simplest way to obtain the matrix [5 7 ; 6 13] from this logical indexing? If I know the shape of the non-zero elements of I , I can use a reshape after the indexing, but that's not a general

Address woes from Hacking: The Art of Exploitation [closed]

狂风中的少年 提交于 2019-12-04 20:40:37
Closed. This question is off-topic . It is not currently accepting answers. Want to improve this question? Update the question so it's on-topic for Stack Overflow. Closed 6 years ago . I bought this book recently titled: Hacking: The Art of Exploitation (2nd Edition) and it's been bugging me so much lately. Anyway, with one of the examples, firstprog.c : #include <stdio.h> int main() { int i; for(i=0; i < 10; i++) { // Loop 10 times. printf("Hello, world!\n"); // put the string to the output. } return 0; // Tell OS the program exited without errors. } It has you compile it with gcc (obviously

How to get LBA(logical block addressing) of a file from MFT on NTFS file system?

一曲冷凌霜 提交于 2019-12-04 06:34:07
问题 I accessed the $MFT file and extracted file attributes. Given the file attributes from MFT, how to get a LBA of file from the MFT record on NTFS file system? To calculate LBA, I know that cluster number of file. It that possible using cluster number to calculate? 回答1: I'm not entirely sure of your question-- But if you're simply trying to find the logical location on disk of a file, there are various IOCTLs that will achieve this. For instance, MFT File records: FSCTL_GET_NTFS_FILE_RECORD

Transformation of based indexed mode into indirect addressing mode (x86 assembly)

▼魔方 西西 提交于 2019-12-04 05:10:41
问题 I'm corrently working on changing examples from complex indirect addresssing mode into simple indirect addressing mode pieces. However, I've come across an example from the Based Mode, I'm unable to "transform". Code: move %eax, 28(%esp) I've tried addl $28, %esp movl (%eax), %esp This creates a segmentation fault; and I've no idea how else I should write it. Another example, I've failed to "transform is compl $4, 28(%esp) -> into addl $28, %esp cmpl $4, %esp However this is working, but it

Using references to access class objects C++

三世轮回 提交于 2019-12-02 11:51:11
This one has me stumped. What I'm trying to do is get a reference variable in a wrapper class to point to a struct object in the class it wraps so that any setting of variables in the struct from other classes that use the wrapper class, actually are set in the wrapped class not the wrappper class. To do this I tried to simply create a reference in the wrap class to the struct in the wrapped class like class CClassWrap { CClass::plot_type& PlotArgs; } and then init PlotArgs CClassWrap::InitWrap( CClass AppIfx ) { PlotArgs = AppIfx.PlotArgs; } I just want PlotArgs to point to the wrapped class'

How to get LBA(logical block addressing) of a file from MFT on NTFS file system?

孤街醉人 提交于 2019-12-02 09:13:06
I accessed the $MFT file and extracted file attributes. Given the file attributes from MFT, how to get a LBA of file from the MFT record on NTFS file system? To calculate LBA, I know that cluster number of file. It that possible using cluster number to calculate? I'm not entirely sure of your question-- But if you're simply trying to find the logical location on disk of a file, there are various IOCTLs that will achieve this. For instance, MFT File records: FSCTL_GET_NTFS_FILE_RECORD http://msdn.microsoft.com/en-us/library/windows/desktop/aa364568(v=vs.85).aspx Location on disk of a specific

Transformation of based indexed mode into indirect addressing mode (x86 assembly)

旧时模样 提交于 2019-12-02 06:07:05
I'm corrently working on changing examples from complex indirect addresssing mode into simple indirect addressing mode pieces. However, I've come across an example from the Based Mode, I'm unable to "transform". Code: move %eax, 28(%esp) I've tried addl $28, %esp movl (%eax), %esp This creates a segmentation fault; and I've no idea how else I should write it. Another example, I've failed to "transform is compl $4, 28(%esp) -> into addl $28, %esp cmpl $4, %esp However this is working, but it changes my output slightly, so it might not be correct as well. usr2564301 Disclaimer: I am no fan of

Why does 20 address space with on a 16 bit machine give access to 1 Megabyte and not 2 Megabytes?

时间秒杀一切 提交于 2019-12-01 09:25:16
OK, this question sounds simple but I am taken by surprise. In the ancient days when 1 Megabyte was a huge amount of memory, Intel was trying to figure out how to use 16 bits to access 1 Megabyte of memory. They came up with the idea of using segment and offset address values to generate a 20 bit address. Now, 20 bits gives 2^20 = 1,048,576 locations that can be addressed. Now assuming that we access 1 byte per address location we get 1,048,576/(1024*1024) = 2^20/2^20 Megabytes = 1 Megabyte. Ok understood. The confusion comes here, we have 16 bit data bus in the ancient 8086 and can access 2