Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CreateFileA failes on an existing file #1364

Closed
0xcpu opened this issue Dec 12, 2016 · 8 comments
Closed

CreateFileA failes on an existing file #1364

0xcpu opened this issue Dec 12, 2016 · 8 comments

Comments

@0xcpu
Copy link
Contributor

0xcpu commented Dec 12, 2016

x64dbg failes to open an existing file using CreateFileA
failed1

The system error code is 0x20(ERROR_SHARING_VIOLATION), the file isn't opened by any other program.
failed2

The annoying thing is that OllyDbg succeeds opening it.
olly

Tried opening with x64dbg running as ADMIN and as normal user.

Any ideas what is the problem?

@mrexodia
Copy link
Member

No and it is unlikely to be related to x64dbg unless there is some anti-debug at play or the application is opening a file that is exclusively opened by x64dbg...

@0xcpu
Copy link
Contributor Author

0xcpu commented Dec 12, 2016

There is no anti-debugging in the file. If it's not related to x64dbg, why OllyDbg succeeds?

@mrexodia
Copy link
Member

mrexodia commented Dec 12, 2016 via email

@0xcpu
Copy link
Contributor Author

0xcpu commented Dec 12, 2016

In x64dbg there are no handles, but it should, at least a mutex was opened, while OllyDbg identifies opened handles. So I'm not totally convinced there is no problem in x64dbg.

@mrexodia
Copy link
Member

mrexodia commented Dec 12, 2016 via email

@0xcpu
Copy link
Contributor Author

0xcpu commented Dec 12, 2016

I didn't say that this is a bug in x64dbg. This issue was opened because another debugger succeeds in doing the same operation, on the same system. So, I thought it is helpful to question this situation, also question why x64dbg doesn't show the (other) opened handles.

@mrexodia
Copy link
Member

mrexodia commented Dec 12, 2016 via email

@Gbps
Copy link

Gbps commented Apr 3, 2018

I experienced this same trick. It involves opening the currently executing file in x32dbg with CreateFile. In this case it's an anti-debug/packer trick, which fails for x32dbg due to a request for exclusive access to the file. CreateFileA will fail with LastError of ERROR_SHARING_VIOLATION. OllyDbg does not appear to have this issue.

The issue can be resolved by changing the dwShareMode access requested by CreateFile at runtime from 0 (exclusive) to 7 (FILE_SHARE_READ | FILE_SHARE_WRITE | FILE_SHARE_DELETE)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants