This is a creation in Article, where the information may have evolved or changed.
Listen to Golang listen to implement read EXE Listen DLL listen APK hear version number package listen to Mainimport listen to listen to "flag" listen to hear "FMT" listen to listen to "log" listen to hear "OS" listen to hear "Path/filepath") Import Listen (listen to listen to hear the "Github.com/lunny/axmlparser") var listen (listen to listen to hear the file listen to FileInfo) const Listen (listen to hear listen to listen to hear hear listen listen to "MZ" listen to listen to hear PE listen listen hear Listen to listen to listen to hear rsrc listen to listen to listen to listen to listening to hear the "rsrc" listen to Typet listen to listen to listen to hear 16 listen to hear = listen to listen to hear the listening to listen to hear 64 listen to listen to listen to hear the machine listen to listen to hear = 332 listen to listen to the default listen = Listen to ' C:\Windows\System32\ Cmd.exe ') type listen to FileInfo listen to the struct listen {Listen to hear listen to hear string listen to listen to listen to hear the string listen to the version listen to listen to listening to the FilePath listening to hear and hear, listen to the "Debug listen to listen to hear" " Listen to CheckError (Err listen to error) Listen {Listen and listen to hear if listen to err listen to! = Listen to nil listen to listen to hear the log. Fatalln (ERR) listen to hear}}//listen to get EXE hear DLL version Func listen (f listen to *fileinfo) listen to getexeversion (Err listen to error) Listen {Listen to listen to file, listen to err listen: = Listen to the OS. Open (F.filepath) listen and hear f.checkerror (ERR) Listen listen//Listen to the first reading 64 listen to Byte listen to listen to the buffer hear: = Listen to make ([]byte, listen 64) Listen to hear _, listen to err listen = listen to file. Read (buffer) listen to hear f.checkerror (err) listen to hear defer listen to file. Close () Listen and listen to str listen: = Listen to String (Buffer[0]) Listen + listen to string (Buffer[1]) listen to hear if listen to str listen to = listen to MZ Listen {Listen to listen to hear the log. Fatalln ("read EXE error, cannot find listening mz."), listen F. FilePath listen to listen to listen to listen to hear peoffset hear: = Listen to F.unpack ([]byte{buffer[60], listen to buffer[61], listen to buffer[62], listen to buffer[63]}) Listen to hear if listen to the Peoffset listen to < listen to Peoffset listen to listen and listen to listen to the log. Fatalln ("PeOFfset listen to read error. ", listen to F. FilePath) Listen and hear listen/listen/hear read from the beginning of the file to listen to Peoffset, second read listen to 24 listen to byte listen to hear _, listen to err listen = listen to file. Seek (Int64 (Peoffset), listen to 0) listen and listen to buffer listen = listen to make ([]byte, listen 24) Listen and hear _, listen to err listen = listen to file. Read (buffer) listen to hear f.checkerror (err) listen listen to str listen = Listen string (Buffer[0]) Listen + listen to string (Buffer[1]) listen to listen to hear if listen to str listen to/listen to PE Listen {Listen to listen to listen to hear the log. Fatalln ("read EXE error, cannot find listen pe."), listen F. FilePath) Listen and listen to the machine listen: = Listen to F.unpack ([]byte{buffer[4], listen to buffer[5]}) Listen and listen to the If listen to machine listen to! = Listen to machine listen to listen to the log. Fatalln ("Machine listening read error."), listen F. FilePath listen and listen to listen to listen to hear nosections listen: = Listen to F.unpack ([]byte{buffer[6], listen to buffer[7]) listen to listen to the opthdrsize listen to: = Listen to F.unpack ([]byte{buffer [20], hear buffer[21]}) listen to listen//listen read from the current position shift to listen to opthdrsize, third read listen to 40 listen to byte listen to the file. Seek (Int64 (opthdrsize), listen to 1) listen to listen to listen to hear resfound hear: Listen to listen to hear for listen I listen to hear: = Listen to 0, listen to I listen to < listen int (nosections), listen to the i++ hear {listen to listen to listen to listen to listen to listen to listen to listen to Listen to make ([]byte, listen 40) Listen and listen and listen to the file. Read (buffer) Listen and listen listen to str listen = Listen string (Buffer[0]) Listen + listen to string (Buffer[1]) Listen + listen to string (Buffer[2]) Listen + listen to string (Buffer[3]) listen + Listen, listen, listen, listen, listen, listen, listen, listen, listen, listen, listen, listen, listen, hear, hear, hear, hear, hear, hear, hear, hear, hear, hear, hear, hear, hear, hear, hear, hear, hear, hear, hear, hear, hear, hear, hear, hear, hear, hear, hear, Resfound listen to listen to and listen to and listen to the log. Fatalln ("Read EXE error,I can't find it. rsrc. ", listen to F. FilePath listen to listen to listen to listen to hear infovirt hear: = Listen to F.unpack ([]byte{buffer[12], listen to buffer[13], listen to buffer[14], listen to buffer[15]}) listen to listen to listen to the infosize listen to: Listen to F.unpack ([]byte{buffer[16], listen to buffer[17], listen to buffer[18], listen to buffer[19]}) Listen and listen to the Infooff listen to: = Listen to F.unpack ([]byte{buffer[20], Listen to buffer[21], listen to buffer[22], listen to buffer[23) listen to listen//hear read from the beginning of the file to listen to Infooff, fourth read listen to Infosize listen to the File.seek (Int64 ( Infooff), listen to 0 listen to listen to the buffer listen = listen to make ([]byte, listen to infosize) listen to hear _, listen to err listen = listen to file. Read (buffer) Listen to listen to hear f.checkerror (err) Listen to listen to hear nameentries listen: = Listen to F.unpack ([]byte{buffer[12], listen to buffer[13]}) listen to listen to listen to the identries listen to: Listen to F.unpack ([]byte{buffer[14], listen to buffer[15]) listen to listen to the Var listen to Infofound listen to the bool listen to hear the Var listen to the Suboff, listen to I listen to the int64 listen to hear for listen I listen = listen 0; Listen I listen to < listen to ( Nameentries Listen + listen to identries), listen to i++ listen to listen to listen to listen to hear listen to listen to hear typet listen to: = Listen to F.unpack ([]byte{buffer[i*8+16], listen to buffer[i*8+17], listen to buffer[i*8+18] , hear buffer[i*8+19]}) Listen and listen to hear if listen to listen to Typet listen to listen to listen to listen to listen to listen to Typet listen to listen to listen to hear listen to hear hear listen to listen to hear listening and hearing listen to hear heard and heard to listen to listen to listen to listen to listen to listen to listen to listen to listen to listen to listen to listen to ]BYTE{BUFFER[I*8+20], listen to buffer[i*8+21], listen to buffer[i*8+22], listen, listen, hear, hear, listen, listen, hear, hear, listen, hear, hear, listen, hear, listen to listening and hearing. Infofound listen to listen to and listen to and listen to the log. Fatalln ("read EXE error, can't find hear typet listen = = Listen16. "Listen to F. FilePath listen to listen to listen to hear suboff listen to listen to hear suboff listen to listen to hear & hear 0x7fffffff listen to listen to hear Infooff listen to F.unpack ([]byte{buffer[suboff+20], listen to buffer[ SUBOFF+21], listen to buffer[suboff+22], listen to buffer[suboff+23]) listen to//offset listen to the first listen to FileInfo listen to listen Infooff listen to listen to Infooff listen to & Listen to 0x7fffffff listen to hear Infooff listen to listen to F.unpack ([]byte{buffer[infooff+20], listen to buffer[infooff+21], listen to buffer[infooff+22], listen to buffer[ INFOOFF+23]) Listen to//offset listen to the data listen to the Dataoff listen to listen to the listening and listening: = Listen to F.unpack ([]byte{buffer[infooff], listen to buffer[infooff+1], listen to buffer[ INFOOFF+2], listen to buffer[infooff+3]}) listen to listen to listen to hear dataoff listen to listen to Dataoff-listen to the infovirt listen to listen to hear version1 listen to: = Listen to F.unpack ([]byte{buffer[dataoff+ 48], hear buffer[dataoff+48+1]}) listen to hear version2 listen to: = Listen to F.unpack ([]byte{buffer[dataoff+48+2], listen to buffer[dataoff+48+3]}) Listen to listen to Version3 listen: = Listen to F.unpack ([]byte{buffer[dataoff+48+4], listen to buffer[dataoff+48+5]) listen to listen to the version4 listen to: = Listen to F.unpack ([]byte{ BUFFER[DATAOFF+48+6], listen to buffer[dataoff+48+7]) listen and listen to version: = Listen to FMT. Sprintf ("%d.%d.%d.%d", listen to Version2, listen to Version1, listen to Version4, listen to Version3) listen and listen to F. Version Listen = Listen to version listen to hear return listen to Nil}func listen to (f listen to *fileinfo) listen to unpack (b listen to []byte) listen to (num listen to Int64) Listen {Listen listen to listen to I listen to: = Listen to 0; listen I listen < listen to Len (b) Listen to i++ Listen {ListenListen and listen to num listen = listen to 256*num + Listen to Int64 ((B[len (b) -1-i] Listen & listen to 0xFF) listen and listen to listen to the return}//listen to hear the APK listen to the version Func listen (f listen to *fileinfo) Listen to Getapkversion (Err listen to error) Listen {Listen to listen to listen to listener listen to hear: Listen to New (Axmlparser.appnamelistener) listen to listen to hear _, listen to err listen = Listen to axmlparser.parseapk ( F.filepath, listen to listener) listen to listen to F.checkerror (err) listen to hear F. Version Listen = listen to listener. Versionname listen to the return listen to Nil}func listen to init () listen {Listen to and listen to flag. Stringvar (&file. FilePath, listen to "path", listen to default, listen "Get listen exe listen to or listen to the DLL listen or listen to the APK listen to the information.") Listen and listen to flag. Boolvar (&file. Debug, listen to "D", listen to False, listen "If listen to true listen to print listen EXE listen to or listen to the DLL listen to file listen to the name.")} Func listen to Main () listen {Listen and listen to flag. Parse () Listen and listen to suffix listen: = listen to filepath. Ext (file. FilePath listen to the switch listen to suffix listen to listen to the case listen to ". exe", listen to ". dll": Listen to hear and listen to listen to the file. Getexeversion () Listen to the case listen to ". APK": Listen and listen to listen to the file. Getapkversion () Listen and listen to the default: Listen, listen, listen and listen to log. Fatalln ("Can only get exe, DLL, APK version number, please re-enter the program path."), listen to file. FilePath) listen to listen and listen to the switch listen to listen to listen to hear the case listen to file. Debug: Listen, listen, listen and listen to the FMT. Printf ("%s listened to the version number: Listen", listen to file.) FilePath listen to the case and listen to file. FilePath Listen = = Listen to the default: Listen and listen to the flag. Printdefaults () Listen, listen, listen and listen to the FMT. Printf ("%s listened to the version number: Listen", listen to file.) FilePath listen to listen and listen to the FMT. Printf ("%s", listen to file.) Version)}
This article is from the "Codyguo" blog, make sure to keep this source http://codyguo.blog.51cto.com/10440635/1700347