DllMain in Freebasic - DllEntryPoint


Freebasic is a free and open-source self hosting compiler. It can produce fast and efficient pure native code for all Versions of Microsoft Windows and Linux Operating System. In this post, I am going to show you how to write a standard DLL in Freebasic. Of course, the -dll switch is all that you need to pass to get a working DLL but, you will have to manually work a bit if you need to add the DllMain in Freebasic DLL.

The Barebone of a DLL Code in C Programming Language looks something like this:
/*    mtsDll.C    */

#include

BOOL WINAPI DllMain ( HINSTANCE hInstDll, DWORD fdwReason, LPVOID lpvReserved )
{
    if (fdwReason == DLL_PROCESS_ATTACH)
    {
        MessageBox(NULL, "DLL Mapped into Memory", "Caption", MB_OK);
    }
    else if (fdwReason == DLL_PROPCESS_DETACH)
    {
        MessageBox(NULL, "DLL UnMapped from Memory", "Caption", MB_OK);
    }
return TRUE;
}
If it is C++, you will need to add extern "C" just before BOOL. But, even if you enter your own DllMain in Freebasic DLL, which looks something like this:
/'    mtsDll.BAS    '/

#include "windows.bi"

Function DllMain stdcall Alias "MAIN" ( hInstDll As HINSTANCE, _
          fdwReason As DWORD, lpvReserved As LPVOID ) As BOOL Export                             
    if (fdwReason = DLL_PROCESS_ATTACH) then
            MessageBox(NULL, "DLL Mapped into Memory", "CAPTION", MB_OK)
    ElseIf (fdwReason = DLL_PROCESS_DETACH) then
            MessageBox(NULL, "DLL UnMapped from Memory", "CAPTION", MB_OK)
    EndIf
return TRUE
End Function
Calling the Freebasic Compiler (FBC.EXE) with the -dll switch, you can create your own DLL like this:
    fbc mtsDll.bas -export -dll 


Please note that we have added our own DllMain in the DLL SourceFile. Now after calling our DLL with RUNDLL or LoadLibrary, we should have our DLL popping up a MessageBox just as written in the Code.


But, you will not have the Code in the DllMain performed. This is because the Freebasic Compiler redirects the DLL Entrypoint by default to it's own copy of DllMain (defaults it) (which ofcourse, doesnot contain the Code you have written).

Make your own Fonts for Windows OS





To design your own font, you need not be a specialist. You can make your own custom fonts with some Commercial and or non-commercial soft wares found readily on the Web. The software that I am going to use here is the one called TypeLight.



Typelight Setup
TypeLight - NEW FONT SCREEN
Drawing Character in Typelight (Source: Typelight Help)
The Fonts designed and or developed with Typelight can be used for personal or limited Commercial use. The fonts developed with Typelight can be sold legally with an exception that you are not a professional Font Developer (or earning from sale of fonts is not your primary source of income).

Found this post useful ? If so, Click +1 and RECOMMEND THIS SITE on Google

Get free domain name - Part 2


CO.NR




Freepremiumdomain Scheme











ShortURL
Get your own Subdomain (yourname.vze.com).

Cheap Domain name providers:







HostGator

Download Powerbasic for Windows for free

powerbasic

PowerBASIC for Windows is a native code compiler for all versions of Windows, from Windows 95 to Windows 7. It creates applications with a Graphical User Interface (GUI), to provide the typical "Look and Feel" of Windows. It creates highly efficient executables and industry-standard DLLs for optimum flexibility. The machine code generated by PowerBASIC is among the mostefficient in the industry, both in terms of size and speed. It compares most favorably with leading compilers of any dialect, Pascal, C++, Fortran, and others. 



The newest version of PB/Win sports a number of exciting new features. Total support for both ANSI and Unicode strings with automatic conversion. Simplified resource support. You can add resource data inline, right in your basic source code. There is no need to create a resource file, compile it, and then link it into your source. All this done automatically. Dead code removal. Unreferenced code will be removed from the compiled program to minimize the executable file size. Create client COM application sand COM components using Dispatch, Direct, Automation, or Dual interfaces. The inline assembler has been expanded to support the full range of SIMD opcodes. A complete graphics engine, a printer package for Windows-Only printers, dynamic pointers, and thread local storage, to name just a few.

