NSD_CreateText not populating stack - stack

For my NSIS script I need some user info, so I have the following code:
Function tomcatConfig
!insertmacro MUI_HEADER_TEXT "$(TEXT_CONF_TITLE)" "$(TEXT_CONF_SUBTITLE)"
nsDialogs::Create 1018
Pop $0
${NSD_CreateLabel} 0 2u 100u 14u "Tomcat shutdown port"
Pop $R0
${NSD_CreateText} 150u 0 50u 12u "8005"
Pop $CtlTomcatPortShutdown
${NSD_SetTextLimit} $CtlTomcatPortShutdown 5
${NSD_CreateLabel} 0 19u 100u 14u "Tomcat default http port"
Pop $R0
${NSD_CreateText} 150u 17u 50u 12u "80"
Pop $CtlTomcatPortHttp
${NSD_SetTextLimit} $CtlTomcatPortHttp 5
${NSD_CreateLabel} 0 36u 100u 14u "Tomcat default https port"
Pop $R0
${NSD_CreateText} 150u 34u 50u 12u "443"
Pop $CtlTomcatPortSSL
${NSD_SetTextLimit} $CtlTomcatPortSSL 5
${NSD_CreateLabel} 0 57u 140u 14u "Tomcat service name"
Pop $R0
${NSD_CreateText} 150u 55u 140u 12u "Servicename"
Pop $CtlTomcatServiceName
${NSD_SetFocus} $CtlTomcatPortShutdown
nsDialogs::Show
FunctionEnd
When I am using $CtlTomcatPortShutdown, $CtlTomcatPortHttp, $CtlTomcatPortHttp, $CtlTomcatServiceName in my script, I get returned some random number, instead of the input I expect (service name, port numbers etc.).
This sample from NSIS NsDialog page also looks invalid on Windows 10, when I use $Text I am returned a random number as well.
!include nsDialogs.nsh
!include LogicLib.nsh
Name nsDialogs
OutFile nsDialogs.exe
XPStyle on
Var Dialog
Var Label
Var Text
Page custom nsDialogsPage
Page instfiles
Function nsDialogsPage
nsDialogs::Create 1018
Pop $Dialog
${If} $Dialog == error
Abort
${EndIf}
${NSD_CreateLabel} 0 0 100% 12u "Hello, welcome to nsDialogs!"
Pop $Label
${NSD_CreateText} 0 13u 100% -13u "Type something here..."
Pop $Text
nsDialogs::Show
FunctionEnd
Section
DetailPrint "hello $Text"
SectionEnd

The ${NSD_CreateXYZ} macros return the handle (HWND) to the control on the stack, not a random number. This handle can be used in calls to ${NSD_GetText} and ${NSD_SetText} etc.

Related

Web RTC setLocalDescription always fails on iOS 14

