MCPcopy Create free account
hub / github.com/HyperDbg/HyperDbg / GetToken

Function GetToken

hyperdbg/script-engine/code/scanner.c:21–966  ·  view source on GitHub ↗

* @brief reads a token from the input string * * @param c * @param str * @return PSCRIPT_ENGINE_TOKEN */

Source from the content-addressed store, hash-verified

19 * @return PSCRIPT_ENGINE_TOKEN
20 */
21PSCRIPT_ENGINE_TOKEN
22GetToken(char * c, char * str)
23{
24 PSCRIPT_ENGINE_TOKEN Token = NewUnknownToken();
25
26 switch (*c)
27 {
28 case '"':
29 do
30 {
31 *c = sgetc(str);
32
33 if (*c == '\\')
34 {
35 *c = sgetc(str);
36 if (*c == 'n')
37 {
38 AppendByte(Token, '\n');
39 continue;
40 }
41 if (*c == '\\')
42 {
43 AppendByte(Token, '\\');
44 continue;
45 }
46 else if (*c == 't')
47 {
48 AppendByte(Token, '\t');
49 continue;
50 }
51 else if (*c == 'x')
52 {
53 char ByteString[] = "000";
54 INT Len = (INT)strlen(ByteString);
55 int i = 0;
56 for (; i < Len; i++)
57 {
58 *c = sgetc(str);
59 if (!IsHex(*c))
60 break;
61
62 RotateLeftStringOnce(ByteString);
63 ByteString[Len - 1] = *c;
64 }
65
66 if (i == 0 || i == 3)
67 {
68 Token->Type = UNKNOWN;
69 *c = sgetc(str);
70 return Token;
71 }
72 else
73 {
74 InputIdx--;
75 CHAR Num = (CHAR)strtol(ByteString, NULL, 16);
76 AppendByte(Token, Num);
77 }
78 }

Callers 1

ScanFunction · 0.85

Calls 15

NewUnknownTokenFunction · 0.85
sgetcFunction · 0.85
AppendByteFunction · 0.85
IsHexFunction · 0.85
RotateLeftStringOnceFunction · 0.85
IsLetterFunction · 0.85
IsDecimalFunction · 0.85
IsUnderscoreFunction · 0.85
RegisterToIntFunction · 0.85
PseudoRegToIntFunction · 0.85
RemoveTokenFunction · 0.85

Tested by

no test coverage detected