M
M
Michael.2012-02-13 14:39:21
Windows
Michael., 2012-02-13 14:39:21

Double in kernel-mode (WinXp)?

There is a need to actively use real numbers in the driver.
Here msdn.microsoft.com/en-us/library/windows/hardware/... (v=vs.85).aspx write this way:

KFLOATING_SAVE saveData;
NTSTATUS status;
double floatValue;

status = KeSaveFloatingPointState(&saveData);

if (NT_SUCCESS(status)) {

    floatValue = 1.0;
    KeRestoreFloatingPointState(&saveData);
}

but I would like to place variables of type double in DEVICE_EXTENSION, and then in the code, when using these variables, use the proposed method.
1. Any suggestions on how this can be done?
2. Are there other ways to work with double in
PS Windows XP kernel, WDM

Answer the question

In order to leave comments, you need to log in

2 answer(s)
A
amirul, 2012-02-15
@kulinich

There is a misunderstanding :-), I'll try to clarify the situation
In general, each thread has its own "context" (stored in _KTHREAD::StateSaveArea), which includes, among other things, the state of the FPU (as well as MMX, SSE and others) registers. You can’t get away from this, and when the context is switched, all this state is saved and reloaded with new values.
But given that
1. All those vector extensions/floating points have quite a lot of fairly large registers
2. The vast majority of "kernel" code don't need them anyway
3. Switching from usermode to kernel and back should be as fast as possible
then it was decided that the nuclear workers would not peel off to roll the sun by hand. In other words, when switching to kernel mode and back, only general-purpose integer registers (well, flags, segment registers, etc.) are reloaded. In order not to spoil the calculation results of the user part of the thread, which had the imprudence to call (directly or indirectly) your code, you need to save it before modifying the FP context, and restore it before returning to the user mode. You can store the results anywhere (including in the device extension).

A
Alexey Akulovich, 2012-02-13
@AterCattus

Due to the specifics of the topic, I would recommend contacting wasm.ru with such a question.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question