Convert Binary Data to Date - type-conversion

I have the following data: F0 60 5B 50 BB 27 C4 01
I am 99% certain that this represents the date: 21/04/2004 17:11:33
I cannot for the life of me work out how it is encoding it. Am I being dense? I've tried just reading it in as a binary date, but that comes back with a date way in the future. I've tried assuming it's number of ticks since some epoch, but to no avail.
Does anyone have any suggestions?
Edit: The data is from an export of an application over which I have no control. I am trying to extract data from this dump in order to make reporting of the contents of the application a little easier.
Another sample is: 90 53 EC 85 CB B2 C5 01 -> 06/09/2005 11:12:44
I'm only about 50 sure that this date is correct (which is why I didn't include it previously).

I think I'm onto something. If you reverse bytes (so that they read 01 C4 27 BB ... and feed that into DateTime.FromBinary, you'll get 21.04.0404 16:11:33, which is very close digit-wise to your date.

Related

What is the correct way to calculate number of DNS queries/second using Get-DnsServerStatistics?

I am trying to figure out how to get the number of DNS queries/second for each domain controller using PowerShell Get-DnsServerStatistics. I copied some of the relevant outputs below.
I try to figure out what is the time period of getting 11793847 "TotalQueries" ?
Under section "TimeStatistics," does the field "TimeElapsedSinceLastClearStatisticsBetweenRestart" with value 00:00:28 means 28 seconds? There is another field "TimeElapsedSinceServerStart" has value 34.01:35:21 and I don't understand what it means? maybe 34 days 1 hour 35 min 21 second?
But if there are 28 seconds with total 11793847 DNS queries. i.e. 421208 queries/second is seems not true in our environment. Could you please help me out?
TimeStatistics:
==============
**TimeElapsedSinceLastClearedStatisticsBetweenRestart 00:00:28**
LastClearTime 9/7/2021 9:33:20 PM
ServerStartTime 9/7/2021 9:33:20 PM
TimeElapsedSinceLastClearedStatistics 34.01:35:21
TimeElapsedSinceServerStartBetweenRestart 00:00:28
**TimeElapsedSinceServerStart 34.01:35:21**
Query2Statistics:
================
TypeAll 1917
TKeyNego 0
TypeOther 897431
**TotalQueries 11793847**
Your assumptions about the time formats are correct. The *BetweenRestart times are the offline times of your DNS service. The time you are looking for is
TimeElapsedSinceLastClearedStatistics - TimeElapsedSinceLastClearedStatisticsBetweenRestart
This is the timespan in which your DNS service was actually answering queries (34.01:34:53). I recommend to parse the timespans into TimeSpan objects using [System.TimeSpan]::Parse("34.01:35:21"), for example. Then you can easily subtract the timespans like shown above.
The resulting timespan object offers you the TotalSeconds member attribute, which you can use for your ratio calculation (your ratio is about 4 queries/s).

59-60 second Coordinate issue

everyone, who read this.
I found an issue that latitude or longitude of geocoordinate with, for example, 2 minutes and 59 seconds, after converting to decimal format, has value "0.049722", but
2 minutes and 60 seconds has value "0.35", but I thought it must be equal to equal to
3 minutes and 00 seconds, that has value "0.05"
3 minutes and 00 seconds, that has value "0.05"
But again
2 minutes and 61 seconds, that has expected value "0.050278"
Is it global geocoordinate issue or online converter issue?
I use http://the-mostly.ru/konverter_geograficheskikh_koordinat.html
When looking at the source of the respective website, you notice the following line:
if (LAsec==60) {LAsec = 0;LAminutes = LAminutes+1;}
Since LAminutes is still a string, this represents a string concatenation, so 2 is converted to 21 instead of 3.
See: javascript (+) sign concatenates instead of giving sum?
In short, the website is very wrong!
Maybe you should use WolframAlpha for this:
https://www.wolframalpha.com/input/?i=0+deg+2%27+60%22+N,+0+deg+E

Convert MIDI file to list of notes with length and starting time