I'm working on a small web rtc framework on iOS and having difficulties with setRemoteDescription. I wrote my own SDP parser/writer and checked every aspect of it. Even thought the SDP looks fine, it always fails:
let sessionDescription = RTCSessionDescription(type: .answer, sdp: sdp)
pc.setRemoteDescription(sessionDescription) { error in
if let error = error {
// Always fails with "SessionDescription is NULL"
}
else {
...
}
}
The error is:
Error Domain=org.webrtc.RTC_OBJC_TYPE(RTCPeerConnection) Code=-1 "SessionDescription is NULL." UserInfo={NSLocalizedDescription=SessionDescription is NULL.}
Here is the po of sessionDescription:
v=0
o=clientlib 10000 1 IN IP4 0.0.0.0
s=-
t=0 0
a=ice-lite
a=fingerprint:sha-512 C9:CE:DF:4A:9A:35:95:6F:94:BF:14:82:50:A2:73:97:54:97:5D:1D:7A:C1:B0:31:A7:44:92:4A:A5:F1:ED:22:EB:A1:D2:22:7B:6F:76:96:F1:95:97:2E:49:4E:B1:A4:61:AF:D9:9E:82:55:C8:55:EA:6E:2B:56:BE:55:C4:3C
a=msid-semantic: WMS *
a=group:BUNDLE 0
m=video 7 96 97 98 99 100 101 127 123 125 122 124 100
c=IN IP4 127.0.0.1
a=rtpmap:100 VP8/90000
a=fmtp:100 x-google-start-bitrate=1000
a=extmap:4 urn:ietf:params:rtp-hdrext:sdes:mid
a=extmap:5 urn:ietf:params:rtp-hdrext:sdes:rtp-stream-id
a=extmap:6 urn:ietf:params:rtp-hdrext:sdes:repaired-rtp-stream-id
a=extmap:2 http://www.webrtc.org/experiments/rtp-hdrext/abs-send-time
a=extmap:3 http://www.ietf.org/id/draft-holmer-rmcat-transport-wide-cc-extensions-01
a=extmap:8 http://tools.ietf.org/html/draft-ietf-avtext-framemarking-07
a=extmap:13 urn:3gpp:video-orientation
a=extmap:14 urn:ietf:params:rtp-hdrext:toffset
a=setup:active
a=mid:0
a=recvonly
a=ice-ufrag:jf3q436s5vhriv09
a=ice-pwd:s4sft4792k6gv49ml9psq9cantjt4hqj
a=candidate:udpcandidate 1 udp 1076558079 34.199.191.112 25738 typ host
a=candidate:tcpcandidate 1 tcp 1076302079 34.199.191.112 24688 typ host tcptype passive
a=end-of-candidates
a=ice-options:renomination
a=rtcp-mux
a=rtcp-rsize
Peer connection (pc) was created in a usual way:
let config = RTCConfiguration()
config.sdpSemantics = .unifiedPlan
let constraints = RTCMediaConstraints(mandatoryConstraints: nil, optionalConstraints: nil)
pc = peerConnectionFactory.peerConnection(with: config, constraints: constraints, delegate: self)
Is there any way to get more information about what's wrong with the sdp other than "SessionDescription is NULL"?
Any hints, ideas are appreciated.
I see a couple possible issues
Your m line contains RTP PayloadTypes that aren't defined. Change it to m=video 100
m line was the issue, see comments for discussion. candidate string isn't actually an issue
Your candidate line might be wrong. I don't believe foundation can be a string? I need to check the spec though. Instead of udpcandidate and tcpcandidate do 1 and 2. Refer to the spec for the actual algorithim to generate that value.

Generate electron app.exe which will ask for user input during installation (using electron-builder and nsis)?

I am trying to generate electron app.exe with the use of **electron-builder** and **nsis**, which should ask user input at time of installation.
Following is my **package.json**.
...
"build": {
"appId": "com.electron.test",
"productName": "test",
"win": {
"target": [
"nsis"
],
"icon": "assets/icon.ico"
},
"nsis": {
"warningsAsErrors": false,
"installerIcon": "assets/icon.ico",
"runAfterFinish": false,
"oneClick": false,
"perMachine": true,
"allowToChangeInstallationDirectory": true,
"installerHeader": "assets/installerHeader.bmp",
"include": "build/installer.nsh"
},
"mac": {
"category": "your.app.category.type"
}
}
...
I want to display custom page **Between** Select Location Page and Installation Progress Page.
Following is my **installer.nsh** which is create one custom page i.e. ask for user to input username and password.
!include "EnvVarUpdate.nsh"
!include "MUI2.nsh"
!include "nsDialogs.nsh"
!include "LogicLib.nsh"
Var Dialog
Var UserLabel
Var UserText
Var UserState
Var PassLabel
Var PassText
Var PassState
;--------------------------------
; Show install details
ShowInstDetails show
;--------------------------------
;Interface Settings
!define MUI_ABORTWARNING
Page custom nsDialogsPage nsDialogsPageLeave
Function nsDialogsPage
nsDialogs::Create 1018
Pop $Dialog
${If} $Dialog == error
Abort
${EndIf}
${NSD_CreateLabel} 0 0 100% 12u "Username:"
Pop $UserLabel
${NSD_CreateText} 0 13u 100% 12u $UserState
Pop $UserText
${NSD_CreateLabel} 0 39u 100% 12u "Password:"
Pop $PassLabel
${NSD_CreatePassword} 0 52u 100% 12u $PassState
Pop $PassText
nsDialogs::Show
FunctionEnd
Function nsDialogsPageLeave
${NSD_GetText} $UserText $UserState
${NSD_GetText} $PassText $PassState
${If} $UserState == ""
MessageBox MB_OK "Username is missing."
Abort
${EndIf}
${If} $PassState == ""
MessageBox MB_OK "Password is missing."
Abort
${EndIf}
StrCpy $1 $UserState
StrCpy $2 $PassState
FileOpen $9 $INSTDIR\credentials.txt w
FileWrite $9 "$1:$2"
FileClose $9
SetFileAttributes $INSTDIR\credentials.txt HIDDEN|READONLY
FunctionEnd
Section
SectionEnd
!macro customHeader
!macroend
!macro preInit
!macroend
!macro customInstall
${EnvVarUpdate} $0 "PATH" "A" "HKLM" "$INSTDIR"
!macroend
!macro customUnInstall
${un.EnvVarUpdate} $0 "PATH" "R" "HKLM" "$INSTDIR"
!macroend
Please provide any solution.
**Thanks & Regards**
Rachit V. Sakhidas
It looks like everything is correct. The NSIS script posted is for creating your custom page. What is your question? Do you have any errors or you just do not know what to do?
Q: Your page is not shown in installer?
If no: Did you include you custom page in the electron-nsis script so the page is actually shown?
Q: Do you have troubles with creating custom pages?
If yes: try this tool: https://nsis.sourceforge.io/Install_Designer (I am its developer so feel free to ask here any questions).
It is really tough to says what is wrong with this few information, please post full scripts and logs.

