Results 1 to 3 of 3
Thread: Parsing lnk files in windows
- 11-04-2010, 06:07 PM #1
Member
- Join Date
- Oct 2010
- Posts
- 2
- Rep Power
- 0
Parsing lnk files in windows
Does anyone have any experience parsing Windows *.lnk files. I've tried reading them into a byte array but when I evaluate the array byte by byte the 32 bit sequences appear to vary from little endian to big endian. I'm trying to map a lnk file based on the file specs found on Microsoft.com ([MS-SHLLINK]: Shell Link (.LNK) Binary File Format). Please let me know if I'm reading byte output incorrectly or if I'm just missing something. FYI, I'm using an Intel(R) Core(TM)2 Duo CPU X86 processor
See code and output below. Thanks
package com.aMAEze.utilities;
code
import java.util.*;
import javax.swing.*;
import java.io.*;
public class ParseLnkFile
{
public ParseLnkFile(File file)
{
if (file.exists())
{
try
{
loadFile(file);
}
catch (IOException ioe)
{
}
}
for (int ii = 0; ii < bytearray.length ; ii++)
{
System.out.print(Integer.parseInt(new String(bytearray,ii,1),16) + " " );
if ((ii >= 8) && ((ii % 8) ==0)){System.out.print("\n");};
}
}
public ParseLnkFile(String filepath)
{
File file = new File(filepath);
if (file.exists())
{
try
{
loadFile(file);
}
catch (IOException ioe)
{
}
for (int ii = 0; ii < bytearray.length ; ii++)
{
System.out.print(Integer.toString(bytearray[ii],16) + " ");
if ((ii == 7) || ((ii > 8) && (ii % 8) == 0)){System.out.print("\n");};
}
}
}
private byte[] bytearray;
private void loadFile(File file) throws IOException
{
FileInputStream fin = new FileInputStream(file);
ByteArrayOutputStream bout = new ByteArrayOutputStream();
byte[] buff = new byte[256];
int offset = 0;
int numRead = 0;
while (true)
{
int n = fin.read(buff);
if (n == -1){break;};
bout.write(buff,0,n);
}
fin.close();
bytearray = bout.toByteArray();
}
}
output **notice the first 32 bits appear lttle endian according to the specs. 4c 0 0 0 s/b 000 4c as is the second 32 bit segment. Then look at the 4th 32 bit segment and it appears to be big endian -40 0 0 0 appears -40 0 0 0.
4c 0 0 0 1 14 2 0
0 0 0 0 -40 0 0 0 0
0 0 46 -75 0 0 0 10
0 0 0 -34 -45 23 -55 -60
27 -35 1 5 13 -d 66 -65
53 -35 1 22 -1 -10 -7f 4a
4a -35 1 0 0 0 0 0
0 0 0 1 0 0 0 0
0 0 0 0 0 0 0 0
0 0 0 63 0 14 0 1f
50 -20 4f -30 20 -16 3a 69
10 -5e -28 8 0 2b 30 30
-63 19 0 2f 43 3a 5c 0
0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0
0 0 34 0 31 0 0 0
0 0 22 3d 1d 17 10 0
54 45 53 54 0 0 20 0
3 0 4 0 -11 -42 -c 3c
-f 1 2d 3d -6a -45 14 0
0 0 54 0 45 0 53 0
54 0 0 0 14 0 0 0
36 0 0 0 1c 0 0 0
1 0 0 0 1c 0 0 0
2d 0 0 0 0 0 0 0
35 0 0 0 11 0 0 0
3 0 0 0 -1 -5f 8 -18
10 0 0 0 0 43 3a 5c
54 45 53 54 0 0 d 0
2e 0 2e 0 5c 0 2e 0
2e 0 5c 0 2e 0 2e 0
5c 0 54 0 45 0 53 0
54 0 60 0 0 0 3 0
0 -60 58 0 0 0 0 0
0 0 61 6d 61 65 7a 65
0 0 0 0 0 0 0 0
0 0 -76 12 39 -23 18 -22
-4a 49 -67 72 61 45 -7f -c
-6a 29 -34 5d 15 63 -40 -6e
-21 11 -79 29 0 1f 3a 73
-43 -2c -76 12 39 -23 18 -22
-4a 49 -67 72 61 45 -7f -c
-6a 29 -34 5d 15 63 -40 -6e
-21 11 -79 29 0 1f 3a 73
-43 -2c 0 0 0 0Last edited by raysod; 11-04-2010 at 06:29 PM. Reason: adding processor
- 11-04-2010, 08:27 PM #2
I tried it once (in VFP, not Java) but gave up in disgust when I discovered that different Windows versions have differing .lnk formats.Does anyone have any experience parsing Windows *.lnk files.
My purpose was different -- I hoped to create the .lnk from my program without going through the wsshell.script (?) ActiveX.
db
- 11-05-2010, 06:39 PM #3
Member
- Join Date
- Oct 2010
- Posts
- 2
- Rep Power
- 0
Similar Threads
-
Parsing Text Files
By coder09 in forum New To JavaReplies: 6Last Post: 02-18-2009, 12:08 PM -
Opeing multiple pdf files in different acrobat reader windows
By shweta.ahuja in forum Web FrameworksReplies: 2Last Post: 05-07-2008, 12:33 PM -
Parsing MIDI files
By rsk8332 in forum Advanced JavaReplies: 1Last Post: 01-21-2008, 10:43 PM -
packages for parsing docs files
By gabriel in forum Advanced JavaReplies: 1Last Post: 08-06-2007, 03:42 AM


LinkBack URL
About LinkBacks
Reply With Quote

Bookmarks