I was working on a practice binary. It opens the file at C:/WINDOWS/system32/filename#123.dat, if the file does not exist, the check compares the result to -1 (An invalid handle). However, even after creating the file, then re-running (Using ollydbg) the handle value is still invalid (-1). I am following a walk-through where the individual goes through the exact same steps. and a valid handle is returned. I am running as administrator. Is this a known issue? Anyone have a solution to it? Been stuck for 2 days

File being accessed via:

ShareMode = 0
pSecurity= NULL
Attributes = NORMAL
hTemplateFile = NULL
FileName = "C:\WINDOWS\system32\filename#123.dat"

I originally tried on Windows 10, did not work, so then I hopped over to windows XP 64 bit (what the walkthrough was using - still did not work.)

  • Hi and welcome to RE.SE. I suppose the fact that you do this in a debugger makes it somewhat on-topic. But so far you're not even giving us the full picture. What's the last error code when it fails to give you a valid handle?
    – 0xC0000022L
    Commented Jun 28, 2021 at 21:44
  • 1
    Look up Wow64 fs redirection
    – Igor Skochinsky
    Commented Jul 2, 2021 at 22:28

1 Answer 1


Found solution here: https://stackoverflow.com/questions/64109842/reopenfile-windows-api-fails-with-error-invalid-name-when-reopening-a-file-in

Fix: Ran the binary on 32 architecture windows XP

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.