Tshark - How to show the Dissection Tree of tcp playload only with tshark?

I am writing a wireshark dissector.I want to show the Dissection Tree in console.
So I tried:
tshark -V
It will show something like:
Frame 105: 69 bytes on wire (552 bits)...
...
Ethernet II, Src: Giga-Byt_97:b3:26 (e0:d5:5e:97:b3:26), Dst: Cradlepo_68:04:37 (00:e0:1c:68:04:37)
...
Internet Protocol Version 4, Src: 192.168.1.153, Dst: 192.168.1.99
...
Transmission Control Protocol, Src Port: 7555, Dst Port: 50555, Seq: 10182, Ack: 485, Len: 15
....
erlang term
PackageLength: 11
compressFlag: 0
m_system_hb_toc(2) [SmallTuple: 2]
time: 1589549432 [Int]
But only the last part is what i need:
erlang term
PackageLength: 11
compressFlag: 0
m_system_hb_toc(2) [SmallTuple: 2]
time: 1589549432 [Int]
I have tried with '-T fields' and -e option,but can not find any thing help.
Here's my dissecter's code:
local tcpPortLs = {7555}
local SIZE_LEN = 4
local pErlangExt = Proto("ErlangExt", "erlang term")
local fLen = ProtoField.uint32("ErlangExt.len", "PackageLength", base.DEC)
local fCompressFlag = ProtoField.string("ErlangExt.compressFlag", "compressFlag", base.ASCII)
local fBytes = ProtoField.bytes("ErlangExt.data", "PackageData", base.COLON)
pErlangExt.fields = {
fLen,
fBytes,
fCompressFlag,
}
local function msg_pdu_length(buf, pkt, offset)
local size_tvbr = buf:range(offset, SIZE_LEN)
local size = size_tvbr:uint()
return size + SIZE_LEN
end
local function _headBytes(n, dataBuf)
local head = dataBuf(0, n)
if dataBuf:len() == n then
return head, nil
end
local tailDataBuf = dataBuf(n, dataBuf:len() - n)
return head, tailDataBuf
end
local function _addToGroup()
-- ...
end
local function _calcMainTree()
-- ...
end
local function msg_proto_dissector(buf, pkt, root)
local dataLenBuf, metaAndDataBytes = _headBytes(SIZE_LEN, buf)
local detail = root:add(pErlangExt, buf)
local dataLen = dataLenBuf:uint()
detail:add(fLen, dataLenBuf, dataLen)
local zlibFlagBuf, tupleDataBuf = _headBytes(1, metaAndDataBytes)
local zlibFlag = zlibFlagBuf:uint()
detail:add(fCompressFlag, zlibFlagBuf, zlibFlag)
local dataRoot = detail:add(fBytes, tupleDataBuf)
pkt.cols.protocol = "ErlangExt"
local tree = _calcMainTree(tupleDataBuf, zlibFlag)
_addToGroup(dataRoot, tree)
end
function pErlangExt.dissector(buf, pkt, root)
local pktLen = buf:len()
if pktLen ~= buf:reported_len() then
return 0
end
dissect_tcp_pdus(buf, root, 4, msg_pdu_length, msg_proto_dissector)
return pktLen
end
local tcp_encap_table = DissectorTable.get("tcp.port")
for _, port in pairs(tcpPortLs) do
tcp_encap_table:add(port, pErlangExt)
end
And the captured data is https://github.com/cmingjian/testData/blob/master/stage.pcapng
How can I display only the data that I need?
Thanks.
Maybe tshark -O ErlangExt will provide you with the results you're seeking? You'll still get summary lines of all lower layers (Ethernet, IP, TCP), but only your ErlangExt data will be expanded.
From the tshark man page:
-O < protocols >
Similar to the -V option, but causes TShark to only show a detailed view of the comma-separated list of protocols specified, and show only the top-level detail line for all other protocols, rather than a detailed view of all protocols. Use the output of "tshark -G protocols" to find the abbreviations of the protocols you can specify.