PowerBasic Home
Download Powerbasic 9 for Windows (PBWIN 9.05) - SITE1SITE2  Download Powerbasic 10 for Windows (PBWIN 10) - SITE1 | SITE2 | SITE3
Found this post useful ? If so, Click +1 and RECOMMEND THIS SITE on Google

Visual Studio 6 download

Download Visual Studio 6 Enterprise Edition
  1. 4Shared
  2. KAT.PH
Download Visual Studio 6 Portable Edition
  1. Dl4All
Download Visual Basic 6 Portable Edition
  1. Rapidshare
Download Visual C++ 6 Portable Edition

  1. Mediafire
  2. KickAss Torrents
Visual Studio IDE Snapshots:

Visual Basic 6 IDE
Visual C++ 6 IDE


Videos of Visual Studio Development Tool:







PLEASE LET US KNOW IF YOU FIND THE 4SHARED LINK NOT WORKING OR FACE ANY PROBLEMS INSTALLING THE VISUAL STUDIO 6 ENTERPRISE EDITION.


THE FILE UPLOADED ON 4SHARED DOESN'T VIOLATE ANY COPYRIGHT(S). SOMEONE REPORTED IT ABUSIVE. I UPLOADED IT SO THAT THE NEEDY ONES COULD DOWNLOAD AND USE IT. I DIRECTLY UPLOADED A *LEGALLY* PURCHASED COPY OF VISUAL-STUDIO-6. IF YOU DON'T LIKE IT, DON'T DOWNLOAD IT. BUT, YOU'VE NO RIGHT TO REPORT OR MARK IT AS ABUSIVE.

Found this post useful ? If so, Click +1 and RECOMMEND THIS SITE on Google

USB not recognized


USB Not Recognized is an error related to the Universal Serial Bus.

First make sure that your USB Device (USB Keyboard or Pendrive) is not faulty. You can do that by connecting the Device to other Computer(s).Most of the time, it is the damaged Device itself not the USB Port.

What people report is that their Cell-phones properly charge when connected and kept to charge with a USB Cable.

Try unplugging the Computer completely from the main power line. Keep it so somewhere from 30 seconds to at most 30 minutes. Many reported to have their USB Ports working fine back again after doing so. If it is a Laptop, dis-connect the battery for the given period of time to see if it helps.
While this may not be the case for everyone, many report to have their USB Ports working fine again after replacing their Lithium Battery. Maybe that is the case for you.
Lithium Battery
The causes of this error are as follows:
  1. Outdated Driver
  2. Faulty Hardware
  3. Loose Connection
Solution:

Outdated Driver:
Download and install the latest version on the Driver from the Device Manufacturer's website. The Driver must be compatible to your Operating System.

Loose Connection:
Reseat the Motherboard. Pay a careful attention to the USB Cables connected to the Motherboard while reseating the Mobo.

Faulty Hardware:
The only solution could be replacing the Motherboard or using a what is known as 'PCI to USB Card'. Have all the 6 / 8 USB ports stopped working? If only the two USB Ports on the front section of the Computer have stopped working then, it could because of a cheap cabling.

Found this post useful ? If so, Click +1 and RECOMMEND THIS SITE on Google

Prevent Autorun Virus - Fighting Autorun Viruses



Autorun.inf, a feature introduced in Microsoft Windows Operating System family to help even the most unexperienced users to run and install softwares and System Device Drivers. A feature so infamous, criticized and so severe that Experts estimated that 1 outof every 10 viruses would be compulsorily an Autorun Virus. The was Feature so infamous that people believed the presence of Autorun.inf to be the presence of malwares and possible signs of infections. Antiviruses today report a suspicious object / infected object if they find an Autorun.inf file on the Computer on any directory and / or drive other than the CDVD Roms.
From simple Script Viruses like: Rahul’sVirusProtection, SemiAntivirus and the family of VBS.Autorun.Gen and other infection agents to the super-viruses like Conficker and Stuxnet.A, all (mis)used Autorun.inf in their quest of infecting the computers of innocent people.  

I won’t claim that after reading this you won’t at all get infected by any Autorun Virus and I won’t claim that you will be able to cure an already infected PC. What I guarantee is that the next time you insert your Removable Device in your Computer, you will open it with a knowledge which will save you from a possible infection.

