Finding Macintosh file's attributes - objective-c

I will illustrate a use case of my issue.
I have here two files which happen to be the Finder 7.5.5 and Finder 8.1 from legacy Mac OS versions.
If I use Cmd + I I get the following information:
Version:
7.5.5, © Apple Computer, Inc. 1983-96
System 7.5 Version 7.5.3
and
Version:
8.1, Copyright Apple Computer, Inc. 1983-97
Mac OS 8.1
I want to extract these information programatically. However, I am not even sure where it is being hold.
In a small Objective-C project (Foundation) I did the following for the 7.5 file:
NSString * finder7 = [[NSString alloc] initWithString:#"/Users/me/Desktop/Finder7"];
NSFileManager * fileManager = [NSFileManager defaultManager];
NSError * error = nil;
NSDictionary * attr = [fileManager attributesOfItemAtPath:finder7 error:&error];
NSLog(#"%#", attr);
This is the output:
2013-09-25 10:53:30.224 GetAttributes[1164:903] {
NSFileCreationDate = "1996-01-15 12:00:00 +0000";
NSFileExtensionHidden = 0;
NSFileGroupOwnerAccountID = 20;
NSFileGroupOwnerAccountName = staff;
NSFileHFSCreatorCode = 1296122707;
NSFileHFSTypeCode = 1179534418;
NSFileModificationDate = "1996-01-15 12:00:00 +0000";
NSFileOwnerAccountID = 501;
NSFileOwnerAccountName = me;
NSFilePosixPermissions = 493;
NSFileReferenceCount = 1;
NSFileSize = 0;
NSFileSystemFileNumber = 4384377;
NSFileSystemNumber = 234881026;
NSFileType = NSFileTypeRegular;
}
As you can see, there is no reference to version or copyright. I can't open the "app's content" because legacy applications obviously don't have it.
So I figured it could be an extended attribute, so I got the console and did this:
$ ls -l#
-rwxr-xr-x# 1 me staff 0 15 Jan 1996 Finder7
com.apple.FinderInfo 32
com.apple.ResourceFork 503994
-rwxr-xr-x# 1 me staff 3631000 16 Dec 1997 Finder8
com.apple.FinderInfo 32
com.apple.ResourceFork 502012
com.apple.metadata:kMDItemFinderComment 42
Then I found these entries in each of them:
$ xattr -l com.apple.FinderInfo Finder7
(...)
00077AE0 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 |................|
00077AF0 00 00 32 07 55 80 00 00 00 05 37 2E 35 2E 35 25 |..2.U.....7.5.5%|
00077B00 37 2E 35 2E 35 2C 20 A9 20 41 70 70 6C 65 20 43 |7.5.5, . Apple C|
00077B10 6F 6D 70 75 74 65 72 2C 20 49 6E 63 2E 20 31 39 |omputer, Inc. 19|
00077B20 38 33 2D 39 36 00 00 00 2B 00 00 00 00 00 00 00 |83-96...+.......|
(...)
$ xattr -l com.apple.FinderInfo Finder8
(...)
00077330 06 46 69 6E 64 65 72 00 00 00 00 00 00 36 08 10 |.Finder......6..|
00077340 80 00 00 00 03 38 2E 31 2B 38 2E 31 2C 20 43 6F |.....8.1+8.1, Co|
00077350 70 79 72 69 67 68 74 20 41 70 70 6C 65 20 43 6F |pyright Apple Co|
00077360 6D 70 75 74 65 72 2C 20 49 6E 63 2E 20 31 39 38 |mputer, Inc. 198|
00077370 33 2D 39 37 00 00 00 26 01 08 10 80 00 06 46 69 |3-97...&......Fi|
00077380 6E 64 65 72 00 00 00 00 00 00 00 00 00 00 00 00 |nder............|
(...)
I never really used extended attributes, specially in a development. So here I need some light. I see the version numbers are in different positions. How can I get this information straight like the OSX Finder does? I spent several minutes to do it manually and still is not clear to me how the version is stored. Is there other place I can find this information or am I going in the right direction?
Are there Objective-C or C solutions that will do this so I don't need to reinvent the wheel?
I appreciate the help!
I also tried checking rsrc. Found an easter egg just before the version number.

The information is stored in the extended attribute com.apple.ResourceFork. You can use a tool like DeRez to decompile the information.
If you want to programatically access the resource fork, there is the Resource Manager API, but pretty much everything there is deprecated for 10.8. The resource type for version information is the 'vers' resource.

Related

How to identify an IDR frame from the Video packet

I need to be able to inspect ts packets (looking at video PID 481) and determine whether the packet contains an IDR frame. My understanding is that I need to look for a NAL unit start code, and then something else after that to signify it's the start of an IDR frame. Please can someone clarify?
Here's an example of a packet that I think is an IDR frame, but need to be able to prove it from the payload data:
* Packet 2
---- TS Header ----
PID: 481 (0x01E1), header size: 12, sync: 0x47
Error: 0, unit start: 1, priority: 0
Scrambling: 0, continuity counter: 1
Adaptation field: yes (8 bytes), payload: yes (176 bytes)
Discontinuity: 1, random access: 1, ES priority: 0
PCR: 0x000000013A5
---- PES Header ----
Stream id: 0xE0 (Video 0)
PES packet length: 0 (unbounded)
---- Full TS Packet Content ----
47 41 E1 31 07 D0 00 00 00 08 7E E5 00 00 01 E0 00 00 84 C0 0A 31 00 05
E5 CD 11 00 05 AD 8D 00 00 00 01 09 10 00 00 00 01 67 64 00 29 AC D9 40
78 04 4F DE 02 94 04 04 05 00 00 03 00 01 00 00 03 00 32 E6 80 00 F4 24
00 04 F5 8A 49 30 0F 8B 16 CB 00 00 00 01 68 FA A7 CB 00 00 01 06 00 05
95 6C 60 E4 85 80 00 00 01 06 05 FF FF F5 DC 45 E9 BD E6 D9 48 B7 96 2C
D8 20 D9 23 EE EF 78 32 36 34 20 2D 20 63 6F 72 65 20 31 34 38 20 2D 20
48 2E 32 36 34 2F 4D 50 45 47 2D 34 20 41 56 43 20 63 6F 64 65 63 20 2D
20 43 6F 70 79 72 69 67 68 74 20 32 30 30 33 2D 32 30 31 36
Its not possible to tell from that packet. It is however VERY likely it is an IDR. I say its likely, because looking at the NALUs, I can see an AUD 00 00 00 01 09, an SPS 00 00 00 01 67 a PPS 00 00 00 01 68 then an SEI 00 00 01 06
The SEI however takes the remaining bytes of the packet, You will need to continue reading packets from that PID until you fine the next NALU and see if its an IDR.

GET PROCESSING OPTION error with contactless Card

I'm trying to make the call GET PROCESSING OPTION regardless EMV Contactless.
The data is:
6F 42 84 07 A0 00 00 00 04 10 10 A5 37 50 0A 4D 61 73 74 65 72 43 61
72 64 87 01 01 5F 2D 08 69 74 65 6E 66 72 64 65 BF 0C 1A 9F 4D 02 0B
0A 9F 6E 07 03 80 00 00 30 30 00 9F 0A 08 00 01 05 04 00 00 00 00
PDOL is not present. So the GPO call is:
80A8000002830000
But I get the status 6985. What mistake am I making?

Unpacking jPOS ISO8583

I am having this error when I am generating transaction with Magnetic stripe card. Could you suggest what is the problem here?
<receive>
<iso-exception>
org.jpos.iso.IFB_LLLCHAR: Problem unpacking field 54 (java.lang.ArrayIndexOutOfBoundsException: 86) unpacking field=54, consumed=86
org.jpos.iso.ISOException: org.jpos.iso.IFB_LLLCHAR: Problem unpacking field 54 (java.lang.ArrayIndexOutOfBoundsException: 86) unpacking field=54, consumed=86
at org.jpos.iso.ISOBasePackager.unpack(ISOBasePackager.java:340)
at org.jpos.iso.ISOMsg.unpack(ISOMsg.java:468)
at org.jpos.iso.BaseChannel.unpack(BaseChannel.java:965)
at org.jpos.iso.BaseChannel.receive(BaseChannel.java:735)
at org.jpos.iso.ISOServer$Session.run(ISOServer.java:344)
at org.jpos.util.ThreadPool$PooledThread.run(ThreadPool.java:76)
</iso-exception>
--- header ---
0000 00 00 00 00 00 .....
--- data ---
0000 02 00 70 38 04 80 20 80 3F 04 16 94 96 10 03 32 ..p8.. .?......2
0010 13 38 00 00 00 00 00 00 01 88 00 00 00 00 30 11 ..8............0.
0020 11 27 11 28 00 21 00 37 94 96 10 03 32 13 38 00 .'.(.!.7....2.8.
0030 D2 00 89 EC 49 D2 C2 B5 6B 2A 00 39 35 30 30 30 ....I...k*.95000
0040 30 32 30 34 39 36 F0 D2 EB A5 2B 2F AE 2E 00 06 020496....+/....
0050 30 30 30 30 35 30 000050
We have not been fully aware of BITMAP structure at first field. There are 64 bits with and if there are not 64 i.e 62 bits with starting 1, that means 1st and 2nd fields are not presented. Bitmap never starts with 0 so as long as it starts with 1 we need to add incomplete sequence prior to that with zeros.

OTI Copni device Java Card Applet install fails

I have an OTI Copni device and I need to install a .cap file to this Copni device. So I have JCOP tools with Eclipse and I try to upload and install. It then gives this the indicated error. I presume this is happening because of a failed authentication.
cm> /term "winscard:4|SCM Microsystems Inc. SDI011G Contactless Reader 0"
--Opening terminal
> /card -a a000000003000000 -c com.ibm.jc.CardManager
resetCard with timeout: 0 (ms)
--Waiting for card...
ATR=3B 88 80 01 00 73 C8 40 00 00 90 00 62 ;....s.#....b
ATR: T=0, T=1, Hist=0073C84000009000
=> 00 A4 04 00 08 A0 00 00 00 03 00 00 00 00 ..............
(21592 usec)
<= 6F 65 84 08 A0 00 00 00 03 00 00 00 A5 59 9F 65 oe...........Y.e
01 FF 9F 6E 06 47 91 20 17 3F 00 73 4A 06 07 2A ...n.G. .?.sJ..*
86 48 86 FC 6B 01 60 0C 06 0A 2A 86 48 86 FC 6B .H..k.`...*.H..k
02 02 01 01 63 09 06 07 2A 86 48 86 FC 6B 03 64 ....c...*.H..k.d
0B 06 09 2A 86 48 86 FC 6B 04 02 15 65 0B 06 09 ...*.H..k...e...
2B 85 10 86 48 64 02 01 03 66 0C 06 0A 2B 06 01 +...Hd...f...+..
04 01 2A 02 6E 01 02 90 00 ..*.n....
Status: No Error
cm> set-key 255/1/DES-ECB/404142434445464748494a4b4c4d4e4f 255/2/DES-ECB/404142434445464748494a4b4c4d4e4f 255/3/DES-ECB/404142434445464748494a4b4c4d4e4f
cm> init-update 255
=> 80 50 00 00 08 C2 3F 4B C4 BE B6 E5 58 00 .P....?K....X.
(43622 usec)
<= 00 00 32 98 00 09 30 97 06 25 01 02 00 10 68 6C ..2...0..%....hl
E3 CA 2C 2B 4D 2C 4B 0D 0E 62 5F 8C 90 00 ..,+M,K..b_...
Status: No Error
cm> ext-auth plain
=> 84 82 00 00 10 EB FC 66 BC FA 30 91 58 5B 51 FA .......f..0.X[Q.
0C 46 D7 43 C9 .F.C.
(12557 usec)
<= 69 85 i.
Status: Conditions of use not satisfied
jcshell: Error code: 6985 (Conditions of use not satisfied)
jcshell: Wrong response APDU: 6985
Unexpected error; aborting execution
Can someone tell me how to upload a .cap file to this device?
Try ext-auth mac instead, the smart card is probably in the state OP_SECURE, which means that at minimal command MAC is required.
As JCOP tools is not publicly available nor open source, I'd suggest you try a publicly available piece of software instead:
https://github.com/martinpaljak/GlobalPlatform#globalplatform-from-openkms
(as the name of the github repository implies this is self-promotion)

Can't Register assembly in GAC for .NET4, Server 2008 R2

I have a strong-named assembly containing Model classes that can be shared among several applications (WCF Services in IIS) hosted on the same machine.
Instead of each service having their own copy of this DLL in Bin folder, I want to add it to GAC.
I am using a gacutil.exe for .NET4: Microsoft (R) .NET Global Assembly Cache Utility. Version 4.0.30319.1 Copyright (c) Microsoft Corporation. All rights reserved.
The DLL is registered in GAC, but ends up in C:\Windows\Assembly (GAC 2.0) - not in C:\Windows\Microsoft.NET\Assembly (GAC 4).
When I register the DLL in GAC and remove it from Bin folder, my applications fail with:
Could not load file or assembly 'MyCompany.Enterprise.BOM' or one of its dependencies. The system cannot find the file specified. at System.Reflection.RuntimeAssembly._nLoad(AssemblyName fileName, String codeBase, Evidence assemblySecurity, RuntimeAssembly locationHint, StackCrawlMark& stackMark, Boolean throwOnFileNotFound, Boolean forIntrospection, Boolean suppressSecurityChecks)...
Note: Server 2008 R2 is 64-bit, assembly is built for MSIL, .NET 4.0.
I am using gacutil.exe which comes with Windows SDK v7.1 and is in NETFX 4.0 Tools folder.
What can I be missing? I can't think of any alternatives so any ideas are welcome.
EDIT (Manifest):
// Metadata version: v2.0.50727
.assembly extern mscorlib
{
.publickeytoken = (B7 7A 5C 56 19 34 E0 89 ) // .z\V.4..
.ver 2:0:0:0
}
.assembly extern System.Runtime.Serialization
{
.publickeytoken = (B7 7A 5C 56 19 34 E0 89 ) // .z\V.4..
.ver 3:0:0:0
}
.assembly HCS.Enterprise.BOM
{
.custom instance void [mscorlib]System.Runtime.InteropServices.GuidAttribute::.ctor(string) = ( 01 00 24 63 31 34 64 39 31 65 32 2D 30 35 31 65 // ..$c14d91e2-051e
2D 34 66 65 31 2D 38 62 37 30 2D 61 36 36 33 66 // -4fe1-8b70-a663f
39 61 37 62 34 33 35 00 00 ) // 9a7b435..
.custom instance void [mscorlib]System.Reflection.AssemblyKeyFileAttribute::.ctor(string) = ( 01 00 20 43 3A 5C 48 43 53 2E 45 6E 74 65 72 70 // .. C:\HCS.Enterp
72 69 73 65 5C 4B 65 79 5C 48 43 53 4B 65 79 2E // rise\Key\HCSKey.
73 6E 6B 00 00 ) // snk..
// --- The following custom attribute is added automatically, do not uncomment -------
// .custom instance void [mscorlib]System.Diagnostics.DebuggableAttribute::.ctor(valuetype [mscorlib]System.Diagnostics.DebuggableAttribute/DebuggingModes) = ( 01 00 02 00 00 00 00 00 )
.custom instance void [mscorlib]System.Runtime.CompilerServices.CompilationRelaxationsAttribute::.ctor(int32) = ( 01 00 08 00 00 00 00 00 )
.custom instance void [mscorlib]System.Runtime.CompilerServices.RuntimeCompatibilityAttribute::.ctor() = ( 01 00 01 00 54 02 16 57 72 61 70 4E 6F 6E 45 78 // ....T..WrapNonEx
63 65 70 74 69 6F 6E 54 68 72 6F 77 73 01 ) // ceptionThrows.
.custom instance void [mscorlib]System.Reflection.AssemblyFileVersionAttribute::.ctor(string) = ( 01 00 07 31 2E 30 2E 30 2E 30 00 00 ) // ...1.0.0.0..
.custom instance void [mscorlib]System.Reflection.AssemblyTitleAttribute::.ctor(string) = ( 01 00 12 48 43 53 2E 45 6E 74 65 72 70 72 69 73 // ...HCS.Enterpris
65 2E 42 4F 4D 00 00 ) // e.BOM..
.custom instance void [mscorlib]System.Reflection.AssemblyDescriptionAttribute::.ctor(string) = ( 01 00 00 00 00 )
.custom instance void [mscorlib]System.Reflection.AssemblyConfigurationAttribute::.ctor(string) = ( 01 00 00 00 00 )
.custom instance void [mscorlib]System.Reflection.AssemblyCompanyAttribute::.ctor(string) = ( 01 00 0E 48 6F 72 69 7A 6F 6E 2D 42 43 42 53 4E // ...HN
4A 00 00 ) // J..
.custom instance void [mscorlib]System.Reflection.AssemblyProductAttribute::.ctor(string) = ( 01 00 12 48 43 53 2E 45 6E 74 65 72 70 72 69 73 // ...HCS.Enterpris
65 2E 42 4F 4D 00 00 ) // e.BOM..
.custom instance void [mscorlib]System.Reflection.AssemblyCopyrightAttribute::.ctor(string) = ( 01 00 20 43 6F 70 79 72 69 67 68 74 20 C2 A9 20 // .. Copyright ..
48 6F 72 69 7A 6F 6E 2D 42 43 42 53 4E 4A 20 32 // H2
30 31 30 00 00 ) // 010..
.custom instance void [mscorlib]System.Reflection.AssemblyTrademarkAttribute::.ctor(string) = ( 01 00 00 00 00 )
.custom instance void [mscorlib]System.Runtime.InteropServices.ComVisibleAttribute::.ctor(bool) = ( 01 00 00 00 00 )
.publickey = (00 24 00 00 04 80 00 00 94 00 00 00 06 02 00 00 // .$..............
00 24 00 00 52 53 41 31 00 04 00 00 01 00 01 00 // .$..RSA1........
3B 65 DD 3B C7 49 A7 F4 C9 50 BE 27 F9 62 B6 54 // ;e.;.I...P.'.b.T
D1 26 7B DC 5B EF C1 02 59 E8 77 D4 3D F5 2F 50 // .&{.[...Y.w.=./P
94 22 AC C3 B7 07 71 A4 99 D4 FF 10 ED 05 6D 70 // ."....q.......mp
9A 9D 99 DC 33 1F 8A 3F A5 77 2E C5 5F 9D 35 15 // ....3..?.w.._.5.
BA 54 47 47 C2 8B 13 8C 57 57 C6 1E F5 AB 7B D5 // .TGG....WW....{.
B8 87 DD 4A F3 69 01 B2 6B C8 88 99 04 09 19 FC // ...J.i..k.......
5E 51 7E 2A B9 B5 03 80 C9 A3 EA ED EF B8 EC BF // ^Q~*............
EB 97 30 EC D9 E4 36 7C 0F 64 B7 27 9D 29 0D C5 ) // ..0...6|.d.'.)..
.hash algorithm 0x00008004
.ver 1:0:0:0
}
.module HCS.Enterprise.BOM.dll
// MVID: {D4D8B566-6B0D-4F8D-ABD4-C3A1339B4F84}
.imagebase 0x00400000
.file alignment 0x00000200
.stackreserve 0x00100000
.subsystem 0x0003 // WINDOWS_CUI
.corflags 0x00000009 // ILONLY
// Image base: 0x031B0000
As can be seen from the manifest, the Dll is a runtime 2.0 version, so even the gacutil of 4.0 will place it in the 2.0 GAC.
The manifest is created at compile time, so there must be something wrong with your project and/or compilation settings.
I assume you use Visual Studio, so check out the projects (not solutions) settings in the Application tab.