none
ACPI methods from KM RRS feed

  • Question

  • Hello. I'm having trouble with calling ACPI methods from a KM driver. Always getting err 0xc0000034 (Object Name not found)

    For testing purposes, I am just using root ACPI methods. Here is one under \ and takes 0 args.

    DefinitionBlock ("DSDT.AML", "DSDT", 0x02, "aaaaaa", "8724    ", 0x00000000){
    ... Method(GTOS, 0, Serialized){ ... }
    ...
    }

    I call this in the driver by creating a device object and attaching to the ACPI device stack via:

    RtlInitUnicodeString(&TargetDeviceName, L"\\DosDevices\\ACPI_ROOT_OBJECT");
    IoGetDeviceObjectPointer(&TargetDeviceName, FILE_READ_DATA, &pFileObject, &pTargetPdo);
    pTargetStack = IoAttachDeviceToDeviceStack(pOurFdo, pTargetPdo);
    acpiInBuf.Signature = ACPI_EVAL_INPUT_BUFFER_SIGNATURE;
    acpiInBuf.MethodNameAsUlong = (ULONG)('GTOS'); pIrp = IoBuildDeviceIoControlRequest(IOCTL_ACPI_EVAL_METHOD, pTargetStack, &acpiInBuf, sizeof(ACPI_EVAL_INPUT_BUFFER), &acpiOutBuf, sizeof(ACPI_EVAL_OUTPUT_BUFFER), FALSE, &kEvent, &ioStatus); status = IoCallDriver(pTargetStack, pIrp);

    And I'm definitely attached to the ACPI stack:

    1: kd> !devstack @@(pOurFdo)
      !DevObj           !DrvObj            !DevExt           ObjectName
    > ffff9a840c0f9040  \Driver\BootDrv    00000000  
      ffff9a8409bfdc40  \Driver\ACPI       ffff9a8409bfd840  
      ffff9a8408fd2bf0  \Driver\ACPI_HAL   ffff9a8408fd2d40  00000011
    // Where pTargetStack = 0xffff9a84`09bfdc40 Device for "\Driver\ACPI"

    But IoCallDriver() always returns 0xc0000034 - Object Name not found. 

    I've also manually edited the pTargetStack as a test and set it directly to lowest PDO - ACPI_HAL and that also fails, but with a different error 0xc0000010 (The specified request is not a valid operation for the target device). But I assume this is not the correct way.

    Any help? Is my attaching to that ACPI device correct? What does that error even mean? 



    Tuesday, March 17, 2020 5:17 PM

All replies

  • Where in the DSDT is your method defined?  In normal circumstances, an ACPI method will be part of some device's definition.  Only the driver for that device, loaded by PnP in response to the ACPI ID, can access the methods.

    Tim Roberts | Driver MVP Emeritus | Providenza & Boekelheide, Inc.

    Tuesday, March 17, 2020 7:11 PM
  • This method is not under any specific device, it's at the top simply under the global root. So I've been told it's callable from anywhere. Hence why I tried to attach to the generic ACPI device (ACPI_ROOT_OBJECT) and send it the ACPI method.

    Is IOCTL_ACPI_EVAL_METHOD correct vs IOCTL_ACPI_EVAL_METHOD_EX?

    If ACPI_HAL is not the PDO for the root, then what device is?

    Tuesday, March 17, 2020 8:19 PM
  • > Method(GTOS, 0, Serialized){ ... }
    > ...
    > acpiInBuf.MethodNameAsUlong = (ULONG)('GTOS');

    A multi-character constant like that is stored in memory as little-endian, which is usually the opposite of what you want.  If you want to match the string "GTOS", you must write it backwards, as (ULONG)'SOTG'.


    Tim Roberts | Driver MVP Emeritus | Providenza & Boekelheide, Inc.

    Thursday, March 19, 2020 4:19 AM
  • Hello Tim. Yes I know it's little endian, that was an error on my part in the copying of code here, hundreds of lines of testing code in my driver at the moment. 

    I can already successfully call methods e.g. in the Battery device Device(BATZ) by attaching to it's device stack in Windows and sending the ACPI method in the Irp.

    But I can not figure out what the PDO in Windows for the root is. I've tried calling the method on random devices that look like it could be the root, but to no avail so far. I have a feeling the root PDO, may not even be obviously named like all other ACPI devices.

    Thursday, March 19, 2020 8:43 AM