Get free domain name









www.youname.co.cc
Free for 1 year. The Site owner will have to pay $3 per year to renew and use it after the first year.







www.yourname.co.nr
The Free Service is a URL Forwarding Service with URL Cloaking. The site needs to be reviewed and accepted before you get the Service.







www.yourname.com
You can register for a Website with Hyper Web Enable. You will recieve your own free TLD (Top Level Domain) website. Domain must be active and must generate the required traffic. Website must generate minimum traffic of 100 page views per day or 3000 page views on a monthly average. User will be given a 45 day grace period to generate this traffic after website allocation. HyperWebEnable.com has the right to deactivate your account if you do not meet the minimum traffic requirements.












www.yourname.free










www.yourname.tk
Free URL Forwarding, URL Cloaking and TikiLinks. The Website must fulfill a minimum traffic of 25 visits per month. But, once registered, one can request renewal for the Domain Name to be up again. You can also purchase a Premium Domain. TikiLinks (Tags) are small advertisements on Tk Websites that are useful in generating some traffic.







www.yourname.me.cc
Free URL Forwarding, URL Cloaking.





AwardSpace Free Webhosting Plan.



www.yourname.com.co.in




1YearFree

EU.ORG

Ezy Free - Domain Scheme

Free .pk  - Free domain for Pakistani Citizens
Free .com.np - Free domain for Nepalese Citizens

 Page 2 >>>

PLEASE DONOT POST *ANY* KIND OF ADVERT COMMENT(S) IN THIS BLOG

Found this post useful ? If so, Click +1 and recommend this site on Google

Driver in Freepascal - Target NativeNT

Freepascal Driver - Target NativeNT

Based on ‘WRITE ONCE COMPILE ANYWHERE’ principle, Freepascal has the ability to make DLLs, Console and GUI Applications for multiple platforms followed by support for ARM Processors, etc. A very interesting feature that Freepascal (may) will have in the near future is the ability to compile Kernel Mode and or User Mode Device Drivers. Although the support is unavailable in the current stable release, we might one day in the near future be writing our own Device Drivers in Freepascal wth a built in support in some new future release of Freepascal, that is for now not possible with the Current Stable Release of Freepascal. The Official Page related to this new feature is: Target-NativeNT in Freepascal Wiki.  
This post was created because we saw that many people were having problem/s building the NativeNT Freepascal Package provided as the Trunk Build.
If you just want the Compiled Tools and don’t want to know the actual build process, scroll down to the end of this page and you will find a RAR Package (password: nativent). You will find the Kernel Mode RTL (Units), NativeNT ppc386 (renamed to ppc) and NativeNT fpcmake. With those, you can simply extract and immediately start building your own Kernel Mode Driver in FreePascal. The Details are provided within the Package in the ReadME File along with a Sample Driver. If you have Delphi installed on your PC, you can use DDDK (Delphi Driver Development Kit).
With that being said, let’s start.
The real problem starts for the beginners, completely new to the GnuWIN32 MAKE Utility. The GnuWIN32 MAKE Utility simply reads the MakeFile in the Current Directory and starts the build process without giving the user the pain of doing it all manually. Now, I already have Lazarus installed in my Computer which means I don’t have to install the GnuWIN32 MAKE Utility additionally. The Lazarus Package comes with it (%LAZARUS_DIR%\fpc\2.4.4\bin\i386-win32\make.exe).

Goto the Freepascal Development Page

Download FPCBUILD.ZIP ( >= 60 MB )
Don’t download the fpc.zip ( 31 MB ), it will only emit error(s) and doesn't contain the files required for NativeNT Build Process.

Extract the ZIP to say drive D: and you will have a folder D:\fpcbuild



Okay, so below is my MAKE.CMD to enter the required Directories and call the required MAKE.EXE:
@ECHO OFF
d:
ECHO { NAVIGATING TO FPCBUILD DIR  }
ECHO { CALLING LAZARUS_MAKE.EXE    }
cd fpcbuild\fpcsrc\compiler
d:\lazarus\fpc\2.4.4\bin\i386-win32\make

