How to Read Private Fields Through Reflection In .net

February 22, 2008

After a long while, no i am not in a mood to blog right now! lol but still i just wanted to share/save this code snippet here in my blog as i could’t  think of a better place :P

Basically this code works on dot net compact framework. and it was written so that i can read a table name that is stored inside a SQLCeResultSet object… this code uses reflection to archive this task :)

//load the assembly by the given name
Assembly asm = Assembly.Load(“System.Data.SqlServerCe”);
//get the type of MetaData the class that holds the needed field
Type MetaData = asm.GetType(“System.Data.SqlServerCe.MetaData”);
//get the Field info for the needed field, baseTableName
FieldInfo FIbaseTableName = MetaData.GetField(“baseTableName”, BindingFlags.Instance | BindingFlags.NonPublic);
//get the FieldInfo for the metadata property in the SQLCeDataReader class.
FieldInfo fi = typeof(SqlCeDataReader).GetField(“metadata”, BindingFlags.Instance | BindingFlags.NonPublic);
//get the metadata array
IList metadataArray = (IList)fi.GetValue(rsSeek);
//get the table name that we want
Debug.Assert(metadataArray.Count > 0);
string tableName = (string) FIbaseTableName.GetValue(metadataArray[0]);

thats it folks, i hope this would help someone out in the future(including my self :) ). read the comments if you have any doubts about how this works.


Debain lenny rocks!

December 2, 2007

hmmm after some time… back to my blog! :) this time i have something really refreshing and fun to rant about… i am a long term ubuntu user.. and btw ubuntu is a grate distro, there is no argument about that(i don’t have one… i mean heck… its a really nice distro.. specially if you are lazy :P ) but i have been experiencing some annoyances with it…

mainly my sound was crashing at random times… like sometimes it works till 2 hours pass ans suddenly… something crashes or messes up… and then the sound it iterating between two points(like if it got stuck when someone was saying “hello!”, i will be hearing hello hello hello…. all the time, until i restart the lap). this was bearable… i mean i was staying with this from the time of ubuntu edgy to ubuntu feisty and finally till gusty came out… i was expecting this will be fixed(i guess this is something with my kernel… some kernel module most probably… this was this issue that i could zero in on.. after all the efforts i have put to it…).

i experienced a huge speed boost after the kernel upgrade(completely fair scheduling…) so actually i was really happy with my ubuntu system :) until i upgraded to gusty and found out that the sound problem is still there! and its not only that… it have got worse… now it is crashing more often and i really really can’t live with this annoyance… so i backed up my data and did a clean installation of gusty in my lap… still no changes… damn… this sucks….

So i wanted to try something new… well yeah debain is hardly something new for me cause after all ubuntu is based on debian. and i have used debain sometime back… it was one of the first ever distros that i have installed by my self… when i first discovered linux…. in those days there were no “easy to use” ubunut isos around ;)

debian is pretty popular for  been a stable os(linux is in general very stable relative to windows and debain is much more solid… hence it is really popular with sys admins… i guess) . and debain was supposed to be simple… and more ‘raw’(in sense that it had less uneeded stuff and was very simple and basic… so that i can really decide what kind of system i want to get installed in my lap). so i downloaded a debain net installer iso. and booted up my lap. but the first time it didn’t just boot up… it got stuck or something… generally linux kernels hang when i boot them in my lap with pcmcia support… so i turned it off and switched to a much safer video mode. then debain booted up to the setup(wich was really fast!!!). and then i just installed a standard sys + laptop support + desktop env(which was gnome by defult.. which i am used to btw(well i was using ubuntu for nearly two years!))…

the installation took about 4 hours i guess… i had a crappy Internet connection and so if you have a better one this time would go down a lot(u people who live in sweeden are really lucky to have all that nice huge pipes!!!).

