Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>You're on the right track, you just need to figure out the constant to use. Your vendor's program will actually print it out, in decimal and hex-- if you would just edit <code>main()</code> and move the <code>printf</code> line above the endless <code>while</code> loop:</p> <pre><code>printf("Ioctl Number: (int)%d (hex)%x\n", SSD1289_GET_KEYS, SSD1289_GET_KEYS); while(1) get_keys(fd); </code></pre> <p>Explanation:</p> <p><code>_IOR</code> is a macro defined in <code>sys/ioctl.h</code>. Its definition is as follows:</p> <pre><code>#define _IOC(inout,group,num,len) \ (inout | ((len &amp; IOCPARM_MASK) &lt;&lt; 16) | ((group) &lt;&lt; 8) | (num)) #define _IO(g,n) _IOC(IOC_VOID, (g), (n), 0) #define _IOR(g,n,t) _IOC(IOC_OUT, (g), (n), sizeof(t)) #define _IOW(g,n,t) _IOC(IOC_IN, (g), (n), sizeof(t)) </code></pre> <p>I have included the relevant context lines. You can see that this macro constructs a bit mask that (we can tell from the name) deals with read operations. But your goal is to figure out the bitmask you need, which you can do without too much trouble: Run your vendor's C program through <code>cc -E</code>, and you'll see the source after preprocessor commands have applied. Track down the definition of <code>get_keys</code> (there'll be a whole lot of header files first, so it'll be at the very end of the output), and pull out the second argument. </p> <p>The result just might be system-dependent, so you should really try it yourself. On my box, it comes out as </p> <pre><code>((__uint32_t)0x40000000 | ((sizeof(unsigned char *) &amp; 0x1fff) &lt;&lt; 16) | ((('keys')) &lt;&lt; 8) | ((1))) </code></pre> <p>Not eager to translate that into python, I added the following lines at the very start of <code>main()</code>:</p> <pre><code>printf("%d", ((__uint32_t)0x40000000 | ((sizeof(unsigned char *) &amp; 0x1fff) &lt;&lt; 16) | ((('keys')) &lt;&lt; 8) | ((1)))); exit(0); </code></pre> <p>I ran the program and it gave me the output <code>1702458113</code>, which <em>may</em> be the value you need. It should be the same as the decimal output from the <code>printf</code> command that was already there (but hidden below the endless <code>while</code> loop). But check it yourself and don't blame me if you blow out your hardware or something!</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload