Search the Community
Showing results for tags 'c'.
-
Full Disclaimer: e pentru un proiect la facultate Am si eu o nelamurire, ca sunt destul de noob in ceea ce priveste kernelul de Linux. Am de implementat un syscall (lucru pe care l-am invatat din tutorialul asta ), dar trebuie sa adaug un struct custom care sa-mi intoarca niste date despre procese si pe care sa-l primeasca ca parametru. Problema e ca nu stiu unde sa-l adaug, pentru ca la compilare imi spune ca nu-l gaseste. Pana acum l-am pus intr-un fisier .h din folderul cu syscallul si in include/linux/sched.h (practic ce am gasit printre putinele raspunsuri de pe stackoverflow si pe unde am mai cautat), dar tot nu e inclus in syscalls.h . Ideea e ca nici nu as vrea sa modific includeurile din syscalls.h fara sa fie nevoie, ci sa aflu unde sa-l pun corect. ./include/linux/syscalls.h:1389:32: error: unknown type name ‘ProcStruct’ Intrebarea mea e urmatoarea: unde ar trebui sa-l adaug?
-
Salutari! Am inceput sa invat programare de la 0 acum 6-7 luni in cadrul unei firme(C# in VS 2015, Sql Server 2008, Crystal Reports, WCF, am lucrat cu Windows Forms, Xaml, importuri de Excel in Sql). Eu consider ca am trecut prin the very basic stuffs. Inca nu le am foarte bine puse la punct, dar lucrez acasa si in timpul saptamanii si in week-end-uri cu tutoriale. Din anumite motive vreau sa plec de la firma asta si as vrea sa stiu de la cei cu experienta daca as putea sa caut un job remote, de acasa, avand in vedere ca orasul in care stau nu are prea multe firme de IT si in urmatorii 2 ani nu pot pleca. Mai precizez faptul ca nu am urmat facultatea pe domeniu(desi am inteles ca nu are mare relevanta daca ai sau nu) si nu am portofoliu, doar 6 luni in cartea de munca. Ce ati face in locul meu? Mersi anticipat! P.S. : imi cer scuze daca am postat intr-o sectie nepotrivita
-
Cum as putea sa obfuscatez un script in c code ??
-
Salut, Am o intrebare pentru voi astia care sunteti mai capabili... Cum pot modifica fieldul asta? Am gasit cod care modifica astea de sus, se foloseste de API-ul WinInet, dar nu ma duce capul cum pot sa modific doar fieldul Socks... Codul sursa este asta: Imports System Imports System.Runtime.InteropServices Public Class IEProxy Public Enum Options INTERNET_PER_CONN_FLAGS = 1 INTERNET_PER_CONN_PROXY_SERVER = 2 INTERNET_PER_CONN_PROXY_BYPASS = 3 INTERNET_PER_CONN_AUTOCONFIG_URL = 4 INTERNET_PER_CONN_AUTODISCOVERY_FLAGS = 5 INTERNET_OPTION_REFRESH = 37 INTERNET_OPTION_PER_CONNECTION_OPTION = 75 INTERNET_OPTION_SETTINGS_CHANGED = 39 PROXY_TYPE_PROXY = &H2 PROXY_TYPE_DIRECT = &H1 End Enum <StructLayout(LayoutKind.Sequential)> _ Private Class FILETIME Public dwLowDateTime As Integer Public dwHighDateTime As Integer End Class <StructLayout(LayoutKind.Explicit, Size:=12)> _ Private Structure INTERNET_PER_CONN_OPTION <FieldOffset(0)> Dim dwOption As Integer <FieldOffset(4)> Dim dwValue As Integer <FieldOffset(4)> Dim pszValue As IntPtr <FieldOffset(4)> Dim ftValue As IntPtr Public Function GetBytes() As Byte() Dim b(12) As Byte BitConverter.GetBytes(dwOption).CopyTo(b, 0) Select Case dwOption Case (Options.INTERNET_PER_CONN_FLAGS) BitConverter.GetBytes(dwValue).CopyTo(b, 4) Case (Options.INTERNET_PER_CONN_PROXY_BYPASS) BitConverter.GetBytes(pszValue.ToInt32()).CopyTo(b, 4) Case (Options.INTERNET_PER_CONN_PROXY_SERVER) BitConverter.GetBytes(pszValue.ToInt32()).CopyTo(b, 4) End Select Return (b) End Function End Structure <StructLayout(LayoutKind.Sequential, CharSet:=CharSet.Auto)> _ Private Class INTERNET_PER_CONN_OPTION_LIST Public dwSize As Integer Public pszConnection As String Public dwOptionCount As Integer Public dwOptionError As Integer Public pOptions As IntPtr End Class <StructLayout(LayoutKind.Sequential)> _ Private Class INTERNET_PROXY_INFO Public dwAccessType As Integer Public lpszProxy As IntPtr Public lpszProxyBypass As IntPtr End Class Private Const ERROR_INSUFFICIENT_BUFFER = 122 Private Const INTERNET_OPTION_PROXY = 38 Private Const INTERNET_OPEN_TYPE_DIRECT = 1 <DllImport("wininet.dll")> _ Private Shared Function InternetSetOption(ByVal hInternet As IntPtr, _ ByVal dwOption As Integer, _ ByVal lpBuffer As INTERNET_PER_CONN_OPTION_LIST, _ ByVal dwBufferLength As Integer) As Boolean End Function <DllImport("kernel32.dll")> _ Private Shared Function GetLastError() As Integer End Function Public Function SetProxy(ByVal proxy_full_addr As String) As Boolean Dim bReturn As Boolean Dim list As New INTERNET_PER_CONN_OPTION_LIST Dim dwBufSize As Integer = Marshal.SizeOf(list) Dim opts(3) As INTERNET_PER_CONN_OPTION Dim opt_size As Integer = Marshal.SizeOf(opts(0)) list.dwSize = dwBufSize list.pszConnection = ControlChars.NullChar list.dwOptionCount = 3 'set flags opts(0).dwOption = Options.INTERNET_PER_CONN_FLAGS opts(0).dwValue = Options.PROXY_TYPE_DIRECT Or Options.PROXY_TYPE_PROXY 'set proxyname opts(1).dwOption = Options.INTERNET_PER_CONN_PROXY_SERVER opts(1).pszValue = Marshal.StringToHGlobalAnsi(proxy_full_addr) 'set override opts(2).dwOption = Options.INTERNET_PER_CONN_PROXY_BYPASS opts(2).pszValue = Marshal.StringToHGlobalAnsi("local") Dim b(3 * opt_size) As Byte opts(0).GetBytes().CopyTo(b, 0) opts(1).GetBytes().CopyTo(b, opt_size) opts(2).GetBytes().CopyTo(b, 2 * opt_size) Dim ptr As IntPtr = Marshal.AllocCoTaskMem(3 * opt_size) Marshal.Copy(b, 0, ptr, 3 * opt_size) list.pOptions = ptr 'Set the options on the connection bReturn = InternetSetOption(IntPtr.Zero, Options.INTERNET_OPTION_PER_CONNECTION_OPTION, list, dwBufSize) If Not bReturn Then Debug.WriteLine(GetLastError) End If 'Notify existing Internet Explorer instances that the settings have changed bReturn = InternetSetOption(IntPtr.Zero, Options.INTERNET_OPTION_SETTINGS_CHANGED, Nothing, 0) If Not bReturn Then Debug.WriteLine(GetLastError) End If 'Flush the current IE proxy setting bReturn = InternetSetOption(IntPtr.Zero, Options.INTERNET_OPTION_REFRESH, Nothing, 0) If Not bReturn Then Debug.WriteLine(GetLastError) End If Marshal.FreeHGlobal(opts(1).pszValue) Marshal.FreeHGlobal(opts(2).pszValue) Marshal.FreeCoTaskMem(ptr) Return (bReturn) End Function Public Function DisableProxy() As Boolean Dim bReturn As Boolean Dim list As New INTERNET_PER_CONN_OPTION_LIST Dim dwBufSize As Integer = Marshal.SizeOf(list) Dim opts(0) As INTERNET_PER_CONN_OPTION Dim opt_size As Integer = Marshal.SizeOf(opts(0)) list.dwSize = dwBufSize list.pszConnection = ControlChars.NullChar list.dwOptionCount = 1 opts(0).dwOption = Options.INTERNET_PER_CONN_FLAGS opts(0).dwValue = Options.PROXY_TYPE_DIRECT Dim b(opt_size) As Byte opts(0).GetBytes().CopyTo(b, 0) Dim ptr As IntPtr = Marshal.AllocCoTaskMem(opt_size) Marshal.Copy(b, 0, ptr, opt_size) list.pOptions = ptr 'Set the options on the connection bReturn = InternetSetOption(IntPtr.Zero, Options.INTERNET_OPTION_PER_CONNECTION_OPTION, list, dwBufSize) If Not bReturn Then Debug.WriteLine(GetLastError) End If 'Notify existing Internet Explorer instances that the settings have changed bReturn = InternetSetOption(IntPtr.Zero, Options.INTERNET_OPTION_SETTINGS_CHANGED, Nothing, 0) If Not bReturn Then Debug.WriteLine(GetLastError) End If 'Flush the current IE proxy setting bReturn = InternetSetOption(IntPtr.Zero, Options.INTERNET_OPTION_REFRESH, Nothing, 0) If Not bReturn Then Debug.WriteLine(GetLastError) End If Marshal.FreeCoTaskMem(ptr) Return (bReturn) End Function End Class sProxy.SetProxy("proxy:port") 'setezi proxy sProxy.SetProxy("proxy:port") 'opresti proxy
-
Salut, am si eu o problema care ma tine pe loc de cateva zile. Ideea este ca am o tema de facut pentru facultate... este vorba de o aplicatie C# (WPF) in care trebuie folosit standardul MVVM. Pe langa asta, mai trebuie folosit si data binding, subiect care din punctul meu de vedere este destul de complex. Astazi este a treia zi in care ma documentez despre MVVM si DataBinding si totodata a doua zi in care nu am reusit sa avansez cu nimic concret. Link repo: https://bitbucket.org/WiseMarius/mediivizuale/overview Mai sus am lasat link catre repo-ul proiectului. Ce incerc sa fac ? Am in aplicatie un obiect ListBox si un obiect Image. Aceste doua obiecte trebuie legate de: o clasa ce implementeaza ObservableCollection si o clasa simpla ce contine o proprietate formata dintr-un vector de string-uri (care reprezinta calea catre niste imagini). Daca rulati proiectul o sa vedeti ca am reusit sa leg obiectul Image de clasa ce contine calea catre imagini, dar nu stiu cat de bine e facuta treaba asta. Practic eu in main am spus this.DataContext = obiectulMeu... asta inseamna ca pentru toata fereastra eu am setat un DataContext, deci tot ce pot lega de fereastra este strict legat de obiectulMeu... asta nu ma ajuta, in sensul in care eu am nevoie sa fac legaturi si catre alt obiect. Intrebarea mea este: de ce nu apar userii in listbox si cum as putea sa scap de chestia aia cu this.DataContext = obiectulMeu astfel incat sa nu am setat un singur DataContext pe tot MainWindow ? P.S: Nu stiu daca am organizat proiectul in cel mai bun mod... nu ma consider un arhitect foarte bun. Orice sfat e bine venit, cat timp are legatura cu intrebarile mele sau macar cu subiectul. Multumesc anticipat !
-
Repo-ul e pe private for now.
-
Salut, Am intalnit urmatoarea problema. Primesc un char * care reprezinta un ip. Ideea e ca eu trebuie sa compar mai multe ip-uri, dar, trebuie ca ele sa fie transformate in int32_t, adica numere pe 32 de biti. Are cineva idee cum se face asta? Initial am incercat ceva de genul asta #include <stdio.h> #include <stdlib.h> #include <string.h> #include <stdarg.h> int main (){ char * buffer; int sum = 0, i; buffer = (char*)malloc(100*sizeof(char)); scanf("%s", buffer); int32_t x; x = (int32_t)buffer; printf("%zu\n", x); } Am mai incercat la afisare sa fac cu %lo dar nu am obtinut nimic. Are cineva idee :D?
-
Avem urmatoarea bucata de cod scris in C: main(_){_^448&&main(-~_);putchar(--_%64?32|-~7[__TIME__-_/8%8][">'txiZ^(~z?"-48]>>";;;====~$::199"[_*2&8|_/64]/(_&2?1:8)%8&1:10);} Programul poate fi compilat exact asa cum este (testat cu gcc (GCC) 4.8.5 20150623 (Red Hat 4.8.5-4)), outputul fiind: [mrgrj@localhost tmp]# vim challangeRST.c [mrgrj@localhost tmp]# gcc challangeRST.c -o challangeRST [mrgrj@localhost tmp]# ./challangeRST !!!!!! !!!!!! !!!!!! !!!!!! !! !!!!!! !! !! !! !! !! !! !! !! !! !! !! !! !! !! !! !! !! !! !!!!!! !! !!!! !!!! !! !! !!!! !! !! !! !! !! !! !! !! !! !! !! !! !! !! !! !! !!!!!! !!!!!! !!!!!! !!!!!! !! !!!! Cum functioneaza programul ? (explicati output-ul) O sa va rog sa folositi buttonul de spoiler in momentul in care dati un raspuns decent. Challange-ul expira vineri la ora 23:59. Solvers: 1. @MasterLight 2. 3.