logo
down
shadow

CreateFile over USB HID device fails with Access Denied (5) since Windows 10 1809


CreateFile over USB HID device fails with Access Denied (5) since Windows 10 1809

By : Sergey
Date : November 22 2020, 04:01 AM
I hope this helps . The fix is in this windows update released today (March 1, 2019).
https://support.microsoft.com/en-us/help/4482887/windows-10-update-kb4482887
code :


Share : facebook icon twitter icon
Access denied when Called CreateFile()

Access denied when Called CreateFile()


By : user2906122
Date : March 29 2020, 07:55 AM
To fix this issue When called CreateFile() function it returns an error code 0x5, which means access denied. Can anyone help with this issue?
code :
ConnectionOptions connection = new ConnectionOptions();

//just username, without domain name, otherwise, a "RPC is Unavaliable." exception will be thrown.
connection.Username = "testUser";

connection.Password = "testPassword";

//Allow privilege
connection.EnablePrivileges = true;

connection.Impersonation = ImpersonationLevel.Delegate;

connection.Authentication = AuthenticationLevel.Call;

//Neither ntdlmdomain or kerberoes, otherwise, a "Invalid Parameter." exception will be thrown.
connection.Authority = "ntlmdomain:MYDOMAIN";

//IP Address or host full name.
ManagementScope scope = new ManagementScope("\\\\myIPAddress\\root\\CIMV2", connection);

scope.Connect();

ManagementClass classInstance = new ManagementClass(scope,new ManagementPath("Win32_Process"), null);

ManagementBaseObject inParams = classInstance.GetMethodParameters("Create");

//Change it to your own execute file path
inParams["CommandLine"] = "myExecuteFilePath";

ManagementBaseObject outParams = classInstance.InvokeMethod("Create", inParams, null);
Denied GENERIC_READ access to USB device, granted GENERIC_WRITE with CreateFile()

Denied GENERIC_READ access to USB device, granted GENERIC_WRITE with CreateFile()


By : Emzo Abjandadze
Date : March 29 2020, 07:55 AM
Any of those help If the keyboard has functions that don't fit well in a normal keyboard class, it may very well expose multiple device instances, one which encompasses the normal keyboard behavior, and one for the fancy stuff.
And one of the instances could well be write-only.
Send IOCTL to Windows device driver - CreateFile fails

Send IOCTL to Windows device driver - CreateFile fails


By : user3810978
Date : March 29 2020, 07:55 AM
I wish this helpful for you Try it my way. I'm using Setup API to enumerate all USB active devices in the system and get paths. That way you can find out whether it's the path or other arguments that CreateFile doesn't like.
I'll add some comments a bit later, if anyone's interested.
code :
HDEVINFO hDevInfo = SetupDiGetClassDevs( &_DEVINTERFACE_USB_DEVICE, 0, 0, DIGCF_DEVICEINTERFACE | DIGCF_PRESENT);
    if(hDevInfo == INVALID_HANDLE_VALUE)
    {
        return ERR_FAIL;
    }

    std::vector<SP_INTERFACE_DEVICE_DATA> interfaces;

    for (DWORD i = 0; true; ++i)
    {
        SP_DEVINFO_DATA devInfo;
        devInfo.cbSize = sizeof(SP_DEVINFO_DATA);
        BOOL succ = SetupDiEnumDeviceInfo(hDevInfo, i, &devInfo);
        if (GetLastError() == ERROR_NO_MORE_ITEMS)
            break;
        if (!succ) continue;

        SP_INTERFACE_DEVICE_DATA ifInfo;
        ifInfo.cbSize = sizeof(SP_INTERFACE_DEVICE_DATA);
        if (TRUE != SetupDiEnumDeviceInterfaces(hDevInfo, &devInfo,  &(_DEVINTERFACE_USB_DEVICE), 0, &ifInfo))
        {
            if (GetLastError() != ERROR_NO_MORE_ITEMS)
                break;
        }
        interfaces.push_back(ifInfo);
    }

    std::vector<SP_INTERFACE_DEVICE_DETAIL_DATA*> devicePaths;
    for (size_t i = 0; i < interfaces.size(); ++i)
    {
        DWORD requiredSize = 0;
        SetupDiGetDeviceInterfaceDetail(hDevInfo, &(interfaces.at(i)), NULL, NULL, &requiredSize, NULL);
        SP_INTERFACE_DEVICE_DETAIL_DATA* data = (SP_INTERFACE_DEVICE_DETAIL_DATA*) malloc(requiredSize);
        assert (data);
        data->cbSize = sizeof(SP_INTERFACE_DEVICE_DETAIL_DATA);

        if (!SetupDiGetDeviceInterfaceDetail(hDevInfo, &(interfaces.at(i)), data, requiredSize, NULL, NULL))
        {
            continue;
        }
        devicePaths.push_back(data);
    }
