dcsimg
CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 4 of 4

Thread: CreateFile returns a 0xffffffff error

  1. #1
    Join Date
    Dec 2010
    Posts
    907

    CreateFile returns a 0xffffffff error

    The target file already exists in the same folder as the starting program.
    Any ideas?
    Thanks
    Jack

    Code:
    if(!pe->bLoadFromBuffer) {
    		DMSG("Creating Map View of File");
    
    		hFile = CreateFile(pe->pTargetPath, GENERIC_READ, 
    			FILE_SHARE_READ, NULL, OPEN_EXISTING, 0, NULL);
    		if(hFile == INVALID_HANDLE_VALUE) {
    			DMSG("Failed to open PE File");
    			goto out;
    		}
    Update:
    Alright, I change it to absolute pathing, it works now

  2. #2
    Join Date
    Nov 2000
    Location
    Voronezh, Russia
    Posts
    6,603

    Re: CreateFile returns a 0xffffffff error

    Please do clearly tell between handle 0xffffffff and error code 0xffffffff. The former makes sense while the latter does not. CreateFile returns handle, and error code is returned by GetLastError. Please avoid making us guess what you really meant when you described a situation.
    Best regards,
    Igor

  3. #3
    2kaud's Avatar
    2kaud is offline Super Moderator Power Poster
    Join Date
    Dec 2012
    Location
    England
    Posts
    6,972

    Re: CreateFile returns a 0xffffffff error

    It would be of greater use for future debugging if the message passed to your DMSG() also included the error code obtained from GetLastError(). The clairvoyant skills of the debugee wouldn't then need to be tested.
    All advice is offered in good faith only. All my code is tested (unless stated explicitly otherwise) with the latest version of Microsoft Visual Studio (using the supported features of the latest standard) and is offered as examples only - not as production quality. I cannot offer advice regarding any other c/c++ compiler/IDE or incompatibilities with VS. You are ultimately responsible for the effects of your programs and the integrity of the machines they run on. Anything I post, code snippets, advice, etc is licensed as Public Domain https://creativecommons.org/publicdomain/zero/1.0/ and can be used without reference or acknowledgement. Also note that I only provide advice and guidance via the forums - and not via private messages!

    C++17 Compiler: Microsoft VS2019 (16.4.3)

  4. #4
    Arjay's Avatar
    Arjay is online now Moderator / EX MS MVP Power Poster
    Join Date
    Aug 2004
    Posts
    13,209

    Re: CreateFile returns a 0xffffffff error

    Quote Originally Posted by lucky6969b View Post
    Update: Alright, I change it to absolute pathing, it works now
    Actually, it worked before - it just used the page file as memory backing instead of the file.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  


Windows Mobile Development Center


Click Here to Expand Forum to Full Width




On-Demand Webinars (sponsored)