Jump to content

How to make this dllcall work?


kosamja
 Share

Recommended Posts

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
Link to comment
Share on other sites

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
Link to comment
Share on other sites

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...

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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

Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...