what really impressed me was the speed of the system!!! its so freaking fast! when comparing with ubuntu! i guess its a bit bloated now…. which is a bit sad.. :(

the default debain sys had most of the stuff working in my lap… it could hibernate, sound works with no problems!!!(so far :D )… so it was pretty much all i needed… the wifi support is something that i am not worried about that much although i can use it… so i really didn’t check whether it works or not… i guess i will have to get some ndiswrapper or something working to get the wifi… which i won’t need so… i won’t prolly do it…

and i feel really good that i am using the real FOSS thing now, the big brother of all distros… debian! btw i am using the unstable testing version.. called lenny… if you are out on the look out for a stable less bloated distro, why not give  a try to debain! its really nice… and it will leave a really fresh feeling in your mind after installation :)


Relationships

October 8, 2007

some times you come across stuff that are really hard to understand. or at least stuff that seems to be really hard to understand. i think i have come across something like that… it have a “property” of mine to like and do things that are normally different… from the things that others do. and i always think in a manner where there are really low number of limits… like freedom… to all of my thoughts or something like that…

so when ever a problem comes to my mind i just try to think of it as freely as possible. now of course i can’t really think about stuff 100% freely… for example. if i am asked to think about MS i can’t hardly think of any good they are doing! :D now of course… they do have good things. but i feel that i am turning out to be a linux/foss fan boy. with time this have happened(and i don’t really see any reason why i should be unhappy about me been a linux fan boy…). hmmm but anyways there are more things to think about now. more things other than stuff like linux(sweet), computers, internet, bit torrent and ratio cheating….

hehe… i think i am in some intermediate state where i must choose whether i should enter a relationship or whether i should leave it. by all logical means this relationship would turn out to be so stupid… :(

she is older and she comes from a different ethnic background… so yeah its a girl ;) lets just list the good’s and bad’s i’ve got cause of this…

been positive let’s start with the good’s

* i feel love after sometime

* have a feeling of been cared by someone

* feel that i am valued

* feel good(kinda evil ;) ) when ‘other’ girls looks at me and this ‘girl’ goes nervous about others looking at me :D hehe…

* i am learning to take up responsibilities i guess…

Bads

* running out of time!

* more money spent on communication(sms… phone bills… :( )

* life feels complicated (i love every thing simple)

* i fear that my parents will find out about this(in that case if they do i am kinda dead…)

* feel this is a waste of time sometimes as all this seems to be very temporary and unrealistic…

* i am confused and i am blogging about this…. ;)

well for me it seems that the goods that i listed are more sillier than the bads…(yeah for you who read this all of them should look silly, i expect this…) but i don’t really wanna loose someone who loves and values me… i mean heck… not every girl falls in love with me!(who am i after all a geek :P hehe… well of course there are geek girls out there too… ;) )


RatioBlaster

September 22, 2007

after some heavy hacking with RM’s source, i have come up with something called RB ;) take a look!

Release of RatioBlaster 0.15 beta

http://www.moofdev.org/forums/index.php/topic,2395.0.html

Download Links

RB skinned version…(this version is OLD, please consider downloading the clean version till a new skinned version is released)

http://www.moofdev.org/forums/index.php?action=dlattach;topic=2395.0;attach=231

RB clean version

http://www.moofdev.org/forums/index.php/topic,2414.0.html

w00t! feel so good to do some programing after all! :P


Reverse Engineering NRPG RM!

September 6, 2007

NRPG Ratiomaster is a small standalone application which fakes upload and download stats of a torrent to almost all bittorrent trackers.
This means that it does NOT rely on your bittorrent client (uTorrent, Azureus, etc.) and it will NOT download/upload the files on a torrent – it only can fake download/upload.
NRPG RatioMaster has hardcoded emulations for the most commonly used BitTorrent clients: uTorrent, BitComet, Azureus, ABC, BitLord, BTuga, BitTornado, Burst, BitTyrant, BitSpirit.

NRPG RM is a RM mod. it is based on RM 1.4. it is actively maintained and have any new features when comparing to RM.  Now i reverced engineered RM. and these days i am busy(well… to be ohenset i am busy watching SG1!!! these days… it have influenced me a damn lot… man i love SG1! its a grate show), getting RM in to a single class. that means i just wanna make a class that will perform normal tasks done by RM. so that i can better hadel it… and improve on it. and if i succesfully complete taking RM in to a class. it will enable me to do a lots of things… hmmm yeah a lot of things! hehe but i have to do the ‘hard part’ first.

