Showing posts with label code. Show all posts
Showing posts with label code. Show all posts

Friday, March 4, 2016

Parsing PDFs

I am trying to code up a PDF parser in order to parse and sort my huge directory of academic and conference papers. I tried most of the PDF reference manager and organizer(maybe a forthcoming blog post review), but none of them were intuitive, did exactly what I wanted, and did not move or create new files.

I wanted to write a parser in .NET C#, here are my preliminary search results:
  • iTextSharp - GOOD
  • Restrictive license - still the best option
  • PDFSharp - FAIL
  • Failed to parse newer/most PDF - Work around with iTextSharp
      
Do you have a open-source PDF parser you can recommend?
Please comment below, thanks!

Monday, February 29, 2016

Static link .NET assemblies/DLL

Get ILMerge or ILRepack
or
Jeffrey Richter resource load

For ease of use and if you don't want to modify existing code then use ILMerge. Otherwise use the code reflection method.

Method 1:

Note: ILMerge is not able to merge WPF assemblies.

ilmerge /target:winexe /out:SelfContainedProgram.exe 
        Program.exe ClassLibrary1.dll ClassLibrary2.dll
 

Method 2:

Embed DLLs as resources using Visual Studio, then add code,

AppDomain.CurrentDomain.AssemblyResolve += (sender, args) => {  
   String resourceName = "AssemblyLoadingAndReflection." +  
      new AssemblyName(args.Name).Name + ".dll";  
   using (var stream = 
      Assembly.GetExecutingAssembly().GetManifestResourceStream(resourceName)) {  
      Byte[] assemblyData = new Byte[stream.Length];  
      stream.Read(assemblyData, 0, assemblyData.Length);  
      return Assembly.Load(assemblyData);  
   }  
};  

TIP: make sure registering the callback comes before everything
TIP: make sure the resource name is correct, esp. if its in a folder

There's a lot of information out there, let me know if I missed anything.

References
http://www.codeproject.com/Articles/9364/Merging-NET-assemblies-using-ILMerge
http://www.digitallycreated.net/Blog/61/combining-multiple-assemblies-into-a-single-exe-for-a-wpf-application

Saturday, February 27, 2016

Android File Monitoring

Lately I been doing some Android reversing so I have been trying to catch up on the latest Android tools. I immediately tried to find the SysInternal's tool equivalent on Android. Process monitor/File monitor/Registry monitor is a very powerfull anaytic tool that I use all the time on Windows.

Here is what I found for Android
  1. logcat
  2. strace
  3. application specific instrumentation/injection
  4. inotify/FileObserver - monitor specific file/directory for filesystem events
  5. systrace
  6. fsmon - monitor specific file/directory for filesystem events
Wanting to expand my search, I also looked at Linux
  1. auditd
  2. strace/ptrace/dtrace
  3. htop 
      • includes lsof
      • includes strace
      • includes perfmon
  4. top
  5. lsof
  6. inotify
  7. kprobes
  8. perf
  9. Monks- Procmon alternative for Linux - most promising for Linux

TLDR; so in conclusion I did not find anything that was a equivalent replacement for Android, the closest was Monks for Linux.

Please comment if I am missing something obvious.

If I see enough interest/page hits/comments, I will write one, I will probably write one any way ...

COMING SOON