win32api::file translation of c-code to perl: help pls

Discussion in 'Perl Misc' started by Susanne West, Apr 21, 2008.

  1. Susanne West

    Susanne West Guest

    i have the following c-code that sould send out a
    command through deviceIO using win32api::file, and
    i'm struggling with the proper handling of the code.
    the result of my DeviceIoControl() command is always
    NULL...

    #! perl
    # -------------------------------
    # c-code:
    # define BUFF_SIZE 0x2c
    # HANDLE hHandle = CreateFileA("\\\\.\\APPDRV",
    # GENERIC_READ|GENERIC_WRITE, 0,
    # NULL, OPEN_EXISTING, 0x80, NULL);
    #
    # char buffer[BUFF_SIZE];
    # memset(buffer, 0, BUFF_SIZE);
    # buffer[0] = 0x04;
    # buffer[1] = 0x00;
    # buffer[2] = 0x06;
    # buffer[3] = 0x00;
    # buffer[4] = 7;
    # buffer[5] = 7;
    #
    # DWORD bytesReturned;
    # BOOL result = DeviceIoControl(hHandle, 0x23209C,
    # buffer, BUFF_SIZE, buffer, BUFF_SIZE, &bytesReturned, NULL);
    #-------------------------------
    #
    #for testing, this should translate into the following:

    $hDevice = createFile("\\\\.\\APPDRV", "rw", '' );
    if (! $hDevice){ die("Could not open device! \n"); }
    print "Device open\n"; #this seems to be working

    $buffer = chr(04) . chr(0) . chr(06) . chr(0) .
    7 . 7 . chr(0) . chr(0) .
    chr(0) . chr(0) . chr(0) . chr(0) .
    chr(0) . chr(0) . chr(0) . chr(0) .
    chr(0) . chr(0) . chr(0) . chr(0) .
    chr(0) . chr(0) . chr(0) . chr(0) .
    chr(0) . chr(0) . chr(0) . chr(0) .
    chr(0) . chr(0) . chr(0) . chr(0) .
    chr(0) . chr(0) . chr(0) . chr(0) .
    chr(0) . chr(0) . chr(0) . chr(0);

    $res = DeviceIoControl( $hDevice, 0x23209C, $buffer, 44, $opOutBuf, 44,
    $olRetBytes, $pOverlapped );
    if (! $res){ print "IO control failed\n"; } # this fails


    am i missing something here?

    thanks for any hints...
     
    Susanne West, Apr 21, 2008
    #1
    1. Advertising

  2. Susanne West

    smallpond Guest

    On Apr 21, 9:20 am, Susanne West <> wrote:
    > i have the following c-code that sould send out a
    > command through deviceIO using win32api::file, and
    > i'm struggling with the proper handling of the code.
    > the result of my DeviceIoControl() command is always
    > NULL...
    >
    > #! perl


    #!/usr/bin/perl
    use warnings;
    use strict;

    > am i missing something here?
    >


    Yes. You are missing the error messages for your
    undefined functions.
    --S
     
    smallpond, Apr 21, 2008
    #2
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Geni[X]MeN
    Replies:
    0
    Views:
    382
    Geni[X]MeN
    Jun 10, 2004
  2. Replies:
    8
    Views:
    327
    JosephKK
    May 6, 2009
  3. Li Chen
    Replies:
    2
    Views:
    121
    Josef 'Jupp' Schugt
    Oct 13, 2008
  4. ThERiZla
    Replies:
    0
    Views:
    137
    ThERiZla
    Dec 17, 2003
  5. Replies:
    19
    Views:
    204
Loading...

Share This Page