DllCreateEmpty()
- Shorter and Faster than CreateDLL() used in ROD-Ex owing to the 'Apply Patch' technique used.
- Supports Unicode filename ( use fullpath prefixed with "\\?\" )
- Places a Creation TimeDateStamp inside DLL
- Created DLL is more Compact - only 1024 bytes
Code:
DllCreateEmpty( F="empty.dll" ) { ; www.autohotkey.com/forum/viewtopic.php?p=381161#381161
;Creates Empty Resource-Only DLL (1024 bytes) / CD:05-Sep-2010 | LM:01-Jun-2011 - by SKAN
IfNotEqual,A_Tab, % TS:=A_NowUTC, EnvSub,TS,1970,S
Src := "0X5A4DY3CXC0YC0X4550YC4X1014CYD4X210E00E0YD8XA07010BYE0X200YECX1000YF0X1000YF4X1"
. "0000YF8X1000YFCX200Y100X4Y108X4Y110X2000Y114X200Y11CX4000003Y120X40000Y124X1000Y128X1"
. "00000Y12CX1000Y134X10Y148X1000Y14CX10Y1B8X7273722EY1BCX63Y1C0X10Y1C4X1000Y1C8X200Y1CC"
. "X200Y1DCX40000040", VarSetCapacity( Trg,1024,0 ), Numput( TS,Trg,200 ), DA:=0x40000000
Loop, Parse, Src, XY
Mod( A_Index,2 ) ? O := "0x" A_LoopField : NumPut( "0x" A_LoopField, Trg, O )
If ( hF := DllCall( "CreateFile", Str,F, UInt,DA, UInt,2,Int,0,UInt,2,Int,0,Int,0 ) ) > 0
B := DllCall( "_lwrite", UInt,hF,Str,Trg,UInt,1024 ), DllCall( "CloseHandle",UInt,hF )
Loop %F%
Return B ? A_LoopFileLongPath :
}
Quote:
Note to self:Exercise #3 Unlike
Exercise #2 where AStr is used to force ANSI filename, this function uses CreateFile() to support unicode filename.
Handles obtained with CreateFile() & OpenFile() are not compatible with _lclose().. and so CloseHandle() is being used here.
But _lwrite(), _llseek() and _lread() works properly with any file handle and are shorter/easier to use.