« first day (1572 days earlier)      last day (1281 days later) » 

6:13 AM
when calling functions which one of them (caller callee) is responsible with cleaning the stack and why
 
 
1 hour later…
7:24 AM
what could go wrong if I mix line endings between different platforms?
I had some cpp files with Windows line endings and I saved them in Ubuntu
 
@Rick if you're using multiline string literals it could change the actual program
imagine if you have some HTTP headers as string literals with new lines in there, if you convert the newlines it could stop working
but other than that it's just annoying for people to have to deal with mixed new-line styles in a project
 
8:22 AM
OK
 
 
3 hours later…
11:08 AM
How can I insert my own C++/ASM code into an executable? I read that I need something like a section. I reverse engineered a bit and know addresses of interest
On top of that I know that I perhaps need the windows api func Memory or process Write ?
 
11:59 AM
@stringExchange processWrite is for writing into the memory of a running process, not for writing to the executable file
so the changes you make would be gone after the process stops
I think most common approach is to hook a common OS function, load your code as dynamic library, and then modify some existing code with process write to jump to your code
 
Hello @PeterT, thank you for answering!
 
12:41 PM
@stringExchange note that rewriting executables may not behave the way you expect. There are a lot of things you need to get right. Also some executables actively fight this, and most modern OSes will prevent it by using No Execute flags
 
 
5 hours later…
6:01 PM
how can you pass a pointer by refference
 
 
1 hour later…
7:09 PM
finally, the callee save registers such as ESI, EDI, and EBX are stored if they are used at any point during the functions execution.
what is ESI EDI and EBX? (source index register, destination index register?
 
Registers are specific to an architecture, C++ is architecture independent.
 
but when you call a function
one of the steps the stack frame of the function have is the "callee save registers"
what do that mean?
 
8:00 PM
@CătălinaSîrbu it means if you want to keep the value in those registers you need to deal with saving them and restoring them yourself
 
I donțt understand the concept of restoring the stack
is it related to what you said earliyer?
 
yeah, you just point to the start of the stack memory that your function uses. Then you always address everything relative to it
if you want to save and restore some registers, you make room on the stack for them, save them, call the function, read back the register values you stored on the stock
 
and what do you do after the function call ends? Who clear the stack and what do you restore ?
 
the function that does the saving, knows what it saved where
 
so the function itself clears the stack frame?
 
8:07 PM
on x86 I think a function is responsible for restoring the stack base pointer before returning
if that's what you're asking
because "clearing the stack frame" is mostly just "move the pointer"
 
restoring the stack base pointer
for me is equal with move the pointer back
this is what Ițm missing
 
but there's a reason why people named it "calling convention". If you're making your own operating system, you can do it differently if you want.
 
no, I just want to understand calling convetion
the "official" one
push    ebp       ; save old call frame : Why do you need to save the old call frame ?
@PeterT "We’ve decided that the callee is responsible for stack restoration. It can do this, as it knows how many parameters have to be removed." Can you plase tell me one more what does the stack restoration means?
 
it just means you move the base pointer back to the value that it was when the function was entered
 
8:28 PM
ok then, thanks
which register holds the stack pointer?
esp?
 
yeah rsp/esp/sp , whichever mode you're in
and then rbp is the start of the stack-frame for the current function
 
8:50 PM
like 16-bit, 32-bit, 64-bit
 
ok, and what king of calling convention do we use nowadays?
pascal ? stdcall ?
 
@CătălinaSîrbu Please be aware that calling conventions and registers are not standard C++ features. It depends on the platform you are compiling for.
 
9:48 PM
hey guys, I want to embed 3 (or possibly more) float values into a single float value. what do I need to know/read to implement this?
 
@Henri like with reduced precision?
 
I mean, I have a player position (x, y) and it's id. I want to embed all the 3 values into one, so there's less copy/assignments and reduced memory for storing those objects
 
10:47 PM
@Henri First, I would not put an ID in a float. An ID needs to be exact and floating point types are imprecise.
Second, it is not clear what you mean by embed.
A float can store exactly 1 float.
If you want to save on memory, use a smaller type to represent your positions. It is not worth trying to compress a position member.
This is probably not something worth worrying about, unless you can measure that it is actually problematic.
 

« first day (1572 days earlier)      last day (1281 days later) »