
evilertoaster
Active Members-
Posts
1,196 -
Joined
-
Last visited
Everything posted by evilertoaster
-
How to generate a specific TCP sequence
evilertoaster replied to skreien's topic in AutoIt Technical Discussion
That exact line would probably be something like: DllCall(DllOpen( "Ws2_32.dll" ), "int", "shutdown", "uint", $socket, "int", 1) ... -
ftp folder and sub-folder.
evilertoaster replied to pdinillo's topic in AutoIt General Help and Support
Not sure what FTP UDF you're using...maybe try using the 'official' one bundled with the installer: #Include <FTPEx.au3> $server ='my server' $username ='my username' $pass = 'my password' $location = 'someFolder' $Open = _FTP_Open('MyFTP Control') $Conn = _FTP_Connect($Open, $server, $username, $pass) _FTP_DirCreate($Conn,$location) $Ftpp = _FTP_DirPutContents($Conn, @MyDocumentsDir & '\And here the folder that have selected', $location,1) $Ftpc = _FTP_Close ($Open) -
Seems there was a handle leak in _BMPOpen. It's been fixed in v3.3, see first post. Thanks.
-
Selecting and Copying Text
evilertoaster replied to susb8383's topic in AutoIt General Help and Support
Firefox also has a UDF for automation you might want to try: I'd tend to use the browsers API rather than the windows API given the option. There's also an activeX option: but it seems to be less reliable. -
for any program to run more than one
evilertoaster replied to mesale0077's topic in AutoIt General Help and Support
If you'd like to leverage sandboxie to run multiple instances you can use command line args: http://www.sandboxie.com/index.php?StartCommandLine and call those from an AutoIt Script as the need may be. If you're asking how to make a virtual machine/sandbox using AutoIt as the desired programming language I think you're asking in the wrong forums. -
Selecting and Copying Text
evilertoaster replied to susb8383's topic in AutoIt General Help and Support
If it's a matter of putting it into a web form, it's usually easier to use the _IE UDFs (See the HelpFile)....assuming you're using Internet Explorer. _IEAttach() _IEGetObjById() and _IEFormElementSetValue() Are the relevant functions I think... -
WinAPI OpenProcess returns 0
evilertoaster replied to tom13's topic in AutoIt General Help and Support
I'm able to reproduce this on server 2008 as well (running as admin). Originally, there were about 50 of 80 processes that returned 0. Changing to 0x1000 reduced this to 6 (mostly system processes). To get the rest I used this: #RequireAdmin #Include <WinAPI.au3> setprivilege("sedebugprivilege", 1) $procs = ProcessList() $count = 0 for $a =1 to $procs[0][0] $processId = ProcessExists($procs[$a][0]) $processHandle = _WinAPI_OpenProcess(0x1000, 0, $processId, True) if ($processHandle=0) then $count+=1 Next MsgBox(0,"",$count) Func setprivilege($PRIVILEGE, $BENABLE) Const $MY_TOKEN_ADJUST_PRIVILEGES = 32 Const $MY_TOKEN_QUERY = 8 Const $MY_SE_PRIVILEGE_ENABLED = 2 Local $HTOKEN, $SP_AUXRET, $SP_RET, $HCURRPROCESS, $NTOKENS, $NTOKENINDEX, $PRIV $NTOKENS = 1 $LUID = DllStructCreate("dword;int") If IsArray($PRIVILEGE) Then $NTOKENS = UBound($PRIVILEGE) $TOKEN_PRIVILEGES = DllStructCreate("dword;dword[" & (3 * $NTOKENS) & "]") $NEWTOKEN_PRIVILEGES = DllStructCreate("dword;dword[" & (3 * $NTOKENS) & "]") $HCURRPROCESS = DllCall("kernel32.dll", "hwnd", "GetCurrentProcess") $SP_AUXRET = DllCall("advapi32.dll", "int", "OpenProcessToken", "hwnd", $HCURRPROCESS[0], "int", BitOR($MY_TOKEN_ADJUST_PRIVILEGES, $MY_TOKEN_QUERY), "int*", 0) If $SP_AUXRET[0] Then $HTOKEN = $SP_AUXRET[3] DllStructSetData($TOKEN_PRIVILEGES, 1, 1) $NTOKENINDEX = 1 While $NTOKENINDEX <= $NTOKENS If IsArray($PRIVILEGE) Then $PRIV = $PRIVILEGE[$NTOKENINDEX - 1] Else $PRIV = $PRIVILEGE EndIf $RET = DllCall("advapi32.dll", "int", "LookupPrivilegeValue", "str", "", "str", $PRIV, "ptr", DllStructGetPtr($LUID)) If $RET[0] Then If $BENABLE Then DllStructSetData($TOKEN_PRIVILEGES, 2, $MY_SE_PRIVILEGE_ENABLED, (3 * $NTOKENINDEX)) Else DllStructSetData($TOKEN_PRIVILEGES, 2, 0, (3 * $NTOKENINDEX)) EndIf DllStructSetData($TOKEN_PRIVILEGES, 2, DllStructGetData($LUID, 1), (3 * ($NTOKENINDEX - 1)) + 1) DllStructSetData($TOKEN_PRIVILEGES, 2, DllStructGetData($LUID, 2), (3 * ($NTOKENINDEX - 1)) + 2) DllStructSetData($LUID, 1, 0) DllStructSetData($LUID, 2, 0) EndIf $NTOKENINDEX += 1 WEnd $RET = DllCall("advapi32.dll", "int", "AdjustTokenPrivileges", "hwnd", $HTOKEN, "int", 0, "ptr", DllStructGetPtr($TOKEN_PRIVILEGES), "int", DllStructGetSize($NEWTOKEN_PRIVILEGES), "ptr", DllStructGetPtr($NEWTOKEN_PRIVILEGES), "int*", 0) $F = DllCall("kernel32.dll", "int", "GetLastError") EndIf $NEWTOKEN_PRIVILEGES = 0 $TOKEN_PRIVILEGES = 0 $LUID = 0 If $SP_AUXRET[0] = 0 Then Return 0 $SP_AUXRET = DllCall("kernel32.dll", "int", "CloseHandle", "hwnd", $HTOKEN) If Not $RET[0] And Not $SP_AUXRET[0] Then Return 0 Return $RET[0] EndFunc ;==>SETPRIVILEGE SetPrivilege was taken from nomads memory UDF. I'm not sure the full implications of doing it this way but it worked for me. -
And adding to that: I'd even go so far as to say recently (using .NET 4.0), I have yet to come across any practical situation where single pass (not spending hours on perf-testing/optimizing) C++ is faster than C#, especially C# with parallel extensions (http://en.wikipedia.org/wiki/Parallel_Extensions).All my developmental is for Windows though, and typically running on higher-endish servers with modern hardware. Only time I use C++ anymore is for platforms that don't support .NET (ever less common as Mono develops). I've resigned to the fact that C# and CLR compilers will micro-optimize my code across multiple hardware platforms better than I can optimize C++ for even a single one (at least in any sane-timely manner).
-
There's a lot of reasons why they COULD fail, detecting the error code can help you troubleshoot your specific problem: TCPStartup() Global $IpAddress=TCPNameToIP("blablabla.no-ip.biz") if (@error) Then MsgBox(0,"TCPNameToIP Error","Code: "&@error) Exit EndIf Global $Port = 2123 If _TCPSend("just some text") = 0 Then MsgBox(0, "error", "<.<") TCPShutdown() Func _TCPSend($fdata) $TCPConnect = TCPConnect($IpAddress, $Port) if (@error) Then MsgBox(0,"TCPConnect Error","Code: "&@error) return 0 EndIf TCPSend($TCPConnect, $fdata) if (@error) Then MsgBox(0,"TCPSend Error","Code: "&@error) return 0 EndIf Return 1 EndFunc If an error is given you can look up the code meaning on MSDN: http://msdn.microsoft.com/en-us/library/ms740668.aspx (note that TCPConnect codes 1 and 2 are proprietary).
-
In both cases, (TCPNameToIP and TCPConnect) try detecting errors using @error (see the examples in TCPSend in the help file) instead of the return value (as in question 1) or nothing (as in question 2). Subsequent calls to TCP functions would fail if those do...
-
It comes across as a dash in notepad or what-have-you, but that was never the issue. The raw output (for me at least) is:"73 74 75 66 66 E2 80 94" which as noted isn't quite what I'm after. Or does it come out differently for you?
-
Hum, I tried: char longdash = Convert.ToChar(8212); StringBuilder sb = new StringBuilder(); sb.Append("stuff" + longdash); File.WriteAllText("something.txt", sb.ToString()); But it doesn't output correctly either... did you have a working example?
-
The actual code involves a very heavy amount of looping, so you'd end up with thousands of FileWrite's doing that. You'd probably then use a Stream object for the writes instead of the static method, but at that point you're basically doing what I have there (assuming Stream objects are handled similar to an array of bytes)... and this way I don't have to refactor much. I tested a sample case after the fact, and they're near identical in terms of performance so it's a moot point for me.
-
Well, I can't argue with the results, a simple wrapping class allowed me near drop-in replacement for StringBuilder methods I was using: class ByteBuilder { public List<byte> bytes; public ByteBuilder() { bytes = new List<byte>(); } public void Append(string inStr) { bytes.AddRange(Encoding.Default.GetBytes(inStr)); } public void AppendByte(byte inByte) { bytes.Add(inByte); } } Then it's just: ByteBuilder bb = new ByteBuilder(); bb.Append("stuff"); bb.AppendByte(0x97); File.WriteAllBytes("something.txt", bb.bytes.ToArray()); Thanks for the help Richard + others.
-
hum, so I'd basically have to manually manage my byte arrays (resizing ect) when I append to them (or just allocate a safe upper-bound static one)... I don't know if it would do very well performance wise...In the actual code I'm enumerating though the results of a very large result set of a select * in SQL, then for each column of each row I do some string manipulation (which the String object's built in methods are of great help) and format an output line to the text file I'm writing... Sounds like alot of refactoring just to fix a supposedly basic encoding problem... I thought there'd by a better way to handle this with .NET...
-
How do you get a byte array from a StringBuilder object?
-
Basing it off the appendix in the AutoIt Help file, matches this page http://www.alanwood.net/demos/ansi.html AFAIK. The actual character is somewhat irrelevant, as long as it renders as the exact byte value I'm trying to tell it. This output is being fed into another system that expects a byte value of 0x97 (151).
-
No go.UTF8 Results in: "EF BB BF 73 74 75 66 66 C2 97". Just for the record I've already tried every available static property of encoding as a parameter to the FileWrite method, I'm hesitant to believe the solution lies solely within FileWrite...
-
Humm, no go: StringBuilder sb = new StringBuilder(); sb.Append("stuff" + '\x97'); File.WriteAllText("something.txt", sb.ToString(), Encoding.Default); Still writes a '?' And using Encoding.Unicode makes the file...unicode (2 bytes per char), which is not what I what.
-
That doesn't work for me... what's your full code? StringBuilder sb = new StringBuilder(); sb.Append("stuff"); sb.Append(Convert.ToChar(151)); File.WriteAllText("something.txt", sb.ToString(), Encoding.Default) //There is no Encoding.ANSI; edit: btw, that was exactly what I tired before asking-
-
Sounds about right, but no array support. It has 18 overloads for me, all taking a single object and converting it to a char.
-
hum *epiphany*... a char is 16 bits in C# (not 8!)...this changes a few assumptions I made when debugging for correctness. Regardless I tested both your examples. The first one has a binary output of "73 74 75 66 66 E2 80 94" the second has "73 74 75 66 66 C2 97 E2 80 94” neither is what I'm after. I want "73 74 75 66 66 97"... any idea how to get that?
-
So the problem was actually the way I tried appending to the StringBuilder...makes sense I guess, I had kinda always envisioned StringBuilder to use the Default encoding by...default... (go figure). I was in the same train of thought as Richard probably...a I tried telling the File.WriteAllText() to use ANSI encoding but it never worked. Thanks all.
-
I have a StringBuilder object that I append some text to and then convert to a string for a File.WriteAllText(). StringBuilder sb = new StringBuilder(); sb.Append("suff"); //Other sb.Append()'s File.WriteAllText("C:\Something.txt",sb.ToString()); The problem is that one of my appends is this: sb.Append(Convert.ToChar(151)) Which is supposed to make a "long dash". When the file gets written though, that byte comes out as 63, a question mark. I've tried various Encoding parameters but none of them seem to work... how do I get it to preserve the character when writing?
-
Possible @LogonDomain bug?
evilertoaster replied to 2tim3_16's topic in AutoIt General Help and Support
The script above returns the correct value for @LogonDomain when I tired it as: -a script -an x64 exe -an x86 exe -a domain user w/domain admin rights -a domain user w/o domain admin rights -a local user w/ local admin -a local user w/o local admin I certainly can't get it to be blank... can you describe your environment in any more detail?