ECHO { NAVIGATING TO UTILS_FPCM    }
ECHO { CALLING LAZARUS_MAKE.EXE    }
cd..\utils\fpcm
d:\lazarus\fpc\2.4.4\bin\i386-win32\make

ECHO { COMPILING FREEPASCAL RTL    }
cd d:\fpcbuild\fpcsrc\rtl
d:\lazarus\fpc\2.4.4\bin\i386-win32\make FPC=d:\fpcbuild\fpcsrc\compiler\ppc386.exe OS_TARGET=nativent OPT=”-dKMODE”

ECHO { #EXITING COMMAND_PROMPT#    }
PAUSE

Now, lets understand it part by part:
@ECHO OFF
d:
ECHO { NAVIGATING TO FPCBUILD DIR  }
ECHO { CALLING LAZARUS_MAKE.EXE    }
cd fpcbuild\fpcsrc\compiler
d:\lazarus\fpc\2.4.4\bin\i386-win32\make
1.       Enters Drive D:
2.       Goes to the Folder fpcbuild\fpcsrc\compiler
3.       Calls GnuWIN32 MAKE Utility residing in %LAZARUS_DIR%\fpc\2.4.4\bin\i386-win32\make.exe (%LAZARUS_DIR% in my case is D:\Lazarus).
If you are aware, there is a MakeFile in fpcbuild\fpcsrc\compiler\ which comes with the FPCBUILD.ZIP. The MAKE.EXE reads the MakeFile and starts the build Process of the Compiler.
The Same goes for the FPCMAKE.EXE in (..\utils\fpcm\). 
Now, building the RTL, we need to choose between UserMode and KernelMode. I will choose KernelMode RTL Compilation as it runs under RING0.
ECHO { COMPILING FREEPASCAL RTL    }
cd d:\fpcbuild\fpcsrc\rtl
d:\lazarus\fpc\2.4.4\bin\i386-win32\make FPC=d:\fpcbuild\fpcsrc\compiler\ppc386.exe OS_TARGET=nativent OPT=”-dKMODE”
The Make is the path of GnuWIN32 Make Utility in Lazarus Directory, FPC=YOUR_NEW_PPC386.EXE, OS_TARGET=nativent (otherwise the i386-win32 RTL would be produced) and OPT=”-dKMODE” is the switch that makes the difference between UserMode RTL and KernelMode RTL. You cannot produce both at once.

As you can see, the build process is quite simple. It Compiles fine with few warnings here and there. But at last, you will get the ppc386.exe(2.16MB) in  \fpcbuild\fpcsrc\compiler\ppc386.exe, fpcmake.exe in \fpcbuild\fpcsrc\utils\rtl\units\i386-nativent.
Found this post useful ? If so, Click +1 and recommend this site on Google

Driver in Freebasic


Freebasic is a free, open-source Dialect of Basic. It can produce fast, small and native Executables and DLLs. With no need for explicit declaration(s) of any Win32 API Function(s) followed by full inline ASM support, it turned out to be more reliable, efficient and powerful than other Basic dialects that i had (have) seen so far. With a helpful community available voluntarily available 24x7 for your help, it was a perfect Basic Language for both beginners and experts alike. It soon proved to be more powerful than it actually seemed.
I found a Sample Kernel Mode Device Driver in the FBC\examples\windows\ddk\driver\. The Sample Device Driver was written by a Freebasic Member called VoodooAttack.

I wanted to give it a try. I started by taking a look at the Code in Freebasic Driver Sample FBC\examples\windows\ddk\driver\DRIVER.BAS. The Code is:

'' NT driver example, written by voodooattack
   
    #include once "win\ddk\winddk.bi"
   
    #undef fb_RtInit
   
    declare function DriverEntry stdcall alias "DriverEntry" (byval pDriverObject as PDRIVER_OBJECT, _
                                                      byval pRegistryPath as PUNICODE_STRING) as NTSTATUS
   
   
   
    static shared dev_name as wstring ptr = @wstr("\Device\FBExample")
    static shared dev_dos_name as wstring ptr = @wstr("\DosDevices\FBExample")
   
    declare sub fb_RtInit stdcall alias "fb_RtInit"()
   
    declare function FBDriver_UnsupportedFunction(byval as PDEVICE_OBJECT, byval as PIRP) as NTSTATUS
    declare function FBDriver_Create(byval as PDEVICE_OBJECT, byval as PIRP) as NTSTATUS
    declare function FBDriver_Close(byval as PDEVICE_OBJECT, byval as PIRP) as NTSTATUS
    declare function FBDriver_IoControl(byval as PDEVICE_OBJECT, byval as PIRP) as NTSTATUS
    declare function FBDriver_Read(byval as PDEVICE_OBJECT, byval as PIRP) as NTSTATUS
    declare function FBDriver_Write(byval as PDEVICE_OBJECT, byval as PIRP) as NTSTATUS
    declare sub FBDriver_Unload(byval as PDRIVER_OBJECT)
   
   
    function DriverEntry(byval pDriverObject as PDRIVER_OBJECT, _
                         byval pRegistryPath as PUNICODE_STRING) as NTSTATUS
       
        dim Status as NTSTATUS = STATUS_SUCCESS
        dim pDeviceObject as PDEVICE_OBJECT = NULL
       
        dim as UNICODE_STRING usDriverName, usDosDeviceName
        dim i as integer
       
        DbgPrint(@!"FBExample: DriverEntry Called \r\n")
       
        RtlInitUnicodeString(@usDriverName, dev_name)
        RtlInitUnicodeString(@usDosDeviceName, dev_dos_name)
   
        Status = IoCreateDevice(pDriverObject, _
                                0, _
                                @usDriverName, _
                                FILE_DEVICE_UNKNOWN, _
                                FILE_DEVICE_SECURE_OPEN, _
                                FALSE, _
                                @pDeviceObject)
       

        if (Status = STATUS_SUCCESS) then
           
            DbgPrint(@!"FBExample: Device created \r\n")
           
            for i = 0 to IRP_MJ_MAXIMUM_FUNCTION - 1
                pDriverObject->MajorFunction(i) = @FBDriver_UnsupportedFunction
            next
           
            with *pDriverObject
                .MajorFunction(IRP_MJ_CLOSE)  = @FBDriver_Close
                .MajorFunction(IRP_MJ_CREATE) = @FBDriver_Create
                .MajorFunction(IRP_MJ_DEVICE_CONTROL) = @FBDriver_IoControl
                .MajorFunction(IRP_MJ_READ) = @FBDriver_Read
                .MajorFunction(IRP_MJ_WRITE) = @FBDriver_Write
                .DriverUnload = @FBDriver_Unload
                .Flags or= DO_DIRECT_IO
                .Flags and= NOT (DO_DEVICE_INITIALIZING)
            end with
           
            IoCreateSymbolicLink(@usDosDeviceName, @usDriverName)
        else
            DbgPrint(@!"FBExample: Error creating device \r\n")
        end if
       
        return Status
       
    end function
   
    sub fb_RtInit()
        DbgPrint(@!"FBExample: fb_RtInit Called \r\n")
        return
    end sub
   
    declare function KeTickCount stdcall alias "KeTickCount" () as PLARGE_INTEGER
   
    function KeTickCount () as LARGE_INTEGER ptr
        static as LARGE_INTEGER c
        KeQueryTickCount(@c)
        return @c
    end function
   
    sub FBDriver_Unload(byval DriverObject as PDRIVER_OBJECT)
       
        dim usDosDeviceName as UNICODE_STRING
       
        DbgPrint(@!"FBExample: unloading.. \r\n")
       
        RtlInitUnicodeString(@usDosDeviceName, dev_dos_name)
       
        IoDeleteSymbolicLink(@usDosDeviceName)
        IoDeleteDevice(DriverObject->DeviceObject)
       
    end sub
   
    function FBDriver_UnsupportedFunction(byval DeviceObject as PDEVICE_OBJECT, byval Irp as PIRP) as NTSTATUS
        DbgPrint(@!"FBExample: Unsupported Function \r\n")
        return STATUS_NOT_SUPPORTED
    end function
   
    function FBDriver_Create(byval DeviceObject as PDEVICE_OBJECT, byval Irp as PIRP) as NTSTATUS
        DbgPrint(@!"FBExample: FBDriver_Create \r\n")
        return STATUS_SUCCESS
    end function

    function FBDriver_Close(byval DeviceObject as PDEVICE_OBJECT, byval Irp as PIRP) as NTSTATUS
        DbgPrint(@!"FBExample: FBDriver_Close \r\n")
        return STATUS_SUCCESS
    end function

    function FBDriver_IoControl(byval DeviceObject as PDEVICE_OBJECT, byval Irp as PIRP) as NTSTATUS
        DbgPrint(@!"FBExample: FBDriver_IoControl \r\n")
        return STATUS_SUCCESS
    end function

    function FBDriver_Read(byval DeviceObject as PDEVICE_OBJECT, byval Irp as PIRP) as NTSTATUS
        DbgPrint(@!"FBExample: FBDriver_Read \r\n")
        return STATUS_SUCCESS
    end function

    function FBDriver_Write(byval DeviceObject as PDEVICE_OBJECT, byval Irp as PIRP) as NTSTATUS
        DbgPrint(@!"FBExample: FBDriver_Write \r\n")
        return STATUS_SUCCESS
    end function

The Command in FBC\examples\windows\ddk\driver\MAKE.BAT. It has(d) the following command:

@echo off         
set drvname=driver

fbc %drvname%.bas -c

link %drvname%.o /DRIVER /align:0x80 /FULLBUILD /base:0x10000 /release /osversion:5.1 /version:5.1 /OPT:ICF /OPT:REF /SECTION:INIT,d /MERGE:_PAGE=PAGE /MERGE:.data=PAGE /MERGE:.ctors=PAGE /MERGE:_INIT=INIT /MERGE:_TEXT=.text /subsystem:native,5.01 /entry:GsDriverEntry@8 bufferoverflowk.lib ntoskrnl.lib /OUT:%drvname%.sys

Just in case you don’t know Command Prompt, @echo off prevents the Command Prompt Commands from showing up in the Console Window. Set drvname sets the Driver name as driver(filename of the Sample Driver). Fbc is the compiler executable belonging to the Freebasic Package. –c compiler switch belongs to FBC.EXE which tells the Compiler to output an Object File(.o).
%drvname%.bas = driver.bas(Filename of the Freebasic Sample Driver)

Now, lets compile, with these commands first and you may get the error:
\inc\win\ddk\winddk.bi(3399) error 4: Duplicated definition in type EXECUTION_STATE As ULONG
Error during Compilation

Now, open \inc\win\ddk\winddk.bi and goto Line 3399 and modify type EXECUTION_STATE As ULONG to ‘ type EXECUTION_STATE As ULONG. This will make the line appear as a comment to the Freebasic Compiler.  Now, try the same command fbc %drvname%.bas –c and you will get driver.o in the Source Folder.
Now, the real process starts here.

The point worth noting here is that the Author of the Sample Driver (VoodooAttack) possibly was calling link (LINK.EXE - the linker which upon passing proper commands would produce an Executable accordingly from an Object File(s)). The Sample Driver was written possibly for Freebasic v0.17b or earlier. And, there is no link.exe now. The latest Freebasic Version available for use at the time of writing this article is Freebasic V0.23 which has ld.exe (\bin\win32\ld.exe). The Other point worth noting is that the current version of ld.exe has no compiler switch (command) called /driver.
Now, how could we build a Device Driver then. I went to the Freebasic forum and started a thread with a question about the LINK.EXE.  

The New command needed to produce a Kernel Mode Device Driver is as follows:
bin\win32\ld -h DRIVER.O -o DRIVER.SYS -shared  -e DriverEntry@8 --image-base 0x1000 --subsystem native -s -l ntoskrnl -L lib\win32

The bin\win32\ld is the path to the LD.EXE File. –h is the path to the Source (Object File), -o is the path to the desired output file, -e defines the Executable’s EntryPoint, --image-base defines the base Address of the Executable –subsystem is to be passed native (Drivers have no Subsystem(s)so pass native) –l  is the path to the Library (LIBPATH), -L is the path to the Directory holding the Library File.

Your Antivirus may complain about the Driver but, it is clean.
Avira AV falsely detects the Driver as a Rootkit


And, there you have it, a KERNEL MODE DEVICE DRIVER written entirely on Freebasic.

Found this post useful ? If so, Click +1 and recommend this site on Google