NSIS : How to keep input value from previous dialog after click Next/Back button?

If I change value in textbox and click Next button, then click Back button to back to the page again, I wanna keep new value that I changed it in textbox. How can I do?
This is my code :
AcustomPage.nsh
!macro create_AcustomPage APP_NAME CUS_FULLNAME
Page custom create_AcustomPage leave_AcustomPage
Function create_AcustomPage
Push $0
StrCpy $AcustomPage.FirstOpened 0
nsDialogs::Create 1018
Pop $AcustomPage
GetDlgItem $AcustomPage.Button.Next $HWNDPARENT 1
System::Call user32::GetWindowText(i$AcustomPage.Button.Next,t.s,i${NSIS_MAX_STRLEN})
nsDialogs::CreateControl STATIC ${WS_VISIBLE}|${WS_CHILD}|${WS_CLIPSIBLINGS} 0 0u 0u 100% 20u "${AcustomPage_TITLE}"
Pop $AcustomPage.Text
${NSD_CreateGroupBox} 0u 20u 100% 78% "AcustomPage Setting"
Pop $AcustomPage.SettingBox
${NSD_CreateLabel} 10u 50u 20u 11u "URL:"
Pop $AcustomPage.FULLNAME.Label
${NSD_CreateText} 60u 50u 60% 11u ""
Pop $0
${NSD_OnChange} $0 Update_AcustomPage_Next_Button
${If} ${CUS_FULLNAME} != ""
${NSD_SetText} $0 ${CUS_FULLNAME}
${EndIf}
Call Update_AcustomPage_Next_Button
nsDialogs::Show
FunctionEnd
Function leave_AcustomPage
${NSD_GetText} $0 $CUS_FULLNAME
FunctionEnd
Function Update_AcustomPage_Next_Button
Push $R5
${NSD_GetText} $0 $R5
${If} $R5 != ""
EnableWindow $AcustomPage.Button.Next 1
Return
${EndIf}
${If} $R5 == ""
EnableWindow $AcustomPage.Button.Next 0
Return
${EndIf}
Pop $R5
FunctionEnd
!macroend
Thanks,
You are on the right track by always saving the text in $CUS_FULLNAME in the leave callback but you never use $CUS_FULLNAME to set the text when creating the page, you seem to try to do something with ${CUS_FULLNAME} instead!
It should probably look more like this:
${NSD_CreateText} 60u 50u 60% 11u "${CUS_FULLNAME}"
Pop $0
${If} $CUS_FULLNAME != ""
${NSD_SetText} $0 $CUS_FULLNAME
${EndIf}
${NSD_OnChange} $0 Update_AcustomPage_Next_Button
Here is a standalone example:
!include nsDialogs.nsh
var hCtlFullName
var FullName
Function mypageCreate
nsDialogs::Create 1018
Pop $0
${NSD_CreateText} 60u 30u 60% 11u "$FullName"
Pop $hCtlFullName
${NSD_OnChange} $hCtlFullName mypage_VerifyInput
call mypage_VerifyInput
nsDialogs::Show
FunctionEnd
Function mypageLeave
${NSD_GetText} $hCtlFullName $FullName
FunctionEnd
Function mypage_VerifyInput
Call mypageLeave ; Loads the text into $FullName
Push $0
GetDlgItem $0 $HWNDPARENT 1
${If} $FullName == ""
EnableWindow $0 0
${Else}
EnableWindow $0 1
${EndIf}
Pop $0
FunctionEnd
Page Custom mypageCreate mypageLeave
Page Components
Page InstFiles
Section
DetailPrint $FullName
SectionEnd