I am working on a game in Unity that will generate levels from music. I am planning to include simple text files (that don't have to be in a standard format) with the game and parse them to generate the levels. The problem is, I need to be able to convert MIDI files to a text format (preferably not something as complicated as MusicXML). The text files that I will include with the game would ideally consist of a list of notes, each with a length and a starting time (in arbitrary time units). I cannot simply include a music file, as my bullet-hell game will have to precisely time the bullets with the notes.
I do not care what programming language this is in, as this code will not be included with the game. Also, I have never worked with MIDI before in any form. I am happy to use any library and/or free program for this.
Thank you in advance for your help!
You can use any open-source library for parsing MIDI file and convert its data to text file in your desired format. For example, with the DryWetMIDI you can use this code:
public static void ConvertMidiToText(string midiFilePath, string textFilePath)
{
var midiFile = MidiFile.Read(midiFilePath);
File.WriteAllLines(textFilePath,
midiFile.GetNotes()
.Select(n => $"{n.NoteNumber} {n.Time} {n.Length}"));
}
ConvertMidiToText method will produce text files like this:
37 0 480
37 960 480
37 1920 480
37 2400 480
70 2640 192
where first number is note number (60 = C4), second one is starting time in MIDI ticks and the third one is length in MIDI ticks.
You can even write time and length in hours:minutes:seconds format. This code
public static void ConvertMidiToText(string midiFilePath, string textFilePath)
{
var midiFile = MidiFile.Read(midiFilePath);
TempoMap tempoMap = midiFile.GetTempoMap();
File.WriteAllLines(textFilePath,
midiFile.GetNotes()
.Select(n => $"{n.NoteNumber} {n.TimeAs<MetricTimeSpan>(tempoMap)} {n.LengthAs<MetricTimeSpan>(tempoMap)}"));
}
will produce text like this:
37 00:00:00 00:00:00.4800000
37 00:00:00.9600000 00:00:00.4800000
37 00:00:01.9200000 00:00:00.4800000
37 00:00:02.4000000 00:00:00.4800000
70 00:00:02.6400000 00:00:00.1920000

Error loading the subtitle file into my mp4 file

I have already did my subtitle file in notepad and saved it as a SRT file but I couldn't load it in my mp4 file through VLC?
1
00:09:37.570 --> 00:10:80.570
(car speeding across the road)
2
00:11:70.570 --> 00:13:47.570
(screeching of tires)
3
00:13:70.570 --> 00:15:63.570
(car crash)
4
00:15:70.570 --> 00:20:87.570
(sirens)
5
00:24:77.570 --> 00:25:97.570
(phone buzzes)
6
00:34:43.570 --> 00:39:40.570
Hello?
Yes, it's me.
7
00:41:50.570 --> 00:42:73.570
I'm sorry?
8
00:49:90.570 --> 00:51:30.570
Okay, I'm coming.
9
00:54:53.570 --> 01:02:10.570
(scribbles of pen)
10
01:05:00.570 --> 01:06:67.570
[car slows down]
11
01:08:00.570 --> 01:10:57.570
(opening and closing of car door)
12
01:11:43.570 --> 01:16:37.570
Can you take me to St. Patrick's Hospital please?
Thank you.
13
01:21:90.570 --> 01:23:20.570
Um, excuse me?
14
01:25:00.570 --> 01:30:80.570
Uh, I'm Penelope and I'm here to see Chris Wardsworth.
He was brought in an hour ago.
15
01:30:97.570 --> 01:33:63.570
Relationship with patient?
16
01:33:67.570 --> 01:35:97.570
He is my brother.
17
01:38:90.570 --> 01:42:80.570
Go to the elevator and ride up to the fourth floor.
18
01:43:50.570 --> 01:44:77.570
Thank you.
19
01:46:97.570 --> 01:55:90.570
(footsteps along the corridor)
20
02:03:00.570 --> 02:04:77.570
Miss Wardsworth.
21
02:05:90.570 --> 02:08:47.570
Yes?
Come here.
22
02:10:90.570 --> 02:18:00.570
Can you see your marks?
You barely pass your exams!!!
Your brother would have passed it with flying colors.
23
02:19:37.570 --> 02:21:97.570
I'm sorry, I'll work harder next time.
24
02:26:15.570 --> 02:28:90.570
Every bad student said that. She is hopeless.
25
02:39:00.570 --> 02:42:18.570
Hey Carrie!
God, Chris, it's good to see you!
26
02:42:53.570 --> 02:49:07.570
Uh, where’s your troublesome sister?
Oh, who knows. Probably in her room sulking about her marks.
27
02:50:80.570 --> 02:54:07.570
She just won't work hard, isn't it?
She's so lazy.
28
02:54:20.570 --> 02:58:30.570
Oh, I’m sorry you have such a dumb sister.
We can’t change that, can we?
29
03:00:70.570 --> 03:02:90.570
Do you really hate me that much?
30
03:04:00.570 --> 03:07:50.570
I’ll take that as a yes… but why?
31
03:10:30.570 --> 03:17:77.570
Is it because you’re jealous?
You are a perfectionist that hates to lose?
That you’d like to be the better one?
32
03:20:43.570 --> 03:27:60.570
Look I might have teased you when we were younger and…
I really want to apologize for being a jerk.
33
03:28:90.570 --> 03:30:37.570
It's okay.
34
03:30:43.570 --> 03:39:70.570
I know you’re still mad at me. But, from now on we’ll be living together and…
No matter what happens we’ll get through this together, okay?
35
03:41:50.570 --> 03:45:87.570
I promise I’ll always be by your side.
Thank you.
36
04:30:93.570 --> 04:32:13.570
“I love you more than Spongebob loves Patrick”
37
04:37:13.570 --> 04:38:67.570
How do I solve this?
38
04:40:00.570 --> 04:44:30.570
Hey sis, how’re you doing?
Oh my gosh Chris, you came in the right time!
39
04:40:57.570 --> 04:48:30.570
I’m not doing good but, uh…
Do you know how to find "x"?
40
04:48:70.570 --> 04:51:00.570
Oh, geometry. Let me see.
41
04:59:80.570 --> 05:01:67.570
Yeah, there you go.
42
05:02:05.570 --> 05:03:23.570
Oh my gosh, but how???
43
05:03:70.570 --> 05:07:07.570
Uh… maybe it would be easier if you weren’t that stupid?
44
05:07:63.570 --> 05:12:07.570
[inner voice] Nobody likes you, you know?
Ah… Penelope sorry I don’t mean… I don’t mean--
45
05:13:10.570 --> 05:16:23.570
GET OUT! GET OUT I DON’T WANT TO SEE YOU ANYMORE!!!
Penelope!!!
46
05:16:83.570 --> 05:17:93
GO AWAY!!!
47
05:18:27.570 --> 05:22:13.570
Penelope! I’m sorry, uh… Can I…UGH
48
05:38:00.570 --> 05:38:60.570
Goodbye
49
06:37:20.570 --> 06:40:03.570
Chris? Where is he?
50
06:40:83.570 --> 06:45:50.570
He is currently in surgery. The surgeons are trying their best to save him.
51
06:46:00.570 --> 06:51:63.570
He has broken some of his bones, ribs, and he has lost a lot of blood.
52
06:52:28.570 --> 06:54:17.570
But… he’ll be okay, right?
53
06:55:03.570 --> 06:59:27.570
Well, I can’t be certain about that. I apologize.
54
06:59:80.570 --> 07:07:57.570
However, I think you should better be prepared for the worst.
He wasn’t in a good shape when he was brought in.
55
07:10:83.570 --> 07:14:10.570
I’m sorry. We have tried our very best.
56
07:15:60.570 --> 07:18:53.570
But… he lost too much blood.
57
07:23:13.570 --> 07:25:83.570
…May I have a last look of him?
58
07:32:03.570 --> 07:33:93.570
Hey. Chris...
59
07:34:60.570 --> 07:36:93.570
Hey don’t you do this to me!
60
07:38:53.570 --> 07:40:70.570
Why are you dead...
61
07:42:73.570 --> 07:49:80.570
You are my brother…
My only friend and my… and my soulmate in the world…
62
07:50:27.570 --> 07:51:90.570
Why are you dead?
63
07:56:13.570 --> 07:58:33.570
Miss, I’m sorry, you have to leave now.
64
07:59:03.570 --> 08:01:33.570
My team will continue the work.
65
08:02:87.570 --> 08:05:53.570
No, I haven’t said my goodbyes yet…
66
08:10:83.570 --> 08:11:97.570
No...
67
08:12:30.570 --> 08:13:47.570
Please, miss.
68
08:15:47.570 --> 08:16:43.570
Let's go.
69
08:23:25.570 --> 08:24:13.570
NO!!!
70
08:27:93.570 --> 08:30:93.570
Miss. are you alright? We have the accused with us now.
71
08:31:23.570 --> 08:35:33.570
He admitted knocking down Mr. … Mr. Wardsworth.
72
08:36:72.570 --> 08:37:10.570
I'm fine.
73
08:37:90.570 --> 08:39:67.570
Miss Wardsworth, this is Mr. Cheng.
74
08:39:69.570 --> 08:42:10.570
Miss Wardsworth, I swear! I didn’t mean to knock him down!
75
08:42:47.570 --> 08:45:90.570
I- I have had some alcohol and I thought I was okay so I drove anyway.
76
08:46:27.570 --> 08:52:67.570
But- but then- he- when I blinked, and my eyesight was blurry and… he was standing there!
77
08:52:70.570 --> 08:56:37.570
And I tried to swerve away from him! But- but it was too late!!
78
08:56:57.570 --> 08:58:90.570
I tried! I really tried!! I’m sorry!!!
79
08:59:50.570 --> 09:00:27.570
I hate you!!!
80
09:26:97.570 --> 09:27:60.570
Dear Chris,
81
09:28:00.570 --> 09:33:87.570
I don’t know if you will be able to read this one day
But I just want to tell you, I’m sorry.
82
09:34:40.570 --> 09:38:03.570
I miss you so much and I can’t stop thinking about us when we were younger.
83
09:38:70.570 --> 09:43:13.570
I was wondering after all these years, do you still feel ashamed of me?
84
09:43:87.570 --> 09:51:67.570
I am so sorry for blocking you out, but I am always late for everything,
And I only just realized how important you are to me.
85
09:52:37.570 --> 09:56:50.570
You are my soulmate, my teacher, my only friend in life.
86
09:56:90.570 --> 10:01:93.570
Without you, I will never be okay.
I was told to move on, but I can’t.
87
10:02:53.570 --> 10:12:00.570
The guilt of my stupidity and ignorance is eating me alive.
The overwhelming pain assaulted every ounce of my body, especially my heart.
88
10:12:90.570 --> 10:15:40.570
I will never stop regretting for blocking you out.
89
10:16:00.570 --> 10:19:47.570
I miss you. Miss, not missed. Present tense.
90
10:18:83.570 --> 10:21:60.570
Regards, Your sister.
I'm stupid, pls help.bgdfstewasrdtfyguhip[awesrdtfy[]\QEAWRS[WEASRFUOIPO[AERSTRDYFUGIUHOIK
As long as the file that you are playing is a video and returns the number of frames per second, vlc will look for a file with exactly the same name as the video but ending with .srt (i.e. myvideo.avi --> myvideo.srt)
The srt file must be in the same directory as the video file.
You can manually load a subtitle file with Subtitle-->Load subtitle file

How to generate 0xE8 (call) opcode with C++

Basically, what I have is a game which has a function MyFunc(), and it's called on 4 places in the game. One of the addresses is 0x10002000, and the bytes are E8 0B 83 01 00.
I'm injecting a DLL, and want to patch that 0xE8 (call) to my own address. When I do it with Cheat Engine's Auto Assembler and write call MYADDRESS, it generates the proper opcode, and proper bytes.
However, if I do it with the DLL, this is what I get:
What I want to achieve is call 74C611CC. So I need to generate the bytes for the opcode to be like I want instead of what is it currently (in the screenshot)
I use this kind of code:
*(BYTE*) dwPatchAddr = 0xE8;
*(DWORD*) (dwPatchAddr + 1) = (DWORD) myFunc;
An e8 instruction is a relative call instruction, not absolute. So the next 4 bytes need to be the difference between the pc when processing this instruction and your target function. So what you want is:
*(BYTE *)dwPatchAddr = 0xE8;
*(DWORD *)(dwPatchAddr + 1) = (DWORD)((char *)myFunc - (char *)(dwPatchAddr + 5));
Note that the PC address used to compute the offset is actually the address of the next instruction after the call (what will also be pushed as the return address).