I am using VS C# IDE to develop RM. but i have tried out MonoDevelop, #develop… too. #develop is very cool! it is more faster and really responsive than VS… but RM developed in VS. and it seems that GUI designer code of VS is not recognized by #develop :( this is really sad… if it worked that way i could have very easily moved my project to #develop…. it’s GPLed too! so whats more :) lol…

anyways back to NRPG RM. well nrpg rm was not so easy to decompile at first. cause it seemed that it was not a normal .net assembliy!!! lol i tried to  decompile it with .net reflector and some other stuff… even with the defult tool which comes with VS. but no luck it says that it doesn’t have msil headers! :P it seems that nrpg was compiled to native code by the devs… to protect the source may be. given that nrpg reverce engineered RM when he started out his program, i am pretty sure he thought of the possibility that someone can try to decompile nrpg as well. so he must have applied some protection.

nrpg was a nice person cause he released a nrpg version for mono as well! so that people like my self could run it in linux and any other nix that can run mono. thanks nrpg for doing this. but anyways i believe he could not do the same compiling to native code thing to the mono version of nrpg rm. and as a result the version for mono was easily decompiled using dot net reflector(love this piece of software!!!) . ASAF i can understand most of the RM’s basic stuff was not changed. nrpg have made RM a component. which i recognize as the main thing he have done. so by doing that and implementing tabs, he generates components in the runtime. so u can run many RMs simultaneously…

however this way of implementing has its draw backs too…. i think it slows RM a lot… jsut think, every time you call a new tab its a new set of components! it is heavy on memory… and kinda slow too… but it doesn’t mean this nrpg rm is bulshit! it is a very good software…

I could have developed my custom RM upon nrpg’s rm but i think i am better off with modding the clean, original RM. nrpg version have some fancy controls which makes things more heavy on memory… and the code. and hey after all for me, the simple code is much better anyways, its easier to understand it, it easier to change it…

I hope to finish developing my custom version of RM as fast as i can lol hehe if it wasn’t the stargate series i would have finished doing most of the stuff… in the basic RM class implementation. but i am seriously addicted to SG1, and i have to watch at least three episode per day… :D


Reverse Engineering RM

August 28, 2007

RatioMaster is an application designed for spoofing uploads on BitTorrent trackers. It connects to a tracker and behaves like a normal BitTorrent client, but without actually uploading to / downloading from other peers in the swarm. It reports to the tracker that it’s uploading (or downloading or both, it’s your choice) at a certain rate, thus making it useful for artificially increasing your ratio on certain sites that track a user’s overall ratio (total uploaded/total downloaded).

RM is grate. but unfortunately it is not very actively maintained now days… which is bad. i recently decompiled RM. and right now i am having fun hacking it. RM seems to be a very nice app. but i am sure that people like OiNK(n TMT, tracker admins..etc) could have figured out some ’signatures’ that RM process. to catch it in action. i am not sure about this. i don’t know if there was a sig or not. i don’t know what it could be if there is a one(or more than one). It seems RM uses some libraries. etc BytesRoad libs…. so it is possible that some common bug or some sig in these libs can make RM detectable on trackers.

Anyways i did at some custom features to RM and recompiled it. so i can use it for faking of course! :P but it wasn’t very straight forward process. cause when i decompiled RM to c# using

.NET Reflector 5.0 / Lutz Roeder’s .NET Reflector  – www.aisto.com/roeder/dotnet/

the source it produced(which was very good! i was impressed! good work Lutz!!!), could not be loaded in to visual studio. well it was loadable but i couldn’t open the forms in the GUI editor. there were some errors. there was this manager object which gave a whole lot of errors. it was associated with this tray icon control. i removed all the lines that gave errors until it stoped giving me errors!!! :P lol well after wards the GUI editor could show me the RM UI. and i had to do the same editing/commenting for the other form Memory Reader UI. afterwards i tried to compile it. but hey, it gave some errors. two main errors actually. one was in a switch statement.  it couldn’t accept a float variable as the value on which the switch must happen,

