News:

MASM32 SDK Description, downloads and other helpful links
MASM32.com New Forum Link
masmforum WebSite

STD before DragQueryFile returns wrong results

Started by Igor, August 20, 2010, 11:30:54 AM

Previous topic - Next topic

Igor

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.

dedndave

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

Igor

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 :)

Rockoon

The STDCALL calling convention defines the rule:

"the direction flag is clear on entry and must be returned clear."
When C++ compilers can be coerced to emit rcl and rcr, I *might* consider using one.

hutch--

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.
Download site for MASM32      New MASM Forum
https://masm32.com          https://masm32.com/board/index.php