[Solved] How is shellcode generated from C? – With code example

The problem with creating shellcode from C programs is not that you cannot control the assembly generated, nor something related with the code generation. The problem with creating shellcode from C programs is symbols resolution or relocation, call it whatever you like. You approach, for what I have understand, is right, you are just using … Read more

[Solved] Is it possible to create the low-level grapics API (similar to OpenGL)? [closed]

No, implementing something like OpenGL is not possible. Since the time OpenGL has decended from the heavens complete, writing something like it was forbidden by all common religions. But really, what you’ll actually need is about 21 years of work, a few thousands of developers and broad support from all industry leaders, so yea, piece … Read more

[Solved] How mingw32-g++ compiler know where to inject system calls in the WIN32 machine executable?

To quote the gcc manual: If no init section is available, when GCC compiles any function called main (or more accurately, any function designated as a program entry point by the language front end calling expand_main_function), it inserts a procedure call to __main as the first executable code after the function prologue. The __main function … Read more

[Solved] Worst case memory access in 80×86 assembly

From memory, the instruction has an opcode byte (“add”), an address mode byte, an offset for x (4 bytes) and the constant (4 bytes) ==> 10 bytes. I assume the 486 fetches 4 bytes at a time from memory with a bus address aligned to 4 byte DWORD boundaries. So 10 bytes arguably takes 3 … Read more

[Solved] How to declare local variables in macro asm of gas like decalaring it in macro asm with %local in macro asm of nasm or local in macro asm of masm?

gas is primarily intended as a compiler backend, not for human use. As such, it’s lacking some features, among others this one. You can of course try to make a macro to do this, something along these lines: .intel_syntax noprefix .globl main .macro local head, tail:vararg # assume dwords for simplicity .set localsize, localsize + … Read more

[Solved] error c2400 found new line

I guess the thread will be soon on hold (“off topic”), so let me show quickly the corrected code: #include<stdio.h> int main (void) { char y = 10; char* format = “%d”; __asm { movzx eax, y add eax,1 push eax push format call printf add esp, 8 } return 0; } 1 solved error … Read more

[Solved] What is the most efficient way to zero all bits below the most significant set bit?

There’s no single instruction that can do this. BMI1 blsi dst,src can isolate the lowest set bit, not the highest. i.e. x & -x. If x86 had a bit-reversed version of blsi, we could use that, but it doesn’t. But you can do much better than what you were suggesting. An all-zero input is always … Read more

[Solved] Does AT&T syntax work on intel platform?

att vs intel syntax has been covered many times, here and other places. Assembly language is a language defined by the assembler, the particular program used to convert the ASCII assembly language into machine code for the particular target you are interested in. Unlike say a C or C++ compiler where there is a standard … Read more

[Solved] Data Structure of Class [closed]

The compiler assigns offsets to all members, and includes these in all load/store operations on members: struct foo { uint32_t bar; uint32_t baz; uint32_t get_baz() { return baz; } }; uint32_t get_baz_from_foo(foo *f) { return f->baz; } becomes (ARM assembler code used for simplicity): foo__get_baz: ; calling convention: this pointer in r3 ; load 32 … Read more