Hide password with asterisk in lua

I there a way to ask password in lua but hide with asterisks?
I'm asking about a console application
For Unix: use os.execute("stty -echo raw") to turn off echoing and enter raw mode (character-by-character input) and os.execute("stty echo cooked") to turn it on and exit raw mode when you are done. In raw mode, you can get each character of the input using io.stdin:read(1) and echo your asterisk as you go (use io.flush to ensure the character appears straight away). You will need to handle deletes and the end of line yourself.
For Windows, the situation is a bit trickier. Look at What would be the Windows batch equivalent for HTML's input type=“password”? for some approaches, the best of which seems to be a VB script.
Postscript
Thanks for lhf for pointing out that you need raw mode besides -echo on input and flush after each output asterisk to get the desired result: unless you have both, the asteriskes will not be echoed until the line is ended.
This code uses platform-specific features and works both on Linux and 32-bit Windows.
Compatible with Lua 5.1 and Lua 5.2
local console
local function enter_password(prompt_message, asterisk_char, max_length)
-- returns password string
-- "Enter" key finishes the password
-- "Backspace" key undoes last entered character
if not console then
if (os.getenv'os' or ''):lower():find'windows' then
------------------ Windows ------------------
local shift = 10
-- Create executable file which returns (getch()+shift) as exit code
local getch_filespec = 'getch.com'
-- mov AH,8
-- int 21h
-- add AL,shift
-- mov AH,4Ch
-- int 21h
local file = assert(io.open(getch_filespec, 'wb'))
file:write(string.char(0xB4,8,0xCD,0x21,4,shift,0xB4,0x4C,0xCD,0x21))
file:close()
console = {
wait_key = function()
local code_Lua51, _, code_Lua52 = os.execute(getch_filespec)
local code = (code_Lua52 or code_Lua51) - shift
assert(code >= 0, getch_filespec..' execution failed')
return string.char(code)
end,
on_start = function() end,
on_finish = function() end,
backspace_key = '\b'
}
-------------------------------------------
else
------------------ Linux ------------------
console = {
wait_key = function()
return io.read(1)
end,
on_start = function()
os.execute'stty -echo raw'
end,
on_finish = function()
os.execute'stty sane'
end,
backspace_key = '\127'
}
-------------------------------------------
end
end
io.write(prompt_message or '')
io.flush()
local pwd = ''
console.on_start()
repeat
local c = console.wait_key()
if c == console.backspace_key then
if #pwd > 0 then
io.write'\b \b'
pwd = pwd:sub(1, -2)
end
elseif c ~= '\r' and #pwd < (max_length or 32) then
io.write(asterisk_char or '*')
pwd = pwd..c
end
io.flush()
until c == '\r'
console.on_finish()
io.write'\n'
io.flush()
return pwd
end
-- Usage example
local pwd = enter_password'Enter password: '
print('You entered: '..pwd:gsub('%c','?'))
print(pwd:byte(1,-1))
Bug in code, for at least linux implementation. Need to add 'and c ~= nil`:
elseif c ~= '\r' and #pwd < (max_length or 32) and c ~= nil then

Resources