Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories

VxD in Delphi

c0nf1gc0nf1g Member Posts: 7
Is there anybody know how to call a procedure in a VxD (from Delphi of course)?

Comments

  • zibadianzibadian Member Posts: 6,349
    : Is there anybody know how to call a procedure in a VxD (from Delphi of course)?
    :
    If you know the name and parameters of the procedure, you might try to load it similar to dynamically loading a standard DLL, ie. LoadLibrary(), GetProcAddress() and FreeLibrary().
  • c0nf1gc0nf1g Member Posts: 7
    : : Is there anybody know how to call a procedure in a VxD (from Delphi of course)?
    : :
    : If you know the name and parameters of the procedure, you might try to load it similar to dynamically loading a standard DLL, ie. LoadLibrary(), GetProcAddress() and FreeLibrary().
    :

    What should I do if I got the proc's address? How to call it?
  • zibadianzibadian Member Posts: 6,349
    : : : Is there anybody know how to call a procedure in a VxD (from Delphi of course)?
    : : :
    : : If you know the name and parameters of the procedure, you might try to load it similar to dynamically loading a standard DLL, ie. LoadLibrary(), GetProcAddress() and FreeLibrary().
    : :
    :
    : What should I do if I got the proc's address? How to call it?
    :
    You need to create a procedural type for that procedure. Here is an example of a procedural type in code:
    [code]
    type
    TStringExample = procedure(InStr: PChar; OutStr: PChar); StdCall;
    [/code]
    Then you can simply typecast the pointer returned by GetProcAddress as the correct procedure using the procedural type:
    [code]
    ...
    MyUpperCase = GetProcAddress(...);
    TStringExample(MyUppercase)(NormalStr, UpperStr);
    ...
    [/code]
    The code above might look strange, but that is because you are typecasting a pointer and then supplying the parameters.

    Note: In the type definition you need to match the parameters and calling convension precisely, otherwise you'll probably get several errors, or your system might freeze up.
  • c0nf1gc0nf1g Member Posts: 7
    : : : : Is there anybody know how to call a procedure in a VxD (from Delphi of course)?
    : : : :
    : : : If you know the name and parameters of the procedure, you might try to load it similar to dynamically loading a standard DLL, ie. LoadLibrary(), GetProcAddress() and FreeLibrary().
    : : :
    : :
    : : What should I do if I got the proc's address? How to call it?
    : :
    : You need to create a procedural type for that procedure. Here is an example of a procedural type in code:
    : [code]
    : type
    : TStringExample = procedure(InStr: PChar; OutStr: PChar); StdCall;
    : [/code]
    : Then you can simply typecast the pointer returned by GetProcAddress as the correct procedure using the procedural type:
    : [code]
    : ...
    : MyUpperCase = GetProcAddress(...);
    : TStringExample(MyUppercase)(NormalStr, UpperStr);
    : ...
    : [/code]
    : The code above might look strange, but that is because you are typecasting a pointer and then supplying the parameters.
    :
    : Note: In the type definition you need to match the parameters and calling convension precisely, otherwise you'll probably get several errors, or your system might freeze up.
    :

    Thanks pal, I'll try soon.
  • c0nf1gc0nf1g Member Posts: 7
    I can't LoadLibrary()!!!
    FYI, I make my own VxD like this :

    .386p
    include vmm.inc
    Declare_Virtual_Device ARIOSS, 1, 0, Control_Proc, Undefined_Device_ID,
    Undefined_Init_Order, , ,

    VxD_LOCKED_DATA_SEG
    SomeData db 0;
    VxD_LOCKED_DATA_ENDS

    VxD_LOCKED_CODE_SEG
    WaktuThread macro hThread, tThread
    VMMCall _GetLastUpdatedThreadExecTime, hThread
    mov [tThread], eax;
    EndM

    BeginProc Control_Proc
    Control_Dispatch Device_Init, Do_Device_Init
    clc
    ret
    EndProc Control_Proc
    VxD_LOCKED_CODE_ENDS

    VxD_ICODE_SEG
    BeginProc Do_Device_Init
    ret
    EndProc Do_Device_Init
    VxD_ICODE_ENDS

    END

    Is there something wrong????
Sign In or Register to comment.