When I use STD (set direction flag) before calling DragQueryFile it will always return 1 for number of characters in a file path, which of course is not correct.
Is this a bug or do I have to clear the flag before calling any windows api functions?
This is with 64bit code, don't know if its the same for 32bit code.
if you set the direction flag, you should clear it prior to calling an API
if the state needs to be preserved across the call, it's PUSHF/POPF
CLD, STD, PUSHF, POPF are surprisongly slow instructions - but that may not matter where you are using them
Quote from: dedndave on August 20, 2010, 01:55:42 PM
if you set the direction flag, you should clear it prior to calling an API
Thanks, didn't know that :)
The STDCALL calling convention defines the rule:
"the direction flag is clear on entry and must be returned clear."
Long ago I learnt that if you use instructions that depend on the direction flag, set it yourself and make sure on exit that it is clear.