Jump to content
xisto Community

heaven_master_ash

Members
  • Content Count

    28
  • Joined

  • Last visited

About heaven_master_ash

  • Rank
    Newbie [Level 2]
  • Birthday 05/29/1990

Contact Methods

  • Website URL
    http://www.phpbber.com/phpbb/index.php?mforum=7heaven

Profile Information

  • Location
    India / Mumbai
  • Interests
    I Like Almost Everything But I Like Computer And Internet The Most Thanx..
  1. Heey Nice Signature I Like It U Like Dragon Ball Z I Liked It Very Much The Great Super Saiyan Goku Man Excellent program But It Stopped In Half In India But I Like It And Keep Making Cool Signs Like This Thanx
  2. Well this Other One Thats I Like Muhc Pokemon Is Also Of Toonami Well This Toonami Programs R really Good Normally I watch Every Program Of Toonami And I Never Miss Any episodes Of Any Program Of toonami. Well About Pokemon Its Nice Inspringing Program Great Adventure Program I Like Ash Very Much As My Name Is Also Ash But This Program Is Very very Nice Great adventures Good Battles And Also Effects Are Given great prority Which Makes It Much More Interesting To Watch This Program Go Great Effects Nice Comments And Encourages Us To Do Something Well Thats It From My point Of View If U Have Thoughts About It Please Tell Me THanx...
  3. Well Im a Fan of Beyblade which Comes On Cartoon Network I Know Many More People Will be There Well I Like Tyson Very Much But I Feel Like Im Like kai Kai Is An intreesting Character Actually He Is Just Like Me Only Well Thought And Thing That He Has Me Also Have Very Semilar Thinks Well I Like Beyblade Very Much And Never Miss Any Episode Of Beyblade Well At The Moment tag Team Beyblade Is going On Namely G-revolution I Like It Very Much Well If U Also Like Beyblade Please tell Me Ur Thoughts Thanx..
  4. Well This Is A Very very Easy Topic Every One Know About This thing If U Need Help To Understand Better Refer My Knowledge Gatherance Thanx.. The SQL SELECT statement queries data from tables in the database. The statement begins with the SELECT keyword. The basic SELECT statement has 3 clauses: * SELECT * FROM * WHERE The SELECT clause specifies the table columns that are retrieved. The FROM clause specifies the tables accessed. The WHERE clause specifies which table rows are used. The WHERE clause is optional; if missing, all table rows are used.For example, SELECT name FROM s WHERE city='Rome'This query accesses rows from the table - s. It then filters those rows where the city column contains Rome. Finally, the query retrieves the name column from each filtered row. Using the example s table, this query produces: name MarioA detailed description of the query actions: * The FROM clause accesses the s table. Contents: sno name city S1 Pierre Paris S2 John London S3 Mario Rome * The WHERE clause filters the rows of the FROM table to use those whose city column contains Rome. This chooses a single row from s: sno name city S3 Mario Rome * The SELECT clause retrieves the name column from the rows filtered by the WHERE clause: name MarioThe remainder of this subsection examines the 3 major clauses of the SELECT statement, detailing their syntax and semantics: * SELECT Clause -- specifies the table columns retrieved * FROM Clause -- specifies the tables to be accessed * WHERE Clause -- specifies which rows in the FROM tables to use Extended query capabilities are covered in the next sub-section.SELECT ClauseThe SELECT clause is mandatory. It specifies a list of columns to be retrieved from the tables in the FROM clause. It has the following general format: SELECT [ALL|DISTINCT] select-listselect-list is a list of column names separated by commas. The ALL and DISTINCT specifiers are optional. DISTINCT specifies that duplicate rows are discarded. A duplicate row is when each corresponding select-list column has the same value. The default is ALL, which retains duplicate rows.For example, SELECT descr, color FROM pThe column names in the select list can be qualified by the appropriate table name: SELECT p.descr, p.color FROM pA column in the select list can be renamed by following the column name with the new name. For example: SELECT name supplier, city location FROM sThis produces: supplier location Pierre Paris John London Mario RomeThe select list may also contain expressions. See Expressions.A special select list consisting of a single '*' requests all columns in all tables in the FROM clause. For example, SELECT * FROM sp sno pno qty S1 P1 NULL S2 P1 200 S3 P1 1000 S3 P2 200The * delimiter will retrieve just the columns of a single table when qualified by the table name. For example: SELECT sp.* FROM spThis produces the same result as the previous example.An unqualified * cannot be combined with other elements in the select list; it must be stand alone. However, a qualified * can be combined with other elements. For example, SELECT sp.*, city FROM sp, s WHERE sp.sno=s.sno sno pno qty city S1 P1 NULL Paris S2 P1 200 London S3 P1 1000 Rome S3 P2 200 RomeNote: this is an example of a query joining 2 tables. See Joining Tables.FROM ClauseThe FROM clause always follows the SELECT clause. It lists the tables accessed by the query. For example, SELECT * FROM sWhen the From List contains multiple tables, commas separate the table names. For example, SELECT sp.*, city FROM sp, s WHERE sp.sno=s.snoWhen the From List has multiple tables, they must be joined together. See Joining Tables.Correlation NamesLike columns in the select list, tables in the from list can be renamed by following the table name with the new name. For example, SELECT supplier.name FROM s supplierThe new name is known as the correlation (or range) name for the table. Self joins require correlation names.WHERE ClauseThe WHERE clause is optional. When specified, it always follows the FROM clause. The WHERE clause filters rows from the FROM clause tables. Omitting the WHERE clause specifies that all rows are used.Following the WHERE keyword is a logical expression, also known as a predicate.The predicate evaluates to a SQL logical value -- true, false or unknown. The most basic predicate is a comparison: color = 'Red'This predicate returns: * true -- if the color column contains the string value -- 'Red', * false -- if the color column contains another string value (not 'Red'), or * unknown -- if the color column contains null. Generally, a comparison expression compares the contents of a table column to a literal, as above. A comparison expression may also compare two columns to each other. Table joins use this type of comparison. See Joining Tables.The = (equals) comparison operator compares two values for equality. Additional comparison operators are: * > -- greater than * < -- less than * >= -- greater than or equal to * <= -- less than or equal to * <> -- not equal to For example, SELECT * FROM sp WHERE qty >= 200 sno pno qty S2 P1 200 S3 P1 1000 S3 P2 200Note: In the sp table, the qty column for one of the rows contains null. The comparison - qty >= 200, evaluates to unknown for this row. In the final result of a query, rows with a WHERE clause evaluating to unknown (or false) are eliminated (filtered out).Both operands of a comparison should be the same data type, however automatic conversions are performed between numeric, datetime and interval types. The CAST expression provides explicit type conversions; see Expressions.Extended ComparisonsIn addition to the basic comparisons described above, SQL supports extended comparison operators -- BETWEEN, IN, LIKE and IS NULL. * BETWEEN Operator The BETWEEN operator implements a range comparison, that is, it tests whether a value is between two other values. BETWEEN comparisons have the following format: value-1 [NOT] BETWEEN value-2 AND value-3 This comparison tests if value-1 is greater than or equal to value-2 and less than or equal to value-3. It is equivalent to the following predicate: value-1 >= value-2 AND value-1 <= value-3 Or, if NOT is included: NOT (value-1 >= value-2 AND value-1 <= value-3) For example, SELECT * FROM sp WHERE qty BETWEEN 50 and 500 sno pno qty S2 P1 200 S3 P2 200 * IN Operator The IN operator implements comparison to a list of values, that is, it tests whether a value matches any value in a list of values. IN comparisons have the following general format: value-1 [NOT] IN ( value-2 [, value-3] ... ) This comparison tests if value-1 matches value-2 or matches value-3, and so on. It is equivalent to the following logical predicate: value-1 = value-2 [ OR value-1 = value-3 ] ... or if NOT is included: NOT (value-1 = value-2 [ OR value-1 = value-3 ] ...) For example, SELECT name FROM s WHERE city IN ('Rome','Paris') name Pierre Mario * LIKE Operator The LIKE operator implements a pattern match comparison, that is, it matches a string value against a pattern string containing wild-card characters. The wild-card characters for LIKE are percent -- '%' and underscore -- '_'. Underscore matches any single character. Percent matches zero or more characters. Examples, Match Value Pattern Result 'abc' '_b_' True 'ab' '_b_' False 'abc' '%b%' True 'ab' '%b%' True 'abc' 'a_' False 'ab' 'a_' True 'abc' 'a%_' True 'ab' 'a%_' True LIKE comparison has the following general format: value-1 [NOT] LIKE value-2 [ESCAPE value-3] All values must be string (character). This comparison uses value-2 as a pattern to match value-1. The optional ESCAPE sub-clause specifies an escape character for the pattern, allowing the pattern to use '%' and '_' (and the escape character) for matching. The ESCAPE value must be a single character string. In the pattern, the ESCAPE character precedes any character to be escaped. For example, to match a string ending with '%', use: x LIKE '%/%' ESCAPE '/' A more contrived example that escapes the escape character: y LIKE '/%//%' ESCAPE '/' ... matches any string beginning with '%/'. The optional NOT reverses the result so that: z NOT LIKE 'abc%' is equivalent to: NOT z LIKE 'abc%' * IS NULL Operator A database null in a table column has a special meaning -- the value of the column is not currently known (missing), however its value may be known at a later time. A database null may represent any value in the future, but the value is not available at this time. Since two null columns may eventually be assigned different values, one null can't be compared to another in the conventional way. The following syntax is illegal in SQL: WHERE qty = NULL A special comparison operator -- IS NULL, tests a column for null. It has the following general format: value-1 IS [NOT] NULL This comparison returns true if value-1 contains a null and false otherwise. The optional NOT reverses the result: value-1 IS NOT NULL is equivalent to: NOT value-1 IS NULL For example, SELECT * FROM sp WHERE qty IS NULL sno pno qty S1 P1 NULLLogical OperatorsThe logical operators are AND, OR, NOT. They take logical expressions as operands and produce a logical result (True, False, Unknown). In logical expressions, parentheses are used for grouping. * AND Operator The AND operator combines two logical operands. The operands are comparisons or logical expressions. It has the following general format: predicate-1 AND predicate-2 AND returns: o True -- if both operands evaluate to true o False -- if either operand evaluates to false o Unknown -- otherwise (one operand is true and the other is unknown or both are unknown) Truth tables for AND: AND T F U T T F U F F F F U U F U Input 1 Input 2 AND Result True True True True False False False False False False True False Unknown Unknown Unknown Unknown True Unknown Unknown False False True Unknown Unknown False Unknown False For example, SELECT * FROM sp WHERE sno='S3' AND qty < 500 sno pno qty S3 P2 200 * OR Operator The OR operator combines two logical operands. The operands are comparisons or logical expressions. It has the following general format: predicate-1 OR predicate-2 OR returns: o True -- if either operand evaluates to true o False -- if both operands evaluate to false o Unknown -- otherwise (one operand is false and the other is unknown or both are unknown) Truth tables for OR: OR T F U T T T T F T F U U T U U Input 1 Input 2 OR Result True True True True False True False False False False True True Unknown Unknown Unknown Unknown True True Unknown False Unknown True Unknown True False Unknown Unknown For example, SELECT * FROM s WHERE sno='S3' OR city = 'London' sno name city S2 John London S3 Mario Rome AND has a higher precedence than OR, so the following expression: a OR b AND c is equivalent to: a OR (b AND c) * NOT Operator The NOT operator inverts the result of a comparison expression or a logical expression. It has the following general format: NOT predicate-1 Truth tables for NOT: NOT T F F T U U Input NOT Result True False False True Unknown Unknown Example query: SELECT * FROM sp WHERE NOT sno = 'S3' sno pno qty S1 P1 NULL S2 P1 200 Well Thats It Isnt That Very Very Easy Hope U Find It Help Ful Thanx..
  5. Well this Is My Hard Work On Qbasic So Please Don Underasstimate Me I Have Learned Many Thing And How To Describe Them Today I tell U My Experince Of Qbasic In That Way That Every One Can Understand This Its Easy And nice Simple So Concentrate now.. phew This Was A hard Work Well Hope U Like My Research Thats My 2yrs Works Hope Apricate Thanx..
  6. This Is Java Script tutorial which is very neccessary for webdesgining so contrate and learn its nice and easy
  7. Well Ya Nice Work I Apricate Ur Hard Work Keep Rocking Like That And nice Sencerays nice font well every thing is nice thanx nice beauty
  8. Well Ya Nice Quiz and I Think Its Not For Indians Only Its For Every Body So Play And Enjoy Thanx I Have Given Right Answers Without ur Help Thanx
  9. Hey I Think Xisto is better bcoz it has many facilites that Xisto doesnt have so my vote for Xisto thanx
  10. Well Yaa I Think This Is A Nice Way to Keep Up persons Knowledge About Programming Language. Nice Forum Hope U Keep Up Have Fun Thanx
  11. Hey Excellent Work U Have Worked Very hard For it As I Think But I Have To Say Nice Work excellent Quality And Very Simple And Help Full Keep Posting Like That Thanx
  12. My Collection starts Here:- That's It Thanx.. Well But Wow s2k6 U Got Damn Good Collection.
  13. Well I Dont Put >> --- XX For Credits I Put This For Quality Of Post Which Very Neccessary Bcause They Can Unterstand Only If The Quality of Post Is Good
  14. Greatings to the cyber world............. <><><><><><><><><><><><><><><><><><><><><><><>< >>Beginners Guide In Speeding Up The Pc,Internet and Other stuff<<<< >>>>>>>>>>>>>>>>By Heaven_master_ash<<<<<<<<<<<<<<<< <><><><><><><><><><><><><><><><><><><><><><><>< I spent months trying various but simple MANUAL ways to speed up the pc,IE and various other stuff and writing them down,i now pass them to you,any comments or questions please look me up at heaven_master_ash@yahoo.com and mail it to me. <><><><><><><><><><><><><><><><><><><><><><><>< 1-First the Easy ways: i- click on the desktop>>>Properties>>>Desktop>>>Customize Desktop>>>Uncheck RUN DESKTOP CLEANUP>>Ok ii-Desktop>>>Properties>>>Power>>>Turn off monitor>>>NEVER(not recommended if you spend like 12 hours on the pc or more) iii-Desktop>>>properties>>>Appearance>>>Effects>>>Uncheck USE THE FOLLOWING TRANSITIONS and SHOW SHADIWS UNDER MENUS>>>ok iiii-Desktop>>>properties>>>Settings>>>Advanced>>>change the srr(screen refresh rate) to 75Hz if found>apply iv-Go to internet explorer>>> Properties>>>Content>>>Auto complete>>>Uncheck all but FORMS>>>Apply v-Internet Explorer>>>Properties>>>Connections>>>LAN Settings>>>Automatically detect settings>>ok vi-Click Start>>>Control Panel>>>Printers and other hardwares>>>Mouse>>>Pointer>>>change SCHEME to 3D WHITE SYSTEM SCHEME, and uncheck the ENABLE POINTER SHADOW>>>Ok vii-Control Panel>>>Sounds and audio devices>>>place volume icon in taskbar , then back to Performance and Maintenance>>>system>>>Advanced>>>settings(under Performance)>>>Adjust for best Perforance>>then check : SHOW WINDO CONTENTS WHILE DRAGGING and SMOOTH EDGESON SCREEN FONTS and USE COMMON TASKS IN FOLDER and USE DROP SHADOWS FOR ICON LABELS and USE VIRTUAL STYLES ON WINDOWS AND BUTTONS>>>APPLY>>>Ok. <><><><><><><><><><><><><><><><><><><><><><><>< 2-Now to the more complex but effective ways: viii-My computer>>>right click on C hd (the hd you have ure OS on)>>>properties>>>uncheck ALLOW INDEXING SERVICE TO INDEX THIS DISK FOR FAST SEARCHING>>>ignore and ok all msgs. (THIS IS A VERY EFFECTIVE WAY TO SPEED UP THE HD) Now back to Control panel>>>add/remove programs>>Add/remove windowscomponents>>>uncheck(if checked) INDEXING SERVICES>>>Next ix-IMPORTANT: Now There are many unimportant services that the user does not need tp run the system.These services operate everytime you Boot and EVERY SINGLE ONE OF THOSE have an exploit that can viruses get in threw and leads to a slow Os etc...etc...so it is a good idea to close these holes(exploits) and stop these useless services to both increase security and speed. Let's start doing that : Start>>>Run>>>services.msc>>>ok The Services window will open so now we close the dangerous holes and useless services: The first service:ALERTER right click then Properties>>>a window will appear>> next to STARTUP press the arrow and change the status to DISABLE. DO THE SAME THING FOR THE FOLLOWING SERVICES: AUTOMATC UPDATE CLIPBOOK COMPUTER BROWSER Disributed Link Tracking Client Error reporting service Fast User Switching Fax Human Interface Access Devices Indexing Service IPSEC Services Messenger Net Logon Netmeeting Remote Desktop Sharing Network DDE Network DDE DSDM Portable Media Serial Number Service Remote Desktop Help Session Manager Remote Procedure Call Locator Remote Registry Routing & Remote Access Server SSDP Discovery Service TCP/IP NetBIOS Helper Telnet Terminal Services Universal Plug and Play Device Host Upload Manager Uninterruptible Power Supply Windows Time Wireless Zero ConfiguratioN Workstation <><><><><><><><><><><><><><><><><><><><><><><>< 3-Now WAYS TO INCREASE SEURITY AND SPEED UP THE INTERNET CONNECTION(kinda): x-Double click on the time on the taskbar>>>Internet Time>>>Uncheck AUTOMATICALLY SYNCHRONIZE WITH AN INTERNET TIME SERVER. xi-Right click Mycomputer>>>Properties>>>remote>>Uncheck ALLOW REMOTE ASSISTANCE INVITATION TO BE SENT FROM THIS COMPUTER. xii-Now We speed up the internet more and more but from the REGISTERY: start>>>run>>>regedit>>>HKEY_LOCAL_MACHINE>>>Software>>>Microsoft/Windows>>>Current Version>>>Explorer>>>RemoteComputer>>>NameSpace Look up for the key under the NAme space and Delete it: D6277990-4C6A-11CF-8D87-00AA0060F5BF xii-There are files that slow down the Pc very very much and they aren't important and the OS deletes them anyways every month or week or so.These files can be found in: start>>>Run>>>Prefetch Wipe all the files in it. There is a way actually that prevents the existence of these files FROM THE FIRST PLACE but i DON't Reccomend this: start>>>Run>>>regedit>>>HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Contro l\Session Manager\MemoryManagement\PrefetchParameters Now change the PARAMETER value to: 0- to totally deny these files 1-to allow program files only 2-to allow Operatinf Files only 3-allow All files (best recommended and you can delete the files manually eachtime u remember!Smile <><><><><><><><><>><><><><><><><><><><><><><><> xiii-WAY TO SPPED UP WINDOWS SHUTDOWN: start>>>run>>>regedit>>>HKEY_LOCAL_MACHINE/SYSTEM/CurrentControlSet/Control >>>click control>>>Waittokillservicetimeout>>>right click waittokillservicetimeout>>>modify>>>choose value less than 2000(i put 0). also go to HKEY_CURRENT_USER\Control Panel\Desktop and do the same thing to WAITTOKILLAPPTIMEOUT xiv-DeLeTe ALL TEMP FILES COZ THEY ARE MAJOR SLOWDOWNERS! <><><><><><><><><><><><><><><><><><><><><><><>< xv-STOPPING PROGRAMS THAT OPEN WHEN THE OS BOOTS: start>>>Run>>>msconfig>>>startup>>>uncheck all the programs u dont want them to boot with ure system. xvi-IMPORTANT!!!(u'll thank me for this): How to STOP the error Messages that show without reason at startup: again start>>>run>>>regedit>>>HKEY_LOCAL MACHINE\SYSTEM\CurrentControlSet\Control\Windows>>right click on the right and choose newdword ,name it NoPopupsOnBoot and give it a value of 1 <><><><><><><><><><><><><><><><><><><><><><><>< xvii-WAY TO SPEED UP THE START MENU: start>>>menu>>>regedit>>>HKEY_CURRENT_USER\Control Panel\Desktop>>>look for MENUSHOWDELAY and change its value from 400 to 0,reboot and u'll see the difference. <><><><>><><><><><><><><><><><><><><><><><><><> <><><><><><><><><><><><><><><><><><><><><><><>< Hope u like and benefit from it all,QUESTIONS R WIDELY WELCOMED. ReMeBeR:THE FiRsT STeP 2 KNoWLeDGe iS 2 KNoW HoW 2 SHaRe!Smile . <><><><><><>Written by: Heaven_master_ash<><><><><<><>><>< <><><><><><><><><><Hook me up<><><<><><><><><><><>< <><><><><><><><><><><><><><><><><><><><><><><>< Look forward to my next article: Advanced Html:Lesson1 :Working with multimedia.Peace Smile X----------------------X-----------------------X------------------------X-------------------------X------------------X If You Like My ths Post Do Rate This And Tell Your Thoughts About This Topic Thanx.. Notice from BuffaloHELP: Quoting your phrase, the first step to knowledge is knowing rules before attempting to commit. If you cannot communicate in plain English, how would you be able to receive the proper feedback and respect? This is your last verbal warning regarding slang and leet usage. The forum rule states everyone to use proper English grammar and spelling. Do not, I repeat, do not use unnecessary characters. Study the lists of bbcodes and you'll find that you can structure your essay with LIST, TAB, HIGHLIGHT etc tags.
  15. Help About C & C++ Programming Langauge Prologue I remember the time I started learning C. It was not too long ago. I liked programming, I always did, but I didn't know a lot of languages. The only languages I knew were useless, such as Visual Basic, PHP, ASP, and the basics of Javascript and VBScript. So I decided to learn a real language: C. So I downloaded some tutorials and started reading. The well known "Hello, world!" program didn't cause any difficulties, nor did the few programs after it. But then some new word showed up in the tutorial: "pointer". What was this horrible thing? I kept reading, but I just could not understand it. Maybe it was because my first language wasn't English, and the explenation was too hard? I didn't know - I still don't actually. Maybe my English was too bad back then? Fortunately I didn't give up and kept on reading. I understood everything except for the pointer, and it was a huge pain in the **bottom**. Pointers are used very often in C. And it took a long time before I really understood how pointers worked and yet it was actually very easy... Once you understand it. So I will try to explain it in this tutorial. Basic knowledge of C is required. POINTERS What is a pointer? A pointer is nothing else than an address of some place in the memory. A pointer can be defined like: char* test; In this case, test is a number, not a char as you might think. It's a number - an address to be exact. This address is an address of a place in the memory. Let's describe the memory as a bunch of lines. Every line (-) is one byte. The "^" points to a line, thus to a byte. Now have a look at the following drawing: The "^" points to a byte. It just shows you one place in the memory. It's a pointer(!) to a place in the memory. So the pointer is an address. The address may or may not already point to a valid address in the memory right after you declared it, that depends on the way you declare it: char* test; will NOT point to a valid address in the memory. You will have to make it point somewhere before you read/write from/to it, or else a "Segmentation Fault" will occur. char test[10]; will point to a valid address in the memory. You can read/write from/to the memory, but be careful: you can not read/write more than 10 characters (note the [10]?). If you DO read/write more than 10 characters, a "Segmentation Fault" will occur. Of course this 10 can be changed, which will allow more characters to be read/written. What's the use of pointers? There are many uses of pointers. A lot of functions need pointers to be passed. One example is printf if you want to print a string: it will need a pointer to this string. Another use is the ability to use arrays. You may not know what it means now, but I will cover that later. I do assume you know what printf does and how it works. If you do not, please read the printf manual. Point the pointer In case you define it the first way ("char* test"), it will not yet point to a valid address in the memory. You can make it point somewhere with malloc. Malloc will reserve the specified amount of bytes and return the memory address of this. So malloc will create a place in the memory where you can read/write from/to without any problems. It will "allocate" some space in the memory (malloc = Memory ALLOCate). The malloc function will take the ammount of space to allocate as a parameter and return the pointer to the memory. It will return a "void *", but that doesn't matter since all pointers are actually handled exactly the same. Though, there are differences in how you can read/write from/to the memory, so always use the type you want to read or write. An example: This will allocate 10 bytes (10 bytes, not 10 characters! The size of a character is 1 byte most of the times, but it may differ.), and assign the location of the memory to test. Note that I use "(char*)" before malloc. This will not convert anything and this is not required. Though, if you don't do this your compiler will display a warning ("warning: assignment makes pointer from integer without a cast"), and it is best to have as little warnings in your program as possible. [indent]Malloc or [#]So there are two ways to create a pointer to the memory to write to: char test[10];or char* test;test = (char*)malloc(10); Of course the number 10 can be changed into any number above 0 (although there is a maximum, but you will probably never reach it). There are two differences in these ways. The first difference is that from "char test[10];", the size can not be changed. It will keep a length of 10 characters but you can always re-allocate the space for a "char* test;". The second difference is that "char test[10];" will reserve 10 characters while malloc will reserve 10 bytes if you specify 10 as the parameter. On most machines a character will be 1 byte, but this is not on all machines. You can use "malloc(10 * sizeof(char));" to allocate 10 characters in stead of 10 bytes (sizeof(char) will return the size of one character, multiplied with the number of characters to allocate will be the memory in bytes to allocate). You should always do this so that your program will be portable to other computers. Malloc may fail. This can for example happen when there wasn't enough memory to allocate the specified bytes. If this happens, malloc will return NULL. You should always check whether its NULL after you allocated some space. If you write to a NULL pointer, a "Segmentation Fault" will occur. I will use "[#]" the rest of this tutorial, because that's easier. Note that the other method may be required sometimes, but since that not the case now and "[#]" will only be one line of code, I will use that method. Free If you have a pointer created by malloc which you will not use anymore, you should ALWAYS use free(pointer); (where pointer is the pointer). You must do this before you use malloc on the same pointer again, too. If you do not do this, your program will leak memory. This is bad if it happens once or twice, but can kill your program if it happens very often! But there is another way to kill your program, which you should watch out for, too. You may not EVER free a pointer which either has not yet been allocated, which failed to be allocated or which has been defined with "[#]". If you do this, a "Segmentation Fault" will occur. So to make sure you are not freeing a pointer that failed to be created, you should always add a check before you free it: if(test != NULL)free(test); But if you declared test with "char* test;", test will not be NULL. So if it is not allocated and it tries to free it, the program will crash. This is why you should alway declare pointers you will malloc later with "char* test = NULL;". That way the default will be NULL, and the above check will also prevent it from freeing unallocated parts of the memory. One more tricky part: free will not make the pointer NULL again. So if it is possible it would free it more than once, always use the following check: if(test != NULL){free(test);test = NULL;}test will be set to NULL when freed, and will not be freed anymore until it has been re-allocated. Access the memory one by one You can access the memory on several ways. One way is to access it one by one. I can't say byte by byte, since it differs on how you declared it. For example, if you used a pointer to an integer, this will work integer by integer. If it's to a character it will work character by character. For example, let's define it as a char: char test[10] = "0123456789"; This will allocate the space for 10 characters (10 x sizeof(char) bytes), and put "0123456789" in the memory on that place. Test will point to the first character to this string: "0". Now lets say you have defined a character: "char test2;" and you want to put the second character of test in it. What could you do? What we actually got is nothing else than an array of characters: 10 characters after each other. You can simply access these characters in the memory with "test[#];". Replace the "#" with the number of the character you need, minus one. In this case, "test[0]" equals "0". This way of accessing it will select a char from the memory, not a byte. So in this case, you can pick any number from 0 to 9, and test[#] (where # is your chosen number) will have your number stored as character. Make sure you do not pick a number below 0 or higher than 9, or else it will cause the program to crash with a "Segmentation Fault" or just return a character from another part of the memory. So test[1] will be in the memory with the address test + 1 * sizeof(char). Test[#] will not return a pointer, but a char, but "test + 1 * sizeof(char)" is possible and will return a pointer. Of course, test[2] will be in the memory with the address test + 2 * sizeof(char), etc. You can also get a character of a specified memory address by adding a "*" in front of it. For example, "char test2 = *test;" will put the character test points to in test2. Again, you can also use "char test2 = *(test + 1 * sizeof(char));", which will select the second character in the array. So this means that "test[0]" equals "*test","test[1]" equals "*(test + 1 * strlen(char));","test[2]" equals "*(test + 2 * strlen(char));",and so on. Here, too, you must pay attention: you may not read in a memory location you did not allocate. Otherwise the result will be a character of something different in the memory from or, again, cause a "Segmentation Fault". Of course you can write to the memory the same way: test[0] = 'a';will put the character "a" in the memory ('' is for characters, "" is for pointers to strings), and *test = 10;will put a return character (\n, ascii code 10) in the memory test points to. Value to pointer Let's say you have a character and you would like to know where in the memory it is. It's very simple to do this: just put a "&" in front of the variable you want the pointer of, and it will return a pointer. So: char* test;char test2 = '!'; //This character is somewhere in the memory... but Where?test = &test2; //Ah, there it is! Now test contains the address of the memory where test2 is stored. This can be used on, for example, the following way: char test[11] = "0123456789\0";//\0 Makes sure it ends with a 0-character. If not, the printf//function will just keep on reading until it sees a 0-char.//So it will display characters which should not be shown.//Or may cause a "Segmentation Fault"printf("%s\n", &test[1]); The first thing to explain is the term a "0-character". It's a character with the ascii code 0. In a string, it identifies the end of the string. If this is read, the functions know what the end of the string is. test[1] will select the second character. The & will make a pointer of it. So the pointer to the second character of "0123456789" will be passed, thus the memory address of the character '1' will be passed to printf. Printf will read the memory, and show the characters there. So it will show "123456789". If test[10] would not be 0, it would keep on reading memory outside test's allocated memory, and possible show characters that should not be shown, maybe even complete passwords if you're unlucky or it may crash with a "Segmentation Fault". Copy functions You can use the method described above to assign values to the memory manually. Of course, this is a lot of work for some tasks. For example, if you would want to put "test" in the memory, ending with a 0 character so that you can use it with printf(); later, you could use: char test[5];test[0] = 't';test[1] = 'e';test[2] = 's';test[3] = 't';test[4] = 0;Too much work. And you can't use char test[10] = "0123456789";test = "9876543210"; either, because that would try to put the string "9876543210" somewhere in the memory, and try to put the pointer in test. Not the string itself into the memory where the pointer points to. For this use some functions were developed. I won't cover all of them, but I will cover the ones you will probably use most: - sprintf and snprintf - strcpy and strncpy - memcpy Note that all those functions can cause so called "buffer overflows" these are exploits that can be used for causing the program to crash, or even become (both remote or local) root, or just get a remote shell. You should NEVER try to copy more characters to the destination than allocated for the destination! Check all the data you want to write before you actually write it! sprintf and snprintf I said earlier in this tutorial I assume you know how printf works. That's required to understand this function too: this is simply because the sprintf function is almost identical to the printf function. Everything works exactly the same, but it will require one more paramter: the first parameter has to be the pointer pointing to the place in the memory to write to. The output will unlike the printf function not be sent to the screen, but to the memory the pointer points to. An example: char test[11];sprintf(test, "%s", "0123456789"); will write "0123456789" to the memory where test points to. This string will be terminated with a 0-character so that you can pass it to functions like printf. Note you will have to spare one character for this 0-character too! But this is still unsafe. For this matter, snprintf has been developed. This is almost identical to the sprintf function with one difference: it has one more parameter, inserted between the first and second parameter, which will be the MAXIMUM number of characters to write to the memory. This is including the 0-character, thus: char test[10];snprintf(test, 10, "%s", "0123456789"); Will only print "012345678" to the memory, ended with a 0-character. Note that it will not only stop when the maximum number of characters has been reached, but also when a 0-character is seen. This is because the 10th character is the last character allowed to be written and has to be changed to a 0-character in order be allowed to be passed to functions such as printf, and a lot others. If the string to write is less than the number specified, the number is just ignored. This function is to prevent data from being written to memory where it may not be written. Both functions will return the number of characters successfuly written, the 0-character not counted. For both functions the strings written to the memory will end with a 0-character. strcpy and strncpy Strcpy is even easier than sprintf. Strcpy requires two parameters, both pointers. It will read all data from the memory the second parameter points to and write this to the memory the first parameter points to. It will not stop before it reaches a 0-character (it WILL copy the 0-character too), so you should be 100% sure it ends with one! An example of this function: char test[11];strcpy(test, "0123456789"); will copy "0123456789" to the memory test points to, including the terminating 0-character (which is added automatically, if you use ""). Strncpy will work exactly the same way, except that it allows a third parameter: the MAXIMUM number of characters to copy. It will stop when the 0-character is reached or if the maximum number of characters has been reached. This means it is possible it does not end with a 0-character. For example: char test[5];strncpy(test, "0123456789", 5); will write "01234" to the memory test points to, but it will not be terminated with a 0-character, so you may NOT pass it to functions such as printf before you checked or added the 0-character. This function is to prevent data from being written to memory where it may not be written. memcpy Memcpy is another function to write something to the memory. It works the same as strncpy, except that it will not terminate after a 0-character. This is useful for things other than strings. For example if you have two variables with the same structure, and you want to copy them. The first parameter is the destination, the second the source and the third the number of bytes to write (so it's the same as strncpy). An example: struct sockaddr test;struct sockaddr test2;memcpy(&test, &test2, sizeof(test2)); This will copy test2 to the memory where test is located. Test will be exactly the same as test2 after this. Sizeof(test2) characters were copied, which is the complete size. So everything. Compare functions Now you may need a way to compare two memory locations. For exmaple, are two strings the same, or are two memory locations the same. For this you will need to know three more functions: - strcmp and strncmp - memcmp strcmp and strncmp Strcmp is the easiest function to compare. It compares two strings (both the parameters), and it will return 0 if the strings are the same. Both strings must be terminated with a 0-character. An example: char test[11] = "0123456789";char test2[11] = "9876543210";if(strcmp(test, test2) == 0)printf("The strings are the same (1)\n");strcpy(test2, "0123456789");if(strcmp(test, test2) == 0)printf("The strings are the same (2)\n"); This will only display the string "The strings are the same (2)\n". Thus only the second time there was a match. Strncmp is almost identical, but it will take a third parameter: the number of characters to test. It will ignore all the characters behind this. An example: char test[11] = "0123456789";if(strncmp(test, "01234", 5) == 0)printf("The first 5 characters are equal (1)!\n");if(strncmp(test, "01234!", 6) == 0)printf("The first 6 characters are equal (2)!\n"); This will only display the string "The first 5 characters are equal (1)!\n". Thus only the first time there was a match. memcmp memcmp is identical to strncmp, except that it will not be terminated by the 0-character. This is useful to compare two non-strings, for example structures. Let's take the example from memcpy a bit further: struct sockaddr test;struct sockaddr test2;memcpy(&test, &test2, sizeof(test2));if(memcmp(&test, &test2, sizeof(test2)) == 0)printf("test equals test2\n");This equals both test's. Since they were just copied, they are identical. Comments This version of this textfile is released in astalavista.net and has been written under the name of my group, the Raiders of the Lost Circuit (RLC). You can contact me (Spoofed Existence) using u2u if you got any questions, comments, etc. You can also contact me with u2u if you would like to join the Raiders of the Lost Circuit. We do not yet have a website, but we are working on it. The Raiders of the Lost Circuit is not a hacking group. It's a group of all kind of people: we have (and still need) authors, programmers, researchers, exploits finders and lots more. If you think you are good enough for any job, even when this job isn't mentioned here, u2u me and we will talk about it. And please, DO comment. What isn't clear (enough)? What should be improved?
×
×
  • Create New...

Important Information

Terms of Use | Privacy Policy | Guidelines | We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.