like… switch(num) where num is a float. i tried to find a solution to this. but it seems to trouble sum so i replaced the switch with a nested if.  i think its ok to that.

and then there was a list collection class. and it had a problem referring to it while we are inside a foreach loop! arrr… i tried to find something do about this. but again… i didn’t find anything that could make it work. but the good thing was that this class only helped RM to add a log entry!!! so i commented it out(which makes it unusable of cause… but its just adding a line to the log, nothing bad for the operation of the client… i will have to fix it later or sooner…).

after that RM compiled with no errors. and then i added some tiny features like confirming exit.. different tray icon(of a piggy!!! lol oink! ;) ). and i change the nasty ballon behaviour of the tray icon. it keeps displaying em all the time… so i made it clear to the app to not to show them too often. it will wait 15000 mil secs(15 secs) between two baloons been displayed… nice :)

and then i added a new tab, where i hope to add some stuff. some new features… i have one feature there for now. it will stop updating the tracker. just like when you kill RM(not exit it, cause then it sends the stop event to the tracker). i called this the ‘emulation of a client crash’ feature!!! lol.. hehe.. this could let you make a second choice in case you need to… easily… with out having to kill RM through some process manager(windows task manager)…

hmmm… after a long time i am having fun developing something… lol last time i developed something it was a trojen(which i started from scratch, but i used samples yes! :D )… and now its a ratio cheating program! i guess its getting better lol ;)


Know your ‘enemy’

August 21, 2007

I have been working in my new workplace for about a week now. and as far as i can say this place is very nice. its a small software company with some history. it have a friendly set of coworkers, the polices are fine(except the fact that the working hours are from 9am – 6pm, i would like it to be 8-5 ratehr), there are so many ‘treats’(where people get to eat stuff that will make em fat :P ), the salary is fine. and the location is ok too. so this is pretty much the ideal workplace right… hehe you ask me! well there is something that annoys me a lot. its not about the people there or anything like that. its with the way they do ‘work’;)

for whatever things that they do they use microsoft products for that!!!! oh shit! for everything… they blindly use micorsoft products for everything for every purpose. with out considering alternatives. and this is just sooooo annoying for a linux fan like me!(yeah i admit it i am a fan! and hey whats wrong with it? lol i am happy that i am! but don’t get me wrong i am not a ‘fanboy’ rather i am a fan i really really like the idea of FOSS and open source… wow… its one of the best thing ever!)

And i have to learn all that microsoft stuff… i have to learn dot net and not java :( i have learn sql server and not mysql… oohh… this is bad… but hey i am still learning stuff… and i think i have been away form all this MS stuff for a long time and i have almost forgot how much they suck… :D and now that i am working with em again i feel what i really have in linux… the way they think is very different… i mean it its so different. when u compare the philosophies they are so far away from each other(but kinda da same too in ways… ;) )

So for now i’ll have to learn dot net + MS SQL server + alll the compact stuff… hmmm not bad i will ‘learn’ anyways… and they do pay me for that. and btw i am getting the feeling of a programmer lol! its nice been one… at least the way you start to think of stuff , is very nice… its logical… and kinda cool. u have a problem n a solution kinda view for most of the stuff that meets your eye when u r a programmer… I am also happy that now i am more aware of ‘time’… as i kinda lack it… after the job there is little time left… so i feel how important time is..

i might just be more ‘activated’… just because i have to work with MS stuff… as i don’t feel so happy about it i can always use that ‘urge’ i get to develop something ‘open’… during the midnight ;)

haaa… god i believe in u :)


My First Job Interview

August 4, 2007

