Jump to content
kosamja

How to make this dllcall work?

Recommended Posts

kosamja

I would like to use FormatEx to format usb drive, but this dllcall crashes script. How to call FormatEx function so that i doesnt crash script?

;~ https://github.com/hacksysteam/ShellcodeOfDeath/blob/master/ShellcodeOfDeath.c
;~ https://www.experts-exchange.com/questions/10500798/Quickformat-Disk-using-API.html
;~ http://www.purebasic.fr/english/viewtopic.php?p=145229
;~ http://forum.codenet.ru/q59720?nowrap=1&s=

#NoTrayIcon
#RequireAdmin
#include <Array.au3>


$a = DllCall("fmifs.dll", "long", "FormatEx", "wstr", 'G:\', "dword", 11, "wstr", "NTFS", "wstr", "", "bool", True, "dword", 0, "ptr", 0)
MsgBox(0,@error, $a[0])
_ArrayDisplay($a)

 

Edited by kosamja

Share this post


Link to post
Share on other sites
RTFC
Quote

TheFormatEx function in FMIFS.DLL is prototyped like this:

VOID FormatEx ( PWCHAR DriveRoot,
   DWORD MediaFlag ,
   PWCHAR Format,
   PWCHAR Label,
   BOOL QuickFormat,
   DWORD ClusterSize,
   PFMIFSCALLBACK Callback);

where the FMIFSCALLBACK is:

typedef BOOLEAN (__stdcall *PFMIFSCALLBACK)(
   CALLBACKCOMMAND Command,
   DWORD SubAction,
   PVOID ActionInfo );

So your dll calling parameters are incorrect. If you had done a proper websearch, you would instantly have found this site, from which source code (that would have to be adapted for AutoIt) can still be downloaded. The rest is up to you...

Edited by RTFC
link updated

Share this post


Link to post
Share on other sites
kosamja
15 minutes ago, RTFC said:

So your dll calling parameters are incorrect. If you had done a proper websearch, you would instantly have found this site, from which source code (that would have to be adapted for AutoIt) can still be downloaded. The rest is up to you...

I dont see nothing useful on site you linked, but If you meant about C examples where FormatEx is used I already found that and since I dont know to read C I obviously cant adapt it to autoit. Thats why I asked here for help...

Share this post


Link to post
Share on other sites
RTFC

You have to set up a dll CallBack for this to work. If you're familiar with PowerBasic, here's a source code example you might be able to adapt. AFAIK, there's no existing AutoIt source code for this particular function on the forums. But someone else may have something lying around, if you're lucky.

  • Like 1

Share this post


Link to post
Share on other sites
Danyfirex

Hello. I have not time to see too much. But base in RTFC's first post This could be a start...

 

Local $hHandle = DllCallbackRegister("_PFMIFSCALLBACK", "long", "long;dword;ptr")
Local $pCallBack = DllCallbackGetPtr($hHandle)


DllCall("yourdll.ll", "none", "FormatEx", "dword", $MediaFlag, "wstr", $Format, "wstr", $Label, "bool", $QuickFormat, "dword", $ClusterSize, "ptr", $pCallBack)

DllCallbackFree($hHandle)


Func _PFMIFSCALLBACK($Command, $SubAction, $ActionInfo)

EndFunc   ;==>_PFMIFSCALLBACK

 

 

Saludos

  • Like 1

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.