Advertisement
Guest User

Untitled

a guest
May 9th, 2009
402
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 12.21 KB | None | 0 0
  1. // - SutraPlex SoftWare
  2.  
  3. #include <windows.h>
  4. #include <stdio.h>
  5.  
  6. typedef __int8  u8;
  7. typedef __int32 s32;
  8.  
  9. /**
  10.  *  HID_DeviceClose
  11.  *  Address : 0x100023F0
  12.  *
  13.  *  .text:100023F0 HID_DeviceClose proc near
  14.  *  .text:100023F0
  15.  *  .text:100023F0 var_C           = dword ptr -0Ch
  16.  *  .text:100023F0 var_8           = dword ptr -8
  17.  *  .text:100023F0
  18.  *  .text:100023F0                 sub     esp, 8
  19.  *  .text:100023F3                 call    sub_10002799
  20.  *  .text:100023F8                 push    eax
  21.  *  .text:100023F9                 lea     ecx, [esp+0Ch+var_8]
  22.  *  .text:100023FD                 call    MFC42_6467
  23.  *  .text:10002402                 call    sub_10001E70
  24.  *  .text:10002407                 mov     eax, [esp+0Ch+var_8]
  25.  *  .text:1000240B                 mov     ecx, [esp+0Ch+var_C]
  26.  *  .text:1000240F                 mov     [eax+4], ecx
  27.  *  .text:10002412                 add     esp, 8
  28.  *  .text:10002415                 retn
  29.  *  .text:10002415 HID_DeviceClose endp ; sp = -4
  30.  */
  31. typedef s32 ( __cdecl* HID_DeviceClose ) ( void );
  32. HID_DeviceClose funcDeviceClose = NULL;
  33.  
  34. /**
  35.  *  HID_DeviceInitialize
  36.  *  Address : 0x100023C0
  37.  *
  38.  *  .text:100023C0 HID_DeviceInitialize proc near
  39.  *  .text:100023C0
  40.  *  .text:100023C0 var_C           = dword ptr -0Ch
  41.  *  .text:100023C0 var_8           = dword ptr -8
  42.  *  .text:100023C0
  43.  *  .text:100023C0                 sub     esp, 8
  44.  *  .text:100023C3                 call    sub_10002799
  45.  *  .text:100023C8                 push    eax
  46.  *  .text:100023C9                 lea     ecx, [esp+0Ch+var_8]
  47.  *  .text:100023CD                 call    MFC42_6467
  48.  *  .text:100023D2                 call    sub_10001000
  49.  *  .text:100023D7                 mov     ecx, [esp+0Ch+var_8]
  50.  *  .text:100023DB                 mov     edx, [esp+0Ch+var_C]
  51.  *  .text:100023DF                 mov     [ecx+4], edx
  52.  *  .text:100023E2                 add     esp, 8
  53.  *  .text:100023E5                 retn
  54.  *  .text:100023E5 HID_DeviceInitialize endp ; sp = -4
  55.  */
  56. typedef s32 ( __cdecl* HID_DeviceInitialize ) ( void );
  57. HID_DeviceInitialize funcDeviceInitialize = NULL;
  58.  
  59. /**
  60.  *  HID_GetID
  61.  *  Address : 0x10002450
  62.  *
  63.  *  .text:10002450 HID_GetID       proc near
  64.  *  .text:10002450
  65.  *  .text:10002450 var_C           = dword ptr -0Ch
  66.  *  .text:10002450 var_8           = dword ptr -8
  67.  *  .text:10002450
  68.  *  .text:10002450                 sub     esp, 8
  69.  *  .text:10002453                 push    esi
  70.  *  .text:10002454                 call    sub_10002799
  71.  *  .text:10002459                 push    eax
  72.  *  .text:1000245A                 lea     ecx, [esp+10h+var_8]
  73.  *  .text:1000245E                 call    MFC42_6467
  74.  *  .text:10002463                 push    9               ; size_t
  75.  *  .text:10002465                 push    1               ; size_t
  76.  *  .text:10002467                 call    ds:calloc
  77.  *  .text:1000246D                 mov     esi, eax
  78.  *  .text:1000246F                 push    esi
  79.  *  .text:10002470                 call    sub_100020D0
  80.  *  .text:10002475                 add     esp, 0Ch
  81.  *  .text:10002478                 test    eax, eax
  82.  *  .text:1000247A                 jz      short loc_100024A4
  83.  *  .text:1000247C                 mov     ecx, [esp+10h]
  84.  *  .text:10002480                 mov     al, [esi+1]
  85.  *  .text:10002483                 push    esi             ; void *
  86.  *  .text:10002484                 mov     [ecx], al
  87.  *  .text:10002486                 call    ds:free
  88.  *  .text:1000248C                 mov     edx, [esp+14h+var_8]
  89.  *  .text:10002490                 mov     eax, [esp+14h+var_C]
  90.  *  .text:10002494                 add     esp, 4
  91.  *  .text:10002497                 mov     [edx+4], eax
  92.  *  .text:1000249A                 mov     eax, 1
  93.  *  .text:1000249F                 pop     esi
  94.  *  .text:100024A0                 add     esp, 8
  95.  *  .text:100024A3                 retn
  96.  *  .text:100024A4 ; ---------------------------------------------------------------------------
  97.  *  .text:100024A4
  98.  *  .text:100024A4 loc_100024A4:                           ; CODE XREF: HID_GetID+2Aj
  99.  *  .text:100024A4                 push    esi             ; void *
  100.  *  .text:100024A5                 call    ds:free
  101.  *  .text:100024AB                 mov     ecx, [esp+14h+var_8]
  102.  *  .text:100024AF                 mov     edx, [esp+14h+var_C]
  103.  *  .text:100024B3                 add     esp, 4
  104.  *  .text:100024B6                 xor     eax, eax
  105.  *  .text:100024B8                 mov     [ecx+4], edx
  106.  *  .text:100024BB                 pop     esi
  107.  *  .text:100024BC                 add     esp, 8
  108.  *  .text:100024BF                 retn
  109.  *  .text:100024BF HID_GetID       endp ; sp = -4
  110.  */
  111. typedef s32 ( __cdecl* HID_GetID ) ( void* a_Buffer );
  112. HID_GetID funcGetID = NULL;
  113.  
  114. /**
  115.  *  HID_ReadData
  116.  *  Address : 0x100024C0
  117.  *
  118.  *  .text:100024C0 HID_ReadData    proc near
  119.  *  .text:100024C0
  120.  *  .text:100024C0 var_C           = dword ptr -0Ch
  121.  *  .text:100024C0 var_8           = dword ptr -8
  122.  *  .text:100024C0
  123.  *  .text:100024C0                 sub     esp, 8
  124.  *  .text:100024C3                 push    esi
  125.  *  .text:100024C4                 call    sub_10002799
  126.  *  .text:100024C9                 push    eax
  127.  *  .text:100024CA                 lea     ecx, [esp+10h+var_8]
  128.  *  .text:100024CE                 call    MFC42_6467
  129.  *  .text:100024D3                 push    9               ; size_t
  130.  *  .text:100024D5                 push    1               ; size_t
  131.  *  .text:100024D7                 call    ds:calloc
  132.  *  .text:100024DD                 mov     esi, eax
  133.  *  .text:100024DF                 push    esi
  134.  *  .text:100024E0                 call    sub_10002140
  135.  *  .text:100024E5                 add     esp, 0Ch
  136.  *  .text:100024E8                 test    eax, eax
  137.  *  .text:100024EA                 jz      short loc_1000251E
  138.  *  .text:100024EC                 mov     ecx, [esp+10h]
  139.  *  .text:100024F0                 xor     eax, eax
  140.  *  .text:100024F2
  141.  *  .text:100024F2 loc_100024F2:                           ; CODE XREF: HID_ReadData+3Dj
  142.  *  .text:100024F2                 mov     dl, [esi+eax+1]
  143.  *  .text:100024F6                 mov     [eax+ecx], dl
  144.  *  .text:100024F9                 inc     eax
  145.  *  .text:100024FA                 cmp     eax, 8
  146.  *  .text:100024FD                 jl      short loc_100024F2
  147.  *  .text:100024FF                 push    esi             ; void *
  148.  *  .text:10002500                 call    ds:free
  149.  *  .text:10002506                 mov     eax, [esp+14h+var_8]
  150.  *  .text:1000250A                 mov     ecx, [esp+14h+var_C]
  151.  *  .text:1000250E                 add     esp, 4
  152.  *  .text:10002511                 mov     [eax+4], ecx
  153.  *  .text:10002514                 mov     eax, 1
  154.  *  .text:10002519                 pop     esi
  155.  *  .text:1000251A                 add     esp, 8
  156.  *  .text:1000251D                 retn
  157.  *  .text:1000251E ; ---------------------------------------------------------------------------
  158.  *  .text:1000251E
  159.  *  .text:1000251E loc_1000251E:                           ; CODE XREF: HID_ReadData+2Aj
  160.  *  .text:1000251E                 push    esi             ; void *
  161.  *  .text:1000251F                 call    ds:free
  162.  *  .text:10002525                 mov     edx, [esp+14h+var_8]
  163.  *  .text:10002529                 mov     eax, [esp+14h+var_C]
  164.  *  .text:1000252D                 add     esp, 4
  165.  *  .text:10002530                 mov     [edx+4], eax
  166.  *  .text:10002533                 xor     eax, eax
  167.  *  .text:10002535                 pop     esi
  168.  *  .text:10002536                 add     esp, 8
  169.  *  .text:10002539                 retn
  170.  *  .text:10002539 HID_ReadData    endp ; sp = -4
  171.  */
  172. typedef s32 ( __cdecl* HID_ReadData ) ( void* a_Buffer );
  173. HID_ReadData funcReadData = NULL;
  174.  
  175. /**
  176.  *  HID_SetCurrentDevice
  177.  *  Address : 0x10002540
  178.  *  .text:10002540 HID_SetCurrentDevice proc near
  179.  *  .text:10002540
  180.  *  .text:10002540 var_C           = dword ptr -0Ch
  181.  *  .text:10002540 var_8           = dword ptr -8
  182.  *  .text:10002540
  183.  *  .text:10002540                 sub     esp, 8
  184.  *  .text:10002543                 call    sub_10002799
  185.  *  .text:10002548                 push    eax
  186.  *  .text:10002549                 lea     ecx, [esp+0Ch+var_8]
  187.  *  .text:1000254D                 call    MFC42_6467
  188.  *  .text:10002552                 mov     eax, [esp+0Ch]
  189.  *  .text:10002556                 dec     eax
  190.  *  .text:10002557                 push    eax
  191.  *  .text:10002558                 call    sub_100013E0
  192.  *  .text:1000255D                 mov     ecx, [esp+10h+var_8]
  193.  *  .text:10002561                 mov     edx, [esp+10h+var_C]
  194.  *  .text:10002565                 mov     [ecx+4], edx
  195.  *  .text:10002568                 add     esp, 0Ch
  196.  *  .text:1000256B                 retn
  197.  *  .text:1000256B HID_SetCurrentDevice endp ; sp = -4
  198.  */
  199. typedef bool ( __cdecl* HID_SetCurrentDevice ) ( int a_Index );
  200. HID_SetCurrentDevice funcSetCurrentDevice = NULL;
  201.  
  202. /**
  203.  *  HID_WriteCommand
  204.  *  Address : 0x10002420
  205.  *
  206.  *  .text:10002420 HID_WriteCommand proc near
  207.  *  .text:10002420
  208.  *  .text:10002420 var_C           = dword ptr -0Ch
  209.  *  .text:10002420 var_8           = dword ptr -8
  210.  *  .text:10002420
  211.  *  .text:10002420                 sub     esp, 8
  212.  *  .text:10002423                 call    sub_10002799
  213.  *  .text:10002428                 push    eax
  214.  *  .text:10002429                 lea     ecx, [esp+0Ch+var_8]
  215.  *  .text:1000242D                 call    MFC42_6467
  216.  *  .text:10002432                 mov     eax, [esp+0Ch]
  217.  *  .text:10002436                 push    eax
  218.  *  .text:10002437                 call    sub_10002080
  219.  *  .text:1000243C                 mov     ecx, [esp+10h+var_8]
  220.  *  .text:10002440                 mov     edx, [esp+10h+var_C]
  221.  *  .text:10002444                 mov     [ecx+4], edx
  222.  *  .text:10002447                 add     esp, 0Ch
  223.  *  .text:1000244A                 retn
  224.  *  .text:1000244A HID_WriteCommand endp ; sp = -4
  225.  */
  226. typedef s32 ( __cdecl* HID_WriteCommand ) ( char a_Command );
  227. HID_WriteCommand funcWriteCommand = NULL;
  228.  
  229.  
  230. void ButtonPushed ( s32 a_NbrOfPush )
  231. {
  232.     printf ( "Button Pressed %d Times\n", a_NbrOfPush );
  233.     PROCESS_INFORMATION _ProcessInfo;
  234.     STARTUPINFO         _StartInfo;
  235.  
  236.     memset ( &_ProcessInfo, 0, sizeof ( PROCESS_INFORMATION ) );
  237.     memset ( &_StartInfo, 0, sizeof ( STARTUPINFO ) );
  238.     _StartInfo.cb = sizeof ( STARTUPINFO );
  239.  
  240.     CreateProcess ( "C:/Program Files/Rockstar Games/GTA San Andreas/samp.exe", "-conntect 213.251.162.217:7776", NULL, NULL, false, NULL, NULL, NULL, &_StartInfo, &_ProcessInfo );
  241. }
  242.  
  243. int main ( int argc, char** argv )
  244. {
  245.     u8 l_UsbResult[ 8 ] = { 0x00 };
  246.     s32 l_Device = 1;
  247.  
  248.     HMODULE l_LibHandle = LoadLibrary ( "TenxHID.dll" );
  249.     if ( l_LibHandle )
  250.     {
  251.         funcDeviceClose = ( HID_DeviceClose )GetProcAddress ( l_LibHandle, "HID_DeviceClose" );
  252.         if ( !funcDeviceClose ) return 0;
  253.  
  254.         funcDeviceInitialize = ( HID_DeviceInitialize )GetProcAddress ( l_LibHandle, "HID_DeviceInitialize" );
  255.         if ( !funcDeviceInitialize ) return 0;
  256.  
  257.         funcGetID = ( HID_GetID )GetProcAddress ( l_LibHandle, "HID_GetID" );
  258.         if ( !funcGetID ) return 0;
  259.  
  260.         funcReadData = ( HID_ReadData )GetProcAddress ( l_LibHandle, "HID_ReadData" );
  261.         if ( !funcReadData ) return 0;
  262.  
  263.         funcSetCurrentDevice = ( HID_SetCurrentDevice )GetProcAddress ( l_LibHandle, "HID_SetCurrentDevice" );
  264.         if ( !funcSetCurrentDevice ) return 0;
  265.  
  266.         funcWriteCommand = ( HID_WriteCommand )GetProcAddress ( l_LibHandle, "HID_WriteCommand" );
  267.         if ( !funcWriteCommand ) return 0;
  268.  
  269.         while ( 1 )
  270.         {
  271.             if ( funcDeviceInitialize() )
  272.             {
  273.                 printf ( "Call Success : funcDeviceInitialize\n" );
  274.  
  275.                 s32 l_Result = funcSetCurrentDevice ( l_Device );
  276.                 if ( l_Result )
  277.                 {
  278.                     printf ( "Call Success : funcSetCurrentDevice ( %d )\n", l_Device );
  279.  
  280.                     if ( funcGetID ( l_UsbResult ) )
  281.                     {
  282.                         printf ( "Call Success : funcGetID | Device ID : %d\n", l_UsbResult[ 0 ] );
  283.  
  284.                         while ( funcReadData ( l_UsbResult ) )
  285.                         {
  286.                             if ( l_UsbResult[ 0 ] > 0 )
  287.                             {
  288.                                 printf ( "Call Success : funcReadData\n" );
  289.                                 ButtonPushed ( l_UsbResult[ 0 ] );
  290.                             }
  291.                             Sleep ( 50 );
  292.                         }
  293.                         funcDeviceClose();
  294.                     }
  295.                     else
  296.                     {
  297.                         printf ( "Call Failed : funcGetID" );
  298.                     }
  299.                 }
  300.                 else
  301.                 {
  302.                     printf ( "Call Fail : funcSetCurrentDevice ( %d )\n", l_Device );
  303.                 }
  304.             }
  305.             else
  306.             {
  307.                 printf ( "Call Fail : funcDeviceInitialize\n" );
  308.             }
  309.         }
  310.     }
  311.     return 1;
  312. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement