See Escape sequences, since backslash accepts \n + \nn + \nnn, \03 is considered one character, instead you need to use \000 if following char is a number.
I will update source to use \000 by default so this won't happen to someone else.
[Guide] Compiling Ahk_h's source step by step Topic is solved
Re: [Guide] Compiling Ahk_h's source step by step
@HotKeyIt
Thank you for taking the time to respond to this, Can I replace all `\0`characters with `\000`manually? Do I have to add anything particular for it to create the correct password regardless of numbers, letters or unicode characters?
On another note, I was hoping you could provide some insight into how to generate a random password. I'm trying to create functions that generate random zeros and points for random characters
I want to:
1) add a function that adds random amounts of "\0" to a global string(passwordString) and places random letters/numbers after the 0's - keeping track of the places of where they were added in string.
2) Replace "0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" with password string mentioned above
3) use charTrackerArray array in place of [i*number] - kept track of where random letters are added... i.e[1,3,2,5,4,3]
effectively replacing this:
with this:
I would like it to output the password in a text file as opposed to a warning. I'm not well versed in C++ but I have attempted to create something mentioned above to no avail, if you could provide your expertise I'm sure many would find this extremely useful. It would also help complete this guide.
Thank you HotKeyIt for all of your hard work, AHK_H is honestly the best.
Thank you for taking the time to respond to this, Can I replace all `\0`characters with `\000`manually? Do I have to add anything particular for it to create the correct password regardless of numbers, letters or unicode characters?
On another note, I was hoping you could provide some insight into how to generate a random password. I'm trying to create functions that generate random zeros and points for random characters
Code: Select all
passwordString = ""
charTrackerArray = []
addRandomChar() {
}
addRandomZeros() {
}
createPW_String {
for (int n=0; n<20; n++) {
tempString = ""
addRandomZeros()
addRandomChar()
charTrackerArray.push(tempString.length() - 2)
passwordString += tempString
}
}
}
1) add a function that adds random amounts of "\0" to a global string(passwordString) and places random letters/numbers after the 0's - keeping track of the places of where they were added in string.
2) Replace "0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" with password string mentioned above
3) use charTrackerArray array in place of [i*number] - kept track of where random letters are added... i.e[1,3,2,5,4,3]
effectively replacing this:
Code: Select all
pw[i] = pwd == g_default_pwd ? (TCHAR) _T("0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0")[i*2] : (TCHAR)*pwd[i];
Code: Select all
pw[i] = pwd == g_default_pwd ? (TCHAR) _T(passwordString)[i*charTrackerArray[i+1]] : (TCHAR)*pwd[i];
Thank you HotKeyIt for all of your hard work, AHK_H is honestly the best.
-
- Posts: 45
- Joined: 14 Dec 2019, 20:21
Re: [Guide] Compiling Ahk_h's source step by step
is there a way we could write a batch to make the selections above , as to what needs installed from visual studios, and the selections for whats included in the build. incase we have to reinstall visual c again. im googling with limited info.
- manehscripts
- Posts: 126
- Joined: 03 May 2019, 16:10
Re: [Guide] Compiling Ahk_h's source step by step
Hello,
I have a problem about the Gdip_SaveBitmapToFile() function that's not working properly when compiling ahk_h source
No errors are displayed in the compilation process. However, the use of the official ahk_h release works, anyone can tell me if I need to add a library when compiling?
Just one more detail: The function is included in the Lib folders, I ran CleanUpAndPack.exe after compilation and the error present is -3 = Could not find matching encoder for specified file format
Function..
I have a problem about the Gdip_SaveBitmapToFile() function that's not working properly when compiling ahk_h source
No errors are displayed in the compilation process. However, the use of the official ahk_h release works, anyone can tell me if I need to add a library when compiling?
Just one more detail: The function is included in the Lib folders, I ran CleanUpAndPack.exe after compilation and the error present is -3 = Could not find matching encoder for specified file format
Function..
Code: Select all
;#####################################################################################
; Function: Gdip_SaveBitmapToFile
; Description: Saves a bitmap to a file in any supported format onto disk
;
; pBitmap Pointer to a bitmap
; sOutput The name of the file that the bitmap will be saved to. Supported extensions are: .BMP,.DIB,.RLE,.JPG,.JPEG,.JPE,.JFIF,.GIF,.TIF,.TIFF,.PNG
; Quality If saving as jpg (.JPG,.JPEG,.JPE,.JFIF) then quality can be 1-100 with default at maximum quality
; toBase64 If set to 1, instead of saving the file to disk, the function will return on success the base64 data
; A "base64" string is the binary image data encoded into text using only 64 characters.
; To convert it back into an image use: Gdip_BitmapFromBase64()
;
; return If the function succeeds, the return value is zero, otherwise:
; -1 = Extension supplied is not a supported file format
; -2 = Could not get a list of encoders on system
; -3 = Could not find matching encoder for specified file format
; -4 = Could not get WideChar name of output file
; -5 = Could not save file to disk
; -6 = Could not save image to stream [for base64]
; -7 = Could not convert to base64
;
; notes This function will use the extension supplied from the sOutput parameter to determine the output format
Gdip_SaveBitmapToFile(pBitmap, sOutput, Quality:=75, toBase64:=0) {
Static Ptr := "UPtr"
nCount := 0
nSize := 0
_p := 0
SplitPath sOutput,,, Extension
If !RegExMatch(Extension, "^(?i:BMP|DIB|RLE|JPG|JPEG|JPE|JFIF|GIF|TIF|TIFF|PNG)$")
Return -1
Extension := "." Extension
DllCall("gdiplus\GdipGetImageEncodersSize", "uint*", nCount, "uint*", nSize)
VarSetCapacity(ci, nSize)
DllCall("gdiplus\GdipGetImageEncoders", "uint", nCount, "uint", nSize, Ptr, &ci)
If !(nCount && nSize)
Return -2
If (A_IsUnicode)
{
StrGet_Name := "StrGet"
N := (A_AhkVersion < 2) ? nCount : "nCount"
Loop %N%
{
sString := %StrGet_Name%(NumGet(ci, (idx := (48+7*A_PtrSize)*(A_Index-1))+32+3*A_PtrSize), "UTF-16")
If !InStr(sString, "*" Extension)
Continue
pCodec := &ci+idx
Break
}
} Else
{
N := (A_AhkVersion < 2) ? nCount : "nCount"
Loop %N%
{
Location := NumGet(ci, 76*(A_Index-1)+44)
nSize := DllCall("WideCharToMultiByte", "uint", 0, "uint", 0, "uint", Location, "int", -1, "uint", 0, "int", 0, "uint", 0, "uint", 0)
VarSetCapacity(sString, nSize)
DllCall("WideCharToMultiByte", "uint", 0, "uint", 0, "uint", Location, "int", -1, "str", sString, "int", nSize, "uint", 0, "uint", 0)
If !InStr(sString, "*" Extension)
Continue
pCodec := &ci+76*(A_Index-1)
Break
}
}
If !pCodec
Return -3
If (Quality!=75)
{
Quality := (Quality < 0) ? 0 : (Quality > 100) ? 100 : Quality
If (quality>90 && toBase64=1)
Quality := 90
If RegExMatch(Extension, "^\.(?i:JPG|JPEG|JPE|JFIF)$")
{
DllCall("gdiplus\GdipGetEncoderParameterListSize", Ptr, pBitmap, Ptr, pCodec, "uint*", nSize)
VarSetCapacity(EncoderParameters, nSize, 0)
DllCall("gdiplus\GdipGetEncoderParameterList", Ptr, pBitmap, Ptr, pCodec, "uint", nSize, Ptr, &EncoderParameters)
nCount := NumGet(EncoderParameters, "UInt")
N := (A_AhkVersion < 2) ? nCount : "nCount"
Loop %N%
{
elem := (24+A_PtrSize)*(A_Index-1) + 4 + (pad := A_PtrSize = 8 ? 4 : 0)
If (NumGet(EncoderParameters, elem+16, "UInt") = 1) && (NumGet(EncoderParameters, elem+20, "UInt") = 6)
{
_p := elem+&EncoderParameters-pad-4
NumPut(Quality, NumGet(NumPut(4, NumPut(1, _p+0)+20, "UInt")), "UInt")
Break
}
}
}
}
If (toBase64=1)
{
; part of the function extracted from ImagePut by iseahound
; https://www.autohotkey.com/boards/viewtopic.php?f=6&t=76301&sid=bfb7c648736849c3c53f08ea6b0b1309
DllCall("ole32\CreateStreamOnHGlobal", "ptr",0, "int",true, "ptr*",pStream)
_E := DllCall("gdiplus\GdipSaveImageToStream", "ptr",pBitmap, "ptr",pStream, "ptr",pCodec, "uint", _p ? _p : 0)
If _E
Return -6
DllCall("ole32\GetHGlobalFromStream", "ptr",pStream, "uint*",hData)
pData := DllCall("GlobalLock", "ptr",hData, "ptr")
nSize := DllCall("GlobalSize", "uint",pData)
VarSetCapacity(bin, nSize, 0)
DllCall("RtlMoveMemory", "ptr",&bin, "ptr",pData, "uptr",nSize)
DllCall("GlobalUnlock", "ptr",hData)
ObjRelease(pStream)
DllCall("GlobalFree", "ptr",hData)
; Using CryptBinaryToStringA saves about 2MB in memory.
DllCall("Crypt32.dll\CryptBinaryToStringA", "ptr",&bin, "uint",nSize, "uint",0x40000001, "ptr",0, "uint*",base64Length)
VarSetCapacity(base64, base64Length, 0)
_E := DllCall("Crypt32.dll\CryptBinaryToStringA", "ptr",&bin, "uint",nSize, "uint",0x40000001, "ptr",&base64, "uint*",base64Length)
If !_E
Return -7
VarSetCapacity(bin, 0)
Return StrGet(&base64, base64Length, "CP0")
}
_E := DllCall("gdiplus\GdipSaveImageToFile", Ptr, pBitmap, "WStr", sOutput, Ptr, pCodec, "uint", _p ? _p : 0)
Return _E ? -5 : 0
}
-----------------------------------------------------------
Stop to think, shut up to resist, and act to win!
Stop to think, shut up to resist, and act to win!