Jump to content

evilertoaster

Active Members
  • Posts

    1,196
  • Joined

  • Last visited

Profile Information

  • Member Title

Recent Profile Visitors

The recent visitors block is disabled and is not being shown to other users.

evilertoaster's Achievements

Universalist

Universalist (7/7)

4

Reputation

  1. That exact line would probably be something like: DllCall(DllOpen( "Ws2_32.dll" ), "int", "shutdown", "uint", $socket, "int", 1) ...
  2. 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)
  3. Seems there was a handle leak in _BMPOpen. It's been fixed in v3.3, see first post. Thanks.
  4. 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.
  5. 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.
  6. 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...
  7. 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.
  8. 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).
  9. 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).
  10. 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...
  11. 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?
  12. 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?
  13. 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.
  14. 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.
  15. 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...
×
×
  • Create New...