Access denied on CreateFile in user folder

Access denied on CreateFile in user folder


By : Trajano Simão
Date : March 29 2020, 07:55 AM
I wish this help you Well the problem is that target process needs to have SeImpersonateUser privilege, available only in SYSTEM processes by default.
When the thread is impersonated, because the process hasn't the required privilege, the api will succeed but actual level will be Delegate instead of Impersonate and CreateFile fails because of this.
Access Denied using CreateFile from Windows API

Access Denied using CreateFile from Windows API


By : Miss Looletta
Date : March 29 2020, 07:55 AM
Does that help You must prefix the path with the string \\?\ in order to bypass the MAX_PATH limitation. This is documented in the CreateFile MSDN information where it states:
Related Posts Related Posts :
  • ATM withdrawing money using only 50s and 20s bills C
  • Alphabets not appearing from array (Strange characters appearing)-C programming
  • Rpn calculator: How to free an element that was popped from the stack?
  • C, minus operator in multiply
  • Is cache invalidation promised in this implementation
  • Assigning memory size dynamically causes stack smashing error
  • Why does makefile recompiles everything when a headerfile is changed?
  • Mutex and thread in c
  • Segmentation Fault while copying unsigned int values in C
  • visual studio code debug C request timeout
  • Understanding indirection through pointers and taking address
  • How can I delete extra break line when read txt in C
  • recv() recieves incorrect data
  • How to make a string out of 3 user input strings in c
  • Can't find issue with "Too many arguments for format"
  • How to print \n on a string during a child process on a fork
  • redundant operations in disassembled c code
  • C output of hexadecimal division different from all other sources
  • C- getchar() re-read characters?
  • C : String comparing
  • Find the maximum sum of positive integers in an array in C language
  • Needs debugging symbols for __alignof__
  • Segmentation fault (core dumped) when using my own struct with pointers to array
  • Converting an uint8_t[] to an IP address string
  • Do the printf statements in this example invoke Undefined Behavior?
  • C Accept Client Socket "Invalid Argument" Error when adding Signal Thread
  • Another invert char array in C
  • A function, which contains a struct, that is declared in the following function?
  • Hashing int16_t to uint64_t
  • free() freezing in visual studio C
  • p is a pointer to a structure, what do all these code snippets do?
  • Android-NDK: Run time errors when using shmget, shmctl, shmdt in Android API 27
  • Is shifting the signed bit of a signed short undefined behaviour in C?
  • How to implement arithmetic right shift in C
  • What happen if passing the address of the stack variable to the pthread function?
  • How to add zeros after the significant digits after decimal in C?
  • C - strcspn() function skipping over the longer strings in my array
  • Do calls to shmget or shmat initialize data?
  • why `execv` can't use implicit convert from char** to char* const*?
  • Avoid pressing enter with getch() on linux ( GCC ) "No-echo"
  • A struct initialised in a function how can i use the values?
  • Facing problems with the atoi function if used repeatedly
  • Assigning a pointer to a larger array to a pointer to a smaller VLA
  • How to set base address of a matrix?
  • Use execvp with Input file to a program and redirection output to a new file
  • Forking and running dhclient (with params -nw -w) in exec creates a defunct process and a daemon process
  • How I can calculate a pointer base address in C
  • (3* - *p/(*q)+7) = 6 how it works?
  • Problems with dynamic memory allocation for structs in C
  • error: expected declaration specifiers or ‘...’
  • C Language: Search text file for a "word" and store the value into int and flout type variables
  • STB Library Quicksort Implementation
  • printf: how to align numbers on decimal point
  • Checking constant variable's value at the compilation time
  • Search C function definition using Compilation Error
  • use gcc to directly compile to machine code without linking
  • Why does Eclipse's C application launch terminal print garbage upon invoking `system("clear")` (defined in std
  • how synchronization is done in shared memory data linux c
  • Input string consists of null terminating chars
  • How to pass parameters to Linux system call?
  • shadow
    Privacy Policy - Terms - Contact Us © bighow.org