Hot answers tagged

10 votes

What does adding 4.294967296e9 to a double do?

I actually found the answer while writing this question! This number is exactly UINT_MAX + 1, stored as a double. So it seems this code converts a unsigned integer to a double. The fild instruction ...
user avatar
  • 241
9 votes
Accepted

XMM register instructions and their c equivalents

You likely won't get an exact reproduction because cvtdq2pd takes the lower 64 bits of the second operand but since we're limited to 32 bits because we're using eax here, there are probably better(?) ...
user avatar
  • 664
6 votes

IDA decompiler macro

COERCE_TYPE(x) is the same thing as *(TYPE *)&x. Hex-Rays uses COERCE_... macros when &x is illegal. For example: COERCE_DOUBLE(__PAIR__(i1,i2)) Is the same as *(double *)&__PAIR__(i1, ...
user avatar
4 votes
Accepted

Moving integer to xmm register

To move a number into an XMM register, you'll first need to move that number into a memory address since you can't move an immediate into an XMM register (meaning, you can't do something like mov XMM1,...
user avatar
  • 2,154
4 votes
Accepted

what is COERCE_FLOAT in ida Hex-Rays' C++ pseudocode?

I assume it's just a simple cast. v29 = *reinterpret_cast< float* >( &v30 ); It would be easier if you'd share the generated assembly instead of the pseudo code.
user avatar
3 votes
Accepted

Encoding of 64-bit double

This appears to be a fixed-point (rather than a floating-point) format. If you treat the 64-bit values as signed integers and divide by 4398046511104.0, you will get the decimal values you show. e.g. ...
user avatar
  • 2,229
3 votes
Accepted

(bad) opcodes of objdump

You are correct, and objdump is actually wrong to disassemble such instruction, only to mark it as (bad) in a later stage. Here is how it works: db a5 4e 9c 95 68 lock (bad) [rbp+0x68959c4e] db ...
user avatar
  • 2,274
3 votes

Reverse Engineer Float and Double Types in C++

For starters you can encode/decode the military format to IEEE 754 this way you can use FPU and standard math stuff so at start everything would work. The code would look like this: military ...
user avatar
  • 1,374
2 votes

Encoding method of float

This isn't a complete answer but is a bit more than fits in a comment. There's definitely a pattern in the powers of 2. They all have exactly 4 bits set. The high bit is always 1 and the lower 15 ...
user avatar
  • 2,229
2 votes
Accepted

determine proprietary 16-bit floating-point format

Maybe it is the temperature in Kelvin: 311 - 80/2 = 217K = -2.15°C Or the offset is different than 80/2. A 16-bit floating-poitn format, especially a different one from IEEE-754 is highly unlikely. ...
user avatar
1 vote

How this Float “4-bytes” is converted to Short_signed “2-bytes”?

One word, precision By definition, a normal is a vector with a length of 1.0f which means that each component of the vector will always fall between -1.0f and +1.0f, and UV are texture coordinates ...
user avatar
1 vote

Weird IDA/Decompiler floating point output

I have added some comments to the disassembly you posted, so it's easier to understand. sub esp, 8 ; stack frame fld [esp+8+arg_0] ; load value of arg0 to st fist [esp+8+var_8] ...
user avatar
  • 3,189
1 vote
Accepted

Viewing 32-bit floats in Internal Call disassembly from .NET 2.0 DLL in x64dbg

After a little digging I got it. Right click your Dump to change data types between address and float. You have to follow the address of the address pointed to by esp-4 to get the parameters.
user avatar
1 vote

Reverse Engineer Float and Double Types in C++

The IEEE 754 standard describes how the floating point representation works under the hood.
user avatar
  • 578
1 vote
Accepted

How to multiply an SSE float with a hardcoded value using MULSS?

Although you indeed cannot use mulss with an immediate value like you've pointed out, you are allowed to pass an 32bit offset as mulss's second operand: Multiplies the low single-precision floating-...
user avatar
  • 11.4k
1 vote
Accepted

Understanding FCOMP instruction and extracted value from address operand

FCOMP Compares the fpu register ST0 with a constant the constant is a QWORD (Meaning DOUBLE , FLOAT , Etc 8+ bytes wide ) ollydbg can show both the ST0 register and decipher the contents of the ...
user avatar
  • 15k
1 vote

Understanding FCOMP instruction and extracted value from address operand

Understanding the assembly line FCOMP QWORD PTR DS:[402CB0] It checks for a qword sized operand. That is 8 bytes while your picture only shows about 3. This comparison is also a floating point ...
user avatar
  • 11.4k
1 vote

Pointer arithmetic in C generated by ida / hexrays decompiler

These casts are done to make the pointer arithmetic that's happening more clear. When you add an integer to a pointer, the integer internally gets multiplied by the size of the object the pointer is ...
user avatar
1 vote

IDA decompiler macro

coerce_* functions are generally a little more coercive that a simple casting, I would assume their meaning as follows: #define VALUE_SIZE (sizeof(int)) struct VALUE_TYPE { char contents[...
user avatar
1 vote

IDA decompiler macro

I'd read this (and probably it is a mistake) as treating binary content of the variable as a variable of another type, something like this: coerce float is *((float*)&var), where var was of the ...
user avatar
  • 7,875
1 vote

Analyse a piece of code using FloatingPoint instructions and calculations

sub esp, 8 movsd xmm0, ds:MEMORY1 ; mov 128-bit memory movsd [esp], xmm0 Fetch MEMORY1. This will be our denominator in fmod(). mov eax, [ebp+ItirationCounter_var_60] mov [ebp+...
user avatar
  • 4,511

Only top scored, non community-wiki answers of a minimum length are eligible