Results 1 to 6 of 6

Threaded View

  1. #1
    'Bruno's Avatar
    Join Date
    Dec 2009
    Gender
    male
    Location
    Portugal
    Posts
    2,883
    Reputation
    290
    Thanks
    1,036
    My Mood
    Busy

    [Release/Source Code]Some API's made Easier

    Well, since last few days i have been writing an application in C# for multiple stuff. In there i have been using some WinAPI's. It annoys me sometimes to use those API's in C# as they are way better used in C++ imo.

    So i decided to create a Library in C++ to just import (.dll), and use it like a charm. I have been passing some of them to it, actually only have 2 of them in it, and and rand extra function that its quite useless anyway.

    What is now easier:
    • Sendinput API:
      • Keyboard; (send keystrokes)
        • Params: message , hWnd
      • Mouse; (send mouse clicks)
        • Params: x, y coords
    • Get Some process Handle. (just random, first created to test, but didn't remove it)


    Instead now of writing the whole API function params, you can easily just type the message/coords and it will all be done quite easily. This makes even easier for other languages to use it.

    Example of usage on another language (C#):

    • Import Dll:


    Code:
    [DllImport("MultiAPIs.dll")]
    public static extern int sendInputMsg(string message, IntPtr hWindow);
    
    [DllImport("MultiAPIs.dll")]
    public static extern int sendInputMouse(int x, int y);
    • Usage:


    Code:
    sendInputMsg("Hello World", windowHandle);
    Code:
    sendInputMouse(100,100);


    • Library Source Code:


    [php]//
    // Multi APIs
    // Created by Bruno Monteiro in 2010
    // MultiAPIs.cpp
    //

    #include "stdafx.h"
    #include <windows.h>

    extern "C" __declspec(dllexport)HANDLE GetHandle(LPCWSTR appName);
    extern "C" __declspec(dllexport)int sendInputMouse(int x, int y);
    extern "C" __declspec(dllexport)int sendInputMsg(char message[], HWND handle);

    //basic msg sending
    int sendInputMsg(char message[], HWND hWnd)
    {
    SetForegroundWindow(hWnd);
    int msgSize = 0;

    for(int i=0; message[i] != '\0'; i++)
    msgSize++;

    INPUT sInput; //INPUT struct used on SendInput
    sInput.type = INPUT_KEYBOARD; //will be doing keyboard input, not mouse or hardware (ki)
    sInput.ki.dwFlags = KEYEVENTF_EXTENDEDKEY;

    for(int i=0; i < msgSize; i++)
    {
    sInput.ki.wVk = ((UCHAR)VkKeyScan(message[i])); //Converts the Char to a VirtualKey
    SendInput(1, &sInput, sizeof(sInput));
    Sleep(10);
    }

    sInput.ki.wVk = (UCHAR)0x0D; //Enter, Virtual Key hex code
    SendInput(1, &sInput, sizeof(sInput));

    return 0;
    }

    int sendInputMouse(int x, int y)
    {
    SetCursorPos(x,y);

    INPUT sInput; //INPUT struct used on SendInput
    sInput.type = INPUT_MOUSE; //will be doing mouse input, not keyboard or hardware (mi)
    sInput.mi.dwFlags = MOUSEEVENTF_LEFTDOWN; //left button press
    SendInput(1, &sInput, sizeof(sInput)); //sends Mouse left buttom Down Press
    sInput.mi.dwFlags = MOUSEEVENTF_LEFTUP; //left button release
    SendInput(1, &sInput, sizeof(sInput)); //obvious?

    return 0;
    }

    //gets processs HANDLE (opened ready for hacking) by it's name
    HANDLE GetOpenHandle(LPCWSTR appName)
    {
    DWORD* idProcess = new DWORD;
    GetWindowThreadProcessId(FindWindow(0, appName), idProcess);
    return OpenProcess(PROCESS_ALL_ACCESS, 0, *idProcess);
    } [/php]

    It's Still small, but i will keep updating it whenever i have time and feel like it.

    Now feel free to compare the code with usage and without the usage of the dll.

    ATTENTION: I'm not a very well coder using APIs, but i keep trying my best, as result probably those API's code could be better. Still, use it if you want.


    Viruscan:
    VirusTotal

    For those who might wand the Dll:
    Download Attachment at the end
    Light travels faster than sound. That's why most people seem bright until you hear them speak.

  2. The Following 3 Users Say Thank You to 'Bruno For This Useful Post:

    citex777 (09-09-2014),spide1123 (09-25-2012),Void (08-24-2010)

Similar Threads

  1. [Release][Source Code] DLL Injection
    By Tukjedude in forum C++/C Programming
    Replies: 12
    Last Post: 06-09-2010, 09:36 AM
  2. [Help] Source code +Help+Release
    By maxius12 in forum CrossFire Hacks & Cheats
    Replies: 33
    Last Post: 02-26-2010, 09:22 PM
  3. <releasing 2 morrow> new opk hack ~source code~ C++
    By pikamew4 in forum Combat Arms Hack Coding / Programming / Source Code
    Replies: 21
    Last Post: 12-02-2009, 02:59 PM
  4. Open Source Release. Semi-Useless Timer Source Code!
    By User1 in forum Visual Basic Programming
    Replies: 6
    Last Post: 09-20-2009, 02:55 AM
  5. [Release] ****** DLL Source Code
    By OneWhoSighs in forum WarRock - International Hacks
    Replies: 20
    Last Post: 10-25-2007, 07:41 AM