Yeah, i went to my first ever job interview. and it was ok! :) as far as i can remember i though job interviews are some hard to go through, painful, stressful experiences… but when i look back at what i had in my first thing it was not true. i was kinda comfortable with the people conducted the interview. there were two people. one senior programmer and someone… and of course they asked me all the questions… the normal ones… the ones you expect in a modern day interview… i just felt it when they ask me… in some(mostly all) questions… they were questioning something with out really directly asking me about it. its like they ask a question about something, and then when i answer it they determine my qualities or they just get answers to there hidden questions ;) i think they do check all the attitudes, goals that i may have and all that… and i think i just made them feel that i am a hacker(as seen on TV!)/anti MS, linux lover/BT ratio cheater!/ person with no goals :( lol hehe… i knew it! i knew that i am getting my marks cut or i am getting minus marks when i was telling stuff… which was the plain truth. i should have hidden some stuff and let more positive ones out… so that they will think of me in a positive way… and may hire me… :D

No need to lie… i had a few dreams of the office… the workplace… and how i would work there… lol :D hehe… it was fun… but i know work is not always fun!!! :D hehe…

It was not only the interview… after the interview they asked me to come and sit for a written exam. and they told me that it is IQ and common knowledge…etc.. so i didn’t refresh ma memory on programming… system analysis… etc but when i sat for the exam… and red the paper… i just knew that i was kinda screwed lol… it asked me to draw a ERD.. and then write some SQL queries… dude… lol… how the fuck am i suppose to know that this is IQ!!! LOL :D may be they though that programmers should know these stuff… like normal people know other(normal IQ) stuff…

Any ways it was not all programming/theory questions… there were some IQ stuff… and i answered them… i guess they was correct… i mean my answers… i don’t know… i am not sad about the whole first job interview of mine… its good. i think now i can face the second one with a lot of confidence than my first one… :)

but… i am still young and why the fuck i am going to a job right now… may be i should do more certs… and gain more qulifications… and have some more fun… ! :) (that was a another question that came up in the interview :D )…


I Wanna Decompile em all!

July 28, 2007

I love open source/FOSS software. but unfortunately not all the software out there are open source. and i don’t want all of them to be open source! cause then there will be no interesting flame wars! :P well anyways i have come across some grate cheating softwares/mods. and shu mod is one of them. basically shu mod is a modification(mod) of Azureus. and how come Azureus got modded so easily? its open source :) now although under the GPL’s terms shu mod must also be open source. but it is not. shu is a asshole and he don’t wanna release the source(this is illegal btw :D ). so what would you do if you want to mod shu? well you guessed it, you have to decompile it. well its not hard at all. it seems java programs are easier to decompile. it should be cause by nature the java byte code is supposed to be a universal thing… so i guess it is easier to deal with it. like its not the direct instructions for the CPU… but for the java VM.

Anyways i have a another favorite program called Ratiomaster(RM). which is kinda old now. it is not maintained now. the guys who created it seems to be not intrested any more in developing it…. anyways now i have the need to decompile it. and RM is closed source + it doesn’t brake any laws by not releasing the source unlike the shu mod. it is written in VB.net(i guess), so i will have to decompile the .net code…. it is not soooo hard… i guess! lol :D

I tried coding a java version of RM… but it is not easy for a amature like me to do something like that. i am just starting coding! lol…. so i’ll try decompiling RM and looking at it’s source… and then may be i can look and learn from RM… and then i will be able to implement it in my own java progy… which of course will be open source(GPLd ;) )…


I hear Kaffirs on AIR!

July 19, 2007

i live in a country which is torn by war for about 20+ years. i think the war is older than me myself. and it sucks. but hey i just don’t know how to get rid of this war shit. anyways, recently there have been some air attacks on our capital(this is where i live by the way). and i had the ‘pleasure’ of witnessing some anti aircraft fire in the sky my self. the war is between the gov and terrorists. and recently the terrorists came up with some light aircrafts! and so the gov was kinda forced to invest in some MIGs(some mil air crafts, i don’t know much about em, and i just don’t wanna google it either).

so anyways i am writing about because i heard some of those MIG(actually these were kaffirs, as i got to know later)s flying over our skies today! man they are soooo noisy! It seems that the air force tring to show off! or may be they are just training the pilots. but i think that they should start training them in some other place where there are less number of people living. or else they would be making all of us living in the capital feel like we are living in the middest of war! well we are kinda living in the middest of war. there are suicide bombings going on everywhere in the capital. but still war in the air is something new for us in the capital. although people in the north are quite used to air raids and stuff(it must be really hard for them, but what the fuck… its war… and i have no clue on how someone can ever stop it!)

i wish peace to our country…

oh lord have some mercy on us!